55 #include "rnr/rnrconfig.h" 60 #include "botsense/BotSense.h" 83 "Transmit packet success",
84 "Receive packet success",
85 "Transmit packet failure",
86 "Receive packet failure",
88 "Waiting to receive packet",
89 "Timed out waiting to receive packet",
90 "Received packet corrupted",
91 "Unknown communication status" 99 "Input voltage out of range",
100 "Angle position out of range",
102 "Command out of range",
104 "Load out of torque range",
156 shm_mutex_init(ShmKey, &m_mutexComm);
162 m_nBaudRate = nBaudRate;
166 shm_mutex_init(ShmKey, &m_mutexComm);
171 if( m_sDevUri != NULL )
176 shm_mutex_destroy(&m_mutexComm);
182 const char *sHostName;
209 else if( (pUri = UriParseNew(sUri)) == NULL )
217 else if( pUri->m_sPath == NULL )
220 "URI \"%s\" does not specify device path.", sUri);
226 else if( pUri->m_sScheme == NULL )
234 else if( !strcasecmp(pUri->m_sScheme, BSPROXY_URI_SCHEME) )
236 sHostName = pUri->m_sHostName;
237 nPortNum = pUri->m_nPortNum;
239 if( sHostName == NULL )
241 sHostName = BSPROXY_URI_HOSTNAME_DFT;
244 if( nPortNum == URI_PORT_NONE )
246 nPortNum = BSPROXY_LISTEN_PORT_DFT;
250 sHostName, nPortNum);
256 else if( !strcasecmp(pUri->m_sScheme, URI_SCHEME_FILE) )
258 if( (pUri->m_sHostName == NULL) ||
259 !strcasecmp(pUri->m_sHostName, URI_LOCAL_HOST) )
266 "URI \"%s\" remote file device access not supported - " 267 "use botsense proxy services.", sUri);
287 if( (pDynaComm != NULL) && !pDynaComm->
IsOpen() )
290 "Failed to open the device \"%s\" at %d baud.", sUri, nBaudRate);
302 uBusStatus = -uBusStatus;
313 const string &strSep)
326 if( !strAlarms.empty() )
341 const string &strSep)
354 if( !strAlarms.empty() )
398 if( (nIndex >= 0) && (nIndex < arraysize(
DynaBaudMap)) )
410 if( (nIndex >= 0) && (nIndex < arraysize(
DynaBaudMap)) )
426 va_start(ap, uCount);
431 tuples[i].
m_uVal = va_arg(ap, uint_t);
436 return SyncWrite(uAddr, uValSize, tuples, (uint_t)i);
RoadNarrows Dynamixel Bus Communications Abstract Base Class Interface.
static int BaudNumToRate(int nBaudRate)
Map baud number to Dynamixel baud rate.
char * newstr(const char *s)
Allocate new duplicated string.
Dynamixel Serial Bus Communications Class.
static const char * DynaServoAlarmStrTbl[]
Dynamixel Servo Alarms String Table.
#define DYNA_BAUDNUM_9600
9,600 bps at -0.160% tolerance
virtual int vSyncWrite(uint_t uAddr, uint_t uValSize, uint_t uCount,...)
Synchronous write 8/16-bit values to a list of Dynamixel servos.
static int BaudNumAt(int nIndex)
Get the baud number associated with the given index.
virtual ~DynaComm()
Destructor.
static int BaudRateAt(int nIndex)
Get the baud rate associated with the given index.
virtual bool IsOpen()
Test if Dynamixel Bus is open.
#define DYNA_BAUDNUM_1000000
1,000,000 bps at 0.0% tolerance
#define DYNA_BAUDNUM_500000
500,000 bps at 0.0% tolerance
#define DYNA_ALARM_NONE
no alarms
#define DYNA_BAUDNUM_200000
200,000 bps at 0.0% tolerance
static const key_t ShmKey
shared memory key
static const char * GetBusStatusString(uint_t uBusStatus)
Get the string describing the Dynamixel servo communication status.
#define DYNA_BAUDNUM_EXT_3000000
3,000,000 bps at 0.0% tolerance
static std::string GetAlarmsShortString(const uint_t uAlarms, const std::string &strSep=",")
Get a formatted servo alarms short string associated with the alarms.
#define DYNA_ID_NUMOF
number of unique servo id's
#define DYNA_ECODE_BAD_DEV
no or bad serial device
#define DYNA_LOG_ERROR(ecode, efmt,...)
Log Error.
static const char * DynaBusStatusStrTbl[]
Dynamixel Bus Communication Status String Table.
static DynaComm * New(const char *sUri, int nBaudRate)
Archetype constructor to create a new Dynamixel bus communication derived instance.
static const int DynaBaudMap[DYNA_BAUDNUM_NUMOF][2]
Baud rate to baud number enumeration map.
The libDynamixel internal declarations.
#define DYNA_BAUDNUM_19200
19,200 bps at -0.160% tolerance
#define DYNA_BAUDNUM_57600
57,600 bps at 0.794 % tolerance
#define DYNA_BAUDNUM_EXT_2500000
2,500,000 bps at 0.0% tolerance
RoadNarrows Dynamixel Bus Communication over Serial Interface Class Interface.
#define DYNA_BAUDNUM_115200
115,200 bps at -2.124% tolerance
static std::string GetAlarmsString(const uint_t uAlarms, const std::string &strSep="; ")
Get a formatted servo alarms string associated with the alarms.
BotSense IP Proxied Dynamixel Bus Communications Class.
RoadNarrows Dynamixel Top-Level Package Header File.
#define DYNA_BAUDNUM_NUMOF
number of supported bit rates
RoadNarrows Botsene IP Proxied Dynamixel Bus Communication Class Interface.
#define DYNA_ECODE_BAD_VAL
bad value
static const char * DynaServoAlarmShortStrTbl[]
Dynamixel Servo Alarms Short String Table.
RoadNarrows Dynamixel Library Error and Logging Routines.
#define DYNA_BAUDNUM_250000
250,000 bps at 0.0% tolerance
static int BaudRateToNum(int nBaudRate)
Map baud rate to Dynamixel baud number.
#define DYNA_BAUDNUM_400000
500,000 bps at 0.0% tolerance
Dynamixel Bus Communications Abstract Base Class.
#define DYNA_BAUDNUM_EXT_2250000
2,250,000 bps at 0.0% tolerance