abdrive360 library  v0.9.3
Differential servo drive library for the Parallax ActivityBot 360
Functions
abdrive360.h File Reference

This library provides a simple set of functions for making the ActivityBot 360 go certain distances and speeds.


For more information, go here:

http://learn.parallax.com/activitybot/navigation-basics

More...

#include "simpletools.h"
#include "servo360.h"

Go to the source code of this file.

Functions

void drive_speed (int left, int right)
 Set wheel speeds in "ticks" per second. A tick is 1/64th of a revolution, and makes an ActivityBot 360 wheel roll 3.25 mm. The maximum speed for each wheel is +/- 128 ticks/second. Positive values are for forward motion; negative values are for reverse. More...
 
void drive_goto (int distLeft, int distRight)
 Make the wheels travel a certain distance, measured in ticks.
Each "tick" is a 64th of a wheel turn, and corresponds to an ActivityBot 360 rolling distance of about 3.25 mm. Ramp up, cruise, ramp down and stop are coordinated so that different left/right distances result in curves.
Same distances are straight lines, and same distances with opposite +/- signs cause the ActivityBot 360 to turn in place. This function does not return until the maneuver has completed. If needed, you change that default with the drive_gotoMode function. The default cruising speed is 64 ticks/second, which can be adjusted with the drive_setMaxVelocity function. More...
 
void drive_getTicks (int *left, int *right)
 Get the measured number of ticks each servo has traveled since the program started running. Each "tick" is a 64th of a wheel turn, and corresponds to an ActivityBot 360 rolling distance of about 3.25 mm. More...
 
void drive_getTicksCalc (int *left, int *right)
 Get the calculated number of 1/64th wheel revolution ticks the abdrive360 control system thinks each servo should have traveled. More...
 
Settings
void drive_servoPins (int controlPinLeft, int controlPinRight)
 Sets servo pins to values other than the default P12 for the left servo and P13 for right servo. Stores values in EEPROM, so you only need to call this function at the start of one program. Programs after that will get the modified port numbers from EEPROM. More...
 
void drive_encoderPins (int encPinLeft, int encPinRight)
 Sets feedback pins to values other than the default P14 for left and P15 for right. Stores values in EEPROM, so you only need to call this function at the start of one program. Programs that are run after that will get the modified port numbers from EEPROM. More...
 
void drive_setMaxVelocity (int forGotoOrSpeed, int ticksPerSec)
 Set the maximum velocity used by either drive_goto or drive_speed.
The defaults are 128 ticks per second for drive_speed, and 64 ticks per second for drive_goto. A tick is a 64th of a turn, and causes an ActivityBot 360 wheel to roll for 3.25 mm. The valid range is 32 to 128 ticks per second. More...
 
void drive_setAcceleration (int forGotoOrSpeed, int ticksPerSecSq)
 Set the acceleration used by either drive_goto or drive_speed. More...
 
void drive_gotoMode (int mode)
 Set the mode of the drive_goto call to blocking (default) or interruptible. For calls in interruptible mode, sufficient time must be allowed for the maneuver to complete before issuing another drive_goto or drive_speed call. The drive_gotoStatus function can also be polled to find when a given maneuver is done. More...
 
int drive_gotoStatus (int side)
 After using drive_gotoMode(0) to cause the drive_goto function to not wait until the maneuver is done before returning, checking the status of a given maneuver can be useful. This function reports the status of maneuver initiated by the most recent drive_goto call. More...
 
void drive_feedback (int enabled)
 Enables or disables encoder feedback for speed control. More...
 
void drive_suppress_eeprom (int state)
 Enables or disables ignore calibration settings stored in EEPROM.
This feature allows an ActivityBot application to initialize using I/O pins that are different from the ones stored in EEPROM. More...
 
Deprecated
void drive_setMaxSpeed (int speed)
 Modifies the default maximum top speed for Feedback 360 high speed servos. For calls to drive_speed, the default is 128 ticks/second = 2 revolutions per second (RPS). This value can be reduced, but not increased. Note: drive_setMaxVelocity is recommended in place of this function. More...
 
void drive_setRampStep (int stepsize)
 Overrides the default 12 ticks/second per 50th of a second for ramping. Note: drive_setAcceleration is recommended in place of this function. More...
 
