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

How can I run rosserial without errors?

asked 2019-08-13 08:04:40 -0600

Naussicca gravatar image

updated 2019-08-13 11:37:08 -0600

jayess gravatar image

Hello everyone,

I'm new to ROS and I was trying to learn how to send a message from ROS to Arduino and the other way using rosserial. I am using ROS Kinetic with Ubuntu 16.04.4 .

Until now I could include ros_lib into the Arduino IDE as it says in the following link http://wiki.ros.org/rosserial_arduino... , so I tried to do the next tutorials, first one is the example step by step for publisher (with HelloWorld program) as http://wiki.ros.org/rosserial_arduino... and the second one is the example for subscriber (with blinking of led program) as this link http://wiki.ros.org/rosserial_arduino....

First, I compile the code in the Arduino IDE and it does not show any error and then I upload it. Also, I checked the port and the baud of Arduino.

So next, I am giving the following commands in the terminal:

  1. Roscore
  2. rosrun rosserial_python serial_node.py /dev/ttyACM0 _baud:=9600

And when I try to run that node I get the following error in both programs (so that's why I think I have the error in the node):

Traceback (most recent call last):
  File "/home/sofia_ws/src/rosserial/rosserial_python/nodes/serial_node.py", line 39, in <module>
    from rosserial_python import SerialClient, RosSerialServer
File "/home/sofia_ws/devel/lib/python3/dist-packages/rosserial_python/__init__.py", line 35, in <module>
    exec(__fh.read())
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'SerialClient'

Since I'm new and I'm following the tutorials I do not know where is my error. I tried to look if there is something similar to this but I couldn't find anything resolved.

Thank you in advanced!! :)

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2019-08-14 03:50:30 -0600

ct2034 gravatar image

updated 2019-08-14 03:51:27 -0600

It looks like there is a problem with your rosserial_python installation. You have a setup mixed up between python 2 and 3. I suspect you installed rosserial_python with pip3. Uninstall it there and install it with sudo apt install ros-YOURDISTRO-rosserial-python.

edit flag offensive delete link more

Comments

1

But also welcome to ROS. ;-) Please stay - we have cookies.

ct2034 gravatar image ct2034  ( 2019-08-14 03:52:18 -0600 )edit

Hii! I love cookies hahaha :D I did what you say and it works perfectly, so thank you so much!! Greetings and hope you are having a good day! Sofi

Naussicca gravatar image Naussicca  ( 2019-08-14 07:59:36 -0600 )edit

Good to hear. Can you please accept my answer (click the little tick)

ct2034 gravatar image ct2034  ( 2019-08-15 03:57:05 -0600 )edit
0

answered 2019-08-14 01:21:57 -0600

krl101 gravatar image

updated 2019-08-14 01:22:30 -0600

First welcome to ROS and this forum!

If you are using the arduino micro, please add to your Arduino code:

#define USE_USBCON

just before

#include <ros.h>

Just in case you are using an Arduino Micro.

As far as i know, rosserial uses 57600 as default baud rate, so if you do not changed it, just try it without _baud:=xyz:

rosrun rosserial_python serial_node.py /dev/ttyACM0

If you want to change your baudrate in your Arduino code by using:

nh.getHardware()->setBaud(BAUD)

(where BAUD can be 9600) before you initialize the node. Here don't forget to call rosserial with _baud:=9600

Greetings and happy coding,

krl

edit flag offensive delete link more

Comments

Thanks for your warm welcome and for your help!

Actually, I had a problem with my rosserial installation, but your answer also helped me to understand how it works better!

Greetings and happy coding for you too!! :D Sofi

Naussicca gravatar image Naussicca  ( 2019-08-14 07:57:24 -0600 )edit

Question Tools

2 followers

Stats

Asked: 2019-08-13 08:04:40 -0600

Seen: 1,371 times

Last updated: Aug 14 '19