abdrive360 library v0.9.2 Differential servo drive library for the Parallax ActivityBot 360

- Main Page
- Files

- File List
- Globals

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.
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.
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.
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.
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.
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.
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.
void | drive_setAcceleration (int forGotoOrSpeed, int ticksPerSecSq)
| Set the acceleration used by either drive_goto or drive_speed.
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.
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.
void | drive_feedback (int enabled)
| Enables or disables encoder feedback for speed control.
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.
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.
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.
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.

## 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.

Copyright
  Copyright (C) Parallax Inc. 2017. All Rights MIT Licensed. See end of file.

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

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

  encPinLeft | I/O pin number for the left encoder signal connection.
  encPinRight | I/O pin number for the right encoder signal connection.

void drive_feedback | ( | int | enabled | ) |

Enables or disables encoder feedback for speed control.

Parameters

  enabled | Set to 1 to enable feedback (default) or 0 to disable.

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

  *left | Pointer to variable to receive the measured left distance.
  *right | Pointer to variable to receive the measured right distance.

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

  *left | Pointer to variable to receive the measured left distance.
  *right | Pointer to variable to receive the measured right distance.

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

  distLeft | Left wheel distance in 1/64th revolution ticks.
  distRight | Right wheel distance in ticks.

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

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

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

  side | with 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).

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

  left | Left wheel speed in ticks per second.
  right | Left wheel speed in ticks per second.

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

  left | Left wheel speed in ticks per second.
  right | Right wheel speed in ticks per second.

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

  controlPinLeft | I/O pin number for the left servo signal connection.
  controlPinRight | I/O pin number for the right servo signal connection.

void drive_setAcceleration | ( | int | forGotoOrSpeed,
|  | int | ticksPerSecSq
| ) |  |

Set the acceleration used by either drive_goto or drive_speed.

Parameters

  forGotoOrSpeed | can be set to FOR_SPEED (0) or FOR_GOTO (1).
  ticksPerSecSq | The 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.

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

  speed | Maximum cruising speed for drive_speed.

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

  forGotoOrSpeed | can be set to FOR_SPEED (0) or FOR_GOTO (1).
  ticksPerSec | The 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.

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

  stepsize | The size of each step in ticks/second to change every 50th of a second

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

  left | Left wheel speed in ticks per second.
  right | Right wheel speed in ticks per second.