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

How to publish .py output

asked 2018-11-15 20:29:39 -0500

M.Amin gravatar image

updated 2018-11-16 02:21:35 -0500

gvdhoorn gravatar image

Hi everybody I have a code which shows specific outputs from my GPS sensor in a terminal but I`m stuck with how to publish that output to a rostopic list. Here is my code:

import serial
ser = serial.Serial( '/dev/ttyUSB0' , 4800, timeout = 5 )
while 1:
    line = ser.readline()
    splitline = line.split(',')
    if splitline[0] == '$GPGSV':
        Heading = line[20]+line[21]+line[22]
        print Heading

I searched and examined different codes but am still confused. I`d appreciate any help on that.

edit retag flag offensive close merge delete

Comments

Can you please clarify:

  • Are you unsure on how to publish in general?
  • Are you unsure which message to use and how to use the data you receive?
mgruhler gravatar image mgruhler  ( 2018-11-16 03:51:56 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2018-11-16 04:32:03 -0500

You can follow the python publisher tutorial here, this will show you how to publish a simple string message. You should be able to put your raw GPS data into these strings to be able to see how publishers work.

However sending the raw sensor data around the ROS system is not the approach we recommend, there is a message type for this specific type of data, sensor_msgs/NavSatFix. This message type contains a sensor independent structured representation of a GPS fix measurement so that other nodes in ROS can work with any type of GPS sensor. If you can parse the string data from your GPS sensor and create NavSatFix messages then your GPS sensor will be properly connected to ROS.

Before you do that though I would check to see if any of the existing ROS GPS drivers would work for you, then you wouldn't have to re-invent the wheel. Unless you're just doing this just to learn how this works.

nmea_navsat_driver

novatel_gps_driver

... More that you can find on google.

Hope this helps.

edit flag offensive delete link more

Comments

Before you do that though I would check to see if any of the existing ROS GPS drivers would work for you, then you wouldn't have to re-invent the wheel.

Yes, +1.

gvdhoorn gravatar image gvdhoorn  ( 2018-11-16 05:06:29 -0500 )edit

Thank for comment. I want "heading" that is why put the string "GPGSV". had tried python publisher but was not able to work with that. Navsat also doesnt provide heading. Tried novatel package but the process is killed. My GPS sensor is BU-353. I just run roslaunch novatel novatel.launch. Wrong?

M.Amin gravatar image M.Amin  ( 2018-11-16 09:25:08 -0500 )edit

had tried python publisher but was not able to work with that

This works, so we should fix this first before moving on. For heading data you could use a std_msgs/Float32 and store the heading angle in radians or perhaps a vector representation.

PeteBlackerThe3rd gravatar image PeteBlackerThe3rd  ( 2018-11-16 09:56:31 -0500 )edit

Sorry but I did not get your point. You mean I need to first save "Heading" in my above python code? Failed to load nodelet [/novatel] of type [novatel_gps_driver/novatel_gps_nodelet] even after refreshing the cache: According to the loaded plugin descriptions the class novatel_gps_driver/novatel_gp

M.Amin gravatar image M.Amin  ( 2018-11-16 10:04:11 -0500 )edit

Were asking how you can publish the heading information from your GPS receiver to ROS? or am I miss-understanding you. What is the fundamental problem you're trying to address here?

PeteBlackerThe3rd gravatar image PeteBlackerThe3rd  ( 2018-11-16 10:14:34 -0500 )edit

That is true. I want to get heading and publish that to ROS. Novatel package is supposed to build many topics but when I run that it says the process is killed and ends that with the message I showed in previous comment.

M.Amin gravatar image M.Amin  ( 2018-11-16 10:16:46 -0500 )edit

Okay that is the real problem we should be fixing here. Since this is very different to your original question can you start a new question describing the errors your having starting the Novatel GPS driver, and we'll start working out what's wrong there.

PeteBlackerThe3rd gravatar image PeteBlackerThe3rd  ( 2018-11-16 10:35:01 -0500 )edit

Sure, thanks I created that here

M.Amin gravatar image M.Amin  ( 2018-11-16 10:36:18 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2018-11-15 20:29:39 -0500

Seen: 268 times

Last updated: Nov 16 '18