Difference between revisions of "S20: Canster Truck"

From Embedded Systems Learning Academy
Jump to: navigation, search
(Software Design)
(Software Design)
Line 839: Line 839:
 
** When the stop button is pressed, the stop command identifier is sent to the car, to stop and turn off the car.
 
** When the stop button is pressed, the stop command identifier is sent to the car, to stop and turn off the car.
 
*Info Activity:
 
*Info Activity:
 +
** Messages from Geological, Driver, Motor coming from CAN bus are decoded by the Sensor and Bridge controller and sent to the Android application as a string.
 +
** The received string is parsed and categorizes the data to store it in the required textView to be displayed.
 +
** Bluetooth status, Lidar Values, Ultrasonic Sensor Values, Motor Speed, Motor RPM, Motor PWM, Cars' current location, Compass Heading, Distance till Destination, Checkpoint Index is displayed for debugging purposes.
 
*Debug Activity:
 
*Debug Activity:
 
**The main function of this activity is to check all RAW RX and RAW TX messages and create a log of all the data received and sent.  
 
**The main function of this activity is to check all RAW RX and RAW TX messages and create a log of all the data received and sent.  

Revision as of 16:03, 20 May 2020

CAN-STER TRUCK LOGO

Abstract

The Canster Truck Project is an autonomous RC car with CAN Bus interfaced controllers. The development of the RC car's subsystem modules (Interfacing of Ultrasonic Sensor, LIDAR, Bluetooth, GPS, Compass and CAN modules) was divided among six team members. The aim of the project is to develop an autonomous RC Car which can navigate from one source location to the selected destination on the app by avoiding obstacles in its path using sensors. Waypoints algorithm is used as the path finding technique.


Introduction and Objectives

The project was divided into 7 modules:

  • Bridge and Sensor Controller
  • Motor Controller
  • Geological Controller
  • Driver and LCD Controller
  • Hardware Integration
  • Android Application
  • Testing & Code Review

RC Car Objectives

     1. Driver and LCD Controller - Handles algorithms for obstacle avoidance, route maneuvering, and waypoints
     2. Geological Controller - Recieves coordinates from GPS and Heading from Compass for navigation 
     3. Motor Controller - Controls movements of the RC Car 
     4. Bridge and Sensor Controller - Detects surrounding objects and interfaces android application to controller via bluetooth

Team Objectives

High Level System Diagram


Team Members and Responsibilities

Gitlab Project Link - Canster Truck

  • Niket Naidu LinkedIn Gitlab
    • Geological Controller
    • Driver and LCD Controller
    • Testing & Code Review
    • Android Application
  • Ganesh Ram Pamadi LinkedIn Gitlab
    • Hardware Integration
    • Testing & Code Review
    • Driver Controller
    • Motor Controller
  • Nikhil Pabbisetty LinkedIn Gitlab
    • Bridge and Sensor Controller
    • Motor Controller
  • Akhil Cherukuri LinkedIn Gitlab Github
    • Android Application
    • Geological Controller
    • Hardware Integration
  • Ashish Anant Ladage LinkedIn Gitlab
    • Driver and LCD Controller
    • Hardware Integration
    • Motor Controller
  • Jesus De Haro De Reza LinkedIn Gitlab
    • Bridge and Sensor Controller
    • Motor Controller


Administrative Responsibilities


Schedule

Week# Start Date End Date Task Status
1 02/11/2020 02/17/2020
  • Form teams and decide group name
  • Review past projects
  • Slack: Create project group and invite Preet
  • GitLab: Create project groups repository
  • Analysis of component required
  • Completed
  • Completed
  • Completed
  • Completed
  • Completed
2 02/18/2020 02/24/2020
  • Study CAN Communication
  • Create Bill of Materials
  • Order RC Car
  • Completed
  • Completed
  • Completed
3 02/25/2020 03/02/2020
  • Setup team finance management using Splitwise application
  • Complete Bill of Materials
  • Order all other required components
  • Wikipedia: Setup project report template
  • Completed
  • Completed
  • Completed
  • Completed
4 03/03/2020 03/09/2020
  • Read the respective datasheets and manuals for each component
  • Test each component for working conditions
  • Completed
  • Completed
