Let’s try the Forward Stop Face Right program from the learn.parallax.com site’s Go Certain Distances ActivityBot page.
The program would make an ActivityBot turn about 90° to the right, but not so with the Arlo. With its different wheel radius, turning radius, and counts per revolution, the number of encoder counts for ¼ turn is no longer a total of 51 counts. It is now 186, or +93 for the left wheel and -93 for the right wheel.
In the More Precise Maneuvers with Encoders section, we’ll get those 90° turns on the first try!
/* Forward Stop Face Right.c http://learn.parallax.com/activitybot/go-certain-distances */ #include "simpletools.h" //#include "abdrive.h" // <- Comment out this line #include "arlodrive.h" // <- Replace it with this line int main() { drive_goto(256, 256); pause(200); drive_goto(26, -25); }
Another approach introduced in the ActivityBot pages is Navigation by Speed. As with the previous program, the parameter’s your programs will pass to the drive_speed calls will have to be adjusted to get the desired outcome. Another thing to keep in mind is that the speeds are not instantaneous. It takes some time for the Arlo to accelerate into and back out of any given maneuver.
/* Arlo - Speeds for Navigation.c Navigate by making your ActivityBot go certain speeds for certain amounts of time. http://learn.parallax.com/activitybot/set-certain-speeds */ #include "simpletools.h" // simpletools library #include "arlodrive.h" // <- CHANGE abdrive to arlodrive int main() { drive_speed(64, 64); // Forward 64 tps for 2 s pause(2000); drive_speed(0, 0); drive_speed(26, 0); // Turn 26 tps for 1 s pause(1000); drive_speed(0, 0); drive_speed(128, 128); // Forward 128 tps for 1 s pause(1000); drive_speed(0, 0); }