Example #1
0
    def __init__(self):

        # control algorithms
        self.pid_line_following = my_controller.pid(kp=0.8,
                                                    ki=0.0,
                                                    kd=0.0,
                                                    integral_max=1000,
                                                    output_max=1.0,
                                                    alpha=0.5)
        self.pid_wall_following = my_controller.pid(kp=0.0033,
                                                    ki=0.0003,
                                                    kd=0.1,
                                                    integral_max=1000,
                                                    output_max=1.0,
                                                    alpha=0.1)
        self.pid_speed = my_controller.pid(kp=70.0,
                                           ki=0.0,
                                           kd=100.0,
                                           integral_max=1000,
                                           output_max=50.0,
                                           alpha=0.5)

        # controller settings
        self.pid_speed_kff = 0.0  # feed forward apart from PID
        self.min_speed = 0.5  # m/s
        self.max_speed = 2.0  # m/s
        self.k_speed = 0.01
        self.positional_error_threshold = 350
        self.dual_rate = 0.5
        self.direction_trim = 0

        # controller state
        self.direction = 128
        self.throttle = 128
        self.mode = 0

        self.actual_error = 0.0
        self.pid_wall = 0.0
        self.pid_line = 0.0
        self.positional_error = 0.0

        self.actual_speed_error_ms = 0.0  # m/s
        self.target_speed_ms = 0.0  # m/s

        # controller inputs data from STM32 controller board
        self.lidar_distance_gauche = 0
        self.lidar_distance_droit = 0
        self.lidar_distance_haut = 0
        self.telemetry_speed = 0
        self.telemetry_manual_dir = 0
        self.telemetry_manual_thr = 0
        self.telemetry_auto_dir = 0
        self.telemetry_auto_thr = 0
        self.telemetry_start_button = 0
        self.actual_speed_ms = 0.0
        self.actual_speed_kmh = 0.0
        # serial port for STM32 data link
        self.port = serial.Serial("/dev/ttyUSB0", baudrate=115200, timeout=3.0)

        # global state
        self.ia = False  # control CNN and image processing
        self.running = False  # control THROTTLE !!!
        self.recording = False  # control recording video and data locally
        self.dataset = 0  # control recording of a dataset (picture,DIR,THR)

        # camera handler
        self.video_capture = 0
        self.video_broadcast = 0
        self.video_recorder = 0
        self.video_broadcast_IP_address = '10.42.0.112'  # IPv4 address of PC connectd through WiFi and receiving video stream

        # camera settings
        self.rec_width = 1280
        self.rec_height = 720
        self.new_width = 160
        self.new_height = 90

        # camera state
        self.image = 0
        self.gray = 0
        self.init_video()

        # AI handler
        self.model = 0

        # AI state
        self.line_pos = 0

        # Data logger
        self.datalogger = my_datalogger.datalogger("datalogger")

        # Dataset
        self.dataset_directory = "dataset"
        self.dataset_counter = 0
        self.dataset_file = None
