Ejemplo n.º 1
0
def publish(command):
    rconn.publish('rover', command)
Ejemplo n.º 2
0
import commands
from settings import rconn

if __name__ == '__main__':
    while True:
        message = raw_input('Enter a command to execute: ')
        
        if commands.can_dispatch(message):        
            rconn.publish('rover', message)
        elif commands.execute(message) == False:
            break;
Ejemplo n.º 3
0
    distance = duration * speed
    distance = round(distance, 2)
    
    LOGGER.debug("Distance: {0}cm".format(distance))
    
    return distance

if __name__ == '__main__':
    delay = float(sys.argv[1])
    limit = float(sys.argv[2])
    count = int(sys.argv[3])
    
    startup()
    
    total = 0
    stop_count = 0
    while True:
        current_distance = read_distance()
        if current_distance < limit:
            stop_count += 1
            if stop_count > 3:
                LOGGER.warn("stopping rover. current distance is {0}cm".format(current_distance))
                rconn.publish('rover', 'stop')
                stop_count = 0
        else:
            stop_count=0
        time.sleep(delay)
        total += current_distance
        
    LOGGER.info("avg distance {0}".format(total/count))