使用getCurrentJointValues()出错。error:Failed to fetch current robot state
-
我看到moveit2有getCurrentJointValues()这个函数就想尝试用这个函数而不是从/joint_states订阅获取关节弧度。我之前使用moveit::planning_interface::MoveGroupInterface下的轨迹规划,执行的函数都没有问题,但是使用的getCurrentJointValues()就会报错。
我的操作方法是创建完规划组之后直接调用:std::shared_ptr<moveit::planning_interface::MoveGroupInterface> move_group; //创建规划组 move_group = std::make_shared<moveit::planning_interface::MoveGroupInterface>( node, "arm"); auto request = std::make_shared<ArmposeToTrajectory::Request>() ;这样有问题吗。日志是这样的:
tree@Ubuntu22:~/robot2_arm_grasp$ ros2 run arm_grasp_cpp arm_trajectory_execute --ros-args --params-file arm_params.yaml [INFO] [1761873928.650758440] [moveit_rdf_loader.rdf_loader]: Loaded robot model in 0 seconds [INFO] [1761873928.650817331] [moveit_robot_model.robot_model]: Loading robot model 'ar3'... [INFO] [1761873928.871226505] [move_group_interface]: Ready to take commands for planning group arm. [INFO] [1761873929.871342341] [arm_test1]: 等待服务端上线中 [INFO] [1761873930.871580393] [arm_test1]: 等待服务端上线中 [INFO] [1761873931.872255316] [arm_test1]: 等待服务端上线中 [INFO] [1761873932.872432526] [arm_test1]: 等待服务端上线中 [INFO] [1761873933.872572785] [arm_test1]: 等待服务端上线中 [INFO] [1761873933.900059538] [moveit_ros.current_state_monitor]: Listening to joint states on topic 'joint_states' [WARN] [1761873935.001136501] [moveit_ros.current_state_monitor]: No state update received within 100ms of system clock. Have been waiting for 1.000000s, timeout is 1.000000s [INFO] [1761873935.001214462] [moveit_ros.current_state_monitor]: Didn't receive robot state (joint angles) with recent timestamp within 1.000000 seconds. Requested time 300.600000, but latest received state has time 0.000000. Check clock synchronization if your are running ROS across multiple machines! [ERROR] [1761873935.001258905] [move_group_interface]: Failed to fetch current robot state [ros2run]: Segmentation fault我的rviz2和gazebo和ros2control都设置{use_sim_time: True}了,/joint_states和/clock都在正常发布。日志可以看到MoveGroupInterface 已经成功初始化了