Public Member Functions | Public Attributes | Static Public Attributes | Private Attributes | List of all members
arbotix_python.arbotix.ArbotiX Class Reference

This class controls an ArbotiX, USBDynamixel, or similar board through a serial connection. More...

Public Member Functions

def __init__ (self, port="/dev/ttyUSB0", baud=115200, timeout=0.1, open_port=True)
 Constructs an ArbotiX instance, optionally opening the serial connection. More...
 
def __write__ (self, msg)
 
def closePort (self)
 
def disableTorque (self, index)
 Turn on the torque of a servo. More...
 
def disableWheelMode (self, index, resolution=10)
 Put a servo into servo mode. More...
 
def enableTorque (self, index)
 Turn on the torque of a servo. More...
 
def enableWheelMode (self, index)
 Put a servo into wheel mode (continuous rotation). More...
 
def execute (self, index, ins, params, ret=True)
 Send an instruction to the device. More...
 
def getAnalog (self, index, leng=1)
 Get the value of an analog input pin. More...
 
def getDigital (self, index)
 Get the value of an digital input pin. More...
 
def getGoalSpeed (self, index)
 Get the goal speed of a servo. More...
 
def getPacket (self, mode, id=-1, leng=-1, error=-1, params=None)
 Read a dynamixel return packet in an iterative attempt. More...
 
def getPosition (self, index)
 Get the position of a servo. More...
 
def getReturnLevel (self, index)
 Get the return level of a device. More...
 
def getSpeed (self, index)
 Get the speed of a servo. More...
 
def getTemperature (self, index)
 Get the temperature of a device. More...
 
def getVoltage (self, index)
 Get the voltage of a device. More...
 
def isMoving (self, index)
 Determine if a device is moving. More...
 
def openPort (self)
 
def read (self, index, start, length)
 Read values of registers. More...
 
def rescan (self)
 Force the ArbotiX2 to rescan the Dynamixel busses. More...
 
def setBaud (self, index, baud)
 Set baud rate of a device. More...
 
def setDigital (self, index, value, direction=0xff)
 Get the value of an digital input pin. More...
 
def setLed (self, index, value)
 Set the status of the LED on a servo. More...
 
def setPosition (self, index, value)
 Set the position of a servo. More...
 
def setReturnLevel (self, index, value)
 Set the return level of a device. More...
 
def setServo (self, index, value)
 Set the position of a hobby servo. More...
 
def setSpeed (self, index, value)
 Set the speed of a servo. More...
 
def setWheelSpeed (self, index, direction, speed)
 Set the speed and direction of a servo which is in wheel mode (continuous rotation). More...
 
def syncRead (self, servos, start, length)
 Read values of registers on many servos. More...
 
def syncWrite (self, start, values)
 Write values to registers on many servos. More...
 
def write (self, index, start, values)
 Write values to registers. More...
 

Public Attributes

 error
 The last error level read back. More...
 

Static Public Attributes

int ANA_BASE = 18
 Register address of first analog port (read only). More...
 
int BACKWARD = 1
 Direction definition for setWheelSpeed. More...
 
int FORWARD = 0
 Direction definition for setWheelSpeed. More...
 
int HIGH = 0xff
 Helper definition for analog and digital access. More...
 
int INPUT = 0
 Helper definition for analog and digital access. More...
 
int LOW = 0
 Extended ArbotiX Driver. More...
 
int OUTPUT = 0xff
 Helper definition for analog and digital access. More...
 
int REG_DIGITAL_IN0 = 5
 Register base address for reading digital ports. More...
 
int REG_DIGITAL_IN1 = 6
 
int REG_DIGITAL_IN2 = 7
 
int REG_DIGITAL_IN3 = 8
 
int REG_DIGITAL_OUT0 = 47
 
int REG_RESCAN = 15
 Register address for triggering rescan. More...
 
int SERVO_BASE = 26
 Register address of analog servos. More...
 

Private Attributes

 _mutex
 
 _ser
 

Detailed Description

This class controls an ArbotiX, USBDynamixel, or similar board through a serial connection.

Definition at line 42 of file arbotix.py.

Constructor & Destructor Documentation

◆ __init__()

def arbotix_python.arbotix.ArbotiX.__init__ (   self,
  port = "/dev/ttyUSB0",
  baud = 115200,
  timeout = 0.1,
  open_port = True 
)

