Kuon  1.1.3
RoadNarrows Robotics Large Outdoor Mobile Robot Project
kuon::KuonSpec Class Reference

Robotic specification. More...

#include <kuonSpec.h>

Public Member Functions

 KuonSpec ()
 Constructor.
 
 ~KuonSpec ()
 Destructor.
 
int set (int eProdId, uint_t uHwVer, double fFrontTireRadius, double fRearTireRadius)
 Set product fixed specification. More...
 
void clear ()
 Clear product fixed specification.
 
int getProdId ()
 Get specification's product id. More...
 
uint_t getProdHwVer ()
 Get specification's product hardware version number. More...
 
int getNumMotors ()
 Get specification's number of motors. More...
 
KuonSpecMotor_TgetMotorSpecAt (int index)
 Get motor spec at the given index. More...
 
KuonSpecMotor_TgetMotorSpec (const std::string &strName)
 Get motor spec associated motor name. More...
 
KuonSpecMotor_TgetMotorSpec (int nMotorId)
 Get motor spec associated with motor id. More...
 
bool hasMotor (int nMotorId)
 Test if motor id is in the motor specifications. More...
 
void getTireSizes (double &fFrontTireRadius, double &fRearTireRadius)
 Get front and rear tire radii (mm). More...
 

Protected Attributes

int m_eProdId
 product id
 
uint_t m_uHwVer
 hardware version
 
int m_nNumMotors
 number of drive motors
 
double m_fFrontTireRadius
 front tire radius (mm)
 
double m_fRearTireRadius
 rear tire radius (mm)
 
std::vector< KuonSpecMotor_Tm_vecSpecMotors
 vector of motor specs
 

Friends

class KuonDesc
 
class KuonRobot
 

Detailed Description

Robotic specification.

Definition at line 151 of file kuonSpec.h.

Member Function Documentation

KuonSpecMotor_T* kuon::KuonSpec::getMotorSpec ( const std::string &  strName)

Get motor spec associated motor name.

Parameters
strNameMotor name (primary key).
Returns
If found, returns pointer to spec. Otherwise returns NULL.
KuonSpecMotor_T * KuonSpec::getMotorSpec ( int  nMotorId)

Get motor spec associated with motor id.

Parameters
nMotorIdMotor id (secondary key).
Returns
If found, returns pointer to spec. Otherwise returns NULL.

Definition at line 166 of file kuonSpec.cxx.

167 {
168  vector<KuonSpecMotor_T>::iterator iter;
169 
170  for(iter = m_vecSpecMotors.begin(); iter != m_vecSpecMotors.end(); ++iter)
171  {
172  if( iter->m_nMotorId == nMotorId )
173  {
174  return &(*iter);
175  }
176  }
177 
178  return NULL;
179 }
std::vector< KuonSpecMotor_T > m_vecSpecMotors
vector of motor specs
Definition: kuonSpec.h:269
KuonSpecMotor_T* kuon::KuonSpec::getMotorSpecAt ( int  index)
inline

Get motor spec at the given index.

Parameters
indexMotor index.
Returns
If found, returns pointer to spec. Otherwise returns NULL.

Definition at line 221 of file kuonSpec.h.

Referenced by kuon::KuonRobot::convertSpecs().

222  {
223  return index < m_vecSpecMotors.size()? &m_vecSpecMotors.at(index): NULL;
224  }
std::vector< KuonSpecMotor_T > m_vecSpecMotors
vector of motor specs
Definition: kuonSpec.h:269
int kuon::KuonSpec::getNumMotors ( )
inline

Get specification's number of motors.

Returns
Returns number of motors.

Definition at line 209 of file kuonSpec.h.

Referenced by kuon::KuonDescBase::getNumMotors().

210  {
211  return m_nNumMotors;
212  }
int m_nNumMotors
number of drive motors
Definition: kuonSpec.h:265
uint_t kuon::KuonSpec::getProdHwVer ( )
inline

Get specification's product hardware version number.

Returns
Returns version number.

Definition at line 199 of file kuonSpec.h.

200  {
201  return m_uHwVer;
202  }
uint_t m_uHwVer
hardware version
Definition: kuonSpec.h:264
int kuon::KuonSpec::getProdId ( )
inline

Get specification's product id.

Returns
Returns product id. See KuonProdId.

Definition at line 189 of file kuonSpec.h.

190  {
191  return m_eProdId;
192  }
int m_eProdId
product id
Definition: kuonSpec.h:263
void kuon::KuonSpec::getTireSizes ( double &  fFrontTireRadius,
double &  fRearTireRadius 
)

