Exemplo n.º 1
0
  def my_handler(self, channel, data):
    msg = vortex_sensor_t.decode(data)
    
    # Print statements for receiving messages

    #print("Received message on channel \"%s\"" % channel)
    #print("   sensor1   = %s" % str(msg.sensor1))
    #print("   sensor2    = %s" % str(msg.sensor2))
    #print("")

    # Sensor 2 is up front
    if msg.sensor2 > self.threshold and not self.lookingforvortex:
      print("She's a beauty!  Vortex at the front sensor!")
      self.start = time.time()
      self.lookingforvortex = True

    if self.lookingforvortex:
      delay = time.time() - self.start      
      if delay > self.waittime:
        self.lookingforvortex = False
        print("Gave up looking for that one...")
      elif msg.sensor1 > self.threshold:
        print("She's at the rear now!")
        delay = time.time() - self.start
        print("That took " + str(delay) + " seconds!")
        speed = self.sensordistance / delay
        print("Estimated vortex speed is " + str(speed) + " meters / sec!")
        msg.velocity = speed
        lc.publish('vortex_sensor',msg.encode())
        self.lookingforvortex = False
Exemplo n.º 2
0
    def my_handler(self, channel, data):
        msg = vortex_sensor_t.decode(data)

        # Print statements for receiving messages

        #print("Received message on channel \"%s\"" % channel)
        #print("   sensor1   = %s" % str(msg.sensor1))
        #print("   sensor2    = %s" % str(msg.sensor2))
        #print("")

        # Sensor 2 is up front
        if msg.sensor2 > self.threshold and not self.lookingforvortex:
            print("She's a beauty!  Vortex at the front sensor!")
            self.start = time.time()
            self.lookingforvortex = True

        if self.lookingforvortex:
            delay = time.time() - self.start
            if delay > self.waittime:
                self.lookingforvortex = False
                print("Gave up looking for that one...")
            elif msg.sensor1 > self.threshold:
                print("She's at the rear now!")
                delay = time.time() - self.start
                print("That took " + str(delay) + " seconds!")
                speed = self.sensordistance / delay
                print("Estimated vortex speed is " + str(speed) +
                      " meters / sec!")
                msg.velocity = speed
                lc.publish('vortex_sensor', msg.encode())
                self.lookingforvortex = False
Exemplo n.º 3
0
    def my_handler(self, channel, data):
        msg = vortex_sensor_t.decode(data)

        # Print statements for receiving messages

        #print("Received message on channel \"%s\"" % channel)
        #print("   sensor1   = %s" % str(msg.sensor1))
        #print("   sensor2    = %s" % str(msg.sensor2))
        #print("")

        # Sensor 2 is up front
        if msg.sensor2 > 5 and not self.lookingforvortex:
            print("She's a beauty!  Vortex at the front sensor!")
            self.start = time.time()
            self.lookingforvortex = True

        if msg.sensor1 > 5 and self.lookingforvortex:
            print("She's at the rear now!")
            delay = time.time() - self.start
            print("That took " + str(delay) + " seconds!")
            speed = self.sensordistance / delay
            print("Estimated vortex speed is " + str(speed) + " meters / sec!")
            self.lookingforvortex = False
Exemplo n.º 4
0
  def my_handler(self, channel, data):
    msg = vortex_sensor_t.decode(data)
    
    # Print statements for receiving messages

    #print("Received message on channel \"%s\"" % channel)
    #print("   sensor1   = %s" % str(msg.sensor1))
    #print("   sensor2    = %s" % str(msg.sensor2))
    #print("")

    # Sensor 2 is up front
    if msg.sensor2 > 5 and not self.lookingforvortex:
      print("She's a beauty!  Vortex at the front sensor!")
      self.start = time.time()
      self.lookingforvortex = True

    if msg.sensor1 > 5 and self.lookingforvortex:
      print("She's at the rear now!")
      delay = time.time() - self.start
      print("That took " + str(delay) + " seconds!")
      speed = self.sensordistance / delay
      print("Estimated vortex speed is " + str(speed) + " meters / sec!")
      self.lookingforvortex = False