ros-simulation / gazebo_ros_pkgs

Wrappers, tools and additional API's for using ROS with Gazebo
http://wiki.ros.org/gazebo_ros_pkgs
756 stars 770 forks source link

/joint_states keep providing wrong data after robot collision with some object in Gazebo #682

Open jacknlliu opened 6 years ago

jacknlliu commented 6 years ago

After robot and an object have a collision, and if the joint trajectory controller still sends joint positions to the robot, the /joint_states will return the wrong data, even if the robot has been moved to another position! And the joint_trajectory_controller/state also return wrong data!

/joint_states can't return normal data from the current model state!

/joint_states:

header: 
  seq: 14205682
  stamp: 
    secs: 71085
    nsecs: 101000000
  frame_id: ''
name: ['elbow_joint', 'shoulder_lift_joint', 'shoulder_pan_joint', 'wrist_1_joint', 'wrist_2_joint', 'wrist_3_joint']
position: [-8.51584976541768, -22393.868370150947, -23210.903847882473, -23059.99195414233, 7.4320796024417355, 9.18637489720941]
velocity: [0.00021875832846863282, 0.00585327683488699, 0.003416905486500389, -0.0001427822974524656, 6.232113829809081e-05, 1.6280227906504893e-06]
effort: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]

NOTE: the joint positions are too large and exceeds the joint limit!

How to fix it? Something related to gazebo_ros_control? We need the correct joint state to control the robot.

I used Ubuntu 16.04, ROS kinetic, and gazebo7.

https://github.com/ros-controls/ros_controllers/issues/313

baoyufuyou commented 2 years ago

For gazebo9 + ubuntu 18.04 + ROS melodic, there is still the same issue. It seems that the joint->GetAngle() doesn't work in gazebo9. Is there solution for this issue? Thanks. @

#if GAZEBO_MAJOR_VERSION >= 8
        double position = joint->Position ( 0 );
#else
        double position = joint->GetAngle ( 0 ).Radian();
#endif
        joint_state_.name[i] = joint->GetName();
        joint_state_.position[i] = position;
        joint_state_.velocity[i] = velocity;