User Tools

Site Tools


marvin:lab7

Lab report 7

Date: October 31th 2008
Duration of activity: 8-13
Participants: Kasper, Bent and Johnny

Project Goal

The project goal is to build and experiment with Braitenberg vehicles. The vehicles are shown here below. We aim to reach an expected behavior of the vehicles, which is introduced and evaluated during the experiments. Tom Dean has written about this subject1) 2)

Vehicle 1

This vehicle utilizes the simplest form of sensor→actuator activation. For this vehicle we shall replica a sensor/actuator system, which originally was connected through a wire-circuit in analog form, where the sensor signal presumably was amplified using transistor or operational amplifiers and fed to the motor. The vehicle behaviour is very simple. The more measured quantity from the sensor the more power is fed to the engine. In theory the sensor input is proportional to the sensor output, but in practice this relationship may not hold due to the sensor characteristic. Our objective is to implement this behavior in a digital form using the LEGO mindstorm NXT module in which we are able program this proportional relationship between sensor and actuator in a java based environment.

In our project a sound sensor is used instead of a light sensor.

Source Code
The source code for vehicle 1 is displayed below.

public class Vehicle1 {
  // Commands for the motors
  private final static int
    forward  = 1,
    backward = 2,
    stop     = 3,
    flt      = 4;
 
  private static MotorPort leftMotor = MotorPort.C;
  private static MotorPort rightMotor= MotorPort.B;
 
  public static void main(String [] args)  throws Exception {
    SoundSensor ss = new SoundSensor(SensorPort.S1);
 
    while (! Button.ESCAPE.isPressed()) {
 
      // Read value from light sensors
      int val = ss.readValue();
 
      LCD.drawInt(val, 0, 3);
 
      leftMotor.controlMotor(val, forward);
      rightMotor.controlMotor(val, forward);
 
      LCD.clear();
    }
 
    leftMotor.controlMotor(0, stop);
    rightMotor.controlMotor(0, stop);
  }
}

Observed behaviour
The first testrun indicated that the sensor was to close to the motors as the sensor readings were 93 (interval going from 0-100) when the motors were running. Therefore the sound sensor was placed further away from the vehicle. The problem was solved by simply placing the sound sensor 20cm. in front of the vehicle. The next testrun proved the expected behaviour for vehicle 1. The soundsensor reacts well to whistle sounds and by making higher amplitudes in a nice whistled sine tone the vehicle moves faster as expected.

Video and pictures of vehicle1
vehicle1_mov.jpg lab7-5.jpg

Vehicle 2a

For vehicle 2a it should be possible to use two sound sensors given they are sufficiently seperated - this statement is based on the characteristic that was measured in Lab session 3, which revealed that the sound sensor readings were reliant on the direction towards the sound source. In spite of this, we have decided to use two light sensors for vehichle 2a. This vehicle will move towards the light source. The light sensors are placed in front of the vehicle seperated by approximately 10cm. The sensor that is nearest to the source will provide most power to the connected motor and thereby turning the car towards the light. The original analog circuit will correspond to a bang-bang controller in the digital form.

Source Code
The source code for vehicle 2a is displayed below.

public class Vehicle2 {
  // Commands for the motors
  private final static int
    forward  = 1,
    backward = 2,
    stop     = 3,
    flt      = 4;
 
  private static MotorPort rightMotor= MotorPort.A;
  private static MotorPort leftMotor = MotorPort.B;
  private static MotorPort light = MotorPort.C;
 
  public static void main(String [] args)  throws Exception {
    LightSensor l1 = new LightSensor(SensorPort.S1);
    LightSensor l2 = new LightSensor(SensorPort.S2);
    l1.setFloodlight(false);
    l2.setFloodlight(false);
 
    light.controlMotor(100, forward);
 
    while (! Button.ESCAPE.isPressed()) {
 
      // Read value from light sensors
      int val1 = l1.readValue() + 60;
      int val2 = l2.readValue() + 60;
 
      LCD.drawInt(val1, 0, 3);
      LCD.drawInt(val2, 0, 4);
 
      leftMotor.controlMotor(val1, forward);
      rightMotor.controlMotor(val2, forward);
 
      LCD.clear();
    }
 
    leftMotor.controlMotor(0, stop);
    rightMotor.controlMotor(0, stop);
  }
}

Observed behaviour
The first testrun indicated that we are facing a motor problem, which have occured often. The problem is, that the car is unable to move forward due to uneven velocity between the motors at the same power level. This problem makes it very difficult to draw conclusions on wheater the code, the sensor or the motors are causing unexpected behaviour. We have attempted to solve this problem by introducing different types of parameters to compensate for the velocity difference, but the problem seems to be dependent on both battery level and is non-linear to the power level. Therefore we have decided to change to a different set of motors. Another type of problem is the test environment, which has a relatively high ambient light level due to white walls, sun light and lamps. We have decided to make a testrun in a darker environment. This may help to widen the light sensor reading interval. This test indicated yet another problem in the readings from the two sensors. When light is coming from an angle close to 90 degrees the two sensors produce similar readings and the car moves straight ahead, although it should be making a 90 degree turn towards the light source. This problem was solved by mounting a barrier between the two sensors as illustrated on the pictures below. This barrier assures that the sensor closest to the light will have a significant higher reading when the vehicle is pointing in a direction away from the light source. The effect of this modification was a highly improved behaviour in terms of the expectations towards vehicle 2a. The test is shown in a video below.

Video and pictures of vehicle 2a
lab7-7.jpg lab7-6.jpg lab7-9.jpg lab7-8.jpg

Vehicle 2b

For vehicle 2b, the sensor inputs are reversed using the same source code. No practical test have been made for this vehicle.

Interaction between robots

A light sensor has been placed on our robot. If we get access to more robots it would be a nice experiment to place them in a dark room and observe their behaviour. Perhaps it could reflect more complex behaviour than expected given the very simple controllers.

Conclusions

For both vehichles, it was possible to make the robots resemble the expected behaviour of the Braitenberg vehicles, 1 & 2a. The sensors need not be the exact same as in the original proposal in order to reach as similar behaviour/sensor→actuator control. Using a microphone for vehicle 1 and light sensor for vehicle 2a combined with a digital control the experiments proved to be successful in terms of the project goal.

1)
Tom Dean, Introduction to Machina Speculatrix and Braitenberg Vehicles http://www.cs.brown.edu/people/tld/courses/cs148/02/introduction.html
2)
Tom Dean, Notes on construction of Braitenberg's Vehicles, Chapter 1-5 of Braitenbergs book http://www.cs.brown.edu/people/tld/courses/cs148/01/vehicles/vehicles.htm
marvin/lab7.txt · Last modified: 2008/11/07 10:58 by rieper