void drive_rampStep (int left, int right)
 This function allows your code to ask for a speed repeatedly in a loop, but each time your code asks for that speed, it takes a step toward the speed. This helps cushion sudden maneuvers in sensor navigation, where the conditions might change more rapidly than you would want your ActivityBot 360's speed to change. Note: drive_speed has built-in ramping and is recommended in place of this function. It can be called repeatedly the same way applications call this function. More...
 
void drive_ramp (int left, int right)
 This function ramps up to a given speed and blocks execution until the speed is reached. In practice, a call to drive_speed followed by a pause to reach the desired speed will have the same effect but does not have practical applications. More...
 

Detailed Description

This library provides a simple set of functions for making the ActivityBot 360 go certain distances and speeds.


For more information, go here:

http://learn.parallax.com/activitybot/navigation-basics

Author
Parallax Inc.
Core Usage
A single additional core takes care of ActivityBot 360 servo angle monitoring, control system algorithm execution, and servo control signaling.
EEPROM Usage
Reads from addresses 63418..65470.
Memory Models
Use with CMM.
Help Improve this Library
Please submit bug reports, suggestions, and improvements to this code to edito.nosp@m.r@pa.nosp@m.ralla.nosp@m.x.co.nosp@m.m.

Function Documentation

◆ drive_encoderPins()

void drive_encoderPins ( int  encPinLeft,
int  encPinRight 
)

Sets feedback pins to values other than the default P14 for left and P15 for right. Stores values in EEPROM, so you only need to call this function at the start of one program. Programs that are run after that will get the modified port numbers from EEPROM.

IMPORTANT This function should be called before any adbrive360 control functions (drive_speed, drive_goto, etc).

Parameters
encPinLeftI/O pin number for the left encoder signal connection.
encPinRightI/O pin number for the right encoder signal connection.

◆ drive_feedback()

void drive_feedback ( int  enabled)

Enables or disables encoder feedback for speed control.

Parameters
enabledSet to 1 to enable feedback (default) or 0 to disable.

◆ drive_getTicks()

void drive_getTicks ( int *  left,
int *  right 
)

Get the measured number of ticks each servo has traveled since the program started running. Each "tick" is a 64th of a wheel turn, and corresponds to an ActivityBot 360 rolling distance of about 3.25 mm.

Parameters
*leftPointer to variable to receive the measured left distance.
*rightPointer to variable to receive the measured right distance.

◆ drive_getTicksCalc()

void drive_getTicksCalc ( int *  left,
int *  right 
)

Get the calculated number of 1/64th wheel revolution ticks the abdrive360 control system thinks each servo should have traveled.

Parameters
*leftPointer to variable to receive the measured left distance.
*rightPointer to variable to receive the measured right distance.

◆ drive_goto()

void drive_goto ( int  distLeft,
int  distRight 
)

Make the wheels travel a certain distance, measured in ticks.
Each "tick" is a 64th of a wheel turn, and corresponds to an ActivityBot 360 rolling distance of about 3.25 mm. Ramp up, cruise, ramp down and stop are coordinated so that different left/right distances result in curves.
Same distances are straight lines, and same distances with opposite +/- signs cause the ActivityBot 360 to turn in place. This function does not return until the maneuver has completed. If needed, you change that default with the drive_gotoMode function. The default cruising speed is 64 ticks/second, which can be adjusted with the drive_setMaxVelocity function.

Parameters
distLeftLeft wheel distance in 1/64th revolution ticks.
distRightRight wheel distance in ticks.

◆ drive_gotoMode()

void drive_gotoMode ( int  mode)

Set the mode of the drive_goto call to blocking (default) or interruptible. For calls in interruptible mode, sufficient time must be allowed for the maneuver to complete before issuing another drive_goto or drive_speed call. The drive_gotoStatus function can also be polled to find when a given maneuver is done.

Parameters
modeInterruptible (0) or blocking (1). By default, the drive_goto function is set to blocking, and does not return until the maneuver has completed.

◆ drive_gotoStatus()

int drive_gotoStatus ( int  side)

After using drive_gotoMode(0) to cause the drive_goto function to not wait until the maneuver is done before returning, checking the status of a given maneuver can be useful. This function reports the status of maneuver initiated by the most recent drive_goto call.

