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

Kuon robotic manipulator plus accesories class. More...

#include <kuonRobot.h>

Public Types

enum  AsyncTaskId { AsyncTaskIdNone }
 Asynchronous task id. More...
 
typedef std::map< int, KuonRobotJointMapRobotJoints
 Map of robot joints. More...
 
typedef std::map< std::string, int > IMapRobotJoints
 Indirect map of robot joints. More...
 

Public Member Functions

 KuonRobot (bool bNoExec=false)
 Default initialization constructor. More...
 
virtual ~KuonRobot ()
 Destructor.
 
int connect (const std::string &strDevMotorCtlr0=KuonDevMotorCtlr0, const std::string &strDevMotorCtlr1=KuonDevMotorCtlr1, int nBaudRateMotorCtlr=KuonBaudRateMotorCtlr)
 Connect to Kuon. More...
 
int disconnect ()
 Disconnect from Kuon. More...
 
int estop ()
 Emergency stop. More...
 
int freeze ()
 Freeze arm and accessories at current position. More...
 
int release ()
 Release arm and accessories. More...
 
int clearAlarms ()
 Attempt to clear all motor alarms in all kinematic chains. More...
 
void resetEStop ()
 Reset (clears) emergency stop condition. More...
 
float setGovernor (float fGovernor)
 Set speed limit governor value. More...
 
float incrementGovernor (float fDelta)
 Increment/decrement speed limit governor value. More...
 
int setBrake (float fBrake)
 Set robot's auto-brake value. More...
 
int setSlew (float fSlew)
 Set robot's power slew value. More...
 
int setSpeed (double fSpeedLeft, double fSpeedRight, units_t units=units_norm)
 Set robot's left and right motor speeds. More...
 
int move (KuonWheelTrajectoryPoint &trajectoryPoint)
 Move platform through trajectory point. More...
 
int velocityToRawSpeed (double fVelocity, units_t units=units_norm)
 Convert velocity to raw motor speed value. More...
 
int getRobotStatus (KuonRobotStatus &robotStatus)
 Get the robot current status. More...
 
int getJointState (KuonJointStatePoint &jointStatePoint)
 Get the joint states of a kinematic chain. More...
 
int getTrajectoryState (KuonWheelTrajectoryFeedback &trajFeedback)
 Get trajectory feedback. More...
 
void setRobotMode (KuonRobotMode eRobotMode)
 Set robot's operational mode. More...
 
void cancelAsyncTask ()
 Cancel any asynchronous task. More...
 
KuonAsyncTaskState getAsyncState ()
 Get the current asynchronous task state. More...
 
int getAsyncRc ()
 Get the last asynchronous task return code. More...
 
bool isConnected ()
 Test if connected to Kuon hardware. More...
 
void getVersion (int &nVerMajor, int &nVerMinor, int &nRevision)
 Get the Kuon robotic arm hardware version number. More...
 
std::string getVersion ()
 Get the Kuon robotic arm hardware version string. More...
 
KuonDescgetKuonDesc ()
 Get the Kuon product description. More...
 
int getProdId ()
 Convenience function to get this Kuon description's base product id. More...
 
std::string getProdName ()
 Convenience function to get this Kuon description's base product name. More...
 
std::string getFullProdBrief ()
 Get the Kuon full brief descirption. More...
 
int isDescribed ()
 Test if robot is fully described via configuration XML. More...
 
int isEStopped ()
 Test if robot is current emergency stopped. More...
 
int areMotorsPowered ()
 Test if robot motor are currently being driven (powered). More...
 
bool isInMotion ()
 Test if any joint in any of the kinematic chains is moving. More...
 
int isAlarmed ()
 Test if robot is alarmed. More...
 
float getGovernor ()
 Get current speed limit governor setting. More...
 
float getBrake ()
 Get current brake setting. More...
 
float getSlew ()
 Get current slew setting. More...
 
void getVelocitySetPoints (double &fSpeedLeft, double &fSpeedRight, units_t units=units_norm)
 Get the current left and right side motor velocity set points. More...
 
KuonRobotJointgetBaseJointAt (int index)
 Get robotic joint in arm+ee kinematic chain at the given index. More...
 
KuonRobotJointgetBaseJoint (std::string &strName)
 Get robotic joint in arm+ee kinematic chain. More...
 
KuonRobotJointgetBaseJoint (int nMotorId)
 Get robotic joint in arm+ee kinematic chain. More...
 

Static Public Attributes

static const float GovernorDft = 0.20
 speed limit governor start-up default
 
static const float BrakeDft = 0.20
 brake start-up default
 
static const float SlewDft = 0.10
 slew start-up default
 

Protected Member Functions

int convertSpecs ()
 Convert specification(s) to operational parameters. More...
 
int addRobotJoint (KuonSpecMotor_T *pSpecJoint, MapRobotJoints &kin, IMapRobotJoints &imap)
 Add a joint to robot's kinematic chain. More...
 
int configForOperation ()
 Configure Kuon for normal operation. More...
 
int createAsyncThread ()
 Create the asynchronous thread. More...
 

Static Protected Member Functions

static void * asyncThread (void *pArg)
 Asynchronous operation thread. More...
 

Protected Attributes

bool m_bNoExec
 do [not] execute physical movements
 
KuonDesc m_descKuon
  Kuon description
 
KuonRobotMode m_eRobotMode
 robot operating mode
 
bool m_bIsEStopped
 arm is [not] emergency stopped
 
bool m_bAlarmState
 robot is [not] alarmed
 
bool m_bAreMotorsPowered
 arm motor are [not] driven
 
float m_fGovernor
 speed limit governor setting
 
float m_fBattery
 battery energy level
 
float m_fBrake
 motor braking
 
float m_fSlew
 power slewing
 
int m_nGovernSpeedMin
 minimum governed speed limit
 
int m_nGovernSpeedMax
 maximum governed speed limit
 
int m_nSetPtSpeedLeft
 left motors raw speed set point
 
int m_nSetPtSpeedRight
 right motors raw speed set point
 
int m_fdMotorCtlr0
 motor controller 0 file descriptor
 
int m_fdMotorCtlr1
 motor controller 1 file descriptor
 
MapRobotJoints m_kinBase
 robot base kin
 
IMapRobotJoints m_imapBase
 robot base indirect kin map
 
KuonWheelTrajectoryPoint m_lastTrajBase
 last trajectory point for base
 
KuonAsyncTaskState m_eAsyncTaskState
 asynchronous task state
 
int m_rcAsyncTask
 last async task return code
 
AsyncTaskId m_eAsyncTaskId
 asynchronous task id
 
void * m_pAsyncTaskArg
 asynchronous argument
 
pthread_t m_threadAsync
 async pthread identifier
 

Detailed Description

Kuon robotic manipulator plus accesories class.

Includes up to 3 kinematic chains.

Definition at line 83 of file kuonRobot.h.

Member Typedef Documentation

typedef std::map<std::string, int> kuon::KuonRobot::IMapRobotJoints

Indirect map of robot joints.

key: joint name
mapped type: motor id

Definition at line 111 of file kuonRobot.h.

Map of robot joints.

key: motor id
mapped type: joint data
Note
Joint order is critical. Ascending motor ids keeps map in order, but if this cannot be guaranteed, then change strategy.

Definition at line 101 of file kuonRobot.h.

Member Enumeration Documentation

Asynchronous task id.

Enumerator
AsyncTaskIdNone 

no task

Definition at line 116 of file kuonRobot.h.

117  {
118  AsyncTaskIdNone, ///< no task
119 
120  // add others here, as needed
121  };

Constructor & Destructor Documentation

KuonRobot::KuonRobot ( bool  bNoExec = false)

Default initialization constructor.

Parameters
bNoExecDo [not] execute arm physical movements. All commands and responses are supported but the lower level arm movement commands will not be issued.

Definition at line 143 of file kuonRobot.cxx.

References kuon::KUON_OK, kuon::KuonAsyncTaskStateIdle, and kuon::KuonRobotModeAuto.