5 03/10/2020 03/16/2020
  • Assign team responsibilities and roles
  • Setup team project management environment (ClickUp)
  • Define CAN DBC
  • Research GPS antennas and order
  • Android: Environmental setup of Android Studio and enable version control
  • Hardware : Decide PCB editing software (easyEDA)
  • Hardware : Draft schematic for required PCB design
  • Completed
  • Completed
  • Completed
  • Completed
  • Completed
  • Completed
  • Completed
6 03/17/2020 03/23/2020
  • Hardware : Create model of PCB
  • Android: Add a Button for changing bluetooth connection status in the application
  • Geological: Interface Compass module with SJ-2 board using I2C interface
  • Geological: Interface GPS module with SJ-2 board using the UART interface
  • Geological: Parse raw data to get meaningful values for GPS and Compass
  • Sensor: Interface and check the functionality of ultrasonic sensors to the SJ-2 board
  • Motor: Interface of Servo & DC motor to the SJ-2 board and check for basic functionality
  • Completed
  • Completed
  • Completed
  • Completed
  • Completed
  • Completed
  • Completed
7 03/24/2020 03/30/2020
  • Hardware : Finalize components placement on PCB.
  • Motor: Add PWM functionality and test the code on DC and servo motors
  • Sensor: Interface and check and study the output readings of Lidar sensor with SJ-2 board over UART
  • LCD Display: Explore UI designing of LCD
  • Hardware: Finalize on optimal ultrasonic sensor placements
  • Android: Initiate Bluetooth communication and show staus via text view
  • Wikipedia: Establish final wiki schedule
  • Complete CAN communication format for each controller and link DBC file to the Wiki
  • Complete high-level system block diagram
  • Complete unit-level block diagrams
  • Bridge: Interface HC-5 bluetooth module with Sj-2 board using serial communicaton
  • Completed
  • Completed
  • Completed
  • Completed
  • Completed
  • Completed
  • Completed
  • Completed
  • Completed
  • In Progress
  • Completed
8 03/31/2020 04/06/2020
  • Hardware: Analyze PCB model and order PCB Circuit board
  • Android: Initiate Bluetooth communication and send "Hello World".
  • Wikipedia: Start adding information/images/diagrams to the relevant sections
  • Motor: Configure ESC for correct speed outcome according to frequency & PWM values
  • Motor: Finish RPM sensor hardware and software implementation and integration
  • Sensor: Read output from Lidar and setup structure for outputting for DBC
  • Geological: Implement waypoints algorithm
  • Driver: Implement obstacle avoidance algorithm
  • Bridge: Pass data such as "Hello World" from HC-05 bluetooth module to bluetooth terminal android application
  • Completed
  • Completed
  • In Progress
  • Completed
  • Completed
  • In Progress
  • In Progress
  • Completed
  • In Progress
9 04/07/2020 04/13/2020
  • Hardware: Remove Unused parts from RC Car
  • Hardware: Mount PCB and 3D Parts
  • Motor: Decide different cut-off values from sensor to command right /slight right/ straight/ slight left/ left to motor.
  • Android: Embed Google Maps API for setting the car's destination.
  • LCD: Work to show RC cars live status information(battery level, current speed, long, lat, bearing, sensor data, etc)
  • Driver: Test obstacle avoidance algorithm and fine-tune sensor readings
  • Geological: Test checkpoint algorithm
  • Bridge: Establish two way communication between android application and bluetooth module
  • Update Bill of Materials for miscellaneous hardware
  • In Progress
  • In Progress
  • Completed
  • Completed
  • In Progress
  • In Progress
  • In Progress
  • In Progress
  • In Progress
10 04/14/2020 04/20/2020
  • Hardware: Integrate all hardware modules
  • LCD: Testing & Validation of the LCD UI and display vehicle status information
  • Android: Send car location to the app and checkpoints received to Geo module
  • Motor: Optimize PID control by accelerating/decelerating as instructed by Driver
  • Bridge: Configure HC-05 for auto reconnection if bluetooth communication disconnects
  • Add multiple debug messages and transmit on CAN
  • In Progress
  • In Progress
  • Completed
  • In Progress
  • In Progress
  • In Progress
11 04/21/2020 04/27/2020
  • Android: Send additional vehicle status information from RC car to the Application for display
  • Android: Finalize User Interface Design and Icon
  • Continuously test the whole system and handling of corner cases (outside).
  • Finalize RC Car For Project Proto 1
  • In Progress
  • Completed
