Difference between revisions of "S19: Mystery Machine"

From Embedded Systems Learning Academy
Jump to: navigation, search
(Hardware Design)
(Hardware Design)
Line 449: Line 449:
 
<Show your CAN bus hardware design>
 
<Show your CAN bus hardware design>
  
[[File:CMPE243 S19 RCcar SystemArchitecture.jpg| 800px |Team Logo|Center| System Architecture]]
+
[[File:CMPE243 S19 RCcar SystemArchitecture.jpg| 800px |Team Logo|Center|System Architecture]]
  
 
System Nodes: SENSOR, MOTOR, GEO CONTROLLER, BRIDGE, MASTER
 
System Nodes: SENSOR, MOTOR, GEO CONTROLLER, BRIDGE, MASTER

Revision as of 23:34, 7 May 2019

Team Logo

Abstract

This project demonstrates the learning involved in Embedded Systems class to design a self-driving car capable of navigating through terrain and avoiding obstacles to reach a destination. The car receives destination GPS coordinates from a custom Android Application and relays back statistics and progress in reaching the target.

Introduction

The objective of this project was to create an autonomous self-driving car which was able to reach the target destination while avoiding obstacles through the terrain. In order to accomplish this, five SJ One boards were used that handled separate functionality of the car:

  • Master Controller
  • Sensor Controller
  • Geo Controller
  • Bridge Controller
  • Android Application
  • Motor and Steering Controller

Team Members & Responsibilities

<Team Picture>
Gitlab Project Link


Schedule

Week# Start Date End Date Task Status
1
  • 02/22/2019
  • 02/22/2019
  • 02/22/2019
  • 02/22/2019
  • 02/22/2019
  • 03/01/2019
  • Read previous projects, gather information and discuss among the group members.
  • Assign team responsibilities for each module.
  • Analysis of component required for each module
  • Completed
  • Completed
2
  • 03/01/2019
  • 03/01/2019
  • 03/01/2019
  • 03/01/2019
  • 03/01/2019
  • 03/01/2019
  • 03/08/2019
  • 03/08/2019
  • 03/08/2019
  • 03/08/2019
  • Project plans and timelines discussed
  • Android Application: Upload Project to GitLab and Plot Route to destination with dummy location
  • Bridge Controller: Establish access point and STA mode on ESP8266
  • Motor Controller: Understand the working of Electronic Speed Controllers and study previous project reports
  • Sensor Controller: Decide and order the sensors required for Obstacle Avoidance
  • Completed
  • Completed
  • Completed
  • Completed
  • Completed
3
  • 03/08/2019
  • 03/08/2019
  • 03/08/2019
  • 03/08/2019
  • 03/08/2019
  • 03/10/2019
  • 03/15/2019
  • 03/15/2019
  • 03/13/2019
  • 03/15/2019
  • Order the RC car and the required peripherals
  • Android Application: Create base android project with map and display activities
  • GPS Controller: Create an algorithm for the navigation system
  • Bridge Controller: Implementation of basic lightweight web server for WiFi configuration using GUI
  • Motor Controller: Work on the ESC of the RC car and develop algorithm for the Steering Control
  • Completed
  • Completed
  • Completed
  • Completed
  • Completed
4
  • 03/15/2019
  • 03/15/2019
  • 03/15/2019
  • 03/15/2019
  • 03/15/2019
  • 03/15/2019
  • 03/15/2019
  • 03/15/2019
  • Android: Get access tokens for Google API to enable maps in the application
  • GPS Controller: Get raw values from MPU9150 IMU sensor
  • Bridge Controller:Implementation of mDNS protocol for discovery of device on local subnet
  • Motor Controller: Tap into the servo motor controlling the steering
  • Completed
  • Completed
  • Completed
  • Completed
