Did You Know: Set and Forget Maneuvers
Just keep rolling
The drive.speed() speed is a "set-it-and-forget-it" method. It starts the wheels turning at the chosen speed, and then code execution immediately continues with the next statement. The wheels will keep turning at that speed until another drive.speed() call changes the wheel speeds.
Speed vs. Velocity
Velocity is like speed, but it can be either positive (forward motion) or negative (backward motion). Speed itself is just velocity without the sign that indicates direction; velocity's absolute value.
Speeds are not instantaneous
In this system, it takes time for the wheels to accelerate to whatever the new speed settings are. So, it’s not like drive.speed(64, 64) instantly makes the wheels turn that fast. The wheels were not turning at 1 turn/second the whole time, but start off more slowly and ease into the full speed maneuver. Keep that in mind if you are trying to set up a distance = velocity x time equation. The wheel will not have turned as far in 2 seconds as you’d expect with the equation. However, in the next activity, you will use distance control statements, and the control system built into the cyber:bot board will calculate acceleration as part of the distance.
Types of Turns
Your cyber:bot can perform a variety of turn styles with velocity control. Here are some examples:
Rotate in Place
This is the familiar drive.speed(64, 64). Both wheels are turning in equal velocities. The result is that the entire cyber:bot rotates about the center-point between the servo axes.
One-wheel Pivot
A pivot turn works by holding one wheel still and turning the other wheel forward or backward.
You can use drive.speed(64, 0) to pivot forward right on the right wheel as shown below. If you want the cyber:bot to pivot forward left instead, use drive.speed(0, 64). To pivot backward in either direction, use -64 instead of 64.
Arcs
An arc is performed by turning both wheels forwards or both wheels backwards, just with one wheel slower than the other. The arc shown below turns the right wheel slower than the left. Examples include drive.speed(64, 32) for a tighter arc:
....and drive.speed(64, 46) for a wider arc. Notice that with tigher arcs, the speed difference is largeer, and with wide arcs, the speed difference is smaller.
Your Turn
- Write a script to demonstrate the turns, arcs, and pivots shown above. Include both the left and right turn versions.