3#include "controllers/impedance/Impedance.hpp" 
    4#include "state_representation/parameters/Parameter.hpp" 
    5#include "state_representation/space/cartesian/CartesianState.hpp" 
    6#include <eigen3/Eigen/Core> 
    7#include <eigen3/Eigen/Dense> 
    9namespace controllers::impedance {
 
   19enum class ComputationalSpaceType {
 
   20  LINEAR, ANGULAR, DECOUPLED_TWIST, FULL
 
   37  explicit Dissipative(
const ComputationalSpaceType& computational_space, 
unsigned int dimensions = 6);
 
   46      const std::list<std::shared_ptr<state_representation::ParameterInterface>>& parameters,
 
   47      const ComputationalSpaceType& computational_space, 
unsigned int dimensions = 6
 
   74  static Eigen::MatrixXd 
orthonormalize_basis(
const Eigen::MatrixXd& basis, 
const Eigen::VectorXd& main_eigenvector);
 
   92  std::shared_ptr<state_representation::Parameter<Eigen::VectorXd>>
 
  104    damping_eigenvalues_(
 
  106            "damping_eigenvalues", Eigen::ArrayXd::Ones(dimensions))),
 
  107    computational_space_(computational_space),
 
  108    basis_(Eigen::MatrixXd::Random(dimensions, dimensions)) {
 
  110  this->
stiffness_->set_value(Eigen::MatrixXd::Zero(dimensions, dimensions));
 
  112  this->
inertia_->set_value(Eigen::MatrixXd::Zero(dimensions, dimensions));
 
  114  this->
damping_->set_value(Eigen::MatrixXd::Identity(dimensions, dimensions));
 
  120    const std::list<std::shared_ptr<state_representation::ParameterInterface>>& parameters,
 
  121    const ComputationalSpaceType& computational_space, 
unsigned int dimensions
 
  129    const std::shared_ptr<state_representation::ParameterInterface>& parameter
 
  131  if (parameter->get_name() == 
"damping_eigenvalues") {
 
  132    this->damping_eigenvalues_->set_value(this->gain_matrix_from_parameter(parameter).diagonal());
 
  138    const Eigen::MatrixXd& basis, 
const Eigen::VectorXd& main_eigenvector
 
  140  Eigen::MatrixXd orthonormal_basis = basis;
 
  141  uint dim = basis.rows();
 
  142  orthonormal_basis.col(0) = main_eigenvector.normalized();
 
  143  for (uint i = 1; i < dim; i++) {
 
  144    for (uint j = 0; j < i; j++) {
 
  145      orthonormal_basis.col(i) -= orthonormal_basis.col(j).dot(orthonormal_basis.col(i)) * orthonormal_basis.col(j);
 
  147    orthonormal_basis.col(i).normalize();
 
  149  return orthonormal_basis;
 
  154    const S& command_state, 
const S& feedback_state
 
  157  this->compute_damping(command_state);
 
  164  this->basis_ = this->compute_orthonormal_basis(desired_velocity);
 
  165  auto diagonal_eigenvalues = this->damping_eigenvalues_->get_value().asDiagonal();
 
  166  this->damping_->set_value(this->basis_ * diagonal_eigenvalues * this->basis_.transpose());
 
Definition of a dissipative impedance controller (PassiveDS) in task space.
 
const ComputationalSpaceType computational_space_
the space in which to compute the command vector
 
Dissipative(const ComputationalSpaceType &computational_space, unsigned int dimensions=6)
Base constructor.
 
static Eigen::MatrixXd orthonormalize_basis(const Eigen::MatrixXd &basis, const Eigen::VectorXd &main_eigenvector)
Orthornormalize the basis matrix given in input wrt the main engenvector.
 
void validate_and_set_parameter(const std::shared_ptr< state_representation::ParameterInterface > ¶meter) override
Validate and set parameter for damping eigenvalues.
 
Eigen::MatrixXd basis_
basis matrix used to compute the damping matrix
 
std::shared_ptr< state_representation::Parameter< Eigen::VectorXd > > damping_eigenvalues_
coefficient of eigenvalues used in the damping matrix computation
 
S compute_command(const S &command_state, const S &feedback_state) override
Compute the force (task space) or torque (joint space) command based on the input state of the system...
 
Dissipative(const std::list< std::shared_ptr< state_representation::ParameterInterface > > ¶meters, const ComputationalSpaceType &computational_space, unsigned int dimensions=6)
Constructor from an initial parameter list.
 
void compute_damping(const S &desired_velocity)
Compute the damping matrix as the orthonormal basis to the direction of the desired velocity.
 
Eigen::MatrixXd compute_orthonormal_basis(const S &desired_velocity)
Compute the orthonormal basis based on the desired velocity input.
 
Definition of an impedance controller in either joint or task space.
 
std::shared_ptr< state_representation::Parameter< Eigen::MatrixXd > > stiffness_
stiffness matrix of the controller associated to position
 
std::shared_ptr< state_representation::Parameter< Eigen::MatrixXd > > inertia_
inertia matrix of the controller associated to acceleration
 
S compute_command(const S &command_state, const S &feedback_state) override
Compute the command output based on the commanded state and a feedback state To be redefined based on...
 
std::shared_ptr< state_representation::Parameter< Eigen::MatrixXd > > damping_
damping matrix of the controller associated to velocity
 
void set_parameters(const ParameterInterfaceList ¶meters)
Set parameters from a list of parameters.
 
ParameterInterfaceMap parameters_
map of parameters by name
 
Core state variables and objects.