144 {
145  // state
146  m_bNoExec = bNoExec;
148  m_bIsEStopped = false;
149  m_bAlarmState = false;
150  m_fBattery = 0.0;
151  m_fBrake = BrakeDft;
152  m_fSlew = SlewDft;
153  m_nSetPtSpeedLeft = 0;
154  m_nSetPtSpeedRight = 0;
155 
157 
158  // motor controllers i/f
159  m_fdMotorCtlr0 = -1; // front or rear (cannot tell with RS160D ctlrs)
160  m_fdMotorCtlr1 = -1; // front or rear (cannot tell with RS160D ctlrs)
161 
162  // asynchronous task control
166  m_pAsyncTaskArg = NULL;
167 }
int m_nSetPtSpeedLeft
left motors raw speed set point
Definition: kuonRobot.h:650
int m_fdMotorCtlr1
motor controller 1 file descriptor
Definition: kuonRobot.h:655
static const int KUON_OK
not an error, success
Definition: kuon.h:80
idle, no async task running
Definition: kuon.h:376
static const float BrakeDft
brake start-up default
Definition: kuonRobot.h:87
void * m_pAsyncTaskArg
asynchronous argument
Definition: kuonRobot.h:668
float m_fBattery
battery energy level
Definition: kuonRobot.h:645
bool m_bIsEStopped
arm is [not] emergency stopped
Definition: kuonRobot.h:641
AsyncTaskId m_eAsyncTaskId
asynchronous task id
Definition: kuonRobot.h:667
int m_rcAsyncTask
last async task return code
Definition: kuonRobot.h:666
bool m_bNoExec
do [not] execute physical movements
Definition: kuonRobot.h:638
int m_fdMotorCtlr0
motor controller 0 file descriptor
Definition: kuonRobot.h:654
static const float SlewDft
slew start-up default
Definition: kuonRobot.h:88
float setGovernor(float fGovernor)
Set speed limit governor value.
Definition: kuonRobot.h:229
bool m_bAlarmState
robot is [not] alarmed
Definition: kuonRobot.h:642
KuonAsyncTaskState m_eAsyncTaskState
asynchronous task state
Definition: kuonRobot.h:665
int m_nSetPtSpeedRight
right motors raw speed set point
Definition: kuonRobot.h:651
float m_fSlew
power slewing
Definition: kuonRobot.h:647
float m_fBrake
motor braking
Definition: kuonRobot.h:646
static const float GovernorDft
speed limit governor start-up default
Definition: kuonRobot.h:86
KuonRobotMode m_eRobotMode
robot operating mode
Definition: kuonRobot.h:640
fully available
Definition: kuon.h:368

Member Function Documentation

int KuonRobot::addRobotJoint ( KuonSpecMotor_T pSpecJoint,
MapRobotJoints kin,
IMapRobotJoints imap 
)
protected

Add a joint to robot's kinematic chain.

Parameters
[in]pSpecJointPointer to joint spcecification.
[in]pSpecMotorPointer to motor spcecification.
[out]kinModified kinematics chain of joints.
[out]imapIndirect map of kinematic chain.

Definition at line 681 of file kuonRobot.cxx.

References kuon::KUON_OK, kuon::KuonJointTypeContinuous, kuon::KuonRobotJoint::m_eJointType, kuon::KuonRobotJoint::m_fGearRatio, kuon::KuonSpecMotor_T::m_fGearRatio, kuon::KuonRobotJoint::m_fTicksPerMotorRad, kuon::KuonRobotJoint::m_fTicksPerWheelRad, kuon::KuonRobotJoint::m_fTireRadius, kuon::KuonSpecMotor_T::m_fTireRadius, kuon::KuonSpecMotor_T::m_nDir, kuon::KuonRobotJoint::m_nMotorCtlrId, kuon::KuonSpecMotor_T::m_nMotorCtlrId, kuon::KuonRobotJoint::m_nMotorDir, kuon::KuonRobotJoint::m_nMotorId, kuon::KuonSpecMotor_T::m_nMotorId, kuon::KuonRobotJoint::m_nMotorIndex, kuon::KuonSpecMotor_T::m_nMotorIndex, kuon::KuonRobotJoint::m_strName, and kuon::KuonSpecMotor_T::m_strName.

684 {
685  int nMotorId; // master servo id
686  KuonRobotJoint joint; // robotic joint
687 
688  // master servo id associated with joint
689  nMotorId = pSpecMotor->m_nMotorId;
690 
691  //
692  // Populate joint data.
693  //
694  joint.m_strName = pSpecMotor->m_strName;
695  joint.m_nMotorId = nMotorId;
696  joint.m_nMotorCtlrId = pSpecMotor->m_nMotorCtlrId;
697  joint.m_nMotorIndex = pSpecMotor->m_nMotorIndex;
698  joint.m_nMotorDir = pSpecMotor->m_nDir;
700  joint.m_fGearRatio = pSpecMotor->m_fGearRatio;
701  joint.m_fTireRadius = pSpecMotor->m_fTireRadius;
702  joint.m_fTicksPerMotorRad = 0.0;
703  joint.m_fTicksPerWheelRad = 0.0;
704 
705  //
706  // Sanity checks.
707  //
708 
709  //
710  // Add to kinematic chain.
711  //
712  kin[nMotorId] = joint; // kinematic chain
713  imap[joint.m_strName] = nMotorId; // indirect map by joint name
714 
715  return KUON_OK;
716 }
double m_fTicksPerMotorRad
encoder/odom. ticks per motor radian
Definition: kuonJoint.h:140
std::string m_strName
joint name
Definition: kuonJoint.h:132
static const int KUON_OK
not an error, success
Definition: kuon.h:80
int m_nMotorIndex
motor controller unique motor index
Definition: kuonJoint.h:135
double m_fTicksPerWheelRad
encoder/odom. ticks per wheel radian
Definition: kuonJoint.h:141
double m_fGearRatio
joint gear ratio
Definition: kuonJoint.h:138
int m_nMotorCtlrId
motor controller id
Definition: kuonJoint.h:134
int m_nMotorDir
motor normalized direction
Definition: kuonJoint.h:136
int m_eJointType
joint type
Definition: kuonJoint.h:137
int m_nMotorId
motor id
Definition: kuonJoint.h:133
Operational robotic joint class.
Definition: kuonJoint.h:83
double m_fTireRadius
tire radius
Definition: kuonJoint.h:139
continuous rotation
Definition: kuonSpec.h:80
int kuon::KuonRobot::areMotorsPowered ( )
inline

Test if robot motor are currently being driven (powered).

Returns
Returns true or false.

Definition at line 509 of file kuonRobot.h.

References m_bAreMotorsPowered.

510  {
511  return m_bAreMotorsPowered;
512  }
bool m_bAreMotorsPowered
arm motor are [not] driven
Definition: kuonRobot.h:643
void * KuonRobot::asyncThread ( void *  pArg)
staticprotected

Asynchronous operation thread.

Parameters
pArgThread argument (point to KuonRobot object).
Returns
Returns NULL on thread exit.

Definition at line 790 of file kuonRobot.cxx.

References kuon::KUON_ECODE_BAD_VAL, kuon::KuonAsyncTaskStateIdle, m_eAsyncTaskId, m_eAsyncTaskState, m_pAsyncTaskArg, and m_rcAsyncTask.

791 {
792  KuonRobot *pThis = (KuonRobot *)pArg;
793  int oldstate;
794  int rc;
795 
796  pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &oldstate);
797  pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldstate);
798  //pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, &oldstate);
799 
800  LOGDIAG3("Async robot task thread created.");
801 
802  //
803  // Execute asychronous task.
804  //
805  // For now, only calibrate task is supported asynchronously.
806  //
807  switch( pThis->m_eAsyncTaskId )
808  {
809  // Unknown task id.
810  default:
811  LOGERROR("Unknown async task id = %d.", (int)pThis->m_eAsyncTaskId);
812  rc = -KUON_ECODE_BAD_VAL;
813  break;
814  }
815 
816  // freeze robot at current calibrated or aborted position.
817  //pThis->freeze(); disable, so that goto zero pt in calibration finsishes
818 
820  pThis->m_pAsyncTaskArg = NULL;
821  pThis->m_rcAsyncTask = rc;
823 
824  LOGDIAG3("Async robot task thread exited.");
825 
826  return NULL;
827 }
idle, no async task running
Definition: kuon.h:376
Kuon robotic manipulator plus accesories class.
Definition: kuonRobot.h:83
void * m_pAsyncTaskArg
asynchronous argument
Definition: kuonRobot.h:668
static const int KUON_ECODE_BAD_VAL
bad value general error
Definition: kuon.h:85
AsyncTaskId m_eAsyncTaskId
asynchronous task id
Definition: kuonRobot.h:667
int m_rcAsyncTask
last async task return code
Definition: kuonRobot.h:666
KuonAsyncTaskState m_eAsyncTaskState
asynchronous task state
Definition: kuonRobot.h:665
void KuonRobot::cancelAsyncTask ( )

Cancel any asynchronous task.

Note
There may be a little delay between canceling an async task and the task actually stopping.

Definition at line 764 of file kuonRobot.cxx.

References kuon::KUON_ECODE_INTR, and kuon::KuonAsyncTaskStateIdle.

Referenced by setRobotMode().

765 {
766  MapRobotJoints::iterator iter;
767 
769  {
770  // cancel thread
771  pthread_cancel(m_threadAsync);
772  pthread_join(m_threadAsync, NULL);
773 
774  // cleanup
775  switch( m_eAsyncTaskId )
776  {
777  default:
778  break;
779  }
780 
781  // clear state
783  m_pAsyncTaskArg = NULL;
786  LOGDIAG3("Async task canceled.");
787  }
788 }
idle, no async task running
Definition: kuon.h:376
void * m_pAsyncTaskArg
asynchronous argument
Definition: kuonRobot.h:668
AsyncTaskId m_eAsyncTaskId
asynchronous task id
Definition: kuonRobot.h:667
int m_rcAsyncTask
last async task return code
Definition: kuonRobot.h:666
pthread_t m_threadAsync
async pthread identifier
Definition: kuonRobot.h:669
static const int KUON_ECODE_INTR
operation interrupted
Definition: kuon.h:104
KuonAsyncTaskState m_eAsyncTaskState
asynchronous task state
Definition: kuonRobot.h:665
int KuonRobot::clearAlarms ( )

Attempt to clear all motor alarms in all kinematic chains.

Note
Not all alarms are clearable (e.g. temperature).

