![]() |
Dynamixel
2.9.5
RoadNarrows Robotics Dynamixel Package
|
Public Member Functions | |
dxl () | |
Default constructor. | |
~dxl () | |
Destructor. | |
int | open (const char *deviceName, int baudrate) |
Open Dynamixel Bus serial interface. More... | |
int | dxl_initialize (int deviceIndex, int baudnum) |
Initialize Dynamixel Bus USB serial interface by index. More... | |
void | close () |
Close the Dynamixel Bus serial interface. More... | |
int | setBaudRate (int baudrate) |
Set Dynamixel Bus serial device baud rate. More... | |
int | setHalfDuplexCallbacks (dxl_hdctl_tx_cb_t enable_tx_cb, dxl_hdctl_rx_cb_t enable_rx_cb, void *arg) |
Set serial half-duplex callbacks. More... | |
int | getFd () |
Get the Dynamixel Bus serial device file descriptor. More... | |
void | setTxPacketId (int id) |
Set transmit packet servo id. More... | |
void | setTxPacketInstruction (int instruction) |
Set transmit packet instruction. More... | |
void | setTxPacketParameter (int index, int value) |
Set transmit packet parameter value. More... | |
void | setTxPacketLength (int length) |
Set transmit packet length. More... | |
unsigned int | getRxPacketErrBits () |
Get receive packet error bits field. More... | |
bool | getRxPacketError (unsigned int errbit) |
Test if error bit is set on received packet. More... | |
int | getRxPacketLength () |
Get receive packet length field. More... | |
int | getRxPacketParameter (int index) |
Get receive packet parameter value. More... | |
int | makeWord (int lowbyte, int highbyte) |
Make 16-bit word. More... | |
int | getLowByte (int word) |
Get low byte from word. More... | |
int | getHighByte (int word) |
Get high byte from word. More... | |
void | txPacket () |
Transmit a previously packed instruction packet. More... | |
void | rxPacket () |
Receive status packet. More... | |
void | txrxPacket () |
Transmit instruction packet and receive status response packet. More... | |
int | getResult () |
Get last transmit/receive result. More... | |
void | ping (int id) |
Ping servo. More... | |
int | readByte (int id, int address) |
Read byte from servo's control table. More... | |
void | writeByte (int id, int address, int value) |
Write byte to servo's control table. More... | |
int | readWord (int id, int address) |
Read word from servo's control table. More... | |
void | writeWord (int id, int address, int value) |
Write word to servo's control table. More... | |
Protected Member Functions | |
float | dxl_baudnum_to_baudrate (int baudnum) |
Convert Dynamixel baud number to baud rate. More... | |
Protected Attributes | |
uint8_t | m_bufInstructionPacket [(150)+10] |
instruction transmit packet buffer | |
uint8_t | m_bufStatusPacket [(60)+10] |
status receive packet buffer | |
int | m_nRxPacketLength |
expected received packet length | |
int | m_nRxGetLength |
current received packet length | |
int | m_nCommStatus |
communication status | |
bool | m_bBusUsing |
bus is [not] busy | |
dxl_hdctl_tx_cb_t | m_fnEnableTx |
enable tx callback | |
dxl_hdctl_rx_cb_t | m_fnEnableRx |
enable rx callback | |
void * | m_pTxRxArg |
tx/rx argument passback | |
dxlhal * | m_pDxlHal |
void dxl::close | ( | ) |
Close the Dynamixel Bus serial interface.
The serial device is closed.
Definition at line 89 of file dynamixel.cxx.
References libdxl::dxlhal::close().
Referenced by DynaCommSerial::Close().
|
protected |
Convert Dynamixel baud number to baud rate.
baudnum | Dynamixel baud number. |
Definition at line 519 of file dynamixel.cxx.
References DXL_BAUDNUM_EXT_2250000, DXL_BAUDNUM_EXT_2500000, and DXL_BAUDNUM_EXT_3000000.
Referenced by dxl_initialize().
int dxl::dxl_initialize | ( | int | deviceIndex, |
int | baudnum | ||
) |
Initialize Dynamixel Bus USB serial interface by index.
The serial device is opened and attributes set.
deviceIndex | Device number of /dev/ttyUSBn, n == deviceIndex. |
baudnum | Dynamixel baud number. |
Definition at line 72 of file dynamixel.cxx.
References dxl_baudnum_to_baudrate(), DXL_COMM_RXSUCCESS, libdxl::dxlhal::dxl_hal_open(), m_bBusUsing, and m_nCommStatus.
Referenced by DynaCommSerial::Open().
int dxl::getFd | ( | ) |
Get the Dynamixel Bus serial device file descriptor.
Definition at line 110 of file dynamixel.cxx.
References libdxl::dxlhal::getFd().
Referenced by DynaCommSerial::Open().
int dxl::getHighByte | ( | int | word | ) |
Get high byte from word.
word | 16-bit word. |
Definition at line 173 of file dynamixel.cxx.
Referenced by DynaCommSerial::SyncWrite(), and writeWord().
int dxl::getLowByte | ( | int | word | ) |
Get low byte from word.
word | 16-bit word. |
Definition at line 165 of file dynamixel.cxx.
Referenced by DynaCommSerial::SyncWrite(), and writeWord().
int dxl::getResult | ( | ) |
Get last transmit/receive result.
Definition at line 446 of file dynamixel.cxx.
References m_nCommStatus.
Referenced by DynaCommSerial::Ping(), DynaCommSerial::Read16(), DynaCommSerial::Read8(), DynaCommSerial::Reset(), DynaCommSerial::SyncWrite(), DynaCommSerial::Write16(), and DynaCommSerial::Write8().
unsigned int dxl::getRxPacketErrBits | ( | ) |
Get receive packet error bits field.
Definition at line 135 of file dynamixel.cxx.
References DXL_ERRBIT, and m_bufStatusPacket.
Referenced by DynaCommSerial::Read16(), DynaCommSerial::Read8(), DynaCommSerial::Reset(), DynaCommSerial::Write16(), and DynaCommSerial::Write8().
bool dxl::getRxPacketError | ( | unsigned int | errbit | ) |
Test if error bit is set on received packet.
errbit | Error bit to test. |
Definition at line 140 of file dynamixel.cxx.
References DXL_ERRBIT, and m_bufStatusPacket.
int dxl::getRxPacketLength | ( | ) |
Get receive packet length field.
Definition at line 145 of file dynamixel.cxx.
References DXL_LENGTH, and m_bufStatusPacket.
int dxl::getRxPacketParameter | ( | int | index | ) |
Get receive packet parameter value.
index | Zero offset parameter index. |
Definition at line 150 of file dynamixel.cxx.
References DXL_PARAMETER, and m_bufStatusPacket.
int dxl::makeWord | ( | int | lowbyte, |
int | highbyte | ||
) |
Make 16-bit word.
lowbyte | Least significant byte. |
highbyte | Most significant byte. |
Definition at line 155 of file dynamixel.cxx.
Referenced by readWord().
int dxl::open | ( | const char * | deviceName, |
int | baudrate | ||
) |
Open Dynamixel Bus serial interface.
The serial device is opened and attributes set.
deviceName | Serial device name. |
baudrate | Dynamixel baud rate. |
Definition at line 59 of file dynamixel.cxx.
References DXL_COMM_RXSUCCESS, m_bBusUsing, m_nCommStatus, and libdxl::dxlhal::open().
Referenced by DynaCommSerial::Open().
void dxl::ping | ( | int | id | ) |
Ping servo.
Use dxl_get_result() to check for success or failure.
id | Servo id. |
Definition at line 451 of file dynamixel.cxx.
References DXL_ID, DXL_INST_PING, DXL_INSTRUCTION, DXL_LENGTH, m_bBusUsing, m_bufInstructionPacket, and txrxPacket().
Referenced by DynaCommSerial::Ping().
int dxl::readByte | ( | int | id, |
int | address | ||
) |
Read byte from servo's control table.
Use dxl_get_result() to check for success or failure.
id | Servo id. |
address | Control table address. |
Definition at line 462 of file dynamixel.cxx.
References DXL_ID, DXL_INST_READ, DXL_INSTRUCTION, DXL_LENGTH, DXL_PARAMETER, m_bBusUsing, m_bufInstructionPacket, m_bufStatusPacket, and txrxPacket().
Referenced by DynaCommSerial::Read8().
int dxl::readWord | ( | int | id, |
int | address | ||
) |
Read word from servo's control table.
Use dxl_get_result() to check for success or failure.
id | Servo id. |
address | Control table address. |
Definition at line 490 of file dynamixel.cxx.
References DXL_ID, DXL_INST_READ, DXL_INSTRUCTION, DXL_LENGTH, DXL_PARAMETER, m_bBusUsing, m_bufInstructionPacket, m_bufStatusPacket, makeWord(), and txrxPacket().
Referenced by DynaCommSerial::Read16().
void dxl::rxPacket | ( | ) |
Receive status packet.
Definition at line 271 of file dynamixel.cxx.
References DXL_BROADCAST_ID, DXL_COMM_RXCORRUPT, DXL_COMM_RXSUCCESS, DXL_COMM_RXTIMEOUT, DXL_COMM_RXWAITING, DXL_COMM_TXSUCCESS, DXL_ID, DXL_INST_PING, DXL_INSTRUCTION, DXL_LENGTH, libdxl::dxlhal::hasTimedOut(), m_bBusUsing, m_bufInstructionPacket, m_bufStatusPacket, m_fnEnableRx, m_nCommStatus, m_nRxGetLength, m_nRxPacketLength, m_pTxRxArg, and libdxl::dxlhal::rx().
Referenced by txrxPacket().
int dxl::setBaudRate | ( | int | baudrate | ) |
Set Dynamixel Bus serial device baud rate.
baudrate | Baud rate. |
Definition at line 94 of file dynamixel.cxx.
References libdxl::dxlhal::setBaudRate().
Referenced by DynaCommSerial::SetBaudRate().
int dxl::setHalfDuplexCallbacks | ( | dxl_hdctl_tx_cb_t | enable_tx_cb, |
dxl_hdctl_rx_cb_t | enable_rx_cb, | ||
void * | arg | ||
) |
Set serial half-duplex callbacks.
The relavent callback is made just prior to transmitting or receiving a packet.
enable_tx_cb | Enable transmit callback. |
enable_rx_cb | Enable receive callback. |
arg | Tx/Rx callback parameter. |
Definition at line 99 of file dynamixel.cxx.
References m_fnEnableRx, m_fnEnableTx, and m_pTxRxArg.
Referenced by DynaCommSerial::SetHalfDuplexCtl().
void dxl::setTxPacketId | ( | int | id | ) |
Set transmit packet servo id.
id | Servo id or broadcast id. |
Definition at line 115 of file dynamixel.cxx.
References DXL_ID, and m_bufInstructionPacket.
Referenced by DynaCommSerial::Reset(), and DynaCommSerial::SyncWrite().
void dxl::setTxPacketInstruction | ( | int | instruction | ) |
Set transmit packet instruction.
instruction | Request instruction id. |
Definition at line 120 of file dynamixel.cxx.
References DXL_INSTRUCTION, and m_bufInstructionPacket.
Referenced by DynaCommSerial::Reset(), and DynaCommSerial::SyncWrite().
void dxl::setTxPacketLength | ( | int | length | ) |
Set transmit packet length.
length | Length in bytes. |
Definition at line 130 of file dynamixel.cxx.
References DXL_LENGTH, and m_bufInstructionPacket.
Referenced by DynaCommSerial::Reset(), and DynaCommSerial::SyncWrite().
void dxl::setTxPacketParameter | ( | int | index, |
int | value | ||
) |
Set transmit packet parameter value.
index | Zero offset parameter index. |
value | Parameter byte value. |
Definition at line 125 of file dynamixel.cxx.
References DXL_PARAMETER, and m_bufInstructionPacket.
Referenced by DynaCommSerial::SyncWrite().
void dxl::txPacket | ( | ) |
Transmit a previously packed instruction packet.
< length field value in instruction packate
< length of packet to transmit
< actual length transmitted
< working index
< packet checksum
Definition at line 182 of file dynamixel.cxx.
References libdxl::dxlhal::clear(), DXL_COMM_RXCORRUPT, DXL_COMM_RXTIMEOUT, DXL_COMM_TXERROR, DXL_COMM_TXFAIL, DXL_COMM_TXSUCCESS, DXL_INST_ACTION, DXL_INST_PING, DXL_INST_READ, DXL_INST_REG_WRITE, DXL_INST_RESET, DXL_INST_SYNC_WRITE, DXL_INST_WRITE, DXL_INSTRUCTION, DXL_LENGTH, DXL_MAXNUM_TXPARAM, DXL_PARAMETER, m_bBusUsing, m_bufInstructionPacket, m_fnEnableRx, m_fnEnableTx, m_nCommStatus, m_pTxRxArg, libdxl::dxlhal::setTimeout(), and libdxl::dxlhal::tx().
Referenced by txrxPacket().
void dxl::txrxPacket | ( | ) |
Transmit instruction packet and receive status response packet.
Use dxl_get_result() to check for success or failure.
Use the tranmit packing functions to build the instruction packet and the receive unpacking function to get any read data.
Definition at line 431 of file dynamixel.cxx.
References DXL_COMM_RXWAITING, DXL_COMM_TXSUCCESS, m_nCommStatus, rxPacket(), and txPacket().
Referenced by ping(), readByte(), readWord(), DynaCommSerial::Reset(), DynaCommSerial::SyncWrite(), writeByte(), and writeWord().
void dxl::writeByte | ( | int | id, |
int | address, | ||
int | value | ||
) |
Write byte to servo's control table.
Use dxl_get_result() to check for success or failure.
id | Servo id. |
address | Control table address. |
value | 8-bit value to write. |
Definition at line 477 of file dynamixel.cxx.
References DXL_ID, DXL_INST_WRITE, DXL_INSTRUCTION, DXL_LENGTH, DXL_PARAMETER, m_bBusUsing, m_bufInstructionPacket, and txrxPacket().
Referenced by DynaCommSerial::Write8().
void dxl::writeWord | ( | int | id, |
int | address, | ||
int | value | ||
) |
Write word to servo's control table.
Use dxl_get_result() to check for success or failure.
id | Servo id. |
address | Control table address. |
value | 16-bit value to write. |
Definition at line 505 of file dynamixel.cxx.
References DXL_ID, DXL_INST_WRITE, DXL_INSTRUCTION, DXL_LENGTH, DXL_PARAMETER, getHighByte(), getLowByte(), m_bBusUsing, m_bufInstructionPacket, and txrxPacket().
Referenced by DynaCommSerial::Write16().