ros-drivers / rosserial

A ROS client library for small, embedded devices, such as Arduino. See: http://wiki.ros.org/rosserial
519 stars 524 forks source link

rosserial doesn't work when Arduino communicates with device using serial pins. #124

Open amartya18x opened 10 years ago

amartya18x commented 10 years ago

"

include

include <std_msgs/Float32.h>

include

ros::NodeHandle nh; Ultrasonicn sensor(&Serial2);

std_msgs::Float32 dist_msg; ros::Publisher pub_dist("Dist", &dist_msg);

void setup() { Serial.begin(9600); Serial2.begin(9600); nh.initNode(); nh.advertise(pub_dist);

}

void loop() {

dist_msg.data = sensor.getDistance(); pub_dist.publish(&dist_msg);

nh.spinOnce(); } " I have an ultrasonic connected to the arduino using Serial 2 Hardware Serial Port where the ultrasonic sends the distance data in ASCII coded format over the Serial comunication line. However ROS node fails to communicate and give an error (unable to sync, version mismatch etc) But when i remove the line :- "dist_msg.data = sensor.getDistance(); " it does connect.

Could someone help me solve this. Thank you in advance.

mikepurvis commented 10 years ago

I know it's a long time ago now— do you have an update on this? Did it get resolved? Thanks.