Definition at line 362 of file kuonRobot.cxx.

References kuon::KUON_OK, and KUON_TRY_CONN.

363 {
364  KUON_TRY_CONN();
365 
366  return KUON_OK;
367 }
static const int KUON_OK
not an error, success
Definition: kuon.h:80
#define KUON_TRY_CONN()
Test for connection.
Definition: kuonRobot.cxx:106
int KuonRobot::configForOperation ( )
protected

Configure Kuon for normal operation.

The arm, end effector, and accessory effectors are configured for normal operation.

Definition at line 718 of file kuonRobot.cxx.

References kuon::KUON_OK, and kuon::KuonRobotModeAuto.

719 {
721  m_bIsEStopped = false;
722  m_bAlarmState = false;
723  m_fBattery = 0.0;
724  m_fBrake = BrakeDft;
725  m_fSlew = SlewDft;
726  m_nSetPtSpeedLeft = 0;
727  m_nSetPtSpeedRight = 0;
728 
731  setSlew(SlewDft);
732  setSpeed(0.0, 0.0);
733 
734  return KUON_OK;
735 }
int m_nSetPtSpeedLeft
left motors raw speed set point
Definition: kuonRobot.h:650
static const int KUON_OK
not an error, success
Definition: kuon.h:80
static const float BrakeDft
brake start-up default
Definition: kuonRobot.h:87
float m_fBattery
battery energy level
Definition: kuonRobot.h:645
bool m_bIsEStopped
arm is [not] emergency stopped
Definition: kuonRobot.h:641
int setBrake(float fBrake)
Set robot&#39;s auto-brake value.
Definition: kuonRobot.cxx:369
int setSpeed(double fSpeedLeft, double fSpeedRight, units_t units=units_norm)
Set robot&#39;s left and right motor speeds.
Definition: kuonRobot.cxx:419
static const float SlewDft
slew start-up default
Definition: kuonRobot.h:88
float setGovernor(float fGovernor)
Set speed limit governor value.
Definition: kuonRobot.h:229
bool m_bAlarmState
robot is [not] alarmed
Definition: kuonRobot.h:642
int m_nSetPtSpeedRight
right motors raw speed set point
Definition: kuonRobot.h:651
float m_fSlew
power slewing
Definition: kuonRobot.h:647
float m_fBrake
motor braking
Definition: kuonRobot.h:646
int setSlew(float fSlew)
Set robot&#39;s power slew value.
Definition: kuonRobot.cxx:395
static const float GovernorDft
speed limit governor start-up default
Definition: kuonRobot.h:86
KuonRobotMode m_eRobotMode
robot operating mode
Definition: kuonRobot.h:640
fully available
Definition: kuon.h:368
int KuonRobot::connect ( const std::string &  strDevMotorCtlr0 = KuonDevMotorCtlr0,
const std::string &  strDevMotorCtlr1 = KuonDevMotorCtlr1,
int  nBaudRateMotorCtlr = KuonBaudRateMotorCtlr 
)

Connect to Kuon.

Parameters
strDevMotorCtlr0Motor controller serial device name 0.
strDevMotorCtlr1Motor controller serial device name 1.
nBaudRateMotorCtlrMotor controllers baud rate.

Definition at line 174 of file kuonRobot.cxx.

References kuon::getRealDeviceName(), kuon::KUON_ECODE_BAD_OP, kuon::KUON_ECODE_MOT_CTLR, and kuon::KUON_OK.

177 {
178  string strDevName0; // real device name 0
179  string strDevName1; // real device name 1
180  int rc; // return code
181 
182  //
183  // Need a robot description before preceeding.
184  //
185  if( !m_descKuon.isDescribed() )
186  {
187  LOGERROR("Undefined Kuon description - "
188  "don't know how to initialized properly.");
189  return -KUON_ECODE_BAD_OP;
190  }
191 
192  // get the real device names, not any symbolic links
193  strDevName0 = getRealDeviceName(strDevMotorCtlr0);
194  strDevName1 = getRealDeviceName(strDevMotorCtlr1);
195 
196  // RDK Hack
197  // Possible race condition where controller is not fully powered on.
198  // Wait a little bit.
199  // RDK Hack
200  long usec = 3000000;
201  LOGDIAG2("Waiting for motor controllers to power-up");
202  usleep(usec);
203  // RDK Hack
204 
205  // Open motor controller 0.
206  //
207  if( RS160DOpenConnection(strDevName0.c_str(), &m_fdMotorCtlr0) < 0 )
208  {
209  LOGERROR("%s: Failed to open motor controller 0.", strDevName0.c_str());
210  rc = -KUON_ECODE_MOT_CTLR;
211  }
212 
213  //
214  // Configure motor controller 0.
215  //
216  else if( RS160DSetToSerial(m_fdMotorCtlr0) < 0 )
217  {
218  LOGERROR("%s: Failed to configure motor controller 0.",
219  strDevName0.c_str());
220  rc = -KUON_ECODE_MOT_CTLR;
221  }
222 
223  //
224  // Open motor controller 1.
225  //
226  if( RS160DOpenConnection(strDevName1.c_str(), &m_fdMotorCtlr1) < 0 )
227  {
228  LOGERROR("%s: Failed to open motor controller 1.", strDevName1.c_str());
229  rc = -KUON_ECODE_MOT_CTLR;
230  }
231 
232  //
233  // Configure motor controller 1.
234  //
235  else if( RS160DSetToSerial(m_fdMotorCtlr1) < 0 )
236  {
237  LOGERROR("%s: Failed to configure motor controller 1.",
238  strDevName1.c_str());
239  rc = -KUON_ECODE_MOT_CTLR;
240  }
241 
242  //
243  // Convert fixed specifications to operational parameters.
244  //
245  else if( (rc = convertSpecs()) < 0 )
246  {
247  LOGERROR("Failed to convert product specifications to "
248  "operational parameters.");
249  }
250 
251  //
252  // Configure for operation.
253  //
254  else if( (rc = configForOperation()) < 0 )
255  {
256  LOGERROR("Failed to configure for operation.");
257  }
258 
259  // success
260  else
261  {
262  LOGDIAG1("Connected to Kuon with controllers = (%s, %s).",
263  strDevMotorCtlr0.c_str(), strDevMotorCtlr1.c_str());
264 
265  rc = KUON_OK;
266  }
267 
268  // undo
269  if( rc < 0 )
270  {
271  disconnect();
272  }
273 
274  return rc;
275 }
int m_fdMotorCtlr1
motor controller 1 file descriptor
Definition: kuonRobot.h:655
static const int KUON_OK
not an error, success
Definition: kuon.h:80
KuonDesc m_descKuon
<b><i>Kuon</i></b> description
Definition: kuonRobot.h:639
int configForOperation()
Configure <b><i>Kuon</i></b> for normal operation.
Definition: kuonRobot.cxx:718
int m_fdMotorCtlr0
motor controller 0 file descriptor
Definition: kuonRobot.h:654
static const int KUON_ECODE_MOT_CTLR
motor controller error
Definition: kuon.h:97
std::string getRealDeviceName(const std::string &strDevName)
Get real device name.
int disconnect()
Disconnect from <b><i>Kuon</i></b>.
Definition: kuonRobot.cxx:277
bool isDescribed()
Test if required descriptions are described.
Definition: kuonDesc.h:145
int convertSpecs()
Convert specification(s) to operational parameters.
Definition: kuonRobot.cxx:648
static const int KUON_ECODE_BAD_OP
invalid operation error
Definition: kuon.h:89
int KuonRobot::convertSpecs ( )
protected

Convert specification(s) to operational parameters.

The specifications must be defined and the connecton to the Kuon hardware must be open.

There are up to 3 kinematic chains, given the specifications and the hardware:

  • arm + end effector
  • equipment deck effector
  • auxiliary effector
Note
A kinematic chain differs from the dynamixel chain. Kuon supports one dynamixel bus in which all motor hang. A dynamixel chain defines this communication bus. Motors on the bus can be associated with any of the above three kinematic chains.

Definition at line 648 of file kuonRobot.cxx.

References kuon::KuonSpec::getMotorSpecAt(), kuon::KuonDescBase::getNumMotors(), kuon::KUON_OK, kuon::KuonSpecMotor_T::m_nMotorId, and kuon::KuonDescBase::m_spec.

