Scribbler 2 Motion
The Robot
The Scribbler 2 robot has three wheels. The small wheel below the fluke dongle is purely for balance. The two large wheels each have their own motor, which can be adjusted to move at separate speeds to turn the robot to the left or right. The speed of the motors ranges from -1 (backwards at full speed) to 1 (forwards at full speed). It is important to note that there is no built-in time limit for how long the motor can run, so if you call a command to move without specifying a time limit or commanding the robot to stop, the motors will keep running until the Scribbler 2 battery dies.
A second important feature of the Scribbler 2 robot is that it can have the
"front" set as either direction. When the robot has its forwardness set as
"scribbler-forward", the front of
the robot is the direction without a wheel. When the forwardness
is "fluke-forward", the front is the
direction with the small wheel (below the green card-like fluke
dongle). The command to change the forwardness of the robot is:
rSetForwardness (char * direction);
The options are "scribbler-forward"
or "fluke-forward". By default,
forwardness is set to
"scribbler-forward"
by rConnect.
That is, when the Scribbler 2 is turned on, the robot will consider "forward" so that the small wheel is at the back (under the fluke). Then the command
rSetForwardness ("fluke-forward");
will change forwardness, so that forward now means the end with the fluke. To change forwardness back, away from the fluke, use the command
rSetForwardness ("scribbler-forward");
Robot Commands
Scribbler robots responds to several motion commands that include moving forward, backward, or turning. These commands can be classified as blocking or non-blocking. Most motion commands can fall into either category, depending on the given parameters.
Blocking and non-blocking commands
A blocking command means that while the robot is excecuting this command, the program will not proceed until the command is completed. That is, while the Scribbler 2 is performing these commands, it cannot perform other actions (such as beeping). A non-blocking command is one that allows the robot to multi-task. For example, you could issue a non-blocking forward command and have the robot beep several times as it moves forward.
Motion Commands with Time and/or Speed Parameters
Many motion commands take two parameters:
-
A speed parameter specifies a real number between -1.0 and 1.0:
- The value -1.0 specifies full speed backward
- The value -0.5 specifies half speed backward
- The value 0.0 specifies no motion either forward or backward
- The value 0.5 specifies half speed forward
- The value 1.0 specifies full speed forward
-
A duration parameter specifies the amount of time for the action.
- The magnitude of the duration specifies the time for the action, in seconds. That is, durations of both -1.5 and 1.5 indicate that the action will continue for 1.5 seconds.
- If the duration is non-negative, the action is blocking. Once the action is started, the procedure will not return (allowing your program to continue with another activity) until the action is completed.
- If the duration is negative, the action is non-blocking. Once the action is started, the procedure returns (allowing your program continue with another activity); the action continues until the duration expires or another motion command is given.
The following table identifies the available motion commands, together with examples and notes:
| Procedure header | Blocking example | Nonblocking example | Notes |
|---|---|---|---|
rTurnLeft (double speed, double time); |
rTurnLeft (0.5, 3.5); |
rTurnLeft (0.5, -3.5); |
Turn left at half speed for 3.5 seconds |
rTurnRight (double speed, double time); |
rTurnRight (0.25, 1.0/3.0); |
rTurnRight (0.25, -1.0/3.0); |
Turn right at quarter speed for 0.66666 seconds |
rTurnSpeed (double direction, double speed, double time); |
rTurnSpeed ("left", 0.5, 2.0); |
rTurnSpeed ("left", 0.5, -2.0); |
direction may be "left" or "right"; the examples turn left at half speed for two seconds |
rForward (double speed, double time); |
rForward (1.0, 3.7); |
rForward (1.0, -3.7); |
Move forward at roughly full speed for 3.7 seconds; the -1.0 to 1.0 range is only approximate for this command |
rBackward (double speed, double time); |
rBackward (0.5, 1.5); |
rBackward (0.5, -1.5); |
Move backward at half speed for one and a half seconds |
rFastForward (double time); |
rFastForward (2.7); |
rFastForward (-2.7); |
Move forward as fast as possible for 2.7 seconds. |
Summary: Most motion commands (i.e., commands with a time parameter) perform as blocking or non-blocking depending on their parameters. If the time given is greater than 0, the robot will move for that amount of time while blocking other commands. If the time parameter is negative, then it will be a non-blocking command that will continue until it is stopped, allowing subsequent commands to be processed in the meantime. A time of 0 will result in no motion. Also, remember that speed ranges from 0 (no movement) to 1 (full speed), and the unit of time is seconds.
A Command without a Time parameter
Continuous commands are commands that do not include time as a variable. Such commands are always non-blocking; that is, while the Scribbler 2 is performing these commands, it can perform other actions (such as beeping). The current MyroC.h specification includes only one continuous command:
rMotors (double leftSpeed, double rightSpeed);
For example, the command
rMotors (0.3, 0.7);
moves with the left wheel at 30% of full speed, and the right wheel at 70% of full speed, so the robot moves in a circular motion.
Stop Commands
These commands stop the continuous commands after they have been issued.
rStop();rHardStop();
