在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/SetEndEffectorGripper.h"
#include "dobot/SetHOMECmd.h"
#include "dobot/SetHOMEParams.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 end effector parametersclient = n.serviceClient<dobot::SetEndEffectorParams>("/DobotServer/SetEndEffectorParams");dobot::SetEndEffectorParams srv5;srv5.request.xBias = 70;srv5.request.yBias = 0;srv5.request.zBias = 0;client.call(srv5);// Set PTP joint parametersdo {client = n.serviceClient<dobot::SetPTPJointParams>("/DobotServer/SetPTPJointParams");dobot::SetPTPJointParams srv;for (int i = 0; i < 4; i++) {srv.request.velocity.push_back(100);}for (int i = 0; i < 4; i++) {srv.request.acceleration.push_back(100);}client.call(srv);} while (0);// 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 jump parametersdo {client = n.serviceClient<dobot::SetPTPJumpParams>("/DobotServer/SetPTPJumpParams");dobot::SetPTPJumpParams srv;srv.request.jumpHeight = 20;srv.request.zLimit = 200;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"); // The client is using the nodehandler // to access the advertised service SetHOMEParams // within the DobotServer.dobot::SetHOMEParams home; // Sets the position of the home.home.request.x = 200; // Setting the x coordinate through a client request.home.request.y = 0; // Setting the x coordinate through a client request.home.request.z = 0; // Setting the x coordinate through a client request.home.request.r = 0; // Setting the x coordinate through a client request.home.request.isQueued = 1; // Enabling the queue through a client request.client.call(home); // Calls the service with all the requests made but won't be performed until a spin is called.} while(0);do{client = n.serviceClient<dobot::SetHOMECmd>("/DobotServer/SetHOMECmd");dobot::SetHOMECmd home1; // SetHomeCmd needs to be called after SetHOMEParams otherwise the magician will not move to the user defined positions.client.call(home1);} while(0);ros::spinOnce(); // All the callbacks will be called from spinOnce() 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);} 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);} while(0);do{srv.request.ptpMode = 1;srv.request.x = 250;srv.request.y = -30;srv.request.z = 0;srv.request.r = 0;client.call(srv);} while(0);client = n.serviceClient<dobot::SetEndEffectorGripper>("/DobotServer/SetEndEffectorGripper");dobot::SetEndEffectorGripper grp1;// Pick updo{grp1.request.enableCtrl = 1; // When the enableCtrl == 1 the motor will operate.grp1.request.grip = 1; // When grip == 1 the gripper will close. grp1.request.isQueued = true; // This command puts the request in the queue.client.call(grp1);} 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 = 0;srv6.request.r = 0;client.call(srv6);} 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);}while(0);do{srv6.request.ptpMode = 1;srv6.request.x = 250;srv6.request.y = 50;srv6.request.z = -30;srv6.request.r = 0;client.call(srv6);}while(0);client = n.serviceClient<dobot::SetEndEffectorGripper>("/DobotServer/SetEndEffectorGripper");dobot::SetEndEffectorGripper grp2;// Drop object  do{   grp2.request.grip = 0; // Release grip.grp2.request.enableCtrl = 1;grp2.request.isQueued = true;client.call(grp2);} while(0);client = n.serviceClient<dobot::SetPTPCmd>("/DobotServer/SetPTPCmd");dobot::SetPTPCmd srv7;do{srv7.request.ptpMode = 1;srv7.request.x = 250;srv7.request.y = 50;srv7.request.z = 0;srv7.request.r = 0;client.call(srv7);} while(0);do{srv7.request.ptpMode = 1;srv7.request.x = 250;srv7.request.y = 0;srv7.request.z = 0;srv7.request.r = 0;client.call(srv7);} while(0);    client = n.serviceClient<dobot::SetEndEffectorGripper>("/DobotServer/SetEndEffectorGripper");dobot::SetEndEffectorGripper grp3;// Turn off motordo{    grp3.request.grip = 0;grp3.request.enableCtrl = 0; // Turn off the power. grp3.request.isQueued = true;client.call(grp3);} while(0);ros::spinOnce();return 0;
}

