SCL  1.0
Standard Control Library : Control, dynamics, physics, and simulation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends Macros Groups Pages
Public Member Functions | Private Attributes | List of all members
scl::CRobot Class Reference

#include <CRobot.hpp>

Collaboration diagram for scl::CRobot:
Collaboration graph
[legend]

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 ()
 
SRobotgetData ()
 
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)
 
CControllerBasegetControllerCurrent ()
 
sBool setControllerCurrent (std::string arg_ctrl_name)
 
SControllerBasegetControllerDataStruct (const std::string &arg_ctrl_name)
 
const CDynamicsBasegetControllerDynamics ()
 
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_
 
SDatabasedb_
 
CDynamicsBasedynamics_
 
CDynamicsBaseintegrator_
 
sutil::CMappedList
< std::string, CControllerBase * > 
ctrl_
 
CControllerBasectrl_current_
 
std::string log_file_name_
 
std::fstream log_file_
 
sBool logging_on_
 

Detailed Description

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.

Constructor & Destructor Documentation

scl::CRobot::CRobot ( )

Constructor sets pointers to NULL

scl::CRobot::~CRobot ( )
virtual

Destructor does nothing

Member Function Documentation

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

const CDynamicsBase* scl::CRobot::getControllerDynamics ( )
inline

Gets access to the current controller's dynamics

SRobot* scl::CRobot::getData ( )
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.

Parameters
[out]ret_gainsThe variable into which the gains will be copied
[in]ctrl_nameThe controller's name. If no controller name is specified, it picks the current controller by default.
[in]task_nameThe 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.

Parameters
[out]ret_gainsThe variable into which the gains will be copied
[in]arg_ctrl_nameThe controller's name. If no controller name is specified, it picks the current controller by default.
[in]task_nameThe 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.

Parameters
[out]ret_gainsThe variable into which the gains will be copied
[in]ctrl_nameThe controller's name. If no controller name is specified, it picks the current controller by default.
[in]task_nameThe 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.

Parameters
[out]ret_gainsThe variable into which the gains will be copied
[in]arg_ctrl_nameThe controller's name. If no controller name is specified, it picks the current controller by default.
[in]task_nameThe 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.

Parameters
[out]ret_gainsThe variable into which the gains will be copied
[in]ctrl_nameThe controller's name. If no controller name is specified, it picks the current controller by default.
[in]task_nameThe 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.

Parameters
[out]ret_gainsThe variable into which the gains will be copied
[in]ctrl_nameThe controller's name. If no controller name is specified, it picks the current controller by default.
[in]task_nameThe 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::hasBeenInit ( )
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:

  1. Verifies that the robot's data in the database is consistent
  2. DELETES all its existing data! (NOTE this carefully!)
  3. Reads the list of available controllers from the database, finds the controllers that match this robot, and initializes them. (a) Creates a controller object for each new controller (b) Adds the controller data-structure to this robot's database data structure (c) Sets the last controller as the current controller (default, can be changed)
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.

Parameters
[in]arg_kvThe gains to be set
[in]ctrl_nameThe controller's name. If no controller name is specified, it picks the current controller by default.
[in]task_nameThe 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.

Parameters
[in]arg_kvThe gains to be set
[in]arg_ctrl_nameThe controller's name. If no controller name is specified, it picks the current controller by default.
[in]task_nameThe task for which the gains will be selected. Not reqd for gen coord controllers.
void scl::CRobot::setFlagApplyActuatorForceLimits ( sBool  arg_flag)
inline

Turn the actuator limits on or off. Simulates physical force limits of the actuators

void scl::CRobot::setFlagApplyDamping ( sBool  arg_flag)
inline

Turn velocity damping on or off. Turning it on will make the robot lose some (1% default) velocity each second

void scl::CRobot::setFlagApplyGcPosLimits ( sBool  arg_flag)
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

void scl::CRobot::setFlagControllerOn ( sBool  arg_flag)
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.

Parameters
[in]arg_kiThe gains to be set
[in]ctrl_nameThe controller's name. If no controller name is specified, it picks the current controller by default.
[in]task_nameThe 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.

Parameters
[in]arg_kvThe gains to be set
[in]arg_ctrl_nameThe controller's name. If no controller name is specified, it picks the current controller by default.
[in]task_nameThe 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.

Parameters
[in]arg_gainsThe gains to be set
[in]ctrl_nameThe controller's name. If no controller name is specified, it picks the current controller by default.
[in]task_nameThe 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.

Parameters
[in]arg_gainsThe gains to be set
[in]arg_ctrl_nameThe controller's name. If no controller name is specified, it picks the current controller by default.
[in]task_nameThe task for which the gains will be selected. Not reqd for gen coord controllers.

Member Data Documentation

sutil::CMappedList<std::string,CControllerBase*> scl::CRobot::ctrl_
private

A mapped list of controllers that can control this robot.

CControllerBase* scl::CRobot::ctrl_current_
private

The current controllers controlling this robot.

SRobot scl::CRobot::data_
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.

CDynamicsBase* scl::CRobot::dynamics_
private

A dynamics object, which implements all the dynamics matrix computation algorithms.

NOTE : CRobot will deallocate this pointer later.

CDynamicsBase* scl::CRobot::integrator_
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.

std::string scl::CRobot::log_file_name_
private

For logging stuff to a file.


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