Example #2
0
    def __init__(self):

        # control algorithms
        self.pid_camera_params = {
            'kp': 1.5,
            'kd': 3.0,
            'kd2': 2.0,
            'error': 0.0,
            'last_error': 0.0,
            'next_error': 0.0
        }
        self.pid_wall_following = my_controller.pid(kp=0.0033,
                                                    ki=0.0003,
                                                    kd=0.1,
                                                    integral_max=1000,
                                                    output_max=1.0,
                                                    alpha=0.1)

        # controller settings
        self.min_speed = 146
        self.max_speed = 163
        self.k_speed = 0.01
        self.positional_error_threshold = 350
        self.dual_rate = 0.5
        self.direction_trim = 0

        # controller state
        self.direction = 128
        self.throttle = 128
        self.mode = 0
        self.actual_error = 0.0
        self.pid_wall = 0.0
        self.pid_ai = 0.0
        self.positional_error = 0.0

        # controller inputs data from STM32 controller board
        self.lidar_distance_gauche = 0
        self.lidar_distance_droit = 0
        self.lidar_distance_haut = 0
        self.telemetry_speed = 0
        self.telemetry_manual_dir = 0
        self.telemetry_manual_thr = 0
        self.telemetry_auto_dir = 0
        self.telemetry_auto_thr = 0
        self.telemetry_mode = 0
        # serial port for STM32 data link
        self.port = serial.Serial("/dev/ttyUSB0", baudrate=115200, timeout=3.0)

        # global state
        self.ia = False  # control CNN and image processing
        self.running = False  # control THROTTLE !!!
        self.recording = False  # control recording video and data locally

        # camera handler
        self.video_capture = 0
        self.video_broadcast = 0
        self.video_recorder = 0
        self.video_broadcast_IP_address = '10.42.0.112'  # IPv4 address of PC connectd through WiFi and receiving video stream

        # camera settings
        self.rec_width = 1280
        self.rec_height = 720
        self.new_width = 160
        self.new_height = 90

        # camera state
        self.image = 0
        self.init_video()

        # AI handler
        self.model = 0

        # AI settings
        self.ia_version = 2

        # AI state
        self.y_1 = 0
        self.y_2 = 0
Example #3
0
    def __init__(self, host, port):

        # init (for client-server communication)
        asyncore.dispatcher.__init__(self)
        self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
        self.set_reuse_addr()
        self.bind((host, port))
        self.listen(5)

        # control
        self.pid_camera_params = {
            'kp': 1.5,
            'kd': 3.0,
            'kd2': 2.0,
            'error': 0.0,
            'last_error': 0.0,
            'next_error': 0.0
        }
        self.pid_wall_following = my_controller.pid(kp=0.0033,
                                                    ki=0.0003,
                                                    kd=0.1,
                                                    integral_max=1000,
                                                    output_max=1.0,
                                                    alpha=0.1)
        self.wall_threshold_min = 40
        self.wall_threshold_max = 160
        self.wall_distance_middle = 86
        self.direction = 128
        self.throttle = 128
        self.mode = 0
        self.min_speed = 146
        self.max_speed = 163
        self.k_speed = 0.01
        self.positional_error_threshold = 350
        self.dual_rate = 0.5
        self.direction_trim = 0
        self.actual_error = 0.0
        self.pid_wall = 0.0
        self.positional_error = 0.0

        # On met -1 pour qu'au premier calcul des pids, les Lidars ne soient pas pris en compte, car nous n'avons pas encore d'acquisition
        self.lidar_distance_gauche = 0
        self.lidar_distance_droit = 0
        self.telemetry_speed = 0
        self.telemetry_manual_dir = 0
        self.telemetry_manual_thr = 0
        self.telemetry_auto_dir = 0
        self.telemetry_auto_thr = 0
        self.telemetry_mode = 0

        # global state
        self.ia = False  # control CNN and image processing
        self.running = False  # control THROTTLE !!!
        self.recording = False  # control recording video and data locally

        self.s = 0
        self.ia_version = 2
        self.model = 0
        self.cap_send = 0
        self.out_send = 0

        self.rec_width = 0
        self.rec_height = 0

        #self.pc_IP ='10.42.0.188' #PC Section Robotique !
        self.pc_IP = '10.42.0.112'  #PC HP portable Patrick !
        #self.pc_IP ='192.168.1.34' #PC Home Patrick !
        #self.pc_IP ='192.168.1.10' #PC Home Patrick !
        #self.pc_IP ='10.0.10.50' #test card

        #serial port for STM32 communication
        self.port = serial.Serial("/dev/ttyUSB0", baudrate=115200, timeout=3.0)

        self.y_1 = 0
        self.y_2 = 0

        self.image = 0
        self.video_mode = "hires"

        if self.video_mode == "hires":

            self.rec_width = 1280
            self.rec_height = 720

            self.new_width = 160
            self.new_height = 90

        if self.video_mode == "lores":

            self.rec_width = 1280
            self.rec_height = 720

            self.new_width = 160
            self.new_height = 90

        self.init_cam()