12 04/28/2020 05/04/2020
  • Gitlab: Push final code
  • April 28th: Project Proto 1
  • Finalize RC Car for Project Demo
  • May 1st: Project Presentation
  • Finalize RC Car for Project Proto 2
13 05/05/2020 05/21/2020
  • Complete Individual Contribution Peer Grading
  • Review and Complete Wiki Project Page


Bill Of Materials

Item# Part Description Part Model & Vendor Quantity Cost in USD
1 Microcontroller Boards SJ2 Boards (Purchased from Preet Kang) 4 $200.00
2 CAN Transceivers Waveshare SN65HVD230 12 $54.48
3 RC Car Traxxas 2WD RTR with 2.4Ghz Radio 1 $260.00
4 Lithium-Ion Battery Traxxas 7600mAh 2S 7.4V 25C iD LiPo Battery Pack 1 $75.00
5 Lithium-Ion Battery Charger Traxxas 2970 EZ-Peak Plus 4-Amp NiMH/LiPo Fast Charger 1 $50.00
6 Compass Breakout Board DFRobot CMPS11 Compass 1 $29.99
7 Bluetooth Breakout Board DSD TECH Bluetooth HC-05 1 $8.49
8 LIDAR Sensor SEEED STUDIO RPLIDAR A1M8 1 $109.99
9 RPM Sensor Traxxas 6520 RPM Sensor 1 $13.70
10 GPS Breakout Board Adafruit Ultimate GPS Breakout v3 1 $44.30
11 LCD Display 4Dsystems 3.2 TFT-LCD ULCD-32PTU 1 $79.00
12 Ultrasonic Sensors ELEGOO HC-SR04 Ultrasonic Module 5 $12.00
13 GPS Antenna GPS Antenna A1-UX 1 $10.98
14 PCB Fabrication JLCPCB 5 $40.15
15 Miscellaneous Amazon,Mouser Electronics,Digikey,Anchor Electronics ~ $48.07
Total $1036.15


Printed Circuit Board

Design And Architecture

The complete PCB (for boards and hardware peripherals) was designed using EasyEDA online software. The 4 nodes will be communicating via CAN bus and other peripherals are connected to the PCB via headers.

Power Section

We have 2 power banks supplying our system. And the Servo Motor, RPM sensor and DC rear Motor (via ESC) are powered using LiPo battery (6 volts).

  • Power bank #1 - Subset 2
  • Power bank #2 - Subset 1, Subset 3, Bluetooth

NOTE:

Subset 1:

1. LIDAR
2. LCD
3. Compass

Subset 2:

1. Motor node
2. Driver node
3. BS node

Subset 3:

1. Geo node
2. Back ultrasonic sensor

Fabrication

  • PCB was sent to fabrication to JLCPCB China which provided PCB with MOQ of 5 and 2 layers of PCB with common grounded the entire copper area.

DRC elements

  • Track Width = 12
  • Clearance = 10
  • Via Diameter = 24
  • Via Drill Diameter = 12

Challenges

  • Auto-routing gave lot of challenges (only ~60% success) and sometimes the online server even crashes and faces downtime. Even local routing had lot of issues. So make sure to plan your design accordingly.
  • We started our PCB design well ahead of the project. So lot of pre-planning had to be done with regard to final hardware and placement of components in order to avoid spending extra time and money while re-ordering.
  • The PCB went through a lot of internal revisions even before placing order. This was time-consuming.




PCB Layout Design in EasyEDA
PCB Schematic
  • PCB Top Layer
  • PCB Bottom Layer


CAN Communication

<Talk about your message IDs or communication strategy, such as periodic transmission, MIA management, etc.>

Hardware Design

<Show your CAN bus hardware design>

DBC File

DBC FILE: Gitlab

VERSION ""

NS_:
	BA_
	BA_DEF_
	BA_DEF_DEF_
	BA_DEF_DEF_REL_
	BA_DEF_REL_
	BA_DEF_SGTYPE_
	BA_REL_
	BA_SGTYPE_
	BO_TX_BU_
	BU_BO_REL_
	BU_EV_REL_
	BU_SG_REL_
	CAT_
	CAT_DEF_
	CM_
	ENVVAR_DATA_
	EV_DATA_
	FILTER
	NS_DESC_
	SGTYPE_
	SGTYPE_VAL_
	SG_MUL_VAL_
	SIGTYPE_VALTYPE_
	SIG_GROUP_
	SIG_TYPE_REF_
	SIG_VALTYPE_
	VAL_
	VAL_TABLE_

