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

Help in using serial library on Ubuntu for communication with ROS

asked 2014-08-04 00:50:37 -0600

sumanth gravatar image

updated 2014-08-06 07:03:23 -0600

Hello,

I am currently working on my custom robot project, for which I need my robot to communicate with the ROS running on a linux-ubuntu PC, so I need a Serial library running on linux Pc which is capable of communicating with the ROS and the Robot.

I can use rosserial but I don't have C++ support on my controller (Rather I can't write code in C++ as the existing code is in C, I want to reuse the already available framework), the micro controller on the robot is a non-aurdino one.

I have tried using the r2serial code from the link : http://code.google.com/p/team-diana/s... .

I am running this code on the ROS PC, with this I am able to receive the data from Linux PC to the robot, but I am able to send the data from the robot to the linux PC.

Can any one guide me on what's going wrong with the code I am using..? or there is any other solution/ serial library that I can use for my project.

Many Thanks in advance.

edit retag flag offensive close merge delete

Comments

1

That package is essentially a translator between ROS and raw serial. Have you checked that all your serial port settings are correct? Can you use a port monitor to check if the correct data are being sent and returned from the uC?

dpiet gravatar image dpiet  ( 2014-08-04 16:41:34 -0600 )edit

Yeah I can recieve the data from ROS PC to uC properly, But I am unable to send the data from uC to ROS.

sumanth gravatar image sumanth  ( 2014-08-04 23:52:20 -0600 )edit

strange observation is uC will send data every 100ms which I cannot see on ROS pc, but when I connect the serial port through the H-term (UART visualiser link: http://www.der-hammer.info/terminal/) and click on "connect" I can see data on ROS PC also.

sumanth gravatar image sumanth  ( 2014-08-04 23:55:06 -0600 )edit

But the data gets drifted continuously, any insights why this is happening

sumanth gravatar image sumanth  ( 2014-08-04 23:55:39 -0600 )edit

fgets is probably expecting a newline. Are you sure your microcontroller is sending a newline after every packet?

ahendrix gravatar image ahendrix  ( 2014-08-05 01:51:51 -0600 )edit

No I don't send any newline from micro controller.

sumanth gravatar image sumanth  ( 2014-08-05 02:23:16 -0600 )edit

@ahendrix, or Do I have any other serial port library so that I can use with my micro controller.

sumanth gravatar image sumanth  ( 2014-08-05 04:41:41 -0600 )edit

You could continue debugging that package and make sure it's publishing to the ROS topic with dummy values. If that's working then you know it's a serial read issue.

dpiet gravatar image dpiet  ( 2014-08-06 12:03:59 -0600 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2014-08-05 10:59:17 -0600

ahendrix gravatar image

As a C++ serial port library, I like http://wjwwood.io/serial/

In python, pyserial is very good.

I'm not aware of any other ROS nodes which convert a serial port directly into ROS messages. This seems like a bad idea, because it breaks the abstraction that ROS is trying to provide.

edit flag offensive delete link more

Comments

Any examples of how to use this C++ serial port library. If this seems like a bad idea, what is the option I have for my kind of scenario..??

sumanth gravatar image sumanth  ( 2014-08-06 07:04:43 -0600 )edit

The serial library comes with examples in the documentation: http://wjwwood.io/serial/doc/1.1.0/serial__example_8cc.html

ahendrix gravatar image ahendrix  ( 2014-08-06 12:07:51 -0600 )edit

Instead of exposing the raw serial stream as ROS messages, you node should interpret it in some way; for example by publishing Odometry messages and subscribing to Twist messages.

ahendrix gravatar image ahendrix  ( 2014-08-06 12:10:57 -0600 )edit

publishing Odometry messages and subscribing to Twist messages is fine. But the question is how to get the data from the controller to the ROS PC over UART, once I have the data to ROS-PC I can manipulate the data as required.

sumanth gravatar image sumanth  ( 2014-08-06 12:48:06 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2014-08-04 00:50:37 -0600

Seen: 1,307 times

Last updated: Aug 06 '14