NameError: global name 'NAME' is not defined
hello, I'm trying to publish data of my GPS but it appears this error
NameError: global name 'hora' is not defined
Anybody help me please :)
My code is this:
#!/usr/bin/env python
import rospy
import serial
import pynmea2
import roslib; roslib.load_manifest('ceres_pkg')
from std_msgs.msg import String
from geometry_msgs.msg import Point
serialStream = serial.Serial("/dev/ttyAMA0",9600,timeout=0.5)
class GPS(object):
def __init__(self):
self.pub_ = rospy.Publisher("/dat_gps", Point, queue_size = 1)
return
def start(self):
sentence = serialStream.readline()
global hora,lat,lon
if sentence.find('GGA') > 0:
data = pynmea2.parse(sentence)
hora = data.timestamp
lat = data.latitude
lon = data.longitude
pos_msg = Point(hora, lat, lon)
loop_rate = rospy.Rate(1)
while not rospy.is_shutdown():
self.pub_.publish(pos_msg);
loop_rate.sleep()
return
if __name__ == '__main__':
rospy.init_node('GPS_py', log_level=rospy.INFO)
rospy.loginfo("%s: starting GPS node", rospy.get_name())
Gps = GPS()
Gps.start()
could you post the actual error output with a bit of context?