BS_:

BU_: DBG DRIVER IO MOTOR SENSOR GEO

BO_ 100 DRIVER_HEARTBEAT: 1 DRIVER
 SG_ DRIVER_HEARTBEAT_cmd: 0|8@1+ (1,0) [0|0] "" GEO,MOTOR,SENSOR

BO_ 101 GEO_HEARTBEAT: 1 GEO
 SG_ GEO_HEARTBEAT_cmd: 0|8@1+ (1,0) [0|0] "" DRIVER,MOTOR,SENSOR

BO_ 102 MOTOR_HEARTBEAT: 1 MOTOR
 SG_ MOTOR_HEARTBEAT_cmd: 0|8@1+ (1,0) [0|0] "" DRIVER,GEO,SENSOR

BO_ 103 SENSOR_HEARTBEAT: 1 SENSOR
 SG_ SENSOR_HEARTBEAT_cmd: 0|8@1+ (1,0) [0|0] "" DRIVER,GEO,MOTOR

BO_ 200 MOTOR_STEERING: 1 DRIVER
 SG_ MOTOR_STEERING_direction: 0|8@1- (1,0) [-2|2] "" MOTOR

BO_ 210 DRIVER_COORDINATES: 8 DRIVER
 SG_ DRIVER_COORDINATES_latitude: 0|32@1- (0.000001,-90) [-90|90] "degrees" GEO
 SG_ DRIVER_COORDINATES_longitude: 32|32@1- (0.000001,-180) [-180|180] "degrees" GEO

BO_ 220 MOTOR_SPEED: 1 DRIVER
 SG_ MOTOR_SPEED_processed: 0|8@1- (1,0) [-3|3] "" MOTOR

BO_ 300 GEO_DEGREE: 8 GEO
 SG_ GEO_DEGREE_current: 0|32@1+ (0.000001,0) [0|360] "degrees" DRIVER
 SG_ GEO_DEGREE_required: 32|32@1+ (0.000001,0) [0|360] "degrees" DRIVER

BO_ 310 GEO_DESTINATION_REACHED: 1 GEO
 SG_ GEO_DESTINATION_REACHED_cmd: 0|8@1+ (1,0) [0|0] "" DRIVER

BO_ 400 MOTOR_SPEED_FEEDBACK: 4 MOTOR
 SG_ MOTOR_SPEED_current: 0|32@1+ (0.1,0) [0|60] "kph" DRIVER

BO_ 500 SENSOR_BT_COORDINATES: 8 SENSOR
 SG_ SENSOR_BT_COORDINATES_latitude: 0|32@1- (0.000001,-90) [-90|90] "degrees" GEO
 SG_ SENSOR_BT_COORDINATES_longitude: 32|32@1- (0.000001,-180) [-180|180] "degrees" GEO

BO_ 510 SENSOR_SONARS: 8 SENSOR
 SG_ SENSOR_SONARS_left: 0|21@1+ (0.001,0) [0|0] "cm" DRIVER
 SG_ SENSOR_SONARS_right: 21|21@1+ (0.001,0) [0|0] "cm" DRIVER
 SG_ SENSOR_SONARS_middle: 42|21@1+ (0.001,0) [0|0] "cm" DRIVER

BO_ 520 SENSOR_LIDAR: 8 SENSOR
 SG_ SENSOR_LIDAR_middle: 0|16@1+ (1,0) [0|0] "cm" DRIVER
 SG_ SENSOR_LIDAR_slight_left: 16|16@1+ (1,0) [0|0] "cm" DRIVER
 SG_ SENSOR_LIDAR_slight_right: 32|16@1+ (1,0) [0|0] "cm" DRIVER
 SG_ SENSOR_LIDAR_back: 48|16@1+ (1,0) [0|0] "cm" DRIVER

BO_ 530 MOTOR_KEY: 1 SENSOR
 SG_ MOTOR_KEY_val: 0|8@1+ (1,0) [0|0] "" DRIVER

