1.发生问题描述
- Arduino IDE编译通过且下载!
- 运行:rosrun rosserial_python serial_node.py /dev/ttyACM0时报错!内容为:Unable to sync with device; possible link problem or link software version mismatch such as hydro rosserial_python with groovy Arduino
2. 解决方案
很多博客说:应该在程序头添加:#define USE_USBCON;没有用,推测这个方案应该解决的编译时报错问题;
- 当通信时报错的时候,应该检查在在Loop()程序中,是否少添加了:nh.spinOnce();这条语句!
- 检查下是否存在这Arduino与ROS通信是否存在这串口读取以及串口输出,如果有的话,应该取消掉,否则会报错。如下:
#include <ros.h>
#include <std_msgs/String.h>
ros::NodeHandle nh;
std_msgs::String str_msg;
ros::Publisher chatter("chatter", &str_msg);
char hello[13] = "hello world!";
void setup()
{
nh.initNode();
nh.advertise(chatter);
//Serial.begin(9600);
}
void loop()
{
//Serial.println("Hello World!");
str_msg.data = hello;
chatter.publish( &str_msg );
nh.spinOnce();
delay(1000);
}