M-File Help: Arbotix | View code for Arbotix

# Arbotix

Interface to Arbotix robot controller

## Methods

Arbotix | Constructor, establishes serial communications
delete | Destructor, closes serial connection
getpos | Get joint angles
setpos | Set joint angles and optionally speed
relax | Control relax (zero torque) state
setled | Control LEDs on servos
gettemp | Temperature of motors

writedata1 | Write byte data to servo control table
writedata2 | Write word data to servo control table
readdata | Read servo control table

command | Execute command on servo
flush | Flushes serial data buffer

## Example

    arb=Arbotix('port', '/dev/tty.usbserial-A800JDPN', 'nservos', 5);

## Notes

- interface is via serial to an Arbotix controller running the pypose sketch

# Arbotix.Arbotix

Create Arbotix interface object

dm = Arbotix(options) is an object that represents a connection to a chain of Arbotix servos connected via an Arbotix controller and serial link to the host computer.

## Options

'port', P | Name of the serial port device, eg. /dev/tty.USB0
'baud', B | Set baud rate (default 38400)
'debug', D | Debug level, show communications packets (default 0)
'nservos', N | Number of servos in the chain

# Arbotix.a2e

Convert angle to encoder

E = ARB.A2E(a) is a vector of encoder values E corresponding to the vector of joint angles a.

# Arbotix.char

Convert Arbotix status to string

C = ARB.char() is a string that succinctly describes the status of the Arbotix controller link.

# Arbotix.command

Execute command on servo

R = ARB.COMMAND(id, instruc) executes the instruction instruc on servo id.

R = ARB.COMMAND(id, instruc, data) as above but the vector data forms the payload of the command message, and all numeric values in data must be in the range 0 to 255.

The optional output argument R is a structure holding the return status.

## Notes

- ID is in the range 0 to N-1, where N is the number of servos in the system.
- Values for INSTRUC are defined as class properties INS_*.
- If 'debug' was enabled in the constructor then the hex values are echoed to the screen as well as being sent to the Arbotix.
- If an output argument is requested the serial channel is flushed first.

## See also

Arbotix.receive, Arbotix.flush

# Arbotix.delete

Close the serial connection

delete(dm) closes the serial connection and removes the dm object from the workspace.

# Arbotix.discover

how many servos in the chain

# Arbotix.display

Display parameters

ARB.display() displays the servo parameters in compact single line format.

## Notes

- This method is invoked implicitly at the command line when the result of an expression is a Arbotix object and the command has no trailing semicolon.

## See also

Arbotix.char

# Arbotix.e2a

Convert encoder to angle

a = ARB.E2A(E) is a vector of joint angles a corresponding to the vector of encoder values E.

# Arbotix.flush

Flush the receive buffer

ARB.FLUSH() flushes the serial input buffer, data is discarded.

s = ARB.FLUSH() as above but returns a vector of all bytes flushed from the channel.

## Notes

- Every command sent to the Arbotix elicits a reply.
- The method receive() should be called after every command.
- Some Arbotix commands also return diagnostic text information.

## See also

Arbotix.receive, Arbotix.parse

# Arbotix.getpos

Get position

p = ARB.GETPOS(id) is the position (0-1023) of servo id.

p = ARB.GETPOS([]) is a vector (1xN) of positions of servos 1 to N.

## Notes

- N is defined at construction time by the 'nservos' option.

# Arbotix.gettemp

Get temperature

T = ARB.GETTEMP(id) is the tempeature (deg C) of servo id.

T = ARB.GETTEMP() is a vector (1xN) of the temperature of servos 1 to N.

## Notes

- N is defined at construction time by the 'nservos' option.

# Arbotix.parse

Parse Arbotix return strings

ARB.PARSE(s) parses the string returned from the Arbotix controller and prints diagnostic text. The string s contains a mixture of Dynamixel style return packets and diagnostic text.

## Notes

- Every command sent to the Arbotix elicits a reply.
- The method receive() should be called after every command.
- Some Arbotix commands also return diagnostic text information.

## See also

Arbotix.flush, Arbotix.command

# Arbotix.readdata

Read byte data from servo control table

R = ARB.READDATA(id, addr) reads the successive elements of the servo control table for servo id, starting at address addr. The complete return status in the structure R, and the byte data is a vector in the field 'params'.

## Notes

- ID is in the range 0 to N-1, where N is the number of servos in the system.
- If 'debug' was enabled in the constructor then the hex values are echoed to the screen as well as being sent to the Arbotix.

## See also

Arbotix.receive, Arbotix.command

# Arbotix.receive

Decode Arbotix return packet

R = ARB.RECEIVE() reads and parses the return packet from the Arbotix and returns a structure with the following fields:

id | The id of the servo that sent the message
error | Error code, 0 means OK
params | The returned parameters, can be a vector of byte values

## Notes

- Every command sent to the Arbotix elicits a reply.
- The method receive() should be called after every command.
- Some Arbotix commands also return diagnostic text information.
- If 'debug' was enabled in the constructor then the hex values are echoed

# Arbotix.relax

Control relax state

ARB.RELAX(id) causes the servo id to enter zero-torque (relax state) ARB.RELAX(id, FALSE) causes the servo id to enter position-control mode ARB.RELAX([]) causes servos 1 to N to relax ARB.RELAX() as above ARB.RELAX([], FALSE) causes servos 1 to N to enter position-control mode.

## Notes

- N is defined at construction time by the 'nservos' option.

# Arbotix.setled

Set LEDs on servos

ARB.led(id, status) sets the LED on servo id to on or off according to the status (logical).

ARB.led([], status) as above but the LEDs on servos 1 to N are set.

## Notes

- N is defined at construction time by the 'nservos' option.

# Arbotix.setpath

Load a path into Arbotix controller

ARB.setpath(jt) stores the path jt (PxN) in the Arbotix controller where P is the number of points on the path and N is the number of robot joints.

# Arbotix.setpos

Set position

ARB.SETPOS(id, pos) sets the position (0-1023) of servo id. ARB.SETPOS(id, pos, SPEED) as above but also sets the speed.

ARB.SETPOS(pos) sets the position of servos 1-N to corresponding elements of the vector pos (1xN). ARB.SETPOS(pos, SPEED) as above but also sets the velocity SPEED (1xN).

## Notes

- ID is in the range 1 to N
- N is defined at construction time by the 'nservos' option.
- SPEED varies from 0 to 1023, 0 means largest possible speed.

# Arbotix.setpos_sync

speed are vectors

# Arbotix.syncwrite

column per actuator

# Arbotix.writedata1

Write byte data to servo control table

ARB.WRITEDATA1(id, addr, data) writes the successive elements of data to the servo control table for servo id, starting at address addr. The values of data must be in the range 0 to 255.

## Notes

- ID is in the range 0 to N-1, where N is the number of servos in the system.
- If 'debug' was enabled in the constructor then the hex values are echoed to the screen as well as being sent to the Arbotix.

## See also

Arbotix.writedata2, Arbotix.command

# Arbotix.writedata2

Write word data to servo control table

ARB.WRITEDATA2(id, addr, data) writes the successive elements of data to the servo control table for servo id, starting at address addr. The values of data must be in the range 0 to 65535.

## Notes

- ID is in the range 0 to N-1, where N is the number of servos in the system.
- If 'debug' was enabled in the constructor then the hex values are echoed to the screen as well as being sent to the Arbotix.

## See also

Arbotix.writedata1, Arbotix.command

© 1990-2014 Peter Corke.