649 {
650  KuonDescBase *pDescBase;
651  KuonSpecMotor_T *pSpecMotor;
652  KuonRobotJoint *pMotor;
653  int i;
654  int rc;
655 
656  m_kinBase.clear();
657  m_imapBase.clear();
658 
659  pDescBase = m_descKuon.getBaseDesc();
660 
661  //
662  // Build up base kinematic chain.
663  //
664  for(i = 0; i < pDescBase->getNumMotors(); ++i)
665  {
666  // joint specification
667  pSpecMotor = pDescBase->m_spec.getMotorSpecAt(i);
668 
669  // add robotic 'joint'
670  if( (rc = addRobotJoint(pSpecMotor, m_kinBase, m_imapBase)) < 0 )
671  {
672  LOGERROR("Motor %d: Cannot add to kinematic chain.",
673  pSpecMotor->m_nMotorId);
674  return rc;
675  }
676  }
677 
678  return KUON_OK;
679 }
KuonSpec m_spec
fixed specification
Definition: kuonDescBase.h:221
int addRobotJoint(KuonSpecMotor_T *pSpecJoint, MapRobotJoints &kin, IMapRobotJoints &imap)
Add a joint to robot&#39;s kinematic chain.
Definition: kuonRobot.cxx:681
static const int KUON_OK
not an error, success
Definition: kuon.h:80
int getNumMotors()
Get the number of expected and required motors.
Definition: kuonDescBase.h:176
KuonDesc m_descKuon
<b><i>Kuon</i></b> description
Definition: kuonRobot.h:639
Kuon robotic mobile base escription class.
Definition: kuonDescBase.h:79
Robotic motor specification.
Definition: kuonSpec.h:111
MapRobotJoints m_kinBase
robot base kin
Definition: kuonRobot.h:658
KuonSpecMotor_T * getMotorSpecAt(int index)
Get motor spec at the given index.
Definition: kuonSpec.h:221
Operational robotic joint class.
Definition: kuonJoint.h:83
int m_nMotorId
robot unique robot motor id
Definition: kuonSpec.h:136
KuonDescBase * getBaseDesc()
Get the <b><i>Kuon</i></b> base product description.
Definition: kuonDesc.h:156
IMapRobotJoints m_imapBase
robot base indirect kin map
Definition: kuonRobot.h:659
int KuonRobot::createAsyncThread ( )
protected

Create the asynchronous thread.

Context:
Calling thread.

Definition at line 737 of file kuonRobot.cxx.

References kuon::KUON_ECODE_SYS, kuon::KUON_OK, kuon::KuonAsyncTaskStateIdle, and kuon::KuonAsyncTaskStateWorking.

738 {
739  int rc;
740 
742 
743  rc = pthread_create(&m_threadAsync, NULL, KuonRobot::asyncThread, (void*)this);
744 
745  if( rc == 0 )
746  {
747  rc = KUON_OK;
748  }
749 
750  else
751  {
753  LOGSYSERROR("pthread_create()");
756  m_pAsyncTaskArg = NULL;
757  rc = m_rcAsyncTask;
758  }
759 
760  return rc;
761 }
static const int KUON_OK
not an error, success
Definition: kuon.h:80
idle, no async task running
Definition: kuon.h:376
void * m_pAsyncTaskArg
asynchronous argument
Definition: kuonRobot.h:668
async task running
Definition: kuon.h:377
AsyncTaskId m_eAsyncTaskId
asynchronous task id
Definition: kuonRobot.h:667
static const int KUON_ECODE_SYS
system (errno) error
Definition: kuon.h:83
int m_rcAsyncTask
last async task return code
Definition: kuonRobot.h:666
pthread_t m_threadAsync
async pthread identifier
Definition: kuonRobot.h:669
static void * asyncThread(void *pArg)
Asynchronous operation thread.
Definition: kuonRobot.cxx:790
KuonAsyncTaskState m_eAsyncTaskState
asynchronous task state
Definition: kuonRobot.h:665
int KuonRobot::disconnect ( )

Disconnect from Kuon.

Definition at line 277 of file kuonRobot.cxx.

References kuon::KUON_OK.

278 {
279  bool bWasConn = false;
280 
281  if( isConnected() )
282  {
283  bWasConn = true;
284  RS160DEStop(m_fdMotorCtlr0, m_fdMotorCtlr1);
285  }
286 
287  if( m_fdMotorCtlr0 >= 0 )
288  {
289  RS160DClose(m_fdMotorCtlr0);
290  m_fdMotorCtlr0 = -1;
291  }
292 
293  if( m_fdMotorCtlr1 >= 0 )
294  {
295  RS160DClose(m_fdMotorCtlr1);
296  m_fdMotorCtlr1 = -1;
297  }
298 
299  if( bWasConn )
300  {
301  LOGDIAG1("Disconnected from Kuon.");
302  }
303 
304  return KUON_OK;
305 }
int m_fdMotorCtlr1
motor controller 1 file descriptor
Definition: kuonRobot.h:655
static const int KUON_OK
not an error, success
Definition: kuon.h:80
int m_fdMotorCtlr0
motor controller 0 file descriptor
Definition: kuonRobot.h:654
bool isConnected()
Test if connected to <b><i>Kuon</i></b> hardware.
Definition: kuonRobot.h:408
int KuonRobot::estop ( )

Emergency stop.

All motor will stop driving, so arm or accessories may fall.

Definition at line 307 of file kuonRobot.cxx.

References kuon::KUON_OK, KUON_TRY_CONN, and KUON_TRY_NO_EXEC.

308 {
310  KUON_TRY_CONN();
311 
312  RS160DEStop(m_fdMotorCtlr0, m_fdMotorCtlr1);
313 
314  setBrake(1.0);
315 
316  m_bIsEStopped = true;
317  m_bAlarmState = true;
318 
320 
321  LOGDIAG3("Kuon emergency stopped.");
322 
323  return KUON_OK;
324 }
int m_fdMotorCtlr1
motor controller 1 file descriptor
Definition: kuonRobot.h:655
static const int KUON_OK
not an error, success
Definition: kuon.h:80
#define KUON_TRY_CONN()
Test for connection.
Definition: kuonRobot.cxx:106
bool m_bIsEStopped
arm is [not] emergency stopped
Definition: kuonRobot.h:641
int setBrake(float fBrake)
Set robot&#39;s auto-brake value.
Definition: kuonRobot.cxx:369
#define KUON_TRY_NO_EXEC()
Test for no execute flag.
Definition: kuonRobot.cxx:89
int m_fdMotorCtlr0
motor controller 0 file descriptor
Definition: kuonRobot.h:654
KuonWheelTrajectoryPoint m_lastTrajBase
last trajectory point for base
Definition: kuonRobot.h:662
bool m_bAlarmState
robot is [not] alarmed
Definition: kuonRobot.h:642
void clear()
Clear data.
Definition: kuonTraj.h:297
int KuonRobot::freeze ( )

Freeze arm and accessories at current position.

Motors are still being driven.

Definition at line 326 of file kuonRobot.cxx.

References kuon::KUON_OK, KUON_TRY_CONN, and KUON_TRY_NO_EXEC.

327 {
329  KUON_TRY_CONN();
330 
332 
333  // stop
334  setSpeed(0.0, 0.0);
335 
336  // set 'parking' brake
337  setBrake(1.0);
338 
339  LOGDIAG3("Kuon frozen at current position.");
340 
341  return KUON_OK;
342 }
static const int KUON_OK
not an error, success
Definition: kuon.h:80
#define KUON_TRY_CONN()
Test for connection.
Definition: kuonRobot.cxx:106
int setBrake(float fBrake)
Set robot&#39;s auto-brake value.
Definition: kuonRobot.cxx:369
#define KUON_TRY_NO_EXEC()
Test for no execute flag.
Definition: kuonRobot.cxx:89
int setSpeed(double fSpeedLeft, double fSpeedRight, units_t units=units_norm)
Set robot&#39;s left and right motor speeds.
Definition: kuonRobot.cxx:419
KuonWheelTrajectoryPoint m_lastTrajBase
last trajectory point for base
Definition: kuonRobot.h:662
void clear()
Clear data.
Definition: kuonTraj.h:297
int kuon::KuonRobot::getAsyncRc ( )
inline

Get the last asynchronous task return code.

Returns
Returns KUON_OK when task terminated successfully. Otherwise, returns < 0 Kuon Error Codes.

Definition at line 393 of file kuonRobot.h.

References m_rcAsyncTask.

394  {
395  return m_rcAsyncTask;
396  }
int m_rcAsyncTask
last async task return code
Definition: kuonRobot.h:666
KuonAsyncTaskState kuon::KuonRobot::getAsyncState ( )
inline

Get the current asynchronous task state.

Returns
KuonAsyncTaskState enum value.

Definition at line 381 of file kuonRobot.h.

References m_eAsyncTaskState.

382  {
383  return m_eAsyncTaskState;
384  }
KuonAsyncTaskState m_eAsyncTaskState
asynchronous task state
Definition: kuonRobot.h:665
KuonRobotJoint* kuon::KuonRobot::getBaseJoint ( std::string &  strName)
inline

Get robotic joint in arm+ee kinematic chain.

Parameters
strNameJoint name (key).
Returns
If found, returns pointer to joint. Otherwise returns NULL.

Definition at line 601 of file kuonRobot.h.

References m_imapBase, and m_kinBase.

602  {
603  IMapRobotJoints::iterator iter;
604 
605  if( (iter = m_imapBase.find(strName)) != m_imapBase.end() )
606  {
607  return &(m_kinBase[iter->second]);
608  }
609  else
610  {
611  return NULL;
612  }
613  }
MapRobotJoints m_kinBase
robot base kin
Definition: kuonRobot.h:658
IMapRobotJoints m_imapBase
robot base indirect kin map
Definition: kuonRobot.h:659
KuonRobotJoint* kuon::KuonRobot::getBaseJoint ( int  nMotorId)
inline

Get robotic joint in arm+ee kinematic chain.

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

Definition at line 622 of file kuonRobot.h.

References m_kinBase.