5
  • 03/08/2019
  • 03/08/2019
  • 03/08/2019
  • 03/08/2019
  • 03/08/2019
  • 03/22/2019
  • 03/22/2019
  • 03/22/2019
  • 03/22/2019
  • 03/22/2019
  • Android: Embed Google maps onto the Android App and add the project to the git repository
  • GPS Controller: Implement driver to get filtered values from the IMU
  • Bridge Controller: Implementation of local MQTT Broker on ESP8266 and Cloud broker on EC2 Instance
  • Pin Layouts from all groups
  • Motor Controller: Tap into the in-built ESC and overclock
  • Completed
  • Completed
  • Completed
  • Completed
6
  • 03/22/2019
  • 03/22/2019
  • 03/22/2019
  • 03/22/2019
  • 03/22/2019
  • 03/29/2019
  • 03/29/2019
  • 03/29/2019
  • 03/24/2019
  • 03/29/2019
  • GPS Controller: Send and receive coordinates and other parameters between Car and application
  • PCB layout 1st Iteration
  • Bridge Controller: Configure ESP8266 (as Wifi-to-serial bridge) to receiver data over Wifi and push it on UART
  • Motor Controller: Find suitable Motor Driver Module and place an order
  • Sensor Controller: Experiment with the different sensors to check for which type works best for the RC Car
  • Completed
  • Completed
  • Completed
  • Completed
7
  • 03/29/2019
  • 03/29/2019
  • 03/29/2019
  • 03/29/2019
  • 04/05/2019
  • 04/07/2019
  • 04/05/2019
  • 04/05/2019
  • GPS Controller: Send and receive coordinates and other parameters between Car and appS
  • Bridge Controller: Program for MQTT Client to UART link on ESP8266 module
  • Motor Controller: Find optimal Frequency and PWM values to drive Steering and Rear Wheels
  • Sensor Controller: Obstacle detection with SJ One board
  • Completed
  • Completed
  • Completed
  • Completed
8
  • 04/05/2019
  • 04/05/2019
  • 04/05/2019
  • 04/05/2019
  • 04/05/2019
  • 04/05/2019
  • 04/09/2019
  • 04/09/2019
  • 04/12/2019
  • 04/12/2019
  • 04/12/2019
  • 04/10/2019
  • Android: Read the current position and get user input for the destination
  • GPS Controller: Get GPS and COMPASS readings and parse them
  • Bridge Controller: MQTT to UART to CAN Bus Link and Bridge Controller MQTT to Android application Connection Link
  • Master Controller: Define and acquire DBC messages intended for master
  • Motor Controller: Implementation of basic maneuvering of the RC car
  • Sensor Controller: Integration with the RC Car and distance calculation
  • Completed
  • Completed
  • Completed
  • Completed
  • Completed
  • Completed
9
  • 04/12/2019
  • 04/12/2019
  • 04/12/2019
  • 04/12/2019
  • 04/12/2019
  • 04/12/2019
  • 04/16/2019
  • 04/16/2019
  • 04/16/2019
  • 04/16/2019
  • 04/16/2019
  • 04/16/2019
  • Android: Configure the UI elements for live monitoring in the app.
  • GPS Controller: Get the destination and waypoints from the Bridge Controller
  • Bridge Controller: Define messages and MQTT topics for bridge to app communication
  • Master Controller: Create a simple program to instruct motor ECU to drive and acquire sensor values to send stop instruction to motor ECU
  • Motor Controller: Implementation of RPM Sensor and integration with CAN Bus
  • Sensor Controller: Final Testing
  • Completed
  • Completed
  • Completed
  • Completed
  • Completed
  • Completed
10
  • 04/19/2019
  • 04/19/2019
  • 04/19/2019
  • 04/19/2019
  • 04/19/2019
  • 04/23/2019
  • 04/23/2019
  • 04/23/2019
  • 04/23/2019
  • 04/23/2019
  • Android: Define the message parameters and packing format for communication between car and app and plot the waypoints for the given coordinates
  • GPS Controller: Calculate Bearing and send navigation instructions to the Master
  • Bridge Controller: Encapsulation and parsing the data from MQTT payload
  • Master Controller: Receive navigation instructions from the GPS Controller and move the car accordingly
  • Motor Controller: Fine tuning of Speed Control and Steering control using PWM duty cycle levels
  • Completed
  • Completed
  • Completed
  • Completed
  • Completed
