Dynamixel  2.9.5
RoadNarrows Robotics Dynamixel Package
DynaShellCmdCfgWriteServoMode Class Reference

Write EEPROM configuration to put servos into the given modes. More...

Inheritance diagram for DynaShellCmdCfgWriteServoMode:
DynaShellCmdChainOut DynaShellCmd

Public Member Functions

 DynaShellCmdCfgWriteServoMode ()
 Default constructor.
 
virtual ~DynaShellCmdCfgWriteServoMode ()
 Default destructor.
 
- Public Member Functions inherited from DynaShellCmdChainOut
 DynaShellCmdChainOut (bool bMasterOpOnly=false)
 Default constructor.
 
virtual ~DynaShellCmdChainOut ()
 Default destructor.
 
virtual void Exec (DynaShell &shell, int argc, char *argv[])
 Execute 'write-like' command on servos. More...
 
virtual char * TabCompletion (DynaShell &shell, const char *sText, size_t uTextLen, int nState, const char *sContext)
 Command tab completion generator. More...
 
- Public Member Functions inherited from DynaShellCmd
 DynaShellCmd (int nArgCntMin=0, int nArgCntMax=0)
 Default constructor.
 
virtual ~DynaShellCmd ()
 Default destructor.
 
const char * GetCmdName ()
 Get dynamixel shell command name. More...
 
const char * GetCmdHelpBrief ()
 Get shell command name brief description. More...
 
virtual void PrintHelp (int indent=0, int width=80)
 Print command help with the description aligned at the given indentation. More...
 
int GetPublishedLevel () const
 
const char * GetPublishedName () const
 
int SetPublishedInfo (int nLevel, const char *sParent=NULL)
 
virtual bool ChkArgCnt (DynaShell &shell, int argc)
 Check that the argument count is within the class (min,max). More...
 
bool ChkArgCnt0 (DynaShell &shell, int argc)
 Check that the argument count is zero. More...
 
bool ChkArgCntEQ (DynaShell &shell, int argc, int eq)
 Check that the argument count is equal to the required. More...
 
bool ChkArgCntGE (DynaShell &shell, int argc, int min)
 Check argument count against minimum required. More...
 
bool ChkArgCntLE (DynaShell &shell, int argc, int max)
 Check argument count against maximum allowed. More...
 
bool ChkComm (DynaShell &shell)
 Check that Dynamixel communication exists and is open. More...
 
bool ChkChain (DynaShell &shell)
 Check that the servo chain exists. More...
 
bool ChkChainNotEmpty (DynaShell &shell)
 Check that the servo chain exists and is not empty. More...
 
bool ChkChainHasServo (DynaShell &shell, int nServoId)
 Check that the given servo is present in the chain. More...
 
bool ChkChainIsMasterServo (DynaShell &shell, int nServoId)
 Check that the given servo is a master. More...
 
bool ToInt (DynaShell &shell, const char *sArg, int *pVal)
 Convert command argument to integer. More...
 
bool ToUInt (DynaShell &shell, const char *sArg, uint_t *pVal)
 Convert command argument to unsigned integer. More...
 
bool ToDouble (DynaShell &shell, const char *sArg, double *pVal)
 Convert command argument to double. More...
 
bool ToBool (DynaShell &shell, const char *sArg, bool *pVal)
 Convert command argument to boolean. More...
 

Protected Member Functions

virtual void doExec (DynaShell &shell, ExecTup_T tup[], uint_t uCount)
 Execute operation. More...
 
virtual bool ArgToInt (DynaShell &shell, const char *sArg, int *pVal)
 Convert command argument into servo mode. More...
 
- Protected Member Functions inherited from DynaShellCmdChainOut
virtual bool ArgToUInt (DynaShell &shell, const char *sArg, uint_t *pVal)
 Convert command argument into unsigned integer. More...
 
- Protected Member Functions inherited from DynaShellCmd
virtual void PrintSynopses (int indent, int width)
 Print synsopses. More...
 
virtual void PrintBlock (int col, int indent, int width, const char *sText)
 Print a block of indented text of width. More...
 
virtual void PrintDelim (int width, const char cDelim)
 
char * eow (const char *s)
 Find end of word. More...
 

Additional Inherited Members

- Protected Attributes inherited from DynaShellCmdChainOut
bool m_bMasterOpOnly
 is [not] a master-only supported operation
 
int m_nTabIter
 tab completion: servo id iterator
 
int m_nTabServoId
 tab completion: current servo id
 
bool m_bTabIncChain
 tab completion: [do not] include chain keyword
 
- Protected Attributes inherited from DynaShellCmd
const char * m_sCmdName
 command name
 
const char * m_sCmdHelpBrief
 command help brief
 
const char * m_sCmdHelpArgs
 command help arguments
 
const char * m_sCmdHelpDesc
 command help description
 
const int m_nArgCntMin
 minimum argument count
 
