Kangaroo Library for Arduino
Use reliable Packet Serial to communicate with your Kangaroo.
Classes | Macros | Enumerations | Functions
Kangaroo.h File Reference

Go to the source code of this file.

Classes

class  KangarooStatus
 Stores the response to a status request. More...
 
class  KangarooSerial
 Create a KangarooSerial for the serial port you are using, and then attach a KangarooChannel for each channel you want to communicate with. More...
 
class  KangarooTimeout
 Encapsulates a starting time and duration. More...
 
class  KangarooChannel
 Lets you send commands to and get position, speed, etc. for a specific channel of the Kangaroo. More...
 
class  KangarooMonitor
 Makes it easy to track the status of position commands, speed commands, and any other commands that take time to complete. More...
 

Macros

#define KANGAROO_DEFAULT_ADDRESS   128
 The default Packet Serial address for Kangaroo is 128.
 
#define KANGAROO_DEFAULT_COMMAND_RETRY_INTERVAL   100
 By default, commands retry after 100 milliseconds if no response is received.
 
#define KANGAROO_DEFAULT_COMMAND_TIMEOUT   KANGAROO_INFINITE_TIMEOUT
 By default, commands are retried forever.
 
#define KANGAROO_INFINITE_TIMEOUT   -1
 This value, passed as a timeout, disables the timeout.
 
#define KANGAROO_UNSPECIFIED_LIMIT   -1
 This value, passed as a limit, leaves the limit unspecified.
 

Enumerations

enum  KangarooError {
  KANGAROO_NO_ERROR = 0x00, KANGAROO_NOT_STARTED = 0x01, KANGAROO_NOT_HOMED = 0x02, KANGAROO_CONTROL_ERROR = 0x03,
  KANGAROO_WRONG_MODE = 0x04 , KANGAROO_SERIAL_TIMEOUT = 0x06 , KANGAROO_TIMED_OUT = -0x02
}
 
enum  KangarooGetType {
  KANGAROO_GETP = 0x01, KANGAROO_GETPI = 0x41, KANGAROO_GETS = 0x02, KANGAROO_GETSI = 0x42,
  KANGAROO_GETMIN = 0x08, KANGAROO_GETMAX = 0x09
}
 
enum  KangarooGetFlags { KANGAROO_GET_DEFAULT = 0x00 , KANGAROO_GET_RAW_UNITS = 0x20 }
 
enum  KangarooMoveFlags { KANGAROO_MOVE_DEFAULT = 0x00, KANGAROO_MOVE_NO_DEFAULT_LIMITS = 0x08, KANGAROO_MOVE_RAW_UNITS = 0x20 }
 
enum  KangarooStatusFlags { KANGAROO_STATUS_NONE = 0x00, KANGAROO_STATUS_ERROR = 0x01, KANGAROO_STATUS_BUSY = 0x02 , KANGAROO_STATUS_RAW_UNITS = 0x20 }
 
enum  KangarooSystemCommand {
  KANGAROO_SYS_POWER_DOWN = 0x00, KANGAROO_SYS_POWER_DOWN_ALL = 0x01, KANGAROO_SYS_TUNE_ENTER_MODE = 0x03, KANGAROO_SYS_TUNE_SET_DISABLED_CHANNELS = 0x08,
  KANGAROO_SYS_TUNE_CONTROL_OPEN_LOOP = 0x06, KANGAROO_SYS_TUNE_GO = 0x04, KANGAROO_SYS_TUNE_ABORT = 0x05, KANGAROO_SYS_SET_BAUD_RATE = 0x20,
  KANGAROO_SYS_SET_SERIAL_TIMEOUT = 0x21
}
 

Functions

boolean waitAll (size_t count, KangarooMonitor *monitors[], int32_t timeoutMS=KANGAROO_INFINITE_TIMEOUT)
 
boolean waitAll (size_t count, KangarooMonitor *monitors[], const KangarooTimeout &timeout)
 
int waitAny (size_t count, KangarooMonitor *monitors[], int32_t timeoutMS=KANGAROO_INFINITE_TIMEOUT)
 
int waitAny (size_t count, KangarooMonitor *monitors[], const KangarooTimeout &timeout)
 

Detailed Description

Include this file to use the Kangaroo Arduino library.

Enumeration Type Documentation

Errors that can occur in response to status queries.

Enumerator
KANGAROO_NO_ERROR 

No error occurred.

KANGAROO_NOT_STARTED 

The channel is not started. Call KangarooChannel::start() on the channel.

KANGAROO_NOT_HOMED 

The channel needs to be homed. Call KangarooChannel::home() on the channel.

KANGAROO_CONTROL_ERROR 

A control error has occurred. Call KangarooChannel::start() on the channel to clear the control error.

KANGAROO_WRONG_MODE 

The controller is in the wrong mode. For example, the DIP switches may be in Mixed Mode while the tune was done in Independent Mode.

KANGAROO_SERIAL_TIMEOUT 

A serial timeout occurred, or the TX line was disconnected. Call KangarooChannel::start() on the channel to clear the serial timeout.

KANGAROO_TIMED_OUT 

The requested timeout expired.

Flags that modify the behavior of a 'get' request.

