![]() |
Kuon
1.1.3
RoadNarrows Robotics Large Outdoor Mobile Robot Project
|
Kuon robotic manipulator plus accesories class. More...
#include <kuonRobot.h>
Public Types | |
| enum | AsyncTaskId { AsyncTaskIdNone } |
| Asynchronous task id. More... | |
| typedef std::map< int, KuonRobotJoint > | MapRobotJoints |
| 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... | |
| KuonDesc * | getKuonDesc () |
| 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... | |
| KuonRobotJoint * | getBaseJointAt (int index) |
| Get robotic joint in arm+ee kinematic chain at the given index. More... | |
| KuonRobotJoint * | getBaseJoint (std::string &strName) |
| Get robotic joint in arm+ee kinematic chain. More... | |
| KuonRobotJoint * | getBaseJoint (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 | |
Kuon robotic manipulator plus accesories class.
Includes up to 3 kinematic chains.
Definition at line 83 of file kuonRobot.h.
| 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.
| typedef std::map<int, KuonRobotJoint> kuon::KuonRobot::MapRobotJoints |
Map of robot joints.
| key: | motor id |
| mapped type: | joint data |
Definition at line 101 of file kuonRobot.h.
| KuonRobot::KuonRobot | ( | bool | bNoExec = false | ) |
Default initialization constructor.
| bNoExec | Do [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.
|
protected |
Add a joint to robot's kinematic chain.
| [in] | pSpecJoint | Pointer to joint spcecification. |
| [in] | pSpecMotor | Pointer to motor spcecification. |
| [out] | kin | Modified kinematics chain of joints. |
| [out] | imap | Indirect 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.
|
inline |
Test if robot motor are currently being driven (powered).
Definition at line 509 of file kuonRobot.h.
References m_bAreMotorsPowered.
|
staticprotected |
Asynchronous operation thread.
| pArg | Thread argument (point to KuonRobot object). |
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.
| void KuonRobot::cancelAsyncTask | ( | ) |
Cancel any asynchronous task.
Definition at line 764 of file kuonRobot.cxx.
References kuon::KUON_ECODE_INTR, and kuon::KuonAsyncTaskStateIdle.
Referenced by setRobotMode().
| int KuonRobot::clearAlarms | ( | ) |
Attempt to clear all motor alarms in all kinematic chains.
Definition at line 362 of file kuonRobot.cxx.
References kuon::KUON_OK, and KUON_TRY_CONN.
|
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.
| int KuonRobot::connect | ( | const std::string & | strDevMotorCtlr0 = KuonDevMotorCtlr0, |
| const std::string & | strDevMotorCtlr1 = KuonDevMotorCtlr1, |
||
| int | nBaudRateMotorCtlr = KuonBaudRateMotorCtlr |
||
| ) |
Connect to Kuon.
| strDevMotorCtlr0 | Motor controller serial device name 0. |
| strDevMotorCtlr1 | Motor controller serial device name 1. |
| nBaudRateMotorCtlr | Motor 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.
|
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:
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.
|
protected |
Create the asynchronous thread.
Definition at line 737 of file kuonRobot.cxx.
References kuon::KUON_ECODE_SYS, kuon::KUON_OK, kuon::KuonAsyncTaskStateIdle, and kuon::KuonAsyncTaskStateWorking.
| int KuonRobot::disconnect | ( | ) |
Disconnect from Kuon.
Definition at line 277 of file kuonRobot.cxx.
References kuon::KUON_OK.
| 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.
| 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.
|
inline |
Get the last asynchronous task return code.
Definition at line 393 of file kuonRobot.h.
References m_rcAsyncTask.
|
inline |
Get the current asynchronous task state.
Definition at line 381 of file kuonRobot.h.
References m_eAsyncTaskState.
|
inline |
Get robotic joint in arm+ee kinematic chain.
| strName | Joint name (key). |
Definition at line 601 of file kuonRobot.h.
References m_imapBase, and m_kinBase.
|
inline |
Get robotic joint in arm+ee kinematic chain.
| nMotorId | Motor id (primary key). |
Definition at line 622 of file kuonRobot.h.
References m_kinBase.
|
inline |
Get robotic joint in arm+ee kinematic chain at the given index.
| index | Joint index. |
Definition at line 589 of file kuonRobot.h.
References m_kinBase.
|
inline |
Get current brake setting.
Definition at line 551 of file kuonRobot.h.
References m_fBrake.
|
inline |
Get the Kuon full brief descirption.
Definition at line 479 of file kuonRobot.h.
References kuon::KuonDesc::getFullProdBrief(), and m_descKuon.
|
inline |
Get current speed limit governor setting.
Definition at line 541 of file kuonRobot.h.
References m_fGovernor.
| int KuonRobot::getJointState | ( | KuonJointStatePoint & | jointStatePoint | ) |
Get the joint states of a kinematic chain.
| [in,out] | jointStatePoint | Joint 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().
|
inline |
Get the Kuon product description.
Definition at line 447 of file kuonRobot.h.
References m_descKuon.
|
inline |
Convenience function to get this Kuon description's base product id.
Definition at line 458 of file kuonRobot.h.
References kuon::KuonDesc::getBaseDesc(), kuon::KuonDescBase::getProdId(), and m_descKuon.
|
inline |
Convenience function to get this Kuon description's base product name.
Definition at line 469 of file kuonRobot.h.
References kuon::KuonDesc::getBaseDesc(), kuon::KuonDescBase::getProdName(), and m_descKuon.
| int KuonRobot::getRobotStatus | ( | KuonRobotStatus & | robotStatus | ) |
Get the robot current status.
| [in,out] | robotStatus | Robot 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().
|
inline |
Get current slew setting.
Definition at line 561 of file kuonRobot.h.
References getVelocitySetPoints(), and m_fSlew.
| int KuonRobot::getTrajectoryState | ( | KuonWheelTrajectoryFeedback & | trajFeedback | ) |
Get trajectory feedback.
TODO
| [in,out] | trajectoryFeedback | Wheel state point. |
Definition at line 639 of file kuonRobot.cxx.
References kuon::KuonWheelTrajectoryFeedback::clear(), and kuon::KUON_OK.
Referenced by incrementGovernor().
| void KuonRobot::getVelocitySetPoints | ( | double & | fSpeedLeft, |
| double & | fSpeedRight, | ||
| units_t | units = units_norm |
||
| ) |
Get the current left and right side motor velocity set points.
| [out] | fSpeedLeft | Current left motors set velocity in units. |
| [out] | fSpeedRight | Current right motors set velocity in units. |
| units | Velocity units. |
Definition at line 489 of file kuonRobot.cxx.
Referenced by getSlew().
|
inline |
Get the Kuon robotic arm hardware version number.
| [out] | nVerMajor | Major version number. |
| [out] | nVerMinor | Minor version number. |
| [out] | nVerRevision | Revision 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().
|
inline |
Get the Kuon robotic arm hardware version string.
Version number strings are of the dotted form maj.min.rev.
Definition at line 437 of file kuonRobot.h.
References kuon::KuonDesc::getBaseDesc(), kuon::KuonDescBase::getProdHwVer(), and m_descKuon.
|
inline |
Increment/decrement speed limit governor value.
Governor is defined as:
speed = set_speed * governor
| fDelta | Governor ± delta. |
Definition at line 248 of file kuonRobot.h.
References getJointState(), getRobotStatus(), getTrajectoryState(), m_fGovernor, move(), setBrake(), setGovernor(), setSlew(), setSpeed(), and velocityToRawSpeed().
|
inline |
Test if robot is alarmed.
Definition at line 531 of file kuonRobot.h.
References m_bAlarmState.
|
inline |
Test if connected to Kuon hardware.
Definition at line 408 of file kuonRobot.h.
References m_fdMotorCtlr0, and m_fdMotorCtlr1.
|
inline |
Test if robot is fully described via configuration XML.
Definition at line 489 of file kuonRobot.h.
References kuon::KuonDesc::isDescribed(), and m_descKuon.
|
inline |
Test if robot is current emergency stopped.
Definition at line 499 of file kuonRobot.h.
References m_bIsEStopped.
|
inline |
Test if any joint in any of the kinematic chains is moving.
Definition at line 521 of file kuonRobot.h.
References m_nSetPtSpeedLeft, and m_nSetPtSpeedRight.
| int KuonRobot::move | ( | KuonWheelTrajectoryPoint & | trajectoryPoint | ) |
Move platform through trajectory point.
TODO
| trajectoryPoint | Trajectory end point. |
Definition at line 446 of file kuonRobot.cxx.
References kuon::KUON_OK.
Referenced by incrementGovernor().
| 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.
|
inline |
Reset (clears) emergency stop condition.
Definition at line 213 of file kuonRobot.h.
References m_bAlarmState, and m_bIsEStopped.
| 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.
| fBrake | Brake 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().
|
inline |
Set speed limit governor value.
Governor is defined as:
speed = cap(set_speed, min_speed * governor, max_speed * governor)
| fGovernor | Governor value between [0.0, 1.0]. |
Definition at line 229 of file kuonRobot.h.
References kuon::fcap(), m_fGovernor, m_nGovernSpeedMax, and m_nGovernSpeedMin.
Referenced by incrementGovernor().
|
inline |
Set robot's operational mode.
Definition at line 363 of file kuonRobot.h.
References cancelAsyncTask(), and m_eRobotMode.
| 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.
| fSlew | Slew 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().
| int KuonRobot::setSpeed | ( | double | fSpeedLeft, |
| double | fSpeedRight, | ||
| units_t | units = units_norm |
||
| ) |
Set robot's left and right motor speeds.
| fSpeedLeft | Left motor speeds in the given units. |
| fSpeedRight | Right motor speeds in the given units. |
| units | Speed 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().
| int KuonRobot::velocityToRawSpeed | ( | double | fVelocity, |
| units_t | units = units_norm |
||
| ) |
Convert velocity to raw motor speed value.
| fVelocity | Velocity. |
| units | Velocity 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] |
Definition at line 452 of file kuonRobot.cxx.
References kuon::fcap().
Referenced by incrementGovernor().