在ROS下控制dobot(magician)机械手的夹抓相关推荐

  1. 在ROS下控制dobot(magician)机械手的滑轨

    在ROS下控制越疆科技dobot(magician)机械手的滑轨 GetQueuedCmdCurrentIndex.srv代码: --- int32 result uint64 queuedCmdIn ...

  2. 在ROS下控制dobot(magician)机械手的吸盘

    在ROS下控制越疆科技dobot(magician)机械手的吸盘气泵 代码: #include "ros/ros.h" #include "ros/console.h&q ...

  3. ROS下连接dobot机械臂

    ROS下连接dobot机械臂 我使用的操作系统是ubuntu16.04,ros是kinetic! 首先到dobot官网下载ros下的demo模块,网址:https://cn.dobot.cc/down ...

  4. ROS下连接Dobot魔术师机械臂

    实验室最近购入Dobot 魔术师机械臂,是一款桌面级机械臂,精度较高而且相对便宜,支持二次开发,适合实验室进行学习与开发使用.提供了较为丰富的api,方便使用各种平台及语言进行开发.这里介绍如何在RO ...

  5. ROS下使用dobot越疆科技的M1-B1机器人进行定点抓取代码

    ROS下使用越疆科技的M1-B1机器人进行定点抓取代码 #include <ros/ros.h> #include "ros/console.h" #include & ...

  6. Franka Emika 机械臂在ROS下控制

    请安装franka_ros franka_ros元包将libfranka集成到ros和ros控制中.在这里,我们将介绍它的软件包,并简要介绍如何编写控制器. 本节中传递给启动文件的所有参数都带有默认值 ...

  7. 「完结撒花」使用intel realsense D435i深度相机获取信息,DOBOT MG400机械手实现动态实时抓取,并做了个GUI界面(python实现)

    GUI界面如下,丑是丑了点,但很好用,嘿嘿. GUI部分 1.GUI界面可以实现的功能 暂停・继续相机画面 显示彩色RGB图像・深度图像・开运算结果图・进行图像处理后的图片(右侧) 调节opencv轮 ...

  8. ROS下dobot(magician)机械臂的URDF模型 有兴趣的可以下载来玩

    大家好,看到很多人想玩ROS来控制Dobot,我这里有一个URDF模型分享给大家.下载链接https://download.csdn.net/download/qq_42145185/10818360 ...

  9. ROS下dobot(magician)机械臂的python demo

    和朋友一起试了试ROS里 roscpp代码改rospy 使用的是dobot magician ,这是客户端用python写的 #!/usr/bin/env python # -*- coding: u ...

最新文章

  1. 人名翻译_考研英语翻译:句子中出现人名怎么办?
  2. 工业视觉检测发展的现状
  3. WebForm页面生命周期及asp.net运行机制
  4. UDP成为低延时流媒体关键 选SRT还是QUIC?
  5. 操作系统之计算机系统概述:7、操作系统的体系结构
  6. C/C++基础::sizeof() 与 sizeof(string)
  7. android 网页取词,有道词典屏幕取词怎么用?,你知道吗?在浏览网页
  8. iOS AVPlayer的那些坑
  9. 发电厂电气部分第三版pdf_“十三五”普通高等教育本科规划教材 发电厂电气设备及运行(第三版) pdf epub mobi txt 下载...
  10. matlab电机仿真 pdf,现代永磁同步电机控制原理及MATLAB仿真 pdf+随书仿真模型
  11. Modern UI for WPF的使用
  12. 100天python、github_GitHub - 100440175/Python-100-Days: Python - 100天从新手到大师
  13. ctor/dtor 与线程安全
  14. 蓝牙技术|蓝牙Mesh照明技术照亮世界
  15. linux系统查询服务器型号,Linux系统查看服务器型号
  16. python樱花树代码_python3实现用turtle模块画一棵随机樱花树
  17. FROM_UNIXTIME()函数UNIX_TIMESTAMP()函数
  18. vite的搭建与使用
  19. 什么人适合学习嵌入式开发?
  20. Java复习题1(1.写出抽象类和接口的区别。2.This和Super关键字的区别有哪些?3.常见的类集子类有哪些,各有什么特点?4.什么是多态,多态实现的前提是什么?)

热门文章

  1. 通过计算机控制电机的方法,计算机控制技术步进电机工作原理精选.ppt
  2. 【数据分析】疫情对美国民众消费的影响研究报告
  3. (已解决)C盘空间内存不足?C盘爆满怎么清理?C盘如何扩容?
  4. 一文讲清楚Windows Mobile和Wince(Windows Embedded CE)的字符集问题
  5. 福师计算机原理与接口技术期末考试a卷答案2014,福师1203考试批次《计算机原理与接口技术》复习题及参考答案.doc...
  6. eclipse不用方向键移动光标
  7. java——创意图形项目总结
  8. XMU 数字图像处理实验4 VC/VS MFC 编写JPEG图象读/写程序
  9. 硬件中断和软中断的区别
  10. 男人的深度,源于他的精神深度