I am using a GPS plugin on my model. I know it works as I have tested by using
rostopic echo gps_out
and it continually outputs data in the NavSatFix form.
I am trying to write a script that will ultimately give my robot velocity commands through reading a target and current GPS location.
The python script I'm currently writing is to read in the data and then assign the longitude and latitude to global variables which can be displayed to confirm they are correct. This is the python script currently.
from sensor_msgs.msg import NavSatFix
latitude = data.latitude
longitude = data.longitude
rospy.Subscriber('gps_out', NavSatFix, callback)
As can be read from the code, the only output is
Longitude: Not re-assigned
Latitude: Not re-assigned
What am I doing wrong?
From my understanding I am setting longitude and latitude variables to be global, and assigning them the initial conditions. Then assigned the nodes name, then subscribing to the topic and running callback which should assign the values to the variables which will allow them to be printed.
Post score: 0