#!/usr/bin/env python # -*- coding: utf-8 -*- import logging import time import signal import sys from epuck import Controller, WrongCommand c = Controller('/dev/rfcomm0', asynchronous=True) bias = 200 too_close = 2000 max_speed = 1000 min_speed = -1000 # Signal handler to cleanup after shutdown def handle_signal(signum, frame): r = c.set_speed(0, 0) r.join() sys.exit(0) # SIGINT is interrupt signal sent by CTRL+C signal.signal(signal.SIGINT, handle_signal) while True: # Read values from proximity sensors r = c.get_proximity_sensors()
def __init__(self): logging.basicConfig(level=logging.WARNING) self.c = Controller('/dev/rfcomm0', asynchronous=True) self.state_request = None # Get first state self.state = self.c.get_turning_selector().get_response()