Society of Robots - Robot Forum

General Misc => Robot Videos => Topic started by: g1marios on May 08, 2013, 06:35:08 AM

Title: Following rc car project
Post by: g1marios on May 08, 2013, 06:35:08 AM
Guys i work on a project about following rc car for my senior design.. has anyone did something similar? i want details and infos...
Title: Re: Following rc car project
Post by: idee17 on May 08, 2013, 04:51:46 PM
Some more specifics would be helpful; if i'm understanding you correctly, you want a car to follow you. Can the person followed be wearing anything (GPS, accelerometer) or does the car need to track the person using object recognition algorithms? What is the part your having difficulties with: person tracking, the mechanical side of the car, electronics on the car?
Title: Re: Following rc car project
Post by: g1marios on May 09, 2013, 05:03:36 AM
i want my rc car follow another rc car.. i want to do this with ultrasonic or ir distance sensors... i can control the motors of the car with arduino... how can i achieve that?
Title: Re: Following rc car project
Post by: jwatte on May 09, 2013, 11:25:24 AM
The main problem is going to be figuring out where the other RC car is. Using only ultrasonic and IR sensors is not going to be very robust.
However, you can probably get good enough to demonstrate under controlled circumstances.
What you have to do is discriminate where "the thing" you are following is relative to the local bot, and compare to where it "should" be. Then output speed/direction control based on that discrimination.
Assuming you're on a track where there aren't many other obstacles or other cars, you can start with a simple follower controller. Use three ultrasonic sensors.

Code: [Select]
// the control values we send to servos, in servo pulse time units
unsigned short turning = 1500; // < for left, > for right
unsigned short speed = 1500; // < for reverse, > for forward

const unsigned short TURN_SENSITIVITY = 20;
const unsigned short SPEED_SENSITIVITY = 20;
const unsigned short TURN_DEADZONE = 40;
const unsigned short FOLLOW_DISTANCE = 1000; // assuming unit == thousandths of a foot, so microseconds
const unsigned short TOLERANCE = 200;

void loop() {
  leftDistance = readSensor1();
  midDistance = readSensor2();
  rightDistance = readSensor3();
  targetDistance = midDistance;
  short delta = 0;
  if (turning < 1500 - TURN_DEADZONE) {
  else if (turning > 1500 + TURN_DEADZONE) {
    delta = -TURN_SENSITIVITY;
  if (leftDistance < targetDistance) {
    if (turning > 1000) {
      delta = -TURN_SENSITIVITY;
    targetDistance = leftDistance;
  if (rightDistance < targetDistance) {
    if (turning < 2000) {
      delta = TURN_SENSITIVITY;
    targetDistance = rightDistance;
  turning += delta;
  if (targetDistance < FOLLOW_DISTANCE - TOLERANCE) {
    if (speed > 1000) {
      speed -= SPEED_SENSITIVITY;
  else if (targetDistance > FOLLOW_DISTANCE + TOLERANCE) {
    if (speed < 2000) {
      speed += SPEED_SENSITIVITY;
  setServoTiming(STEERING_SERVO, turning);
  setServoTiming(DRIVING_SERVO, speed);

This illustrates a simple control algorithm, which technically is a hybrid between a decision tree and a PID controller. You want to tweak the various constants until you have the responsiveness that you need. This loop should really run as fast as it can, although there may be some crosstalk between the ultrasonic sensors that may require you to insert short delays between each sensor reading.

I'm assuming that you know how to program an Arduino, and read this C-like code for describing what the algorithm does.