47 #include <sys/select.h> 55 #include "rnr/rnrconfig.h" 59 #include "dynamixel/Dynamixel.h" 60 #include "dynamixel/libDynamixel.h" 65 #define APP_EC_USAGE 2 88 "Spin dynamixel servo continuously.",
91 "The %P test application spins the given servo continuously at the given " 113 "Serial device interface",
126 "Serial interface baudrate",
139 "Speed of servo. <0 = CCW, 0 = stop, >0 = CW.",
149 DynaHandle_T *DynaHandle;
151 bool_t peekc(uint_t msec)
153 int fno = fileno(stdin);
155 uint_t usec = msec * 1000;
156 struct timeval timeout;
163 timeout.tv_sec = (time_t)(usec / 1000000);
164 timeout.tv_usec = (time_t)(usec % 1000000);
166 if( (rc = select(fno+1, &fdset, NULL, NULL, &timeout)) > 0 )
171 return rc>0?
true:
false;
186 Argv0 = basename(argv[0]);
194 OptsInvalid(
Argv0,
"no servo id specified.");
212 static int AppDynaInit()
225 if( DynaHandle == NULL )
227 LOGERROR(
"failed to create interface.");
236 LOGERROR(
"failed to ping servo %d.",
ArgServoId);
276 dynaWrite16(DynaHandle,
ArgServoId, DYNA_ADDR_LIM_TORQUE_LSB, torque,
282 static void AppDynaRun()
293 static void AppDynaDeinit()
301 static void AppBanner()
304 printf(
"Spinning servo %d %s at raw speed of %d.\n",
306 (ServoDir==
DYNA_DIR_CW?
"clockwise":
"counter-clockwise"),
308 printf(
"Press <CR> to stop.\n");
321 int main(
int argc,
char *argv[])
327 if( (rc = AppDynaInit()) == APP_EC_OK )
334 return rc >= 0? APP_EC_OK: -rc;
#define DYNA_TORQUE_MAX_RAW
maximum raw torque
#define DYNA_OK
not an error, success
#define DYNA_ADDR_GOAL_SPEED_LSB
goal speed lsb (RW)
#define DYNA_ADDR_LIM_CW_LSB
clockwise angle limit lsb (RW)
int main(int argc, char *argv[])
Main.
#define DYNA_CCW_POS_CONT_MODE
continuous mode (with cw limit)
static int OptsSpeed
servo speed
#define DYNA_DIR_CW
clockwise direction
static void MainInitArgs(int argc, char *argv[])
Main argument initialization.
static OptsPgmInfo_T AppPgmInfo
Program information.
static char * Argv0
the command
static char * OptsSerDev
the serial device
#define DYNA_DIR_CCW
counterclockwise direction
static const PkgInfo_T PkgInfo
#define DYNA_GOAL_SPEED_MAG_MASK
speed magnitude field mask
#define DYNA_GOAL_SPEED_DIR_CW
clockwise direction
#define DYNA_GOAL_SPEED_DIR_CCW
counterclockwise direction
Package version information.
#define DYNA_ADDR_LIM_CCW_LSB
counterclockwise angle limit lsb (RW)
static int ArgServoId
servo id
static OptsInfo_T AppOptsInfo[]
Command line options information.
static int OptsBaudRate
serial baudrate
#define DYNA_CW_POS_CONT_MODE
continuous mode (with ccw limit)