S15: Cyclops: Smart RC Car

From Embedded Systems Learning Academy
Jump to: navigation, search

Grading Criteria

  • How well is Software & Hardware Design described?
  • How well can this report be used to reproduce this project?
  • Code Quality
  • Overall Report Quality:
    • Software Block Diagrams
    • Hardware Block Diagrams
      Schematic Quality
    • Quality of technical challenges and solutions adopted.

Cyclops: Smart RC Car

Abstract

The Smart RC car is an autonomous car that given a destination coordinate, drives to that location without any user interaction. It also has the ability to avoid obstacles in its path with the help of Sonar sensors.

Objectives & Introduction

In a world of autonomous systems, it is only a matter of time until we see all cars on the roads that drive themselves. Our concept for the RC car is based on that idea that cars will be able to drive themselves. The car will drive itself from a starting point to an ending point provided by the driver, which in our case is the host computer. The car will also have the capability to avoid obstacles in its path using three LV-MaxSonar-EZ0 Ultrasonic Range Sensors in the front. A GPSBee module with a SIM28 GPS receiver is being used to track the position of the car. This allows the car to navigate to the provided location autonomously. In addition to GPS navigation, a pixyCam will be used for lane detection to assist in the automated driving. So, jointly, the car will be able to drive following lanes, just like a real car on the road, and will have sensors to be able to avoid obstacles, along with reaching a destination with the help of GPS.

Team Members & Responsibilities

  • Hector Prado-Guerrero
    • GPS / Navigation Development
  • Calvin Lai
    • Sonar Sensors / Lane Guidance
  • Britto Thomas
    • Motor Control / Wireless Communication

Schedule

Week# Date Task Status Actual
1 04/17 PWM tasks Completed

Mounting equipment Completed

Some code for object tracking

Some code on GPS

PWM Complete

Mounting Complete

Object is being tracked but we need to train it to follow a specific color of tape.

Code for GPS is still being worked.

4/19

4/19

4/21

4/21

2 04/24 GPS and Compass completed

Wireless completed

Sensors completed

Compass - completed

Wireless - completed

Sensors - completed

GPS - completed

4/27

4/27

4/27

5/24

3 05/01 Obstacle avoidance Completed

GPS Navigation completed

Obstacle avoidance - mostly complete

5/24

4 05/08 Object Tracking / Lane Guidance Completed Decided to avoid lane guidance due to its complexity

and overhead along with lack of time

5 05/15 Testing and Verification In progress 5/20
6 05/22 More Testing and Verification Complete 5/24
7 05/25 Demo Date Pending

Parts List & Cost

Line Item# Part Description Vendor Part Number Qty Cost ($)
1 Lightning EPX Pro 1/10 4WD scale RC car Redcat Racing 1 200.00
2 SJSU One Board Preet Industries 3 240.00
3 GPS Bee kit (with Mini Embedded Antenna) Seeed Studio SEN133D1P 1 39.95
4 Smart Vision Sensor - Object Tracking Camera Pixy CMUcam5 1 69.00
5 Triple Axis Compass Magnetometer Sensor Module 365buying HMC5883L 1 8.99
6 2.4GHz, 3 dBi at 5Ghz Rubber Duck WiFi Antenna Embedded Works EW2458-02 2 8.00
7 Jumper Wires Pack of 100 10.00
8 XBEE Explorer USB SparkFun 5030 1 24.95
Additional Shipping $0.00
Total Cost $600.89

.

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

Discuss your hardware design here. Show detailed schematics, and the interface here.

  • Overall design
S15 146 IMG OVERALL WIRING.png
  • GPS
S15 146 G6 IMG GPS WIRING.png
  • Figure GPS_WIRING
    • As seen in figure GPS_WIRING, one can see the needed wires to connect to the GPS module in order to communicate with it via UART.

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.

  • GPS
    • For GPS, the only interface that was used, and basically the easiest one, was UART. Refer to Hardware design Figure GPS_WIRING to see the specifics on what exactly was wired.

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.

  • Tasks
    • GPS task - which handles all retrieval of GPS coordinates, and parses data, and converts into radian coordinates to be used by compass task.
    • Compass task - handles calculation of heading and bearing and uses GPS information to determine which way to go
    • PWM Task - handles the signals sent to both the Servo and Car motor. Sets speed for motors, and turns left or right for servo.

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.

GPS

S15 146 G6 IMG GPS MODULE.png

For GPS, communication can be done over a few methods: I2C, UART, SPI, etc. For this project, UART will be used to collect data from the GPS module. Here are a few steps that should be done when interfacing with GPS module.

  • 1. Plug into XBee socket.
    • a. If not using XBee socket type GPS module, then make sure to plug in the GPS VCC an appropriate power source. Make sure ground from GPS is tied in with ground from SJSU one board.
    • Then, make sure to wire the Tx pin of the GPS to the Rx pin of the SJSUOne board. If you would like to configure the GPS to, for example, only output a certain type of sentence, then wire GPS Rx to SJSUOne Tx pin.
  • 2. If you see that you aren't getting any data using a basic program to getChar from uart, then refer to Issue #2.

Magnetometer

S15 146 G6 magnetometer.jpg

The magnetometer is used to find the current heading of the car. Without this heading, it would be impossible to face the vehicle in the correct direction without first driving in an arbitrary direction to orient according to GPS location. The magnetometer is an HMC5883L which is a Triple Axis Compass Magnetometer Sensor Module. The module uses I2C for communication and outputs data in an XYZ, pitch, yaw, roll format. In order to use this data, it first needed to be converted to a heading in degrees. The HMC5883L was implemented through the existing I2C bus and can be called using a similar method as the existing peripheral sensors. It is used as an IO device and can be called using the funtion MS.getHeading(), which returns a float value of the current heading.


