5#include <base/Eigen.hpp>
6#include <base/samples/RigidBodyStateSE3.hpp>
7#include <base/samples/Joints.hpp>
8#include <base/Acceleration.hpp>
9#include <base/JointLimits.hpp>
10#include <base/samples/Wrenches.hpp>
11#include <base/commands/Joints.hpp>
13#include <urdf_world/world.h>
17std::vector<std::string>
operator+(std::vector<std::string> a, std::vector<std::string> b);
27 const std::string
chainID(
const std::string& root,
const std::string& tip){
return root +
"_" + tip;}
49 base::samples::RigidBodyStateSE3
rbs;
76 const base::samples::RigidBodyStateSE3&
floating_base_state = base::samples::RigidBodyStateSE3()) = 0;
82 virtual void systemState(base::VectorXd &q, base::VectorXd &qd, base::VectorXd &qdd) = 0;
85 virtual const base::samples::RigidBodyStateSE3 &
rigidBodyState(
const std::string &root_frame,
const std::string &tip_frame) = 0;
93 virtual const base::MatrixXd &
spaceJacobian(
const std::string &root_frame,
const std::string &tip_frame) = 0;
101 virtual const base::MatrixXd &
bodyJacobian(
const std::string &root_frame,
const std::string &tip_frame) = 0;
124 virtual const base::MatrixXd &
jacobianDot(
const std::string &root_frame,
const std::string &tip_frame) = 0;
142 uint
jointIndex(
const std::string &joint_name);
154 bool hasLink(
const std::string& link_name);
157 bool hasJoint(
const std::string& joint_name);
201 urdf::ModelInterfaceSharedPtr
loadRobotURDF(
const std::string& file_or_string);
214 throw std::runtime_error(
"Failed to create instance of plugin " + name +
". Is the plugin registered?");
221 T* ret =
dynamic_cast<T*
>(tmp);
228 return robot_model_map;
232 robot_model_map->clear();
243 throw std::runtime_error(
"Failed to register plugin with name " + name +
". A plugin with the same name is already registered");
Interface for all robot models. This has to provide all kinematics and dynamics information that is r...
Definition RobotModel.hpp:22
virtual const base::samples::RigidBodyStateSE3 & rigidBodyState(const std::string &root_frame, const std::string &tip_frame)=0
const RobotModelConfig & getRobotModelConfig()
Get current robot model config.
Definition RobotModel.hpp:195
bool has_floating_base
Definition RobotModel.hpp:41
bool hasActuatedJoint(const std::string &joint_name)
Return True if given joint name is an actuated joint in robot model, false otherwise.
Definition RobotModel.cpp:67
std::string world_frame
Definition RobotModel.hpp:34
void setActiveContacts(const ActiveContacts &contacts)
Provide information about which link is currently in contact with the environment.
Definition RobotModel.cpp:37
virtual ~RobotModel()
Definition RobotModel.hpp:61
virtual const base::VectorXd & biasForces()=0
Compute and return the bias force vector, which is nj x 1, where nj is the number of joints of the sy...
base::MatrixXd joint_space_inertia_mat
Definition RobotModel.hpp:43
RobotModelConfig robot_model_config
Definition RobotModel.hpp:33
std::map< std::string, base::MatrixXd > JacobianMap
Definition RobotModel.hpp:51
std::vector< std::string > actuated_joint_names
Definition RobotModel.hpp:36
base::samples::RigidBodyStateSE3 com_rbs
Definition RobotModel.hpp:48
std::vector< std::string > independent_joint_names
Definition RobotModel.hpp:37
virtual void computeInverseDynamics(base::commands::Joints &solver_output)=0
Compute and return the inverse dynamics solution.
uint noOfActuatedJoints()
Return number of actuated/active joints.
Definition RobotModel.hpp:180
bool hasFloatingBase()
Is floating base robot?
Definition RobotModel.hpp:198
urdf::ModelInterfaceSharedPtr loadRobotURDF(const std::string &file_or_string)
Load URDF model from either file or string.
Definition RobotModel.cpp:94
const base::MatrixXd & selectionMatrix()
Return current selection matrix S that maps complete joint vector to actuated joint vector: q_a = S *...
Definition RobotModel.hpp:165
const std::vector< std::string > & independentJointNames()
Return only independent joint names.
Definition RobotModel.hpp:139
virtual const base::Acceleration & spatialAccelerationBias(const std::string &root_frame, const std::string &tip_frame)=0
Returns the spatial acceleration bias, i.e. the term Jdot*qdot.
const ActiveContacts & getActiveContacts()
Provide links names that are possibly in contact with the environment (typically the end effector lin...
Definition RobotModel.hpp:174
ActiveContacts active_contacts
Definition RobotModel.hpp:29
JacobianMap jac_dot_map
Definition RobotModel.hpp:54
const base::JointLimits & jointLimits()
Return current joint limits.
Definition RobotModel.hpp:151
base::samples::RigidBodyStateSE3 rbs
Definition RobotModel.hpp:49
const base::samples::RigidBodyStateSE3 & floatingBaseState()
Get current status of floating base.
Definition RobotModel.hpp:186
const std::vector< std::string > & jointNames()
Return all joint names.
Definition RobotModel.hpp:133
const std::string & worldFrame()
Get the world frame id.
Definition RobotModel.hpp:148
virtual const base::MatrixXd & spaceJacobian(const std::string &root_frame, const std::string &tip_frame)=0
Returns the Space Jacobian for the kinematic chain between root and the tip frame as full body Jacobi...
virtual const base::MatrixXd & comJacobian()=0
Returns the CoM Jacobian for the entire robot, which maps the robot joint velocities to linear spatia...
const std::string & baseFrame()
Get the base frame of the robot.
Definition RobotModel.hpp:145
RobotModel()
Definition RobotModel.cpp:15
virtual const base::samples::RigidBodyStateSE3 & centerOfMass()=0
Compute and return center of mass expressed in base frame.
JacobianMap space_jac_map
Definition RobotModel.hpp:52
base::Acceleration spatial_acc_bias
Definition RobotModel.hpp:46
base::MatrixXd selection_matrix
Definition RobotModel.hpp:47
base::MatrixXd com_jac
Definition RobotModel.hpp:44
virtual const base::MatrixXd & jointSpaceInertiaMatrix()=0
Compute and return the joint space mass-inertia matrix, which is nj x nj, where nj is the number of j...
std::string base_frame
Definition RobotModel.hpp:34
base::samples::RigidBodyStateSE3 floating_base_state
Definition RobotModel.hpp:31
virtual void update(const base::samples::Joints &joint_state, const base::samples::RigidBodyStateSE3 &floating_base_state=base::samples::RigidBodyStateSE3())=0
Update the robot configuration.
JacobianMap body_jac_map
Definition RobotModel.hpp:53
bool hasJoint(const std::string &joint_name)
Return True if given joint name is available in robot model, false otherwise.
Definition RobotModel.cpp:63
std::vector< std::string > joint_names_floating_base
Definition RobotModel.hpp:39
virtual bool configure(const RobotModelConfig &cfg)=0
Load and configure the robot model.
base::JointLimits joint_limits
Definition RobotModel.hpp:35
uint jointIndex(const std::string &joint_name)
Get index of joint name.
Definition RobotModel.cpp:48
base::VectorXd bias_forces
Definition RobotModel.hpp:45
void setContactWrenches(const base::samples::Wrenches &wrenches)
Set contact wrenches, names have to consistent with the configured contact points.
Definition RobotModel.hpp:189
urdf::ModelInterfaceSharedPtr robot_urdf
Definition RobotModel.hpp:40
const base::samples::Joints & jointState(const std::vector< std::string > &joint_names)
Definition RobotModel.cpp:71
base::samples::Wrenches contact_wrenches
Definition RobotModel.hpp:32
virtual const base::MatrixXd & jacobianDot(const std::string &root_frame, const std::string &tip_frame)=0
Returns the derivative of the Jacobian for the kinematic chain between root and the tip frame as full...
void setGravityVector(const base::Vector3d &g)
Set the current gravity vector.
Definition RobotModel.hpp:183
const std::vector< std::string > & actuatedJointNames()
Return only actuated joint names.
Definition RobotModel.hpp:136
virtual const base::MatrixXd & bodyJacobian(const std::string &root_frame, const std::string &tip_frame)=0
Returns the Body Jacobian for the kinematic chain between root and the tip frame as full body Jacobia...
bool hasLink(const std::string &link_name)
Return True if given link name is available in robot model, false otherwise.
Definition RobotModel.cpp:56
std::vector< std::string > joint_names
Definition RobotModel.hpp:38
base::samples::Joints joint_state
Definition RobotModel.hpp:42
base::Vector3d gravity
Definition RobotModel.hpp:30
virtual void systemState(base::VectorXd &q, base::VectorXd &qd, base::VectorXd &qdd)=0
const std::string chainID(const std::string &root, const std::string &tip)
Definition RobotModel.hpp:27
uint noOfJoints()
Return number of joints.
Definition RobotModel.hpp:177
base::samples::Joints joint_state_out
Definition RobotModel.hpp:57
void clear()
Definition RobotModel.cpp:19
Definition ContactsAccelerationConstraint.cpp:3
QPSolver * createT()
Definition QPSolver.hpp:33
std::shared_ptr< RobotModel > RobotModelPtr
Definition RobotModel.hpp:204
std::vector< std::string > operator+(std::vector< std::string > a, std::vector< std::string > b)
Definition RobotModel.cpp:10
Robot Model configuration class.
Definition RobotModelConfig.hpp:40
Definition RobotModel.hpp:208
static T * createInstance(const std::string &name)
Definition RobotModel.hpp:219
static RobotModel * createInstance(const std::string &name)
Definition RobotModel.hpp:211
std::map< std::string, RobotModel *(*)()> RobotModelMap
Definition RobotModel.hpp:209
static RobotModelMap * getRobotModelMap()
Definition RobotModel.hpp:225
static void clear()
Definition RobotModel.hpp:231
Definition RobotModel.hpp:239
RobotModelRegistry(const std::string &name)
Definition RobotModel.hpp:240