0
我正在使用ros_lib为arduino创建使用rosserial的串行节点。我想编写一个订阅/ cmd_vel主题的代码,并将geometry_msgs/Twist消息输出到串行端口(arduion mega,多个串行端口)。ROS Arduino订阅/ cmd_vel
在此先感谢
#include <ros.h>
#include <std_msgs/String.h>
#include <std_msgs/Empty.h>
#include <geometry_msgs/Twist.h>
ros::NodeHandle nh;
ros::Subscriber<geometry_msgs::Twist> sub("/cmd_vel", messageCb);
void setup()
{
Serial1.begin(9600);
nh.initNode();
nh.subscribe(sub);
}
void loop()
{
Serial1.println(sub.data);
nh.spinOnce();
delay(1);
}
欢迎SO。现在你的问题太广泛而且没有特定性,这使得人们不太可能回答它。请使用编辑功能来解释您已经尝试过的更多内容以及您在哪里遇到问题。另请参阅https://stackoverflow.com/help/how-to-ask。 – luator