Constructs an ArbotiX instance, optionally opening the serial connection.

Parameters
portThe name of the serial port to open.
baudThe baud rate to run the port at.
timeoutThe timeout to use for the port. When operating over a wireless link, you may need to increase this.
openWhether to open immediately the serial port.

Definition at line 54 of file arbotix.py.

Member Function Documentation

◆ __write__()

def arbotix_python.arbotix.ArbotiX.__write__ (   self,
  msg 
)

Definition at line 68 of file arbotix.py.

◆ closePort()

def arbotix_python.arbotix.ArbotiX.closePort (   self)

Definition at line 82 of file arbotix.py.

◆ disableTorque()

def arbotix_python.arbotix.ArbotiX.disableTorque (   self,
  index 
)

Turn on the torque of a servo.

Parameters
indexThe ID of the device to disable.
Returns
The error level.

Definition at line 290 of file arbotix.py.

◆ disableWheelMode()

def arbotix_python.arbotix.ArbotiX.disableWheelMode (   self,
  index,
  resolution = 10 
)

Put a servo into servo mode.

Parameters
indexThe ID of the device to write.
resolutionThe resolution of the encoder on the servo. NOTE: if using 12-bit resolution servos (EX-106, MX-28, etc), you must pass resolution = 12.
Returns

Definition at line 407 of file arbotix.py.

◆ enableTorque()

def arbotix_python.arbotix.ArbotiX.enableTorque (   self,
  index 
)

Turn on the torque of a servo.

Parameters
indexThe ID of the device to enable.
Returns
The error level.

Definition at line 282 of file arbotix.py.

◆ enableWheelMode()

def arbotix_python.arbotix.ArbotiX.enableWheelMode (   self,
  index 
)

Put a servo into wheel mode (continuous rotation).

Parameters
indexThe ID of the device to write.

Definition at line 396 of file arbotix.py.

◆ execute()

def arbotix_python.arbotix.ArbotiX.execute (   self,
  index,
  ins,
  params,
  ret = True 
)

Send an instruction to the device.

Parameters
indexThe ID of the servo to write.
insThe instruction to send.
paramsA list of the params to send.
retWhether to read a return packet.
Returns
The return packet, if read.

Definition at line 149 of file arbotix.py.

◆ getAnalog()

def arbotix_python.arbotix.ArbotiX.getAnalog (   self,
  index,
  leng = 1 
)

Get the value of an analog input pin.

Parameters
indexThe ID of the pin to read (0 to 7).
lengThe number of bytes to read (1 or 2).
Returns
8-bit/16-bit analog value of the pin, -1 if error.

Definition at line 478 of file arbotix.py.

◆ getDigital()

def arbotix_python.arbotix.ArbotiX.getDigital (   self,
  index 
)

Get the value of an digital input pin.

Parameters
indexThe ID of the pin to read (0 to 31).
Returns
0 for low, 255 for high, -1 if error.

Definition at line 490 of file arbotix.py.

◆ getGoalSpeed()

def arbotix_python.arbotix.ArbotiX.getGoalSpeed (   self,
  index 
)

Get the goal speed of a servo.

Parameters
indexThe ID of the device to read.
Returns
The servo goal speed.

Definition at line 352 of file arbotix.py.

◆ getPacket()

def arbotix_python.arbotix.ArbotiX.getPacket (   self,
  mode,
  id = -1,
  leng = -1,
  error = -1,
  params = None 
)

Read a dynamixel return packet in an iterative attempt.

Parameters
modeThis should be 0 to start reading packet.
Returns
The error level returned by the device.

Definition at line 90 of file arbotix.py.

◆ getPosition()

def arbotix_python.arbotix.ArbotiX.getPosition (   self,
  index 
)

Get the position of a servo.

Parameters
indexThe ID of the device to read.
Returns
The servo position.

Definition at line 328 of file arbotix.py.

◆ getReturnLevel()

def arbotix_python.arbotix.ArbotiX.getReturnLevel (   self,
  index 
)

Get the return level of a device.

Parameters
indexThe ID of the device to read.
Returns
The return level, .

Definition at line 261 of file arbotix.py.

◆ getSpeed()

def arbotix_python.arbotix.ArbotiX.getSpeed (   self,
  index 
)

Get the speed of a servo.

Parameters
indexThe ID of the device to read.
Returns
The servo speed.

