Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add dummy physics for imu sensor to make gyro work #101

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jgueldenstein
Copy link
Contributor

The gyro needs to be child to a Node with a a Physics element. Otherwise the following warning will pop up:
WARNING: DEF Robot <robotname> (PROTO) > HingeJoint > Solid > HingeJoint > Solid > Solid > Gyro: this node or its parents requires a 'physics' field to be functional.

In URDFs there is often an extra frame for an IMU which is attached by a fixed joint to the actual link the imu is attached to.

This PR adds a dummy physics node to the link holding the imu similar to the dummy physics added so tools don't fall off here:

# add dummy physics and bounding object, so tools don't fall off

@jgueldenstein
Copy link
Contributor Author

The relevant part of the generated proto:

Solid {
  translation -0.025450 0.053500 -0.023500
  rotation -1.000000 -0.000000 -0.000000 1.570800
  physics Physics {
  }
  boundingObject Box {
  size 0.01 0.01 0.01
  }
  children [
    Accelerometer {
      name "imu_head accelerometer"
    }
    Gyro {
      name "imu_head gyro"
    }
    Compass {
      name "imu_head compass"
    }
  ]
  name "imu_frame_2"
}

@omichel omichel self-requested a review January 16, 2021 08:19
@omichel omichel added enhancement New feature or request bug Something isn't working labels Jan 16, 2021
@omichel
Copy link
Member

omichel commented Jan 16, 2021

I am not sure this is the best way to address the problem. Adding a dummy physics-enable object will cause other problems, including performance drop and instability due to this useless mass. Instead, we should remove the intermediate Solid so that the Gyro is a direct child of the upper parent Solid which has physics, so instead, the relevant part should look like that:

Accelerometer {
  translation -0.025450 0.053500 -0.023500
  rotation -1.000000 -0.000000 -0.000000 1.570800
  name "imu_head accelerometer"
}
Gyro {
  translation -0.025450 0.053500 -0.023500
  rotation -1.000000 -0.000000 -0.000000 1.570800
  name "imu_head gyro"
}
Compass {
  translation -0.025450 0.053500 -0.023500
  rotation -1.000000 -0.000000 -0.000000 1.570800
  name "imu_head compass"
}

@jgueldenstein
Copy link
Contributor Author

I agree and will work on it, a problem is if there are multiple fixed joints in series the first link/solid with physics when going up the kinematic chain towards the root should be used. The transforms would have to be multiplied.

@omichel
Copy link
Member

omichel commented Jan 18, 2021

Note: Webots has a mechanism called Solid merger that avoids to create fixed joints. Instead, it multiplies transforms to merge them together into a single Solid, adding masses of each part. So, you should not worry about this in the PROTO file.

@jgueldenstein
Copy link
Contributor Author

I have tested the solution you proposed but it only works if there is a Physics node in the direct parent.

I think a better solution might be to make the following call recursive and adapt the transformation matrix. https://github.com/cyberbotics/webots/blob/a05248b57540c72651f7353dfd34718c8ffaceba/src/webots/nodes/WbGyro.cpp#L150

What do you think about this solution?

@jgueldenstein
Copy link
Contributor Author

Or somethink like here could be done: https://github.com/cyberbotics/webots/blob/a05248b57540c72651f7353dfd34718c8ffaceba/src/webots/nodes/WbAccelerometer.cpp#L154

@omichel
Copy link
Member

omichel commented Jan 21, 2021

Or somethink like here could be done: https://github.com/cyberbotics/webots/blob/a05248b57540c72651f7353dfd34718c8ffaceba/src/webots/nodes/WbAccelerometer.cpp#L154

Yes, this is exactly what I meant. I believe this is way to go.

@StefanFabian
Copy link

Any update on this?
We're having the same problem and this PR is of great interest to us!

@jgueldenstein
Copy link
Contributor Author

We currently just add a dummy physics node to the Solid which has the IMU as children but I would like to fix this in webots in the future, I just have not gotten to it. It is a bit more complicated than I thought though since the acceleration is not the same as the first parent node with physics if there is a transform in between.

@omichel
Copy link
Member

omichel commented Feb 22, 2021

@jgueldenstein: I am happy to help you if you have any question and to review your patch proposals.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Development

Successfully merging this pull request may close these issues.

3 participants