XBotInterface  2.4.1
XBotInterface provides a generic API to model and control a robot.
ModelInterface.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 IIT-ADVR
3  * Author: Arturo Laurenzi, Luca Muratore
4  * email: arturo.laurenzi@iit.it, luca.muratore@iit.it
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>
18  *
19  * NOTE: implementation of the jacobian derivative was adapted from KDL::ChainJntToJacDotSolver
20  */
21 
22 #ifndef __MODEL_INTERFACE_H__
23 #define __MODEL_INTERFACE_H__
24 
25 
26 #include <vector>
27 #include <map>
28 
29 #include <Eigen/Geometry>
30 #include <kdl/frames.hpp>
31 #include <kdl/jacobian.hpp>
32 #include <eigen_conversions/eigen_kdl.h>
33 
36 
37 namespace XBot {
38 
39 class RobotInterface;
40 
46 class ModelInterface : public XBotInterface {
47 
48 public:
49 
50 
51  friend XBot::RobotInterface;
52 
56  typedef std::shared_ptr<ModelInterface> Ptr;
57 
61  typedef std::shared_ptr<const ModelInterface> ConstPtr;
62 
63  // ModelInterface must be default constructible and non-copyable
64  ModelInterface() = default;
65  ModelInterface& operator=(const ModelInterface& other) = delete;
66  ModelInterface(const ModelInterface& other) = delete;
67 
68 
79  static ModelInterface::Ptr getModel(const ConfigOptions& config);
80 
91  static ModelInterface::Ptr getModel(const std::string& path_to_cfg, AnyMapConstPtr any_map = AnyMapConstPtr());
92 
93 
102  ModelChain& chain(const std::string& chain_name);
103  const ModelChain& chain(const std::string& chain_name) const;
104 
113  ModelChain& operator()(const std::string& chain_name);
114  const ModelChain& operator()(const std::string& chain_name) const;
115 
125  ModelChain& arm(int arm_id);
126  const ModelChain& arm(int arm_id) const;
127 
137  ModelChain& leg(int leg_id);
138  const ModelChain& leg(int leg_id) const;
139 
170  template <typename... SyncFlags>
171  bool syncFrom(const XBotInterface& other, SyncFlags... flags);
172 
173 
200  template <typename... SyncFlags>
201  bool syncFrom_no_update(const XBotInterface& other, SyncFlags... flags);
202 
212  bool update( bool update_position = true,
213  bool update_velocity = true,
214  bool update_desired_acceleration = true );
215 
223  virtual void getModelOrderedJoints( std::vector<std::string>& joint_name ) const = 0;
224 
231  int getActuatedJointNum() const;
232 
238  bool isFloatingBase() const;
239 
247  virtual bool setFloatingBasePose( const KDL::Frame& floating_base_pose ) = 0;
248 
256  bool setFloatingBaseOrientation( const KDL::Rotation& world_R_floating_base );
257 
264  bool getFloatingBasePose( KDL::Frame& floating_base_pose ) const;
265 
273  virtual bool setFloatingBaseTwist( const KDL::Twist& floating_base_twist ) = 0;
274 
282  bool setFloatingBaseAngularVelocity( const KDL::Vector& floating_base_omega );
283 
292  bool setFloatingBaseState( const KDL::Frame& pose, const KDL::Twist& twist );
293 
303  bool setFloatingBaseState( XBot::ImuSensor::ConstPtr imu, const Eigen::Matrix3d& offset = Eigen::Matrix3d::Identity());
304 
311  bool getFloatingBaseTwist( KDL::Twist& floating_base_twist ) const;
312 
319  virtual bool getFloatingBaseLink( std::string& floating_base_link) const = 0;
320 
329  virtual bool getPose( const std::string& source_frame,
330  KDL::Frame& pose ) const = 0;
331 
341  bool getPose( const std::string& source_frame,
342  const std::string& target_frame,
343  KDL::Frame& pose ) const;
344 
353  bool getOrientation(const std::string& source_frame,
354  KDL::Rotation& orientation) const;
355 
365  bool getOrientation(const std::string& source_frame,
366  const std::string& target_frame,
367  KDL::Rotation& orientation) const;
368 
369 
378  bool getPointPosition(const std::string& source_frame,
379  const KDL::Vector& source_point,
380  KDL::Vector& world_point) const;
381 
391  bool getPointPosition(const std::string& source_frame,
392  const std::string& target_frame,
393  const KDL::Vector& source_point,
394  KDL::Vector& target_point) const;
404  virtual bool getJacobian( const std::string& link_name,
405  const KDL::Vector& reference_point,
406  KDL::Jacobian& J) const = 0;
407 
416  bool getJacobian( const std::string& link_name,
417  KDL::Jacobian& J) const;
418 
430  bool getJacobian( const std::string& link_name,
431  const std::string& target_frame,
432  KDL::Jacobian& J) const;
433 
442  void getPosturalJacobian(Eigen::MatrixXd& J) const;
443 
453  virtual bool getRelativeJacobian( const std::string& target_link_name,
454  const std::string& base_link_name,
455  KDL::Jacobian& J) const;
456 
465  virtual bool getVelocityTwist( const std::string& link_name,
466  KDL::Twist& velocity) const = 0;
467 
478  bool getRelativeVelocityTwist( const std::string& link_name, const std::string& base_link_name,
479  KDL::Twist& velocity) const;
480 
491  virtual bool getVelocityTwist( const std::string& source_frame,
492  const std::string& target_frame,
493  KDL::Twist& velocity) const;
494 
503  virtual bool getAccelerationTwist( const std::string& link_name,
504  KDL::Twist& acceleration) const = 0;
505 
514  virtual bool getRelativeAccelerationTwist(const std::string& link_name, const std::string& base_link_name,
515  KDL::Twist& acceleration) const = 0;
516 
517 
526  virtual bool getPointAcceleration(const std::string& link_name,
527  const KDL::Vector& point,
528  KDL::Vector& acceleration) const = 0;
529 
539  virtual bool computeJdotQdot(const std::string& link_name,
540  const KDL::Vector& point,
541  KDL::Twist& jdotqdot) const;
542 
551  virtual bool computeRelativeJdotQdot(const std::string& target_link_name,
552  const std::string& base_link_name,
553  KDL::Twist& jdotqdot) const = 0;
554 
561  virtual void getCOM( KDL::Vector& com_position ) const = 0;
562 
570  bool getCOM( const std::string& reference_frame,
571  KDL::Vector& com_position ) const;
572 
573 
584  virtual void getCOMJacobian( KDL::Jacobian& J, KDL::Vector& dJcomQdot) const;
585 
586 
595  virtual void getCOMJacobian( KDL::Jacobian& J) const;
596 
603  virtual void getCOMVelocity( KDL::Vector& velocity) const = 0;
604 
611  virtual void getCOMAcceleration( KDL::Vector& acceleration) const = 0;
612 
613 
621  virtual void getCentroidalMomentum(Eigen::Vector6d& centroidal_momentum) const = 0;
622 
631  virtual void getCentroidalMomentumMatrix(Eigen::MatrixXd& centroidal_momentum_matrix,
632  Eigen::Vector6d& CMMdotQdot) const;
633 
641  virtual void getCentroidalMomentumMatrix(Eigen::MatrixXd& centroidal_momentum_matrix) const;
642 
647  virtual double getMass() const = 0;
648 
649 
656  virtual void getGravity( KDL::Vector& gravity ) const = 0;
657 
665  bool getGravity( const std::string& reference_frame,
666  KDL::Vector& gravity ) const;
673  virtual void setGravity( const KDL::Vector& gravity ) = 0;
674 
682  bool setGravity( const std::string& reference_frame,
683  const KDL::Vector& gravity );
684 
691  virtual void getInertiaMatrix(Eigen::MatrixXd& M) const = 0;
692 
699  virtual void getInertiaInverseTimesVector(const Eigen::VectorXd& vec, Eigen::VectorXd& minv_vec) const;
700 
707  virtual void getInertiaInverseTimesMatrix(const Eigen::MatrixXd& Mat, Eigen::MatrixXd& Minv_Mat) const;
708 
713  virtual void getInertiaInverse(Eigen::MatrixXd& Minv) const;
714 
715 
723  virtual void computeGravityCompensation( Eigen::VectorXd& g ) const = 0;
724 
732  virtual void computeNonlinearTerm( Eigen::VectorXd& n ) const = 0;
733 
740  virtual void computeInverseDynamics( Eigen::VectorXd& tau) const = 0;
741 
750  bool computeConstrainedInverseDynamics( const Eigen::MatrixXd& J, const Eigen::VectorXd& weights, Eigen::VectorXd& tau) const;
751 
760  bool getChainSelectionMatrix( const std::string& chain_name, Eigen::MatrixXd& S ) const;
761 
770  bool getJointSelectionMatrix( const std::string& joint_name, Eigen::RowVectorXd& S ) const;
771 
780  bool getJointSelectionMatrix( int joint_id, Eigen::RowVectorXd& S ) const;
781 
790  bool maskJacobian( const std::string& chain_name, KDL::Jacobian& J) const;
791 
792 
793  /*************************/
794  /**** EIGEN OVERLOADS ****/
795  /*************************/
796 
804  bool setFloatingBasePose( const Eigen::Affine3d& floating_base_pose );
805 
814  bool setFloatingBaseState( const Eigen::Affine3d& pose, const Eigen::Vector6d& twist );
815 
823  bool setFloatingBaseOrientation( const Eigen::Matrix3d& world_R_floating_base );
824 
832  virtual bool setFloatingBaseTwist( const Eigen::Vector6d& floating_base_twist );
833 
841  bool setFloatingBaseAngularVelocity( const Eigen::Vector3d& floating_base_omega );
842 
849  bool getFloatingBasePose( Eigen::Affine3d& floating_base_pose ) const;
850 
851 
858  bool getFloatingBaseTwist( Eigen::Vector6d& floating_base_twist ) const;
859 
869  bool getPose( const std::string& source_frame,
870  const std::string& target_frame,
871  Eigen::Affine3d& pose ) const;
880  bool getPose( const std::string& source_frame,
881  Eigen::Affine3d& pose ) const;
882 
891  bool getOrientation( const std::string& source_frame,
892  Eigen::Matrix3d& orientation) const;
902  bool getOrientation( const std::string& source_frame,
903  const std::string& target_frame,
904  Eigen::Matrix3d& orientation) const;
913  bool getPointPosition( const std::string& source_frame,
914  const Eigen::Vector3d& source_point,
915  Eigen::Vector3d& world_point) const;
916 
926  bool getPointPosition( const std::string& source_frame,
927  const std::string& target_frame,
928  const Eigen::Vector3d& source_point,
929  Eigen::Vector3d& target_point) const;
930 
939  bool getJacobian( const std::string& link_name,
940  Eigen::MatrixXd& J) const;
941 
953  bool getJacobian( const std::string& link_name,
954  const std::string& target_frame,
955  Eigen::MatrixXd& J) const;
956 
966  bool getJacobian( const std::string& link_name,
967  const Eigen::Vector3d& reference_point,
968  Eigen::MatrixXd& J) const;
969 
979  bool getRelativeJacobian( const std::string& target_link_name,
980  const std::string& base_link_name,
981  Eigen::MatrixXd& J) const;
982 
989  void getCOM( Eigen::Vector3d& com_position ) const;
990 
998  bool getCOM( const std::string& reference_frame,
999  Eigen::Vector3d& com_position ) const;
1000 
1011  virtual void getCOMJacobian( Eigen::MatrixXd& J, Eigen::Vector3d& dJcomQdot) const;
1012 
1021  void getCOMJacobian( Eigen::MatrixXd& J) const;
1022 
1029  void getCOMVelocity( Eigen::Vector3d& velocity) const;
1030 
1037  void getCOMAcceleration( Eigen::Vector3d& acceleration) const;
1038 
1049  bool getRelativeVelocityTwist( const std::string& link_name, const std::string& base_link_name,
1050  Eigen::Vector6d& velocity) const;
1051 
1060  bool getRelativeAccelerationTwist(const std::string& link_name, const std::string& base_link_name,
1061  Eigen::Vector6d& acceleration) const;
1062 
1071  bool getVelocityTwist( const std::string& link_name,
1072  Eigen::Vector6d& velocity) const;
1073 
1084  virtual bool getVelocityTwist( const std::string& source_frame,
1085  const std::string& target_frame,
1086  Eigen::Matrix<double,6,1>& velocity) const;
1087 
1096  bool getAccelerationTwist( const std::string& link_name,
1097  Eigen::Vector6d& acceleration) const;
1098 
1107  bool getPointAcceleration(const std::string& link_name,
1108  const Eigen::Vector3d& point,
1109  Eigen::Vector3d& acceleration) const;
1110 
1120  bool computeJdotQdot(const std::string& link_name,
1121  const Eigen::Vector3d& point,
1122  Eigen::Vector6d& jdotqdot) const;
1123 
1132  bool computeRelativeJdotQdot(const std::string& target_link_name,
1133  const std::string& base_link_name,
1134  Eigen::Vector6d& jdotqdot) const;
1135 
1142  void getGravity( Eigen::Vector3d& gravity ) const;
1143 
1151  bool getGravity( const std::string& reference_frame,
1152  Eigen::Vector3d& gravity ) const;
1153 
1160  void setGravity( const Eigen::Vector3d& gravity );
1161 
1169  bool setGravity( const std::string& reference_frame,
1170  const Eigen::Vector3d& gravity );
1171 
1180  bool maskJacobian( const std::string& chain_name, Eigen::MatrixXd& J) const;
1181 
1187  virtual int getLinkID(const std::string& link_name) const = 0;
1188 
1189 
1190  // Getters for RX
1191 
1200 
1201 
1202  // Setters for RX
1203 
1210 
1213 
1214 
1215 protected:
1216 
1217  virtual bool init_internal(const ConfigOptions& config);
1218  virtual bool init_model(const ConfigOptions& config) = 0;
1219  virtual bool update_internal( bool update_position,
1220  bool update_velocity,
1221  bool update_desired_acceleration) = 0;
1222 
1223  inline void rotationEigenToKDL(const Eigen::Matrix3d& eigen_rotation, KDL::Rotation& kdl_rotation) const;
1224  inline void rotationKDLToEigen(const KDL::Rotation& kdl_rotation, Eigen::Matrix3d& eigen_rotation) const;
1225 
1227 
1228 private:
1229 
1230 
1231 
1232 
1235  std::map<std::string, XBot::ModelChain::Ptr> _model_chain_map;
1236  XBot::ModelChain _dummy_chain;
1237 
1239  std::map<int, int> _joint_id_to_model_id;
1240 
1241  bool fillModelOrderedChain();
1242 
1243  mutable KDL::Twist _tmp_kdl_twist;
1244  mutable KDL::Frame _tmp_kdl_frame, _tmp_kdl_frame_1;
1245  mutable KDL::Jacobian _tmp_kdl_jacobian, _tmp_kdl_jacobian_1;
1246  mutable KDL::Vector _tmp_kdl_vector, _tmp_kdl_vector_1;
1247  mutable KDL::Rotation _tmp_kdl_rotation, _tmp_kdl_rotation_1;
1248  mutable std::vector<int> _tmp_int_vector;
1249  mutable std::string _floating_base_link;
1250  mutable Eigen::MatrixXd _tmp_postural_jacob;
1251  mutable Eigen::MatrixXd _tmp_inertia;
1252  mutable Eigen::MatrixXd _tmp_inverse_inertia;
1253  mutable Eigen::VectorXd _tmp_inv_inertia_vec;
1254  mutable Eigen::MatrixXd _tmp_jacobian, _tmp_cmm, _tmp_jacobiandot;
1255  mutable Eigen::MatrixXd _tmp_M;
1256  mutable Eigen::MatrixXd _tmp_I;
1257  mutable Eigen::VectorXd _tmp_gcomp, _tmp_h, _tmp_jstate, _M_col;
1258  mutable Eigen::MatrixXd _tmp_jacobian_relative;
1259  mutable Eigen::Vector6d _tmp_jdot_qdot;
1260  mutable bool _compute_inverse_inertia;
1261 
1264 
1265  // Getters for TX
1266 
1270 
1271 
1272  // Setters for TX
1273 
1277 
1278 
1280 
1281  using XBotInterface::sync;
1282 
1283  void seekAndDestroyFixedControlledJoints();
1284 
1285 };
1286 };
1287 
1288 
1289 // NOTE we should put all the utils function in an hpp file with a proper namespace.
1290 
1291 
1292 inline void XBot::ModelInterface::rotationEigenToKDL(const Eigen::Matrix3d& eigen_rotation, KDL::Rotation& kdl_rotation) const
1293 {
1294  for(int i = 0; i < 3; i++){
1295  for(int j = 0; j < 3; j++){
1296  kdl_rotation.data[3*i+j] = eigen_rotation(i,j);
1297  }
1298  }
1299 }
1300 
1301 inline void XBot::ModelInterface::rotationKDLToEigen(const KDL::Rotation& kdl_rotation, Eigen::Matrix3d& eigen_rotation) const
1302 {
1303  for(int i = 0; i < 3; i++){
1304  for(int j = 0; j < 3; j++){
1305  eigen_rotation(i,j) = kdl_rotation.data[3*i+j];
1306  }
1307  }
1308 }
1309 
1310 template <typename... SyncFlags>
1311 bool XBot::ModelInterface::syncFrom(const XBot::XBotInterface& other, SyncFlags... flags)
1312 {
1313  if( XBot::XBotInterface::sync(other, flags...) ){
1314  update(true, true, true);
1315  return true;
1316  }
1317  else{
1318  return false;
1319  }
1320 }
1321 
1322 template <typename... SyncFlags>
1324 {
1325  if( XBot::XBotInterface::sync(other, flags...) ){
1326  update(true, true, true);
1327  return true;
1328  }
1329  else{
1330  return false;
1331  }
1332 }
1333 
1334 
1335 #endif // __MODEL_INTERFACE_H__
1336 
XBot::ModelInterface::getLinkID
virtual int getLinkID(const std::string &link_name) const =0
getLinkID return the link ID
XBot::XBotInterface::setDamping
bool setDamping(const Eigen::VectorXd &D)
Sets the XBotInterface internal joint damping according to the provided vector, which must be ordered...
Definition: XBotInterface.cpp:1008
XBot::ModelInterface::getActuatedJointNum
int getActuatedJointNum() const
Gets the number of actuated joints in the model, i.e.
Definition: ModelInterface.cpp:874
XBot::ModelInterface::getPose
virtual bool getPose(const std::string &source_frame, KDL::Frame &pose) const =0
Computes the pose of the source_frame w.r.t.
XBot::ConfigOptions
Definition: ConfigOptions.h:36
XBot::XBotInterface::getJointEffort
bool getJointEffort(Eigen::VectorXd &tau) const
Gets the robot joint efforts as an Eigen vector.
Definition: XBotInterface.cpp:740
XBot::ModelInterface::rotationEigenToKDL
void rotationEigenToKDL(const Eigen::Matrix3d &eigen_rotation, KDL::Rotation &kdl_rotation) const
Definition: ModelInterface.h:1292
XBot::XBotInterface::getEffortReference
bool getEffortReference(Eigen::VectorXd &tau) const
Gets the robot effort references as an Eigen vector.
Definition: XBotInterface.cpp:751
XBot::XBotInterface::getMotorPosition
bool getMotorPosition(Eigen::VectorXd &q) const
Gets the robot motor positions as an Eigen vector.
Definition: XBotInterface.cpp:786
XBot::ModelInterface::getModelOrderedJoints
virtual void getModelOrderedJoints(std::vector< std::string > &joint_name) const =0
Gets a vector with the joint names ordered according to the model.
XBot::XBotInterface::getJointPosition
bool getJointPosition(Eigen::VectorXd &q) const
Gets the robot joint positions as an Eigen vector.
Definition: XBotInterface.cpp:348
XBot::ModelInterface::Ptr
std::shared_ptr< ModelInterface > Ptr
Shared pointer to a ModelInterface.
Definition: ModelInterface.h:56
XBot::XBotInterface::_chain_map
std::map< std::string, XBot::KinematicChain::Ptr > _chain_map
Definition: XBotInterface.h:1382
XBot::ModelInterface::update_internal
virtual bool update_internal(bool update_position, bool update_velocity, bool update_desired_acceleration)=0
XBot::XBotInterface::getMotorVelocity
bool getMotorVelocity(Eigen::VectorXd &qdot) const
Gets the robot motor velocities as an Eigen vector.
Definition: XBotInterface.cpp:797
XBot::ModelInterface::getFloatingBaseTwist
bool getFloatingBaseTwist(KDL::Twist &floating_base_twist) const
Gets the floating base twist w.r.t.
Definition: ModelInterface.cpp:918
XBot::ModelInterface::computeGravityCompensation
virtual void computeGravityCompensation(Eigen::VectorXd &g) const =0
Computes gravity compensation torques.
XBot::ModelInterface::operator()
ModelChain & operator()(const std::string &chain_name)
Returns a handle to the kinematic chain named chain_name.
Definition: ModelInterface.cpp:234
XBot::XBotInterface::setJointPosition
bool setJointPosition(const Eigen::VectorXd &q)
Sets the XBotInterface internal joint positions according to the provided vector, which must be order...
Definition: XBotInterface.cpp:1050
XBot::ModelInterface::getModel
static ModelInterface::Ptr getModel(const ConfigOptions &config)
Factory method for generating instances of the ModelInterface class according to the provided configu...
Definition: ModelInterface.cpp:39
XBot::ModelInterface::operator=
ModelInterface & operator=(const ModelInterface &other)=delete
XBot::ModelInterface::setFloatingBaseOrientation
bool setFloatingBaseOrientation(const KDL::Rotation &world_R_floating_base)
Sets the floating base orientation w.r.t.
Definition: ModelInterface.cpp:983
XBot::XBotInterface::getTemperature
bool getTemperature(Eigen::VectorXd &temp) const
Gets the robot joint temperatures as an Eigen vector.
Definition: XBotInterface.cpp:819
XBot::XBotInterface::_ordered_chain_names
std::vector< std::string > _ordered_chain_names
Definition: XBotInterface.h:1391
XBot::XBotInterface::setStiffness
bool setStiffness(const Eigen::VectorXd &K)
Sets the XBotInterface internal joint stiffness according to the provided vector, which must be order...
Definition: XBotInterface.cpp:1135
XBot::ModelInterface::getInertiaInverseTimesMatrix
virtual void getInertiaInverseTimesMatrix(const Eigen::MatrixXd &Mat, Eigen::MatrixXd &Minv_Mat) const
getInertiaInverseTimesMatrix Computes the inverse of the Inertia Matrix times a given matrix
Definition: ModelInterface.cpp:1059
ModelChain.h
XBot::XBotInterface::setMotorPosition
bool setMotorPosition(const Eigen::VectorXd &q)
Sets the XBotInterface internal motor positions according to the provided vector, which must be order...
Definition: XBotInterface.cpp:1093
XBot::ModelInterface::getJacobian
virtual bool getJacobian(const std::string &link_name, const KDL::Vector &reference_point, KDL::Jacobian &J) const =0
Gets the Jacobian of link_name expressed in the world frame, i.e a matrix such that its product with ...
XBot::XBotInterface::sync
bool sync(const XBotInterface &other, SyncFlags... flags)
Synchronize the current XBotInterface with another XBotInterface object: only the common chains will ...
Definition: XBotInterface.h:1421
XBot::ModelInterface::setFloatingBaseState
bool setFloatingBaseState(const KDL::Frame &pose, const KDL::Twist &twist)
Sets the floating base pose and twist w.r.t.
Definition: ModelInterface.cpp:1121
XBot::XBotInterface::getDamping
bool getDamping(Eigen::VectorXd &D) const
Gets the robot damping as an Eigen vector.
Definition: XBotInterface.cpp:729
XBot::ModelInterface::getCOMJacobian
virtual void getCOMJacobian(KDL::Jacobian &J, KDL::Vector &dJcomQdot) const
Gets the COM Jacobian expressed in the world frame and the d(Jcom)/dt * qdot term,...
Definition: ModelInterface.cpp:1042
XBot::XBotInterface::getVelocityReference
bool getVelocityReference(Eigen::VectorXd &qdot) const
Gets the robot velocity references as an Eigen vector.
Definition: XBotInterface.cpp:830
Eigen::Vector6d
Eigen::Matrix< double, 6, 1 > Vector6d
Typedef for a 6 element column vector of double.
Definition: TypedefAndEnums.h:132
XBot::ModelInterface::getCOMVelocity
virtual void getCOMVelocity(KDL::Vector &velocity) const =0
Gets the COM velocity expressed in the world frame.
XBot::XBotInterface::setJointVelocity
bool setJointVelocity(const Eigen::VectorXd &qdot)
Sets the XBotInterface internal joint velocities according to the provided vector,...
Definition: XBotInterface.cpp:1064
XBot::ModelInterface::syncFrom
bool syncFrom(const XBotInterface &other, SyncFlags... flags)
Synchronizes the internal model state to the one of the XBotInterface given as an argument.
Definition: ModelInterface.h:1311
XBot::ModelInterface::getJointSelectionMatrix
bool getJointSelectionMatrix(const std::string &joint_name, Eigen::RowVectorXd &S) const
Gets a selection matrix for the requested joint, i.e.
Definition: ModelInterface.cpp:778
XBot::ModelInterface::getFloatingBasePose
bool getFloatingBasePose(KDL::Frame &floating_base_pose) const
Gets the floating base pose w.r.t.
Definition: ModelInterface.cpp:909
XBot::ModelInterface::init_model
virtual bool init_model(const ConfigOptions &config)=0
XBot::ModelInterface::getPosturalJacobian
void getPosturalJacobian(Eigen::MatrixXd &J) const
Gets the Jacacobian matrix corresponding to a joint-space postural task, i.e.
Definition: ModelInterface.cpp:861
XBot::XBotInterface::getChainMap
const std::map< std::string, XBot::KinematicChain::Ptr > & getChainMap() const
Getter for the chain map inside the XBotInterface.
Definition: XBotInterface.cpp:1389
XBot::ModelInterface::getVelocityTwist
virtual bool getVelocityTwist(const std::string &link_name, KDL::Twist &velocity) const =0
Gets the velocity twist of link_name (first linear, then angular velocity).
XBot::ModelInterface::ConstPtr
std::shared_ptr< const ModelInterface > ConstPtr
Shared pointer to const ModelInterface.
Definition: ModelInterface.h:61
XBot::XBotInterface::setJointEffort
bool setJointEffort(const Eigen::VectorXd &tau)
Sets the XBotInterface internal joint efforts according to the provided vector, which must be ordered...
Definition: XBotInterface.cpp:1022
XBotInterface.h
XBot::ModelInterface::getGravity
virtual void getGravity(KDL::Vector &gravity) const =0
Gets the gravity vector expressed in the world frame.
XBot::ModelInterface::getPointPosition
bool getPointPosition(const std::string &source_frame, const KDL::Vector &source_point, KDL::Vector &world_point) const
Gets the position in world coordinates for a source_point expressed w.r.t.
Definition: ModelInterface.cpp:560
XBot::ModelInterface::computeInverseDynamics
virtual void computeInverseDynamics(Eigen::VectorXd &tau) const =0
Computes inverse dynamics.
XBot::ModelInterface::getChainSelectionMatrix
bool getChainSelectionMatrix(const std::string &chain_name, Eigen::MatrixXd &S) const
Gets a selection matrix for the requested chain, i.e.
Definition: ModelInterface.cpp:750
XBot::ModelInterface::getFloatingBaseLink
virtual bool getFloatingBaseLink(std::string &floating_base_link) const =0
Gets the name of the floating base link.
XBot::XBotInterface::setJointAcceleration
bool setJointAcceleration(const Eigen::VectorXd &qddot)
Sets the XBotInterface internal joint accelerations according to the provided vector,...
Definition: XBotInterface.cpp:1078
XBot::ModelInterface::getRelativeAccelerationTwist
virtual bool getRelativeAccelerationTwist(const std::string &link_name, const std::string &base_link_name, KDL::Twist &acceleration) const =0
getRelativeAccelerationTwist compute the relative acceleration of body "link" wrt body "base_link" ex...
XBot::ModelInterface::setGravity
virtual void setGravity(const KDL::Vector &gravity)=0
Sets the gravity vector expressed in the world frame.
XBot::ModelInterface::getInertiaInverse
virtual void getInertiaInverse(Eigen::MatrixXd &Minv) const
getInertiaInverse compute the inverse of the Inertia Matrix
Definition: ModelInterface.cpp:1073
XBot::ModelInterface::getCOMAcceleration
virtual void getCOMAcceleration(KDL::Vector &acceleration) const =0
Gets the COM acceleration expressed in the world frame.
XBot::ModelInterface::getAccelerationTwist
virtual bool getAccelerationTwist(const std::string &link_name, KDL::Twist &acceleration) const =0
Gets the acceleration twist of link_name (first linear, then angular acceleration).
XBot::ModelInterface::_is_floating_base
bool _is_floating_base
Definition: ModelInterface.h:1226
XBot::ModelInterface
ModelInterface is an abstraction layer for a kinematic/dynamic model of a robot.
Definition: ModelInterface.h:46
XBot::ModelInterface::getCentroidalMomentumMatrix
virtual void getCentroidalMomentumMatrix(Eigen::MatrixXd &centroidal_momentum_matrix, Eigen::Vector6d &CMMdotQdot) const
Gets the robot centroidal momentum matrix, i.e.
Definition: ModelInterface.cpp:1001
XBot::XBotInterface::getJointVelocity
bool getJointVelocity(Eigen::VectorXd &qdot) const
Gets the robot joint velocities as an Eigen vector.
Definition: XBotInterface.cpp:762
XBot::ModelInterface::getMass
virtual double getMass() const =0
Gets the weight of the robot.
XBot::ModelInterface::computeJdotQdot
virtual bool computeJdotQdot(const std::string &link_name, const KDL::Vector &point, KDL::Twist &jdotqdot) const
Computed the product of the link_name jacobian time derivative by the joint velocity vector.
Definition: ModelInterface.cpp:707
XBot::ModelInterface::setFloatingBasePose
virtual bool setFloatingBasePose(const KDL::Frame &floating_base_pose)=0
Sets the floating base pose w.r.t.
XBot::ModelInterface::setFloatingBaseAngularVelocity
bool setFloatingBaseAngularVelocity(const KDL::Vector &floating_base_omega)
Sets the floating base angular velocity w.r.t.
Definition: ModelInterface.cpp:958
XBot::XBotInterface::_ordered_joint_vector
std::vector< Joint::Ptr > _ordered_joint_vector
Definition: XBotInterface.h:1383
XBot::ModelInterface::syncFrom_no_update
bool syncFrom_no_update(const XBotInterface &other, SyncFlags... flags)
Synchronizes the internal model state to the one of the XBotInterface given as an argument.
Definition: ModelInterface.h:1323
XBot::ModelInterface::getInertiaMatrix
virtual void getInertiaMatrix(Eigen::MatrixXd &M) const =0
Gets the joint space inertia matrix of the robot.
XBot::ModelInterface::rotationKDLToEigen
void rotationKDLToEigen(const KDL::Rotation &kdl_rotation, Eigen::Matrix3d &eigen_rotation) const
Definition: ModelInterface.h:1301
XBot::XBotInterface::setPositionReference
bool setPositionReference(const Eigen::VectorXd &q)
Sets the XBotInterface internal joint position references according to the provided vector,...
Definition: XBotInterface.cpp:1121
XBot::AnyMapConstPtr
std::shared_ptr< const AnyMap > AnyMapConstPtr
Shared pointer to AnyMap.
Definition: TypedefAndEnums.h:84
XBot::RobotInterface
Definition: RobotInterface.h:36
XBot::ModelInterface::getRelativeVelocityTwist
bool getRelativeVelocityTwist(const std::string &link_name, const std::string &base_link_name, KDL::Twist &velocity) const
Gets the velocity twist of link_name (first linear, then angular velocity) w.r.t.
Definition: ModelInterface.cpp:404
XBot::ModelInterface::init_internal
virtual bool init_internal(const ConfigOptions &config)
Definition: ModelInterface.cpp:75
XBot::XBotInterface::getStiffness
bool getStiffness(Eigen::VectorXd &K) const
Gets the robot stiffness as an Eigen vector.
Definition: XBotInterface.cpp:808
XBot::XBotInterface::setVelocityReference
bool setVelocityReference(const Eigen::VectorXd &qdot)
Sets the XBotInterface internal joint velocity references according to the provided vector,...
Definition: XBotInterface.cpp:1163
XBot::ModelChain
Kinematic chain useful for a model abstraction.
Definition: ModelChain.h:34
XBot::ModelInterface::leg
ModelChain & leg(int leg_id)
Returns a handle to the kinematic chain corresponding to the leg n° leg_id.
Definition: ModelInterface.cpp:224
XBot::ModelInterface::computeRelativeJdotQdot
virtual bool computeRelativeJdotQdot(const std::string &target_link_name, const std::string &base_link_name, KDL::Twist &jdotqdot) const =0
computeRelativeJdotQdot return the relative acceleration component between "target_link" and "base_li...
XBot::ModelInterface::getOrientation
bool getOrientation(const std::string &source_frame, KDL::Rotation &orientation) const
Computes the orientation of the source_frame w.r.t.
Definition: ModelInterface.cpp:495
XBot::ModelInterface::getInertiaInverseTimesVector
virtual void getInertiaInverseTimesVector(const Eigen::VectorXd &vec, Eigen::VectorXd &minv_vec) const
getInertiaInverseTimesVector Computes the inverse of the Inertia Matrix times a given vector
Definition: ModelInterface.cpp:1052
XBot::ModelInterface::getCentroidalMomentum
virtual void getCentroidalMomentum(Eigen::Vector6d &centroidal_momentum) const =0
Gets the robot centroidal momentum matrix, i.e.
XBot::XBotInterface::getJointAcceleration
bool getJointAcceleration(Eigen::VectorXd &qddot) const
Gets the robot joint accelerations as an Eigen vector.
Definition: XBotInterface.cpp:773
XBot::ModelInterface::computeNonlinearTerm
virtual void computeNonlinearTerm(Eigen::VectorXd &n) const =0
Computes the non-linear torque term without the contribution from gravity, i.e.
XBot::ModelInterface::update
bool update(bool update_position=true, bool update_velocity=true, bool update_desired_acceleration=true)
Updates the kinematic variables of the model according to the current state of the model.
Definition: ModelInterface.cpp:115
XBot::ModelInterface::computeConstrainedInverseDynamics
bool computeConstrainedInverseDynamics(const Eigen::MatrixXd &J, const Eigen::VectorXd &weights, Eigen::VectorXd &tau) const
Computes inverse dynamics for a constrained system.
Definition: ModelInterface.cpp:816
XBot::XBotInterface::getPositionReference
bool getPositionReference(Eigen::VectorXd &q) const
Gets the robot position references as an Eigen vector.
Definition: XBotInterface.cpp:418
XBot::XBotInterface::setTemperature
bool setTemperature(const Eigen::VectorXd &temp)
Sets the XBotInterface internal joint temperatures according to the provided vector,...
Definition: XBotInterface.cpp:1149
XBot::ModelInterface::ModelInterface
ModelInterface()=default
XBot::ModelInterface::maskJacobian
bool maskJacobian(const std::string &chain_name, KDL::Jacobian &J) const
Applies a mask corresponding to the specified chain to the jacobian provided as an argument.
Definition: ModelInterface.cpp:810
XBot::XBotInterface::setMotorVelocity
bool setMotorVelocity(const Eigen::VectorXd &qdot)
Sets the XBotInterface internal motor velocities according to the provided vector,...
Definition: XBotInterface.cpp:1107
XBot::ModelInterface::arm
ModelChain & arm(int arm_id)
Returns a handle to the kinematic chain corresponding to the arm n° arm_id.
Definition: ModelInterface.cpp:214
XBot::XBotInterface::setEffortReference
bool setEffortReference(const Eigen::VectorXd &tau)
Sets the XBotInterface internal joint effort references according to the provided vector,...
Definition: XBotInterface.cpp:1036
XBot::ImuSensor::ConstPtr
std::shared_ptr< const ImuSensor > ConstPtr
Definition: ImuSensor.h:33
XBot::ModelInterface::getRelativeJacobian
virtual bool getRelativeJacobian(const std::string &target_link_name, const std::string &base_link_name, KDL::Jacobian &J) const
Gets the relative Jacobian of target_link_name w.r.t to base_link_name.
Definition: ModelInterface.cpp:369
XBot::ModelInterface::chain
ModelChain & chain(const std::string &chain_name)
Returns a handle to the kinematic chain named chain_name.
Definition: ModelInterface.cpp:243
XBot
Definition: IXBotModel.h:20
XBot::ModelInterface::isFloatingBase
bool isFloatingBase() const
True if the robot is floating base, false if it has a fixed base.
Definition: ModelInterface.cpp:34
XBot::ModelInterface::setFloatingBaseTwist
virtual bool setFloatingBaseTwist(const KDL::Twist &floating_base_twist)=0
Sets the floating base twist w.r.t.
XBot::ModelInterface::getPointAcceleration
virtual bool getPointAcceleration(const std::string &link_name, const KDL::Vector &point, KDL::Vector &acceleration) const =0
Gets the acceleration of a given point which is solidal with the given link.
XBot::XBotInterface
Definition: XBotInterface.h:41
XBot::ModelInterface::getCOM
virtual void getCOM(KDL::Vector &com_position) const =0
Gets the COM position vector w.r.t.