Difference between revisions of "2019FallTeam1"

From MAE/ECE 148 - Introduction to Autonomous Vehicles
Jump to navigation Jump to search
Line 35: Line 35:
We use the Donkey Car framework for car control.
We use the Donkey Car framework for car control.
With the framework, we can easily train deep learning autonomous driving models by recording manual driving.
With the framework, we can easily train deep learning autonomous driving models by recording manual driving.
The frameworks use modularized "parts" to manage all the components in a car. When the car runs, it loops through all parts that have been added to it.
The frameworks use modularized "parts" to manage all the components in a car. When the car runs, it loops through all parts that have been added to it.
Our project involves new sensors, ToF and Lidar, that have not been included in Donkey. They should be added to Donkey in the form of parts.


Our project involves new sensors, ToF and Lidar, that have not been included in Donkey. They should be added to Lidar in the form of parts.
We connect the Lidar and ToF(Arduino) using serial ports.
We need to add our user to a group that has access to serial ports.
<source lang="bash">sudo usermod -a -G dialout jetson</source>


We are using [http://www.ydlidar.com/product/X4 YD Lidar X4]
We are using [http://www.ydlidar.com/product/X4 YD Lidar X4]
There is a python library [https://github.com/lakshmanmallidi/PyLidar3 PyLidar3] that supports this model.
There is a python library [https://github.com/lakshmanmallidi/PyLidar3 PyLidar3] that supports this model.


The Donkey part for Lidar  
To use the PyLidar3 library
 
Create an instance and connect
<source lang="python3">
lidar = YdLidarX4("/dev/ttyUSB0")
lidar.Connect()
</source>
Scan
<source lang="python3">
scans = self.lidar.StartScanning()
for scan in scans:
    for i in range(360):
        self.scan[i] = scan[i]
</source>
Stop Lidar and disconnect
<source lang="python3">
<source lang="python3">
# in python2 it has argument (object)
lidar.StopScanning()
class YDLidar: 
lidar.Disconnect()
    # the lidar should be started as threaded
    def __init__(self, port='/dev/ttyUSB0'):
        from PyLidar3 import YdLidarX4
        self.port = port
        self.lidar = YdLidarX4(self.port)
        self.distances = [5000] * 360
        self.angles = list(range(360))
        self.scan = {}
        for i in range(360):
            self.scan[i] = 5000
        self.lidar.Connect()
        self.on = True
        self.scans = self.lidar.StartScanning()
        self.time = self.get_time()
    def update(self):
        while self.on:
            try:
                for scan in self.scans:
                    for i in range(360):
                        self.scan[i] = scan[i]
                    self.time = self.get_time()
            except serial.serialutil.SerialException:
                print('serial.serialutil.SerialException from Lidar. common when shutting down.')
    def run_threaded(self):
        return self.scan, self.time
    def shutdown(self):
        self.on = False
        time.sleep(2)  # give the update thread some time to shutdown
        self.lidar.StopScanning()
        self.lidar.Disconnect()
    def get_time(self):
        '''
        get time in milliseconds
        the granularity is ten milliseconds
        '''
        return time.time() * 1000
</source>
</source>



Revision as of 20:39, 11 December 2019

Team Members

  • Harou Xue - Electrical Engineering
  • Yuhan Zhang - Electrical Engineering
  • Cheyenne Herrera - Math/Engineering

Project Objectives

The goal of our project is to create a miniature version of a Tesla. We wanted to increase the safety of the self-driving car by implementing rear-end collision prevention as well as apply the lane change safety. The Donkey RoboCar will stop itself when approaching an object in the front using a TOF sensor mounted to it. Additionally, the car will speed up if a vehicle/object is approaching it from behind. Furthermore, the RoboCar will implement lane change on command.

Mechanical Design

Board.png


Camera Mount.png


Adjustable Camera Holder.png

Electronic Design

Components

  • Jetson Nano with fan and wirless card installed
  • PCA9685 PWM (control servo and ESC)
  • Steering Servo (control steering)
  • Electronic speed controller (ESC) (control throttle)
  • Relay (provide emergency stop)
  • LED (show emergency stop status)
  • power
  • USB camera
  • Arduino (for connecting ToF sensor)
  • Time-of-flight sensor (ToF)
  • Lidar and USB controller

Schematic

Electronic Schematic.png

Software

We use the Donkey Car framework for car control. With the framework, we can easily train deep learning autonomous driving models by recording manual driving. The frameworks use modularized "parts" to manage all the components in a car. When the car runs, it loops through all parts that have been added to it. Our project involves new sensors, ToF and Lidar, that have not been included in Donkey. They should be added to Donkey in the form of parts.

We connect the Lidar and ToF(Arduino) using serial ports. We need to add our user to a group that has access to serial ports. <source lang="bash">sudo usermod -a -G dialout jetson</source>

We are using YD Lidar X4 There is a python library PyLidar3 that supports this model.

To use the PyLidar3 library Create an instance and connect <source lang="python3"> lidar = YdLidarX4("/dev/ttyUSB0") lidar.Connect() </source> Scan <source lang="python3"> scans = self.lidar.StartScanning() for scan in scans:

   for i in range(360):
       self.scan[i] = scan[i]

</source> Stop Lidar and disconnect <source lang="python3"> lidar.StopScanning() lidar.Disconnect() </source>

Useful Knowledge

Donkey Parts

https://www.youtube.com/watch?v=YZ4ESrtfShs

How Donkey works

https://www.youtube.com/watch?v=G1JjAw_NdnE

Results

Challenges

Future Work

References