Get front and rear tire radii (mm).

Parameters
[out]fFrontTireRadiusFront tires.
[out]fRearTireRadiusRear tires.
bool kuon::KuonSpec::hasMotor ( int  nMotorId)
inline

Test if motor id is in the motor specifications.

Returns
Returns true or false.

Definition at line 249 of file kuonSpec.h.

Referenced by kuon::KuonDescBase::hasMotor(), and kuon::KuonDesc::hasMotor().

250  {
251  return getMotorSpec(nMotorId) == NULL? false: true;
252  }
KuonSpecMotor_T * getMotorSpec(const std::string &strName)
Get motor spec associated motor name.
int KuonSpec::set ( int  eProdId,
uint_t  uHwVer,
double  fFrontTireRadius,
double  fRearTireRadius 
)

Set product fixed specification.

Parameters
eProdId

Definition at line 80 of file kuonSpec.cxx.

References kuon::KUON_OK, kuon::KuonMotorIdLF, kuon::KuonMotorIdLR, kuon::KuonMotorIdRF, kuon::KuonMotorIdRR, kuon::KuonProdBaseStdNumMotors, kuon::KuonProdBaseStdSpecMotors, kuon::KuonProdIdNarrow, kuon::KuonProdIdStd, and kuon::KuonSpecMotor_T::m_fTireRadius.

Referenced by kuon::KuonDescBase::KuonDescBase().

84 {
85  const KuonSpecMotor_T *pSpecMotors = NULL;
86  int i;
87 
88  clear();
89 
90  switch( eProdId )
91  {
92  //
93  // Standard size Kuon
94  //
95  case KuonProdIdStd:
97  pSpecMotors = KuonProdBaseStdSpecMotors;
98  break;
99 
100  //
101  // Narrow size Kuon
102  //
103  case KuonProdIdNarrow:
104  break;
105  }
106 
107  if( pSpecMotors != NULL )
108  {
109  for(i=0; i<m_nNumMotors; ++i)
110  {
111  m_vecSpecMotors.push_back(pSpecMotors[i]);
112 
113  if( (pSpecMotors[i].m_nMotorId == KuonMotorIdLF) ||
114  (pSpecMotors[i].m_nMotorId == KuonMotorIdRF) )
115  {
116  m_fFrontTireRadius = pSpecMotors[i].m_fTireRadius;
117  }
118  else if( (pSpecMotors[i].m_nMotorId == KuonMotorIdLR) ||
119  (pSpecMotors[i].m_nMotorId == KuonMotorIdRR) )
120  {
121  m_fRearTireRadius = pSpecMotors[i].m_fTireRadius;
122  }
123  }
124  }
125 
126  m_eProdId = eProdId;
127  m_uHwVer = uHwVer;
128 
129  //
130  // Override factory defaults.
131  //
132  if( fFrontTireRadius > 0.0 )
133  {
134  m_fFrontTireRadius = fFrontTireRadius;
135  }
136  if( fRearTireRadius > 0.0 )
137  {
138  m_fRearTireRadius = fRearTireRadius;
139  }
140 
141  return KUON_OK;
142 }
static const int KuonMotorIdLR
left rear
Definition: kuon.h:304
static const int KuonMotorIdLF
left front
Definition: kuon.h:302
static const int KUON_OK
not an error, success
Definition: kuon.h:80
static const int KuonMotorIdRR
right rear
Definition: kuon.h:305
uint_t m_uHwVer
hardware version
Definition: kuonSpec.h:264
std::vector< KuonSpecMotor_T > m_vecSpecMotors
vector of motor specs
Definition: kuonSpec.h:269
Robotic motor specification.
Definition: kuonSpec.h:111
const KuonSpecMotor_T KuonProdBaseStdSpecMotors[]
Specification of servos.
double m_fFrontTireRadius
front tire radius (mm)
Definition: kuonSpec.h:266
const int KuonProdBaseStdNumMotors
number of motors
int m_eProdId
product id
Definition: kuonSpec.h:263
static const int KuonProdIdNarrow
narrow Kuon product id
Definition: kuon.h:146
double m_fRearTireRadius
rear tire radius (mm)
Definition: kuonSpec.h:267
void clear()
Clear product fixed specification.
Definition: kuonSpec.cxx:144
int m_nNumMotors
number of drive motors
Definition: kuonSpec.h:265
static const int KuonProdIdStd
standard Kuon product id
Definition: kuon.h:145
double m_fTireRadius
tire radius (mm)
Definition: kuonSpec.h:140
static const int KuonMotorIdRF
right front
Definition: kuon.h:303

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