Difference between revisions of "2021SpringTeam2"

From MAE/ECE 148 - Introduction to Autonomous Vehicles
Jump to: navigation, search
(PWM Signal Generation)
(PWM Signal Generation)
Line 87: Line 87:
  
 
==== PWM Signal Generation ====
 
==== PWM Signal Generation ====
For the servo PWM signal generated at pin 0, the command ledcWrite [1] was used to generate a 3.3V PWM signal of varying duty cycle based on a normalized steering command between -1 and 1 from the Jetson . For a PWM frequency of 300 Hz, a 33% duty cycle was found to correspond to full left steering and 58% corresponded to full right. Visualization of this signal is provided below:
+
For the servo PWM signal generated at pin 0, the command [https://guitar.ucsd.edu/maeece148/index.php/2021SpringTeam2#References ledcWrite] was used to generate a 3.3V PWM signal of varying duty cycle based on a normalized steering command between -1 and 1 from the Jetson . For a PWM frequency of 300 Hz, a 33% duty cycle was found to correspond to full left steering and 58% corresponded to full right. Visualization of this signal is provided below:
  
 
(VISUALIZATION OF SIGNALS)
 
(VISUALIZATION OF SIGNALS)
 
   ''Figure 9'': Servo Left, Center, and Right Signals
 
   ''Figure 9'': Servo Left, Center, and Right Signals
  
It was found that the ESC does not function with a fixed-frequency PWM signal. Instead, the ESC requires a 20 millisecond low period followed by a 1-2 millisecond high (3.3V) pulse. 1 millisecond high corresponds to full reverse rotation of the motor and 2 milliseconds corresponds to full forward rotation. To generate such a signal, the writeMicroseconds command from the ESP32Servo Library [2] was used to modulate the duration of the 3.3V pulse generated at pin 4. The visualization of this signal is shown below:
+
It was found that the ESC does not function with a fixed-frequency PWM signal. Instead, the ESC requires a 20 millisecond low period followed by a 1-2 millisecond high (3.3V) pulse. 1 millisecond high corresponds to full reverse rotation of the motor and 2 milliseconds corresponds to full forward rotation. To generate such a signal, the writeMicroseconds command from the [https://guitar.ucsd.edu/maeece148/index.php/2021SpringTeam2#References ESP32Servo Library] was used to modulate the duration of the 3.3V pulse generated at pin 4. The visualization of this signal is shown below:
  
 
(VISUALIZATION OF SIGNALS)
 
(VISUALIZATION OF SIGNALS)

Revision as of 21:04, 6 June 2021

Team Members

  • Ari Cortes – ECE Senior
  • Antoine Laget – CSE Senior (UCSD Extension)
  • Kevin Lam – MAE Senior
  • Jack Ringelberg – MAE Senior

(GROUP PICTURE)

Project Overview

In this class, students are tasked with programming a remote control car to navigate a track autonomously. This is first accomplished by using deep learning to train an AI model with the Donkey Car framework, and then tackled using Robot Operating System (ROS) to implement image processing and lane-following algorithms. In both cases, training and tuning result in a lot of eccentric behavior and crashes, so an emergency stop is implemented to minimize accidents. Currently, a relay controlled by a wireless clicker disables the PCA9685 pulse-width modulation (PWM) board, stopping steering and throttle commands from reaching the servo and motor. This assembly is not ideal because it is bulky, requires a lot of jumper wires, and causes the car to coast to a stop rather than brake. The goal of this project is to replace the relay and PWM board assembly with a single ESP32 wi-fi capable microcontroller. The ESP32 will generate PWM signals to control the servo and motor and will receive emergency stop commands through wi-fi from a user's phone or computer.

(IMAGE OF PWM+RELAY+CLICKER NEXT TO ESP32 AND A PHONE)

  Figure 1: Old and New Emergency Stop System

Must Haves

  • ESP32 generates PWM signals based on commands from Jetson Nano to control the servo and motor.
  • ESP32 functions as an access point for a phone or computer to connect to.
  • Website with a red button activates an emergency stop.

Nice to Haves

  • Heartbeat and watchdog to shutdown car when wi-fi connection or serial connection with Jetson is lost.
  • Expand website to include additional functions beyond emergency stop.

Project Video

(QUICK VIDEO OF PROJECT (I (JACK) CAN DO))

Hardware

Team 2 Car Exterior.jpg

  Figure 2: Team 2 Car

Mechanical Design

The major components of the mechanical design include the baseplate, camera mount, and Jetson Nano case.

Baseplate

Text about baseplate

(CAD)

  Figure 3: Baseplate CAD Design

Camera Mount

Text

(CAD)

  Figure 4: Camera Mount CAD Design

Jetson Nano Case

Text (LINK TO DESIGN)

(CAD)

  Figure 5: Jetson Nano Case from (WEBSITE/PERSON)

Electrical Design

The car's electrical assembly consists of eleven main components:

  1. Jetson Nano – The single board computer (SBC) in charge of controlling the remote control car.
  2. 3 Cell LiPo Battery and Alarm– The power source for the car. An alarm is attached to notify the user when the battery charge has depleted.
  3. Power Switch – Switches power to all components on the car except the electronic speed controller (ESC).
  4. DC-DC Converter – Regulates the battery voltage (anywhere from ~10-12V during operation) to a constant 5V.
  5. USB Camera – Camera connected to the Jetson via USB cable to provide a live video feed.
  6. Servo – Steers the car.
  7. Electronic Speed Controller (ESC) and Switch – Controls the DC motor based on commands from the PWM board and provides power to the servo. The ESC can be switched on or off.
  8. Brushless DC Motor – Drives the car's four wheels.
  9. PCA9685 Pusle-Width Modulation (PWM) Board – Receives commands from the Jetson Nano via I2C communication to control the steering and throttle. Generates PWM signals to send to the servo and to the ESC to be then sent to the motor. Also provides power for the status LED light.
  10. Status LED Light – LED light denoting enabled or disabled state of the car.
  11. Emergency Stop Relay – The relay is connected to a wireless remote which switches 3.3V power from the common (CO) terminal between the normally closed (NC) and normally open (NO) terminals. The disable pin (OE) of the PWM board is connected to the NC terminal, stopping generation of PWM signals when switched and therefore shutting down the steering and throttle. To denote the enabled and disabled conditions, the blue light is connected to the NC terminal of the relay and the red light is connected to the NO terminal.

Team2 WiringDiagram.png

  Figure 6: Car Wiring Diagram with Original Hardware

The ESP32 (component 9* in the new diagram) replaces components 9, 10, and 11. The ESP32 communicates with the Jetson Nano via serial communication through a USB cable. Pin 0 and 4 of the ESP32, which are capable of generating PWM signals, are connected to the PWM inputs to the servo and ESC, respectively. The 6V power output from the ESC is connected to the servo. The servo, ESC, and ESP32 are all grounded to the Jetson.

(Diagram2)

  Figure 7: Car Wiring Diagram after ESP32 Implementation

Software

Git Repository: (LINK HERE)

ESP32 (LOLIN32) Code

Web Socket

Description

(GIF)

  Figure 8: Multiple Clients Updating Simultaneously with Web Sockets

Serial Communication

Description

PWM Signal Generation

For the servo PWM signal generated at pin 0, the command ledcWrite was used to generate a 3.3V PWM signal of varying duty cycle based on a normalized steering command between -1 and 1 from the Jetson . For a PWM frequency of 300 Hz, a 33% duty cycle was found to correspond to full left steering and 58% corresponded to full right. Visualization of this signal is provided below:

(VISUALIZATION OF SIGNALS)

  Figure 9: Servo Left, Center, and Right Signals

It was found that the ESC does not function with a fixed-frequency PWM signal. Instead, the ESC requires a 20 millisecond low period followed by a 1-2 millisecond high (3.3V) pulse. 1 millisecond high corresponds to full reverse rotation of the motor and 2 milliseconds corresponds to full forward rotation. To generate such a signal, the writeMicroseconds command from the ESP32Servo Library was used to modulate the duration of the 3.3V pulse generated at pin 4. The visualization of this signal is shown below:

(VISUALIZATION OF SIGNALS)

  Figure 10: Servo Left, Center, and Right Signals

Watchdog

Description

Jetson Nano Code

ROS

ROS nodes, topics, etc. maybe a rqt graph?

Donkey AI

If we do, or if not describe how you would modify the code

App Code

How we designed and also include info on how someone would add features in the future

Quarter Milestones

Donkey Car Deep Learning Autonomous Laps

ROS Autonomous Laps

ESP32 with E-Stop

(VIDEO)

Advice and Suggestions for the Future

Advice

  • Build to Crash - No matter how carefully you drive, you will probably crash a lot! A lot of collisions occur between cars and are often not your fault. The best way to prepare for this is to ensure your mechanical parts are beefy and electrical components are covered.
  • Get Driving ASAP - Training a deep learning model at the tent track was a particularly difficult task due to the constantly changing lighting conditions. It was critical to start training early to ensure there was enough time to work out any kinks and develop a robust model. Listen to Professor Silberman and send your parts out to be manufactured in the first week!

Future Suggestions for ESP32 Use

  • Expanding ESP32 Website Functionality - Describe possible expansions and how to implement
  • Other Suggestions for the ESP32 - If we have them

Acknowledgements and References

Acknowledgements

  • Team 1 - Thank you for helping us determine the proper PWM signals to send to the motor and servo.
  • Dominic and Haoru - Thank you for debugging with us throughout the quarter.
  • Professor Silberman and Professor de Oliveira - Thank you for providing a priceless learning opportunity!

References

  1. ESP32Servo Library, John K. Bennett, 2017.