how to save data subscriber to a variabel
i'd like to try save data from subscriber to a variabel for my condition statement, but when i launch my program, program only execute the subscriber only but not the condition
this is my program
class sukreb():
def __init__(self):
rospy.init_node('sukreb')
rospy.Subscriber('mode',std_msgs.msg.String, self.callback)
# rospy.Subscriber()
rospy.spin()
def callback(self,data):
mode = data
return mode
if(mode == "a"):
lowobj = lowMagenta
upobj = upMagenta
if(mode == "b"):
lowobj = lowCyan
upobj = upCyan
Asked by ilham hermi on 2019-11-28 12:28:16 UTC
Answers
return
exit the fonction so it's normal not to go into the two conditions. I would advise you to get some knwoledge in python before getting into ROS since ROS isn't a way to learn a programming language.
So just get rid of the line return mode
and you will get your data.
Asked by Delb on 2019-11-29 04:05:38 UTC
Comments