Ask Your Question
0

Rosserial examples for arduino

asked 2017-06-16 05:21:33 -0600

Bukmop gravatar image

updated 2017-06-16 08:03:47 -0600

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 <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);
}

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/16419...

The solution for me was the USE_USBCON definition.

/*
 * rosserial Publisher Example
 * Prints "hello world!"
 */
#define USE_USBCON        //<--this is new

#include <ros.h>
#include <std_msgs/String.h>

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

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2017-09-30 18:26:35 -0600

rreignier gravatar image

Hello,

The issue you have encountered is because you have used an Arduino Leonardo that has a native USB port, which is different that on the Arduino UNO, MEGA...

That's why you have to enable the USE_USBCON flag. But it is normal it is not the default.

Maybe, you can edit the tutorials to make it clear that the specific Leonardo model needs this flag to be defined.

The tutorials are hosted on a community Wiki so, feel free to create an account and edit them: http://wiki.ros.org/rosserial

If you want to change the error message, you can send a pull-request on the Github repository: https://github.com/ros-drivers/rosserial

But note that even if the message is not clear enough, it only state that there is a communication problem. In fact, your Arduino was not send anything on the serial port.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2017-06-16 05:16:57 -0600

Seen: 1,028 times

Last updated: Sep 30 '17