class StateMachine: def __init__(self): rospy.init_node('state_machine') rospy.loginfo('state machine') self.rate = rospy.Rate(60) # set rate to 60 hz # publishers #rospy.init_node('automaton') self.sub = rospy.Subscriber('/tricks', Temperature, self.trickCallback) self.nod_trick = Nod() self.shake_trick = Shake() self.dab_trick = Shake() def trickCallback(self, msg): rospy.loginfo('trickCallback') message = msg.average_temperature if message > 0.68 and message < 0.70: rospy.loginfo('callback if statement') self.nod_trick.nod() if message > 0.58 and message < 0.60: rospy.loginfo('callback if statement') self.shake_trick.shake() if message > 0.48 and message < 0.50: rospy.loginfo('callback if statement') self.dab_trick.dab()
def adaugareSpate(self, x): if self.inceput is None: self.inceput = Nod(x, None) else: aux = self.inceput while aux.urm is not None: aux = aux.urm newNode = Nod(x, None) aux.urm = newNode
def adaugareFata(self, x): if self.inceput is None: ref = Nod(x, None, None) self.inceput = ref self.sfarsit = ref else: ref = Nod(x, None, None) ref.urm = self.inceput self.inceput.prec = ref self.inceput = ref
def adaugareSpate(self, x): if self.inceput is None: ref = Nod(x, None, None) self.inceput = ref self.sfarsit = ref else: ref = Nod(x, None, None) ref.prec = self.sfarsit self.sfarsit.urm = ref self.sfarsit = ref
def __init__(self): rospy.init_node('state_machine') rospy.loginfo('state machine') self.rate = rospy.Rate(60) # set rate to 60 hz # publishers #rospy.init_node('automaton') self.sub = rospy.Subscriber('/tricks', Temperature, self.trickCallback) self.nod_trick = Nod() self.shake_trick = Shake() self.dab_trick = Shake()
def Task(self): comments = [ "You are a good teacher", "You look nice today", "I like bananas", "My name is Gemini"] time.sleep(self.wait_time_) ActionProcess('', LookCenter()).Run() time.sleep(self.wait_time_) ActionProcess('', Nod()).Run() random_comment = random.randint(0,len(comments) - 1) ActionProcess('', Speak(150, 50, comments[random_comment])).Run() time.sleep(self.wait_time_) ActionProcess('', Nod()).Run()
def adaugareDupaElement(self, x, y): aux = self.inceput while aux is not None and aux.info != x: aux = aux.urm if aux is not None: nodNou = Nod(y, aux.urm) aux.urm = nodNou else: print 'Nu exista nodul'
def adaugareFata(self, x): if self.inceput is None: self.inceput = Nod(x, None) else: newNode = Nod(x, self.inceput) self.inceput = newNode
def inserareInainte(self, adr, x): ref = Nod(x, None, None) ref.urm = adr ref.prec = adr.prec adr.prec = ref ref.prec.urm = ref
def inserareDupa(self, adr, x): ref = Nod(x, None, None) ref.urm = adr.urm ref.prec = adr adr.urm = ref ref.urm.prec = ref