623  {
624  MapRobotJoints::iterator iter;
625 
626  if( (iter = m_kinBase.find(nMotorId)) != m_kinBase.end() )
627  {
628  return &(iter->second);
629  }
630  else
631  {
632  return NULL;
633  }
634  }
MapRobotJoints m_kinBase
robot base kin
Definition: kuonRobot.h:658
KuonRobotJoint* kuon::KuonRobot::getBaseJointAt ( int  index)
inline

Get robotic joint in arm+ee kinematic chain at the given index.

Parameters
indexJoint index.
Returns
If found, returns pointer to joint. Otherwise returns NULL.

Definition at line 589 of file kuonRobot.h.

References m_kinBase.

590  {
591  return index < m_kinBase.size()? &m_kinBase.at(index): NULL;
592  }
MapRobotJoints m_kinBase
robot base kin
Definition: kuonRobot.h:658
float kuon::KuonRobot::getBrake ( )
inline

Get current brake setting.

Returns
Return value.

Definition at line 551 of file kuonRobot.h.

References m_fBrake.

552  {
553  return m_fBrake;
554  }
float m_fBrake
motor braking
Definition: kuonRobot.h:646
std::string kuon::KuonRobot::getFullProdBrief ( )
inline

Get the Kuon full brief descirption.

Returns
Returns product brief description.

Definition at line 479 of file kuonRobot.h.

References kuon::KuonDesc::getFullProdBrief(), and m_descKuon.

480  {
481  return m_descKuon.getFullProdBrief();
482  }
KuonDesc m_descKuon
<b><i>Kuon</i></b> description
Definition: kuonRobot.h:639
std::string getFullProdBrief()
Get the <b><i>Kuon</i></b> full brief descirption.
Definition: kuonDesc.h:177
float kuon::KuonRobot::getGovernor ( )
inline

Get current speed limit governor setting.

Returns
Return value.

Definition at line 541 of file kuonRobot.h.

References m_fGovernor.

542  {
543  return m_fGovernor;
544  }
float m_fGovernor
speed limit governor setting
Definition: kuonRobot.h:644
int KuonRobot::getJointState ( KuonJointStatePoint jointStatePoint)

Get the joint states of a kinematic chain.

Parameters
[in,out]jointStatePointJoint state point.

Definition at line 579 of file kuonRobot.cxx.

References kuon::KuonJointStatePoint::append(), kuon::KuonJointStatePoint::clear(), kuon::KUON_OK, KUON_TRY_CONN, kuon::KuonJointState::m_fBrake, kuon::KuonJointState::m_fEffort, kuon::KuonJointState::m_fOdometer, kuon::KuonJointState::m_fPe, kuon::KuonJointState::m_fPm, kuon::KuonJointState::m_fPosition, kuon::KuonJointState::m_fSlew, kuon::KuonJointState::m_fVelocity, kuon::KuonJointState::m_fVelocityMps, kuon::KuonJointState::m_nEncoder, kuon::KuonJointState::m_nMotorId, kuon::KuonRobotJoint::m_nMotorIndex, kuon::KuonJointState::m_nSpeed, kuon::KuonRobotJoint::m_strName, kuon::KuonJointState::m_strName, and kuon::KuonJointStatePoint::setKinematicChainName().

Referenced by incrementGovernor().

580 {
581  MapRobotJoints::iterator iter; // kinematic chain iterator
582  int nMotorId; // master servo id
583  KuonRobotJoint *pMotor; // robotic motor joint
584  KuonJointState jointState; // working joint state
585  byte_t uMask; // working bit mask
586  int i; // working index
587 
588  KUON_TRY_CONN();
589 
590  jointStatePoint.clear();
591 
592  jointStatePoint.setKinematicChainName("base");
593 
594  //
595  // Build joint state point.
596  //
597  for(iter = m_kinBase.begin(); iter != m_kinBase.end(); ++iter)
598  {
599  nMotorId = iter->first;
600  pMotor = &(iter->second);
601 
602  // identifiers
603  jointState.m_strName = pMotor->m_strName;
604  jointState.m_nMotorId = nMotorId;
605 
606  // positions (unknown without encoders)
607  jointState.m_fPosition = 0.0;
608  jointState.m_fOdometer = 0.0;
609  jointState.m_nEncoder = 0;
610 
611  // velocities
612  jointState.m_fVelocity = 0.0;
613  jointState.m_fVelocityMps = 0.0;
614  if( pMotor->m_nMotorIndex == RS160D_MOTOR_LEFT_ID )
615  {
616  jointState.m_nSpeed = m_nSetPtSpeedLeft;
617  }
618  else
619  {
620  jointState.m_nSpeed = m_nSetPtSpeedRight;
621  }
622 
623  // torques and powers
624  jointState.m_fEffort = 0.0;
625  jointState.m_fPe = 0.0;
626  jointState.m_fPm = 0.0;
627 
628  // braking and power-up slewing
629  jointState.m_fBrake = m_fBrake;
630  jointState.m_fSlew = m_fSlew;
631 
632  // add state
633  jointStatePoint.append(jointState);
634  }
635 
636  return KUON_OK;
637 }
std::string m_strName
joint name
Definition: kuonJoint.h:132
int m_nSetPtSpeedLeft
left motors raw speed set point
Definition: kuonRobot.h:650
double m_fVelocityMps
current wheel velocity (meters/second)
Definition: kuonJoint.h:195
std::string m_strName
motor joint name
Definition: kuonJoint.h:188
double m_fPosition
current joint position (radians)
Definition: kuonJoint.h:190
static const int KUON_OK
not an error, success
Definition: kuon.h:80
#define KUON_TRY_CONN()
Test for connection.
Definition: kuonRobot.cxx:106
int m_nMotorIndex
motor controller unique motor index
Definition: kuonJoint.h:135
void append(const KuonJointState &jointState)
Append joint state to end of joint state point.
Definition: kuonJoint.h:302
float m_fSlew
current motor power slewing (normalized)
Definition: kuonJoint.h:200
float m_fBrake
current motor braking (normalized)
Definition: kuonJoint.h:199
void setKinematicChainName(std::string strKinName)
Set the kinematic chain name.
Definition: kuonJoint.h:273
int m_nSpeed
current raw speed
Definition: kuonJoint.h:196
double m_fPm
current motor output mechanical power (W)
Definition: kuonJoint.h:198
MapRobotJoints m_kinBase
robot base kin
Definition: kuonRobot.h:658
void clear()
Clear all state data.
Definition: kuonJoint.h:337
double m_fPe
current motor input electrical power (W)
Definition: kuonJoint.h:197
int m_nEncoder
current motor encoder position (ticks)
Definition: kuonJoint.h:194
double m_fOdometer
current wheel odometer reading (meters)
Definition: kuonJoint.h:193
Operational robotic joint class.
Definition: kuonJoint.h:83
int m_nMotorId
motor id
Definition: kuonJoint.h:189
Joint state class.
Definition: kuonJoint.h:159
double m_fVelocity
current joint velocity (radians/second)
Definition: kuonJoint.h:191
int m_nSetPtSpeedRight
right motors raw speed set point
Definition: kuonRobot.h:651
float m_fSlew
power slewing
Definition: kuonRobot.h:647
float m_fBrake
motor braking
Definition: kuonRobot.h:646
double m_fEffort
current joint torque (N-m)
Definition: kuonJoint.h:192
KuonDesc* kuon::KuonRobot::getKuonDesc ( )
inline

Get the Kuon product description.

Returns
Returns pointer to description.

Definition at line 447 of file kuonRobot.h.

References m_descKuon.

448  {
449  return &m_descKuon;
450  }
KuonDesc m_descKuon
<b><i>Kuon</i></b> description
Definition: kuonRobot.h:639
int kuon::KuonRobot::getProdId ( )
inline

Convenience function to get this Kuon description's base product id.

Returns
Returns product id. See KuonProdId.

Definition at line 458 of file kuonRobot.h.

References kuon::KuonDesc::getBaseDesc(), kuon::KuonDescBase::getProdId(), and m_descKuon.

459  {
460  return m_descKuon.getBaseDesc()->getProdId();
461  }
KuonDesc m_descKuon
<b><i>Kuon</i></b> description
Definition: kuonRobot.h:639
int getProdId()
Get this base description&#39;s base product id.
Definition: kuonDescBase.h:136
KuonDescBase * getBaseDesc()
Get the <b><i>Kuon</i></b> base product description.
Definition: kuonDesc.h:156
std::string kuon::KuonRobot::getProdName ( )
inline

Convenience function to get this Kuon description's base product name.

Returns
Returns product name. See KuonProdName.

Definition at line 469 of file kuonRobot.h.

References kuon::KuonDesc::getBaseDesc(), kuon::KuonDescBase::getProdName(), and m_descKuon.

470  {
471  return m_descKuon.getBaseDesc()->getProdName();
472  }
std::string getProdName()
Get this base description&#39;s name.
Definition: kuonDescBase.h:146
KuonDesc m_descKuon
<b><i>Kuon</i></b> description
Definition: kuonRobot.h:639
KuonDescBase * getBaseDesc()
Get the <b><i>Kuon</i></b> base product description.
Definition: kuonDesc.h:156
int KuonRobot::getRobotStatus ( KuonRobotStatus robotStatus)

Get the robot current status.

Parameters
[in,out]robotStatusRobot status.

Definition at line 526 of file kuonRobot.cxx.

