28 #include "rnr/rnrconfig.h" 61 if( m_pDxlHal->
open(deviceName, baudrate) == 0 )
78 if( m_pDxlHal->
dxl_hal_open(deviceIndex, baudrate) == 0 )
100 dxl_hdctl_rx_cb_t enable_rx_cb,
112 return m_pDxlHal->
getFd();
159 word = (uint16_t)highbyte;
160 word = (uint16_t)(word << 8);
161 word = (uint16_t)(word + (uint16_t)lowbyte);
169 temp = (uint16_t)(word & 0xff);
177 temp = (uint16_t)(word & 0xff00);
178 temp = (uint16_t)(temp >> 8);
188 uint8_t checksum = 0;
223 for( i=0; i<(txInstLen+1); i++ )
235 txPktLen = txInstLen + 4;
245 if( txPktLen != txLen )
247 LOGERROR(
"Tx failed.");
276 uint8_t checksum = 0;
314 m_nRxGetLength += nRead;
323 if( m_nRxGetLength == 0 )
335 LOGERROR(
"Partial packet of %d bytes received.", m_nRxGetLength);
341 fprintf(stderr,
"\n");
352 for(i=0; i<(m_nRxGetLength-1); ++i)
358 else if( i == m_nRxGetLength-2 &&
369 for( j=0; j<(m_nRxGetLength-i); j++ )
388 LOGERROR(
"Tx/Rx ids mismatch.");
402 m_nRxGetLength += nRead;
417 checksum = (uint8_t)~checksum;
423 LOGERROR(
"Checksum mismatch.");
530 return 2000000.0f / (float)(baudnum + 1);
Modified dynamixel SDK interface.
void writeWord(int id, int address, int value)
Write word to servo's control table.
int getHighByte(int word)
Get high byte from word.
void * m_pTxRxArg
tx/rx argument passback
#define DXL_MAXNUM_TXPARAM
maximum number of tx parameters
#define DXL_INST_SYNC_WRITE
synchronous write servo(s) data
#define DXL_COMM_TXFAIL
transmit failure error
Dynamixel Hardware Abstraction Layer implementation interface.
int getLowByte(int word)
Get low byte from word.
#define DXL_BAUDNUM_EXT_2250000
2,250,000 bps at 0.0% tolerance
void setTxPacketParameter(int index, int value)
Set transmit packet parameter value.
dxl_hdctl_rx_cb_t m_fnEnableRx
enable rx callback
float dxl_baudnum_to_baudrate(int baudnum)
Convert Dynamixel baud number to baud rate.
int rx(unsigned char *pPacket, int numPacket)
Receive Dynamixel status packet.
#define DXL_INST_RESET
reset servo defaults
#define DXL_BAUDNUM_EXT_3000000
3,000,000 bps at 0.0% tolerance
int getResult()
Get last transmit/receive result.
int m_nRxPacketLength
expected received packet length
void close()
Close Dynamixel Bus serial interface.
#define DXL_COMM_RXSUCCESS
receive success
void txrxPacket()
Transmit instruction packet and receive status response packet.
#define DXL_INST_ACTION
action
int getRxPacketParameter(int index)
Get receive packet parameter value.
void setTxPacketId(int id)
Set transmit packet servo id.
#define DXL_ERRBIT
error bits field packet index
#define DXL_COMM_TXERROR
packed transmit packet format error
void writeByte(int id, int address, int value)
Write byte to servo's control table.
#define DXL_COMM_RXWAITING
waiting for complete receive packet
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.
dxl()
Default constructor.
#define DXL_PARAMETER
start of parameter fields packet index
#define DXL_COMM_RXTIMEOUT
receive timeout error
void setTxPacketInstruction(int instruction)
Set transmit packet instruction.
int dxl_hal_open(int deviceIndex, float baudrate)
Open Dynamixel Bus USB serial device by index.
void rxPacket()
Receive status packet.
int makeWord(int lowbyte, int highbyte)
Make 16-bit word.
#define DXL_INSTRUCTION
instruction field packet index
dxl_hdctl_tx_cb_t m_fnEnableTx
enable tx callback
void txPacket()
Transmit a previously packed instruction packet.
#define DXL_INST_REG_WRITE
register write
int open(const char *deviceName, int baudrate)
Open Dynamixel Bus serial interface.
unsigned int getRxPacketErrBits()
Get receive packet error bits field.
#define DXL_INST_READ
read servo control table data
uint8_t m_bufInstructionPacket[(150)+10]
instruction transmit packet buffer
int getRxPacketLength()
Get receive packet length field.
#define DXL_COMM_RXCORRUPT
receive corrupted packet
#define DXL_COMM_TXSUCCESS
transmit success
uint8_t m_bufStatusPacket[(60)+10]
status receive packet buffer
#define DXL_INST_PING
ping servo
void setTimeout(int NumRcvByte)
Set receive timeout.
bool hasTimedOut()
Test if receive timeout has expired.
int open(const char *deviceName, int baudrate)
Open Dynamixel Bus USB serial device by name.
bool m_bBusUsing
bus is [not] busy
int setBaudRate(int baudrate)
Set Dynamixel Bus serial device baud rate.
#define DXL_ID
servo id field packet index
int setBaudRate(int baudrate)
Set opened Dynamixel Bus serial interface baud rate.
void close()
Close the Dynamixel Bus serial interface.
int getFd()
Get the Dynamixel Bus serial device file descriptor.
void clear()
Discard any pending recieve data.
int m_nCommStatus
communication status
void ping(int id)
Ping servo.
bool getRxPacketError(unsigned int errbit)
Test if error bit is set on received packet.
#define DXL_INST_WRITE
write servo control table data
int tx(unsigned char *pPacket, int numPacket)
Transmit Dynamixel instruction packet.
int dxl_initialize(int deviceIndex, int baudnum)
Initialize Dynamixel Bus USB serial interface by index.
void setTxPacketLength(int length)
Set transmit packet length.
int readByte(int id, int address)
Read byte from servo's control table.
#define DXL_BAUDNUM_EXT_2500000
2,500,000 bps at 0.0% tolerance
int getFd()
Get the Dynamixel Bus serial device file descriptor.
#define DXL_BROADCAST_ID
broadcast "servo" id
int readWord(int id, int address)
Read word from servo's control table.
#define DXL_LENGTH
packet length field packet index
int m_nRxGetLength
current received packet length