RcsPySim
A robot control and simulation library
Rcs::ActionModelIK Class Reference

#include <ActionModelIK.h>

Inheritance diagram for Rcs::ActionModelIK:
Collaboration diagram for Rcs::ActionModelIK:

Public Member Functions

 ActionModelIK (RcsGraph *graph)
 
 ActionModelIK (RcsGraph *graph, std::vector< Task *> tasks)
 
virtual ~ActionModelIK ()
 
virtual void reset ()
 
const ControllerBase * getController () const
 
RcsGraph * getDesiredGraph () const
 
void setDesiredGraph (RcsGraph *newGraph)
 
void setupCollisionModel (const RcsCollisionMdl *modelToCopy)
 
void computeIK (MatNd *q_des, MatNd *q_dot_des, MatNd *T_des, const MatNd *x_des, double dt)
 
void computeIKVel (MatNd *q_des, MatNd *q_dot_des, MatNd *T_des, const MatNd *x_dot_des, double dt)
 
- Public Member Functions inherited from Rcs::ActionModel
 ActionModel (RcsGraph *graph)
 
virtual ~ActionModel ()
 
ActionModelclone () const
 
virtual ActionModelclone (RcsGraph *newGraph) const =0
 
virtual void computeCommand (MatNd *q_des, MatNd *q_dot_des, MatNd *T_des, const MatNd *action, double dt)=0
 
virtual void getStableAction (MatNd *action) const =0
 
RcsGraph * getGraph ()
 
void setGraph (RcsGraph *newGraph)
 
virtual ActionModelgetWrappedActionModel () const
 
const ActionModelunwrapAll () const
 
ActionModelunwrapAll ()
 
template<typename AM >
const AM * unwrap () const
 
template<typename AM >
AM * unwrap ()
 
- Public Member Functions inherited from Rcs::BoxSpaceProvider
 BoxSpaceProvider ()
 
virtual ~BoxSpaceProvider ()
 
 BoxSpaceProvider (const BoxSpaceProvider &)=delete
 
BoxSpaceProvideroperator= (const BoxSpaceProvider &)=delete
 
 BoxSpaceProvider (BoxSpaceProvider &&)=delete
 
BoxSpaceProvideroperator= (BoxSpaceProvider &&)=delete
 
const BoxSpacegetSpace () const
 
virtual unsigned int getDim () const =0
 
virtual void getMinMax (double *min, double *max) const =0
 
virtual std::vector< std::string > getNames () const
 

Protected Member Functions

void addTask (Task *task)
 
void addFixedTask (Task *task, MatNd *value)
 
unsigned int getNumActiveTasks () const
 
void ikFromDX (MatNd *q_des, MatNd *q_dot_des, double dt) const
 

Protected Attributes

RcsGraph * desiredGraph
 
RcsCollisionMdl * collisionMdl
 
MatNd * dx_des
 
MatNd * dH
 
MatNd * dq_ref
 
- Protected Attributes inherited from Rcs::ActionModel
RcsGraph * graph
 

Private Attributes

ControllerBase * controller
 
IkSolverRMR * solver
 
double alpha = 1e-4
 
double lambda = 1e-6
 
MatNd * fixedTasksValues
 
unsigned int dimFixedTasks
 

Friends

class AMIKGeneric
 

Detailed Description

Base class for IK-based action models.

This class encapsulates a Rcs ControllerBase object as well as an inverse kinematics solver.

To use this, create a subclass and add your tasks in the constructor. Then, use computeIK(...) to invoke the solver.

In order to facilitate stable kinematics, the joint space error returned by the IK solver is integrated into the desired joint states ignoring the current measurements. To faciliate this, the ControllerBase object contains a copy of the main RcsGraph. Thus, all IK tasks should use this graph.

Definition at line 52 of file ActionModelIK.h.

Constructor & Destructor Documentation

◆ ActionModelIK() [1/2]

Rcs::ActionModelIK::ActionModelIK ( RcsGraph *  graph)
explicit

Create an empty IK-based action model. Tasks must be added to the controller before the first reset() call.

Parameters
graphcurrent state graph

Definition at line 122 of file ActionModelIK.cpp.

◆ ActionModelIK() [2/2]

Rcs::ActionModelIK::ActionModelIK ( RcsGraph *  graph,
std::vector< Task *>  tasks 
)
explicit

Create an IK based action model using a fixed set of tasks.

Parameters
graphcurrent state graph
taskscontroller tasks to use

Definition at line 144 of file ActionModelIK.cpp.

◆ ~ActionModelIK()

Rcs::ActionModelIK::~ActionModelIK ( )
virtual

Definition at line 154 of file ActionModelIK.cpp.

Member Function Documentation

◆ addFixedTask()

void Rcs::ActionModelIK::addFixedTask ( Task *  task,
MatNd *  value 
)
protected

Add Rcs controller tasks that is always fixed to one target value. Do this after adding the regular tasks.

Definition at line 283 of file ActionModelIK.cpp.

◆ addTask()

void Rcs::ActionModelIK::addTask ( Task *  task)
protected

Add a task to the controller. This works exactly as getController()->addTask() would. However, tasks may only be added before the first reset() call. Thus, getController() returns a const reference, and this method makes sure reset has not been called yet.

