dobot moveit 包_DOBOT magician魔术师在ROS下使用moveit编写代码控制(笛卡尔空间控制走直线)...

该博客详细介绍了如何在ROS环境下使用Dobot Magician(DOBOT magician)的moveit包进行C++和Python编程,控制机械臂在笛卡尔空间中执行走直线的运动规划。首先初始化MoveGroupInterface,设置允许的误差、速度和加速度,然后获取起始位姿并设定目标路径,最后进行路径规划和执行运动。
摘要由CSDN通过智能技术生成

C++ 版

#include #include #include int main(int argc, char **argv)

{

ros::init(argc, argv, "magician_moveit_cartesian_demo");

ros::AsyncSpinner spinner(1);

spinner.start();

moveit::planning_interface::MoveGroupInterface arm("magician_arm");

//获取终端link的名称

std::string end_effector_link = arm.getEndEffectorLink();

//设置目标位置所使用的参考坐标系

std::string reference_frame = "magician_origin";

arm.setPoseReferenceFrame(reference_frame);

//当运动规划失败后,允许重新规划

arm.allowReplanning(true);

//设置位置(单位:米)和姿态(单位:弧度)的允许误差

arm.setGoalPositionTolerance(0.001);

arm.setGoalOrientationTolerance(0.01);

//设置允许的最大速度和加速度

arm.setMaxAccelerationScalingFactor(0.2);

arm.setMaxVelocityScalingFactor(0.2);

// 控制机械臂先回到初始化位置

arm.setNamedTarget("home");

arm.move();

sleep(1);

// 获取当前位姿数据最为机械臂运动的起始位姿

geometry_msgs::Pose start_pose = arm.getCurrentPose(end_effector_link).pose;

std::vectorwaypoints;

//将初始位姿加入路点列表

waypoints.push_back(start_pose);

start_pose.position.z -= 0.093;

waypoints.push_back(start_pose);

start_pose.position.x += 0.04;

waypoints.push_back(start_pose);

start_pose.position.y += 0.04;

waypoints.push_back(start_pose);

start_pose.position.x -= 0.04;

start_pose.position.y -= 0.04;

waypoints.push_back(start_pose);

// 笛卡尔空间下的路径规划

moveit_msgs::RobotTrajectory trajectory;

const double jump_threshold = 0.0;

const double eef_step = 0.005;

double fraction = 0.0;

int maxtries = 100; //最大尝试规划次数

int attempts = 0; //已经尝试规划次数

while(fraction < 1.0 && attempts < maxtries)

{

fraction = arm.computeCartesianPath(waypoints,

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值