예제 #1
0
def main():
    car = Car_Interface(loc="/dev/ttyUSB0")
    imu = IMU_Interface(loc="/dev/ttyUSB1")
    gps = GPS_Interface(loc="/dev/ttyACM0")
    lidar = LIDAR_Interface(loc="/dev/ttyUSB2")

    sf = Sensor_Fusion(IMU=imu, GPS=gps)
    obj = Obstacle_Detection(lidar=lidar)

    car.start()
    sf.start()
    obj.start()
예제 #2
0
def main():
    car = Car_Interface(loc="/dev/ttyUSB2")
    imu = IMU_Interface(loc="/dev/ttyUSB0")
    gps = GPS_Interface(loc="/dev/ttyACM0")

    sf = Sensor_Fusion(IMU=imu, GPS=gps)

    imu.start()
    gps.start()
    car.start()
    sf.start()

    time.sleep(1)

    lat = float(input("Destination lat:"))
    long = float(input("Destination long:"))

    path = Path_Planning(long, lat, sf)
    dist = GPS_Interface.haversin(sf.gps_vector,
                                  [lat, long])  # calc distance remaining

    while True:
        correction = path.follow_path()  # calculate the correction vector

        angle = tan(correction[1] /
                    correction[0])  # convert cartesian into an angle

        sf_mag = sqrt(sf.position_x**2 + sf.position_y**
                      2)  # convert the sf position into cylindrical coords

        dif_angle = angle - sf.orientation  # calculate the angular difference
        dif_dist = dist - sf_mag  # calculate the linear difference

        # output is proportional to dif calcs, (props, have saturation implemented)
        car.steering_angle = dif_angle
        car.motor_speed = dif_dist

        print("dist:", dif_dist, "angle:", dif_angle, "correction vector:",
              correction)

        if dif_dist < 1:
            print("Reached destination")
            car.stop_thread()
            sf.stop_thread()
            return
예제 #3
0
# use this as the main thread
from threading import *
import time

from Autonomous.Sensors.LIDAR.Utils import Ray, Stack
from Autonomous.Sensors.LIDAR.LIDAR_Interface import  LIDAR_Interface
from Autonomous.Sensors.IMU.IMU_Interface import IMU_Interface
from Autonomous.Sensors.GPS.GPS_Interface import GPS_Interface
from Autonomous.Sensors.Car.Car_Interface import Car_Interface

lidar = LIDAR_Interface(loc="/dev/ttyUSB0")
imu = IMU_Interface(loc="/dev/ttyUSB1")
gps = GPS_Interface(loc="/dev/ttyACM0")
car = Car_Interface(loc="/dev/ttySM0")  # need to double check this on the jetson nano


if __name__ == '__main__':
    pass
예제 #4
0
from Autonomous.Sensors.Car.Car_Interface import Car_Interface
import time

if __name__ == "__main__":
    car = Car_Interface(loc='/dev/ttyUSB1')

    car.start()

    print("interface status", car.running)

    print("Starting Car")
    time.sleep(5)

    print("Indicating left led")
    car.left_led = True
    time.sleep(2.5)
    car.left_led = False

    time.sleep(1)

    print("Indicating right led")
    car.right_led = True
    time.sleep(2.5)
    car.right_led = False

    time.sleep(1)

    print("Flashing both lights")
    car.flash_led()
    time.sleep(3)
예제 #5
0
        self.connect_btn.pack()

        self.kill_btn = tk.Button(self, text="Kill", command=self._exit_car)
        self.kill_btn.pack()

    def _enable_car(self):
        self._joy_thread.start()
        print("Starting Controller")

    def _stop_car(self):
        self._joy_thread.stop_thread()
        print("Stopping controller")

    def _exit_car(self):
        self._joy_thread.exit_car()
        exit(1)

    def _connect_to_car(self):
        self._joy_thread.connect_to_car()
        print("Connecting to car")


if __name__ == "__main__":

    controller = PS4_Controller()
    car = Car_Interface(loc="/dev/ttyUSB0")
    root = tk.Tk()
    joy = CarJoy(car, controller)
    window = ManualWindow(joy)
    window.mainloop()
예제 #6
0
def main():

    print("Starting all interfaces")

    car = Car_Interface(loc="/dev/ttyUSB2")
    imu = IMU_Interface(loc="/dev/ttyUSB0")
    gps = GPS_Interface(loc="/dev/ttyACM0")

    sf = Sensor_Fusion(IMU=imu, GPS=gps)

    imu.start()
    gps.start()
    car.start()
    sf.start()

    fk_lat = 43.180208
    fk_long = -79.790125

    time.sleep(5)  # allow everything to start

    lat = float(input("Destination lat"))
    long = float(input("Destination long"))



    #pp = Path_Planning(long, lat, sf)

    while True:
        #dist = GPS_Interface.haversin(sf.gps_vector, [lat, long])
        #angle = GPS_Interface.bearing_to(sf.gps_vector, [lat, long])

        dist = GPS_Interface.haversin([fk_lat, fk_long], [lat, long])
        angle = GPS_Interface.bearing_to([fk_lat, fk_long], [lat, long])

        # convert and compare the correction vector to the car direction
        # turn until theta = 0, then drive towards the point

        dif_angle = angle - sf.orientation

        print("Distance:", dist, "angle:", angle, "error:", dif_angle)

        if dist > 3:  # 3m is the tolerance of the gps
            if abs(dif_angle) > 1:  # 1 degree of tolerance (car can't steer to that accuracy anyways)
                car.steering_angle = dif_angle
                car.motor_speed = 50
                car.left_led = True
                car.right_led = False
            else:
                # drive straight
                car.steering_angle = 0
                car.motor_speed = 100
                car.left_led = False
                car.right_led = True
        else:
            print("Done")
            car.motor_speed = 0
            car.stop_thread()
            sf.stop_thread()
            return