Gazebo Joint's GetForce() returns zero when used in conjunction with SetMaxForce() and SetVelocity()

asked 2015-01-15 10:00:17 -0500

Daniel L gravatar image

I am writing my own robot sim interface (to replace the DefaultRobotSim plugin for our robot), and gazebo::physics::Joint::GetForce() returns zero when velocities are sent directly to the simulator through gazebo::physics::Joint::SetVelocity() + gazebo::physics::Joint::SetMaxForce(). The function starts to return values different from zero for a particular joint when a command has been issued to it from Gazebo GUI's Joints pane, where force, velocity, or position can be set. But until the pane is not used, GetForce() returns zero even if a controller from ros_control is active and the robot is moving. Is there a way to get non-zero force values without having to use the Joints pane first?

The functions gazebo::physics::Joint::GetAngle() and gazebo::physics::Joint::GetVelocity() return non-zero values from the beginning as expected.

To make sure the problem was not related with my robot sim interface, I tested using DefaultRobotSim with standard ros_control controllers. I got the same results. The problem does not happen if gazebo::physics::Joint::SetForce() is used instead of SetVelocity(), and SetMaxForce() is not called. I found a similar question in ROS Answers, but in that case, GetForce() seemed to return zero always because the function was not implemented yet.

ROS Indigo Gazebo version: 2.2.3 gazebo_ros_control: 2.4.6

edit retag flag offensive close merge delete

Comments

@Daniel L: you'll probably get more response on the Gazebo Answers site.

gvdhoorn gravatar image gvdhoorn  ( 2015-01-19 05:51:22 -0500 )edit

Thanks for the heads-up. I'll post there too.

Daniel L gravatar image Daniel L  ( 2015-01-19 13:37:54 -0500 )edit

To rule out possible causes of unexpected behavior: Are you specifying correct velocity and effort limits in your robot model (URDF or SDF)?.

Adolfo Rodriguez T gravatar image Adolfo Rodriguez T  ( 2015-01-23 03:03:14 -0500 )edit

I think so, since I can see they are correctly enforced. There is a similar question in Gazebo's forum. The strange thing is that after I send some commands through the panes, I can read forces afterwards.

Daniel L gravatar image Daniel L  ( 2015-01-24 16:52:26 -0500 )edit