博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ROS下订阅/cmd_vel节点
阅读量:4031 次
发布时间:2019-05-24

本文共 1408 字,大约阅读时间需要 4 分钟。

在ROS下测试订阅/cmd_vel节点,实际测试时采用/turtle1/cmd_vel节点

参考:

http://blog.csdn.net/heyijia0327/article/details/41823809 

http://answers.ros.org/question/129506/subscriber-not-seeing-cmd_vel-messages/

#include
#include
#include
#include
#include
void callback(const geometry_msgs::Twist& cmd_vel){ ROS_INFO("Received a /cmd_vel message!"); ROS_INFO("Linear Components:[%f,%f,%f]",cmd_vel.linear.x,cmd_vel.linear.y,cmd_vel.linear.z); ROS_INFO("Angular Components:[%f,%f,%f]",cmd_vel.angular.x,cmd_vel.angular.y,cmd_vel.angular.z); // Do velocity processing here: // Use the kinematics of your robot to map linear and angular velocities into motor commands // v_l = ... // v_r = ... // Then set your wheel speeds (using wheel_left and wheel_right as examples) // wheel_left.set_speed(v_l) // wheel_right.set_speed(v_r) }int main(int argc, char** argv){ ros::init(argc, argv, "cmd_vel_listener"); ros::NodeHandle n; //ros::Subscriber sub = n.subscribe("cmd_vel", 1000, callback); ros::Subscriber sub = n.subscribe("/turtle1/cmd_vel", 1000, callback);//用/turtle1/cmd_vel做测试哈 ros::spin();/*//http://answers.ros.org/question/129506/subscriber-not-seeing-cmd_vel-messages/ ros::Rate loop_rate(10); while( n.ok() ) { ros::spin(); }*/ return 1;}
turtle使用:http://wiki.ros.org/cn/ROS/Tutorials/UnderstandingTopics

节点结果:

你可能感兴趣的文章
关于数字类型转化为整型的方法
查看>>
PHP 常用正则表达式整理
查看>>
自然计算
查看>>
自然计算时间复杂度杂谈
查看>>
当前主要目标和工作
查看>>
系统菜单
查看>>
路漫漫其修远兮,吾将上下而求索(2)
查看>>
versions mac yosemite 下崩溃的修复
查看>>
github push 出现connection refused 的处理办法
查看>>
Linux配置sendmail实现PHP发送邮件
查看>>
c++ 特性回顾
查看>>
网站注册的时候,烦人的生日年份选择的改进想法
查看>>
游戏开发两年记 之 工程和理论需双剑合璧
查看>>
Nachos中switch汇编源码分析
查看>>
游戏开发两年之产品逻辑鸡肋么?
查看>>
secureCRT和Xshell登录Ubuntu
查看>>
secureCRT和Xshell登录ubuntu
查看>>
Apache下c语言的cgi如何获得Get,Post参数
查看>>
protobuf的使用初探
查看>>
ngx_http分析
查看>>