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

asked 2018-12-05 18:03:20 -0500

FabianMene gravatar image

updated 2018-12-11 10:12:58 -0500

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().

edit retag flag offensive close merge delete

Comments

Can you post your model and steps to reproduce what you are seeing?

nkoenig gravatar imagenkoenig ( 2018-12-06 10:08:42 -0500 )edit

Thanks for the info. Just to confirm, you found a solution to your problem?

nkoenig gravatar imagenkoenig ( 2018-12-11 16:48:09 -0500 )edit

I found an approach that promises to work for me at least. It is not exactly an answer to the issue with GetAngle in general, which is why I didn't post it as an answer. Any potential further issues on my side will lie with precision in general, not with GetAngle in particular though.

FabianMene gravatar imageFabianMene ( 2018-12-11 17:22:39 -0500 )edit