# Autonomous Power Wheel
## Problem

Motor vehicle accidents are the leading cause of death for young adults in the United States. Google has developed full-sized self-driving vehicles that are street-legal in Nevada. Stanford's autonomous vehicle won the DARPA Grand Challenge in 2005. Project Goal: Design and implement the electro-mechanical systems and software required to control a Power Wheel. The autonomous vehicle should be able to travel outdoor on specified paths while avoiding obstacles.
* Google's Lexus RX 450h Self-Driving Car

## Conceive

The Power Wheel (electric ride-on toy) must be able to autonomously drive around the campus of Howard Community College in Columbia, MD. Initially, the car will be confined to a flat open space (e.g. parking lot). The final design should be able to navigate to specified waypoints while avoiding obstacles.

## Design

The design phase involves designing subsystems in order to make the power wheel autonomous. It is obvious that these subsystems have to be able to work together with ease. In doing so, we anticipate that at some stage, the vehicle will be able to drive autonomously without any operator instructions. However, as it stands now, several subsystems must first be designed in order to replace the interactions a human driver would have. These subsystems must be both simple to build, simple to repair and improve upon.

#### Design Concepts for Subsystems

Ultrasonic Sensor Mounting :
| | Design Concept |
| a | Wooden Mount |
| b | Rotating Mounting Bracket |
| c | Wooden Plate |
| | Ease of Construction | Cost | Range of Sensor | Durability | Ease of Use | Overall Capabilities | Total Score |
| a | 4 | 4 | 2 | 3 | 4 | 2 | 19 |
| b | 2 | 2 | 5 | 3 | 3 | 5 | 20 |
| c | 4 | 4 | 4 | 4 | 4 | 3 | 23 |

#### Experimental prototypes and testing

* Video of power window motor turning steering wheel. Testing was successful, but the power window motor was inadvertently damaged and this concept was abandoned.
* Steering Wheel Mock-up for Testing
* Gas Pedal Prototype
* Compressed Pedal
* Compressed
* before on actual pedal
* after on actual pedal
Gas Pedal Presser Test Video http://youtu.be/gIV6zhy3gRI
* Base Prototype

#### Utilization of Knowledge in Design
##### Technical details and scientific principles
##### Prior work in the field, reverse engineering and redesign

Sparkfun Electronics provides an example Arduino code for controlling two motors simultaneously using the Monster Moto Shield. This sketch was the basis for the vehicle control code:

## Implement
#### Overview of Implementation Steps
### Hardware Manufacturing
#### Parts List

* Power Wheel, Fisher-Price Power Wheels Dune Racer 12-Volt Battery-Powered Ride-on, Green, $229.00 from walmart.com
* Miniature linear actuator, a Firgelli Miniature Linear Actuator L16 purchased for $70.00 from firgilli.com
* Screw motor, 12VDC, 78RPM Motor with Right Angle Leadscrew, purchased for $14.95 from mpja.com
* Ultrasonic Sensor, Ultrasonic Sensor HC-SR04 Distance Measuring Module, purchased from miniinthebox.com, for $1.98
* Arduino UNO
* Monster MotoShield, Sparkfun Electronics
* Plywood, batteries, and hardware for assembly acquired from the engineering workshop

#### Hardware Assembly Details

The plywood was cut to make the platform that would sit in the power wheel. The plywood is built to place the other functioning parts, such as the linear actuator, the battery, the Arduino, the wires, and the gas pedal piston. The platform, as well as the other parts, was engineered to ensure that it was easy to remove and re-install if needed. The Power Wheel platform was constructed in two parts, the upper platform to attach to the mounting plate, and a lower platform for the pedal pusher assembly. The two parts were cut from ½” plywood and attached with a section of 2x4 wood stud and attached with 1 ¼” wood screws.
After the platform was built, the steering assembly needed to be constructed. It consisted of three parts: the miniature linear actuator, the steering lever, and the wooden wedge. The steering lever was made from the same material as the platform, ½” plywood, it was attached on either side of the steering will with U-brackets, 3” bolts, and nuts. The height of the wooden wedge was calculated using measurements taken with the aid of the miniature linear actuator. The actuator was extended for seven seconds, half the stroke length, and then attached to the steering wheel lever. The distance was measured from the bottom of the miniature linear actuator to the floor of the mounting platform was measured, that distance was used to measure and construct the wooden wedge. The wooden wedge was constructed from a 2x4 wood stud, and was cut at 50° to match the angle of the steering wheel.
Finally, the last part that needed to be attached was the bracket and the pedal piston to the platform. The pedal pusher assembly was constructed from three parts: the pedal piston, the screw motor, and the mounting bracket. Both the pedal piston and the mounting bracket was constructed from PLA and printed using the MakerBot.
The mount for the Ultrasonic Sensor was added to the front of the Power Wheel. It was attached using the same bolt pattern as the front bumper, with the front bumper reattached back on top. This was done to help protect the Power Wheel and the components from collisions. The mounting plate extended under the front bumper of the Power Wheel and had wooden bumpers attached. The wooden bumpers were added to prevent damage to the Ultrasonic Sensor in case of a collision if the sensor based avoidance system failed.
The last thing that needed to go in the power wheel is the Arduino, battery, and the wires, that can make the power wheel to function as a whole.

