Quantcast
Channel: ROS Answers: Open Source Q&A Forum - RSS feed
Viewing all articles
Browse latest Browse all 59

Rosserial examples for arduino

$
0
0
Hello I had problems with the rosserial communication from, the Host (PC,Ubuntu Xenial, ROS Kinetic) to the Device (Arduino Leonardo). The code (HW Input/Output) in the Arduino worked but it did not published or subscribed any topic. Introduction: Load Rosserial Hello World Example in Arduino: /* * rosserial Publisher Example * Prints "hello world!" */ //#define USE_USBCON //<--this is new #include #include 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); } void loop() { str_msg.data = hello; chatter.publish( &str_msg ); nh.spinOnce(); delay(1000); } Start roscore roscore and start the rosserial communication: rosrun rosserial_python serial_node.py _port:=/dev/tACM0 After this I had two cases. First: without any error output rosrun rosserial_python serial_node.py _port:=/dev/ttyACM0 [INFO] [1497606946.599728]: ROS Serial Python Node [INFO] [1497606946.612089]: Connecting to /dev/ttyACM0 at 57600 baud here I thought the communication works well, I had a rosnode but no topics rosnode list /rosout /serial_node rostopic list /diagnostics /rosout /rosout_agg Second: with error rosrun rosserial_python serial_node.py _port:=/dev/ttyACM0 [INFO] [1497607058.864885]: ROS Serial Python Node [INFO] [1497607058.876586]: Connecting to /dev/ttyACM0 at 57600 baud [ERROR] [1497607075.987434]: Unable to sync with device; possible link problem or link software version mismatch such as hydro rosserial_python with groovy Arduino the nodes and topics where the same. Then I searched for three days for a solution and found this page: http://answers.ros.org/question/164191/rosserial-arduino-cant-connect-arduino-micro/ The solution for me was the USE_USBCON definition. /* * rosserial Publisher Example * Prints "hello world!" */ #define USE_USBCON //<--this is new #include #include after that I had the desired topic and was able to echo it. rosrun rosserial_python serial_node.py _port:=/dev/ttyACM0 [INFO] [1497607701.288109]: ROS Serial Python Node [INFO] [1497607701.298771]: Connecting to /dev/ttyACM0 at 57600 baud [INFO] [1497607704.031868]: Note: publish buffer size is 512 bytes [INFO] [1497607704.033017]: Setup publisher on chatter [std_msgs/String] rosnode list /rosout /serial_node rostopic list /chatter /diagnostics /rosout /rosout_agg rostopic echo /chatter data: hello world! --- data: hello world! --- Conclusion: For me the problem lies in the rosserial examples which are not up to date and the error messages. So I have two questions: Is my conclusion right? And where or whom do I have to write for the updating of the tutorials and editing the error messages? Best regards Bukmop

Viewing all articles
Browse latest Browse all 59

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>