![]() |
Laelaps
2.3.5
RoadNarrows Robotics Small Outdoor Mobile Robot Project
|
Laelaps kinematics class. More...
#include <laeKin.h>
Public Member Functions | |
LaeKinematics () | |
Default initializer constructor. | |
virtual | ~LaeKinematics () |
Desctructor. | |
int | open (const std::string &strDevMotorCtlrs, const int nBaudRate, int(*fnEnable)(void *, bool)=NULL, void *pEnableArg=NULL) |
Open communication with the Laelaps motor controllers. More... | |
virtual int | close () |
Close communication. More... | |
virtual bool | isOpen () |
Test if connection is open. More... | |
virtual bool | isEnabled () |
Test if motors are enabled. More... | |
virtual bool | areMotorsPowered () |
Test if motors are powered. More... | |
virtual int | configure (const LaeDesc &desc) |
Configure kinematics chains and data from product description. More... | |
virtual int | configure (const LaeTunes &tunes) |
Configure kinematics for operation. More... | |
virtual int | reload (const LaeTunes &tunes) |
Reload configuration tuning parameters. More... | |
LaePlatform & | getPlatform () |
Get robot platform kinodynamics. More... | |
motor::roboclaw::RoboClaw * | getMotorCtlr (const int nMotorCtlrId) |
Get pointer to motor controller by name (key). More... | |
LaeMapPowertrain & | getPowertrainMap () |
Get map of all powertrain kinodynamics. More... | |
LaePowertrain * | getPowertrain (const std::string &strName) |
Get pointer to powertrain by name (key). More... | |
LaePowertrain * | getPowertrain (int nCtlr, int nMotor) |
Get pointer to powertrain by controller id and motor index. More... | |
LaePowertrain * | getPowertrain (int nMotorId) |
Get pointer to powertrain by motor id. More... | |
virtual int | getPowertrainState (const std::string &strName, LaePowertrainState &state) |
Get the current powertrain state. More... | |
virtual bool | isStopped () |
Test if all motors are stopped. More... | |
virtual bool | isStopped (const std::string &strName) |
Test if a powertrain motor is stopped. More... | |
virtual int | resetOdometers () |
Reset all motors' odometers to the current respective encoder positions. More... | |
virtual void | estop () |
Emergency stop the robot. More... | |
virtual void | resetEStop () |
Reset emergency stop condition. More... | |
virtual int | freeze () |
Freeze (stop) all motors at the current position. More... | |
virtual int | release () |
Release motors. More... | |
virtual int | stop () |
Stop all motors at the current position. More... | |
virtual int | stop (const std::vector< std::string > &vecNames) |
Stop the set of powertrain motors at the current position. More... | |
virtual int | stop (const std::string &strName) |
Stop one powertrain motor at the current position. More... | |
virtual int | waitForAllStop (double fSeconds) |
Wait for all motors to stop. More... | |
virtual int | setGoalVelocities (const LaeMapVelocity &velocity) |
Set new or updated motor velocity goals. More... | |
virtual int | setGoalDutyCycles (const LaeMapDutyCycle &duty) |
Set new or updated motor duty cycle goals. More... | |
virtual int | setGoalTwist (double fVelLinear, double fVelAngular) |
Set new or updated robot twist velocity goals. More... | |
virtual void | exec () |
Execute kinematics task(s). More... | |
virtual int | monitorHealth () |
Monitor kinematics health. More... | |
Protected Member Functions | |
void | lock () |
Lock the shared resource. More... | |
void | unlock () |
Unlock the shared resource. More... | |
void | resyncComm () |
Attempt to resynchronize the serial communication between the host and the motor controllers. | |
virtual int | configureMotorController (const LaeTunes &tunes, int nCtlr) |
Configure motor controller. More... | |
virtual int | configMotorCtlrBatteryCutoffs (const LaeTunes &tunes, int nCtlr, bool &bNvmSave) |
Configure motor controller battery cutoff voltages. More... | |
virtual int | configMotorCtlrLogicCutoffs (const LaeTunes &tunes, int nCtlr, bool &bNvmSave) |
Configure motor controller logic cutoff voltages. More... | |
virtual int | configMotorCtlrEncoderModes (const LaeTunes &tunes, int nCtlr, bool &bNvmSave) |
Configure motor controller encoder modes. More... | |
virtual int | resetMotorCtlrEncoders (int nCtlr) |
Reset all motor controller encoders to zero. More... | |
virtual int | configurePtp (const LaeTunes &tunes, int nCtlr, bool &bNvSave) |
Configure powertrain pair. More... | |
virtual int | configMotorVelocityPid (const LaeTunes &tunes, LaePowertrain &powertrain, bool &bNvmSave) |
Configure motor velocity PID parameters. More... | |
virtual int | configMotorMaxAmpLimit (const LaeTunes &tunes, LaePowertrain &powertrain, bool &bNvmSave) |
Configure motor maximum ampere limit. More... | |
virtual int | saveConfigToNvm (int nCtlr) |
Save configuration to motor controller's non-volatile memory. More... | |
virtual int | sense () |
Sense real-time state. More... | |
virtual int | senseDynamics () |
Sense real-time kinodynamics. More... | |
virtual int | react () |
React to any necessary time-critical events. More... | |
virtual int | plan () |
Plan kinematic action. More... | |
virtual int | act () |
Act on current action. More... | |
virtual void | enableMotorCtlrs () |
Enable power to motor controllers. | |
virtual void | disableMotorCtlrs () |
Disable power to motor controllers. | |
Protected Attributes | |
bool | m_bIsEnabled |
is [not] enabled | |
bool | m_bAreMotorsPowered |
motors are [not] powered | |
bool | m_bIsStopped |
all motors are [not] stopped | |
int(* | m_fnEnableMotorCtlrs )(void *, bool) |
enable power function | |
void * | m_pEnableArg |
argument to enable function | |
motor::roboclaw::RoboClawComm | m_commMotorCtlrs |
serial communication bus | |
motor::roboclaw::RoboClaw * | m_pMotorCtlr [LaeNumMotorCtlrs] |
RoboClaw motor controllers. | |
LaePlatform | m_kinPlatform |
robot platform kinematics | |
LaeMapPowertrain | m_kinPowertrains |
robot powertrain kinematics | |
LaeKinAction * | m_pAction |
current extended kinematics action | |
pthread_mutex_t | m_mutex |
mutex | |
Laelaps kinematics class.
The LaeKinematics class supports control and monitoring of Laelaps powertrains and base kinodynamics.
|
protectedvirtual |
Act on current action.
Definition at line 1526 of file laeKin.cxx.
Referenced by unlock().
|
inlinevirtual |
Test if motors are powered.
Definition at line 183 of file laeKin.h.
References configure(), m_bAreMotorsPowered, and reload().
Referenced by laelaps::LaeRobot::areMotorsPowered().
|
virtual |
Close communication.
Definition at line 221 of file laeKin.cxx.
Referenced by Laelaps.WatchDog.WatchDog::attach(), laelaps::LaeRobot::disconnect(), and Laelaps.WatchDog.WatchDog::open().
|
protectedvirtual |
Configure motor controller battery cutoff voltages.
tunes | Laelaps tuning parameters. | |
nCtlr | Motor controller id. | |
[out] | bNvmSave | Do [not] save configuration in motor contoller's non-volatile memory. |
Definition at line 447 of file laeKin.cxx.
Referenced by unlock().
|
protectedvirtual |
Configure motor controller encoder modes.
tunes | Laelaps tuning parameters. | |
nCtlr | Motor controller id. | |
[out] | bNvmSave | Do [not] save configuration in motor contoller's non-volatile memory. |
Definition at line 579 of file laeKin.cxx.
Referenced by unlock().
|
protectedvirtual |
Configure motor controller logic cutoff voltages.
tunes | Laelaps tuning parameters. | |
nCtlr | Motor controller id. | |
[out] | bNvmSave | Do [not] save configuration in motor contoller's non-volatile memory. |
Definition at line 512 of file laeKin.cxx.
Referenced by unlock().
|
protectedvirtual |
Configure motor maximum ampere limit.
tunes | Laelaps tuning parameters. | |
powertrain | Powertrain kinodynmics object. | |
strKey | Powertrain key. | |
[out] | bNvmSave | Do [not] save configuration in motor contoller's non-volatile memory. |
Definition at line 798 of file laeKin.cxx.
References LAE_VERSION, laelaps::LaePowertrain::m_attr, laelaps::LaePowertrainAttr::m_nMotorCtlrId, laelaps::LaePowertrainAttr::m_nMotorId, laelaps::LaePowertrainAttr::m_nMotorIndex, and laelaps::LaePowertrain::m_strName.
Referenced by unlock().
|
protectedvirtual |
Configure motor velocity PID parameters.
tunes | Laelaps tuning parameters. | |
powertrain | Powertrain kinodynmics object. | |
[out] | bNvmSave | Do [not] save configuration in motor contoller's non-volatile memory. |
Definition at line 711 of file laeKin.cxx.
References laelaps::LaeTunes::getVelPidKParams(), laelaps::LaePowertrain::m_attr, laelaps::LaePowertrainAttr::m_nMotorCtlrId, laelaps::LaePowertrainAttr::m_nMotorId, laelaps::LaePowertrainAttr::m_nMotorIndex, laelaps::LaePowertrain::m_strName, and laelaps::LaePowertrainAttr::m_uMaxQpps.
Referenced by unlock().
|
virtual |
Configure kinematics chains and data from product description.
desc | Product description. |
Definition at line 331 of file laeKin.cxx.
References laelaps::LaePowertrain::configure(), laelaps::LaeDesc::m_mapDescPowertrain, laelaps::LaeDesc::m_pDescBase, and laelaps::LaePowertrain::m_strName.
Referenced by areMotorsPowered(), and laelaps::LaeRobot::configForOperation().
|
virtual |
Configure kinematics for operation.
tunes | Laelaps tuning parameters. |
Definition at line 367 of file laeKin.cxx.
|
protectedvirtual |
Configure motor controller.
tunes | Laelaps tuning parameters. |
nCtlr | Motor controller id. |
Definition at line 390 of file laeKin.cxx.
Referenced by unlock().
|
protectedvirtual |
Configure powertrain pair.
tunes | Laelaps tuning parameters. | |
nCtlr | Motor controller id. | |
[out] | bNvmSave | Do [not] save configuration in motor contoller's non-volatile memory. |
Definition at line 664 of file laeKin.cxx.
Referenced by unlock().
|
virtual |
Emergency stop the robot.
All motors will stop and power to motor controllers disabled.
Definition at line 1064 of file laeKin.cxx.
Referenced by laelaps::LaeRobot::estop(), and getPowertrainMap().
|
virtual |
Execute kinematics task(s).
Definition at line 1600 of file laeKin.cxx.
Referenced by laelaps::LaeThreadKin::exec(), and freeze().
|
inlinevirtual |
Freeze (stop) all motors at the current position.
Synomonous with stop().
Definition at line 355 of file laeKin.h.
References exec(), monitorHealth(), release(), setGoalDutyCycles(), setGoalTwist(), setGoalVelocities(), stop(), and waitForAllStop().
RoboClaw * LaeKinematics::getMotorCtlr | ( | const int | nMotorCtlrId | ) |
Get pointer to motor controller by name (key).
nMotorCtlrId | Motor controller unique identifier. |
Definition at line 918 of file laeKin.cxx.
Referenced by laelaps::LaeKinActionVelocity::execute(), laelaps::LaeKinActionDutyCycle::execute(), laelaps::LaeKinActionTwist::execute(), getPlatform(), laelaps::LaeKinActionVelocity::terminate(), laelaps::LaeKinActionDutyCycle::terminate(), and laelaps::LaeKinActionTwist::terminate().
|
inline |
Get robot platform kinodynamics.
Definition at line 226 of file laeKin.h.
References getMotorCtlr(), and m_kinPlatform.
Referenced by laelaps::LaeRptRobotStatus::generate(), and laelaps::LaeKinActionTwist::plan().
LaePowertrain* laelaps::LaeKinematics::getPowertrain | ( | const std::string & | strName | ) |
Get pointer to powertrain by name (key).
strName | Powertrain name (key). |
Referenced by laelaps::LaeKinActionDutyCycle::execute(), laelaps::LaeRobot::getNavigationState(), laelaps::LaeRobot::getPowertrain(), getPowertrainMap(), laelaps::LaeKinActionVelocity::plan(), and laelaps::LaeKinActionTwist::plan().
LaePowertrain * LaeKinematics::getPowertrain | ( | int | nCtlr, |
int | nMotor | ||
) |
Get pointer to powertrain by controller id and motor index.
nCtlr | Motor controller id. |
nMotor | Motor index within motor controller. |
Definition at line 942 of file laeKin.cxx.
LaePowertrain * LaeKinematics::getPowertrain | ( | int | nMotorId | ) |
Get pointer to powertrain by motor id.
nMotorId | Motor id. |
Definition at line 956 of file laeKin.cxx.
|
inline |
Get map of all powertrain kinodynamics.
Definition at line 247 of file laeKin.h.
References estop(), getPowertrain(), getPowertrainState(), isStopped(), m_kinPowertrains, resetEStop(), and resetOdometers().
Referenced by laelaps::LaeRptRobotStatus::generate().
|
virtual |
Get the current powertrain state.
[in] | strName | Powertrain unique name. |
[out] | state | Current powertrain state. |
Definition at line 970 of file laeKin.cxx.
Referenced by getPowertrainMap().
|
inlinevirtual |
Test if motors are enabled.
Definition at line 173 of file laeKin.h.
References m_bIsEnabled.
Referenced by laelaps::LaeRobot::estop(), and laelaps::LaeRobot::resetEStop().
|
inlinevirtual |
Test if connection is open.
Definition at line 163 of file laeKin.h.
References motor::roboclaw::RoboClawComm::isOpen(), and m_commMotorCtlrs.
Referenced by Laelaps.WatchDog.WatchDog::cmdConfigDPin(), Laelaps.WatchDog.WatchDog::cmdEnableAuxPort5V(), Laelaps.WatchDog.WatchDog::cmdEnableAuxPortBatt(), Laelaps.WatchDog.WatchDog::cmdEnableMotorCtlrs(), Laelaps.WatchDog.WatchDog::cmdGetFwVersion(), Laelaps.WatchDog.WatchDog::cmdPetTheDog(), Laelaps.WatchDog.WatchDog::cmdReadAPin(), Laelaps.WatchDog.WatchDog::cmdReadDPin(), Laelaps.WatchDog.WatchDog::cmdReadEnables(), Laelaps.WatchDog.WatchDog::cmdReadVoltages(), Laelaps.WatchDog.WatchDog::cmdResetRgbLed(), Laelaps.WatchDog.WatchDog::cmdSetAlarms(), Laelaps.WatchDog.WatchDog::cmdSetBatterySoC(), Laelaps.WatchDog.WatchDog::cmdSetRgbLed(), and Laelaps.WatchDog.WatchDog::cmdWriteDPin().
|
virtual |
Test if all motors are stopped.
Definition at line 986 of file laeKin.cxx.
References iabs().
Referenced by getPowertrainMap(), and laelaps::LaeRobot::isInMotion().
|
virtual |
Test if a powertrain motor is stopped.
strName | Powertrain unique name. |
Definition at line 1007 of file laeKin.cxx.
References iabs().
|
inlineprotected |
|
virtual |
Monitor kinematics health.
Definition at line 1551 of file laeKin.cxx.
References laelaps::LaePowertrain::updateHealth().
Referenced by laelaps::LaeThreadKin::exec(), and freeze().
int LaeKinematics::open | ( | const std::string & | strDevMotorCtlrs, |
const int | nBaudRate, | ||
int(*)(void *, bool) | fnEnable = NULL , |
||
void * | pEnableArg = NULL |
||
) |
Open communication with the Laelaps motor controllers.
Motors controller serial interface support multi-drop, so one serial device can support up to 8 motor controllers. A GPIO pin selects the motor controller.
strDevMotorCtlrs | Motor controllers serial device name. |
nBaudRate | Motor controllers serial baudrate. |
fnEnable | Motor controllers enable power function. |
pEnableArg | Enable power function argument. |
Definition at line 141 of file laeKin.cxx.
References laelaps::getRealDeviceName().
Referenced by laelaps::LaeRobot::connMotorControllers().
|
protectedvirtual |
Plan kinematic action.
Definition at line 1501 of file laeKin.cxx.
Referenced by unlock(), laelaps::LaeKinActionTwist::~LaeKinActionTwist(), and laelaps::LaeKinActionVelocity::~LaeKinActionVelocity().
|
protectedvirtual |
React to any necessary time-critical events.
Definition at line 1496 of file laeKin.cxx.
Referenced by unlock().
|
virtual |
Release motors.
Motors will stop, but are free to roll.
Definition at line 1094 of file laeKin.cxx.
Referenced by freeze(), and laelaps::LaeRobot::release().
|
virtual |
Reload configuration tuning parameters.
tunes | Laelaps tuning parameters. |
Definition at line 897 of file laeKin.cxx.
Referenced by areMotorsPowered(), and laelaps::LaeThreadKin::reload().
|
virtual |
Reset emergency stop condition.
Definition at line 1085 of file laeKin.cxx.
Referenced by getPowertrainMap(), and laelaps::LaeRobot::resetEStop().
|
protectedvirtual |
Reset all motor controller encoders to zero.
nCtlr | Motor controller id. |
Definition at line 643 of file laeKin.cxx.
Referenced by unlock().
|
virtual |
Reset all motors' odometers to the current respective encoder positions.
Definition at line 1026 of file laeKin.cxx.
References laelaps::LaePowertrain::resetOdometer().
Referenced by getPowertrainMap().
|
protectedvirtual |
Save configuration to motor controller's non-volatile memory.
nCtlr | Motor controller id. |
Definition at line 874 of file laeKin.cxx.
Referenced by unlock().
|
protectedvirtual |
Sense real-time state.
Definition at line 1423 of file laeKin.cxx.
Referenced by unlock().
|
protectedvirtual |
Sense real-time kinodynamics.
Definition at line 1435 of file laeKin.cxx.
References iabs(), and laelaps::LaePowertrain::updateStateDynamics().
Referenced by unlock().
|
virtual |
Set new or updated motor duty cycle goals.
The duty cycle actions are very simple actions (contrast with a multi-position task). Therefore, to reduce thread context switching and increase responsiveness, after the new/updated duty goals are set, the plan and execute steps are immediately called.
duty | Map of powertrain duty cycles. Keys are left_front, right_front, left_rear, and right_rear. Values are normalized duty cycle [-1.0, 1.0]. |
Definition at line 1322 of file laeKin.cxx.
References laelaps::LaeKinActionDutyCycle::execute(), laelaps::LaeKinAction::isExecutionRequired(), laelaps::LaeKinAction::isPlanningRequired(), laelaps::LaeKinAction::plan(), and laelaps::LaeKinActionDutyCycle::update().
Referenced by freeze(), and laelaps::LaeRobot::setDutyCycles().
|
virtual |
Set new or updated robot twist velocity goals.
The velocity actions are very simple actions (contrast with a multi-position task). Therefore, to reduce thread context switching and increase responsiveness, after the new/updated velocity goals are set, the plan and execute steps are immediately called.
fVelLinear | Linear velocity (meters/second). |
fVelAngular | Angular velocity (radians/second). |
Definition at line 1370 of file laeKin.cxx.
References laelaps::LaeKinActionTwist::execute(), laelaps::LaeKinAction::isExecutionRequired(), laelaps::LaeKinAction::isPlanningRequired(), laelaps::LaeKinActionTwist::plan(), and laelaps::LaeKinActionTwist::update().
Referenced by freeze(), and laelaps::LaeRobot::move().
|
virtual |
Set new or updated motor velocity goals.
The velocity actions are very simple actions (contrast with a multi-position task). Therefore, to reduce thread context switching and increase responsiveness, after the new/updated velocity goals are set, the plan and execute steps are immediately called.
velocity | Map of powertrain velocities. Keys are left_front, right_front, left_rear, and right_rear. Values are wheel shaft angular velocities (radians/second). |
Definition at line 1274 of file laeKin.cxx.
References laelaps::LaeKinActionVelocity::execute(), laelaps::LaeKinAction::isExecutionRequired(), laelaps::LaeKinAction::isPlanningRequired(), laelaps::LaeKinActionVelocity::plan(), and laelaps::LaeKinActionVelocity::update().
Referenced by freeze(), and laelaps::LaeRobot::move().
|
virtual |
Stop all motors at the current position.
The motor brakes, if available, are applied.
Definition at line 1125 of file laeKin.cxx.
Referenced by laelaps_tune_motors.window::createLeftButtons(), laelaps::LaeRobot::freeze(), and freeze().
|
virtual |
Stop the set of powertrain motors at the current position.
vecName | Vector of unique powertrain names. |
Referenced by laelaps_tune_motors.window::createLeftButtons().
|
virtual |
Stop one powertrain motor at the current position.
strName | Powertrain unique name. |
Referenced by laelaps_tune_motors.window::createLeftButtons().
|
inlineprotected |
Unlock the shared resource.
Definition at line 550 of file laeKin.h.
References act(), configMotorCtlrBatteryCutoffs(), configMotorCtlrEncoderModes(), configMotorCtlrLogicCutoffs(), configMotorMaxAmpLimit(), configMotorVelocityPid(), configureMotorController(), configurePtp(), disableMotorCtlrs(), enableMotorCtlrs(), plan(), react(), resetMotorCtlrEncoders(), resyncComm(), saveConfigToNvm(), sense(), and senseDynamics().
|
virtual |
Wait for all motors to stop.
fSeconds | Maximum number of seconds to wait. |
Definition at line 1253 of file laeKin.cxx.
Referenced by freeze().