References kuon::KuonRobotStatus::clear(), kuon::KUON_ECODE_ALARMED, kuon::KUON_ECODE_ESTOP, kuon::KUON_OK, kuon::KuonTriStateFalse, kuon::KuonTriStateTrue, kuon::KuonRobotStatus::m_eAreDrivesPowered, kuon::KuonRobotStatus::m_eIsEStopped, kuon::KuonRobotStatus::m_eIsInError, kuon::KuonRobotStatus::m_eIsInMotion, kuon::KuonRobotStatus::m_eIsMotionPossible, kuon::KuonRobotStatus::m_eRobotMode, kuon::KuonRobotStatus::m_fBattery, kuon::KuonRobotStatus::m_fGovernor, kuon::KuonMotorHealth::m_fTemperature, kuon::KuonMotorHealth::m_fVoltage, kuon::KuonRobotStatus::m_nErrorCode, kuon::KuonMotorHealth::m_nMotorId, kuon::KuonMotorHealth::m_strName, kuon::KuonMotorHealth::m_uAlarms, and kuon::KuonRobotStatus::m_vecMotorHealth.

Referenced by incrementGovernor().

527 {
528  MapRobotJoints::iterator iter; // kinematic chain iterator
529  int nMotorId; // motor id
530  bool bIsMoving; // robot is [not] moving
531  KuonMotorHealth health; // motor health
532 
533  robotStatus.clear();
534 
535  robotStatus.m_eRobotMode = m_eRobotMode;
536  robotStatus.m_eIsEStopped = m_bIsEStopped?
540  robotStatus.m_eIsInMotion = isInMotion()?
542 
543  // alarmed statue
544  if( m_bAlarmState )
545  {
547  robotStatus.m_eIsInError = KuonTriStateTrue;
548  robotStatus.m_nErrorCode = m_bIsEStopped?
550  }
551 
552  // unalarmed state
553  else
554  {
555  robotStatus.m_eIsMotionPossible = m_bNoExec?
557  robotStatus.m_eIsInError = KuonTriStateFalse;
558  robotStatus.m_nErrorCode = KUON_OK;
559  }
560 
561  robotStatus.m_fGovernor = m_fGovernor;
562  robotStatus.m_fBattery = 0.0;
563 
564 
565  for(iter = m_kinBase.begin(); iter != m_kinBase.end(); ++iter)
566  {
567  health.m_strName = iter->second.m_strName;
568  health.m_nMotorId = iter->first;
569  health.m_fTemperature = 0.0;
570  health.m_fVoltage = 0.0;
571  health.m_uAlarms = 0;
572 
573  robotStatus.m_vecMotorHealth.push_back(health);
574  }
575 
576  return KUON_OK;
577 }
KuonTriState m_eIsMotionPossible
motion is [not] possible
Definition: kuonStatus.h:152
KuonTriState m_eAreDrivesPowered
motor are [not] powered
Definition: kuonStatus.h:151
static const int KUON_OK
not an error, success
Definition: kuon.h:80
uint_t m_uAlarms
motor alarms
Definition: kuonStatus.h:99
float m_fGovernor
speed limiting governor (0-1)
Definition: kuonStatus.h:156
float m_fVoltage
motor voltage (volts)
Definition: kuonStatus.h:98
KuonTriState m_eIsInMotion
robot is [not] moving
Definition: kuonStatus.h:153
int m_nMotorId
motor id
Definition: kuonStatus.h:96
float m_fTemperature
motor temperature (Celsius)
Definition: kuonStatus.h:97
bool m_bIsEStopped
arm is [not] emergency stopped
Definition: kuonRobot.h:641
int m_nErrorCode
kuon error code
Definition: kuonStatus.h:155
KuonTriState m_eIsEStopped
robot is [not] emergency stopped
Definition: kuonStatus.h:150
MapRobotJoints m_kinBase
robot base kin
Definition: kuonRobot.h:658
void clear()
Clear data.
Definition: kuonStatus.cxx:131
bool m_bNoExec
do [not] execute physical movements
Definition: kuonRobot.h:638
bool m_bAreMotorsPowered
arm motor are [not] driven
Definition: kuonRobot.h:643
float m_fBattery
current battery energy (Wh)
Definition: kuonStatus.h:157
VecHealth m_vecMotorHealth
motors&#39; health
Definition: kuonStatus.h:158
static const int KUON_ECODE_ALARMED
robot is alarmed
Definition: kuon.h:103
std::string m_strName
motor name
Definition: kuonStatus.h:95
KuonRobotMode m_eRobotMode
robot operating mode
Definition: kuonStatus.h:149
static const int KUON_ECODE_ESTOP
robot emergency stopped
Definition: kuon.h:106
bool m_bAlarmState
robot is [not] alarmed
Definition: kuonRobot.h:642
bool isInMotion()
Test if any joint in any of the kinematic chains is moving.
Definition: kuonRobot.h:521
KuonTriState m_eIsInError
robot is [not] in error condition
Definition: kuonStatus.h:154
float m_fGovernor
speed limit governor setting
Definition: kuonRobot.h:644
KuonRobotMode m_eRobotMode
robot operating mode
Definition: kuonRobot.h:640
Robot motor health.
Definition: kuonStatus.h:66
float kuon::KuonRobot::getSlew ( )
inline

Get current slew setting.

Returns
Return value.

Definition at line 561 of file kuonRobot.h.

References getVelocitySetPoints(), and m_fSlew.

562  {
563  return m_fSlew;
564  }
float m_fSlew
power slewing
Definition: kuonRobot.h:647
int KuonRobot::getTrajectoryState ( KuonWheelTrajectoryFeedback trajFeedback)

Get trajectory feedback.

TODO

Parameters
[in,out]trajectoryFeedbackWheel state point.

Definition at line 639 of file kuonRobot.cxx.

References kuon::KuonWheelTrajectoryFeedback::clear(), and kuon::KUON_OK.

Referenced by incrementGovernor().

640 {
641  // TBD
642 
643  trajFeedback.clear();
644 
645  return KUON_OK;
646 }
static const int KUON_OK
not an error, success
Definition: kuon.h:80
void clear()
Clear data.
Definition: kuonTraj.h:403
void KuonRobot::getVelocitySetPoints ( double &  fSpeedLeft,
double &  fSpeedRight,
units_t  units = units_norm 
)

Get the current left and right side motor velocity set points.

Parameters
[out]fSpeedLeftCurrent left motors set velocity in units.
[out]fSpeedRightCurrent right motors set velocity in units.
unitsVelocity units.

Definition at line 489 of file kuonRobot.cxx.

Referenced by getSlew().

492 {
493  switch(units)
494  {
495  // [-1.0, 1.0] of max servo speed
496  case units_norm:
497  fSpeedLeft = (double)m_nSetPtSpeedLeft / (double)RS160D_MOTOR_SPEED_MAX;
498  fSpeedRight = (double)m_nSetPtSpeedRight / (double)RS160D_MOTOR_SPEED_MAX;
499  break;
500 
501  // % of max motor speed
502  case units_percent:
503  fSpeedLeft = (double)m_nSetPtSpeedLeft / (double)RS160D_MOTOR_SPEED_MAX;
504  fSpeedRight = (double)m_nSetPtSpeedRight / (double)RS160D_MOTOR_SPEED_MAX;
505  fSpeedLeft *= 100.0;
506  fSpeedRight *= 100.0;
507  break;
508 
509  // %% of max motor speed
510  case units_permil:
511  fSpeedLeft = (double)m_nSetPtSpeedLeft / (double)RS160D_MOTOR_SPEED_MAX;
512  fSpeedRight = (double)m_nSetPtSpeedRight / (double)RS160D_MOTOR_SPEED_MAX;
513  fSpeedLeft *= 1000.0;
514  fSpeedRight *= 1000.0;
515  break;
516 
517  // raw
518  case units_raw:
519  default:
520  fSpeedLeft = (double)m_nSetPtSpeedLeft;
521  fSpeedRight = (double)m_nSetPtSpeedRight;
522  break;
523  }
524 }
int m_nSetPtSpeedLeft
left motors raw speed set point
Definition: kuonRobot.h:650
int m_nSetPtSpeedRight
right motors raw speed set point
Definition: kuonRobot.h:651
void kuon::KuonRobot::getVersion ( int &  nVerMajor,
int &  nVerMinor,
int &  nRevision 
)
inline

Get the Kuon robotic arm hardware version number.

Parameters
[out]nVerMajorMajor version number.
[out]nVerMinorMinor version number.
[out]nVerRevisionRevision version number.

Definition at line 420 of file kuonRobot.h.

References kuon::KuonDesc::getBaseDesc(), kuon::KuonDescBase::getProdHwVer(), KUON_VER_MAJOR, KUON_VER_MINOR, KUON_VER_REV, m_descKuon, and kuon::strToVersion().

421  {
422  uint_t uHwVer;
423 
425  nVerMajor = KUON_VER_MAJOR(uHwVer);
426  nVerMinor = KUON_VER_MINOR(uHwVer);
427  nRevision = KUON_VER_REV(uHwVer);
428  }
KuonDesc m_descKuon
<b><i>Kuon</i></b> description
Definition: kuonRobot.h:639
std::string getProdHwVer()
Get this base description&#39;s hardware version.
Definition: kuonDescBase.h:166
uint_t strToVersion(const std::string &str)
Convert version dotted string to integer equivalent.
#define KUON_VER_REV(ver)
Get revision number from version.
Definition: kuon.h:186
#define KUON_VER_MINOR(ver)
Get version minor number from version.
Definition: kuon.h:177
#define KUON_VER_MAJOR(ver)
Get version major number from version.
Definition: kuon.h:168
KuonDescBase * getBaseDesc()
Get the <b><i>Kuon</i></b> base product description.
Definition: kuonDesc.h:156
std::string kuon::KuonRobot::getVersion ( )
inline

Get the Kuon robotic arm hardware version string.

Version number strings are of the dotted form maj.min.rev.

Returns
Version string.

Definition at line 437 of file kuonRobot.h.

References kuon::KuonDesc::getBaseDesc(), kuon::KuonDescBase::getProdHwVer(), and m_descKuon.

438  {
439  return m_descKuon.getBaseDesc()->getProdHwVer();
440  }
KuonDesc m_descKuon
<b><i>Kuon</i></b> description
Definition: kuonRobot.h:639
std::string getProdHwVer()
Get this base description&#39;s hardware version.
Definition: kuonDescBase.h:166
KuonDescBase * getBaseDesc()
Get the <b><i>Kuon</i></b> base product description.
Definition: kuonDesc.h:156
float kuon::KuonRobot::incrementGovernor ( float  fDelta)
inline

Increment/decrement speed limit governor value.

Governor is defined as:
speed = set_speed * governor

Parameters
fDeltaGovernor ± delta.
Returns
Returns new governor value.

Definition at line 248 of file kuonRobot.h.

References getJointState(), getRobotStatus(), getTrajectoryState(), m_fGovernor, move(), setBrake(), setGovernor(), setSlew(), setSpeed(), and velocityToRawSpeed().

249  {
250  return setGovernor(m_fGovernor+fDelta);
251  }
float setGovernor(float fGovernor)
Set speed limit governor value.
Definition: kuonRobot.h:229
float m_fGovernor
speed limit governor setting
Definition: kuonRobot.h:644
int kuon::KuonRobot::isAlarmed ( )
inline

Test if robot is alarmed.

Returns
Returns true or false.

Definition at line 531 of file kuonRobot.h.

References m_bAlarmState.

532  {
533  return m_bAlarmState;
534  }
bool m_bAlarmState
robot is [not] alarmed
Definition: kuonRobot.h:642
bool kuon::KuonRobot::isConnected ( )
inline

Test if connected to Kuon hardware.

Returns
Returns true or false.

Definition at line 408 of file kuonRobot.h.

References m_fdMotorCtlr0, and m_fdMotorCtlr1.

409  {
410  return (m_fdMotorCtlr0 >= 0) && (m_fdMotorCtlr1 >= 0);
411  }
int m_fdMotorCtlr1
motor controller 1 file descriptor
Definition: kuonRobot.h:655
int m_fdMotorCtlr0
motor controller 0 file descriptor
Definition: kuonRobot.h:654
int kuon::KuonRobot::isDescribed ( )
inline

Test if robot is fully described via configuration XML.

Returns
Returns true or false.

Definition at line 489 of file kuonRobot.h.

References kuon::KuonDesc::isDescribed(), and m_descKuon.

490  {
491  return m_descKuon.isDescribed();
492  }
KuonDesc m_descKuon
<b><i>Kuon</i></b> description
Definition: kuonRobot.h:639
bool isDescribed()
Test if required descriptions are described.
Definition: kuonDesc.h:145
int kuon::KuonRobot::isEStopped ( )
inline

Test if robot is current emergency stopped.

Returns
Returns true or false.

Definition at line 499 of file kuonRobot.h.

References m_bIsEStopped.

500  {
501  return m_bIsEStopped;
502  }
bool m_bIsEStopped
arm is [not] emergency stopped
Definition: kuonRobot.h:641
bool kuon::KuonRobot::isInMotion ( )
inline

Test if any joint in any of the kinematic chains is moving.

Note
RS160D motor controller provide no feedback.
Returns
Returns true or false.

Definition at line 521 of file kuonRobot.h.

References m_nSetPtSpeedLeft, and m_nSetPtSpeedRight.

522  {
523  return (m_nSetPtSpeedLeft != 0) || (m_nSetPtSpeedRight != 0);
524  }
int m_nSetPtSpeedLeft
left motors raw speed set point
Definition: kuonRobot.h:650
int m_nSetPtSpeedRight
right motors raw speed set point
Definition: kuonRobot.h:651
int KuonRobot::move ( KuonWheelTrajectoryPoint trajectoryPoint)

Move platform through trajectory point.

TODO

Parameters
trajectoryPointTrajectory end point.

Definition at line 446 of file kuonRobot.cxx.

References kuon::KUON_OK.

Referenced by incrementGovernor().

447 {
448  // TBD
449  return KUON_OK;
450 }
static const int KUON_OK
not an error, success
Definition: kuon.h:80
int KuonRobot::release ( )

Release arm and accessories.

Motors will stop driving, so the arm may fall.

Definition at line 344 of file kuonRobot.cxx.

References kuon::KUON_OK, KUON_TRY_CONN, and KUON_TRY_NO_EXEC.

345 {
347  KUON_TRY_CONN();
348 
350 
351  // stop
352  setSpeed(0.0, 0.0);
353 
354  // put in 'neutral'
355  setBrake(0.0);
356 
357  LOGDIAG3("Kuon servo drives released.");
358 
359  return KUON_OK;
360 }
static const int KUON_OK
not an error, success
Definition: kuon.h:80
#define KUON_TRY_CONN()
Test for connection.
Definition: kuonRobot.cxx:106
int setBrake(float fBrake)
Set robot&#39;s auto-brake value.
Definition: kuonRobot.cxx:369
#define KUON_TRY_NO_EXEC()
Test for no execute flag.
Definition: kuonRobot.cxx:89
int setSpeed(double fSpeedLeft, double fSpeedRight, units_t units=units_norm)
Set robot&#39;s left and right motor speeds.
Definition: kuonRobot.cxx:419
KuonWheelTrajectoryPoint m_lastTrajBase
last trajectory point for base
Definition: kuonRobot.h:662
void clear()
Clear data.
Definition: kuonTraj.h:297
void kuon::KuonRobot::resetEStop ( )
inline

Reset (clears) emergency stop condition.

Note
Motors are not re-powered until an move or freeze action is called.

Definition at line 213 of file kuonRobot.h.

References m_bAlarmState, and m_bIsEStopped.

214  {
215  m_bIsEStopped = false;
216  m_bAlarmState = false;
217  }
bool m_bIsEStopped
arm is [not] emergency stopped
Definition: kuonRobot.h:641
bool m_bAlarmState
robot is [not] alarmed
Definition: kuonRobot.h:642
int KuonRobot::setBrake ( float  fBrake)

Set robot's auto-brake value.

The brake value is applied to all motors. In the current Kuon, rheostatic motor braking is used. Future versions may use regenerative and/or mechanical braking.

Braking is automatically applied when motor speeds are 0.

Parameters
fBrakeBrake value between [0.0, 1.0] where 0.0 is coasting and 1.0 is full brake.

Definition at line 369 of file kuonRobot.cxx.

References kuon::fcap(), kuon::icap(), kuon::KUON_OK, KUON_TRY_CONN, and KUON_TRY_NOT_ESTOP.

Referenced by incrementGovernor().

370 {
371  int raw;
372 
373  KUON_TRY_CONN();
375 
376  fBrake = (float)fcap(fBrake, 0.0, 1.0);
377 
378  raw = RS160D_MOTOR_BRAKE_MAX * fBrake;
379  raw = icap(raw, RS160D_MOTOR_BRAKE_MIN, RS160D_MOTOR_BRAKE_MAX);
380 
381  RS160DAlterBraking(raw, m_fdMotorCtlr0, RS160D_MOTOR_LEFT_ID);
382  RS160DAlterBraking(raw, m_fdMotorCtlr0, RS160D_MOTOR_RIGHT_ID);
383  RS160DAlterBraking(raw, m_fdMotorCtlr1, RS160D_MOTOR_LEFT_ID);
384  RS160DAlterBraking(raw, m_fdMotorCtlr1, RS160D_MOTOR_RIGHT_ID);
385 
386  m_fBrake = fBrake;
387 
388  m_bAreMotorsPowered = m_fBrake > 0.0? true: false;
389 
390  LOGDIAG3("Brakes set to %3.1f (raw=%d).", m_fBrake, raw);
391 
392  return KUON_OK;
393 }
int m_fdMotorCtlr1
motor controller 1 file descriptor
Definition: kuonRobot.h:655
static const int KUON_OK
not an error, success
Definition: kuon.h:80
#define KUON_TRY_CONN()
Test for connection.
Definition: kuonRobot.cxx:106
int icap(int a, int min, int max)
Cap value within limits [min, max].
Definition: kuonUtils.h:154
bool m_bAreMotorsPowered
arm motor are [not] driven
Definition: kuonRobot.h:643
int m_fdMotorCtlr0
motor controller 0 file descriptor
Definition: kuonRobot.h:654
#define KUON_TRY_NOT_ESTOP()
Test for not estop.
Definition: kuonRobot.cxx:124
double fcap(double a, double min, double max)
Cap value within limits [min, max].
Definition: kuonUtils.h:140
float m_fBrake
motor braking
Definition: kuonRobot.h:646
float kuon::KuonRobot::setGovernor ( float  fGovernor)
inline

