9#ifndef CROCODDYL_MULTIBODY_TASKS_FRAME_ROTATION_HPP_ 10#define CROCODDYL_MULTIBODY_TASKS_FRAME_ROTATION_HPP_ 12#include "crocoddyl/core/task-base.hpp" 13#include "crocoddyl/core/utils/conversions.hpp" 14#include "crocoddyl/multibody/data/multibody.hpp" 15#include "crocoddyl/multibody/fwd.hpp" 16#include "crocoddyl/multibody/states/multibody.hpp" 36template <
typename _Scalar>
39 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
42 typedef _Scalar Scalar;
49 typedef typename MathBase::Matrix3s Matrix3s;
50 typedef typename MathBase::Matrix6xs Matrix6xs;
51 typedef typename MathBase::Vector3s Vector3s;
52 typedef typename MathBase::VectorXs VectorXs;
53 typedef pinocchio::MotionTpl<Scalar> Motion;
62 const pinocchio::FrameIndex
id,
63 const Matrix3s& Rref,
const std::size_t nu);
69 const pinocchio::FrameIndex
id,
70 const Matrix3s& Rref);
76 const pinocchio::FrameIndex
id,
78 const pinocchio::ReferenceFrame
type,
79 const std::size_t nu);
86 virtual void calc(
const std::shared_ptr<TaskDataAbstract>& data,
87 const Eigen::Ref<const VectorXs>& x,
88 const Eigen::Ref<const VectorXs>& u)
override;
93 virtual void calcDiff(
const std::shared_ptr<TaskDataAbstract>& data,
94 const Eigen::Ref<const VectorXs>& x,
95 const Eigen::Ref<const VectorXs>& u)
override;
101 DataCollectorAbstract*
const data)
override;
106 template <
typename NewScalar>
116 void set_id(
const pinocchio::FrameIndex
id);
123 virtual void print(std::ostream& os)
const override;
128 using Base::q_dependent_;
130 using Base::u_dependent_;
131 using Base::v_dependent_;
134 pinocchio::FrameIndex id_;
137 pinocchio::ReferenceFrame type_;
138 std::shared_ptr<typename StateMultibody::PinocchioModel> pin_model_;
144template <
typename _Scalar>
146 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
148 typedef _Scalar Scalar;
152 typedef typename MathBase::Matrix3s Matrix3s;
153 typedef typename MathBase::Matrix3xs Matrix3xs;
154 typedef typename MathBase::Matrix6xs Matrix6xs;
155 typedef pinocchio::MotionTpl<Scalar> Motion;
157 template <
template <
typename Scalar>
class Model>
158 TaskDataFrameRotationTpl(Model<Scalar>*
const model,
159 DataCollectorAbstract*
const data)
161 rRf(Matrix3s::Identity()),
162 rJf(Matrix3s::Zero()),
165 Hlogf(Matrix3s::Zero()),
166 dJ_v(Matrix3s::Zero()),
167 dJ_a(Matrix3s::Zero()),
169 fJf(6, model->get_state()->get_nv()),
170 fVdq(6, model->get_state()->get_nv()),
171 fVdv(6, model->get_state()->get_nv()),
172 fAdq(6, model->get_state()->get_nv()),
173 fAdv(6, model->get_state()->get_nv()) {
185 "Invalid argument: the shared data should be derived from " 186 "DataCollectorMultibody");
197 virtual ~TaskDataFrameRotationTpl() =
default;
200 std::shared_ptr<JointDataAbstractTpl<Scalar>>
222#include "crocoddyl/multibody/tasks/frame-rotation.hxx" State multibody representation.
TaskModelAbstractTpl(std::shared_ptr< StateAbstract > state, const std::size_t nr, const std::size_t nu, const bool q_dependent=true, const bool v_dependent=true, const bool u_dependent=true, const bool has_acceleration=true)
Initialize the task model.
Frame rotation task model.
virtual void calcDiff(const std::shared_ptr< TaskDataAbstract > &data, const Eigen::Ref< const VectorXs > &x, const Eigen::Ref< const VectorXs > &u) override
Compute the task Jacobians.
TaskModelFrameRotationTpl< NewScalar > cast() const
Cast the task model to a different scalar type.
const Matrix3s & get_reference() const
Return the reference rotation.
void set_reference(const Matrix3s &reference)
Update the reference rotation.
void set_id(const pinocchio::FrameIndex id)
Update the frame index.
pinocchio::FrameIndex get_id() const
Return the frame index.
void set_type(const pinocchio::ReferenceFrame type)
Update the reference frame convention.
TaskModelFrameRotationTpl(std::shared_ptr< StateMultibody > state, const pinocchio::FrameIndex id, const Matrix3s &Rref)
Construct a frame rotation task with LOCAL reference frame.
virtual std::shared_ptr< TaskDataAbstract > createData(DataCollectorAbstract *const data) override
Allocate task data.
pinocchio::ReferenceFrame get_type() const
Return the reference frame convention.
virtual void calc(const std::shared_ptr< TaskDataAbstract > &data, const Eigen::Ref< const VectorXs > &x, const Eigen::Ref< const VectorXs > &u) override
Compute the task value and task rate.
TaskModelFrameRotationTpl(std::shared_ptr< StateMultibody > state, const pinocchio::FrameIndex id, const Matrix3s &Rref, const pinocchio::ReferenceFrame type, const std::size_t nu)
Construct a frame rotation task with an explicit reference frame.
TaskModelFrameRotationTpl(std::shared_ptr< StateMultibody > state, const pinocchio::FrameIndex id, const Matrix3s &Rref, const std::size_t nu)
Construct a frame rotation task with LOCAL reference frame.
virtual void print(std::ostream &os) const override
Print relevant information.
Preallocated values and derivatives produced by a task model.
TaskDataAbstractTpl(TaskModelAbstract *const model, DataCollectorAbstract *const data)
Allocate and initialize the common task data.
DataCollectorAbstract * shared
Cached values and derivatives for the frame-rotation task.
Motion vf
Frame velocity in the selected reference frame.
Matrix3s rRf
Rotation-error composition in the selected convention.
Matrix3s Hlogf
Hessian of the SO(3) logarithm.
Matrix3s rJf
Jacobian of the SO(3) logarithm.
Matrix6xs fAdq
Partial derivative of frame acceleration w.r.t. q.
Matrix6xs fAdv
Partial derivative of frame acceleration w.r.t. v.
Matrix6xs fJf
Frame Jacobian in the selected reference frame.
Matrix3s dJ_a
Derivative of rJf contracted with frame acceleration.
Matrix6xs fVdv
Partial derivative of frame velocity with respect to v.
std::shared_ptr< JointDataAbstractTpl< Scalar > > joint
Shared generalized-acceleration data, when available.
DataCollectorAbstract * shared
Shared action-model data collector.
Matrix3xs a_partial_da
Derivative of task acceleration w.r.t. ddq.
Motion af
Frame acceleration in the selected reference frame.
Matrix6xs fVdq
Partial derivative of frame velocity with respect to q.
Matrix3s dJ_v
Derivative of rJf contracted with frame velocity.
pinocchio::DataTpl< Scalar > * pinocchio
Shared Pinocchio data.