Difference between revisions of "2019WinterTeam7"

From MAE/ECE 148 - Introduction to Autonomous Vehicles
Jump to navigation Jump to search
 
(43 intermediate revisions by one other user not shown)
Line 1: Line 1:
== Introduction ==
== Introduction ==
Welcome to the wiki page of Team 7! Our autonomous project consists of 4 parts which are '''indoor autonomous driving''', '''outdoor autonomous driving''', '''parallel parking''' and '''stop sign recognition'''. In this wiki page we are going to walk you through our autonomous vehicle designing process.
Welcome to the wiki page of Team 7! Our autonomous vehicle project consists of 4 parts which are '''indoor autonomous driving''', '''outdoor autonomous driving''', '''parallel parking''' and '''stop sign recognition'''. In this wiki page we are going to walk you through our autonomous vehicle design process.


Our GitHub repository can be found here: [https://github.com/jerryyang1997/ECE148Team7Winter2019]
Our GitHub repository can be found here: [https://github.com/jerryyang1997/ECE148Team7Winter2019]


[[File:car1new.png | 200px]]
[[File:car1new.png | 500px]]


== Team Members ==
== Team Members ==
(Jerry) Yihui Yang
[[File:2019team07.jpg | 500px ]]
 
From left to right:


Chris Jensen
Alan Kuo


Jessica Yang
Jessica Yang


Alan Kuo
(Jerry) Yihui Yang
 
Chris Jensen


== Vehicle Design ==
== Vehicle Design ==
'''Schematics'''
'''Schematics'''


OE - Output enable. Can be used to quickly disable all outputs. When this pin is low all pins are enabled. When the pin is high the outputs are disabled. Pulled low by default.
[[File:team7schematic.png | 500px]]
 
The 12.4V Lipo battery supplies power to the Electrical Speed Controller (ESC), The relay and the Raspbberry Pi.To power a raspberry Pi, a 12V to 5V step down is needed and the output will be from a USB port so that it can power the Raspberry Pi directly. The battery power goes to a switch and then goes to the RF controlled relay, which serves as an emergency stop switch of the entire system. The COM pin of the relay is connected to the 3.3V pin on the Raspberry Pi which provides the “high logic”. The NO pin stands for the “normally open” which controls logic level for the red LED. The NC pin stands for “normally closed” which controls logic level for the blue LED and it is connected to the output enable “OE” pin on the Pulse Width Modulation (PWM) module which disables the PWM pins on logic high. With this circuit built, we are able to shut down the steering and throttle control using a remote control.  
The 12.4V Lipo battery supplies power to the Electrical Speed Controller (ESC), The relay and the Raspbberry Pi.To power a raspberry Pi, a 12V to 5V step down is needed and the output will be from a USB port so that it can power the Raspberry Pi directly. The battery power goes to a switch and then goes to the RF controlled relay, which serves as an emergency stop switch of the entire system. The COM pin of the relay is connected to the 3.3V pin on the Raspberry Pi which provides the “high logic”. The NO pin stands for the “normally open” which controls logic level for the red LED. The NC pin stands for “normally closed” which controls logic level for the blue LED and it is connected to the output enable “OE” pin on the Pulse Width Modulation (PWM) module which disables the PWM pins on logic high. With this circuit built, we are able to shut down the steering and throttle control using a remote control.  
OE - Output enable. Disables all output pins on logic high
 
Battery powers RPi thru a “step-down” converter
Battery powers RPi thru a “step-down” converter
Battery powers ESC, which controls DC motor
 
Battery powers RF relay, which is a part of the emergency stop button
Battery powers ESC, which controls DC motor
Red LED is on when PWM is disabled, blue LED is on when PWM enabled
 
PWM module controls servo motor
Battery powers RF relay, which is a part of the emergency stop button
Problem encountered:
 
Broken RF Relay :(
Red LED is on when PWM is disabled, blue LED is on when PWM enabled
Partial power failure :(
 
PWM module controls servo motor
 
'''Problem encountered:'''
 
Broken RF Relay
 
Partial power failure: since the Raspberry Pi supplies 3.3V (logic high) to the relay module, once the Raspberry loses its power, the relay module will not be able to supply that logic high to the Output Enable pin on the PWM to stop the vehicle while the ESC is still powered


'''Calibration Values'''
'''Calibration Values'''
Line 54: Line 66:
We were able to build a decent model for our vehicle to drive autonomously on the indoor track for 5 laps after collecting 16k data, a short demo can be found here:
We were able to build a decent model for our vehicle to drive autonomously on the indoor track for 5 laps after collecting 16k data, a short demo can be found here:


{{#evu:https://www.youtube.com/watch?v=HXKzBH-yZyQ&t=20s
{{#widget:YouTube|id=HXKzBH-yZyQ|start=20}}
|alignment=center
}}


== Outdoor Autonomous Driving ==
== Outdoor Autonomous Driving ==
The outdoor driving model took us much more effort to build. The first successful model we built was able to ran 3 laps autonomously, however, it only supplied a very limited throttle therefore the vehicle ran out of juice at the sharp uphill turns. This was due to the way we drove the vehicle during the training. We tried driving to slowly in the beginning so that it was able to have enough time to recognize the corners. For the following models, we supplied more constant throttles in fortunately we were able to ran our vehicle autonomously for 6 laps after training it for hundreds of laps!
The outdoor driving model took us much more effort to build. The first successful model we built was able to ran 3 laps autonomously, however, it only supplied a very limited throttle therefore the vehicle ran out of juice at the sharp uphill turns. This was due to the way we drove the vehicle during the training. We tried driving very slowly in the beginning so that it was able to have enough time to recognize the corners. For the following models, we supplied more constant throttles and fortunately we were able to ran our vehicle autonomously for 6 laps after training it for hundreds of laps!


'''Lessons learned:'''
'''Lessons learned:'''
Line 75: Line 85:
• EBU2 courtyard is really cold, bring gloves;)
• EBU2 courtyard is really cold, bring gloves;)


{{#evu:https://www.youtube.com/watch?v=nAYo9gsQZ9E&t=14s
{{#widget:YouTube|id=nAYo9gsQZ9E|start=14}}
|alignment=center
 
}}
== Parallel parking ==
'''Project inspiration and originality:'''<br>
We chose autonomous parallel parking as a part of our project because most drivers are not very good at parallel parking in the real world. Our parallel parking algorithm was inspired from fall 2018 team 2's parallel parking project. However, we were able to use one Pololu Time of Flight VL53L1X sensor to complete the entire parking procedure instead of two of them.
 
'''Spot length detection:'''<br>
[[File:spot.png | 500px]]
 
The ToF sensor is placed at the rear part of the vehicle and the vehicle will be driving with a constant throttle. The ToF sensor constantly reads value in a while loop and it will start the timer once there is a positive change in the distance reading (i.e. there is a parking spot). Then the timer the sensor will stop the timer when it detects a negative change in distance (i.e. the second edge of the spot is detected). The length of the spot will be calculated with the time difference and the constant speed the vehicle is driving. If the length is greater than a threshold, the program will break from the while loop and perform the parking procedure. If not, it will keep looking for a suitable spot.
 
'''Parking Algorithm'''
 
After the vehicle detects a suitable parking spot, the program will break out from the current while loop and it will perform the parking algorithm. Currently, we are following the awesome algorithm developed by team 2 from fall 2018. In the future, we would definitely like to optimize our algorithm to fit the vehicle into tighter spots.
 
[[File:parkingsketch.png | 500px]]
 
Screenshot credit to: Fall 2018 Team 2
 
'''Parking without break'''
 
The first parking algorithm we had simply turns off the throttle instead of breaking the vehicle, therefore the vehicle would travel an extra distance before it stops. We were able to fix this error by running a reverse PWM on the motor in order to stop the vehicle, as shown in the second video.
 
{{#widget:YouTube|id=zFrD8Qqie0I}}
 
'''Parking with break'''
 
{{#widget:YouTube|id=l8N4FTa2AsY}}
 
[[File:parkcode.png | 500px ]]
 
'''Challenges encountered'''<br>
The greatest challenge we encountered was interfacing the Raspberry Pi microcontroller with multiple ToF sensors on multiple I2C buses, which is also the main reason we simplified our parking algorithm with only one sensor. When initializing the program, we were able to turn on the first sensor and change its I2C address and then then on the second sensor so that they will have different addresses on the same I2C bus (the default address for the ToF sensor is 0x29). Unfortunately, all available python libraries for this particular sensor are not suitable for multiple sensors and we did not have enough time to fix the current python library. The way the library defines the variables are static so that when address changes the program gets confused.


We also had problem setting the throttle PWM to run backward after it runs forward. The ESC module is designed in a way that it would not suddenly change the direction of the PWM signal. To fix this problem, we had to reset the throttle PWM to neutral position, set it to a reverse PWM value, back to neutral and finally to the reverse PWM value. We also need to put some short delays between the PWM value sets.


== Parallel parking ==
[[File:2addresses.png | 500px ]]
[[File:IMG_1605.MOV | 200px]]
[[File:error.png | 500px]]


'''Potential improvements'''<br>
If we had more time on this part of the project, we would definitely try improving the current library so that we could interface with multiple sensors at the same time. We would also like to optimize our current parking algorithm to fit our vehicle into tighter spots.


== Stop Sign Recognition ==
== Stop Sign Recognition ==
'''Introduction'''<br>
The objective of this part of the project is to recognize stop signs using the pi-camera and adjust the car's throttle once a stop sign is encountered. To do this, we first did an internet search on different stop-sign xmls. We then used the Haar Cascade Classifier to load each of the models and determine the best one for detecting stop signs.
<br>
{{#widget:YouTube|id=ggCRfib4qQU}}
[[File:Stop_Detection.png|1700px|901px|thumb|center|We initialized the haar cascade classifier model and trained it using an pre-trained stop sign model. We then took an image of a stop sign using our pi camera and inputed into the model for it to recognize. The model was able to successfully output the number of stop signs found on the image.]]
[[File:Stop_Detection.png|1700px|901px|thumb|center|We initialized the haar cascade classifier model and trained it using an pre-trained stop sign model. We then took an image of a stop sign using our pi camera and inputed into the model for it to recognize. The model was able to successfully output the number of stop signs found on the image.]]
[[File:Rectangle.png | 646px|491px|thumb|center|We drew a rectangular box around the stop sign to ensure that the model works properly. While testing the model, we rotated the sign ]]
[[File:Rectangle.png | 646px|491px|thumb|center|We drew a rectangular box around the stop sign to ensure that the model works properly. While testing the model, we rotated the sign to check if the model is capable of detecting signs with different orientations, however, the model failed in doing so.]]
 
[[File:stopcode.png|1700px|901px|thumb|center| The PWM which is connected to channel 2 is initially kept at a constant throttle. Once a stop sign is recognized, the throttle stops for 1.5 seconds and then continues until a next stop sign is detected.]]
 
'''Challenges Encountered'''<br>
<ul>
While testing the pre-trained model, we found out that it only recognizes stop signs that have similar orientations, so if we rotated the stop signs it will no longer to able to recognize it. Also, we had some trouble finding the right throttle that'll allow the car to have enough time to detect the stop sign and change the throttle to 0, however through trial and error we were able to figure out the right throttle.
</ul>
 
'''Potential Improvements'''<br>
<ul>
If we had more time to work on this project, we would want to improve the sign recognition to include other signs such as speed limit and yield.
</ul>
 
== References and Resources Used ==
Team 7 would like to give special thanks to:
 
• Parallel parking inspiration from fall 2018 team 2 [https://guitar.ucsd.edu/maeece148/index.php/2018FallTeam2]
 
• OpenCV tutorial [https://www.superdatascience.com/blogs/opencv-face-detection]
 
• Professor Jack Silberman [https://www.linkedin.com/in/jacksilberman/] and professor Mauricio de Oliveira [http://control.ucsd.edu/mauricio/]
 
• The amazing tutors
 
for making this project happen!

Latest revision as of 03:58, 11 April 2022

Introduction

Welcome to the wiki page of Team 7! Our autonomous vehicle project consists of 4 parts which are indoor autonomous driving, outdoor autonomous driving, parallel parking and stop sign recognition. In this wiki page we are going to walk you through our autonomous vehicle design process.

Our GitHub repository can be found here: [1]

Car1new.png

Team Members

2019team07.jpg

From left to right:

Alan Kuo

Jessica Yang

(Jerry) Yihui Yang

Chris Jensen

Vehicle Design

Schematics

Team7schematic.png

The 12.4V Lipo battery supplies power to the Electrical Speed Controller (ESC), The relay and the Raspbberry Pi.To power a raspberry Pi, a 12V to 5V step down is needed and the output will be from a USB port so that it can power the Raspberry Pi directly. The battery power goes to a switch and then goes to the RF controlled relay, which serves as an emergency stop switch of the entire system. The COM pin of the relay is connected to the 3.3V pin on the Raspberry Pi which provides the “high logic”. The NO pin stands for the “normally open” which controls logic level for the red LED. The NC pin stands for “normally closed” which controls logic level for the blue LED and it is connected to the output enable “OE” pin on the Pulse Width Modulation (PWM) module which disables the PWM pins on logic high. With this circuit built, we are able to shut down the steering and throttle control using a remote control.

• Battery powers RPi thru a “step-down” converter

• Battery powers ESC, which controls DC motor

• Battery powers RF relay, which is a part of the emergency stop button

• Red LED is on when PWM is disabled, blue LED is on when PWM enabled

• PWM module controls servo motor

Problem encountered:

• Broken RF Relay

• Partial power failure: since the Raspberry Pi supplies 3.3V (logic high) to the relay module, once the Raspberry loses its power, the relay module will not be able to supply that logic high to the Output Enable pin on the PWM to stop the vehicle while the ESC is still powered

Calibration Values After assembling the vehicle, the circuit and installed Donkey. We were able to calibrate the steering and throttle with PWM values as follow:

Steering:

Neutral 330

Left 240

Right 420

Throttle:

Neutral 360

Forward Min 370

Forward max 450

Backward min 290

Indoor Autonomous Driving

We were able to build a decent model for our vehicle to drive autonomously on the indoor track for 5 laps after collecting 16k data, a short demo can be found here:

Outdoor Autonomous Driving

The outdoor driving model took us much more effort to build. The first successful model we built was able to ran 3 laps autonomously, however, it only supplied a very limited throttle therefore the vehicle ran out of juice at the sharp uphill turns. This was due to the way we drove the vehicle during the training. We tried driving very slowly in the beginning so that it was able to have enough time to recognize the corners. For the following models, we supplied more constant throttles and fortunately we were able to ran our vehicle autonomously for 6 laps after training it for hundreds of laps!

Lessons learned:

• Driving with constant throttle helps

• Driving closer to the red lines helps because the cracks on the track are also black and they might confuse the models with the actuall black tapes

• Drive with consistent throttle and turning angles

• The outdoor track needs taller camera mounts with a wider angle because the track is wider than the indoor track

• The best training time is from 10am to 2pm with clear sky

• EBU2 courtyard is really cold, bring gloves;)

Parallel parking

Project inspiration and originality:
We chose autonomous parallel parking as a part of our project because most drivers are not very good at parallel parking in the real world. Our parallel parking algorithm was inspired from fall 2018 team 2's parallel parking project. However, we were able to use one Pololu Time of Flight VL53L1X sensor to complete the entire parking procedure instead of two of them.

Spot length detection:
Spot.png

The ToF sensor is placed at the rear part of the vehicle and the vehicle will be driving with a constant throttle. The ToF sensor constantly reads value in a while loop and it will start the timer once there is a positive change in the distance reading (i.e. there is a parking spot). Then the timer the sensor will stop the timer when it detects a negative change in distance (i.e. the second edge of the spot is detected). The length of the spot will be calculated with the time difference and the constant speed the vehicle is driving. If the length is greater than a threshold, the program will break from the while loop and perform the parking procedure. If not, it will keep looking for a suitable spot.

Parking Algorithm

After the vehicle detects a suitable parking spot, the program will break out from the current while loop and it will perform the parking algorithm. Currently, we are following the awesome algorithm developed by team 2 from fall 2018. In the future, we would definitely like to optimize our algorithm to fit the vehicle into tighter spots.

Parkingsketch.png

Screenshot credit to: Fall 2018 Team 2

Parking without break

The first parking algorithm we had simply turns off the throttle instead of breaking the vehicle, therefore the vehicle would travel an extra distance before it stops. We were able to fix this error by running a reverse PWM on the motor in order to stop the vehicle, as shown in the second video.

Parking with break

Parkcode.png

Challenges encountered
The greatest challenge we encountered was interfacing the Raspberry Pi microcontroller with multiple ToF sensors on multiple I2C buses, which is also the main reason we simplified our parking algorithm with only one sensor. When initializing the program, we were able to turn on the first sensor and change its I2C address and then then on the second sensor so that they will have different addresses on the same I2C bus (the default address for the ToF sensor is 0x29). Unfortunately, all available python libraries for this particular sensor are not suitable for multiple sensors and we did not have enough time to fix the current python library. The way the library defines the variables are static so that when address changes the program gets confused.

We also had problem setting the throttle PWM to run backward after it runs forward. The ESC module is designed in a way that it would not suddenly change the direction of the PWM signal. To fix this problem, we had to reset the throttle PWM to neutral position, set it to a reverse PWM value, back to neutral and finally to the reverse PWM value. We also need to put some short delays between the PWM value sets.

2addresses.png Error.png

Potential improvements
If we had more time on this part of the project, we would definitely try improving the current library so that we could interface with multiple sensors at the same time. We would also like to optimize our current parking algorithm to fit our vehicle into tighter spots.

Stop Sign Recognition

Introduction
The objective of this part of the project is to recognize stop signs using the pi-camera and adjust the car's throttle once a stop sign is encountered. To do this, we first did an internet search on different stop-sign xmls. We then used the Haar Cascade Classifier to load each of the models and determine the best one for detecting stop signs.


We initialized the haar cascade classifier model and trained it using an pre-trained stop sign model. We then took an image of a stop sign using our pi camera and inputed into the model for it to recognize. The model was able to successfully output the number of stop signs found on the image.
We drew a rectangular box around the stop sign to ensure that the model works properly. While testing the model, we rotated the sign to check if the model is capable of detecting signs with different orientations, however, the model failed in doing so.
The PWM which is connected to channel 2 is initially kept at a constant throttle. Once a stop sign is recognized, the throttle stops for 1.5 seconds and then continues until a next stop sign is detected.

Challenges Encountered

    While testing the pre-trained model, we found out that it only recognizes stop signs that have similar orientations, so if we rotated the stop signs it will no longer to able to recognize it. Also, we had some trouble finding the right throttle that'll allow the car to have enough time to detect the stop sign and change the throttle to 0, however through trial and error we were able to figure out the right throttle.

Potential Improvements

    If we had more time to work on this project, we would want to improve the sign recognition to include other signs such as speed limit and yield.

References and Resources Used

Team 7 would like to give special thanks to:

• Parallel parking inspiration from fall 2018 team 2 [2]

• OpenCV tutorial [3]

• Professor Jack Silberman [4] and professor Mauricio de Oliveira [5]

• The amazing tutors

for making this project happen!