Differences between revisions 13 and 14
Revision 13 as of 2008-10-21 08:42:57
Size: 5580
Editor: dyn177231
Comment:
Revision 14 as of 2008-10-21 08:43:49
Size: 5583
Editor: dyn177231
Comment:
Deletions are marked like this. Additions are marked like this.
Line 124: Line 124:
 if(sensor == admoveo.getLeftDistanceSensor()){
     bgcolor = newValue/4;
     admoveo.getBlueLed().setPower(bgcolor);
    }
   if(sensor == admoveo.getLeftDistanceSensor()){
      bgcolor = newValue/4;
      admoveo.getBlueLed().setPower(bgcolor);
   }

  • <!> For a more formal and detailed specification, please refer to the javadoc.

1. AdMoVeo in Processing

Together with the IDuino firmware (an Arduino sketch uploaded to the Arduino board), this class allows you to control the AdMoVeo robot from Processing: Controlling all the actuators (LED's, motors, buzzer etc) and receiving input events from all the sensors (distance sensors, light sensors, sound sensors and line readers etc).

1.1. AdMoVeo

1.1.1. Constructor

AdMoVeo(PApplet parent, String name)

Create a proxy to an AdMoVeo robot running the IDuino firmware. it uses a default baud rate of 57600 to communicate with the robot.

parent

the Processing sketch creating this AdMoVeo robot (i.e. "this").

name

the name of the serial device associated with the AdMoVeo robot.

1.1.2. Access to devices

1.1.2.1. Arduino
Arduino getArduino()

Gets the Arduino object used by this AdMoVeo robot.

Returns
the Arduino object.

1.1.2.2. Sensors
AnalogSensor getFrontDistanceSensor()
Gets the reference to the front distance sensor of the robot.
Returns
the reference to the front distance sensor.
AnalogSensor getLeftDistanceSensor()
Gets the reference to the left distance sensor of the robot.
Returns
the reference to the left distance sensor.
AnalogSensor getRightDistanceSensor()
Gets the reference to the right distance sensor of the robot.
Returns
the reference to the right distance sensor.
AnalogSensor getLeftLightSensor()
Gets the reference to the left light sensor of the robot.
Returns
the reference to the left light sensor.
AnalogSensor getRightLightSensor()
Gets the reference to the right light sensor of the robot.
Returns
the reference to the right light sensor.
AnalogSensor getLeftLineSensor()
Gets the reference to the left line sensor of the robot.
Returns
the reference to the left line sensor.
AnalogSensor getRightLineSensor()
Gets the reference to the right line sensor of the robot.
Returns
the reference to the right line sensor.
AnalogSensor getLeftSoundSensor()
Gets the reference to the left sound sensor of the robot.
Returns
the reference to the left sound sensor.
AnalogSensor getRightSoundSensor()
Gets the reference to the right sound sensor of the robot.
Returns
the reference to the right sound sensor.

1.1.2.3. Actuators
AnalogActuator getBuzzer()
Gets the reference to the buzzer of the robot.
Returns
the reference to the buzzer.
AnalogActuator getBlueLed()
Gets the reference to the blue LED of the robot.
Returns
the reference to the blue LED.
AnalogActuator getGreenLed()
Gets the reference to the green LED of the robot.
Returns
the reference to the green LED.
AnalogActuator getRedLed()
Gets the reference to the red LED of the robot.
Returns
the reference to the red LED.
Motor getLeftMotor()
Gets the reference to the left motor of the robot.
Returns
the reference to the left motor.
Motor getRightMotor()
Gets the reference to the right motor of the robot.
Returns
the reference to the right motor.

1.2. Actuators

All the actuators on AdMoVeo are analog (PMW) actuators. it can be powered by a value from 0-255, where 0 turns it off, and 255 gives the maxium power to the actuator. All the actuators (LED's, Buzzer and Motors) support the following control interfaces:

off()
Switches the actuator off. it has the same effect as setPower(0).
on()
Switches the actuator on. Switching it back on will give the power was set before it was switched off.
setPower(int power)
Sets the power level of the actuator.
power
the power level, between 0 and 255.

1.2.1. Motors

Motors are special actuators, for its direction controls in addition to on(), off() and setPower():

forward()
Set the motor to move forward.
backward()
Sets the motor to move backward.

1.3. Sensors

  • All the sensors on AdMoVeo are analog sensors (instances of AnalogSensor). AnalogSensor implements the following controlling interface:

  • disable()
    Disables the sensor. No input event will be received from the sensor afterwords, until it is enabled again.
    enable()
    Enables the sensor input. All the sensors are disabled by default. If input is to be expected from a sensor, it has to be enabled first.

1.4. Input event handling

Implementation of the push mode of event handling. To use this in Processing:

  1. A sensor must be enabled first using enable(). This is usually done in setup() in your Processing code.
  2. In Processing, define the following functions to be called to receive the input events when input is available.
  3. inputAvailable(Sensor sensor, int oldValue, int newValue)
    receives sensor input events in Processing.
    sensor
    from which sensor the input events is received.
    oldValue
    the old value before the change.
    newValue
    the new value after the change.

1.5. Example

   1 import processing.serial.*;
   2 import nl.tue.id.creapro.admoveo.*;
   3 
   4 AdMoVeo admoveo;
   5 int bgcolor = 255;
   6 
   7 void setup()
   8 {
   9   admoveo = new AdMoVeo(this, "COM11"); 
  10   admoveo.getLeftDistanceSensor().enable();
  11 }
  12 
  13 void draw()
  14 {
  15   background(0,0,bgcolor);
  16 }
  17 
  18 void inputAvailable(Sensor sensor, int oldValue, int newValue){
  19    if(sensor == admoveo.getLeftDistanceSensor()){
  20       bgcolor = newValue/4;
  21       admoveo.getBlueLed().setPower(bgcolor);
  22    }
  23 }

CreaPro: AdMoVeoInProcessing (last edited 2008-11-24 12:17:39 by JunHu)