ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
3

rosserial arduino can't connect (Arduino micro)

asked 2014-05-13 02:30:31 -0500

Daniel_2210 gravatar image

updated 2014-05-20 04:47:30 -0500

Hi all,

I have a problem with rosserial_arduino. The demo hello world program compiles fine in the arduino IDE.

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

The problem that I have is that ros can't connect to the arduino.

When I run this "rosrun rosserial_python serial_node.py /dev/ttyACM0" I get the error:

[INFO] [WallTime: 1399983521.604184] ROS Serial Python Node
[INFO] [WallTime: 1399983521.617853] Connecting to /dev/ttyACM0 at 57600 baud
[ERROR] [WallTime: 1399983538.726124] Unable to sync with device; possible link problem or link software version mismatch such as hydro rosserial_python with groovy Arduino

When I run this "rosrun rosserial_server serial_node /dtyACM0" I get these messsages:

[ INFO] [1399983906.306684433]: Opening serial port.
[ INFO] [1399983906.306988104]: Starting session.
[ WARN] [1399983907.309690537]: Sync with device lost.

I also have added my user to the usergroups dialout and tty. That fixes the problem that I can access the port without admin(sudo) right.

I use this in combination with an Arduino Micro but it's the same as an Arduino Uno but then a bit smaller.

I hope you can help me with my problem.

edit retag flag offensive close merge delete

Comments

I have already reinstalled ROS now and that still didn't fixed it.

Daniel_2210 gravatar image Daniel_2210  ( 2014-05-20 04:47:58 -0500 )edit

4 Answers

Sort by ยป oldest newest most voted
12

answered 2014-05-21 01:28:22 -0500

Daniel_2210 gravatar image

I have fixed it. What you need to do is.

The "Hello World" example seems to be working fine. The only change you must to your Arduino code on Micro or just the normal one, I only have a Micro is to add

#define USE_USBCON

just before

#include <ros.h>

That's it.

edit flag offensive delete link more

Comments

Solved my problem! Thanks!

JP_TCC gravatar image JP_TCC  ( 2014-05-24 14:07:29 -0500 )edit
2

i dont understand the micro define usbcon that you mention. can please explain in more details?

dmngu9 gravatar image dmngu9  ( 2015-06-30 06:56:57 -0500 )edit

I can confirm that this solution work in my case as well. My system is Ubuntu 14.04, ROS Indigo and Arduino Micro. I followed the tutorial @ http://wiki.ros.org/rosserial_arduino...

ozsln gravatar image ozsln  ( 2016-06-27 22:59:59 -0500 )edit

This works. Thank you.

webvenky gravatar image webvenky  ( 2016-07-12 11:38:00 -0500 )edit

Found out why this works. See line 54 of Arduinohardware.h : http://docs.ros.org/jade/api/rosseria... . We're suppose to specify the connection type associated with the hardware that rosserial is communicating with.

kev1nnsays gravatar image kev1nnsays  ( 2016-07-17 12:00:51 -0500 )edit

Thanks! We were going nuts when we switched to Micro and started getting an unrelated error about version incompatibility between the ROS lib and rosserial.

toddsampson gravatar image toddsampson  ( 2017-01-10 13:15:23 -0500 )edit

Wow, exactly the fix that I needed.

Marc_B gravatar image Marc_B  ( 2020-08-30 13:28:11 -0500 )edit
0

answered 2015-07-27 03:48:02 -0500

stan gravatar image

Hey, I recently had the same problem. For me this was solved by downgrading the rosserial packages to indigo. I removed the repository version and compiled the indigo branch by hand:

git clone  --branch indigo-devel https://github.com/ros-drivers/rosserial.git
catkin_make

Then, don't forget to rebuild the arduino libraries:

rosrun rosserial_arduino make_libraries.py

This fixed it for me. Hope this helps someone!

edit flag offensive delete link more

Comments

Daniel_2210, thank you very much. That fixed my problem.

Kiran Prakash gravatar image Kiran Prakash  ( 2015-12-02 17:01:21 -0500 )edit

#define USE_USBCON helped me fix the similar problem with micro. Thank you Daniel_2210

Kiran Prakash gravatar image Kiran Prakash  ( 2015-12-02 17:02:25 -0500 )edit
0

answered 2017-04-13 10:10:18 -0500

ChuiV gravatar image

For those that found this thread looking to get the Arduino Due working: For me using the programming port on the Due, I had to change line 72 in ArduinoHardware.h from iostream = &Serial1; to iostream = &Serial; (remove the '1'). After that, It worked like a charm!

Hope that helps somebody.

edit flag offensive delete link more
0

answered 2015-06-24 17:41:55 -0500

The very same problem happened to me using an arduino duemillanove w\ atmega168.

Then I swapped the AVR with an atmega328. And it worked!

edit flag offensive delete link more

Comments

1

hi, what do you think the problem was? i have the same problem at the moment

dmngu9 gravatar image dmngu9  ( 2015-06-30 06:56:16 -0500 )edit

Question Tools

Stats

Asked: 2014-05-13 02:30:31 -0500

Seen: 11,133 times

Last updated: Dec 02 '15