Parameters
[in]tasktask to add. Takes ownership.

Definition at line 165 of file ActionModelIK.cpp.

◆ computeIK()

void Rcs::ActionModelIK::computeIK ( MatNd *  q_des,
MatNd *  q_dot_des,
MatNd *  T_des,
const MatNd *  x_des,
double  dt 
)

Compute IK solution from desired task space state.

Parameters
[out]q_desresulting desired joint positions
[out]q_dot_desresulting desired joint velocities
[out]T_desresulting desired joint torques
[in]x_desdesired task space state
[in]dttime step since the last call

Definition at line 191 of file ActionModelIK.cpp.

◆ computeIKVel()

void Rcs::ActionModelIK::computeIKVel ( MatNd *  q_des,
MatNd *  q_dot_des,
MatNd *  T_des,
const MatNd *  x_dot_des,
double  dt 
)

Compute IK solution from desired task space velocity.

Parameters
[out]q_desresulting desired joint positions
[out]q_dot_desresulting desired joint velocities
[out]T_desresulting desired joint torques
[in]x_dot_desdesired task space velocity
[in]dttime step since the last call

Definition at line 200 of file ActionModelIK.cpp.

◆ getController()

const ControllerBase* Rcs::ActionModelIK::getController ( ) const
inline

Exposes a const reference to the controller object. This is readonly since modifying the controller could break the solver.

Definition at line 76 of file ActionModelIK.h.

◆ getDesiredGraph()

RcsGraph * Rcs::ActionModelIK::getDesiredGraph ( ) const

The graph holding the desired state of the IK solver.

Definition at line 262 of file ActionModelIK.cpp.

◆ getNumActiveTasks()

unsigned int Rcs::ActionModelIK::getNumActiveTasks ( ) const
protected

Definition at line 298 of file ActionModelIK.cpp.

◆ ikFromDX()

void Rcs::ActionModelIK::ikFromDX ( MatNd *  q_des,
MatNd *  q_dot_des,
double  dt 
) const
protected

Definition at line 210 of file ActionModelIK.cpp.

◆ reset()

void Rcs::ActionModelIK::reset ( )
virtual

Called at the start of a rollout to reset any state modified by computeCommand(). This allows to reuse the ActionModel for a new simulation rollout. The graph state will already be reset, so it can be used safely. It will be called before the first rollout too, so it can also be used to setup internals that depend on operations in subclass constructors.

Reimplemented from Rcs::ActionModel.

Reimplemented in Rcs::AMIKControllerActivation, and Rcs::AMPlateAngPos.

Definition at line 175 of file ActionModelIK.cpp.

◆ setDesiredGraph()

void Rcs::ActionModelIK::setDesiredGraph ( RcsGraph *  newGraph)

Definition at line 267 of file ActionModelIK.cpp.

◆ setupCollisionModel()

void Rcs::ActionModelIK::setupCollisionModel ( const RcsCollisionMdl *  modelToCopy)

Setup collision avoidance in the IK.

Will use a copy of the given collision model which operates on the desired graph.

Parameters
modelToCopycollision model to copy

Definition at line 272 of file ActionModelIK.cpp.

Friends And Related Function Documentation

◆ AMIKGeneric

friend class AMIKGeneric
friend

Definition at line 141 of file ActionModelIK.h.

Member Data Documentation

◆ alpha

double Rcs::ActionModelIK::alpha = 1e-4
private

Scaling factor for the nullspace gradient.

Definition at line 148 of file ActionModelIK.h.

◆ collisionMdl

RcsCollisionMdl* Rcs::ActionModelIK::collisionMdl
protected

Definition at line 129 of file ActionModelIK.h.

◆ controller

ControllerBase* Rcs::ActionModelIK::controller
private

Holder for the IK tasks (owned)

Definition at line 144 of file ActionModelIK.h.

◆ desiredGraph

RcsGraph* Rcs::ActionModelIK::desiredGraph
protected

Definition at line 126 of file ActionModelIK.h.

◆ dH

MatNd* Rcs::ActionModelIK::dH
protected

Definition at line 136 of file ActionModelIK.h.

◆ dimFixedTasks

unsigned int Rcs::ActionModelIK::dimFixedTasks
private

Store the cumulative number of task dimensions which are fixed to one target value.

Definition at line 154 of file ActionModelIK.h.

◆ dq_ref

MatNd* Rcs::ActionModelIK::dq_ref
protected

Definition at line 137 of file ActionModelIK.h.

◆ dx_des

MatNd* Rcs::ActionModelIK::dx_des
protected

Definition at line 135 of file ActionModelIK.h.

◆ fixedTasksValues

MatNd* Rcs::ActionModelIK::fixedTasksValues
private

Store the target values of all fixed tasks.

Definition at line 152 of file ActionModelIK.h.

◆ lambda

double Rcs::ActionModelIK::lambda = 1e-6
private

Regularization factor for the task space weighting.

Definition at line 150 of file ActionModelIK.h.

◆ solver

IkSolverRMR* Rcs::ActionModelIK::solver
private

IK solver (owned)

Definition at line 146 of file ActionModelIK.h.


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