12 #define ACTUATOR_DYNAMICS_ENABLED \ 13 template <size_t ACT_STATE_DIMS> \ 14 typename std::enable_if<(ACT_STATE_DIMS > 0), void>::type 15 #define ACTUATOR_DYNAMICS_DISABLED \ 16 template <size_t ACT_STATE_DIMS> \ 17 typename std::enable_if<(ACT_STATE_DIMS <= 0), void>::type 40 template <
class RBDDynamics,
size_t ACT_STATE_DIM = 0,
bool EE_ARE_CONTROL_INPUTS = false>
44 RBDDynamics::NJOINTS + ACT_STATE_DIM / 2,
45 RBDDynamics::NJOINTS + EE_ARE_CONTROL_INPUTS * RBDDynamics::N_EE * 3,
46 typename RBDDynamics::SCALAR>
49 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
51 static const size_t N_EE = RBDDynamics::N_EE;
52 static const size_t STATE_DIM = RBDDynamics::NSTATE + ACT_STATE_DIM;
54 RBDDynamics::NJOINTS + EE_ARE_CONTROL_INPUTS * RBDDynamics::N_EE * 3;
56 static const size_t NJOINTS = RBDDynamics::NJOINTS;
59 using SCALAR =
typename RBDDynamics::SCALAR;
80 basePose_.setIdentity();
87 basePose_.setIdentity();
98 :
Base(arg), basePose_(arg.basePose_), dynamics_(RBDDynamics())
100 if (arg.actuatorDynamics_)
102 actuatorDynamics_ = std::shared_ptr<ActuatorDynamics_t>(arg.actuatorDynamics_->clone());
109 virtual RBDDynamics&
dynamics()
override {
return dynamics_; }
111 virtual const RBDDynamics&
dynamics()
const override {
return dynamics_; }
119 pDot.template topRows<RBDDynamics::NJOINTS>() = v.template topRows<RBDDynamics::NJOINTS>();
125 computeActuatorPdot<ACT_STATE_DIM>(jState, x, v, controlIn, pDot);
136 const Eigen::Ref<const typename p_vector_act_t::Base> actPos =
137 x.template segment<ACT_STATE_DIM / 2>(RBDDynamics::NJOINTS);
138 const Eigen::Ref<const typename v_vector_act_t::Base> actVel = v.template bottomRows<ACT_STATE_DIM / 2>();
139 const Eigen::Ref<const typename control_vector_full_t::Base> actControlIn =
140 controlIn.template topRows<RBDDynamics::NJOINTS>();
144 actState << actPos, actVel;
147 actuatorDynamics_->computePdot(jState, actState, actVel, actControlIn, actPdot);
150 pDot.template bottomRows<ACT_STATE_DIM / 2>() = actPdot;
175 computeActuatorVdot<ACT_STATE_DIM>(jState, x, p, controlIn, vDot, control);
178 typename RBDDynamics::ExtLinkForces_t linkForces(Eigen::Matrix<SCALAR, 6, 1>::Zero());
181 if (EE_ARE_CONTROL_INPUTS ==
true)
183 for (
size_t i = 0;
i < RBDDynamics::N_EE;
i++)
185 auto endEffector = dynamics_.kinematics().getEndEffector(
i);
186 size_t linkId = endEffector.getLinkId();
188 dynamics_.kinematics().mapForceFromWorldToLink3d(
189 control.template segment<3>(RBDDynamics::NJOINTS +
i * 3), basePose_, jState.getPositions(),
i);
193 typename RBDDynamics::JointAcceleration_t jAcc;
195 dynamics_.FixBaseForwardDynamics(jState, control.template head<RBDDynamics::NJOINTS>(), linkForces, jAcc);
197 vDot.template topRows<RBDDynamics::NJOINTS>() = jAcc.getAcceleration();
209 const Eigen::Ref<const typename p_vector_act_t::Base> actPos =
210 p.template segment<ACT_STATE_DIM / 2>(RBDDynamics::NJOINTS);
211 const Eigen::Ref<const typename v_vector_act_t::Base> actVel = x.template bottomRows<ACT_STATE_DIM / 2>();
212 const Eigen::Ref<const typename control_vector_full_t::Base> actControlIn =
213 controlIn.template topRows<RBDDynamics::NJOINTS>();
217 actState << actPos, actVel;
221 actuatorDynamics_->computeVdot(jState, actState, actPos, actControlIn, actVdot);
222 vDot.template bottomRows<ACT_STATE_DIM / 2>() = actVdot;
225 controlOut = actuatorDynamics_->computeControlOutput(jState, actState);
248 typename RBDDynamics::JointState_t jointState;
249 jointState.getPositions() = x_full.template head<RBDDynamics::NJOINTS>();
250 jointState.getVelocities() = x_full.template segment<RBDDynamics::NJOINTS>(STATE_DIM / 2);
258 typename RBDDynamics::RBDState_t rbdState;
260 rbdState.basePose() = basePose;
269 x_small.template head<NJOINTS>() = x_full.template head<NJOINTS>();
270 x_small.template tail<NJOINTS>() = x_full.template segment<NJOINTS>(STATE_DIM / 2);
278 actState.template topRows<ACT_STATE_DIM / 2>() =
279 state.template segment<ACT_STATE_DIM / 2>(RBDDynamics::NSTATE / 2);
280 actState.template bottomRows<ACT_STATE_DIM / 2>() = state.template bottomRows<ACT_STATE_DIM / 2>();
289 fullState.template head<NJOINTS>() = x_rbd.template head<NJOINTS>();
290 fullState.template segment<ACTUATOR_STATE_DIM / 2>(
NJOINTS) = x_act.template head<ACTUATOR_STATE_DIM / 2>();
291 fullState.template segment<NJOINTS>(STATE_DIM / 2) = x_rbd.template tail<NJOINTS>();
292 fullState.template tail<ACTUATOR_STATE_DIM / 2>() = x_act.template tail<ACTUATOR_STATE_DIM / 2>();
301 RBDDynamics dynamics_;
304 std::shared_ptr<ActuatorDynamics_t> actuatorDynamics_;
310 #undef ACTUATOR_DYNAMICS_ENABLED 311 #undef ACTUATOR_DYNAMICS_DISABLED static const size_t STATE_DIM
Definition: FixBaseFDSystemSymplectic.h:52
static const state_vector_act_t actuatorStateFromVector(const state_vector_full_t &state)
transform control systems state vector to the pure actuator state
Definition: FixBaseFDSystemSymplectic.h:275
Pose of a single rigid body.
Definition: RigidBodyPose.h:29
#define ACTUATOR_DYNAMICS_ENABLED
Definition: FixBaseFDSystemSymplectic.h:12
RBDDynamics Dynamics
Definition: FixBaseFDSystemSymplectic.h:58
#define ACTUATOR_DYNAMICS_DISABLED
Definition: FixBaseFDSystemSymplectic.h:15
ACTUATOR_DYNAMICS_DISABLED computeActuatorVdot(const typename RBDDynamics::JointState_t &jState, const state_vector_full_t &x, const p_vector_full_t &p, const control_vector_full_t &controlIn, v_vector_full_t &vDot, control_vector_full_t &controlOut)
Definition: FixBaseFDSystemSymplectic.h:229
virtual ~FixBaseFDSystemSymplectic()
destructor
Definition: FixBaseFDSystemSymplectic.h:107
FixBaseFDSystemSymplectic(std::shared_ptr< ActuatorDynamics_t > actuatorDynamics)
constructor including actuator dynamics
Definition: FixBaseFDSystemSymplectic.h:84
Definition: ActuatorDynamicsSymplectic.h:20
virtual FixBaseFDSystemSymplectic< RBDDynamics, ACT_STATE_DIM, EE_ARE_CONTROL_INPUTS > * clone() const override
deep cloning
Definition: FixBaseFDSystemSymplectic.h:240
virtual void computePdot(const state_vector_full_t &x, const v_vector_full_t &v, const control_vector_full_t &controlIn, p_vector_full_t &pDot) override
compute position derivatives, for both RBD system and actuator dynamics, if applicable ...
Definition: FixBaseFDSystemSymplectic.h:113
LinkIdentifiers
Definition: declarations.h:40
virtual const RBDDynamics & dynamics() const override
get dynamics (const)
Definition: FixBaseFDSystemSymplectic.h:111
This is a common interface class for an RBDSystem.
Definition: RBDSystem.h:15
static const size_t NJOINTS
Definition: FixBaseFDSystemSymplectic.h:56
FixBaseFDSystemSymplectic(const FixBaseFDSystemSymplectic &arg)
copy constructor
Definition: FixBaseFDSystemSymplectic.h:97
ACTUATOR_DYNAMICS_DISABLED computeActuatorPdot(const typename RBDDynamics::JointState_t &jState, const state_vector_full_t &x, const v_vector_full_t &v, const control_vector_full_t &controlIn, p_vector_full_t &pDot)
Definition: FixBaseFDSystemSymplectic.h:154
static const size_t CONTROL_DIM
Definition: FixBaseFDSystemSymplectic.h:53
FixBaseFDSystemSymplectic()
constructor
Definition: FixBaseFDSystemSymplectic.h:77
ACTUATOR_DYNAMICS_ENABLED computeActuatorVdot(const typename RBDDynamics::JointState_t &jState, const state_vector_full_t &x, const p_vector_full_t &p, const control_vector_full_t &controlIn, v_vector_full_t &vDot, control_vector_full_t &controlOut)
Definition: FixBaseFDSystemSymplectic.h:201
static const RBDDynamics::RBDState_t RBDStateFromVector(const state_vector_full_t &x_full, const tpl::RigidBodyPose< SCALAR > &basePose=tpl::RigidBodyPose< SCALAR >())
transform control systems state vector to a RBDState
Definition: FixBaseFDSystemSymplectic.h:255
virtual RBDDynamics & dynamics() override
get dynamics
Definition: FixBaseFDSystemSymplectic.h:109
ACTUATOR_DYNAMICS_ENABLED computeActuatorPdot(const typename RBDDynamics::JointState_t &jState, const state_vector_full_t &x, const v_vector_full_t &v, const control_vector_full_t &controlIn, p_vector_full_t &pDot)
Definition: FixBaseFDSystemSymplectic.h:129
static const state_vector_full_t toFullState(const state_vector_rbd_t &x_rbd, const state_vector_act_t &x_act=state_vector_act_t::Zero())
transform from "reduced" to full coordinates including actuator dynamics
Definition: FixBaseFDSystemSymplectic.h:285
A fix base rigid body system that uses forward dynamics.
Definition: FixBaseFDSystemSymplectic.h:41
typename RBDDynamics::SCALAR SCALAR
Definition: FixBaseFDSystemSymplectic.h:59
static const size_t ACTUATOR_STATE_DIM
Definition: FixBaseFDSystemSymplectic.h:55
virtual void computeVdot(const state_vector_full_t &x, const p_vector_full_t &p, const control_vector_full_t &controlIn, v_vector_full_t &vDot) override
compute velocity derivatives, for both RBD system and actuator dynamics
Definition: FixBaseFDSystemSymplectic.h:164
static EIGEN_MAKE_ALIGNED_OPERATOR_NEW const size_t N_EE
Definition: FixBaseFDSystemSymplectic.h:51
static const state_vector_rbd_t rbdStateFromVector(const state_vector_full_t &x_full)
transform control systems state vector to a RBDState
Definition: FixBaseFDSystemSymplectic.h:266
static const RBDDynamics::JointState_t jointStateFromVector(const state_vector_full_t &x_full)
full vector to ct JointState
Definition: FixBaseFDSystemSymplectic.h:246