Autonomous RC Car

Autonomous RC Car

This project originally started with RBT337, mobile autonomous systems. I was in a class with six other students and we all were making our own autonomous systems. As I had had a lot of experience with RC cars and racing them, I decided that was the platform I wanted to work with. I picked up a Traxxas Slash 2WD version and went to work. I first had to beef up the suspension to accommodate the weight of servos, sensors, network equipment, video transmitters and micro-controllers. From there, I picked out all the IR sensors, pan and tilt servos, XBee network modules, video transmitters and arduino controller that this vehicle was going to need. Throughout the first 4 month class, the vehicle was designed to do object avoidance. It was able to navigate around the school while driving around objects. It send high quality video to my laptop using the transmitter so I was able to be in the robotics lab but have the vehicle anywhere on the campus. This project then expanded into further robotics classes each allowing more development and design making the vehicle better and better. In total, this project was worked on in three different RBT337 classes, and was the basis for my SIP which is also listed and documented on this site.

In the end this car utilized the arduino micro-controller to read in sensors readings from IR and Sonar sensors, and use the on-board GPS to assist in navigating way points. It never used computer vision as that was more processing power than was on-board, but the video stream was always available to monitor the vehicle as it was driving around. It was successfully able to navigate a course around the campus using GPS way-points, and avoid the obstacles such as students walking around and the cars in the parking lot.

<—Below is some code that was loaded onto the vehicle for initial setup and configuration of the motor controller—>

#include Servo.h

Servo steering;
Servo motor;

int lfront = 7;
int left = 6;
int rfront = 5;
int right = 4;
int current_direction = 1;
int current_velocity = 0;
int lf;
int l;
int rf;
int r;

void setup()
{
Serial.begin(115200);
Serial1.begin(115200);
Serial2.begin(115200);
Serial1.println("Running Setup");
Serial1.println();
Serial1.println("Steering Configuration Running:");
steering.attach(12);
Serial1.println("Steering Servo Attached");
delay(150);
steering.write(105);
Serial1.println("Steering Servo Centered");
Serial1.println("Steering Servo Configured!");
Serial1.println();
delay(150);
Serial1.println("Motor Configuration Running:");
delay(150);
pinMode(13, OUTPUT);
motor.attach(13);
motor.write(90);
Serial1.println("Motor Attached");
Serial1.println("Motor Configured!");
Serial1.println();
delay(150);
Serial1.println("Xbee Configuration Running:");

//Xbee configuration code goes here

Serial1.println("Xbee Configuration Completed!");
Serial1.println();
Serial1.println("Sensors Configuration Running:");
pinMode(left, INPUT);
pinMode(right, INPUT);
pinMode(lfront, INPUT);
pinMode(rfront, INPUT);
Serial1.println("Sensors Configured!");
Serial1.println("Setup Completed!!");
//delay(1500);
}

void loop()
{
checkSensors();
}

void checkSensors()
{
lf = analogRead(lfront);
delay(5);
rf = analogRead(rfront);
delay(5);
l = analogRead(left);
delay(5);
r = analogRead(right);
delay(5);
if((rf > 100) && (lf > 100))
if(lf > rf)
steering.write(map(lf, 100, 650, 91, 180));
else
steering.write(map(rf, 100, 650, 89, 0));
if(lf > 100)
steering.write(map(lf, 100, 650, 91, 180));
if(rf > 100)
steering.write(map(rf, 100, 650, 89, 0));
else
steering.write(105);
setVelocity();
delay(25);
checkSensors();
}

void setVelocity()
{
if(Serial2.available() > 0)
{
int temp = Serial2.read();
if(temp == 114)
motor.write(105);
if((temp > 47) && (temp < 58))
temp -= 48;
if(current_direction = 1)
fvelocity(temp);
if(current_direction = 0)
motor.write(105);
current_velocity = temp;
}
else
{
if(current_direction = 1)
fvelocity(current_velocity);
}
return;
}
void fvelocity(int v)
{
int temp = map(v, 0, 9, 91, 125);
motor.write(temp);
return;
}

void backup()
{
for(int i = 95; i > 80; i--)
{
if(Serial2.read() == 48)
motor.write(90);
motor.write(i);
delay(100);
}
Serial2.flush();
return;
}