0
$\begingroup$

Rosanswers logo

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/source/browse/ros_workspace/fuerte/Serial/src/r2Serial.cpp?r=b3ad5adc6b1e885620b615c5f56ccf929cfbcdc2 .

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.


Originally posted by sumanth on ROS Answers with karma: 86 on 2014-08-04

Post score: 0


Original comments

Comment by dpiet on 2014-08-04:
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?

Comment by sumanth on 2014-08-04:
Yeah I can recieve the data from ROS PC to uC properly, But I am unable to send the data from uC to ROS.

Comment by sumanth on 2014-08-04:
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.

Comment by sumanth on 2014-08-04:
But the data gets drifted continuously, any insights why this is happening

Comment by ahendrix on 2014-08-05:
fgets is probably expecting a newline. Are you sure your microcontroller is sending a newline after every packet?

Comment by sumanth on 2014-08-05:
No I don't send any newline from micro controller.

Comment by sumanth on 2014-08-05:
@ahendrix, or Do I have any other serial port library so that I can use with my micro controller.

Comment by dpiet on 2014-08-06:
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.

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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.


Originally posted by ahendrix with karma: 47576 on 2014-08-05

This answer was ACCEPTED on the original site

Post score: 0


Original comments

Comment by sumanth on 2014-08-06:
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..??

Comment by ahendrix on 2014-08-06:
The serial library comes with examples in the documentation: http://wjwwood.io/serial/doc/1.1.0/serial__example_8cc.html

Comment by ahendrix on 2014-08-06:
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.

Comment by sumanth on 2014-08-06:
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.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.