BO_ 900 GEO_CURRENT_COORDINATES: 8 GEO
 SG_ GEO_CURRENT_COORDINATES_latitude: 0|32@1- (0.000001,-90) [-90|90] "degrees" DBG
 SG_ GEO_CURRENT_COORDINATES_longitude: 32|32@1- (0.000001,-180) [-180|180] "degrees" DBG

BO_ 901 GEO_DISTANCE_FROM_DESTINATION: 4 GEO
 SG_ GEO_distance_from_destination: 0|32@1+ (0.001,0) [0|0] "meters" DBG

BO_ 902 MOTOR_INFO_DBG: 4 MOTOR
 SG_ MOTOR_INFO_DBG_rps: 0|16@1+ (1,0) [0|0] "" DBG
 SG_ MOTOR_INFO_DBG_pwm: 16|16@1+ (0.001,0) [0|0] "" DBG

BO_ 903 LIPO_BATTERY_VOLTAGE_DBG: 4 MOTOR
 SG_ LIPO_BATTERY_VOLTAGE_val: 0|32@1+ (0.01,0) [0|0] "volts" DBG

BO_ 904 CURRENT_CHECKPOINT_DBG: 1 GEO
 SG_ CURRENT_CHECKPOINT_val: 0|8@1+ (1,0) [0|0] "" DBG

CM_ "--BU (Network Node) Information--";
CM_ BU_ DRIVER "The driver controller of the car";
CM_ BU_ GEO "The geo controller of the car";
CM_ BU_ MOTOR "The motor controller of the car";
CM_ BU_ SENSOR "The sensor controller of the car";

CM_ "--BO (Message) Information--";
CM_ BO_ 100 "Driver Sync message used to synchronize the controllers";
CM_ BO_ 101 "Geo Sync message used to synchronize the controllers";
CM_ BO_ 102 "Motor Sync message used to synchronize the controllers";
CM_ BO_ 103 "Sensor Sync message used to synchronize the controllers";

CM_ BO_ 200 "Steering direction values sent by Driver Node to Motor Node";
CM_ BO_ 210 "Driver Destination coordinates sent by Driver Node";
CM_ BO_ 220 "Required motor speed computed from Driver Node to Motor Node";

CM_ BO_ 300 "Current and computer/required degree values sent by Geo Node";
CM_ BO_ 310 "Indicator signal to check if the RC car has reached the destination";

CM_ BO_ 400 "Current motor info (rps and kph) sent as feedback to the Driver Node";

CM_ BO_ 500 "Coordinate BT values (destination coordinates) sent by Sensor Node";
CM_ BO_ 510 "LIDAR - Distance from obstacle detected in each sector";
CM_ BO_ 520 "Ultrasonic Sensor - Distance from obstacle detected by each sensor";
CM_ BO_ 530 "Start/Stop signal from the Bluetooth app";

CM_ BO_ 900 "Destination coordinates for BUSMASTER debugging";
CM_ BO_ 901 "Distance from destination";
CM_ BO_ 902 "Supplied PWM value to the motor and its RPM";
CM_ BO_ 903 "LIPO Battery Voltage";
CM_ BO_ 904 "Current checkpoint of the car";

CM_ "--SG (Signal) Information for Heartbeats--";
CM_ SG_ 100 DRIVER_HEARTBEAT_cmd "Heartbeat command from the driver node";
CM_ SG_ 101 GEO_HEARTBEAT_cmd "Heartbeat command from the geological node";
CM_ SG_ 102 MOTOR_HEARTBEAT_cmd "Heartbeat command from the motor node";
CM_ SG_ 103 SENSOR_HEARTBEAT_cmd "Heartbeat command from the sensor node";

CM_ "--SG (Signal) Information for DRIVER Node--";
CM_ SG_ 200 DRIVER_STEERING_direction "Calculated Driver Steering values (-2,2) for Motor";
CM_ SG_ 210 DRIVER_COORDINATES_latitude "Destination Latitude coordinate";
CM_ SG_ 210 DRIVER_COORDINATES_longitude "Destination Longitude coordinate";
CM_ SG_ 220 MOTOR_SPEED "Calculated Driver speed values (-3,3) for Motor";

CM_ "--SG (Signal) Information for GEO Node--";
CM_ SG_ 300 GEO_DEGREE_current "Current Geo Degree relative to true north";
CM_ SG_ 300 GEO_DEGREE_required "Calculated Geo Degree computed by Haversine Formula";
CM_ SG_ 310 GEO_DESTINATION_REACHED "Indicator signal to check if the RC car has reached the destination";

