F17: Rolling Thunder
Contents
- 1 Legend
- 2 Team Members & Responsibilities
- 3 Abstract
- 4 Schedule
- 5 Parts List & Cost
- 6 Master Controller
- 7 Sensor Controller
- 8 Motor & I/O Controller
- 9 Geographical Controller
- 10 Communication Controller (Bridge)
- 11 Android App
- 12 Conclusion
- 13 References
Legend
Color | Component |
---|---|
Orange |
Master Controller |
Red |
Geographical Controller |
Indigo |
Communication Controller (Bridge) |
Green |
Motor/IO Controller |
Blue |
Sensor Controller |
Teal |
Android App |
Brown |
QA |
Team Members & Responsibilities
- Master Controller
- Akil Khan
- Jerry John
- Geographical Controller
- Abhilash Tuse
- Vishal Shrivastava
- Communication Controller (Bridge)
- Akinfemi Akin-Aluko
- Motor and I/O Controller
- Saurabh Ravindra Badenkal
- Joshua Skow
- Sona Bhasin
- Sensor Controller
- Sona Bhasin
- Thrishna Palissery
- Android App
- Johnny Nigh
- QA Team
- Akil Khan
- Saurabh Ravindra Badenkal
Abstract
A self-driving car navigates to a destination while avoiding obstacles. The car is a modified RC (remote control) car. The destination is set using an Android app.
Schedule
Start Date | End Date | Task | Status | Date of Completion | |
---|---|---|---|---|---|
1 | 09/20/2017 | 09/26/2017 |
|
Completed | 09/26/2017 |
2 | 09/27/2017 | 10/03/2017 |
|
Completed | 10/03/2017 |
3 | 10/04/2017 | 10/10/2017 |
|
Completed | 10/10/2017 |
10/10/2017 | Wiki Schedule | Completed | 10/10/2017 | ||
4 | 10/11/2017 | 10/17/2017 |
|
Completed | 10/17/2017 |
5 | 10/18/2017 | 10/24/2017 |
|
Completed | 10/24/2017 |
10/24/2017 | DBC File | Completed | 10/24/2017 | ||
10/24/2017 | DEMO: CAN communication between controllers | Completed | 10/24/2017 | ||
6 | 10/25/2017 | 10/31/2017 |
|
Completed | |
7 | 11/01/2017 | 11/07/2017 |
|
Completed | 11/07/2017 |
11/07/2017 | DEMO: Motors driven by wheel feedback and sensors, Basic obstacle avoidance
Final Wiki Schedule |
Completed | 11/07/2017 | ||
8 | 11/08/2017 | 11/14/2017 |
|
Completed | 11/14/2017 |
9 | 11/15/2017 | 11/21/2017 |
|
Completed | 11/21/2017 |
11/21/2017 | DEMO: GPS driving | Completed | 11/21/2017 | ||
10 | 11/22/2017 | 11/28/2017 |
|
Completed | |
11 | 11/29/2017 | 12/19/2017 |
|
In Progress | |
12/20/2017 | DEMO: Final Project
SUBMISSION: Final Project Wiki |
Parts List & Cost
Item # | Description | Distributor | Qty | Cost |
---|---|---|---|---|
1 | SJOne Board | Provided by Preet | 5 | $400 |
2 | RC Car - Traxxas 1/10 Slash 2WD | Amazon | 1 | $189.95 |
3 | Bluetooth Bee BLE 4.0 Module | ebay | 1 | $15 |
4 | GPS Module | Amazon | 1 | $28.99 |
5 | Compass (CMPS11) | Acroname | 1 | $45.95 |
6 | Traxxas 6520 RPM Sensor | Amazon | 1 | $10.82 |
7 | Traxxas 2991 LiPo Battery and Charger | Amazon | 1 | $199.95 |
8 | Breadboard Jumper Wires | Amazon | 1 | $6.99 |
9 | MIFFLIN Acrylic Plexiglass Clear Plastic Sheet | Amazon | 1 | $9.89 |
10 | Printed Circuit Board | Amazon | 1 | $16.83 |
11 | PCB Mounting Feet Set | Amazon | 1 | $11.99 |
12 | Traxxas 6538 Telemetry Trigger Magnet Holder | Amazon | 1 | $4.63 |
13 | MB1240 XL-MaxSonar EZ4 Ultrasonic Sensor | Amazon | 2 | $73.90 |
14 | Parallax Ping Ultrasonic Range Sensor | Amazon | 2 | $69.98 |
15 | CAN Transceiver | Microchip | 10 | Free |
16 | 4D systems 32u LCD | 4D Systems | 1 | $85.00 |
17 | Miscellaneous Items | 1 | $100.00 |
Total cost: $1,269.87
Master Controller
Design & Implementation
The master controller acts as the brainpower of the car and processes the data from the rest of the nodes to achieve smooth navigation of the car to its destination. Basically, it takes data from the sensor and geo node to ensure obstacle avoidance and navigation.
Hardware Design & Interface
Master controller does not need any other additional hardware to be connected/interfaced to it as it is responsible for implementing the obstacle avoidance and directing the car to the destination. Hence, the hardware design of master controller only consists of the node being connected to the CAN bus via CAN transceiver module. The figure shows the hardware design of the master.
- Below is the pin connection table of the master controller to the CAN bus
S.R. | CAN Transiever Pins | SJOne Board Pins |
---|---|---|
1 | Vdd | 3.3v |
2 | GND | GND |
3 | RXD | P0.1 (RXD3) |
4 | TXD | P0.0 (TXD3) |
Software Design
Show your software design. For example, if you are designing an MP3 Player, show the tasks that you are using, and what they are doing at a high level. Do not show the details of the code. For example, do not show exact code, but you may show psuedocode and fragments of code. Keep in mind that you are showing DESIGN of your software, not the inner workings of it.
Implementation
This section includes implementation, but again, not the details, just the high level. For example, you can list the steps it takes to communicate over a sensor, or the steps needed to write a page of memory onto SPI Flash. You can include sub-sections for each of your component implementation.
Testing & Technical Challenges
Describe the challenges of your project. What advise would you give yourself or someone else if your project can be started from scratch again? Make a smooth transition to testing section and described what it took to test your project.
Include sub-sections that list out a problem and solution, such as:
<Bug/issue name>
Discuss the issue and resolution.
Sensor Controller
Design & Implementation
The sensor controller oversees the functioning of ultrasonic sensors for the purpose of obstacle avoidance. The sensor controller comprises of four ultrasonic sensors interfaced to an SJOne board. XL-Maxbotix-ez4 sensors are installed on the front and back of the car respectively and Parallax ping sensors are placed to guard the sides of the car from obstacles. Based on the beam angle of each sensor, they have been mounted to protect the front and rear of the car from hitting obstacles.
XL-Maxbotix-ez4
The XL-Maxbotix-ez4 sensor can detect obstacles up to 7.65 meters and works between a supply voltage range of 3.3 V to 5.5 V. The sensor operates at 42 KHz and is equipped with inbuilt acoustic and electrical noise filtering. It has the highest noise tolerance compared to other Maxbotix sensors. It has low power consumption and can also detect small objects, This sensor is not reliable for detecting objects closer than 20cm.
Parallax ping
The Parallax ping sensor requires a supply voltage of 5 V. It can measure the distance of obstacles within a range of 3 cm to 3 m. An LED indicator on the sensor shows that the measurement is in progress. A single General-purpose input/output(GPIO) pin is used to trigger the sensor (to send an ultrasonic burst) as well as to listen for the echo pulse that is returned. The distance to the target can be calculated by measuring the width of the echo pulse.The sensor won’t be able to accurately measure the distance to obstacle in the following scenarios:
- If the object is at a distance of more than 3 meters
- If the object is too small
- The sound gets reflected off the floor if the sensor is mounted low on the device
- If the sound is reflected at a shallow angle ( < 45 °), it won’t be reflected back to the sensor
Hardware Design
The sensors are interfaced to the SJOne board on port 2 pins. The ultrasonic sensor triggering and ranging is implemented with the help of GPIO and external interrupts. All sensors and can transceiver (MCP 2551) requires a supply voltage of 5V. An external power supply is provided to SJOne board. Port 0 pins are configured as CAN receiver and transmitter. A 120 ohm resistor is used as terminating resistor for CAN bus.
Position | Maxbotix Sensor Pins | SJOne Board Pins |
---|---|---|
Front | RX - Trigger | 2.1 |
PWM - Echo | 2.3 | |
Back | RX - Trigger | 2.0 |
PWM - Echo | 2.5 |
Position | Parallax Sensor Pins | SJOne Board Pins |
---|---|---|
Left | SIG | 2.4 |
Right | SIG | 2.2 |
Hardware Interface
- Pin 2.1 of SJOne board is configured as GPIO and is connected to the RX pin (Pin 4) of Front Sensor(Maxbotix sensor)
- Pin 2.0 of SJOne board is configured as GPIO connected to the RX pin (Pin 4) of Back Sensor (Maxbotix sensor)
- Pin 2.3 of SJOne board is configured as GPIO and external interrupt is enabled for rising and falling edge. This pin is connected to the PWM (Pin 2) pin of Front Sensor (Maxbotix sensor)
- Pin 2.5 of SJOne board is configured as GPIO and external interrupt is enabled for rising and falling edge. This pin is connected to the PWM pin (Pin 2) of Back Sensor (Maxbotix sensor)
- Pin 2.4 of SJOne board is configured as GPIO and external interrupt for both rising and falling edge is also enabled. It is connected to SIG pin of left sensor (Parallax ping)
- Pin 2.2 of SJOne board is configured as GPIO and external interrupt for both rising and falling edge is also enabled. It is connected to SIG pin of right sensor (Parallax ping)
- Pin 0.0 of SJOne board is configured as RD1 and is connected to RXD pin (Pin 4) of MCP 2551 (can transceiver). Messages from other nodes are received via this pin.
- Pin 0.1 of SJOne board is configured as TD1 and is connected to TXD pin (Pin 1) of MCP 2551 (can transceiver). The sensor values are tranmitted over the CAN BUS via this pin.
CAN DBC Message: sensor node BO_ 200 SENSOR_DATA: 5 SENSOR SG_ SENSOR_left_sensor : 0|8@1+ (1,0) [0|0] "Inches" MASTER,BRIDGE SG_ SENSOR_middle_sensor : 8|9@1+ (1,0) [0|0] "Inches" MASTER,BRIDGE SG_ SENSOR_right_sensor : 17|8@1+ (1,0) [0|0] "Inches" MASTER,BRIDGE SG_ SENSOR_back_sensor : 25|9@1+ (1,0) [0|0] "Inches" MASTER,BRIDGE
CAN 1 of sensor controller (SJOne board) is configured and used for transmitting all sensor values (distance to obstacles) to the master controller.
Software Design
The front and the back sensors (Maxbotix sensors) are triggered first by driving their respective Rx pin (Pin 4 of the sensors) high for around 25 microseconds. The PW (Pin 2 of the sensors) pin is set high after the Rx pin is triggered and will be set to low if an object is detected. The PW pin will be held high for 44.4 milliseconds(ms) in case if no obstacle is detected. The front and back sensors are triggered at 10 ms,100ms,200ms, 300ms… and so on. The left and right sensors (parallax ping sensors) are triggered after 50ms is elapsed from the time the Maxbotix sensors are triggered. This is to minimize the effect of reflected waves from the maxbotix interfere with parallax ping which results in erroneous values. The SIG pin of the parallax ping sensors is set high for around 5us to send the trigger pulse. The sensor emits a short 40 kHz (ultrasonic) burst. The same pin is used for listening the echo pulse that is returned from obstacle in parallax ping. The SIG pin is set high after the trigger pulse is sent from the host microcontroller and will be set low if an obstacle is detected. The PW pin will be held high for 18 milliseconds(ms) approximately in case if no obstacle is detected. The left and right sensors are triggered at 60ms, 160ms, 260ms, 360ms… and so on. All the four sensor values will be available at every 90ms and will be transmitted over the CAN bus at 90ms, 190ms, 290ms, 390ms and so on… Triggering as well as transmission of the sensor values over the CAN bus is handled in 100Hz periodic task with proper elapsed time count check. A heartbeat message is transmitted to master controller using 1Hz periodic task
Implementation
Steps for triggering and distance calculation for Maxbotix sensors:
- Configure the micro-controller pin which is connected to the RX pin of the sensor as output
- Configure the micro-controller pin which is connected to the PWM pin of the sensor as input
- Enable external interrupts for rising and falling edge for the pin connected to PWM pin of sensor
- Trigger the RX pin by sending a clean high pulse through host micro-controller
- Set GPIO pin connected to RX as low (for a clean high pulse)
- Give delay of ~2us
- Set GPIO pin connected to RX as high
- Give delay of ~25us
- Set GPIO pin connected to RX as low
- Get the time at which rising edge interrupt occurs on micro-controller pin connected to PWM (start time)
- Get the time at which falling edge interrupt occurs on micro-controller pin connected to PWMT(stop time )
- Calculate the distance in inches to the obstacle using the formula: Distance = [ ( start_time – stop_time ) / 147 ] ( inches )
- Send the calculated distance to the master controller using CAN Bus.
- Repeat the steps 4 to 8
Steps for triggering and distance calculation for Parallax ping sensors:
- Enable external interrupts for rising and falling edge for the pin connected to PWM pin of sensor
- Configure the micro-controller pin which is connected to the SIG pin of the sensor as output
- Trigger the SIG pin by sending a clean high pulse through host micro-controller
- Set GPIO pin connected to SIG as low (for a clean high pulse)
- Give delay of ~2us
- Set GPIO pin connected to SIG as high
- Give delay of ~5us
- Set GPIO pin connected to SIG as low
- Configure the micro-controller pin which is connected to the SIG pin of the sensor as input
- Get the time at which rising edge interrupt occurs on microcontroller pin connected to SIG (start time)
- Get the time at which falling edge interrupt occurs on microcontroller pin connected to SIG (stop time)
- Calculate the distance in inches to the obstacle using the formula: Distance = [ ( start_time – stop_time ) / 147 ] ( inches )
- Send the calculated distance to the master controller using CAN Bus.
- Repeat the steps 2 to 8
Plot of Sensor Readings on Bus Master
Testing & Technical Challenges
Interference between sensors
Issue: Due to the placement of front, left and right sensors in close proximity to each other, we observed that there were inconsistencies in sensor readings on the detection of an obstacle. This was checked by monitoring sensor messages on BusMaster.
Solution: We were able to reduce the impact of interference by avoiding overlap of ranging time of sensors. To achieve this, the sensors with non-overlapping ranging areas are being triggered at a time and enough time is provided for the sensors to complete their ranging before the next set of sensors are triggered.
Blind spots to the front of the car
Issue: On putting the permanent sensor mounts in place and after subsequent testing, it was observed that there were blind spots at the front end of the car such that obstacles falling in some areas weren't being detected effectively.
Solution: To overcome the issue, we isolated the sensing area of each sensor based on their respective beam angles and adjusted the sensor positions. As a result, we were able to minimize the blind spots towards the front of the car with least interference. The tradeoff that we had to make was leaving the extreme left and right sides of the car vulnerable to collision with obstacles.
Motor & I/O Controller
Design & Implementation
The Traxxas Slash is a 2 wheel drive car makes use of two motors.
DC Motor
This motor is responsible for driving the rear wheels. This motor takes in a 100Hz duty cycle - 10-15% drives the motor in reverse, 15-20% drives the motor forward.
Servo Motor
This motor is responsible for turning the two front wheels left and right. The servo operates on the same duty cycle as the driver motor; 10-15% duty cycle turns the wheels left, 15-20% duty cycle turns the wheels right.
Display Module
The module used to display the key diagnostics of the car is a 3.2" TFT Display from 4D Systems. Apart from adding to the aesthetics of the car, it serves as an effective tool for debugging by displaying crucial car diagnostics data collected from the sensor controller, the motor controller and the geographical controller that play an important role in guiding the car from source to destination with a significant level of efficiency.
Hardware Design
The schematic of the motor controller is:
The Traxxas Slash receiver box contains 3 pin connectors for signal, input voltage (VCC) and ground. There are 4 3 pin connectors that come on the Traxxas Slash receiver - 3 of which are used for the car (Servo motor, Driver motor, and RPM sensor). The VCC of each connector is shorted together, and tied to the car battery. The grounds are all shorted as well and connected to the PCB of everything on the car.
The RPM sensor is connected physically to the gearbox, with a small magnet attached to the largest gear. There is a small hall sensor mounted next to this large gear, and every time the gear makes a revolution the hall sensor provides a high pulse indicating the a rotation. The RPM sensor signal is tied to a GPIO on the SJOne board.
The display module from 4D Systems is connected to the TX and RX pins of UART 3 communication channel, on the SJOne board, to display the status of the car on the move.
Hardware Interface
The motor controller contains the following interfaces to the SJOne board:
- PWM to the Driver motor
- PWM to the Servo motor
- GPIO to the RPM sensor
- GPIO to the ADC for battery voltage monitoring
- UART to the display module
DC Motor
Servo Motor
RPM Sensor
Battery Voltage Monitor
Display Module
The 4D Systems LCD is interfaced to the motor controller using UART communication protocol. It uses a power supply of 5V. The LCD can be programmed using the 4D Workshop4 IDE software tool. It can be connected to the PC using the accompanying 4D programming cable. To program the LCD, the compiled project file, for the GUI design, generated from the development environment is loaded on to an SD card and inserted into the card slot on the LCD. The motor controller can then send data serially to the LCD and it is displayed on the GUI for easy interpretation and debugging.
Software Design
The software design of the motor controller and the display module are explained below.
Motor Controller
The motor is abstracted as a C++ class. The motor class is able to set the Driver motor and the Servo motor.
The motor class is also responsible for taking in a desired speed, and making sure the car is driving at that speed. The motor class interprets the RPM sensor output, determines the current car speed compared to the desired car speed, and drives the motor to make the current car speed as close to the desired speed as possible.
The motor used a PID (proportional, integral, derivative) based control algorithm to keep the actual motor speed as close as possible to the desired speed. The tuning was done with the car mounted on a platform. The PID was tuned with the following method:
1. Select a proportional coefficient and change it until the motor feedback has a minimal oscillation. 2. Increase the derivative coefficient until there are no more oscillations. 3. Increase the integral coefficient until the speed increases fast enough and there is no oscillations.
Display Module
The below flowchart explains how the display module receives and transmits data.
The UART 3 communication channel is initialized at a baud rate of 9600 bps. The diagnostics data is received at the motor controller from corresponding nodes via CAN bus. The data is then populated into the LCD-specific frame format and sent to the LCD in the 1 Hz periodic task. On receiving the frame, the LCD displays the data and sends an acknowledgment back to the motor controller. Thus, the data on LCD is updated every 1 s.
Implementation
This section includes implementation, but again, not the details, just the high level. For example, you can list the steps it takes to communicate over a sensor, or the steps needed to write a page of memory onto SPI Flash. You can include sub-sections for each of your component implementation.
Motor Controller
Display Module
The LCD graphical user interface is designed using the 4D Workshop4 IDE. A screen dedicated to each controller is created using suitable objects or strings to interpret the critical car data like sensor readings, speed, GPS coordinates, distance to destination and compass data. Some of the objects used on the LCD are:
- Gauges: For displaying sensor data and battery status
- Meter: For displaying motor speed
- Angularmeter: For displaying compass direction
- LEDDigits: For displaying compass readings
In addition, strings are used to display attributes like GPS coordinates, distance to destination, motor speed, and sensor readings.
Transmission of data to LCD
The LCD expects the data, received over UART, in a specific message format depending on whether an object or string would be used to display the same.
The message format for writing to an object is as shown below.
To display any data using an object, the host controller transmits the 1-byte command code 0x01 followed by the object ID byte and the object index byte. The object ID is a value assigned to each object type to differentiate one from the other and the object index is its unique number. Both these values can be determined by referring to the quick guide provided on 4D Systems website and from the 4D Systems development environment. After sending the object index, the MSB and LSB of the data are sent. The checksum byte is calculated by XOR’ing all bytes in the message from (and including) command byte to the last parameter byte. The result is appended to the message.
The message format for writing to a string is as shown below.
For writing to string, the host controller transmits the 1-byte command code 0x02 followed by the unique string index byte. The actual data is sent as a character array of 1-byte values preceded by its length and followed by the checksum.
For every message corresponding to a 'write object' or 'write string' received by the LCD, it sends an acknowledgment ACK = 0x06 to the host controller.
LCD Screens
The screens displaying the car diagnostics corresponding to each controller are as shown below.
Testing & Technical Challenges
Describe the challenges of your project. What advise would you give yourself or someone else if your project can be started from scratch again? Make a smooth transition to testing section and described what it took to test your project.
Include sub-sections that list out a problem and solution, such as:
Problems faced by motor:
Measuring motor speed accurately
Measure the motor speed accurately (measure for # of pulses vs. time between pulses)
Knowing when the car has stopped
How to know when the car is stopped
Attaining desired speed
How to make the car be the desired speed (steps vs PID)
PID Tuning
Tuning the PID loop
Geographical Controller
Group Members
- Abhilash Tuse
- Vishal Shrivastava
Design & Implementation
The Geographical Controller is in place for navigation purpose. It has two essential parts, namely GPS and compass. It provides direction to the car, by calculating the heading angle and the distance between the coordinates, based on GPS and compass readings. To calculate heading angle, we need a compass bearing angle and angle between the line joining the two coordinates and the true north (bearing angle for GPS).
GPS Bearing angle calculation
With the reference to the figure, the bearing angle for GPS is the angle between the line joining the two coordinates and the true north. To calculate it graphically, draw a vector pointing towards the destination coordinates from the start point coordinate and measure the angle between the vector and the true north. Use the below formula to calculate the angle mathematically.
Bearing angle(α) = atan2(sin Δλ ⋅ cos φ2 , cos φ1 ⋅ sin φ2 − sin φ1 ⋅ cos φ2 ⋅ cos Δλ) where, φ1 = Latitude of 1st Coordinate φ2 = Latitude of 2nd Coordinate λ1 = Longitude of 1st Coordinate λ2 = Longitude of 2nd Coordinate Δλ = λ2 - λ1
Heading angle calculation
The heading angle is the angle between the compass vector and the vector drawn for calculating GPS bearing angle.
Heading angle(γ) = α – β where, α = Angle between the line joining the two coordinates and the true north β = Angle between compass vector and the true north (Compass bearing angle)
If heading angle is positive the car turns right or else turns left.
Distance between the two coordinates calculation
The distance between the two coordinates can be calculated using the Haversine formula.
a = sin²(Δφ/2) + cos φ1 ⋅ cos φ2 ⋅ sin²(Δλ/2) c = 2 ⋅ atan2(√a, √(1−a)) d = R ⋅ c where, φ1 = Latitude of 1st Coordinate φ2 = Latitude of 2nd Coordinate λ1 = Longitude of 1st Coordinate λ2 = Longitude of 2nd Coordinate Δφ = φ2 - φ1 Δλ = λ2 - λ1 d = distance between the two coordinates R = earth’s radius (mean radius = 6,371km) Note: All the angles should be in radians.
Hardware Design
The diagram below shows the h/w interfacing of SJ One board with GPS module and Compass module. The GPS module and the Compass module is communicating over UART3 and I2C respectively with SJ One board.
Pin mapping of GPS module with SJ One board:
GPS Module Pins | SJ One Board Pins |
---|---|
Vin | 3.3v |
GND | GND |
TX | RXD3 |
RX | TXD3 |
Pin mapping of Compass module with SJ One board:
Compass Module Pins | SJ One Board Pins |
---|---|
GND | GND |
SDA | SDA |
SCL | SCL |
Compass module requires an external power supply of 5V.
Hardware Interface
GPS Module
Gps is communicating over UART with SJ One board. The data from the GPS is updated at a 5Hz frequency. The most important part is GPS configuration. It is configured using FTDI cable and Ublox software kit. We are using settings for GPS configuration in Ublox as shown below:
Compass Module
Compass is communicating over I2C with SJ One board. The register 2 and 3 of the compass provide the compass bearing angle (0- 360 range). Calibrating the compass is an important part. We are calibrating it on ‘horizontal calibration mode’, it works for us because the compass has tilt calibration.
Calibration process: First of all, you need to enter the calibration mode by sending a 3-byte sequence of 0xF0,0xF5 and then 0xF7 to the command register, these MUST be sent in 3 separate I2C frames. There MUST be a minimum of 20ms between each I2C frame.
The LED will then extinguish and the CMPS11 should now be rotated in all directions on a horizontal plane, if a new maximum for any of the sensors is detected then the LED will flash, when you cannot get any further LED flashes in any direction then exit the calibration mode with a command of 0xF8.
Note: Please make sure that the CMPS11 is not located near to ferrous objects as this will distort the magnetic field and induce errors in the reading. While calibrating rotate the compass slowly. Only the X and Y magnetometer axis is calibrated in this mode.
We are sending 3-byte sequence command of 0xF0,0xF5 and then 0xF7 on 4th switch press and 0xF8 command on 2nd switch press of the SJ One board. You can always restore factory calibration mode by sending the 3-byte sequence command of 0x20,0x2A,0x60. We are using switch 3 to restore factory calibration.
Software Design
Show your software design. For example, if you are designing an MP3 Player, show the tasks that you are using, and what they are doing at a high level. Do not show the details of the code. For example, do not show exact code, but you may show pseudocode and fragments of code. Keep in mind that you are showing DESIGN of your software, not the inner workings of it.
CAN Communication
The following table lists the CAN messages used for communication with the Geographical controller.
Message Number | Sender | Destination | Message Name |
---|---|---|---|
0x100 | Master | Geo | MASTER_CONTROL |
0x150 | Bridge | Geo | BRIDGE_START_STOP |
0x250 | Geo | Master, Motor | GEO_DATA |
0x400 | Geo | Bridge, Motor | UPDATE_CURRENT_LOCATION |
0x450 | Geo | Motor | UPDATE_COMPASS_BEARING |
0x520 | Geo | Master | GEO_HB |
Implementation
- In 1 Hz periodic call back function
- Reset CAN Bus if bus off
- Send heartbeat signal to Master
- Send compass reading to Motor controller
- In 10 Hz periodic call back function
- Read the compass bearing angle from Compass module
- Read the GPS data string from the GPS module
- Parse the GPS string and send the current location coordinates to Bridge controller and Motor controller
- Calculate and send distance to immediate checkpoint, heading angle, and a flag to indicate final destination reached to Master controller and Motor controller
- Display the distance to immediate checkpoint on 7 segment displays on the Geo controller’s SJ one board
- Toggle the LED 4 on Geo controller’s SJ one board to indicate the GPS fix
- In 100 Hz periodic call back function
- Compass calibration routine called here
- Receive the checkpoint coordinates from the Bridge controller
Testing & Technical Challenges
GPS doesn’t retain configuration settings
Issue: Every time the GPS is powered down it forgets the configuration settings after 4-5 hours and it has to be configured again.
Solution: It could retain the configuration for some time (after powering down) because of a supercapacitor. We replaced the supercapacitor with a 3.3v battery and now it retains the configuration after it is powered down.
Compass frequently losing calibration
Issue: Compass was losing calibration because of the magnetic interference from the motors.
Solution: We wrapped the acrylic sheet (on which our compass was placed) with aluminum foil that acts as a magnetic shield for the compass. To ease the calibration process, we came up with an idea to do it on a switch press.
Unable to send complete GPS coordinates on CAN bus (with 6 decimal digits)
Issue: GPS coordinates require double data type and current python script doesn't handle it.
Solution: So we had to make changes to Python script. Reference: F16: Titans Team
Communication Controller (Bridge)
Group Members
- Akinfemi Akin-Aluko
Design & Implementation
The design section can go over your hardware and software design. Organize this section using sub-sections that go over your design and implementation.
Hardware Design
Hardware Components:
SJ-One Board Features Summary :
|
XBee Bluetooth.
|
Hardware Interface
In this section, you can describe how your hardware communicates, such as which BUSes used. You can discuss your driver implementation here, such that the Software Design section is isolated to talk about high level workings rather than inner working of your project.
Software Design
Show your software design. For example, if you are designing an MP3 Player, show the tasks that you are using, and what they are doing at a high level. Do not show the details of the code. For example, do not show exact code, but you may show psuedocode and fragments of code. Keep in mind that you are showing DESIGN of your software, not the inner workings of it.
Implementation
This section includes implementation, but again, not the details, just the high level. For example, you can list the steps it takes to communicate over a sensor, or the steps needed to write a page of memory onto SPI Flash. You can include sub-sections for each of your component implementation.
Testing & Technical Challenges
Describe the challenges of your project. What advise would you give yourself or someone else if your project can be started from scratch again? Make a smooth transition to testing section and described what it took to test your project.
Gibberish values while transmitting data from the app
Issue: Even though the website says the default xBee baud rate is 38400, it wasn't. It took a couple of days to figure why we had gibberish values.
Solution: UART speed should be accounted for when transmitting data from the app.
Android App
Design & Implementation
The app plays a crucial role in the project since it provides the checkpoints for the car's route. The app was designed for Android 7.0 (Nougat; API level 24) and requires Android 4.4 (KitKat; API level 19) or higher (up to Android 8.1, Oreo; API level 27). Google Play Services 11.0.0 or higher is required to use the Google Maps portion (for selecting the destination).
Software Design
The GUI uses a fragment instead of activities to make it easier to add more features such as a wireless CAN bus monitor (which is not included since we did not have time to complete this).
We only have one user-defined class (locationPoint) in the app.
activity_main.xml
This layout is displayed after the app is launched. The parent layout uses RelativeLayout and it contains a FrameLayout for loading fragments.
fragment_main.xml
This is the only fragment in the app. This layout uses a RelativeLayout with a child layout that uses ConstraintLayout and a child MapView.
The ConstraintLayout contains an ImageView, TextView, and Button. The ImageView and TextView are for displaying the Bluetooth connection status on the top left-hand side of the screen. Both of these components change based on the following conditions:
- Bluetooth is disabled.
- The app is connected to the Bluetooth module on the communication controller (the bridge).
- The app is not connected to the Bluetooth module.
- The app is trying to connect to the Bluetooth module.
To the right of the Bluetooth status is a Button used to set the destination and put the vehicle in self-driving mode (if the user has already tapped on a location on the map) or to stop the car manually (if the vehicle is in self-driving mode).
The rest of the screen is the MapView. The map shows the location of the vehicle using a green marker and a red marker is used to show the destination (if applicable).
build.gradle (app)
This Gradle build file contains the Play Services version requirement (11.0.0), the target SDK version (Android API level 24), minimum SDK version (Android API level 19), the key information for generating the release version of the .apk file, the compiled SDK version (Android API level 27), and the build tools version (27.0.2).
AndroidManifest.xml
The manifest file contains the permission to access the device's Bluetooth and the key for using the Google Maps Android API (the key is required to display the Google Map within the MapView component of the fragment_main.xml layout).
MainActivity.java
This is the only activity in the app and it is first loaded when the app is started. It loads the activity_main.xml layout which holds a FrameLayout. The FrameLayout is used for loading fragments.
MainFragment.java
This is the only fragment in the app and contains the ImageView and TextView objects for the Bluetooth connection status, the button for setting the destination and stopping the vehicle, and the (Google) MapView.
locationPoint.java
This is a user-defined class for each location that is used in the app (each of the checkpoints, the vehicle, and the destination). The class contains a String and double field for the latitude and corresponding fields for the longitude (there are also byte array fields for both of these coordinates).
The method processLatLong() processes the latitude and longitude so that each coordinate has six decimal places. This method also calculates the byte array versions of the latitude and longitude.
The String and double coordinates are assigned using the setLatLong(double latitude, double longitude) method, which also calls processLatLong() to get the byte array versions.
The methods getMessageNumberOfBytesLatitude() and getMessageNumberOfBytesLongitude() return the number of bytes for the coordinate in the byte array format.
strings.xml
This file stores all of the strings used in the app.
Implementation
This section reviews the implementation of the key components of the app such as establishing the Bluetooth connection between the bridge and app, the Google Maps, and the directions (using the Google Maps Directions API).
Bluetooth
We used Bluetooth sockets to connect the app and bridge controller.
First, we get a list of all of the paired Bluetooth connections on the Android device (these are stored using the Java Set interface). Second, we check each Bluetooth connection to find a paired device that has the same Bluetooth MAC address of the module on the bridge controller (if applicable).
Google Maps Android API
A key has to be generated in the Google API Console to use Google Maps within your app. This key is copied in the AndroidManifest.xml file.
Google Maps Directions API
In order to get direction, a key has to be generated in the Google API Console for the Google Maps Directions API. A request is sent to Google using a String with the following values:
Testing & Technical Challenges
There are two apps for this project.
One app was used for testing and includes two "screens"-one for basic obstacle avoidance testing and the other for navigation (the markers for each checkpoint are displayed).
The second app is for the "consumer" (everyday user) which has only one screen for navigation, does not display markers for any of the checkpoints (the only markers shown are for the vehicle and the destination), and does not have a START button (for starting obstacle avoidance "mode").
Bluetooth socket
One of the initial challenges was finding out how to connect to the socket of the Bluetooth module.
JSON
The directions are returned by Google in a JSON object. It can be difficult to parse JSON objects if you aren't familiar with doing this task.
Conclusion
By completing this project we all learned how to use a very important and necessary tool in development-Git (if we did not have experience with it previously). Git allowed us to keep track of changes to the master branch as well as branches for each of the controllers and the app. We also got hands-on experience with the CAN bus protocol which is useful for any embedded system in the automotive industry. This includes learning how to use the DBC format and the BusMaster CAN tracing tool. We were required to complete unit testing for each of the controllers. Learning TDD (Test-Driven-Development) was a challenge but overall it was a great experience for us because developing this way reduces time spent on debugging.