Basic Code Methods

The following is the  description of the function that will be used to control the actions of AEV and will be used frequently in the future codes and exercise:

  • celerate(m, p1, p2, t);
    • accelerates (or decelerates) motor(s) m from the starting speed, p1, to the finish speed, p2, over a time span of t
    • Example:  celerate(1,20,45,2);
    • Accelerates motor 1 from 20% to 45% power in 2 seconds.
  •  motorSpeed(m, p);
    • runs motor(s) m at p (%) power
    • Example: motorSpeed(2,16);
    • Sets motor 2 speed to 16% power.
  • goFor(t);
    • runs the motor(s) at their current power for t seconds
    • Example: goFor(5);
    • Runs the motor(s) at their initialized state for 5 seconds.
  • brake(m);
    • brakes motor(s) m
    • Example: brake(4);
    • Cuts the power to all motors.
  • reverse(m);
    • reverses the current direction of motor(s) m
    • Example: reverse(1);
    • Reverses polarity of motor 1.
  • goToRelativePosition(n);
    • continues previous command for n marks from the current position of the vehicle (can be positive or negative)
    • Example:
    • motorSpeed(4,20);
    • goToRelativePosition(30);
    • All motors are set to 20%power, and they will continue to run at 20% power until the AEV reaches 30 marks from its current position.
  • goToAbsolutePosition(n);
    • continues previous command for n marks relative to the starting position of the AEV at initialization
    • Example:
    • motorSpeed(4,20);
    • goToAbsolutePosition(300);
    • All motors are set to 20% power, and they will continue to run at 20% power until the AEV reaches 300 marks from its starting position.

(1) All Function calls and examples can be found on  Preliminary R&D Lab Manual on Carmen.