const int m_nArgCntMax
 maximum argument count (0 if not max)
 
int m_nPubLevel
 command's published level (depth)
 
char * m_sPubName
 command's published name
 

Detailed Description

Write EEPROM configuration to put servos into the given modes.

Syntax:
* arg_to_uint ::= mode
* mode ::= 'c' | 'cont' | 'continuous' | 's' | 'servo'
* 

Definition at line 670 of file dynashell_cmd_servo.cxx.

Member Function Documentation

virtual bool DynaShellCmdCfgWriteServoMode::ArgToInt ( DynaShell shell,
const char *  sArg,
int *  pVal 
)
inlineprotectedvirtual

Convert command argument into servo mode.

Parameters
shellDynamixel shell.
sArgString argument to convert.
[out]pValConverted argument.
Returns
Returns true on success, false otherwise.

Reimplemented from DynaShellCmdChainOut.

Definition at line 744 of file dynashell_cmd_servo.cxx.

References DYNA_MODE_CONTINUOUS, DYNA_MODE_SERVO, and DynaShell::Error().

745  {
746  size_t n = strlen(sArg);
747 
748  if( !strncmp("continuous", sArg, n) )
749  {
750  *pVal = DYNA_MODE_CONTINUOUS;
751  return true;
752  }
753  else if( !strncmp("servo", sArg, n) )
754  {
755  *pVal = DYNA_MODE_SERVO;
756  return true;
757  }
758  else
759  {
760  shell.Error("Argument value \"%s\": Not a servo mode.", sArg);
761  return false;
762  }
763  }
#define DYNA_MODE_SERVO
servo mode with limited rotation
Definition: Dynamixel.h:170
#define DYNA_MODE_CONTINUOUS
continuous mode with/without position
Definition: Dynamixel.h:171
void Error(int rc, const char *sFmt,...)
Raise error on dynamixel error code.
Definition: dynashell.cxx:808
virtual void DynaShellCmdCfgWriteServoMode::doExec ( DynaShell shell,
ExecTup_T  tup[],
uint_t  uCount 
)
inlineprotectedvirtual

Execute operation.

Parameters
shellDynamixel shell.
tupArray of (servo id, mode) 2-tuples.
uCountNumber of tuples.

Implements DynaShellCmdChainOut.

Definition at line 703 of file dynashell_cmd_servo.cxx.

References DYNA_MODE_CONTINUOUS, DYNA_MODE_SERVO, DYNA_OK, DynaShell::Error(), DynaChain::GetServo(), DynaServo::GetServoId(), DynaServo::GetSpecification(), ExecTup_T::m_nVal, DynaShell::m_pDynaChain, DynaServoSpec_T::m_uRawPosMax, and DynaServoSpec_T::m_uRawPosMin.

704  {
705  DynaServo *pServo;
706  DynaServoSpec_T spec;
707  uint_t i;
708  int rc;
709 
710  for(i=0, rc=DYNA_OK; i<uCount && rc==DYNA_OK; ++i)
711  {
712  pServo = shell.m_pDynaChain->GetServo(tup[i].m_nServoId);
713 
714  switch( tup[i].m_nVal )
715  {
717  rc = pServo->CfgWriteServoModeContinuous();
718  break;
719 
720  case DYNA_MODE_SERVO:
721  default:
722  spec = pServo->GetSpecification();
723  rc = pServo->CfgWriteServoMode(spec.m_uRawPosMin, spec.m_uRawPosMax);
724  break;
725  }
726  }
727 
728  if( rc != DYNA_OK )
729  {
730  shell.Error(rc, "Servo %d: Failed to set mode to %d.",
731  pServo->GetServoId(), tup[i].m_nVal);
732  }
733  }
Dynamixel Servo Specification Structure.
Definition: DynaTypes.h:81
#define DYNA_OK
not an error, success
Definition: Dynamixel.h:78
#define DYNA_MODE_SERVO
servo mode with limited rotation
Definition: Dynamixel.h:170
uint_t m_uRawPosMin
minimum raw position value (servo mode)
Definition: DynaTypes.h:101
Dynamixel Servo Abstract Base Class.
Definition: DynaServo.h:78
virtual DynaServo * GetServo(int nServoId)
Definition: DynaChain.h:129
#define DYNA_MODE_CONTINUOUS
continuous mode with/without position
Definition: Dynamixel.h:171
int m_nVal
value
virtual const DynaServoSpec_T & GetSpecification() const
Get servo specification.
Definition: DynaServo.h:185
virtual uint_t GetServoId() const
Get servo id.
Definition: DynaServo.h:155
uint_t m_uRawPosMax
maximum raw position value (servo mode)
Definition: DynaTypes.h:102
DynaChain * m_pDynaChain
dynamixel chain
Definition: dynashell.h:360
void Error(int rc, const char *sFmt,...)
Raise error on dynamixel error code.
Definition: dynashell.cxx:808

The documentation for this class was generated from the following file: