8 #include <unordered_map> 26 template <
class RBD,
size_t N_EE>
30 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
32 Kinematics(std::shared_ptr<RBD> rbdContainer = std::shared_ptr<RBD>(
new RBD()))
33 : rbdContainer_(rbdContainer), floatingBaseTransforms_(rbdContainer_)
39 : rbdContainer_(new RBD()), endEffectors_(other.endEffectors_), floatingBaseTransforms_(rbdContainer_)
47 static const size_t NJOINTS = RBD::NJOINTS;
48 static const size_t NLINKS = RBD::NLINKS;
50 using Ptr_t = std::shared_ptr<Kinematics<RBD, N_EE>>;
53 using SCALAR =
typename ROBCOGEN::SCALAR;
74 endeffectors[
i].setLinkId(ROBCOGEN::UTILS::eeIdToLinkId(
i));
98 throw std::runtime_error(
"floating base transforms not implemented");
99 return floatingBaseTransforms_;
104 throw std::runtime_error(
"floating base transforms not implemented");
105 return floatingBaseTransforms_;
115 eeVelocityBase.toImplementation() =
117 .
template bottomRows<3>();
120 eeVelocityBase += rbdState.
base().velocities().getTranslationalVelocity();
123 eeVelocityBase += rbdState.
base().velocities().getRotationalVelocity().cross(
126 return eeVelocityBase;
132 return rbdState.
base().pose().rotateBaseToInertia(eeVelocityBase);
147 return robcogen().getEEPositionInBase(eeID, jointPosition);
159 return robcogen().getEEPoseInBase(eeID, jointPosition);
167 return robcogen().getEERotInBase(eeID, jointPosition);
188 Position3Tpl W_x_EE = basePose.template rotateBaseToInertia(B_x_EE);
191 return basePose.
position() + W_x_EE;
207 QuaterionTpl W_q_EE = basePose.template rotateBaseToInertiaQuaternion(B_q_EE);
221 return basePose.template rotateBaseToInertiaMat(B_R_EE);
229 throw std::runtime_error(
"Solver ID must be less than 100.");
231 size_t hash = eeID * 100 + solverID;
232 if (ikSolvers_.find(hash) != ikSolvers_.end())
233 throw std::runtime_error(
"Solver with the same eeID and solverID already present.");
234 ikSolvers_[hash] = solver;
237 std::shared_ptr<InverseKinematicsBase<NJOINTS, SCALAR>>
getIKSolver(
const size_t eeID,
238 const size_t solverID = 0)
const 241 throw std::runtime_error(
"Solver ID must be less than 100.");
242 size_t hash = eeID * 100 + solverID;
243 return ikSolvers_[hash];
260 EEForce eeForce(EEForce::Zero());
261 eeForce.
force() = W_force;
308 B_force.
force() = basePose.template rotateInertiaToBase<Vector3Tpl>(W_force.
force());
309 B_force.
torque() = B_x_EE.toImplementation().cross(B_force.
force()) +
310 basePose.template rotateInertiaToBase<Vector3Tpl>(W_force.
torque());
313 return EEForce(
robcogen().getForceTransformLinkBaseById(linkId, jointPosition) * B_force);
350 B_force.
force() = T_B_EE.template rotateBaseToInertia<Vector3Tpl>(EE_force.
force());
354 B_x_EE.cross(B_force.
force()) + T_B_EE.template rotateBaseToInertia<Vector3Tpl>(EE_force.
torque());
357 return EEForce(
robcogen().getForceTransformLinkBaseById(linkId, jointPosition) * B_force);
362 std::shared_ptr<RBD> rbdContainer_;
363 std::array<EndEffector<NJOINTS, SCALAR>, N_EE> endEffectors_;
366 std::unordered_map<size_t, std::shared_ptr<InverseKinematicsBase<NJOINTS, SCALAR>>> ikSolvers_;
typename ROBCOGEN::ForceTransform ForceTransform
Definition: Kinematics.h:57
typename ROBCOGEN::SCALAR SCALAR
Definition: Kinematics.h:53
EIGEN_MAKE_ALIGNED_OPERATOR_NEW Kinematics(std::shared_ptr< RBD > rbdContainer=std::shared_ptr< RBD >(new RBD()))
Definition: Kinematics.h:32
Jacobian getJacobianBaseEEbyId(size_t eeId, const RBDState< NJOINTS, SCALAR > &rbdState)
Definition: Kinematics.h:91
JointState< NJOINTS, SCALAR >::JointPositionBlock jointPositions()
get joint positions
Definition: RBDState.h:99
size_t eeId
Definition: rbdJITtests.h:24
RigidBodyState_t & base()
get base states
Definition: RBDState.h:63
Pose of a single rigid body.
Definition: RigidBodyPose.h:29
RBD & robcogen()
Definition: Kinematics.h:360
RigidBodyPoseTpl getEEPoseInWorld(size_t eeID, const RigidBodyPoseTpl &basePose, const typename JointState_t::Position &jointPosition)
get the end-effector pose in world coordinates
Definition: Kinematics.h:195
const Position3Tpl & position() const
This method returns the position of the Base frame in the inertia frame.
Definition: RigidBodyPose.h:246
joint state and joint velocity
Definition: JointState.h:21
Jacobians & jacobians()
Definition: Kinematics.h:111
FloatingBaseTransforms< RBD > & floatingBaseTransforms()
Definition: Kinematics.h:96
HomogeneousTransforms & transforms()
Definition: Kinematics.h:109
joint states and base states
Definition: RBDState.h:27
EEForce mapForceFromWorldToLink3d(const Vector3Tpl &W_force, const RigidBodyPoseTpl &basePose, const typename JointState_t::Position &jointPosition, size_t eeId)
Transforms a force applied at an end-effector and expressed in the world into the link frame the EE i...
Definition: Kinematics.h:255
virtual ~Kinematics()=default
const Jacobians & jacobians() const
Definition: Kinematics.h:110
Matrix3Tpl getEERotInBase(size_t eeID, const typename JointState_t::Position &jointPosition)
Definition: Kinematics.h:165
kindr::Position< SCALAR, 3 > Position3Tpl
Definition: Kinematics.h:62
void setEndEffector(size_t id, const EndEffector< NJOINTS, SCALAR > &ee)
Set an end-effector.
Definition: Kinematics.h:89
EndEffector< NJOINTS, SCALAR > & getEndEffector(size_t id)
Get an end-effector.
Definition: Kinematics.h:83
Position3Tpl getEEPositionInWorld(size_t eeID, const RigidBodyPoseTpl &basePose, const typename JointState_t::Position &jointPosition)
Definition: Kinematics.h:180
Position3Tpl getEEPositionInBase(size_t eeID, const typename JointState_t::Position &jointPosition)
Definition: Kinematics.h:145
SpatialForceVector< SCALAR > EEForce
Definition: Kinematics.h:66
typename ROBCOGEN::HomogeneousTransform HomogeneousTransform
Definition: Kinematics.h:55
void initEndeffectors(std::array< EndEffector< NJOINTS, SCALAR >, NUM_EE > &endeffectors)
Definition: Kinematics.h:70
A spatial force vector This vector contains a torque (angular) in the upper three rows and a linear f...
Definition: SpatialForceVector.h:18
Velocity3Tpl getEEVelocityInWorld(size_t eeId, const RBDState< NJOINTS, SCALAR > &rbdState)
Definition: Kinematics.h:129
Eigen::Matrix< SCALAR, NJOINTS, 1 > Position
Definition: JointState.h:32
Vector3Tpl EEForceLinear
Definition: Kinematics.h:67
typename ROBCOGEN::Jacobian Jacobian
Definition: Kinematics.h:58
Definition: InverseKinematicsBase.h:25
kindr::Velocity< SCALAR, 3 > Velocity3Tpl
Definition: Kinematics.h:63
tpl::RigidBodyPose< SCALAR > RigidBodyPoseTpl
Definition: Kinematics.h:65
Eigen::Matrix< SCALAR, 3, 3 > Matrix3Tpl
Definition: Kinematics.h:61
std::shared_ptr< Kinematics< RBD, N_EE > > Ptr_t
Definition: Kinematics.h:50
Velocity3Tpl getEEVelocityInBase(size_t eeId, const RBDState< NJOINTS, SCALAR > &rbdState)
Definition: Kinematics.h:112
const HomogeneousTransforms & transforms() const
Definition: Kinematics.h:108
static const size_t NJOINTS
Definition: Kinematics.h:47
RigidBodyPoseTpl getEEPoseInBase(size_t eeID, const typename JointState_t::Position &jointPosition)
Definition: Kinematics.h:157
Matrix3Tpl getEERotInWorld(size_t eeID, const RigidBodyPoseTpl &basePose, const typename JointState_t::Position &jointPosition)
get the end-effector rotation matrix expressed in world coordinates
Definition: Kinematics.h:213
static const size_t NLINKS
Definition: Kinematics.h:48
kindr::RotationQuaternion< SCALAR > getRotationQuaternion() const
This method returns the quaternion rotation.
Definition: RigidBodyPose.h:134
ForceTorqueBlock torque()
Get the torque block (upper 3D block)
Definition: SpatialForceVector.h:96
typename ROBCOGEN::HomogeneousTransforms HomogeneousTransforms
Definition: Kinematics.h:56
kindr::RotationQuaternion< SCALAR > QuaterionTpl
Definition: Kinematics.h:64
Kinematics< RBD, N_EE > * clone() const
Definition: Kinematics.h:45
JointState< NJOINTS, SCALAR >::JointPositionBlock jointVelocities()
get joint velocities
Definition: RBDState.h:108
EEForce mapForceFromEEToLink(const EEForce &EE_force, const RigidBodyPoseTpl &T_B_EE, const typename JointState_t::Position &jointPosition, size_t eeId)
Transforms a force applied at an end-effector expressed in an arbitrary (end-effector) frame into the...
Definition: Kinematics.h:335
FloatingBaseTransforms< RBD > & floatingBaseTransforms() const
Definition: Kinematics.h:102
typename ROBCOGEN::Jacobians Jacobians
Definition: Kinematics.h:59
A general class for computing Kinematic properties.
Definition: Kinematics.h:27
EEForce mapForceFromWorldToLink(const EEForce &W_force, const RigidBodyPoseTpl &basePose, const typename JointState_t::Position &jointPosition, const Position3Tpl &B_x_EE, size_t eeId)
Transforms a force applied at an end-effector and expressed in the world into the link frame the EE i...
Definition: Kinematics.h:296
void addIKSolver(const std::shared_ptr< InverseKinematicsBase< NJOINTS, SCALAR >> &solver, size_t eeID, size_t solverID=0)
Definition: Kinematics.h:224
std::shared_ptr< InverseKinematicsBase< NJOINTS, SCALAR > > getIKSolver(const size_t eeID, const size_t solverID=0) const
Definition: Kinematics.h:237
Definition: EndEffector.h:15
EEForce mapForceFromWorldToLink(const EEForce &W_force, const RigidBodyPoseTpl &basePose, const typename JointState_t::Position &jointPosition, size_t eeId)
Transforms a force applied at an end-effector and expressed in the world into the link frame the EE i...
Definition: Kinematics.h:275
ForceTorqueBlock force()
Get the force block (lower 3D block)
Definition: SpatialForceVector.h:104
Kinematics(const Kinematics< RBD, N_EE > &other)
Definition: Kinematics.h:38
Eigen::Matrix< SCALAR, 3, 1 > Vector3Tpl
Definition: Kinematics.h:60
static const size_t NUM_EE
Definition: Kinematics.h:46
RBD ROBCOGEN
Definition: Kinematics.h:52