Enumerator
KANGAROO_GET_DEFAULT 

Normal behavior.

KANGAROO_GET_RAW_UNITS 

Use raw units. For analog, raw units are millivolts. For quadrature, 4 raw units equal 1 line.

The possible 'get' request types.

Enumerator
KANGAROO_GETP 

Absolute position.

KANGAROO_GETPI 

Incremental position (relative to the position when the last command was issued).

KANGAROO_GETS 

Absolute velocity.

KANGAROO_GETSI 

Incremental velocity (relative to the speed when the last command was issued).

KANGAROO_GETMIN 

The minimum position. This corresponds to DEScribe's Nominal Travel minimum.

KANGAROO_GETMAX 

The maximum position. This corresponds to DEScribe's Nominal Travel maximum.

Flags that modify the behavior of a motion request.

Enumerator
KANGAROO_MOVE_DEFAULT 

Normal behavior.

KANGAROO_MOVE_NO_DEFAULT_LIMITS 

Do not apply the speed limit and speed ramping source settings. By default, the speed limit comes from Kangaroo's potentiometers.

KANGAROO_MOVE_RAW_UNITS 

Use raw units. For analog, raw units are millivolts. For quadrature, 4 raw units equal 1 line.

Flags that provide details about a query response.

Enumerator
KANGAROO_STATUS_NONE 

The response is normal.

KANGAROO_STATUS_ERROR 

The response is an error.

KANGAROO_STATUS_BUSY 

For a motion, this means the motion is not finished. For an error, this means the error (such as KANGAROO_NOT_HOMED) should self-clear. This corresponds to a lowercase letter in Simplified Serial.

KANGAROO_STATUS_RAW_UNITS 

The value in the response is in raw units. For analog, raw units are millivolts. For quadrature, 4 raw units equal 1 line.

Advanced commands that have special effects on the Kangaroo motion controller.

Enumerator
KANGAROO_SYS_POWER_DOWN 

Powers down the channel.

KANGAROO_SYS_POWER_DOWN_ALL 

Powers down all channels of the controller that receives the command.

KANGAROO_SYS_TUNE_ENTER_MODE 

Enters tune mode 1 (Teach), 2 (Limit Switches), or 3 (Mechanical Stops). This corresponds to pressing the tune button to get to the mode you want.

Do not expect a reply from this command.

KANGAROO_SYS_TUNE_SET_DISABLED_CHANNELS 

Initially all channels are disabled for safety reasons after entering a tune mode. You must send this bitmask before beginning the tune. 0 enables all channels.

Do not expect a reply from this command.

KANGAROO_SYS_TUNE_CONTROL_OPEN_LOOP 

Sets the open loop power. This can be used to position for a Teach tune. The range is -(2^28-1) to 2^28-1.

Do not expect a reply from this command.

KANGAROO_SYS_TUNE_GO 

Begins the tune. This corresponds to pressing the tune button after you are in the desired mode.

Tuning has an automatic serial timeout for safety reasons. You must continually send packets or it will abort. KangarooChannel::getP() in a loop does the job.

Do not expect a reply from this command.

KANGAROO_SYS_TUNE_ABORT 

Aborts the tune.

                                       Do not expect a reply from this command.  
KANGAROO_SYS_SET_BAUD_RATE 

Sets the baud rate.

                                       Do not expect a reply from this command.  
KANGAROO_SYS_SET_SERIAL_TIMEOUT 

Sets the serial timeout.

Function Documentation

boolean waitAll ( size_t  count,
KangarooMonitor monitors[],
int32_t  timeoutMS = KANGAROO_INFINITE_TIMEOUT 
)

Waits until all of the monitors are done or the timeout expires.

Parameters
countThe number of monitors.
monitorsThe monitors to wait for.
timeoutMSThe timeout to use, in milliseconds.
Returns
True if all of the monitors are done, or false if the timeout expired.
Remarks
If a monitor is null, it is ignored.
boolean waitAll ( size_t  count,
KangarooMonitor monitors[],
const KangarooTimeout timeout 
)

Waits until all of the monitors are done or the timeout object expires.

Parameters
countThe number of monitors.
monitorsThe monitors to wait for.
timeoutThe timeout object to use.
Returns
True if all of the monitors are done, or false if the timeout expired.
Remarks
If a monitor is null, it is ignored.
int waitAny ( size_t  count,
KangarooMonitor monitors[],
int32_t  timeoutMS = KANGAROO_INFINITE_TIMEOUT 
)

Waits until at least one of the monitors is done or the timeout expires.

Parameters
countThe number of monitors.
monitorsThe monitors to wait for.
timeoutMSThe timeout to use, in milliseconds.
Returns
The array index of the monitor that is done, or -1 if the timeout expired.
Remarks
If a monitor is null, it is ignored.
int waitAny ( size_t  count,
KangarooMonitor monitors[],
const KangarooTimeout timeout 
)

Waits until at least one of the monitors is done or the timeout expires.

Parameters
countThe number of monitors.
monitorsThe monitors to wait for.
timeoutThe timeout object to use.
Returns
The array index of the monitor that is done, or -1 if the timeout expired.
Remarks
If a monitor is null, it is ignored.