Try & Tune Some ActivityBot Code

Try & Tune Some ActivityBot Code

Distance Navigation

Let’s try the Forward Stop Face Right program from the learn.parallax.com site’s Go Certain Distances ActivityBot page. 

  • Set power like this: MAIN (on), MOTORS (off), Activity Board (position-2)
  • Use SimpleIDE’s Load EEPROM & Run button to run Forward Stop Face Right.
  • Turn all power off, unplug the programming cable, and take to your Arlo navigation area.
  • Turn MAIN and MOTORS power on.
  • Set the Activity Board power switch to 2.
  • Verify that the Arlo goes forward, stops, and turns slightly to the right.

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.

  • Try changing drive_goto(26, -25) to drive_goto(93, -93), load the modified program into EEPROM, and verify that it makes the Arlo turn 90°. 

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);
}

 

Speed Navigation

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.

  • Set power like this: MAIN (on), MOTORS (off), Activity Board (position-2)
  • Run Speeds for Navigation.
  • Turn all power off, unplug the programming cable, and take to your Arlo navigation area.
  • Turn MAIN and MOTORS power on.
  • Set the Activity Board power switch to 2.
  • Verify that the Arlo goes forward, stops, and turns slightly to the right, then goes forward again.
/*

  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);
}