Parameters
sidewith options of SIDE_LEFT, SIDE_RIGHT, or SIDE_BOTH.
Returns
value that corresponds to the 0 (done with last drive_goto maneuver or 1 (maneuver still in progress).

◆ drive_ramp()

void drive_ramp ( int  left,
int  right 
)

This function ramps up to a given speed and blocks execution until the speed is reached. In practice, a call to drive_speed followed by a pause to reach the desired speed will have the same effect but does not have practical applications.

Parameters
leftLeft wheel speed in ticks per second.
rightLeft wheel speed in ticks per second.

◆ drive_rampStep()

void drive_rampStep ( int  left,
int  right 
)

This function allows your code to ask for a speed repeatedly in a loop, but each time your code asks for that speed, it takes a step toward the speed. This helps cushion sudden maneuvers in sensor navigation, where the conditions might change more rapidly than you would want your ActivityBot 360's speed to change. Note: drive_speed has built-in ramping and is recommended in place of this function. It can be called repeatedly the same way applications call this function.

Parameters
leftLeft wheel speed in ticks per second.
rightRight wheel speed in ticks per second.

◆ drive_servoPins()

void drive_servoPins ( int  controlPinLeft,
int  controlPinRight 
)

Sets servo pins to values other than the default P12 for the left servo and P13 for right servo. Stores values in EEPROM, so you only need to call this function at the start of one program. Programs after that will get the modified port numbers from EEPROM.

IMPORTANT: This function should be called before any adbrive360 control functions (drive_speed, drive_goto, etc).

Parameters
controlPinLeftI/O pin number for the left servo signal connection.
controlPinRightI/O pin number for the right servo signal connection.

◆ drive_setAcceleration()

void drive_setAcceleration ( int  forGotoOrSpeed,
int  ticksPerSecSq 
)

Set the acceleration used by either drive_goto or drive_speed.

Parameters
forGotoOrSpeedcan be set to FOR_SPEED (0) or FOR_GOTO (1).
ticksPerSecSqThe ticks per second squared value to set the acceleration that speed and goto calls use. The default is 600 for drive_speed and 400 for drive_goto. Use increments of 50, up to 2000.

◆ drive_setMaxSpeed()

void drive_setMaxSpeed ( int  speed)

Modifies the default maximum top speed for Feedback 360 high speed servos. For calls to drive_speed, the default is 128 ticks/second = 2 revolutions per second (RPS). This value can be reduced, but not increased. Note: drive_setMaxVelocity is recommended in place of this function.

Parameters
speedMaximum cruising speed for drive_speed.

◆ drive_setMaxVelocity()

void drive_setMaxVelocity ( int  forGotoOrSpeed,
int  ticksPerSec 
)

Set the maximum velocity used by either drive_goto or drive_speed.
The defaults are 128 ticks per second for drive_speed, and 64 ticks per second for drive_goto. A tick is a 64th of a turn, and causes an ActivityBot 360 wheel to roll for 3.25 mm. The valid range is 32 to 128 ticks per second.

Parameters
forGotoOrSpeedcan be set to FOR_SPEED (0) or FOR_GOTO (1).
ticksPerSecThe ticks per second value that limits the top velocity, regardless of what calls to drive_speed ask for. The default is 128 for drive_speed and 64 for drive_goto. 128 is the maximum possible.

◆ drive_setRampStep()

void drive_setRampStep ( int  stepsize)

Overrides the default 12 ticks/second per 50th of a second for ramping. Note: drive_setAcceleration is recommended in place of this function.

Parameters
stepsizeThe size of each step in ticks/second to change every 50th of a second

◆ drive_speed()

void drive_speed ( int  left,
int  right 
)

Set wheel speeds in "ticks" per second. A tick is 1/64th of a revolution, and makes an ActivityBot 360 wheel roll 3.25 mm. The maximum speed for each wheel is +/- 128 ticks/second. Positive values are for forward motion; negative values are for reverse.

Parameters
leftLeft wheel speed in ticks per second.
rightRight wheel speed in ticks per second.

◆ drive_suppress_eeprom()

void drive_suppress_eeprom ( int  state)

Enables or disables ignore calibration settings stored in EEPROM.
This feature allows an ActivityBot application to initialize using I/O pins that are different from the ones stored in EEPROM.

Parameters
enabledSet to 1 to enable or 0 (default) to disable.