Moveit Error: Failed to fetch current robot state

在获取Moveit中机械臂当前状态时遇到报错:Failed to fetch current robot state

获取当前位置代码如下:

  // Get the current pose of the end effector
  geometry_msgs::msg::Pose current_pose = move_group_interface.getCurrentPose().pose;

  // Print the current pose
  RCLCPP_INFO(node->get_logger(), "Current Pose:");
  RCLCPP_INFO(node->get_logger(), "Position: [x: %f, y: %f, z: %f]",
              current_pose.position.x, current_pose.position.y, current_pose.position.z);
  RCLCPP_INFO(node->get_logger(), "Orientation: [x: %f, y: %f, z: %f, w: %f]",
              current_pose.orientation.x, current_pose.orientation.y,
              current_pose.orientation.z, current_pose.orientation.w);

经排查发现是未在功能函数中对ROS消息回调进行异步处理,增加异步处理程序:

  // Create an executor and spin it in a separate thread
  rclcpp::executors::MultiThreadedExecutor executor;
  executor.add_node(node);

  std::thread executor_thread([&executor]() {
    executor.spin();

问题解决。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值