当前位置:网站首页>dynamixel舵机在ros下的workbnech使用
dynamixel舵机在ros下的workbnech使用
2022-07-24 03:36:00 【冰激凌啊】
01 安装环境
在工作空间的src文件夹下安装功能包dynamixel-workbench,dynamixel-workbench-msgs,以及依赖库DynamixelSDK
具体参考:https://emanual.robotis.com/docs/en/software/dynamixel/dynamixel_workbench/
关于dynamixelSDK和workbench,我的理解是workbench是在dynamixelSDK的基础上,专为ROS开发,提供一些简单的易实现的API
接下来可以按照官方教程的Tutorials使用,也可以自己写
02 使用自己的程序
为了更适合自己,也为了更了解程序,所以是自己写的。
2.1 创建自己的功能包
- 创建功能包
catkin_create_pkg myDynamixel std_msgs rospy roscpp dynamixel_workbench_toolbox
注意:需要添加依赖dynamixel_workbench_toolbox
2.2 简单控制一个舵机
实现了一个舵机PID简单控制,可以位置控制(也可以电流控制),可以读取位置和电流
其中的一些API
DynamixelWorkbench dxl_wb; //声明对象
dxl_wb.begin("/dev/ttyUSB0",BAUDRATE); //打开串口
dxl_wb.ping(ID); //连接
dxl_wb.setPositionControlMode(ID); //设置位置控制模式
dxl_wb.torqueOn(ID); //上电,只有断电的情况下才能设置控制模式
dxl_wb.itemRead(ID,"Present_Position",&present_position); //读取当前的位置
dxl_wb.itemWrite(ID,"Goal_Position",goal_position); //写入目标的位置
具体过程如下:
首先在功能包的src下创建cpp文件
touch singleSimpleControl.cpp然后把cpp设为可执行文件:
右键文件-属性-权限-执行:允许作为可执行文件在CMakeList.txt中添加:
add_executable(my_dxl_node src/singleSimpleControl.cpp) target_link_libraries(my_dxl_node ${catkin_LIBRARIES})cpp程序参考知乎博主的,但需要注意在
torqueOn之前需要ping,否则舵机无法执行动作
2.3 简单控制多个舵机
创建cpp文件,并设置为可执行文件
touch multiSimpleControl.cpp头文件
my_dxl_controller.h对应cpp文件
my_dxl_controller.cpp(multiSimpleControl.cpp中创建对象调用)roslaunch文件
start_multi_dxl.launch修改
CMakeList.txtadd_library(MyDynamixelController include/my_dynamixel/my_dxl_controller.h src/my_dxl_controller.cpp ) add_executable(my_multi_dxl_node src/multi_simple_control.cpp) add_dependencies(my_multi_dxl_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS}) target_link_libraries(my_multi_dxl_node MyDynamixelController ${catkin_LIBRARIES} ${YAML_CPP_LIBRARIES})遇到的问题和解决:
- 这里主要遇到的就是自定义的头文件无法使用,要注意修改CMakeList.txt的一些依赖(比如
add_library那一步,target_link_libraries也要把add_library加上去)(add_library后面的MyDynamixelController是类名,下面是一些文件)
然后可以先build一下,因为他其实是在devel文件下找头文件的 - 还有就是roslaunch启动含有node的cpp文件,因为涉及到
node_handle.param读取启动的参数
- 这里主要遇到的就是自定义的头文件无法使用,要注意修改CMakeList.txt的一些依赖(比如
边栏推荐
- How to realize WiFi Internet short message authentication in the park / factory
- How to write selenium's testng.xml
- Rpc-bdy (5) - automatic service logoff, load balancing
- Problem solution of supporting problem solution of heavy chain dissection example
- 水题: 接雨水
- STL multimap
- C文件操作详解
- [untitled]
- Error code 0x80004005
- [JS reverse hundred examples] a public resource trading network, reverse analysis of announcement URL parameters
猜你喜欢

JIRA automation experience sharing for 2 years

Jump statements break and continue

Hcip day 9 notes (OSPF routing feedback, routing policy, and Configuration Guide)

4. Hezhou air32f103_ LCD

Data Lake: comparative analysis of open source data Lake schemes deltalake, Hudi and iceberg

The error of van swipe in the rotation chart: cannot read a properties of null (reading width)

Lagrange polynomial

Idea failed to load resource: the server responded with a status of 404 (not found)

数据湖:开源数据湖方案DeltaLake、Hudi、Iceberg对比分析

Outlook client outlook.com mailbox setting method
随机推荐
如何在 pyqt 中实现桌面歌词
Idea failed to load resource: the server responded with a status of 404 (not found)
拉格朗日插值法
JS 數組 isAarray() typeof
C dynamic memory management details
Do you know how to do interface testing well?
Gpushare. COM | how to use tensorboardx visualization tool?
Cache component status when Vue components are switched, that is, dynamic components keep alive dynamic components and asynchronous components
Exercices classiques de langue C (2) - « tri des bulles »
How will you answer the "Hello world" challenge written in C language?
MySQL学习——MySQL软件的安装及环境配置(Windows)详细!
leetcode hot 100(刷題篇8)(232/88/451/offer10/offer22/344/)
Introduction to pytorch ecology
Express内置的中间件
1. Learn to understand web pages
Error code 0x80004005
数据湖:开源数据湖方案DeltaLake、Hudi、Iceberg对比分析
什么是IMU?
Basic syntax of MySQL DDL and DML and DQL
4. Hezhou air32f103_ LCD