Definition at line 340 of file arbotix.py.

◆ getTemperature()

def arbotix_python.arbotix.ArbotiX.getTemperature (   self,
  index 
)

Get the temperature of a device.

Parameters
indexThe ID of the device to read.
Returns
The temperature, in degrees C.

Definition at line 375 of file arbotix.py.

◆ getVoltage()

def arbotix_python.arbotix.ArbotiX.getVoltage (   self,
  index 
)

Get the voltage of a device.

Parameters
indexThe ID of the device to read.
Returns
The voltage, in Volts.

Definition at line 364 of file arbotix.py.

◆ isMoving()

def arbotix_python.arbotix.ArbotiX.isMoving (   self,
  index 
)

Determine if a device is moving.

Parameters
indexThe ID of the device to read.
Returns
True if servo is moving.

Definition at line 386 of file arbotix.py.

◆ openPort()

def arbotix_python.arbotix.ArbotiX.openPort (   self)

Definition at line 75 of file arbotix.py.

◆ read()

def arbotix_python.arbotix.ArbotiX.read (   self,
  index,
  start,
  length 
)

Read values of registers.

Parameters
indexThe ID of the servo.
startThe starting register address to begin the read at.
lengthThe number of bytes to read.
Returns
A list of the bytes read, or -1 if failure.

Definition at line 182 of file arbotix.py.

◆ rescan()

def arbotix_python.arbotix.ArbotiX.rescan (   self)

Force the ArbotiX2 to rescan the Dynamixel busses.

Definition at line 468 of file arbotix.py.

◆ setBaud()

def arbotix_python.arbotix.ArbotiX.setBaud (   self,
  index,
  baud 
)

Set baud rate of a device.

Parameters
indexThe ID of the device to write (Note: ArbotiX is 253).
baudThe baud rate.
Returns
The error level.

Definition at line 253 of file arbotix.py.

◆ setDigital()

def arbotix_python.arbotix.ArbotiX.setDigital (   self,
  index,
  value,
  direction = 0xff 
)

Get the value of an digital input pin.

Parameters
indexThe ID of the pin to write (0 to 31).
valueThe value of the port, >0 is high.
directionThe direction of the port, >0 is output.
Returns
-1 if error.

Definition at line 512 of file arbotix.py.

◆ setLed()

def arbotix_python.arbotix.ArbotiX.setLed (   self,
  index,
  value 
)

Set the status of the LED on a servo.

Parameters
indexThe ID of the device to write.
value0 to turn the LED off, >0 to turn it on
Returns
The error level.

Definition at line 300 of file arbotix.py.

◆ setPosition()

def arbotix_python.arbotix.ArbotiX.setPosition (   self,
  index,
  value 
)

Set the position of a servo.

Parameters
indexThe ID of the device to write.
valueThe position to go to in, in servo ticks.
Returns
The error level.

Definition at line 310 of file arbotix.py.

◆ setReturnLevel()

def arbotix_python.arbotix.ArbotiX.setReturnLevel (   self,
  index,
  value 
)

Set the return level of a device.

Parameters
indexThe ID of the device to write.
valueThe return level.
Returns
The error level.

Definition at line 274 of file arbotix.py.

◆ setServo()

def arbotix_python.arbotix.ArbotiX.setServo (   self,
  index,
  value 
)

Set the position of a hobby servo.

Parameters
indexThe ID of the servo to write (0 to 7).
valueThe position of the servo in milliseconds (1500-2500). A value of 0 disables servo output.
Returns
-1 if error.

Definition at line 532 of file arbotix.py.

◆ setSpeed()

def arbotix_python.arbotix.ArbotiX.setSpeed (   self,
  index,
  value 
)

Set the speed of a servo.

Parameters
indexThe ID of the device to write.
valueThe speed to write.
Returns
The error level.

Definition at line 320 of file arbotix.py.

◆ setWheelSpeed()

def arbotix_python.arbotix.ArbotiX.setWheelSpeed (   self,
  index,
  direction,
  speed 
)

Set the speed and direction of a servo which is in wheel mode (continuous rotation).

Parameters
indexThe ID of the device to write.
directionThe direction of rotation, either FORWARD or BACKWARD
speedThe speed to move at (0-1023).
Returns

Definition at line 425 of file arbotix.py.

◆ syncRead()

def arbotix_python.arbotix.ArbotiX.syncRead (   self,
  servos,
  start,
  length 
)