CM_ "--SG (Signal) Information for MOTOR Node--";
CM_ SG_ 400 MOTOR_SPEED_FEEDBACK "Feedback speed (kph) sent by Motor Node";

CM_ "--SG (Signal) Information for SENSOR Node--";
CM_ SG_ 500 SENSOR_BT_COORDINATES_latitude "Destination Latitude received over Bluetooth";
CM_ SG_ 500 SENSOR_BT_COORDINATES_longitude "Destination Longitude received over Bluetooth";
CM_ SG_ 510 SENSOR_SONARS_left "Ultrasonic Sensor attached to the left side";
CM_ SG_ 510 SENSOR_SONARS_right "Ultrasonic Sensor attached to the right side";
CM_ SG_ 510 SENSOR_SONARS_middle "Ultrasonic Sensor attached to the middle";
CM_ SG_ 510 SENSOR_SONARS_back_left "Ultrasonic Sensor attached to the back left side";
CM_ SG_ 510 SENSOR_SONARS_back_right "Ultrasonic Sensor attached to the back right side";
CM_ SG_ 520 SENSOR_LIDAR_middle "Lidar sensing the middle sector (-15 to 15 degrees)";
CM_ SG_ 520 SENSOR_LIDAR_slight_left "Lidar sensing the slight left sector (-45 to -15 degrees)";
CM_ SG_ 520 SENSOR_LIDAR_slight_right "Lidar sensing the slight right sector (15 to 45 degrees)";
CM_ SG_ 520 SENSOR_LIDAR_back "Lidar sensing the back of the car (165 to 195 degrees)";
CM_ SG_ 530 MOTOR_KEY_val "1 -> Start the motor from the app, 0 -> Stop";

CM_ SG_ 900 GEO_CURRENT_COORDINATES_latitude "Current Latitude";
CM_ SG_ 900 GEO_CURRENT_COORDINATES_longitude "Current Longitude";
CM_ SG_ 901 GEO_distance_from_destination "Distance from destination";
CM_ SG_ 902 MOTOR_INFO_DBG_rps "Current RPS value of the motor";
CM_ SG_ 902 MOTOR_INFO_DBG_pwm "Supplied motor PWM value";
CM_ SG_ 903 LIPO_BATTERY_VOLTAGE_val "LIPO Battery Voltage";
CM_ SG_ 904 CURRENT_CHECKPOINT_val "Current checkpoint of the car";

BA_DEF_ "BusType" STRING ;
BA_DEF_ BO_ "GenMsgCycleTime" INT 0 0;
BA_DEF_ SG_ "FieldType" STRING ;

BA_DEF_DEF_ "BusType" "CAN";
BA_DEF_DEF_ "FieldType" "";
BA_DEF_DEF_ "GenMsgCycleTime" 0;

BA_ "GenMsgCycleTime" BO_ 100 1000;
BA_ "GenMsgCycleTime" BO_ 200 50;
BA_ "FieldType" SG_ 100 DRIVER_HEARTBEAT_cmd "DRIVER_HEARTBEAT_cmd";
BA_ "FieldType" SG_ 102 GEO_HEARTBEAT_cmd "GEO_HEARTBEAT_cmd";
BA_ "FieldType" SG_ 103 MOTOR_HEARTBEAT_cmd "MOTOR_HEARTBEAT_cmd";
BA_ "FieldType" SG_ 104 SENSOR_HEARTBEAT_cmd "SENSOR_HEARTBEAT_cmd";

BA_ "FieldType" SG_ 200 MOTOR_STEERING "MOTOR_STEERING";
BA_ "FieldType" SG_ 230 MOTOR_SPEED_val "MOTOR_SPEED_val";
BA_ "FieldType" SG_ 310 GEO_DESTINATION_REACHED_cmd "GEO_DESTINATION_REACHED_cmd";

