SCL
1.0
Standard Control Library : Control, dynamics, physics, and simulation
|
#include <CRobot.hpp>
Public Member Functions | |
void | computeServo () |
void | computeDynamics () |
void | computeNonControlOperations () |
void | integrateDynamics () |
sBool | initFromDb (std::string arg_robot_name, CDynamicsBase *arg_dynamics, CDynamicsBase *arg_integrator) |
sBool | init (std::string arg_robot_name, CDynamicsBase *arg_dynamics, CDynamicsBase *arg_integrator, SRobotParsed *arg_robot, SRobotIO *arg_io_data, std::vector< SControllerBase * > &arg_ctrls) |
sBool | hasBeenInit () |
SRobot * | getData () |
void | setFlagApplyDamping (sBool arg_flag) |
sBool | setDamping (const Eigen::VectorXd &arg_d) |
void | setFlagApplyGcPosLimits (sBool arg_flag) |
sBool | setGcPosLimits (const Eigen::VectorXd &arg_max, const Eigen::VectorXd &arg_min) |
void | setFlagApplyActuatorForceLimits (sBool arg_flag) |
sBool | setActuatorForceLimits (const Eigen::VectorXd &arg_max, const Eigen::VectorXd &arg_min) |
void | setFlagControllerOn (sBool arg_flag) |
const Eigen::VectorXd & | getGeneralizedCoordinates () |
const Eigen::VectorXd & | getGeneralizedVelocities () |
const Eigen::VectorXd & | getGeneralizedAccelerations () |
const Eigen::VectorXd & | getGeneralizedForcesMeasured () |
const Eigen::VectorXd & | getGeneralizedForcesCommanded () |
void | setGeneralizedCoordinates (const Eigen::VectorXd &arg_q) |
void | setGeneralizedVelocities (const Eigen::VectorXd &arg_dq) |
void | setGeneralizedAccelerations (const Eigen::VectorXd &arg_ddq) |
void | setGeneralizedForcesMeasured (const Eigen::VectorXd &arg_f) |
void | setGeneralizedForcesCommanded (const Eigen::VectorXd &arg_f) |
void | setGeneralizedCoordinatesToZero () |
void | setGeneralizedVelocitiesToZero () |
void | setGeneralizedAccelerationsToZero () |
void | setGeneralizedForcesMeasuredToZero () |
void | setGeneralizedForcesCommandedToZero () |
sBool | addController (SControllerBase *arg_ctrl_ds) |
CControllerBase * | getControllerCurrent () |
sBool | setControllerCurrent (std::string arg_ctrl_name) |
SControllerBase * | getControllerDataStruct (const std::string &arg_ctrl_name) |
const CDynamicsBase * | getControllerDynamics () |
sBool | getProportionalGain (Eigen::VectorXd &ret_gains, const std::string &arg_ctrl_name="", const std::string &arg_task_name="") |
sBool | getDerivativeGain (Eigen::VectorXd &ret_gains, const std::string &arg_ctrl_name="", const std::string &arg_task_name="") |
sBool | getIntegralGain (Eigen::VectorXd &ret_gains, const std::string &arg_ctrl_name="", const std::string &arg_task_name="") |
sBool | setProportionalGain (const Eigen::VectorXd &arg_kp, const std::string &arg_ctrl_name="", const std::string &arg_task_name="") |
sBool | setDerivativeGain (const Eigen::VectorXd &arg_kv, const std::string &arg_ctrl_name="", const std::string &arg_task_name="") |
sBool | setIntegralGain (const Eigen::VectorXd &arg_ki, const std::string &arg_ctrl_name="", const std::string &arg_task_name="") |
sBool | setLogFile (const std::string &arg_file) |
sBool | logState (bool arg_log_gc=true, bool arg_log_gc_matrices=true, bool arg_log_task_matrices=false) |
CRobot () | |
virtual | ~CRobot () |
Private Attributes | |
SRobot | data_ |
SDatabase * | db_ |
CDynamicsBase * | dynamics_ |
CDynamicsBase * | integrator_ |
sutil::CMappedList < std::string, CControllerBase * > | ctrl_ |
CControllerBase * | ctrl_current_ |
std::string | log_file_name_ |
std::fstream | log_file_ |
sBool | logging_on_ |
The one-stop-do-it-all class that encapsulates dynamics, and a controller for a single robot.
Also provides an interface into the underlying shared data structure, the database, which facilitates communication between different modules.
NOTE : This class manages its memory. Add pointers and forget about them!
NOTE : You will, however, have to initialize (by calling the init function) the individual objects yourself.
scl::CRobot::CRobot | ( | ) |
Constructor sets pointers to NULL
|
virtual |
Destructor does nothing
sBool scl::CRobot::addController | ( | SControllerBase * | arg_ctrl_ds | ) |
Adds a controller based on the initialization information passed in a data structure. Does type-checking (the data structure has a type) and initializes an appropriate controller (controllers are derived from the CControllerBase API). Prints a warning if the passed data structure is invalid.
NOTE : init() adds all the specified robot's controllers from the database by default. Ie. It automatically loads controllers defined in the xml file!!
Only use this function for controllers defined "in code"
void scl::CRobot::computeDynamics | ( | ) |
Computes the robot's dynamic model. Asserts false in debug mode if something bad happens
void scl::CRobot::computeNonControlOperations | ( | ) |
Computes the robot's non-control related operations Asserts false in debug mode if something bad happens
void scl::CRobot::computeServo | ( | ) |
Computes the robot's command torques. Asserts false in debug mode if something bad happens
CControllerBase * scl::CRobot::getControllerCurrent | ( | ) |
Gets access to the current controller data structure
SControllerBase * scl::CRobot::getControllerDataStruct | ( | const std::string & | arg_ctrl_name | ) |
Gets access to the current controller data structure
|
inline |
Gets access to the current controller's dynamics
|
inline |
Returns a pointer to the robot's data structure
sBool scl::CRobot::getDerivativeGain | ( | Eigen::VectorXd & | ret_gains, |
const std::string & | arg_ctrl_name = "" , |
||
const std::string & | arg_task_name = "" |
||
) |
Returns the derivative gain of a given task in a controller.
[out] | ret_gains | The variable into which the gains will be copied |
[in] | ctrl_name | The controller's name. If no controller name is specified, it picks the current controller by default. |
[in] | task_name | The task for which the gains will be selected. Not reqd for gen coord controllers. |
Returns the derivative gain of a given task in a controller.
[out] | ret_gains | The variable into which the gains will be copied |
[in] | arg_ctrl_name | The controller's name. If no controller name is specified, it picks the current controller by default. |
[in] | task_name | The task for which the gains will be selected. Not reqd for gen coord controllers. |
Note: If you modify code here, you will probably also need to modify the same code in the other get gain functions.
sBool scl::CRobot::getIntegralGain | ( | Eigen::VectorXd & | ret_gains, |
const std::string & | arg_ctrl_name = "" , |
||
const std::string & | arg_task_name = "" |
||
) |
Returns the integral gain of a given task in a controller.
[out] | ret_gains | The variable into which the gains will be copied |
[in] | ctrl_name | The controller's name. If no controller name is specified, it picks the current controller by default. |
[in] | task_name | The task for which the gains will be selected. Not reqd for gen coord controllers. |
Returns the integral gain of a given task in a controller.
[out] | ret_gains | The variable into which the gains will be copied |
[in] | arg_ctrl_name | The controller's name. If no controller name is specified, it picks the current controller by default. |
[in] | task_name | The task for which the gains will be selected. Not reqd for gen coord controllers. |
Note: If you modify code here, you will probably also need to modify the same code in the other get gain functions.
sBool scl::CRobot::getProportionalGain | ( | Eigen::VectorXd & | ret_gains, |
const std::string & | arg_ctrl_name = "" , |
||
const std::string & | arg_task_name = "" |
||
) |
Returns the proportional gain of a given task in a controller.
[out] | ret_gains | The variable into which the gains will be copied |
[in] | ctrl_name | The controller's name. If no controller name is specified, it picks the current controller by default. |
[in] | task_name | The task for which the gains will be selected. Not reqd for gen coord controllers. |
Returns the proportional gain of a given task in a controller.
[out] | ret_gains | The variable into which the gains will be copied |
[in] | ctrl_name | The controller's name. If no controller name is specified, it picks the current controller by default. |
[in] | task_name | The task for which the gains will be selected. Not reqd for gen coord controllers. |
Note: If you modify code here, you will probably also need to modify the same code in the other get gain functions.
|
inline |
Initialization state
sBool scl::CRobot::init | ( | std::string | arg_robot_name, |
CDynamicsBase * | arg_dynamics, | ||
CDynamicsBase * | arg_integrator, | ||
SRobotParsed * | arg_robot, | ||
SRobotIO * | arg_io_data, | ||
std::vector< SControllerBase * > & | arg_ctrls | ||
) |
The actual data required to initialize a robot. Initializes the robot:
sBool scl::CRobot::initFromDb | ( | std::string | arg_robot_name, |
CDynamicsBase * | arg_dynamics, | ||
CDynamicsBase * | arg_integrator | ||
) |
Convenience function. Pulls all the data from the database and calls the other init function.
void scl::CRobot::integrateDynamics | ( | ) |
Integrates the robot's dynamics (physics model). By default, it integrates for a time period dt specifiecd in the database
Asserts false in debug mode if something bad happens
sBool scl::CRobot::logState | ( | bool | arg_log_gc = true , |
bool | arg_log_gc_matrices = true , |
||
bool | arg_log_task_matrices = false |
||
) |
Logs data to the file. Pass flags to control the data written to the file.
Logs data to the file
sBool scl::CRobot::setActuatorForceLimits | ( | const Eigen::VectorXd & | arg_max, |
const Eigen::VectorXd & | arg_min | ||
) |
Sets the actuator limits for each gc dof WARNING: This will overwrite the values read in from the config file
Sets the actuator limits for each actuator
sBool scl::CRobot::setControllerCurrent | ( | std::string | arg_ctrl_name | ) |
Selects the passed controller if it exists and has been initialized Returns false if the controller doesn't exist
sBool scl::CRobot::setDamping | ( | const Eigen::VectorXd & | arg_d | ) |
Sets the velocity damping for each gc dof WARNING: This will overwrite the values read in from the config file
Sets the velocity damping for each gc dof
sBool scl::CRobot::setDerivativeGain | ( | const Eigen::VectorXd & | arg_kv, |
const std::string & | arg_ctrl_name = "" , |
||
const std::string & | arg_task_name = "" |
||
) |
Sets the derivative gain of a given task in a controller.
[in] | arg_kv | The gains to be set |
[in] | ctrl_name | The controller's name. If no controller name is specified, it picks the current controller by default. |
[in] | task_name | The task for which the gains will be selected. Not reqd for gen coord controllers. |
Sets the derivative gain of a given task in a controller.
[in] | arg_kv | The gains to be set |
[in] | arg_ctrl_name | The controller's name. If no controller name is specified, it picks the current controller by default. |
[in] | task_name | The task for which the gains will be selected. Not reqd for gen coord controllers. |
|
inline |
Turn the actuator limits on or off. Simulates physical force limits of the actuators
|
inline |
Turn velocity damping on or off. Turning it on will make the robot lose some (1% default) velocity each second
|
inline |
Turn gc dof limits on or off. Turning it on will make the robot lose 99% velocity and all acceleration for a gc dof if it collides with its limits
|
inline |
Turn the controller on or off. Controller sends zero command gc forces if off.
sBool scl::CRobot::setGcPosLimits | ( | const Eigen::VectorXd & | arg_max, |
const Eigen::VectorXd & | arg_min | ||
) |
Sets the velocity damping for each gc dof WARNING: This will overwrite the values read in from the config file
sBool scl::CRobot::setIntegralGain | ( | const Eigen::VectorXd & | arg_ki, |
const std::string & | arg_ctrl_name = "" , |
||
const std::string & | arg_task_name = "" |
||
) |
Sets the integral gain of a given task in a controller.
[in] | arg_ki | The gains to be set |
[in] | ctrl_name | The controller's name. If no controller name is specified, it picks the current controller by default. |
[in] | task_name | The task for which the gains will be selected. Not reqd for gen coord controllers. |
Sets the derivative gain of a given task in a controller.
[in] | arg_kv | The gains to be set |
[in] | arg_ctrl_name | The controller's name. If no controller name is specified, it picks the current controller by default. |
[in] | task_name | The task for which the gains will be selected. Not reqd for gen coord controllers. |
sBool scl::CRobot::setLogFile | ( | const std::string & | arg_file | ) |
Sets up logging to a file. The files are opened in append+text mode and the state is written to them every time the logState() function is called.
Sets up logging to a file
sBool scl::CRobot::setProportionalGain | ( | const Eigen::VectorXd & | arg_kp, |
const std::string & | arg_ctrl_name = "" , |
||
const std::string & | arg_task_name = "" |
||
) |
Sets the proportional gain of a given task in a controller.
[in] | arg_gains | The gains to be set |
[in] | ctrl_name | The controller's name. If no controller name is specified, it picks the current controller by default. |
[in] | task_name | The task for which the gains will be selected. Not reqd for gen coord controllers. |
Sets the proportional gain of a given task in a controller.
[in] | arg_gains | The gains to be set |
[in] | arg_ctrl_name | The controller's name. If no controller name is specified, it picks the current controller by default. |
[in] | task_name | The task for which the gains will be selected. Not reqd for gen coord controllers. |
|
private |
A mapped list of controllers that can control this robot.
|
private |
The current controllers controlling this robot.
|
private |
The data is available in the database for other parts of the program to see.
Programs can use it to interact with controllers that don't support polling data structures in the database.
However, the recommended way is to communicate through the I/O data section of the database.
|
private |
A dynamics object, which implements all the dynamics matrix computation algorithms.
NOTE : CRobot will deallocate this pointer later.
|
private |
A dynamics object, which implements a dynamics integrator.
NOTE : CRobot will deallocate this pointer later. NOTE : This may be the same as the dynamics_ object.
|
private |
For logging stuff to a file.