Leap Controlled RC Car

From ESE205 Wiki
Revision as of 18:56, 28 March 2017 by Andrew O'Sullivan (talk | contribs) (Added a pic)
Jump to navigation Jump to search

Proposal

Project Overview

The goal of this project is to create an RC car that is controlled by a Leap Motion pad through hand gestures. The Leap Motion will be connected to a computer and will communicate with an Arduino on the RC car. This communication will most likely occur via a bluetooth dongle. The RC car will be purchased from a kit online and customized as needed.

Team Members

  • David D’Agrosa
  • Andrew O’Sullivan
  • Alden Welsch (TA)

Objectives

The primary objectives of this project involve the construction of an RC car, exploring the capabilities of programming with Arduino, and controlling the RC car via a Leap Motion pad. The RC car is the foundation of our project so finding a suitable kit which can be modified to incorporate an Arduino is the first objective. Building a circuit to connect the Arduino to the RC car will allow us to begin writing code to control the RC car. The final and most difficult objective involves understanding how the Leap Motion pad outputs information, transforming a hand motion into a bluetooth signal, and sending that information to control the RC car. If bluetooth proves to be too difficult of an option, we may pursue simpler ideas with time permitting. If we finish our project early, we will work on a mobile app to control the RC car.

Challenges

Challenges we might encounter include learning how to program in Arduino, taking data in from the Leap Motion pad, communicating wirelessly between a computer and the Arduino, and programming the Leap Motion pad. With minimal experience coding, extra time will need to be devoted to understanding the most accessible language and its functionality.

Budget

  • RC car $13.99 (Link)
    • We need this component to act as the body of our car. It is a simple kit that includes wheels and motors that can be configured with the Arduino
  • Arduino (supplied by class)
    • We need this component to be our motor controller and run our code on the car.
  • Batteries $9.99 (Link)
    • We need batteries to drive the motors and run the Arduino on our RC car
  • Leap Motion $58.99 (Link)
    • Leap motion is a fun, new tool that can easily read hand motions and will act as the input to drive our RC car.
  • Bluetooth dongle $13.99 (Link)
    • We need a this component because the computers in our lab do not have Bluetooth built in. We will be communicating with the Bluetooth shield on the RC car via Bluetooth.
  • Bluetooth Transceiver Module Slave $9.99 (Link)
    • This component allows the Arduino to easily receive information from the computer and act based on whatever inputs it receives.
  • Ardumoto Shield Kit $35.45 (Link)
    • The Ardumoto Shield included in this kit is an easy-to-use dual motor controller. This will allow us to control the motors in 2 directions and integrates easily with our Arduino. Additionally, this kit comes with 2 spare wheels, 2 spare motors, 3 screw terminals which are necessary for our Arduino, stackable headers, extra black wire, and a 9V to barrell jack adapter so that our battery can easily configure with the Arduino.
  • Note: All prices include shipping

Total: $142.40

Gantt Charts

Ganttt.png

Design and Solutions

Leap Car 1.jpg

Java and Leap Motion

Working within Java with the Leap Motion module took some getting used to before working smoothly. The first steps involved downloading the necessary .jar and .dll files from the Leap Motion website. Once these libraries were added to Java, the next step involved understanding how to set up a frame and a controller. To do this, we created a sample listener and controller after looking at other examples of code. This listener acts to update the values in our frame every 100ms (due to a pause we put in). We wanted to utilize the pitch value which goes from -pi to pi so we rounded it and made a few other changes so we got values ranging from -2 to 4. With these values set to variables, we then call our writetoArduino function which has various if statements in it. These if statements look at the values we have and will then write a unique character to our Arduino. Our Arduino sketch then reads that unique character and actuates the motors accordingly.

Arduino Code

Arduino code was written to take in the data from the bluetooth slave, analyze the data, and send information to the motor controller to move the rover forward. The Arduino 'saw' the bluetooth slave as if it were a Serial Monitor. The Arduino would look at it and take in the available information. The raw data that was displayed by the bluetooth were numbers between:

    • 49 and 52 to signal moving forward with variable speed
    • 65 and 68 to signal turning right with variable speed
    • 69 and 72 to signal turning left with variable speed
    • an input of 90 moved the rover backwards at roughly half full speed
  • The Arduino mapped the raw data so that it would move with a variable speed from 0 to 255. (0 being off and 255 being full power)

That was what the Arduino code was written to do, however, we could not get the Java to work with bluetooth. We were able to use this Arduino code when we were hardwired into the computer, and the java code directly wrote its output to the serial monitor of the Arduino. This code can be found on our GitHub below.

Arduino code was written to control the rover by using the WASD keys on the keyboard. The letters were typed into a program called TeraTerm on the computer which sent the letters to the serial port of the bluetooth. The Arduino read its Serial monitor, and moved forward, backwards, left, or right depending on the letter it read from the monitor. This code was very similar to the code used to control the rover with the Leap Motion. This code can be found on our GitHub below.

The Arduino code written to control the rover with the radio controller took in pwm signals from specified pins on the Arduino board, and read the signals using the 'pulsein' function. The Arduino took in a signal for speed, turning, and direction. The code mapped the input signal so that it would have an output of 0-255 to send to the motor controller to move the wheels. This code can be found on our GitHub below.

We made encoders to count the rotations of the wheels. This code was not used in the final design because we were not able to achieve better results with it. The rover worked fine without the encoders. The encoders were 3D printed and used a blue LED and a photosensitive resistor. This code can be found on our GitHub below.

Results

Leap Control

Due to difficulties getting our Bluetooth Module talking with our Java code, we had to be hardwired into the computer in order for our Leap Motion pad to control the car. Initial setup simply involves making sure the COM port specified Once the code is running, it will send a signal to the car every 50ms. If no hand is detected above the Leap Motion module, our Java code outputs "No hand detected". Once a hand is detected it will display the speed that the car is going. A hand flat above the Leap Motion module equals a speed of zero. Tilting the hand downwards increases the speed with three levels of intensity (speed=1, speed=2, speed=3) which are also displayed in our Java code. When the hand is displaced laterally from the Leap Motion module, the direction can be changed. Turning works in unison with the hand tilting so three are three speeds which the car can turn. A link to an example video can be found at the bottom of the page.

WASD Control

Using Tera Term, a free serial port software, we were able to connect to the Bluetooth Module on our RC car. Our laptop had a Bluetooth dongle which was paired with the module on our RC car. When opening Tera Term, select the correct COM port of the bluetooth module. Then with our Arduino sketch uploaded to the RC car, typing W moves the car forward, A moves the car backward, S moves the car left, D moves the car right, and E stops the car. A link to an example video can be found at the bottom of the page.

RC Control

Using a personal remote controller, we were able to control the rover with a variable speed. By moving the joystick on the remote controller forwards/backwards and left/right we were able to effectively control the speed of the rover. Using an on/off switch on the controller we were able to switch the direction the rover moved.

Links

  • Our github with all relevant code can be found Here!
  • An example of our Leap Motion code in action can be found at youtu.be/6KYSonVOybY
  • An example of our WASD code in action can be found at youtu.be/8SPkMzXISdI