Read values of registers on many servos.

Parameters
servosA list of the servo IDs to read from.
startThe starting register address to begin reading at.
lengthThe number of bytes to read from each servo.
Returns
A list of bytes read.

Definition at line 243 of file arbotix.py.

◆ syncWrite()

def arbotix_python.arbotix.ArbotiX.syncWrite (   self,
  start,
  values 
)

Write values to registers on many servos.

Parameters
startThe starting register address to begin writing to.
valuesThe data to write, in a list of lists. Format should be [(id1, val1, val2), (id2, val1, val2)]

Definition at line 208 of file arbotix.py.

◆ write()

def arbotix_python.arbotix.ArbotiX.write (   self,
  index,
  start,
  values 
)

Write values to registers.

Parameters
indexThe ID of the servo.
startThe starting register address to begin writing to.
valuesThe data to write, in a list.
Returns
The error level.

Definition at line 198 of file arbotix.py.

Member Data Documentation

◆ _mutex

arbotix_python.arbotix.ArbotiX._mutex
private

Definition at line 55 of file arbotix.py.

◆ _ser

arbotix_python.arbotix.ArbotiX._ser
private

Definition at line 56 of file arbotix.py.

◆ ANA_BASE

int arbotix_python.arbotix.ArbotiX.ANA_BASE = 18
static

Register address of first analog port (read only).

Each additional port is BASE + index.

Definition at line 460 of file arbotix.py.

◆ BACKWARD

int arbotix_python.arbotix.ArbotiX.BACKWARD = 1
static

Direction definition for setWheelSpeed.

Definition at line 414 of file arbotix.py.

◆ error

arbotix_python.arbotix.ArbotiX.error

The last error level read back.

Definition at line 66 of file arbotix.py.

◆ FORWARD

int arbotix_python.arbotix.ArbotiX.FORWARD = 0
static

Direction definition for setWheelSpeed.

Definition at line 412 of file arbotix.py.

◆ HIGH

int arbotix_python.arbotix.ArbotiX.HIGH = 0xff
static

Helper definition for analog and digital access.

Definition at line 442 of file arbotix.py.

◆ INPUT

int arbotix_python.arbotix.ArbotiX.INPUT = 0
static

Helper definition for analog and digital access.

Definition at line 444 of file arbotix.py.

◆ LOW

int arbotix_python.arbotix.ArbotiX.LOW = 0
static

Extended ArbotiX Driver.

Helper definition for analog and digital access.

Definition at line 440 of file arbotix.py.

◆ OUTPUT

int arbotix_python.arbotix.ArbotiX.OUTPUT = 0xff
static

Helper definition for analog and digital access.

Definition at line 446 of file arbotix.py.

◆ REG_DIGITAL_IN0

int arbotix_python.arbotix.ArbotiX.REG_DIGITAL_IN0 = 5
static

Register base address for reading digital ports.

Definition at line 451 of file arbotix.py.

◆ REG_DIGITAL_IN1

int arbotix_python.arbotix.ArbotiX.REG_DIGITAL_IN1 = 6
static

Definition at line 452 of file arbotix.py.

◆ REG_DIGITAL_IN2

int arbotix_python.arbotix.ArbotiX.REG_DIGITAL_IN2 = 7
static

Definition at line 453 of file arbotix.py.

◆ REG_DIGITAL_IN3

int arbotix_python.arbotix.ArbotiX.REG_DIGITAL_IN3 = 8
static

Definition at line 454 of file arbotix.py.

◆ REG_DIGITAL_OUT0

int arbotix_python.arbotix.ArbotiX.REG_DIGITAL_OUT0 = 47
static

Definition at line 465 of file arbotix.py.

◆ REG_RESCAN

int arbotix_python.arbotix.ArbotiX.REG_RESCAN = 15
static

Register address for triggering rescan.

Definition at line 456 of file arbotix.py.

◆ SERVO_BASE

int arbotix_python.arbotix.ArbotiX.SERVO_BASE = 26
static

Register address of analog servos.

Up to 10 servos, each uses 2 bytes (L, then H), pulse width (0, 1000-2000ms) (Write only)

Definition at line 463 of file arbotix.py.


The documentation for this class was generated from the following file:


arbotix_python
Author(s): Michael Ferguson
autogenerated on Tue Mar 1 2022 23:48:25