In order to use the magnetometer, it first needed to be initialized and configured. The existing I2C base driver was used to send messages to the device who's manufacturer's supplied address was 0x3C. Configuration for this device is stored on two 8-bit registers, Configuration Register A and Configuration Register B. Configuration Register A holds the settings for number of samples averaged per measurement output, data output rate, and the measurement configuration bias. For out purposes, we used the default settings which were eight samples averaged, 15Hz data output rate, and no measurement bias. Configuration Register B holds the gain for the magnetometer. This gain setting ensures that the raw measurements of the Earth's magnetic field are within measurable values. If the values were too large, they would not be able to fit in the 16-bit data registers.

Data is read into six separate registers. There are two registers for each X, Y, and Z readings. For our purposes the Z reading could be omitted because the magnetometer was positioned in a way where the XY plane is parallel to the Earth. The data for each reading is 16-bits wide; however, it is split into two separate 8-bit registers and is stored as a 2's compliment signed integer. In order to read the entire measurement, both registers must be read. The data obtained from these registers are raw magnetic readings and must be converted to a usable heading in degree format.

Implementation

Converting the raw magnetic data from the magnetometer was handled using a simple arctan function found in the <cmath> library. However, in order to use the arctan function, the data must first be converted into float values. The code for the conversion can be found below.

 xH = (float)buff[0]; // convert to float
 yH = (float)buff[2]; //convert to float
 tempheading = atan2(heading.y,heading.x);
 tempheading += declinationAngle; //compensate for declination
 if(tempheading < 0){
   tempheading += 2 * pi;
 }
 if(tempheading > (2 * pi)){
 tempheading -= 2 * pi;
 }
 headingDegrees = (tempheading * 180 / pi);

In order to compensate for our location on Earth and the way the Earth tilts, a declination angle must be used to compensate the final reading. This declination angle can be found at http://www.ngdc.noaa.gov/geomag-web/. The final value must also be adjust to ensure that it falls within the 0-2π range. In order to make the result more readable to us, the value was converted back into degrees.

Proximity Sensors

MB1010 LV-MaxSonar®-EZ1 front
MB1010 LV-MaxSonar®-EZ1 back

The proximity sensors used were MB1010 LV-MaxSonar®-EZ1, which were provided to us. These sensors use sound waves in order to range find and detect objects within a certain distance. The minimum distance for detection is 6 inches, while the maximum is 254 inches with a 1 inch resolution. The sensor can only range every 50ms. The sensor has three different methods to interface with.

  • RS232 Serial
  • PWM
  • Analog voltage output

During power up, the sensor

Implementation

The first method we used to try to interface with the sensor was through a UART port on our SJSUOne board. However, this proved to be troublesome as the sensor does not follow the RS232 standard and inverts all of its signals. In order to decode the signal we would have had to use a voltage inverter. To get around this, we decided to use the analog voltage output. The sensor will hold a base voltage while it sends out a pulse. As time goes on, the voltage will slowly begin to increase in 512 equal levels. The time it takes for the pulse to return to the sensor determines the final voltage it outputs over the AN pin. This results in a signal of (Vcc/512) per inch.

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:

Issue #1

Motor controls were not working as per the documentation of previous groups.

  • It is important that there is a COMMON GROUND for the motor and the servo. So we connected all the required grounds to the SJSU boards ground and it all functioned as needed.

Issue #2

GPS XBee module from Seeedstudio v1.4

  • Connecting the GPS directly into the XBee socket of the SJSU One board would not work. Reason being was that the breakout board for the GPS module created a Tx pin that was too weak to drive the Rx pin on the SJSU one board.
    • Solution: Solder a jumper wire directly to the Tx pin of the GPS chip on the breakout board, and connect that to the external Rx pin of the SJSU one board. The Rx pin of the GPS module works fine for sending commands to configure the GPS.

Issue #3

Magnetometer reading issues.

  • Reading the output from the magnetometer could be done in two ways, continuous and single reading. If we want to read continuously from the magnetometer, all six data registers must be read and then we must send a command to point back to the first data register. This proved tricky to implement with the existing I2C base driver, so we resorted to using the single reading method. This method does not require us to point back to the beginning of the data registers to take the next reading.

Issue #4

GPS XBee module from Seeedstudio v1.4

  • Trying to capture the NMEA sentences and properly parse it. The GPS outputs data constantly, and you must be able to capture that properly. Make sure to properly setup your variables in order to capture the data.
    • Solution: Captured only the exact amount of characters coming in from the GPS. Created a char array, with a certain number of elements, and used that to capture the data, the catch is, however, that you've gotta clear the array prior to capturing the data. Essentially, each time you're trying to capture the data, make sure to clear out the char array, or char* so that it doesn't somehow get messed up like it did for us.
  • For parsing through the NMEA sentence after it's been captured, the same concept must apply, you should create an array with only the number of elements you want, and make sure to clear before trying to parse. We had issues trying to set the data directly, like array[i] = nmeaSentence[i], it started overwriting stuff somehow.
    • Just use a pointer and dereference it to store it.

Conclusion

Conclude your project here. You can recap your testing and problems. You should address the "so what" part here to indicate what you ultimately learnt from this project. How has this project increased your knowledge?

Project Video

Upload a video of your project and post the link here.

Project Source Code

References

Acknowledgement

Any acknowledgement that you may wish to provide can be included here.

References Used

List any references used in project.

Appendix

You can list the references you used.