#include <mc_solver/QPSolver.h>
Classes | |
struct | ControllerToken |
Public Types | |
enum | Backend { Backend::Unset, Backend::Tasks, Backend::TVM } |
Public Member Functions | |
QPSolver (mc_rbdyn::RobotsPtr robots, double timeStep, Backend backend) | |
QPSolver (double timeStep, Backend backend) | |
virtual | ~QPSolver ()=default |
Backend | backend () const noexcept |
void | addConstraintSet (ConstraintSet &cs) |
template<typename T > | |
void | addConstraintSet (const std::unique_ptr< T > &ptr) |
void | removeConstraintSet (ConstraintSet &cs) |
template<typename T > | |
void | removeConstraintSet (const std::unique_ptr< T > &ptr) |
void | addTask (mc_tasks::MetaTask *task) |
void | addTask (std::shared_ptr< mc_tasks::MetaTask > task) |
void | removeTask (mc_tasks::MetaTask *task) |
void | removeTask (std::shared_ptr< mc_tasks::MetaTask > task) |
void | setContacts (const std::vector< mc_rbdyn::Contact > &contacts={}) |
virtual void | setContacts (ControllerToken, const std::vector< mc_rbdyn::Contact > &contacts)=0 |
const std::vector< mc_rbdyn::Contact > & | contacts () const noexcept |
const std::vector< mc_solver::ConstraintSet * > & | constraints () const noexcept |
const std::vector< mc_tasks::MetaTask * > & | tasks () const noexcept |
virtual const sva::ForceVecd | desiredContactForce (const mc_rbdyn::Contact &id) const =0 |
bool | run (FeedbackType fType=FeedbackType::None) |
const mc_rbdyn::Robot & | robot () const |
mc_rbdyn::Robot & | robot () |
mc_rbdyn::Robot & | robot (unsigned int idx) |
const mc_rbdyn::Robot & | robot (unsigned int idx) const |
const mc_rbdyn::Robot & | env () const |
mc_rbdyn::Robot & | env () |
const mc_rbdyn::Robots & | robots () const |
mc_rbdyn::Robots & | robots () |
const mc_rbdyn::Robots & | realRobots () const |
mc_rbdyn::Robots & | realRobots () |
double | dt () const |
virtual double | solveTime ()=0 |
virtual double | solveAndBuildTime ()=0 |
void | logger (std::shared_ptr< mc_rtc::Logger > logger) |
std::shared_ptr< mc_rtc::Logger > | logger () const |
void | gui (std::shared_ptr< mc_rtc::gui::StateBuilder > gui) |
std::shared_ptr< mc_rtc::gui::StateBuilder > | gui () const |
void | controller (mc_control::MCController *ctl) noexcept |
const mc_control::MCController * | controller () const noexcept |
mc_control::MCController * | controller () noexcept |
Static Public Member Functions | |
static Backend | context_backend () |
static void | context_backend (Backend backend) |
Protected Member Functions | |
void | addTaskToGUI (mc_tasks::MetaTask *task) |
virtual bool | run_impl (FeedbackType fType=FeedbackType::None)=0 |
virtual void | addDynamicsConstraint (mc_solver::DynamicsConstraint *dynamics)=0 |
virtual void | removeDynamicsConstraint (mc_solver::ConstraintSet *maybe_dynamics)=0 |
Protected Attributes | |
Backend | backend_ |
mc_rbdyn::RobotsPtr | robots_p |
mc_rbdyn::RobotsPtr | realRobots_p |
double | timeStep |
std::vector< mc_rbdyn::Contact > | contacts_ |
std::vector< mc_tasks::MetaTask * > | metaTasks_ |
std::vector< std::shared_ptr< void > > | shPtrTasksStorage |
std::vector< mc_solver::ConstraintSet * > | constraints_ |
std::shared_ptr< mc_rtc::Logger > | logger_ = nullptr |
std::shared_ptr< mc_rtc::gui::StateBuilder > | gui_ = nullptr |
mc_control::MCController * | controller_ = nullptr |
Abstract base class for wrapping a solver
Always ensure that the solver is up-to-date
|
strong |
mc_solver::QPSolver::QPSolver | ( | mc_rbdyn::RobotsPtr | robots, |
double | timeStep, | ||
Backend | backend | ||
) |
Constructor
robots | Set of robots managed by this solver |
timeStep | Timestep of the solver |
mc_solver::QPSolver::QPSolver | ( | double | timeStep, |
Backend | backend | ||
) |
Constructor (the solver creates its own Robots instance)
timeStep | Timestep of the solver |
|
virtualdefault |
|
inline |
Add a constraint set
cs | Constraint set added to the solver |
void mc_solver::QPSolver::addConstraintSet | ( | ConstraintSet & | cs | ) |
Add a constraint set
cs | Constraint set added to the solver |
|
protectedpure virtual |
This is called when a dynamics constraint is added to the solver
void mc_solver::QPSolver::addTask | ( | mc_tasks::MetaTask * | task | ) |
Add a task to the solver
Adding the same task multiple times has no effect.
task | Pointer to an mc_tasks::MetaTask, QPSolver does not take ownership of this pointer. The MetaTask update function will be automatically called before the optimization is solved. |
|
inline |
Add a task to the solver, ownership is shared with the solver
|
protected |
|
inlinenoexcept |
Returns the backend for this solver instance
|
inlinenoexcept |
Returns the current set of constraints
|
inlinenoexcept |
Returns the current set of contacts
|
static |
Returns the current context backend
This should be set whenever constraints or tasks are about to be created and it is known they don't use the solver object and thus cannot determine the correct backend
For example:
|
static |
Set the current context backend
|
inlinenoexcept |
Returns the controller owning this instance (if any) (const)
|
inlinenoexcept |
Returns the controller owning this instance (if any)
|
inlinenoexcept |
Set the controller that is owning this QPSolver instance
|
pure virtual |
Desired resultant of contact force in robot surface frame
contact | Contact for which the force is desired. This contact must be one of the active contacts in the solver. |
Implemented in mc_solver::TasksQPSolver, and mc_solver::TVMQPSolver.
double mc_solver::QPSolver::dt | ( | ) | const |
Returns the timestep of the solver
mc_rbdyn::Robot& mc_solver::QPSolver::env | ( | ) |
Gives access to the environment robot in the solver (see mc_rbdyn::Robots)
const mc_rbdyn::Robot& mc_solver::QPSolver::env | ( | ) | const |
Gives access to the environment robot in the solver (see mc_rbdyn::Robots)
std::shared_ptr<mc_rtc::gui::StateBuilder> mc_solver::QPSolver::gui | ( | ) | const |
Access to the gui instance
void mc_solver::QPSolver::gui | ( | std::shared_ptr< mc_rtc::gui::StateBuilder > | gui | ) |
Set the GUI helper for this solver instance
std::shared_ptr<mc_rtc::Logger> mc_solver::QPSolver::logger | ( | ) | const |
Access to the logger instance
void mc_solver::QPSolver::logger | ( | std::shared_ptr< mc_rtc::Logger > | logger | ) |
Set the logger for this solver instance
mc_rbdyn::Robots& mc_solver::QPSolver::realRobots | ( | ) |
Gives access to the real robots used by this solver
const mc_rbdyn::Robots& mc_solver::QPSolver::realRobots | ( | ) | const |
Gives access to the real robots used by this solver
|
inline |
Remove a constraint set
cs | Constraint set removed from the solver |
void mc_solver::QPSolver::removeConstraintSet | ( | ConstraintSet & | cs | ) |
Remove a constraint set
cs | Constrain set removed from the solver |
|
protectedpure virtual |
This is called anytime a constraint is removed, the passed constraint is not always a dynamics constraint
void mc_solver::QPSolver::removeTask | ( | mc_tasks::MetaTask * | task | ) |
Remove a task from the solver
Removing a task that is not in the solver has no effect.
task | Pointer to an mc_tasks::MetaTask. The task will not be updated anymore and memory should be released by the task's owner. |
|
inline |
Remove a task from the solver which was shared with the solver
mc_rbdyn::Robot& mc_solver::QPSolver::robot | ( | ) |
Gives access to the main robot in the solver
const mc_rbdyn::Robot& mc_solver::QPSolver::robot | ( | ) | const |
Gives access to the main robot in the solver
mc_rbdyn::Robot& mc_solver::QPSolver::robot | ( | unsigned int | idx | ) |
Gives access to the robot with the given index in the solver
const mc_rbdyn::Robot& mc_solver::QPSolver::robot | ( | unsigned int | idx | ) | const |
Gives access to the robot with the given index in the solver
mc_rbdyn::Robots& mc_solver::QPSolver::robots | ( | ) |
Gives access to the robots controlled by this solver
const mc_rbdyn::Robots& mc_solver::QPSolver::robots | ( | ) | const |
Gives access to the robots controlled by this solver
bool mc_solver::QPSolver::run | ( | FeedbackType | fType = FeedbackType::None | ) |
Run one iteration of the QP.
If succesful, will update the robots' configurations
fType | Type of feedback used to close the loop on sensory information |
|
protectedpure virtual |
Should run the control prroblem and update the control robot accordingly
void mc_solver::QPSolver::setContacts | ( | const std::vector< mc_rbdyn::Contact > & | contacts = {} | ) |
Reset all contacts in the solver and use the new set of contacts provided \item contact Set of mc_rbdyn::Contact
|
pure virtual |
Implemented in mc_solver::TasksQPSolver, and mc_solver::TVMQPSolver.
|
pure virtual |
Returns the building and solving time in ms
Implemented in mc_solver::TasksQPSolver, and mc_solver::TVMQPSolver.
|
pure virtual |
Returns the solving time in ms
Implemented in mc_solver::TasksQPSolver, and mc_solver::TVMQPSolver.
|
inlinenoexcept |
Returns the MetaTasks currently in the solver
|
protected |
|
protected |
Holds ConstraintSet currently in the solver
|
protected |
Holds mc_rbdyn::Contact in the solver
|
protected |
Can be nullptr if this not associated to any controller
|
protected |
Pointer to the GUI helper
|
protected |
Pointer to the Logger
|
protected |
Holds MetaTask currently in the solver
|
protected |
|
protected |
|
protected |
Storage for shared_pointer on tasks
|
protected |