Gazebo Joint's GetForce() returns zero when used in conjunction with SetMaxForce() and SetVelocity()
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
@Daniel L: you'll probably get more response on the Gazebo Answers site.
Thanks for the heads-up. I'll post there too.
To rule out possible causes of unexpected behavior: Are you specifying correct velocity and effort limits in your robot model (URDF or SDF)?.
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.