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

How to publish serial data from screen command?

asked 2021-01-22 08:19:55 -0600

Py gravatar image

I use screen /dev/ttyUSB0 to stream data from some device. This results in a string being printed to the terminal continuously similar to this:

0,0 abc;--------------- def;G;001;
0,0 abc;--------------- def;G;001;
0,0 abc;--------------- def;G;001;
0,0 abc;--------------- def;G;001;

How would I publish this data or some values from it to a topic?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-01-22 10:22:22 -0600

Mackou gravatar image

Hey, You can use the pyseriallibrary to read the data coming from USB with Python. You can process it if you want, then put the data into messages according to your needs and then publish it. This should help you : http://wiki.ros.org/roscpp/Overview/P...

edit flag offensive delete link more

Comments

That's handy - thanks very much! Is there any viable way to achieve this using bash?

Py gravatar image Py  ( 2021-01-22 10:39:55 -0600 )edit

In a bash script ? Technically yes it's possible. You can parse your output somehow, with awk for example and then publish your data with the rostopic pub command., for example like that : $ rostopic pub /topic package/msg_type '{x: 1, y: 2, c: a, type: string}' (Example from here). But I wouldn't call this a clean way to do it. Making a python node would be way better.

Mackou gravatar image Mackou  ( 2021-01-22 10:51:55 -0600 )edit

Question Tools

2 followers

Stats

Asked: 2021-01-22 08:19:55 -0600

Seen: 178 times

Last updated: Jan 22 '21