Also inside the function are two commands to change the color of the controller’s
LED. These two commands work together to cause the LED to flash between blue
and red, indicating that the TaskBot is in pitch and roll mode.
The TaskBot’s motors are controlled with the third command in this function.
Although it looks complicated, the prizm.setMotorPowers() command has just
two values in it: the power for Motor 1 and the power for Motor 2. These two values
are separated by the comma.
For Motor 1, the command adds the pitch and roll measurements from the PS4
controller’s gyroscope. For Motor 2, the controller’s roll measurement is subtracted
from the controller’s pitch measurement. The table below shows the TaskBot’s
behavior when the PS4 controller is tilted to its maximum tilt.
Notice that in the last two table entries, the TaskBot moves the opposite direction of
the controller tilt, but because of the backward motion, the TaskBot ends up facing
the direction of the tilt.
Controller Tilt
Pitch
Roll
Motor 1
P + R
Motor 2
P - R
Result
Motion
All the way
forward
100
0
100
100
Forward at full speed
(both motors forward)
All the way
backward
-100
0
-100
-100
Backward at full speed
(both motors
backward)
All the way left
0
-100
-100
100
Rotate left/
counterclockwise
(left motor backward,
right motor forward)
All the way right
0
100
100
-100
Rotate right/clockwise
(left motor forward,
right motor backward)
Forward and left
100
-100
0
200
Pivot left forward
(left motor stationary,
right motor forward)
Forward and
right
100
100
200
0
Pivot right forward
(left motor forward,
right motor stationary)
Backward and
left
-100
-100
-200
0
Pivot right backward
(left motor backward,
right motor stationary)
Backward and
right
-100
100
0
-200
Pivot left backward
(left motor stationary,
right motor backward
100
Pitch
Roll
100
-100
-100
10
TETRIX Tele-Op Control Module Activity 2