52 #include "rnr/rnrconfig.h" 53 #include "rnr/units.h" 71 #define MOUSEBOT_ECODE_GEN 1 72 #define MOUSEBOT_ECODE_LIBKB 2
73 #define MOUSEBOT_ECODE_LIBKB_RECV 3
74 #define MOUSEBOT_ECODE_LIBKB_SEND 4
75 #define MOUSEBOT_ECODE_BAD_UNITS 5
76 #define MOUSEBOT_ECODE_BAD_VAL 6
77 #define MOUSEBOT_ECODE_SYS 7
78 #define MOUSEBOT_ECODE_INTERNAL 8
80 #define MOUSEBOT_ECODE_BADEC 9 82 #define MOUSEBOT_ECODE_NUMOF 10 87 #define MOUSEBOT_INT_MAX 2147483647 88 #define MOUSEBOT_INT_MIN (-MOUSEBOT_INT_MAX-1)
96 #define MOUSEBOT_BASE_MAX_RADIUS_MM 65 97 #define MOUSEBOT_BASE_MAX_HEIGHT_MM 70
98 #define MOUSEBOT_BASE_WHEEL_BASE_MM 90
99 #define MOUSEBOT_BASE_WHEEL_DIAM_MM 41
108 #define MOUSEBOT_MOTOR_LEFT 0 109 #define MOUSEBOT_MOTOR_RIGHT 1
110 #define MOUSEBOT_MOTOR_NUMOF 2
111 #define MOUSEBOT_SPEED_MIN_ABS 2000
113 #define MOUSEBOT_SPEED_MAX_ABS 65535 115 #define MOUSEBOT_POS_PROF_MIN_SPEED MOUSEBOT_SPEED_MIN_ABS 117 #define MOUSEBOT_POS_PROF_MAX_SPEED 32767 119 #define MOUSEBOT_POS_PROF_MIN_ACCEL 10 121 #define MOUSEBOT_POS_PROF_MAX_ACCEL 255 123 #define MOUSEBOT_OD_MIN (MOUSEBOT_INT_MIN+1) 125 #define MOUSEBOT_OD_MAX (MOUSEBOT_INT_MAX-1) 127 #define MOUSEBOT_OD_UM_PER_STEP 47 128 #define MOUSEBOT_OD_NUMOF 2
138 #define MOUSEBOT_IR_POS_BACK_LEFT 0 139 #define MOUSEBOT_IR_POS_LEFT_90 1
140 #define MOUSEBOT_IR_POS_LEFT_45 2
141 #define MOUSEBOT_IR_POS_FRONT_LEFT 3
142 #define MOUSEBOT_IR_POS_FRONT_RIGHT 4
143 #define MOUSEBOT_IR_POS_RIGHT_45 5
144 #define MOUSEBOT_IR_POS_RIGHT_90 6
145 #define MOUSEBOT_IR_POS_BACK_RIGHT 7
146 #define MOUSEBOT_IR_POS_BACK 8
147 #define MOUSEBOT_IR_POS_GROUND_RIGHT 9
148 #define MOUSEBOT_IR_POS_GROUND_LEFT 10
149 #define MOUSEBOT_IR_NUMOF 11
150 #define MOUSEBOT_IR_VAL_MIN 0
151 #define MOUSEBOT_IR_VAL_MAX 4095
152 #define MOUSEBOT_IR_GRP_FRONT 0
153 #define MOUSEBOT_IR_GRP_RIGHT 1
154 #define MOUSEBOT_IR_GRP_BACK 2
155 #define MOUSEBOT_IR_GRP_LEFT 3
156 #define MOUSEBOT_IR_GRP_GROUND 4
165 #define MOUSEBOT_USS_POS_LEFT_90 0 166 #define MOUSEBOT_USS_POS_LEFT_45 1
167 #define MOUSEBOT_USS_POS_FRONT 2
168 #define MOUSEBOT_USS_POS_RIGHT_45 3
169 #define MOUSEBOT_USS_POS_RIGHT_90 4
170 #define MOUSEBOT_USS_NUMOF 5
171 #define MOUSEBOT_USS_ECHO_MAX_MIN 1
172 #define MOUSEBOT_USS_ECHO_MAX_MAX 5
173 #define MOUSEBOT_USS_ECHO_MAX_DFT 3
174 #define MOUSEBOT_USS_DIST_MIN 20
175 #define MOUSEBOT_USS_DIST_MAX 400
176 #define MOUSEBOT_USS_AMPL_MAX (MOUSEBOT_INT_MAX-1)
177 #define MOUSEBOT_USS_TIME_MAX (MOUSEBOT_INT_MAX-1)
178 #define MOUSEBOT_USS_NOISE_MAX (MOUSEBOT_INT_MAX-1)
179 #define MOUSEBOT_USS_LEFT_90_EN_DFT false
181 #define MOUSEBOT_USS_LEFT_45_EN_DFT false 183 #define MOUSEBOT_USS_FRONT_EN_DFT true 185 #define MOUSEBOT_USS_RIGHT_45_EN_DFT false 187 #define MOUSEBOT_USS_RIGHT_90_EN_DFT false 189 #define MOUSEBOT_USS_HAS_BODY_DFT true 193 #define MOUSEBOT_FWOP_INDEX_USS_MASK 0 194 #define MOUSEBOT_FWOP_INDEX_USS_MAX_ECHOES 1
195 #define MOUSEBOT_FWOP_INDEX_NOT_USED_2 2
196 #define MOUSEBOT_FWOP_INDEX_NOT_USED_3 3
197 #define MOUSEBOT_FWOP_INDEX_IR_MASK 4
198 #define MOUSEBOT_FWOP_INDEX_IR_GAIN_BRAIT 5
199 #define MOUSEBOT_FWOP_INDEX_UPPER_BODY 6
202 #define MOUSEBOT_BUF_MAX 100 210 #define MOUSEBOT_UNITS_SPEED_DFT units_permil 211 #define MOUSEBOT_SPEED_MAX_FWD_DFT 1000
213 #define MOUSEBOT_SPEED_MAX_BWD_DFT -1000 216 #define MOUSEBOT_UNITS_OD_DFT units_mm 217 #define MOUSEBOT_OD_MAX_FWD_DFT 1000000
219 #define MOUSEBOT_OD_MAX_BWD_DFT -1000000 222 #define MOUSEBOT_UNITS_IR_DFT units_raw 223 #define MOUSEBOT_UNITS_USS_DFT units_mm
337 return u==units_raw?
"": units_shortname(u);
340 extern const char *mousebotStrError(
int ecode);
342 extern int k3LibKbToMouseBotEcode(
int libkb_ecode);
344 extern void mousebotPrintBuf(FILE *fp,
345 const char *sPreface,
353 extern void mousebotLogBuf(
const char *sPreface,
366 extern void mousebotExit(
MouseBot_T *pMouseBot);
378 extern units_t mousebotAttrSetUnitsSpeed(
MouseBot_T *pMouseBot, units_t unitsSpeed);
390 extern units_t mousebotAttrSetUnitsOdometer(
MouseBot_T *pMouseBot, units_t unitsOdometer);
402 extern units_t mousebotAttrSetUnitsIr(
MouseBot_T *pMouseBot, units_t unitsIr);
414 extern units_t mousebotAttrSetUnitsUss(
MouseBot_T *pMouseBot, units_t unitsUss);
416 extern int mousebotGetFwVer(
MouseBot_T *pMouseBot, uint_t *puVersion, uint_t *puRevision);
423 extern int mousebotMotorInit(
MouseBot_T *pMouseBot, uint_t uWhich);
425 extern int mousebotMotorGetCfg(
MouseBot_T *pMouseBot,
429 extern int mousebotMotorSetCfg(
MouseBot_T *pMouseBot,
433 extern int mousebotMotorGetSpeeds(
MouseBot_T *pMouseBot,
437 extern int mousebotMotorSetSpeeds(
MouseBot_T *pMouseBot,
int nSpeedLeft,
int nSpeedRight);
448 return mousebotMotorSetSpeeds(pMouseBot, 0, 0);
451 extern int mousebotMotorMoveTo(
MouseBot_T *pMouseBot,
456 extern int mousebotMotorGetOdometry(
MouseBot_T *pMouseBot,
460 extern int mousebotMotorResetOdometry(
MouseBot_T *pMouseBot);
467 extern int mousebotIrInit(
MouseBot_T *pMouseBot);
469 extern int mousebotIrGetAmbient(
MouseBot_T *pMouseBot, uint_t bufIr[]);
471 extern int mousebotIrGetProximity(
MouseBot_T *pMouseBot, uint_t bufIr[]);
473 extern int mousebotIrGetProximityGroup(
MouseBot_T *pMouseBot,
int iGroup);
480 extern int mousebotUssInit(
MouseBot_T *pMouseBot);
507 #endif // _MOUSEBOT_H MouseBotAttrUnits_T m_attrUnits
working units
uint_t m_uAmplitude
echo signal strength (unknown units)
int m_nMaxBwdSpeed
maximum backward current/raw speed limit ≤ 0
#define MOUSEBOT_MOTOR_NUMOF
total number of motors
int m_nMaxFwdSpeed
maximum forward current/raw speed limit ≥ 0
INLINE_IN_H int mousebotMotorStop(MouseBot_T *pMouseBot)
Stop the Khepera III from moving.
int m_dogSpeedLeft
shadowed left motor speed
INLINE_IN_H units_t mousebotAttrGetUnitsSpeed(MouseBot_T *pMouseBot)
Get the current motor speed units.
#define MOUSEBOT_IR_NUMOF
total number of ir sensors
knet_dev_p m_pDevDSPic
dsPIC device handle
INLINE_IN_H units_t mousebotAttrGetUnitsOdometer(MouseBot_T *pMouseBot)
Get the current motor odometer units.
int m_nMaxOdometer
maximum current/raw odometer position limit ≥ 0
uint_t m_uNoise
noise (unknown units)
units_t m_unitsOdometer
odometry distance units
bool_t m_bHasUpperBody
upper plastic body is [not] installed
units_t m_unitsSpeed
motor speed units
#define MOUSEBOT_USS_ECHO_MAX_MAX
maximum maximum echoes/measure
INLINE_IN_H const char * mousebotUnitsSym(units_t u)
Convert units to short symbol name.
int m_dogSpeedRight
shadowed right motor speed
MouseBotUssCfg_T m_cfgUss
USS configuration.
int m_dogSpeedRobot
shadowed robot center speed
int m_nMinOdometer
minimum current/raw odometer position limit ≤ 0
units_t m_unitsIr
IR distance units.
uint_t m_uEchoCnt
number of returned echoes
units_t m_unitsUss
USS distance units.
uint_t m_uMaxEchoes
maximum number of echoes/measure
uint_t m_uDistance
echo distance in current units
INLINE_IN_H units_t mousebotAttrGetUnitsUss(MouseBot_T *pMouseBot)
Get the current UltraSonic Sensor units.
struct knet_dev_s * knet_dev_p
pointer to knet_dev_t
INLINE_IN_H int mousebotUssGetCfg(MouseBot_T *pMouseBot, MouseBotUssCfg_T *pUssCfg)
Get the current ultrasonic sensors configuration.
uint_t m_uMaxTimeTicks
max measurement time (unknown units)
#define MOUSEBOT_USS_NUMOF
total number of uss sensors
#define MOUSEBOT_OK
not an error, success
INLINE_IN_H units_t mousebotAttrGetUnitsIr(MouseBot_T *pMouseBot)
Get the current InfraRed sensor units.