Dynamixel  2.9.5
RoadNarrows Robotics Dynamixel Package
dynashell_cmd_train.cxx File Reference

Dynamixel shell record and playback functions. More...

#include <sys/select.h>
#include <limits.h>
#include <time.h>
#include <ctype.h>
#include <cstring>
#include <iostream>
#include <fstream>
#include <map>
#include <vector>
#include <math.h>
#include <gsl/gsl_bspline.h>
#include <gsl/gsl_multifit.h>
#include <gsl/gsl_rng.h>
#include <gsl/gsl_randist.h>
#include <gsl/gsl_statistics.h>
#include "rnr/rnrconfig.h"
#include "rnr/log.h"
#include "Dynamixel/Dynamixel.h"
#include "Dynamixel/DynaComm.h"
#include "Dynamixel/DynaPidSpeed.h"
#include "Dynamixel/DynaServo.h"
#include "Dynamixel/DynaChain.h"
#include "Dynamixel/DynaOlio.h"
#include "dynashell.h"
#include "dynashell_cmd.h"
#include "dynashell_recording.h"
#include "dynashell_util.h"

Go to the source code of this file.

Classes

class  DynaShellCmdGetPid
 Get the PID values for the given servos. More...
 
class  DynaShellCmdSetPid
 Get the PID values for the given servos. More...
 
class  DynaShellCmdLoadRecording
 Load recording from file. More...
 
class  DynaShellCmdSaveRecording
 Save recording to file. More...
 
class  DynaShellCmdTrain
 Record dynamixel chain movements. More...
 
class  DynaShellCmdPlay
 Record dynamixel chain movements. More...
 

Functions

static bool_t waitkey (int nMSec)
 Block, waiting for either timeout or user keyboard press. More...
 
static bool_t waitkey (double fSec)
 Block, waiting for either timeout or user keyboard press. More...
 
void PublishShellTrainCommands (DynaShell &shell)
 Publish shell servo commands to shell. More...
 

Detailed Description

Dynamixel shell record and playback functions.

LastChangedDate
2015-01-12 10:56:06 -0700 (Mon, 12 Jan 2015)
Rev
3845
Author
Robin Knight (robin.nosp@m..kni.nosp@m.ght@r.nosp@m.oadn.nosp@m.arrow.nosp@m.s.co.nosp@m.m)

Definition in file dynashell_cmd_train.cxx.

Function Documentation

void PublishShellTrainCommands ( DynaShell shell)

Publish shell servo commands to shell.

shell Dynamixel shell.

Definition at line 2260 of file dynashell_cmd_train.cxx.

References DynaShell::PublishCommand().

Referenced by DynaShellCmdChainOut::ArgToUInt().

2261 {
2262  shell.PublishCommand("get", new DynaShellCmdGetPid());
2263  shell.PublishCommand("set", new DynaShellCmdSetPid());
2264  shell.PublishCommand("load", new DynaShellCmdLoadRecording());
2265  shell.PublishCommand("save", new DynaShellCmdSaveRecording());
2266  shell.PublishCommand(NULL, new DynaShellCmdTrain());
2267  shell.PublishCommand(NULL, new DynaShellCmdPlay());
2268 }
Load recording from file.
Get the PID values for the given servos.
Save recording to file.
Record dynamixel chain movements.
Record dynamixel chain movements.
Get the PID values for the given servos.
void PublishCommand(const char *sParent, DynaShellCmd *pNewCmd)
Publish new command to shell.
Definition: dynashell.cxx:192
static bool_t waitkey ( int  nMSec)
static

Block, waiting for either timeout or user keyboard press.

No characters are read.

Parameters
nMSecWait period (ms)
Returns
Returns true if wait was interrupted by keyboard press. Else returns false on time out.

Definition at line 102 of file dynashell_cmd_train.cxx.

Referenced by DynaShellCmdPlay::Play(), and DynaShellCmdTrain::RecordTraining().

103 {
104  int fno = fileno(stdin);
105  fd_set fdset;
106  uint_t usec = (uint_t)nMSec * 1000;
107  struct timeval timeout;
108  int rc;
109 
110  FD_ZERO(&fdset);
111  FD_SET(fno, &fdset);
112 
113  // timeout (gets munged after each select())
114  timeout.tv_sec = (time_t)(usec / 1000000);
115  timeout.tv_usec = (time_t)(usec % 1000000);
116 
117  if( (rc = select(fno+1, &fdset, NULL, NULL, &timeout)) > 0 )
118  {
119  fflush(stdin);
120  }
121 
122  return rc>0? true: false;
123 }
static bool_t waitkey ( double  fSec)
static

Block, waiting for either timeout or user keyboard press.

No characters are read.

Parameters
fSecWait period (seconds)
Returns
Returns true if wait was interrupted by keyboard press. Else returns false on time out.

Definition at line 135 of file dynashell_cmd_train.cxx.

136 {
137  int fno = fileno(stdin);
138  fd_set fdset;
139  struct timeval timeout;
140  int rc;
141 
142  FD_ZERO(&fdset);
143  FD_SET(fno, &fdset);
144 
145  // timeout (gets munged after each select())
146  timeout.tv_sec = (time_t)((int)fSec);
147  timeout.tv_usec = (time_t)(((fSec - (double)timeout.tv_sec)) * 1000000.0);
148 
149  if( (rc = select(fno+1, &fdset, NULL, NULL, &timeout)) > 0 )
150  {
151  fflush(stdin);
152  }
153 
154  return rc>0? true: false;
155 }