Beispiel #1
0
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()
Beispiel #2
0
 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
Beispiel #3
0
 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
Beispiel #4
0
 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
Beispiel #5
0
    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()
Beispiel #6
0
    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()
Beispiel #7
0
 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'
Beispiel #8
0
 def adaugareFata(self, x):
     if self.inceput is None:
         self.inceput = Nod(x, None)
     else:
         newNode = Nod(x, self.inceput)
         self.inceput = newNode
Beispiel #9
0
 def inserareInainte(self, adr, x):
     ref = Nod(x, None, None)
     ref.urm = adr
     ref.prec = adr.prec
     adr.prec = ref
     ref.prec.urm = ref
Beispiel #10
0
 def inserareDupa(self, adr, x):
     ref = Nod(x, None, None)
     ref.urm = adr.urm
     ref.prec = adr
     adr.urm = ref
     ref.urm.prec = ref