VAL_ 100 DRIVER_HEARTBEAT_cmd 2 "DRIVER_HEARTBEAT_cmd_REBOOT" 1 "DRIVER_HEARTBEAT_cmd_SYNC" 0 "DRIVER_HEARTBEAT_cmd_NOOP" ;
VAL_ 101 GEO_HEARTBEAT_cmd 2 "GEO_HEARTBEAT_cmd_REBOOT" 1 "GEO_HEARTBEAT_cmd_SYNC" 0 "GEO_HEARTBEAT_cmd_NOOP";
VAL_ 102 MOTOR_HEARTBEAT_cmd 20 "MOTOR_HEARTBEAT_cmd_REBOOT" 10 "MOTOR_HEARTBEAT_cmd_SYNC" 0 "MOTOR_HEARTBEAT_cmd_NOOP" ;
VAL_ 103 SENSOR_HEARTBEAT_cmd 200 "SENSOR_HEARTBEAT_cmd_REBOOT" 100 "SENSOR_HEARTBEAT_cmd_SYNC" 0 "SENSOR_HEARTBEAT_cmd_NOOP" ;

VAL_ 200 MOTOR_STEERING_direction -2 "MOTOR_STEERING_hard_left" -1 "MOTOR_STEERING_slight_left" 0 "MOTOR_STEERING_straight" 1 "MOTOR_STEERING_slight_right" 2 "MOTOR_STEERING_hard_right";
VAL_ 220 MOTOR_SPEED_processed -3 "MOTOR_SPEED_reverse_fast" -2 "MOTOR_SPEED_reverse_medium" -1 "MOTOR_SPEED_reverse_slow" 0 "MOTOR_SPEED_neutral" 1 "MOTOR_SPEED_forward_slow" 2 "MOTOR_SPEED_forward_medium" 3 "MOTOR_SPEED_forward_fast";
VAL_ 310 GEO_DESTINATION_REACHED_cmd 1 "GEO_DESTINATION_REACHED_cmd_REACHED" 0 "GEO_DESTINATION_REACHED_cmd_NOT_REACHED";


Motor Controller

<Picture and link to Gitlab>

Hardware Design

Software Design

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

Technical Challenges

< List of problems and their detailed resolutions>



Geological Controller

<Picture and link to Gitlab>

Hardware Design

Geological Diagram

Software Design

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

Technical Challenges

< List of problems and their detailed resolutions>



Sensor [Bridge and Sensor Controller]

<Picture and link to Gitlab>

Hardware Design

Software Design

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

Technical Challenges

< List of problems and their detailed resolutions>



Bridge [Bridge and Sensor Controller]

<Picture and link to Gitlab>

Bridge functionality of the Bridge and Sensor Controller is to establish wireless communication between the SJ-2 Board and the android mobile device using the HC-05 Bluetooth module. The Bridge controller will be receiving start command with destination GEO coordinates and stop command. The Bridge controller will be transmitting the required sensor data and debug information to be displayed on the android application.


Ultrasonic Sensor

Hardware Design

This sensor uses ultrasonic beam to measure the distances. Based on the time taken between when the beam is sent and received back to the sensor, the distance is calculated in the node. Apart from 5v and GND, this sensor has 2 pins ECHO and TRIG which are interfaced to the SJ-Two board via GPIO.

Ultrasonic Sensor Diagram

Software Design

  • Init the GPIO pin connected to TRIG of the sensor as output and for ECHO as input port.
  • Attach the interrupt on the ECHO input port.
  • Store the system_clock_count before setting the trigger pulse and then set the pulse. Also keep monitoring the input port.
  • Take the system_clock_count at the instant of receiving the interrupt.

Distance = (system_clock_count_at_trig - system_clock_count_after_at_echo) / 57.14

Bridge Diagram

Software Design

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

Technical Challenges

<List of problems and their detailed resolutions>



Driver [Driver and LCD Controller]

<Picture and link to Gitlab>

Hardware Design

Software Design

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

Technical Challenges

< List of problems and their detailed resolutions>



LCD [Driver and LCD Controller]

<Picture and link to Gitlab>

Hardware Design

Software Design

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

Technical Challenges

< List of problems and their detailed resolutions>



Android Application

Gitlab

Software Design