11
  • 04/26/2019
  • 04/26/2019
  • 04/26/2019
  • 04/26/2019
  • 04/26/2019
  • Android: Send coordinates to Car
  • GPS Controller: Mount on the car and start testing on the field and make final changes accordingly
  • Bridge Controller: Update debug messages
  • Master Controller: Implement algorithm and avoid obstacles while maintaining bearing angles as provided by Geo Controller
  • Motor Controller: Optimize control by accelerating / decelerating as instructed by Master Controller
12
  • 05/03/2019
  • 05/03/2019
  • 05/03/2019
  • 05/03/2019
  • 05/03/2019
  • Android: Add additional commands to the app (stop, reset, reroute)
  • GPS Controller: Final system testing
  • Bridge Controller: Display interfacing and final Testing
  • Master Controller: Final testing and handling of corner cases
  • Motor Controller: Final Testing
13

05/10/2019

Design and implementation of exterior body

14

05/17/2019

Resolve any issues before Final Demo

15

05/22/2019

FINAL DEMO

Parts List & Cost

Item# Part Desciption Vendor Qty Cost
1 RC Car Amazon 1 $90.00
2 CAN Transceivers MCP2551-I/P AliExpress 8 $1.13/piece

Printed Circuit Board

<Picture and information, including links to your PCB>

CAN Communication

Hardware Design

<Show your CAN bus hardware design>

System Architecture

System Nodes: SENSOR, MOTOR, GEO CONTROLLER, BRIDGE, MASTER


CAN(Controlled Area Network) is a Broadcast Bus which is heavily used in automotive industry. It defines protocol and hardware interface. It operates in standard baudrates like 100k, 125k, 250k, 500k or 1M bps. CAN uses half duplex communication over differential pair. The number of nodes affect the cable length because more CAN transeives add more capacitance to the bus.

An MCU can be interfaced to CAN bus using CAN transceiver and terminated on each end with 120 ohm resistors. Resisters are used to avoid signal reflexion. CAN is frame based communication where each frame contains ID, length(DLC), and up to 8 data bytes.Message ID field can be 11-bit or 29-bit. Only one transmitter can transmit at a time which has highest priority will go ahead first. Low priority message ID's will back-off.Lower message ID wins i.e zero is dominant.

Each node asserts an ACK if it receives a good frame. Software may or may not accept the frames. If no one ACKS, then the message is retransmitted. Depending on the CAN specifications retransmission error can be send and can eventually lead to "Bus off" state.

DBC File

<Gitlab link to your DBC file> <You can optionally use an inline image>

BU_: DBG DRIVER MASTER IO MOTOR SENSOR LIGHT BRIDGE GEO GATEWAY

BO_ 600 SONAR_SENSOR_VALUES: 4 SENSOR
 SG_ SONAR_SENSOR_VALUES_Left_Sensor : 0|9@1+ (1,0) [0|300] "cm" BRIDGE,MASTER
 SG_ SONAR_SENSOR_VALUES_Right_Sensor : 9|9@1+ (1,0) [0|300] "cm" BRIDGE,MASTER
 SG_ SONAR_SENSOR_VALUES_Front_Sensor : 18|9@1+ (1,0) [0|300] "cm" BRIDGE,MASTER

BO_ 601 DEMO_IR_SENSOR: 6 SENSOR
 SG_ LEFT_SENSOR : 0|16@1+ (1,0) [0|0] "LEFT_VALUES" MASTER
 SG_ RIGHT_SENSOR : 16|16@1+ (1,0) [0|0] "RIGHT_VALUES" MASTER
 SG_ FRONT_SENSOR : 32|16@1+ (1,0) [0|0] "FRONT_VALUES" MASTER