Set speed limit governor value.

Governor is defined as:
speed = cap(set_speed, min_speed * governor, max_speed * governor)

Parameters
fGovernorGovernor value between [0.0, 1.0].
Returns
Returns new governor value.

Definition at line 229 of file kuonRobot.h.

References kuon::fcap(), m_fGovernor, m_nGovernSpeedMax, and m_nGovernSpeedMin.

Referenced by incrementGovernor().

230  {
231  m_fGovernor = (float)fcap(fGovernor, 0.0, 1.0);
232  m_nGovernSpeedMin = (int)(m_fGovernor * (float)RS160D_MOTOR_SPEED_MIN);
233  m_nGovernSpeedMax = (int)(m_fGovernor * (float)RS160D_MOTOR_SPEED_MAX);
234 
235  return m_fGovernor;
236  }
int m_nGovernSpeedMin
minimum governed speed limit
Definition: kuonRobot.h:648
int m_nGovernSpeedMax
maximum governed speed limit
Definition: kuonRobot.h:649
double fcap(double a, double min, double max)
Cap value within limits [min, max].
Definition: kuonUtils.h:140
float m_fGovernor
speed limit governor setting
Definition: kuonRobot.h:644
void kuon::KuonRobot::setRobotMode ( KuonRobotMode  eRobotMode)
inline

Set robot's operational mode.

Returns
eRobotMode Robot operation mode. See KuonRobotMode.

Definition at line 363 of file kuonRobot.h.

References cancelAsyncTask(), and m_eRobotMode.

364  {
365  m_eRobotMode = eRobotMode;
366  }
KuonRobotMode m_eRobotMode
robot operating mode
Definition: kuonRobot.h:640
int KuonRobot::setSlew ( float  fSlew)

Set robot's power slew value.

The slew value is applied to all motors. It defines the power ramp up scale when accelerating.

Slewing is automatically applied on acceleration changes.

Parameters
fSlewSlew value between [0.0, 1.0] where 0.0 is full power applied instantly with quickest response and 1.0 is the slowest ramp up with sloggish response but little back EMF generated.

Definition at line 395 of file kuonRobot.cxx.

References kuon::fcap(), kuon::icap(), kuon::KUON_OK, KUON_TRY_CONN, and KUON_TRY_NOT_ESTOP.

Referenced by incrementGovernor().

396 {
397  int raw;
398 
399  KUON_TRY_CONN();
401 
402  fSlew = (float)fcap(fSlew, 0.0, 1.0);
403 
404  raw = RS160D_MOTOR_SLEW_MAX * fSlew;
405  raw = icap(raw, RS160D_MOTOR_SLEW_MIN, RS160D_MOTOR_SLEW_MAX);
406 
407  RS160DAlterSlew(raw, m_fdMotorCtlr0, RS160D_MOTOR_LEFT_ID);
408  RS160DAlterSlew(raw, m_fdMotorCtlr0, RS160D_MOTOR_RIGHT_ID);
409  RS160DAlterSlew(raw, m_fdMotorCtlr1, RS160D_MOTOR_LEFT_ID);
410  RS160DAlterSlew(raw, m_fdMotorCtlr1, RS160D_MOTOR_RIGHT_ID);
411 
412  m_fSlew = fSlew;
413 
414  LOGDIAG3("Power slew set to %3.1f (raw=%d).", m_fSlew, raw);
415 
416  return KUON_OK;
417 }
int m_fdMotorCtlr1
motor controller 1 file descriptor
Definition: kuonRobot.h:655
static const int KUON_OK
not an error, success
Definition: kuon.h:80
#define KUON_TRY_CONN()
Test for connection.
Definition: kuonRobot.cxx:106
int icap(int a, int min, int max)
Cap value within limits [min, max].
Definition: kuonUtils.h:154
int m_fdMotorCtlr0
motor controller 0 file descriptor
Definition: kuonRobot.h:654
#define KUON_TRY_NOT_ESTOP()
Test for not estop.
Definition: kuonRobot.cxx:124
double fcap(double a, double min, double max)
Cap value within limits [min, max].
Definition: kuonUtils.h:140
float m_fSlew
power slewing
Definition: kuonRobot.h:647
int KuonRobot::setSpeed ( double  fSpeedLeft,
double  fSpeedRight,
units_t  units = units_norm 
)

Set robot's left and right motor speeds.

Parameters
fSpeedLeftLeft motor speeds in the given units.
fSpeedRightRight motor speeds in the given units.
unitsSpeed units. One of:
units_norm units_percent units_permil units_raw.

Definition at line 419 of file kuonRobot.cxx.

References kuon::icap(), kuon::KUON_OK, KUON_TRY_CONN, and KUON_TRY_NOT_ESTOP.

Referenced by incrementGovernor().

420 {
421  int rawLeft;
422  int rawRight;
423 
424  KUON_TRY_CONN();
426 
427  rawLeft = velocityToRawSpeed(fSpeedLeft, units);
428  rawRight = velocityToRawSpeed(fSpeedRight, units);
429 
430  rawLeft = icap(rawLeft, m_nGovernSpeedMin, m_nGovernSpeedMax);
431  rawRight = icap(rawRight, m_nGovernSpeedMin, m_nGovernSpeedMax);
432 
433  RS160DUpdateMotorSpeeds(-rawLeft, m_fdMotorCtlr0, RS160D_MOTOR_LEFT_ID);
434  RS160DUpdateMotorSpeeds(rawRight, m_fdMotorCtlr0, RS160D_MOTOR_RIGHT_ID);
435  RS160DUpdateMotorSpeeds(-rawLeft, m_fdMotorCtlr1, RS160D_MOTOR_LEFT_ID);
436  RS160DUpdateMotorSpeeds(rawRight, m_fdMotorCtlr1, RS160D_MOTOR_RIGHT_ID);
437 
438  m_nSetPtSpeedLeft = rawLeft;
439  m_nSetPtSpeedRight = rawRight;
440 
441  LOGDIAG3("Speed raw_left=%d, raw_right=%d.", rawLeft, rawRight);
442 
443  return KUON_OK;
444 }
int m_nGovernSpeedMin
minimum governed speed limit
Definition: kuonRobot.h:648
int m_nSetPtSpeedLeft
left motors raw speed set point
Definition: kuonRobot.h:650
int m_fdMotorCtlr1
motor controller 1 file descriptor
Definition: kuonRobot.h:655
static const int KUON_OK
not an error, success
Definition: kuon.h:80
#define KUON_TRY_CONN()
Test for connection.
Definition: kuonRobot.cxx:106
int icap(int a, int min, int max)
Cap value within limits [min, max].
Definition: kuonUtils.h:154
int m_nGovernSpeedMax
maximum governed speed limit
Definition: kuonRobot.h:649
int m_fdMotorCtlr0
motor controller 0 file descriptor
Definition: kuonRobot.h:654
#define KUON_TRY_NOT_ESTOP()
Test for not estop.
Definition: kuonRobot.cxx:124
int m_nSetPtSpeedRight
right motors raw speed set point
Definition: kuonRobot.h:651
int velocityToRawSpeed(double fVelocity, units_t units=units_norm)
Convert velocity to raw motor speed value.
Definition: kuonRobot.cxx:452
int KuonRobot::velocityToRawSpeed ( double  fVelocity,
units_t  units = units_norm 
)

Convert velocity to raw motor speed value.

Parameters
fVelocityVelocity.
unitsVelocity units. One of:
units_norm [-1.0, 1.0]
units_percent [-100.0, 100.0]
units_permil [-1000.0, 1000.0]
units_raw [min, max]
Returns
Raw speed value.

Definition at line 452 of file kuonRobot.cxx.

References kuon::fcap().

Referenced by incrementGovernor().

453 {
454  switch(units)
455  {
456  // [-1.0, 1.0] of max servo speed
457  case units_norm:
458  return (int)(RS160D_MOTOR_SPEED_MAX * fcap(fVelocity, -1.0, 1.0));
459 
460  // % of max motor speed
461  case units_percent:
462  return (int)(RS160D_MOTOR_SPEED_MAX *
463  fcap(fVelocity, -100.0, 100.0)/100.0);
464 
465  // %% of max motor speed
466  case units_permil:
467  return (int)(RS160D_MOTOR_SPEED_MAX *
468  fcap(fVelocity, -1000.0, 1000.0)/1000.0);
469 
470  // raw units
471  case units_raw:
472  return (int)fcap(fVelocity,
473  RS160D_MOTOR_SPEED_MIN, RS160D_MOTOR_SPEED_MAX);
474 
475  // future
476  case units_rad_per_s:
477  case units_m_per_s:
478  LOGWARN("%s velocity units not supported until encoders installed.",
479  units_shortname(units));
480  return 0;
481 
482  // bad units
483  default:
484  LOGWARN("%s velocity units not supported.", units_shortname(units));
485  return 0;
486  }
487 }
double fcap(double a, double min, double max)
Cap value within limits [min, max].
Definition: kuonUtils.h:140

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