MoveGroup类
MoveGroup类提供了许多控制机器人的功能,比如:设置关节角度或目标位姿,进行运动规划和控制机器人运动等。
实例
1.设置规划组
#include <moveit/move_group_interface/move_group_interface.h>
#define PLANNING_GROUP "robot_arm"
moveit::planning_interface::MoveGroupInterface group(PLANNING_GROUP);
2.设置机器人位姿
#include <geometry_msgs/Pose.h>
geometry_msgs::Pose target_pose;
target_pose.position.x = 0.0;
target_pose.position.y = 0.0;
target_pose.position.z = 0.0;
group.setPoseTarget(target_pose);
3.设置机器人关节角度
#include <vector>
using namespace std;
vector<double> joint_states; //空对象
moveit::core::RobotStatePtr current_state = group.getCurrentState();
const robot_state::JointModelGroup* joint_model_group = group.getCurrentState()->getJointModelGroup(PLANNING_GROUP);
//获取当前的关节角度
current_state->copyJointGroupPosition(joint_model_group, joint_states);
//joint_states.push_back(0.0); //为空对象时才使用,压入元素
joint_states[0] = 0.0;
group.setJointValueTarget(joint_states);
4.控制机器人运动
moveit::planning_interface::MoveGroupInterface::Plan my_plan;
group.execute(my_plan);