BO_ 602 SONAR_SENSOR_THRESHOLD: 3 BRIDGE
 SG_ UPDATE_THRESHOLD_VALUE_Left : 0|8@1+ (1,0) [0|0] "cm" MASTER
 SG_ UPDATE_THRESHOLD_VALUE_Right : 8|8@1+ (1,0) [0|0] "cm" MASTER
 SG_ UPDATE_THRESHOLD_VALUE_Front : 16|8@1+ (1,0) [0|0] "cm" MASTER

BO_ 603 STEER_CMD: 1 SENSOR
 SG_ SENSOR_STEER_DIRECTION : 0|8@1+ (1,0) [0|0] "DIRECTION" MASTER,BRIDGE

BO_ 604 SONAR_REVERSE_SENSOR: 2 SENSOR
 SG_ SONAR_REVERSE_SENSOR_value : 0|9@1+ (1,0) [0|300] "cm" BRIDGE,MASTER

BO_ 700 MOTOR_SPEED: 1 MASTER 
 SG_ MOTOR_SPEED_speed_in_mps : 0|8@1+ (0.01,0) [0|2] "mps" MOTOR,BRIDGE

BO_ 701 STEER_DIRECTION: 2 MASTER
 SG_ STEER_DIRECTION_ANGLE : 0|16@1- (1,0) [0|0] "ANGLE" MOTOR,BRIDGE

BO_ 702 DEMO_STEER_DIRECTION: 2 MASTER
 SG_ STEER_DUTY_CYCLE_VAL : 0|8@1+ (0.01,0) [0|0] "DUTY_CYCLE" MOTOR,BRIDGE

BO_ 703 DEMO_MOTOR_SPEED: 2 MASTER
 SG_ MOTOR_SPEED_DUTY_CYCLE : 0|8@1- (1,0) [-127|127] "DUTY_CYCLE" MOTOR,BRIDGE

BO_ 704 MOTOR_FLAG: 1 MOTOR
 SG_ REVERSE_FLAG : 0|8@1+ (1,0) [0|0] "MOTOR_FLAG" MASTER,BRIDGE

BO_ 740 COMPASS_DATA: 2 GEO
 SG_ COMPASS_HEADING_ANGLE : 0|9@1+ (1,0) [0|0] "DEGREES" MASTER,BRIDGE

BO_ 750 GPS_DATA: 8 GEO
 SG_ GPS_LOCK : 0|1@1- (1,0) [0|0] "" MASTER,BRIDGE
 SG_ CURRENT_GPS_COORDINATES_X : 8|28@1- (0.000001,0) [36.000000|38.000000] "" MASTER,BRIDGE
 SG_ CURRENT_GPS_COORDINATES_Y : 36|28@1- (0.000001,0) [-122.000000|-120.000000] "" MASTER,BRIDGE

BO_ 751 TELEMETRY: 8 GEO
 SG_ DISTANCE_TO_DEST : 0|8@1+ (1,0) [0|0] "" MASTER,BRIDGE

BO_ 790 MASTER_HEARTBEAT: 1 MASTER
 SG_ HEART_BEAT : 0|8@1+ (1,0) [0|0] "MASTER_HEARTBEAT" BRIDGE

BO_ 800 APP_CMD: 2 BRIDGE
 SG_ START_COMMAND : 0|8@1+ (1,0) [0|0] "" MASTER
 SG_ ABORT_COMMAND : 8|8@1+ (1,0) [0|0] "" MASTER

BO_ 805 WHEEL_ENCODER: 1 MOTOR
 SG_ WHEEL_ENCODER_data : 0|7@1+ (1,0) [0|0] "" MASTER,BRIDGE

BO_ 810 APP_DESTINATION_GPS: 8 BRIDGE
 SG_ DEST_GPS_COORDINATES_X : 0|28@1+ (0.000001,0) [0|0] "" GEO
 SG_ DEST_GPS_COORDINATES_Y : 28|28@1+ (0.000001,0) [0|0] "" GEO

