20 template <
class RBDDynamics,
bool QUAT_INTEGRATION = false,
bool EE_ARE_CONTROL_INPUTS = false>
23 RBDDynamics::NSTATE / 2,
24 RBDDynamics::NJOINTS + EE_ARE_CONTROL_INPUTS * RBDDynamics::N_EE * 3,
25 typename RBDDynamics::SCALAR>
28 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
33 typedef typename RBDDynamics::SCALAR
SCALAR;
35 const static size_t N_EE = RBDDynamics::N_EE;
36 const static size_t STATE_DIM = RBDDynamics::NSTATE + QUAT_INTEGRATION;
37 const static size_t CONTROL_DIM = RBDDynamics::NJOINTS + EE_ARE_CONTROL_INPUTS * N_EE * 3;
43 SymplecticSystem<RBDDynamics::NSTATE / 2 + QUAT_INTEGRATION, RBDDynamics::NSTATE / 2,
CONTROL_DIM, SCALAR>
50 :
Base(other), dynamics_(other.dynamics_), eeContactModel_(other.eeContactModel_->
clone())
60 virtual RBDDynamics&
dynamics()
override {
return dynamics_; }
61 virtual const RBDDynamics&
dynamics()
const override {
return dynamics_; }
62 void setContactModel(
const std::shared_ptr<ContactModel>& contactModel) { eeContactModel_ = contactModel; }
65 const ControlVector& control,
68 StateVector xLocal = x;
70 xLocal.tail(RBDDynamics::NSTATE / 2) = v;
74 typename RBDDynamics::RBDAcceleration_t xd;
76 pDot = toStateDerivative<QUAT_INTEGRATION>(xd, rbdCached).head(RBDDynamics::NSTATE / 2 + QUAT_INTEGRATION);
81 const ControlVector& control,
84 StateVector xLocal = x;
85 xLocal.head(RBDDynamics::NSTATE / 2 + QUAT_INTEGRATION) = p;
89 typename RBDDynamics::ExtLinkForces_t linkForces(Eigen::Matrix<SCALAR, 6, 1>::Zero());
91 std::array<typename Kinematics::EEForceLinear, N_EE> eeForcesW;
92 eeForcesW.fill(Kinematics::EEForceLinear::Zero());
95 eeForcesW = eeContactModel_->computeContactForces(rbdCached);
97 if (EE_ARE_CONTROL_INPUTS)
98 for (
size_t i = 0;
i <
N_EE;
i++)
99 eeForcesW[
i] += control.template segment<3>(RBDDynamics::NJOINTS +
i * 3);
103 typename RBDDynamics::RBDAcceleration_t xd;
105 dynamics_.FloatingBaseForwardDynamics(rbdCached, control.template head<RBDDynamics::NJOINTS>(), linkForces, xd);
107 vDot = toStateDerivative<QUAT_INTEGRATION>(xd, rbdCached).tail(RBDDynamics::NSTATE / 2);
118 const std::array<typename Kinematics::EEForceLinear, N_EE>& eeForcesW,
119 typename RBDDynamics::ExtLinkForces_t& linkForces)
121 for (
size_t i = 0;
i <
N_EE;
i++)
123 auto endEffector = dynamics_.kinematics().getEndEffector(
i);
124 size_t linkId = endEffector.getLinkId();
126 dynamics_.kinematics().mapForceFromWorldToLink3d(
127 eeForcesW[
i], state.basePose(), state.jointPositions(), i);
133 return RBDStateFromVectorImpl<QUAT_INTEGRATION>(state);
138 typename std::enable_if<T, bool>::type =
true)
141 x.fromStateVectorQuaternion(state);
147 typename std::enable_if<!T, bool>::type =
true)
150 x.fromStateVectorEulerXyz(state);
156 const typename RBDDynamics::RBDState_t& state,
157 typename std::enable_if<T, bool>::type =
true)
159 return acceleration.toStateUpdateVectorQuaternion(state);
164 const typename RBDDynamics::RBDState_t& state,
165 typename std::enable_if<!T, bool>::type =
true)
167 return acceleration.toStateUpdateVectorEulerXyz(state);
172 typename std::enable_if<T, bool>::type =
true)
174 return state.toStateVectorQuaternion();
179 typename std::enable_if<!T, bool>::type =
true)
181 return state.toStateVectorEulerXyz();
185 RBDDynamics dynamics_;
186 std::shared_ptr<ContactModel> eeContactModel_;
typename RBDDynamics::Kinematics_t Kinematics
Definition: FloatingBaseFDSystem.h:31
static const size_t CONTROL_DIM
Definition: FloatingBaseFDSystem.h:37
core::StateVector< STATE_DIM, SCALAR > toStateVector(const typename RBDDynamics::RBDState_t &state, typename std::enable_if<!T, bool >::type=true)
Definition: FloatingBaseFDSystem.h:178
virtual FloatingBaseFDSystem< RBDDynamics, QUAT_INTEGRATION, EE_ARE_CONTROL_INPUTS > * clone() const override
Definition: FloatingBaseFDSystem.h:55
Pose of a single rigid body.
Definition: RigidBodyPose.h:29
FloatingBaseFDSystem()
Definition: FloatingBaseFDSystem.h:48
core::SymplecticSystem< RBDDynamics::NSTATE/2+QUAT_INTEGRATION, RBDDynamics::NSTATE/2, CONTROL_DIM, SCALAR > Base
Definition: FloatingBaseFDSystem.h:44
core::ControlVector< CONTROL_DIM, SCALAR > ControlVector
Definition: FloatingBaseFDSystem.h:40
RBDDynamics::SCALAR SCALAR
Definition: FloatingBaseFDSystem.h:33
void setContactModel(const std::shared_ptr< ContactModel > &contactModel)
Definition: FloatingBaseFDSystem.h:62
FloatingBaseFDSystem(const FloatingBaseFDSystem< RBDDynamics, QUAT_INTEGRATION, EE_ARE_CONTROL_INPUTS > &other)
Definition: FloatingBaseFDSystem.h:49
A floating base rigid body system that uses forward dynamics. The input vector is assumed to consist ...
Definition: FloatingBaseFDSystem.h:21
virtual void computePdot(const StateVector &x, const core::StateVector< RBDDynamics::NSTATE/2, SCALAR > &v, const ControlVector &control, core::StateVector< RBDDynamics::NSTATE/2+QUAT_INTEGRATION, SCALAR > &pDot) override
Definition: FloatingBaseFDSystem.h:63
core::StateVector< STATE_DIM, SCALAR > toStateDerivative(const typename RBDDynamics::RBDAcceleration_t &acceleration, const typename RBDDynamics::RBDState_t &state, typename std::enable_if< T, bool >::type=true)
Definition: FloatingBaseFDSystem.h:155
ct::rbd::TestIrb4600::tpl::Kinematics< double > Kinematics_t
Definition: FixBaseIKTest.cpp:14
virtual const RBDDynamics & dynamics() const override
Definition: FloatingBaseFDSystem.h:61
LinkIdentifiers
Definition: declarations.h:40
This is a common interface class for an RBDSystem.
Definition: RBDSystem.h:15
RBDDynamics::RBDState_t RBDStateFromVectorImpl(const core::StateVector< STATE_DIM, SCALAR > &state, typename std::enable_if<!T, bool >::type=true)
Definition: FloatingBaseFDSystem.h:146
ct::core::StateVector< state_dim > x
virtual ~FloatingBaseFDSystem()
Definition: FloatingBaseFDSystem.h:54
static const size_t STATE_DIM
Definition: FloatingBaseFDSystem.h:36
RBDDynamics::RBDState_t RBDStateFromVectorImpl(const core::StateVector< STATE_DIM, SCALAR > &state, typename std::enable_if< T, bool >::type=true)
Definition: FloatingBaseFDSystem.h:137
core::StateVector< STATE_DIM, SCALAR > toStateDerivative(const typename RBDDynamics::RBDAcceleration_t &acceleration, const typename RBDDynamics::RBDState_t &state, typename std::enable_if<!T, bool >::type=true)
Definition: FloatingBaseFDSystem.h:163
RBDDynamics Dynamics
Definition: FloatingBaseFDSystem.h:30
virtual RBDDynamics & dynamics() override
Definition: FloatingBaseFDSystem.h:60
virtual void computeVdot(const StateVector &x, const core::StateVector< RBDDynamics::NSTATE/2+QUAT_INTEGRATION, SCALAR > &p, const ControlVector &control, core::StateVector< RBDDynamics::NSTATE/2, SCALAR > &vDot) override
Definition: FloatingBaseFDSystem.h:79
core::StateVector< STATE_DIM, SCALAR > toStateVector(const typename RBDDynamics::RBDState_t &state, typename std::enable_if< T, bool >::type=true)
Definition: FloatingBaseFDSystem.h:171
core::StateVector< STATE_DIM, SCALAR > StateVector
Definition: FloatingBaseFDSystem.h:39
static const size_t N_EE
Definition: FloatingBaseFDSystem.h:35
void mapEndeffectorForcesToLinkForces(const typename RBDDynamics::RBDState_t &state, const std::array< typename Kinematics::EEForceLinear, N_EE > &eeForcesW, typename RBDDynamics::ExtLinkForces_t &linkForces)
Definition: FloatingBaseFDSystem.h:117
RBDDynamics::RBDState_t RBDStateFromVector(const core::StateVector< STATE_DIM, SCALAR > &state)
Definition: FloatingBaseFDSystem.h:131