32 #include <pinocchio/algorithm/aba.hpp> 33 #include <pinocchio/algorithm/joint-configuration.hpp> 42 pinocchio::aba(model_, *pinocchio_data_.get(), x.head(num_positions_), x.tail(num_velocities_), u);
43 xdot_analytic_.head(num_velocities_) = x.tail(num_velocities_);
44 xdot_analytic_.tail(num_velocities_) = pinocchio_data_->ddq;
45 return xdot_analytic_;
50 if (x_1.size() != num_positions_ + num_velocities_ || x_2.size() != num_positions_ + num_velocities_)
52 ThrowPretty(
"x_1 or x_2 do not have correct size, x1=" << x_1.size() <<
" x2=" << x_2.size() <<
" expected " << num_positions_ + num_velocities_);
55 Eigen::VectorXd dx(2 * num_velocities_);
56 pinocchio::difference(model_, x_2.head(num_positions_), x_1.head(num_positions_), dx.head(num_velocities_));
57 dx.tail(num_velocities_) = x_1.tail(num_velocities_) - x_2.tail(num_velocities_);
63 if (x_1.size() != num_positions_ + num_velocities_ || x_2.size() != num_positions_ + num_velocities_)
65 ThrowPretty(
"x_1 or x_2 do not have correct size, x1=" << x_1.size() <<
" x2=" << x_2.size() <<
" expected " << num_positions_ + num_velocities_);
68 if (first_or_second != ArgumentPosition::ARG0 && first_or_second != ArgumentPosition::ARG1)
70 ThrowPretty(
"Can only take derivative w.r.t. x_1 or x_2, i.e., ARG0 or ARG1. Provided: " << first_or_second);
73 Eigen::MatrixXd
J = Eigen::MatrixXd::Identity(2 * num_velocities_, 2 * num_velocities_);
75 if (first_or_second == ArgumentPosition::ARG0)
77 pinocchio::dDifference(model_, x_2.head(num_positions_), x_1.head(num_positions_), J.topLeftCorner(num_velocities_, num_velocities_), pinocchio::ArgumentPosition::ARG1);
81 pinocchio::dDifference(model_, x_2.head(num_positions_), x_1.head(num_positions_), J.topLeftCorner(num_velocities_, num_velocities_), pinocchio::ArgumentPosition::ARG0);
82 J.bottomRightCorner(num_velocities_, num_velocities_) *= -1.0;
92 const Eigen::VectorBlock<const Eigen::VectorXd>
q = x.head(num_positions_);
93 const Eigen::VectorBlock<const Eigen::VectorXd>
v = x.tail(num_velocities_);
94 const Eigen::VectorBlock<const Eigen::VectorXd>
a = dx.tail(num_velocities_);
101 Eigen::VectorXd dx_times_dt = dt * dx;
103 xout.tail(num_velocities_) = v + dx_times_dt.tail(num_velocities_);
108 case Integrator::SymplecticEuler:
110 Eigen::VectorXd dx_new(get_num_state_derivative());
111 dx_new.head(num_velocities_).noalias() = dt * v + (dt * dt) * a;
112 dx_new.tail(num_velocities_).noalias() = dt * a;
115 xout.tail(num_velocities_) = v + dx_new.tail(num_velocities_);
const DataTpl< Scalar, Options, JointCollectionTpl >::TangentVectorType & aba(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, DataTpl< Scalar, Options, JointCollectionTpl > &data, const Eigen::MatrixBase< ConfigVectorType > &q, const Eigen::MatrixBase< TangentVectorType1 > &v, const Eigen::MatrixBase< TangentVectorType2 > &tau)
#define REGISTER_DYNAMICS_SOLVER_TYPE(TYPE, DERIV)
void integrate(const LieGroupGenericTpl< LieGroupCollection > &lg, const Eigen::MatrixBase< ConfigIn_t > &q, const Eigen::MatrixBase< Tangent_t > &v, const Eigen::MatrixBase< ConfigOut_t > &qout)
void difference(const LieGroupGenericTpl< LieGroupCollection > &lg, const Eigen::MatrixBase< ConfigL_t > &q0, const Eigen::MatrixBase< ConfigR_t > &q1, const Eigen::MatrixBase< Tangent_t > &v)
Eigen::Matrix< T, NU, 1 > ControlVector
void dDifference(const LieGroupGenericTpl< LieGroupCollection > &lg, const Eigen::MatrixBase< ConfigL_t > &q0, const Eigen::MatrixBase< ConfigR_t > &q1, const Eigen::MatrixBase< JacobianOut_t > &J, const ArgumentPosition arg)
Eigen::Matrix< T, NX, 1 > StateVector