### Software Implementation

An Arduino Duemilanove and Monster MotoShield were used to control the actuators. Starting with example code (see above) for the motor shield, modifications were made to control vehicle steering and forward motion. In order to drive along a predetermined path along a sidewalk on the campus of Howard Community College, the following code was developed.
The second phase of software development was the incorporation of sensor data for simple obstacle avoidance. The following tutorial (https://www.youtube.com/watch?v=PG2VhpkPqoA) shows code to work the ultrasonic sensor, resulting in the serial monitor displaying numbers after the code was uploaded.
* Arduino circuit with ultrasonic sensor
* The serial monitor results for new code
The following algorithm was implemented to pause normal program execution when an obstacles exists in front of the vehicle.
Flowchart of algorithm for sensor-based pause of Arduino code
The algorithm shown above was then implemented in a simple Arduino program, separate from the vehicle control program.
After troubleshooting, the above code was incorporated with the vehicle control code. The power wheel simply drives straight and stops before hitting an obstacle.

### Testing and Performance Verification
#### Testing and analysis

The most basic test of functionality includes turning right or left independently. This functionality is demonstrated in the following preliminary tests.
Left turn test video Right turn test video
After getting the power wheel to just drive left and then right, we designed a path on which we can prove that the power wheel can turn right, go straight, and turn left all in one drive.
Right, Straight, and Left test video
Many changes were made to the code during testing. Actuation times were determined via trial-and-error. To minimize the strain on the Power Wheel and the steering components, steering wheel actuation only occurs when the vehicle is moving.
The Power Wheel initially was set to high gear, this was allowing for to much wheel spin resulting in poor traction and inconsistent drive times. To alleviate these the Power Wheel was put in low gear. This reduced wheel spin, but did not completely resolve the issue. The Power Wheel was making a turn as its initial movement and this was not consistent with even the minimal wheel spin, to solve the issue a floor mat was placed under the rear wheels to provide better traction.
After implementing the Ultrasonic Sensor HC-SR04, we decided to test the reliability of the sensor and the stopping time for the power wheel. In these videos we had the range set at 250cm, in other words if an object is less than 250 cm, the pedal actuator will retract and stop the car.
Distance Sensor Testing Video Compilation

#### The verification of performance to system requirements

According to the videos, the power wheel does pass the basic requirements that we hoped the power wheel would accomplish. The power wheel does turn right and it does turn left, the only issue the power wheel faces is that it takes the power wheel a wider circle to turn both ways. This results in the power wheel taking a longer time to drive and also takes up a lot of space to drive.

## Operate

Develop content related to conducting public demonstrations, competitions, or extended tests of navigation, path planning, and/or obstacle avoidance.

## Demo

Video of vehicle driving on campus

## Next Steps

* Improve and document design of the electrical system.
* Add a gear shift actuator. A gear shift assembly will allow the Power Wheel to go between high and low gear, and to go in reverse. As of now the Power Wheel is set in low gear, to stop wheel spin and to have constant results, engaging high gear once in motion will allow for the Power Wheel to traverse the path at a much quicker time. This will also be helpful when the Power Wheel encounters a steep incline, it can switch to low gear and have more torque to ascend the incline. Reverse will be helpful to avoid obstacles and to change driving paths.
* Design capability for greater field of view for sensing obstacles. For complete autonomy, obstacle detection will be required in multiple directions, including behind the vehicle.
* Add a wireless kill switch. The kill switch will allow for the Power Wheel to stop at any given moment if the human operator determines operation is unsafe. This will allow for the operator to stop the Power Wheel without having to chase down the Power Wheel while in motion, to avoid obstacles, or from driving into unsafe situations.
* Develop software for obstacle avoidance.
* Develop software for navigation. Enable travel between two points on campus, using GPS, waypoints, landmarks, internal map, etc.
* Combine navigation, path planning, and obstacle avoidance behaviors into one control algorithm.