Gazebo | Ignition | Community
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Physics::Joint::GetAngle() returning incorrect values close to 0

I'm modeling elastic links by revolute joints with a certain spring stiffness, where the interest lies in the oscillation of the links. Information about the joint coordinates have to be sent to MATLAB, for which I am using ROS. To access the joint coordinates, I have a Gazebo Plugin that calls joint->GetAngle(0).Radian() and publishes the returned value as a ROS message.

The problem I am facing lies in the reported values when the joint is close to 0. Within a certain range from -phi to phi (where phi is some small value in the order of 0.01 rad), all values get reported as either phi or -phi (seemingly randomly).

To visualize this, here is a plot of reported values over time while exhibiting some damped oscillation: image description

The excitation of oscillation takes place at roughly 5s, the thick "blocks" are rapidly, randomly alternating jumps from -0.0137 to 0.0137.

I understand that these small angles may not be all that relevant for typical robotic joints, but with small oscillations they become very significant and prohibit me from acquiring sensible data. What can I do to get accurate values?

Some things I can say so far:

  • The value of phi is not fixed. It changes with each launch of gazebo and depends on things like inertia
  • It also varies very slightly within the same setting
  • I can definitely rule out MATLAB or ROS as the cause
  • On a link with no attached masses, phi is several orders of magnitude smaller

Physics::Joint::GetAngle() returning incorrect values close to 0

I'm modeling elastic links by revolute joints with a certain spring stiffness, where the interest lies in the oscillation of the links. Information about the joint coordinates have to be sent to MATLAB, for which I am using ROS. To access the joint coordinates, I have a Gazebo Plugin that calls joint->GetAngle(0).Radian() and publishes the returned value as a ROS message.

The problem I am facing lies in the reported values when the joint is close to 0. Within a certain range from -phi to phi (where phi is some small value in the order of 0.01 rad), all values get reported as either phi or -phi (seemingly randomly).

To visualize this, here is a plot of reported values over time while exhibiting some damped oscillation: image description

The excitation of oscillation takes place at roughly 5s, the thick "blocks" are rapidly, randomly alternating jumps from -0.0137 to 0.0137.

I understand that these small angles may not be all that relevant for typical robotic joints, but with small oscillations they become very significant and prohibit me from acquiring sensible data. What can I do to get accurate values?

Some things I can say so far:

  • The value of phi is not fixed. It changes with each launch of gazebo and depends on things like inertia
  • It also varies very slightly within the same setting
  • I can definitely rule out MATLAB or ROS as the cause
  • On a link with no attached masses, phi is several orders of magnitude smaller

Update:

Sadly I'm not allowed to post the model.

While not exactly an answer to the problem with GetAngle(), I was able to circumvent this issue by instead calling GetWorldPose() on the respective links and calculating the relative pose from that.

This figure shows the difference between values reported by GetAngle and those calculated from GetWorldPose (zoomed in to show the comparison). The setting is a a bit different from what the above figure showed, but we can see the same issues from GetAngle as before.

image description

I do not know how the underlying link poses are stored in gazebo, but to me it would appear as if some precision is lost in the calculations behind GetAngle().