MoveIt!学习笔记(四):Move Group

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);
  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值