BO_ 909 SENSOR_TRIGGER: 1 SENSOR
 SG_ SENSOR_TRIGGER_Trigger_status : 0|1@1+ (1,0) [0|1] "" BRIDGE

BO_ 908 SENSOR_INIT: 1 SENSOR
 SG_ SENSOR_INIT_init_Status : 0|1@1+ (1,0) [0|1] "" BRIDGE

BO_ 910 SENSOR_TIMEOUT: 1 SENSOR
 SG_ SENSOR_TIMEOUT_left : 0|1@1+ (1,0) [0|1] "" BRIDGE
 SG_ SENSOR_TIMEOUT_center : 2|1@1+ (1,0) [0|1] "" BRIDGE
 SG_ SENSOR_TIMEOUT_right : 3|1@1+ (1,0) [0|1] "" BRIDGE
 SG_ SENSOR_TIMEOUT_reverse : 4|1@1+ (1,0) [0|1] "" BRIDGE

BO_ 911 LEFT_SENSOR_ECHO_TIME: 2 SENSOR
 SG_ LEFT_SENSOR_ECHO_TIME_left_calculation_time : 0|16@1+ (1,0) [0|0] "us" BRIDGE

BO_ 912 RIGHT_SENSOR_ECHO_TIME: 2 SENSOR
 SG_ RIGHT_SENSOR_ECHO_TIME_right_calculation_time : 0|16@1+ (1,0) [0|0] "us" BRIDGE

BO_ 913 CENTER_SENSOR_ECHO_TIME: 2 SENSOR
 SG_ CENTER_SENSOR_ECHO_TIME_center_calculation_time : 0|16@1+ (1,0) [0|0] "us" BRIDGE

BO_ 917 REVERSE_SENSOR_ECHO_TIME: 2 SENSOR
 SG_ REVERSE_SENSOR_ECHO_TIME_reverse_calculation_time : 0|16@1+ (1,0) [0|0] "us" BRIDGE

BO_ 914 TOTAL_SENSOR_CALCULATION_TIME: 4 SENSOR
 SG_ TOTAL_SENSOR_CALCULATION_TIME_total_time : 0|32@1+ (1,0) [0|0] "us" BRIDGE

BO_ 915 PERIODIC_SCHEDULER_INIT: 1 SENSOR
 SG_ PERIODIC_SCHEDULER_INIT_scheduler_init_status : 0|1@1+ (1,0) [0|1] "" BRIDGE

BO_ 916 DBG_SENSOR_THRESHOLD: 4 MASTER
 SG_ THRESHOLD_VALUE_Left : 0|8@1+ (1,0) [0|0] "SONAR_DBG" BRIDGE
 SG_ THRESHOLD_VALUE_Right : 8|8@1+ (1,0) [0|0] "SONAR_DBG" BRIDGE
 SG_ THRESHOLD_VALUE_Front : 16|8@1+ (1,0) [0|0] "SONAR_DBG" BRIDGE
 SG_ THRESHOLD_VALUE_Reverse : 24|8@1+ (1,0) [0|0] "SONAR_DBG" BRIDGE

BO_ 921 SPEED_CMPS: 1 MOTOR
 SG_ SPEED_CMPS_car : 0|7@1+ (1,0) [0|0] "CAR SPEED IN CM/S" MASTER,BRIDGE

BO_ 926 MOTOR_DUTY: 1 MOTOR
 SG_ MOTOR_DUTY_CYCLE : 0|7@1+ (1,0) [0|1] "" MASTER,BRIDGE

BO_ 922 ROTATIONS_PER_SECOND: 1 MOTOR
 SG_ ROTATIONS_PER_SECOND_WHEELS : 0|7@1+ (1,0) [0|0] "CAR SPEED IN ROTATIONS/SECOND" MASTER,BRIDGE

BO_ 923 STEER_DUTY_LEFT: 1 MOTOR
 SG_ DUTY_CYCLE_LEFT : 0|7@1+ (1,0) [0|1] "" MASTER,BRIDGE

