Here is the code and the error that I am getting when I run the program . Can anyone explain what mistake I am doing? Also is it good to call a function of a class in the constructor like I did?
#!/usr/bin/env python
import rospy
class move_turtlebot(message):
def __init__(self):
self.pub=rospy.Publisher('/cmd_vel', Twist, queue_size=1)
self.vel=Twist()
rospy.loginfo("initiated!!")
self.move(message)
def move(self,message):
if message=="STOP":
rospy.loginfo("inside stop")
self.vel=Twist()
self.pub.publish(vel)
elif message=="LEFT":
#rest of code continues
if __name__=="__main__":
rospy.init_node('move_turtlebot')
rospy.loginfo("here!")
while not rospy.is_shutdown():
ahead=move_turtlebot("FORWARD")
The error is:NameError: name 'message' is not defined at the line of defining class
__init__methodmessagehas not yet been defined. Alsoelifis not indented correctlymove_turtlebotinherits frommessagebut this class is not defined/imported