The application consists of a total of 5 Activities:

  • Main Activity:
    • This is the app launch display screen
    • It will check for all the required permission onStart().
    • Has search button for connecting from a paired device list view
    • Once device is clicked, an intent will start the Map Activity
  • Map Activity:
    • For this requirement we are using the Google Maps Fragment, for the map fragment to function we must request an API key from Google and set the key in the manifest of the application.
    • Destination marker(Red Marker) is set using setOnMapClickListener to which the car will navigate to, the destination can be changed by clicking elsewhere on the Map Fragment. The marker can be removed using setOnMarkerClickListener.
    • When the start button is pressed, the start command identifier along with destination latitude and longitude is sent to the car via the write thread. A background thread is started along with it to indicate the current car's position(Green Marker) along with a plotline between the current position and destination.
    • When the stop button is pressed, the stop command identifier is sent to the car, to stop and turn off the car.
  • Info Activity:
    • Messages from Geological, Driver, Motor coming from CAN bus are decoded by the Sensor and Bridge controller and sent to the Android application as a string.
    • The received string is parsed and categorizes the data to store it in the required textView to be displayed.
    • Bluetooth status, Lidar Values, Ultrasonic Sensor Values, Motor Speed, Motor RPM, Motor PWM, Cars' current location, Compass Heading, Distance till Destination, Checkpoint Index is displayed for debugging purposes.
  • Debug Activity:
    • The main function of this activity is to check all RAW RX and RAW TX messages and create a log of all the data received and sent.
  • Bluetooth Connection Service Activity :
    • This is the background activity that handles all the threads required for transmission and receiving data using Bluetooth connections. It has 3 running threads which is called inside other activities using a handler:
    • Accept Thread - Listens to BluetoothServerSocket using listenUsingRfcommWithServiceRecord. In order for the RF communication socket to connect to the HC-05, we used the following UUID: 00001101-0000-1000-8000-00805F9B34FB. This is a generic SSP Bluetooth UUID that enables the socket to directly connected to HC-05 and maintain the connection.
    • Connect Thread - Creates a Bluetooth socket using createRfcommSocketToServiceRecord
    • Connected Thread - Creates socket.getInputStream(); and socket.getOutputStream(); when bytes are available in input stream it will read them into a buffer.
      • All messages for activities are done by Handler mHandler.obtainMessage(); mHandler.sendMessage();
  • Receieved string:
    • A String is sent to the Bluetooth app from HC-05 and when it receives a string with identifier "$canster", the message is prased accordingly by using the string delimiter ',' and is ended by the newline character '\n' which will remove the data from StringBuffer.
    • Example: $canster,37.339334,-121.881123,37.338713,-121.880685,10.123,20.133,30.123,10.5,88.1,99.2,-2,1,44,7,11,22,33,-3,23\n


Android Application Flowchart

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

Technical Challenges


Other hardware challenges:

  • Figuring out why various hardware peripherals (GPS, Bluetooth, LIDAR and Ultrasonic sensor) started to malfunction (devices were on but values were either inconsistent / not occurring), took a lot of time to debug. It was due to insufficient power.


Conclusion

CMPE243 gives one of the best experiences one could ever get in their academic life. The course is designed to give an insight into how the industry functions and enhances both technical and management skills. Apart from learning how to work and implement application of CAN protocol, one can get a hands-on experience with version control, unit-testing and software design. Overall it was a very great journey.

Project Video

Project Source Code

Advise for Future Students

GENERAL:

  • Form your team and start the project as early as you can.
  • Clearly discuss what role each individual should do and ensure that progress is regularly tracked so that the team doesn't fall back on any schedule.
  • Since lot of code and hardware integration is involved with this project, make sure testing is thoroughly and periodically done and make note of all the issues found.

HARDWARE:

  • Decide on how you would power up the peripherals. We had issues with Bluetooth (not connecting), GPS (lock not happening) and LIDAR (giving incorrect values). After lot of cycles of hardware and software debugging, we found that the issue was with power. Choose wisely as to which peripherals must be connected to which power bank.
  • PCB design is time consuming as there is a lot of hardware components involved and a huge responsibility falls on the designer to know the about each component. Coordinating with multiple team members and verifying with them if their respective hardware is correct takes a lot of time. So start well ahead.
  • Make sure to expose some extra GPIO and GND pins for future use.

Acknowledgement


Firstly we would like to express our gratitude to Professor Preetpal Kang for his guidance throughout the semester and providing us with this opportunity. We would also like to thank the ISA members Vignesh Kumar Venkateshwar and Aakash Vrajlal Chitroda for being available whenever in need and guiding us to complete the project.

References

Motor Controller

Geological Controller

Bridge and Sensor Controller

Driver and LCD Controller

Android

PCB Design