ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

failed to fetch current robot state

asked 2018-09-03 11:34:19 -0500

iabadia gravatar image

Dear all,

I want to use MoveIt to make Baxter follow a trajectory in cartesian space (first on simulation and then on the real robot). Unfortunately I am facing an issue when trying to get the robot's current joints state and have no clue on how to fix it (I have already tried the remapping from="joint_states" to="robot/joint_states as suggested in many posts).

Here is the procedure I'm following:

-Launch Baxter in Gazebo as usual.

 roslaunch baxter_gazebo baxter_world.launch

-Launch the joint trajectory action server and baxter_moveit. This I do all together in a launch file as follows:

    <!-- Run joint trajectory action server node (required for MoveIt!) -->
    <node pkg="baxter_interface" type="" name="trajectory_node" >
    <!-- Run launch file that runs MoveIt!. Remap the joint state topic -->
    <include file="$(find baxter_moveit_config)/launch/baxter_grippers.launch"/>
      <remap from="joint_states" to="robot/joint_states"/>

-Then launch the following very simple node just to test that it's working fine:

#!/usr/bin/env python
import sys
import copy
import rospy
import moveit_commander
import moveit_msgs.msg
import geometry_msgs.msg
from math import pi
from std_msgs.msg import String
from moveit_commander.conversions import pose_to_list

class Simple_test(object):

    def __init__(self):
        rospy.init_node('simple_node', anonymous=True)
        robot = moveit_commander.RobotCommander()
        scene = moveit_commander.PlanningSceneInterface()
        left_group = moveit_commander.MoveGroupCommander('left_arm')

        planning_frame = left_group.get_planning_frame()
        print "============ Reference frame: %s" % planning_frame

        eef_link = left_group.get_end_effector_link()
        print "============ End effector: %s" % eef_link

        group_names = robot.get_group_names()
        print "============ Robot Groups:", robot.get_group_names()

        print "============ Printing robot state"
        print robot.get_current_state()
        print ""

        print "============ Current values:"
        current_state = left_group.get_current_joint_values()
        print current_state

def main():
    print ("Creating Simple_Test")
    example = Simple_test()

if __name__ == '__main__':
    except rospy.ROSInterruptException:

It works fine until it reaches the "Printing robot state" part, where it shows 0.0 position for every joint (when that's not the real position of the joints) and then in the "current values" part it displays the error "Failed to fetch current robot state". As follows:

============ Printing robot state
[ WARN] [1535990091.503402457, 271.621000000]: Joint values for monitored state are requested but the full state is not known
    seq: 0
      secs: 0
      nsecs:         0
    frame_id: "/world"
  name: [head_pan, left_s0, left_s1, left_e0, left_e1, left_w0, left_w1, left_w2, l_gripper_l_finger_joint,
  l_gripper_r_finger_joint, right_s0, right_s1, right_e0, right_e1, right_w0, right_w1,
  right_w2, r_gripper_l_finger_joint, r_gripper_r_finger_joint]
  position: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
  velocity: []
  effort: []
    seq: 0
      secs: 0
      nsecs:         0
    frame_id: "/world"
  joint_names: []
  transforms: []
  twist: []
  wrench: []
attached_collision_objects: []
is_diff: False

============ Current values:
[ INFO] [1535990092.513833652, 272.248000000]: Didn't received robot state (joint angles) with recent timestamp within 1 seconds.
Check clock synchronization if your are running ROS across multiple machines!
[ERROR] [1535990092.513963976, 272.248000000]: Failed to fetch current robot state

I have also tried doing the remapping via command line instead of doing it in the launch file as follows:

rostopic echo /robot ...
edit retag flag offensive close merge delete


Hello. I met the same error. Have you fixed it? Could you help me to figure out what is wrong?

zhanghanbo163 gravatar image zhanghanbo163  ( 2019-03-20 03:37:12 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2020-04-05 22:54:21 -0500

lililiw gravatar image

Just as an explanation: MoveGroupInterface::getCurrentPose() relies on ROS spinning being active.Hence, the spinning needs to be started before this call. The only standard way to accomplish this (without blocking) is to use an AsyncSpinner. There is no issue in using more than one thread for the asynchronous spinner - despite the fact that message processing order is not guaranteed anymore.

ros::AsyncSpinner spinner(1); 
edit flag offensive delete link more


Can you please tell how to do this in python? If someone has tried it, please let me know. Thanks

Akr2712 gravatar image Akr2712  ( 2022-02-19 11:19:30 -0500 )edit

Also curious how to do this in python

Roboticist234 gravatar image Roboticist234  ( 2022-02-24 11:14:29 -0500 )edit

I am trying to do the same in python, let me know if you manage to find how and I will do the same. Thanks

Akr2712 gravatar image Akr2712  ( 2022-02-26 05:34:39 -0500 )edit

Question Tools

1 follower


Asked: 2018-09-03 11:34:19 -0500

Seen: 3,624 times

Last updated: Sep 03 '18