BO_ 924 STEER_DUTY_RIGHT: 1 MOTOR
 SG_ DUTY_CYCLE_RIGHT : 0|7@1+ (1,0) [0|1] "" MASTER,BRIDGE

BO_ 925 STEER_DUTY_CENTRE: 1 MOTOR
 SG_ DUTY_CYCLE_CENTRE : 0|7@1+ (1,0) [0|1] "" MASTER,BRIDGE

Sensor ECU

<Picture and link to Gitlab>

Hardware Design

Software Design

<List the code modules that are being called periodically.>

Technical Challenges

<Bullet or Headings of a module>

Unreliable sonor sensors

<Problem Summary> <Problem Resolution>



Motor ECU

<Picture and link to Gitlab>

Hardware Design

Software Design

<List the code modules that are being called periodically.>

Technical Challenges

<Bullet or Headings of a module>

Unreliable Servo Motors

<Problem Summary> <Problem Resolution>



Geographical Controller

<Picture and link to Gitlab>

The Geographical controller is responisable for navigating the car in the direction of destination selected in the android app. It uses GPS module which gives the current location of the car and compass module for getting the heading angle of the car. After a destination location is selected in the android app, using the shortest path algorithm, the app generates a pirticular number of check points. These check points are then send to bridge controller. Now Bridge controller sends one check point at a time to the Geographical controller. Geo controller uses its current location and the destination location(check point) to calculate the bearing angle and the distance to the destination. Subsequently, heading angle and bearing angle are used to determine the angle that the car should turn, and sent to the master module. On reaching destination, the car will stop.

Hardware Design

Two modules are used in Geograpgical controller: GPS and Compass

GPS

Ublox NEO-7M GPS Module is used for detecting the location of the car. This module returns NMEA string which need to be parsed to get lock, latitude and longitude values from the module. To use the GPS string first we need to get lock. Values read are valid only if we get GPS lock.

COMPASS

The MPU-9150 is first integrated 9-axis MotionTracking device that combines a 3-axis MEMS gyroscope, a 3-axis MEMS accelerometer, a 3-axis MEMS magnetometer and a Digital Motion Processor hardware accelerator engine. The MPU9150’s 9-axis MotionFusion combines acceleration and rotational motion plus heading information into a single data stream for the application.

The MPU-9150 features three 16-bit analog-to-digital converters (ADCs) for digitizing the gyroscope outputs, three 16-bit ADCs for digitizing the accelerometer outputs and three 13-bit ADCs for digitizing the magnetometer outputs. For precision tracking of both fast and slow motions, the parts feature a userprogrammable gyroscope full-scale range of ±250, ±500, ±1000, and ±2000°/sec (dps), a user programmable accelerometer full-scale range of ±2g, ±4g, ±8g, and ±16g, and a magnetometer full-scale range of ±1200µT.

Communication with all registers of the device is performed using I2C at 400 kHz.

Software Design

<List the code modules that are being called periodically.>

Technical Challenges

<Bullet or Headings of a module>

Unreliable GPS lock

<Problem Summary> <Problem Resolution>



Communication Bridge Controller & LCD

<Picture and link to Gitlab>

Hardware Design

Software Design

<List the code modules that are being called periodically.>

Technical Challenges

<Bullet or Headings of a module>

Insane Bug

<Problem Summary> <Problem Resolution>



Master Module

<Picture and link to Gitlab>

Hardware Design

Software Design

<List the code modules that are being called periodically.>

Technical Challenges

<Bullet or Headings of a module>

Improper Unit Testing

<Problem Summary> <Problem Resolution>



Mobile Application

<Picture and link to Gitlab>

Hardware Design

Software Design

<List the code modules that are being called periodically.>

Technical Challenges

<Bullet or Headings of a module>

Wifi Link Reliability

<Problem Summary> <Problem Resolution>



Conclusion

<Organized summary of the project>

<What did you learn?>

Project Video

Project Source Code

Advise for Future Students

<Bullet points and discussion>

Acknowledgement

References