在ROS下控制dobot(magician)机械手的吸盘
在ROS下控制越疆科技dobot(magician)机械手的吸盘气泵
代码:
#include "ros/ros.h"
#include "ros/console.h"
#include "std_msgs/String.h"
#include "dobot/SetCmdTimeout.h"
#include "dobot/SetQueuedCmdClear.h"
#include "dobot/SetQueuedCmdStartExec.h"
#include "dobot/SetQueuedCmdForceStopExec.h"
#include "dobot/GetDeviceVersion.h"
#include <unistd.h>#include "dobot/SetEndEffectorParams.h"
#include "dobot/SetPTPJointParams.h"
#include "dobot/SetPTPCoordinateParams.h"
#include "dobot/SetPTPJumpParams.h"
#include "dobot/SetPTPCommonParams.h"
#include "dobot/SetPTPCmd.h"
#include "dobot/SetEndEffectorSuctionCup.h"
#include "dobot/SetHOMEParams.h"
#include "dobot/SetHOMECmd.h"int main(int argc, char **argv)
{ros::init(argc, argv, "DobotClient");ros::NodeHandle n;ros::ServiceClient client;// SetCmdTimeoutclient = n.serviceClient<dobot::SetCmdTimeout>("/DobotServer/SetCmdTimeout");dobot::SetCmdTimeout srv1;srv1.request.timeout = 3000;if (client.call(srv1) == false) {ROS_ERROR("Failed to call SetCmdTimeout. Maybe DobotServer isn't started yet!");return -1;}// Clear the command queueclient = n.serviceClient<dobot::SetQueuedCmdClear>("/DobotServer/SetQueuedCmdClear");dobot::SetQueuedCmdClear srv2;client.call(srv2);// Start running the command queueclient = n.serviceClient<dobot::SetQueuedCmdStartExec>("/DobotServer/SetQueuedCmdStartExec");dobot::SetQueuedCmdStartExec srv3;client.call(srv3);// Get device version informationclient = n.serviceClient<dobot::GetDeviceVersion>("/DobotServer/GetDeviceVersion");dobot::GetDeviceVersion srv4;client.call(srv4);if (srv4.response.result == 0) {ROS_INFO("Device version:%d.%d.%d", srv4.response.majorVersion, srv4.response.minorVersion, srv4.response.revision);} else {ROS_ERROR("Failed to get device version information!");}// Set PTP coordinate parametersdo {client = n.serviceClient<dobot::SetPTPCoordinateParams>("/DobotServer/SetPTPCoordinateParams");dobot::SetPTPCoordinateParams srv;srv.request.xyzVelocity = 100;srv.request.xyzAcceleration = 100;srv.request.rVelocity = 100;srv.request.rAcceleration = 100;client.call(srv);} while (0);// Set PTP common parametersdo {client = n.serviceClient<dobot::SetPTPCommonParams>("/DobotServer/SetPTPCommonParams");dobot::SetPTPCommonParams srv;srv.request.velocityRatio = 50;srv.request.accelerationRatio = 50;client.call(srv);} while (0);do{client = n.serviceClient<dobot::SetHOMEParams>("/DobotServer/SetHOMEParams");dobot::SetHOMEParams home;home.request.x = 200;home.request.y = 0;home.request.z = 0;home.request.r = 0;home.request.isQueued = 1;client.call(home); } while(0);do{client = n.serviceClient<dobot::SetHOMECmd>("/DobotServer/SetHOMECmd");dobot::SetHOMECmd home1;client.call(home1);} while(0);ros::spinOnce();while (ros::ok()){client = n.serviceClient<dobot::SetEndEffectorSuctionCup>("/DobotServer/SetEndEffectorSuctionCup");dobot::SetEndEffectorSuctionCup sck1; do{sck1.request.enableCtrl = 1; // When enableCtr == 1 the motor will operate. sck1.request.suck = 1; // When suck == 1 the suction cup will suck.sck1.request.isQueued = true; // This command puts the request in the queue.ros::spinOnce(); } while(0);client = n.serviceClient<dobot::SetPTPCmd>("/DobotServer/SetPTPCmd");dobot::SetPTPCmd srv;// The first pointdo{srv.request.ptpMode = 1;srv.request.x = 200;srv.request.y = 0;srv.request.z = 0;srv.request.r = 0;client.call(srv);if (srv.response.result == 0) {break; } ros::spinOnce(); //spinOnce() will execute any callbacks.if (ros::ok() == false) {break;}}while(0);do{srv.request.ptpMode = 1;srv.request.x = 250;srv.request.y = 0;srv.request.z = 0;srv.request.r = 0;client.call(srv);if (srv.response.result == 0) {break; } ros::spinOnce(); //spinOnce() will execute any commands in the queue.if (ros::ok() == false) {break;}} while(0);client = n.serviceClient<dobot::SetEndEffectorSuctionCup>("/DobotServer/SetEndEffectorSuctionCup");dobot::SetEndEffectorSuctionCup sck2;// pick up do{sck2.request.enableCtrl = 1;sck2.request.suck = 1; // Enable suction sck2.request.isQueued = true;client.call(sck2);ros::spinOnce(); //spinOnce() will execute any commands in the queue.if (ros::ok() == false) {break;}} while(0);client = n.serviceClient<dobot::SetPTPCmd>("/DobotServer/SetPTPCmd");dobot::SetPTPCmd srv6;do{srv6.request.ptpMode = 1;srv6.request.x = 250;srv6.request.y = 0;srv6.request.z = -45;srv6.request.r = 0;client.call(srv6);if (srv6.response.result == 0) {break; } ros::spinOnce(); //spinOnce() will execute any commands in the queue.if (ros::ok() == false) {break;}}while(0);do{srv6.request.ptpMode = 1;srv6.request.x = 250;srv6.request.y = 50;srv6.request.z = 0;srv6.request.r = 0;client.call(srv6);if (srv6.response.result == 0) {break; } ros::spinOnce(); //spinOnce() will execute any commands in the queue.if (ros::ok() == false) {break;}}while(0);do{srv6.request.ptpMode = 1;srv6.request.x = 200;srv6.request.y = 50;srv6.request.z = -45;srv6.request.r = 0;client.call(srv6);if (srv6.response.result == 0) {break; } ros::spinOnce(); //spinOnce() will execute any commands in the queue.if (ros::ok() == false) {break;}} while(0);client = n.serviceClient<dobot::SetEndEffectorSuctionCup>("/DobotServer/SetEndEffectorSuctionCup");dobot::SetEndEffectorSuctionCup sck3;//drop off do{ sck3.request.enableCtrl = 1;sck3.request.suck = 0;sck3.request.isQueued = true;client.call(sck3);ros::spinOnce(); //spinOnce() will execute any commands in the queue.if (ros::ok() == false) {break;}}while (0);ros::spinOnce();}return 0;
}
在ROS下控制dobot(magician)机械手的吸盘相关推荐
- 在ROS下控制dobot(magician)机械手的滑轨
在ROS下控制越疆科技dobot(magician)机械手的滑轨 GetQueuedCmdCurrentIndex.srv代码: --- int32 result uint64 queuedCmdIn ...
- 在ROS下控制dobot(magician)机械手的夹抓
在ROS下控制越疆科技dobot(magician)机械手的夹抓 代码: #include "ros/ros.h" #include "ros/console.h&quo ...
- ROS下连接dobot机械臂
ROS下连接dobot机械臂 我使用的操作系统是ubuntu16.04,ros是kinetic! 首先到dobot官网下载ros下的demo模块,网址:https://cn.dobot.cc/down ...
- ROS下连接Dobot魔术师机械臂
实验室最近购入Dobot 魔术师机械臂,是一款桌面级机械臂,精度较高而且相对便宜,支持二次开发,适合实验室进行学习与开发使用.提供了较为丰富的api,方便使用各种平台及语言进行开发.这里介绍如何在RO ...
- ROS下使用dobot越疆科技的M1-B1机器人进行定点抓取代码
ROS下使用越疆科技的M1-B1机器人进行定点抓取代码 #include <ros/ros.h> #include "ros/console.h" #include & ...
- Franka Emika 机械臂在ROS下控制
请安装franka_ros franka_ros元包将libfranka集成到ros和ros控制中.在这里,我们将介绍它的软件包,并简要介绍如何编写控制器. 本节中传递给启动文件的所有参数都带有默认值 ...
- ROS下dobot(magician)机械臂的URDF模型 有兴趣的可以下载来玩
大家好,看到很多人想玩ROS来控制Dobot,我这里有一个URDF模型分享给大家.下载链接https://download.csdn.net/download/qq_42145185/10818360 ...
- ROS下dobot(magician)机械臂的python demo
和朋友一起试了试ROS里 roscpp代码改rospy 使用的是dobot magician ,这是客户端用python写的 #!/usr/bin/env python # -*- coding: u ...
- 2019年大学生智能车大赛室外光电组+在ROS下搭建仿真模拟环境,编程控制小车完成定位导航仿真
2019年大学生智能车大赛室外光电组+在ROS下搭建仿真模拟环境,编程控制小车完成定位导航仿真 一.前言 二.准备工作 1.创建工作空间 2.下载racecar源代码包,并编译工程 三.启动仿真 1. ...
最新文章
- 考研经验交流会【高分前辈】【350分+】
- CF1479B Painting the Array
- Android 简单几行代码实现摇一摇功能
- 我是如何 2 个月拿到 4 份 Offer 并收入翻倍的?
- Google地图更新,更AI更贴心更节约时间,就是不敢来中国
- 【原】Coursera—Andrew Ng机器学习—课程笔记 Lecture 6_Logistic Regression 逻辑回归
- spec.fne病毒
- Java代码发送post请求工具类
- 随笔---ubuntu下通过ifstat查看实时网速
- 修改window本地hosts文件,修改域名指向
- 90后马来西亚女孩闯华为
- 秒抢红包和欧巴江南style红遍全球的背后都是HOOK的功劳!
- ElementUI table表格数据html格式解析
- Mac OS 名称问题及修改方法(修改终端中显示的hostname(主机名称) / 电脑名称 / 管理员名称 / LocalHostName(本地主机名称))
- direction和unicode-bidi
- 2022-2028年中国财税信息化行业市场行情动态及发展趋向分析报告
- 图片编辑软件_pinta在Linux下安装
- 《爱乐之城》配色分享
- 【论文泛读17】BERT后训练复习阅读理解和基于方面的情感分析
- linux获取p12证书信息,微信公众号现金红包——.p12证书linux部署如何使用
热门文章
- ionic2混合应用调起原生地图应用
- 股市几个常用基本面指标介绍
- Hyperledger Fabric 二进制安装部署 Peer 节点
- acme.sh申请Let‘s Encrypt 免费HTTPS证书
- 获取一个group by里面的总和或者聚合函数 思路杂乱 不要看
- 零基础如何自学编程?用这6种方法就够了!
- 已解决ValueError: All arrays must be of the same length
- 配置Tomcat详细教程!
- MLOps极致细节:15. Azure ML数据集的上传(Azure Workspace DataStore Upload)与注册(Azure Dataset Register)
- python复习题库