XBotInterface  2.4.1
XBotInterface provides a generic API to model and control a robot.
XBotInterface.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 
20 #ifndef __I_XBOT_INTERFACE_H__
21 #define __I_XBOT_INTERFACE_H__
22 
23 #include <vector>
24 #include <map>
25 #include <memory>
26 #include <algorithm>
27 
28 #include <yaml-cpp/yaml.h>
29 
30 #include <matlogger2/matlogger2.h>
31 
34 #include <XBotInterface/Hand.h>
36 #include <XBotInterface/Logger.hpp>
38 
39 namespace XBot {
40 
42 
43 public:
44 
45 
46  typedef std::shared_ptr<XBotInterface> Ptr;
47  typedef std::shared_ptr<const XBotInterface> ConstPtr;
48 
49  // Constructor, copy constructor, copy assignment, virtual destructor, init function
50 
51  XBotInterface();
52  XBotInterface ( const XBotInterface& other );
53  XBotInterface& operator= ( const XBotInterface& rhs );
54  virtual ~XBotInterface();
55 
56  bool init (const std::string& path_to_cfg);
57  bool init (const ConfigOptions& options);
58 
59 
60  // URDF, SRDF getters
61 
67  const ConfigOptions& getConfigOptions() const;
68 
69 
75  const std::string& getPathToConfig() const;
76 
83  const urdf::ModelInterface& getUrdf() const;
84 
89  const std::string& getUrdfPath() const;
90 
97  const srdf_advr::Model& getSrdf() const;
98 
103  const std::string& getSrdfPath() const;
104 
111  const std::string& getUrdfString() const;
112 
119  const std::string& getSrdfString() const;
120 
121 
122  // Group states
123 
133  bool getRobotState ( const std::string& state_name, Eigen::VectorXd& q ) const;
134 
142  bool getRobotState ( const std::string& state_name, JointIdMap& q ) const;
143 
151  bool getRobotState ( const std::string& state_name, JointNameMap& q ) const;
152 
153 
154  // Kinematic chains
155 
161  std::vector<std::string> getChainNames() const;
162 
170  bool hasChain ( const std::string& chain_name ) const;
171 
179  int legs() const;
180 
188  int arms() const;
189 
190  // Joints
191 
197  const std::vector<std::string>& getEnabledJointNames() const;
198 
204  const std::vector<int>& getEnabledJointId() const;
205 
213  bool hasJoint ( const std::string& joint_name ) const;
214 
222  bool hasJoint ( int joint_id ) const;
223 
229  int getJointNum() const;
230 
239  XBot::Joint::ConstPtr getJointByName ( const std::string& joint_name ) const;
240 
251  XBot::Joint::ConstPtr getJointByID ( int joint_id ) const;
252 
262  XBot::Joint::ConstPtr getJointByDofIndex ( int idx ) const;
263 
272  int getDofIndex ( const std::string& joint_name ) const;
273 
282  int getDofIndex ( int joint_id ) const;
283 
291  bool getDofIndex ( const std::string& chain_name, std::vector<int>& ids ) const;
292 
293  // Logging utilities
294 
304  void initLog(MatLogger2::Ptr logger, int buffer_size = -1, int interleave = 1, std::string prefix = "");
305 
314  void log(MatLogger2::Ptr logger, double timestamp, const std::string& prefix = "") const;
315 
316 
317 
318  // Force-torque sensors
319 
326  std::map< std::string, ForceTorqueSensor::ConstPtr > getForceTorque() const;
327 
336  ForceTorqueSensor::ConstPtr getForceTorque ( const std::string& parent_link_name ) const;
337 
346  ForceTorqueSensor::ConstPtr getForceTorque ( int ft_id ) const;
347 
348  // IMU sensors
349 
356  std::map< std::string, ImuSensor::ConstPtr > getImu();
357 
366  ImuSensor::ConstPtr getImu ( const std::string& parent_link_name ) const;
367 
376  ImuSensor::ConstPtr getImu ( int imu_id ) const;
377 
378  // Hands
379 
386  std::map< std::string, Hand::Ptr > getHand();
387 
396  Hand::Ptr getHand ( int hand_id ) const;
397 
398 
408  bool eigenToMap(const Eigen::VectorXd& vector, JointNameMap& name_map) const;
409 
419  bool eigenToMap(const Eigen::VectorXd& vector, JointIdMap& id_map) const;
420 
431  bool mapToEigen(const JointNameMap& map, Eigen::VectorXd& vector) const;
432 
443  bool mapToEigen(const JointIdMap& map, Eigen::VectorXd& vector) const;
444 
445 
446 
447  // Getters for RX
448 
458  bool getJointPosition ( Eigen::VectorXd& q ) const;
459 
469  bool getMotorPosition ( Eigen::VectorXd& q ) const;
470 
480  bool getJointVelocity ( Eigen::VectorXd& qdot ) const;
481 
491  bool getMotorVelocity ( Eigen::VectorXd& qdot ) const;
492 
502  bool getJointAcceleration ( Eigen::VectorXd& qddot ) const;
503 
513  bool getJointEffort ( Eigen::VectorXd& tau ) const;
514 
524  bool getTemperature ( Eigen::VectorXd& temp ) const;
525 
526 
535  bool getJointPosition ( JointIdMap& q ) const;
536 
545  bool getMotorPosition ( JointIdMap& q ) const;
546 
555  bool getJointVelocity ( JointIdMap& qdot ) const;
556 
565  bool getMotorVelocity ( JointIdMap& qdot ) const;
566 
575  bool getJointAcceleration ( JointIdMap& qddot ) const;
576 
585  bool getJointEffort ( JointIdMap& tau ) const;
586 
595  bool getTemperature ( JointIdMap& temp ) const;
596 
597 
606  bool getJointPosition ( JointNameMap& q ) const;
607 
616  bool getMotorPosition ( JointNameMap& q ) const;
617 
626  bool getJointVelocity ( JointNameMap& qdot ) const;
627 
636  bool getMotorVelocity ( JointNameMap& qdot ) const;
637 
646  bool getJointAcceleration ( JointNameMap& qddot ) const;
647 
656  bool getJointEffort ( JointNameMap& tau ) const;
657 
666  bool getTemperature ( JointNameMap& temp ) const;
667 
668  // Setters for RX
669 
678  bool setJointPosition ( const Eigen::VectorXd& q );
679 
688  bool setMotorPosition ( const Eigen::VectorXd& q );
689 
698  bool setJointVelocity ( const Eigen::VectorXd& qdot );
699 
708  bool setMotorVelocity ( const Eigen::VectorXd& qdot );
709 
718  bool setJointAcceleration ( const Eigen::VectorXd& qddot );
719 
728  bool setJointEffort ( const Eigen::VectorXd& tau );
729 
738  bool setTemperature ( const Eigen::VectorXd& temp );
739 
740 
748  bool setJointPosition ( const JointIdMap& q );
749 
757  bool setMotorPosition ( const JointIdMap& q );
758 
766  bool setJointVelocity ( const JointIdMap& qdot );
767 
775  bool setMotorVelocity ( const JointIdMap& qdot );
776 
784  bool setJointAcceleration ( const JointIdMap& qddot );
785 
793  bool setJointEffort ( const JointIdMap& tau );
794 
802  bool setTemperature ( const JointIdMap& temp );
803 
813  bool setJointPosition ( const JointNameMap& q );
814 
824  bool setMotorPosition ( const JointNameMap& q );
825 
835  bool setJointVelocity ( const JointNameMap& qdot );
836 
846  bool setMotorVelocity ( const JointNameMap& qdot );
847 
857  bool setJointAcceleration ( const JointNameMap& qddot );
858 
868  bool setJointEffort ( const JointNameMap& tau );
869 
879  bool setTemperature ( const JointNameMap& temp );
880 
881  // Getters for TX
882 
892  bool getPositionReference ( Eigen::VectorXd& q ) const;
893 
903  bool getVelocityReference ( Eigen::VectorXd& qdot ) const;
904 
914  bool getEffortReference ( Eigen::VectorXd& tau ) const;
915 
925  bool getStiffness ( Eigen::VectorXd& K ) const;
926 
936  bool getDamping ( Eigen::VectorXd& D ) const;
937 
938 
947  bool getPositionReference ( JointIdMap& q ) const;
948 
957  bool getVelocityReference ( JointIdMap& qdot ) const;
958 
967  bool getEffortReference ( JointIdMap& tau ) const;
968 
977  bool getStiffness ( JointIdMap& K ) const;
978 
987  bool getDamping ( JointIdMap& D ) const;
988 
997  bool getPositionReference ( JointNameMap& q ) const;
998 
1007  bool getVelocityReference ( JointNameMap& qdot ) const;
1008 
1017  bool getEffortReference ( JointNameMap& tau ) const;
1018 
1027  bool getStiffness ( JointNameMap& K ) const;
1028 
1037  bool getDamping ( JointNameMap& D ) const;
1038 
1039  // Setters for TX
1040 
1049  bool setPositionReference ( const Eigen::VectorXd& q );
1050 
1059  bool setVelocityReference ( const Eigen::VectorXd& qdot );
1060 
1069  bool setEffortReference ( const Eigen::VectorXd& tau );
1070 
1079  bool setStiffness ( const Eigen::VectorXd& K );
1080 
1089  bool setDamping ( const Eigen::VectorXd& D );
1090 
1098  bool setPositionReference ( const JointIdMap& q );
1099 
1107  bool setVelocityReference ( const JointIdMap& qdot );
1108 
1116  bool setEffortReference ( const JointIdMap& tau );
1117 
1125  bool setStiffness ( const JointIdMap& K );
1126 
1134  bool setDamping ( const JointIdMap& D );
1135 
1145  bool setPositionReference ( const JointNameMap& q );
1146 
1156  bool setVelocityReference ( const JointNameMap& qdot );
1157 
1167  bool setEffortReference ( const JointNameMap& tau );
1168 
1178  bool setStiffness ( const JointNameMap& K );
1179 
1189  bool setDamping ( const JointNameMap& D );
1190 
1191 
1192 
1193  // Joint limits
1194 
1202  void getJointLimits ( Eigen::VectorXd& q_min, Eigen::VectorXd& q_max ) const;
1203 
1210  void getVelocityLimits ( Eigen::VectorXd& qdot_max ) const;
1211 
1218  void getEffortLimits ( Eigen::VectorXd& tau_max ) const;
1219 
1228  bool checkJointLimits ( const Eigen::VectorXd& q,
1229  std::vector<std::string>& violating_joints ) const;
1230 
1239  bool checkVelocityLimits ( const Eigen::VectorXd& qdot,
1240  std::vector<std::string>& violating_joints ) const;
1241 
1250  bool checkEffortLimits ( const Eigen::VectorXd& tau,
1251  std::vector<std::string>& violating_joints ) const;
1252 
1253 
1260  bool checkJointLimits ( const Eigen::VectorXd& q ) const;
1261 
1268  bool checkVelocityLimits ( const Eigen::VectorXd& qdot ) const;
1269 
1276  bool checkEffortLimits ( const Eigen::VectorXd& tau ) const;
1277 
1284  bool enforceJointLimits( JointIdMap& q ) const;
1285 
1292  bool enforceJointLimits( JointNameMap& q ) const;
1293 
1300  bool enforceJointLimits( Eigen::VectorXd& q ) const;
1301 
1308  bool enforceEffortLimit( Eigen::VectorXd& tau ) const;
1309 
1316  bool enforceVelocityLimit( Eigen::VectorXd& qdot ) const;
1317 
1325  template <typename... SyncFlags>
1326  bool sync ( const XBotInterface& other, SyncFlags... flags );
1327 
1333  const std::map<std::string, XBot::KinematicChain::Ptr>& getChainMap() const;
1334 
1335  friend std::ostream& operator<< ( std::ostream& os, const XBot::XBotInterface& robot );
1341  void print() const;
1342 
1348  void printTracking() const;
1349 
1350 protected:
1351 
1352  // Joint getters for developers
1353 
1354 
1355  Joint::Ptr getJointByNameInternal(const std::string& joint_name) const;
1356  Joint::Ptr getJointByIdInternal(int joint_id) const;
1357  Joint::Ptr getJointByDofIndexInternal(int dof_index) const;
1358 
1359 
1360 
1361  // Chain getter for developers
1362 
1363  const std::map<std::string, ForceTorqueSensor::Ptr>& getForceTorqueInternal() const; // TBD change the Internal with something more meaningful
1364  const std::map<std::string, ImuSensor::Ptr>& getImuInternal() const; // TBD change the Internal with something more meaningful
1365 
1366 
1367 
1368  virtual bool init_internal (const ConfigOptions& config) {
1369  return true;
1370  }
1371 
1372  virtual bool post_init() {
1373  return true;
1374  }
1375 
1376  const std::vector<std::string>& getModelOrderedChainName() const;
1377 
1378 
1379  // internal XBotCoreModel object: it does the trick using URDF, SRDF and joint map configuration
1381 
1382  std::map<std::string, XBot::KinematicChain::Ptr> _chain_map;
1383  std::vector<Joint::Ptr> _ordered_joint_vector;
1384  std::vector<Joint::Ptr> _joint_vector;
1385  std::map<std::string, ForceTorqueSensor::Ptr> _ft_map;
1386  std::map<int, ForceTorqueSensor::Ptr> _ft_id_map;
1387  std::map<std::string, ImuSensor::Ptr> _imu_map;
1388  std::map<int, ImuSensor::Ptr> _imu_id_map;
1389  std::map<std::string, Hand::Ptr> _hand_map;
1390  std::map<int, Hand::Ptr> _hand_id_map;
1391  std::vector<std::string> _ordered_chain_names;
1392 
1393  std::map<int, int> _joint_id_to_eigen_id;
1394  std::map<std::string, int> _joint_name_to_eigen_id;
1395 
1396 private:
1397 
1398  int _joint_num;
1399 
1400  mutable Eigen::VectorXd _qlink, _qmot, _qdotlink, _qdotmot, _tau, _stiffness, _damping, _temp;
1401 
1402  std::string _urdf_string, _srdf_string, _joint_map_string; // TBD add to copy constr/assign
1403  std::string _urdf_path;
1404  std::string _srdf_path;
1405  std::string _joint_map_config;
1406 
1407  ConfigOptions _cfg;
1408 
1409  std::vector<std::string> _ordered_joint_name;
1410  std::vector<int> _ordered_joint_id;
1411 
1412  std::string _path_to_cfg;
1413 
1414  MatLogger2::Ptr _matlogger;
1415 
1416 };
1417 
1418 std::ostream& operator<< ( std::ostream& os, const XBot::XBotInterface& robot );
1419 
1420 template <typename... SyncFlags>
1421 bool XBot::XBotInterface::sync ( const XBot::XBotInterface &other, SyncFlags... flags )
1422 {
1423  bool success = true;
1424 
1425  /* Sync chains */
1426  for ( const auto & c : other._chain_map ) {
1427  const std::string &chain_name = c.first;
1428  const KinematicChain &chain = *c.second;
1429  if ( _chain_map.count ( chain_name ) ) {
1430  _chain_map.at ( chain_name )->syncFrom ( chain, flags... );
1431 
1432  }
1433  }
1434 
1435  XBot::FlagsParser parser;
1436  parser.load_flags(flags...);
1437 
1438  /* Sync FT */
1439  if(parser.ft_flag()){
1440  for(const auto& pair : other._ft_map){
1441  auto it = _ft_map.find(pair.first);
1442  if(it != _ft_map.end()){
1443  *(it->second) = *(pair.second);
1444  }
1445  else{
1446  std::cerr << "ERROR in " << __func__ << "! Unable to find FT \"" << pair.first << " inside this interface!" << std::endl;
1447  success = false;
1448  }
1449  }
1450  }
1451 
1452  /* Sync IMU */
1453  if(parser.imu_flag()){
1454  for(const auto& pair : other._imu_map){
1455  auto it = _imu_map.find(pair.first);
1456  if(it != _imu_map.end()){
1457  *(it->second) = *(pair.second);
1458  }
1459  else{
1460  std::cerr << "ERROR in " << __func__ << "! Unable to find IMU \"" << pair.first << " inside this interface!" << std::endl;
1461  success = false;
1462  }
1463  }
1464 
1465  }
1466 
1467 
1468  return success;
1469 }
1470 
1471 }
1472 
1473 #endif // __I_XBOT_INTERFACE_H__
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::XBotInterface::mapToEigen
bool mapToEigen(const JointNameMap &map, Eigen::VectorXd &vector) const
Converts a state vector for an arbitrary subset of the robot state (specified as a JointNameMap) to i...
Definition: XBotInterface.cpp:1882
XBot::XBotInterface::getForceTorque
std::map< std::string, ForceTorqueSensor::ConstPtr > getForceTorque() const
Getter for the force-torque sensor map pertaining to the whole robot.
Definition: XBotInterface.cpp:1618
XBot::KinematicChain
Kinematic chain abstraction as a set of joints and sensors.
Definition: KinematicChain.h:49
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::operator<<
std::ostream & operator<<(std::ostream &os, const XBot::Joint &j)
ostream operator << for a Joint object
Definition: Joint.cpp:322
XBot::XBotInterface::initLog
void initLog(MatLogger2::Ptr logger, int buffer_size=-1, int interleave=1, std::string prefix="")
Pre-allocates memory for logging the robot state to a mat file.
Definition: XBotInterface.cpp:2053
XBot::XBotInterface::getEffortReference
bool getEffortReference(Eigen::VectorXd &tau) const
Gets the robot effort references as an Eigen vector.
Definition: XBotInterface.cpp:751
XBot::XBotInterface::getChainNames
std::vector< std::string > getChainNames() const
Return a vector of available chain names as strings.
Definition: XBotInterface.cpp:1380
XBot::XBotInterface::getMotorPosition
bool getMotorPosition(Eigen::VectorXd &q) const
Gets the robot motor positions as an Eigen vector.
Definition: XBotInterface.cpp:786
XBot::XBotInterface::getJointPosition
bool getJointPosition(Eigen::VectorXd &q) const
Gets the robot joint positions as an Eigen vector.
Definition: XBotInterface.cpp:348
XBot::FlagsParser
Definition: SyncFlags.h:83
XBot::XBotInterface::checkVelocityLimits
bool checkVelocityLimits(const Eigen::VectorXd &qdot, std::vector< std::string > &violating_joints) const
Check the input joint velocity vector against joint limits.
Definition: XBotInterface.cpp:1519
XBot::XBotInterface::_chain_map
std::map< std::string, XBot::KinematicChain::Ptr > _chain_map
Definition: XBotInterface.h:1382
XBot::JointIdMap
std::unordered_map< int, double > JointIdMap
std::map with key representing the joint ID (i.e.
Definition: TypedefAndEnums.h:33
XBot::XBotInterface::getMotorVelocity
bool getMotorVelocity(Eigen::VectorXd &qdot) const
Gets the robot motor velocities as an Eigen vector.
Definition: XBotInterface.cpp:797
XBot::XBotInterface::getJointByNameInternal
Joint::Ptr getJointByNameInternal(const std::string &joint_name) const
Definition: XBotInterface.cpp:1999
XBot::XBotInterface::getEnabledJointId
const std::vector< int > & getEnabledJointId() const
Returns a vector of enabled joint IDs.
Definition: XBotInterface.cpp:1697
XBot::XBotInterface::getPathToConfig
const std::string & getPathToConfig() const
Gets the path to the YAML config file used to build the XBotInterface.
Definition: XBotInterface.cpp:117
XBot::XBotInterface::checkJointLimits
bool checkJointLimits(const Eigen::VectorXd &q, std::vector< std::string > &violating_joints) const
Check the input joint position vector against joint limits.
Definition: XBotInterface.cpp:1490
XBot::XBotInterface::getForceTorqueInternal
const std::map< std::string, ForceTorqueSensor::Ptr > & getForceTorqueInternal() const
Definition: XBotInterface.cpp:1630
XBot::XBotInterface::legs
int legs() const
Returns the number of legs defined inside the interface.
Definition: XBotInterface.cpp:279
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::XBotInterface::_imu_id_map
std::map< int, ImuSensor::Ptr > _imu_id_map
Definition: XBotInterface.h:1388
KinematicChain.h
XBot::XBotInterface::_ft_map
std::map< std::string, ForceTorqueSensor::Ptr > _ft_map
Definition: XBotInterface.h:1385
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::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::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::XBotInterface::_imu_map
std::map< std::string, ImuSensor::Ptr > _imu_map
Definition: XBotInterface.h:1387
XBot::ForceTorqueSensor::ConstPtr
std::shared_ptr< const ForceTorqueSensor > ConstPtr
Definition: ForceTorqueSensor.h:46
XBot::XBotInterface::getSrdf
const srdf_advr::Model & getSrdf() const
Getter fot the robot SRDF model corresponding to the SRDF xml file specified in the YAML config file.
Definition: XBotInterface.cpp:1395
XBot::XBotInterface::getJointLimits
void getJointLimits(Eigen::VectorXd &q_min, Eigen::VectorXd &q_max) const
Gets a vector of the robot joint limits, as specified in the URDF file.
Definition: XBotInterface.cpp:1551
XBot::XBotInterface::post_init
virtual bool post_init()
Definition: XBotInterface.h:1372
XBot::XBotInterface::getDofIndex
int getDofIndex(const std::string &joint_name) const
Gets the Eigen ID of the joint with name "joint_name".
Definition: XBotInterface.cpp:252
XBot::XBotInterface::_joint_id_to_eigen_id
std::map< int, int > _joint_id_to_eigen_id
Definition: XBotInterface.h:1393
XBot::XBotInterface::getSrdfString
const std::string & getSrdfString() const
Returns the robot SRDF xml as a string.
Definition: XBotInterface.cpp:1400
XBot::JointNameMap
std::unordered_map< std::string, double > JointNameMap
std::map with key representing the joint human-readable name and value representing a joint state (e....
Definition: TypedefAndEnums.h:51
XBot::XBotInterface::getUrdfPath
const std::string & getUrdfPath() const
getUrdfPath Getter for the path to the URDF model
Definition: XBotInterface.cpp:1916
TypedefAndEnums.h
XBot::XBotInterface::getDamping
bool getDamping(Eigen::VectorXd &D) const
Gets the robot damping as an Eigen vector.
Definition: XBotInterface.cpp:729
XBot::XBotInterface::_hand_map
std::map< std::string, Hand::Ptr > _hand_map
Definition: XBotInterface.h:1389
XBot::XBotInterface::getJointByIdInternal
Joint::Ptr getJointByIdInternal(int joint_id) const
Definition: XBotInterface.cpp:2036
XBot::XBotInterface::getVelocityReference
bool getVelocityReference(Eigen::VectorXd &qdot) const
Gets the robot velocity references as an Eigen vector.
Definition: XBotInterface.cpp:830
XBot::XBotInterface::getConfigOptions
const ConfigOptions & getConfigOptions() const
Gets the configuration struct that has been used to build the XBotInterface.
Definition: XBotInterface.cpp:111
XBot::Hand::Ptr
std::shared_ptr< Hand > Ptr
Definition: Hand.h:40
XBot::XBotInterface::operator<<
friend std::ostream & operator<<(std::ostream &os, const XBot::XBotInterface &robot)
XBot::Joint::Ptr
std::shared_ptr< Joint > Ptr
Definition: Joint.h:53
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::XBotInterface::_ft_id_map
std::map< int, ForceTorqueSensor::Ptr > _ft_id_map
Definition: XBotInterface.h:1386
XBot::XBotInterface::getJointNum
int getJointNum() const
Getter for the number of enabled joints.
Definition: XBotInterface.cpp:95
XBot::XBotInterface::_joint_vector
std::vector< Joint::Ptr > _joint_vector
Definition: XBotInterface.h:1384
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::XBotInterface::checkEffortLimits
bool checkEffortLimits(const Eigen::VectorXd &tau, std::vector< std::string > &violating_joints) const
Check the input joint effort vector against joint limits.
Definition: XBotInterface.cpp:1461
XBot::Joint::ConstPtr
std::shared_ptr< const Joint > ConstPtr
Definition: Joint.h:54
XBot::FlagsParser::ft_flag
bool ft_flag() const
Definition: SyncFlags.h:130
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
XBot::XBotInterface::_joint_name_to_eigen_id
std::map< std::string, int > _joint_name_to_eigen_id
Definition: XBotInterface.h:1394
XBot::XBotInterface::ConstPtr
std::shared_ptr< const XBotInterface > ConstPtr
Definition: XBotInterface.h:47
XBot::XBotInterface::log
void log(MatLogger2::Ptr logger, double timestamp, const std::string &prefix="") const
Logs the current robot state.
Definition: XBotInterface.cpp:2119
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::KinematicChain::syncFrom
bool syncFrom(const KinematicChain &other, SyncFlags... flags)
Synchronize the current KinematicChain with another KinematicChain object.
Definition: KinematicChain.h:734
XBot::XBotInterface::enforceJointLimits
bool enforceJointLimits(JointIdMap &q) const
Modifies the input joint position map by enforcing joint limits.
Definition: XBotInterface.cpp:1973
XBot::XBotInterface::enforceVelocityLimit
bool enforceVelocityLimit(Eigen::VectorXd &qdot) const
Modifies the input joint velcoity vector by enforcing joint limits.
Definition: XBotInterface.cpp:1983
XBot::XBotInterface::arms
int arms() const
Returns the number of arms defined inside the interface.
Definition: XBotInterface.cpp:285
XBot::XBotInterface::getJointVelocity
bool getJointVelocity(Eigen::VectorXd &qdot) const
Gets the robot joint velocities as an Eigen vector.
Definition: XBotInterface.cpp:762
XBot::XBotInterface::printTracking
void printTracking() const
Print a pretty table about the robot tracking.
Definition: XBotInterface.cpp:1909
XBot::XBotInterface::hasChain
bool hasChain(const std::string &chain_name) const
A method for determining if a chain with name "chain_name" is defined inside the interface.
Definition: XBotInterface.cpp:106
XBot::XBotCoreModel
Definition: XBotCoreModel.h:40
XBot::XBotInterface::Ptr
std::shared_ptr< XBotInterface > Ptr
Definition: XBotInterface.h:46
XBot::XBotInterface::init_internal
virtual bool init_internal(const ConfigOptions &config)
Definition: XBotInterface.h:1368
XBot::FlagsParser::load_flags
void load_flags(Flags... flags)
Definition: SyncFlags.h:93
XBot::XBotInterface::_ordered_joint_vector
std::vector< Joint::Ptr > _ordered_joint_vector
Definition: XBotInterface.h:1383
Logger.hpp
XBot::XBotInterface::getImuInternal
const std::map< std::string, ImuSensor::Ptr > & getImuInternal() const
Definition: XBotInterface.cpp:1662
XBot::FlagsParser::imu_flag
bool imu_flag() const
Definition: SyncFlags.h:131
XBot::XBotInterface::operator=
XBotInterface & operator=(const XBotInterface &rhs)
Definition: XBotInterface.cpp:1421
ConfigOptions.h
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::XBotInterface::getRobotState
bool getRobotState(const std::string &state_name, Eigen::VectorXd &q) const
Gets the robot joints group state configuration as specified in the robot SRDF.
Definition: XBotInterface.cpp:1789
XBotCoreModel.h
XBot::XBotInterface::_XBotModel
XBotCoreModel _XBotModel
Definition: XBotInterface.h:1380
XBot::XBotInterface::getStiffness
bool getStiffness(Eigen::VectorXd &K) const
Gets the robot stiffness as an Eigen vector.
Definition: XBotInterface.cpp:808
XBot::XBotInterface::init
bool init(const std::string &path_to_cfg)
Definition: XBotInterface.cpp:226
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::XBotInterface::getEffortLimits
void getEffortLimits(Eigen::VectorXd &tau_max) const
Gets a vector of the robot joint effort limits, as specified in the URDF file.
Definition: XBotInterface.cpp:1534
XBot::XBotInterface::getEnabledJointNames
const std::vector< std::string > & getEnabledJointNames() const
Returns a vector of enabled joint names.
Definition: XBotInterface.cpp:1588
XBot::XBotInterface::print
void print() const
Print a pretty table about the robot state.
Definition: XBotInterface.cpp:1901
XBot::XBotInterface::~XBotInterface
virtual ~XBotInterface()
Definition: XBotInterface.cpp:1417
XBot::XBotInterface::getSrdfPath
const std::string & getSrdfPath() const
getSrdfPath Getter for the path to the SRDF model
Definition: XBotInterface.cpp:1926
XBot::XBotInterface::getJointAcceleration
bool getJointAcceleration(Eigen::VectorXd &qddot) const
Gets the robot joint accelerations as an Eigen vector.
Definition: XBotInterface.cpp:773
Hand.h
XBot::XBotInterface::getUrdf
const urdf::ModelInterface & getUrdf() const
Getter for the robot URDF model corresponding to the URDF xml file specified in the YAML config file.
Definition: XBotInterface.cpp:1405
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::XBotInterface::getJointByDofIndex
XBot::Joint::ConstPtr getJointByDofIndex(int idx) const
Gets the joint with the required dof index.
Definition: XBotInterface.cpp:318
XBot::XBotInterface::getImu
std::map< std::string, ImuSensor::ConstPtr > getImu()
Getter for the IMU sensor map pertaining to the chain.
Definition: XBotInterface.cpp:1650
XBot::XBotInterface::getHand
std::map< std::string, Hand::Ptr > getHand()
Getter for the hands map pertaining to the whole robot.
Definition: XBotInterface.cpp:1669
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::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::XBotInterface::getJointByName
XBot::Joint::ConstPtr getJointByName(const std::string &joint_name) const
Gets the joint with name "joint_name" if it is defined as enabled.
Definition: XBotInterface.cpp:302
XBot::XBotInterface::enforceEffortLimit
bool enforceEffortLimit(Eigen::VectorXd &tau) const
Modifies the input joint effort vector by enforcing effort limits.
Definition: XBotInterface.cpp:1936
XBot::XBotInterface::hasJoint
bool hasJoint(const std::string &joint_name) const
Checks that a joint with name "joint_name" is defined as an enabled joint inside the interface.
Definition: XBotInterface.cpp:291
XBot
Definition: IXBotModel.h:20
XBot::XBotInterface::getJointByDofIndexInternal
Joint::Ptr getJointByDofIndexInternal(int dof_index) const
Definition: XBotInterface.cpp:2015
XBot::XBotInterface::getVelocityLimits
void getVelocityLimits(Eigen::VectorXd &qdot_max) const
Gets a vector of the robot joint velocity limits, as specified in the URDF file.
Definition: XBotInterface.cpp:1569
XBot::XBotInterface::getModelOrderedChainName
const std::vector< std::string > & getModelOrderedChainName() const
Definition: XBotInterface.cpp:101
XBot::XBotInterface::XBotInterface
XBotInterface()
Definition: XBotInterface.cpp:26
XBot::XBotInterface::getUrdfString
const std::string & getUrdfString() const
Returns the robot URDF xml as a string.
Definition: XBotInterface.cpp:1410
XBot::XBotInterface
Definition: XBotInterface.h:41
XBot::XBotInterface::_hand_id_map
std::map< int, Hand::Ptr > _hand_id_map
Definition: XBotInterface.h:1390
XBot::XBotInterface::eigenToMap
bool eigenToMap(const Eigen::VectorXd &vector, JointNameMap &name_map) const
Converts a state vector for the whole robot to its JointNameMap representation.
Definition: XBotInterface.cpp:1848
XBot::XBotInterface::getJointByID
XBot::Joint::ConstPtr getJointByID(int joint_id) const
Gets the joint with ID "joint_id" if it is defined as enabled.
Definition: XBotInterface.cpp:328