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

Revision history [back]

  1. Move the move_group_ initialization outside of the callback. For example, moveit::planning_interface::MoveGroupInterface move_group_("arm"); should be written outside the callback, i.e., msgCallback1.
  2. Remove unnecessary variables temp_orientation, kinematics_pose, and target_pose to clean your code as shown below:

    void msgCallback1(const mpu6050_msg::msg_xyz::ConstPtr& msg)
    {
      ROS_INFO("time = %d", msg->stamp.sec);
      ROS_INFO("x = %lf", msg->t_x);
      ROS_INFO("y = %lf", msg->t_y);
      ROS_INFO("z = %lf", msg->t_z);
    
      move_group_.setPositionTarget(msg->t_x, msg->t_y, msg->t_z);
      move_group_.move();
    }