1#ifndef ROBOTOC_POINT_CONTACT_HXX_
2#define ROBOTOC_POINT_CONTACT_HXX_
6#include "pinocchio/algorithm/joint-configuration.hpp"
7#include "pinocchio/algorithm/frames.hpp"
8#include "pinocchio/algorithm/kinematics-derivatives.hpp"
9#include "pinocchio/algorithm/frames-derivatives.hpp"
16template <
typename VectorType1,
typename VectorType2>
18 const pinocchio::Model& model,
const pinocchio::Data& data,
19 const Eigen::MatrixBase<VectorType1>& desired_contact_position,
20 const Eigen::MatrixBase<VectorType2>& baumgarte_residual)
const {
21 assert(desired_contact_position.size() == 3);
22 assert(baumgarte_residual.size() == 3);
23 const_cast<Eigen::MatrixBase<VectorType2>&
> (baumgarte_residual).noalias()
24 = pinocchio::getFrameClassicalAcceleration(model, data, contact_frame_id_,
25 pinocchio::LOCAL).linear();
26 (
const_cast<Eigen::MatrixBase<VectorType2>&
> (baumgarte_residual)).noalias()
28 * pinocchio::getFrameVelocity(model, data, contact_frame_id_,
29 pinocchio::LOCAL).linear();
30 (
const_cast<Eigen::MatrixBase<VectorType2>&
> (baumgarte_residual)).noalias()
32 * (data.oMf[contact_frame_id_].translation()-desired_contact_position);
36template <
typename MatrixType1,
typename MatrixType2,
typename MatrixType3>
38 const pinocchio::Model& model, pinocchio::Data& data,
39 const Eigen::MatrixBase<MatrixType1>& baumgarte_partial_dq,
40 const Eigen::MatrixBase<MatrixType2>& baumgarte_partial_dv,
41 const Eigen::MatrixBase<MatrixType3>& baumgarte_partial_da) {
42 assert(baumgarte_partial_dq.cols() == dimv_);
43 assert(baumgarte_partial_dv.cols() == dimv_);
44 assert(baumgarte_partial_da.cols() == dimv_);
45 assert(baumgarte_partial_dq.rows() == 3);
46 assert(baumgarte_partial_dv.rows() == 3);
47 assert(baumgarte_partial_da.rows() == 3);
48 pinocchio::getFrameAccelerationDerivatives(model, data, contact_frame_id_,
57 pinocchio::getFrameJacobian(model, data, contact_frame_id_,
58 pinocchio::LOCAL, J_frame_);
59 v_frame_ = pinocchio::getFrameVelocity(model, data, contact_frame_id_,
61 pinocchio::skew(v_frame_.linear(), v_linear_skew_);
62 pinocchio::skew(v_frame_.angular(), v_angular_skew_);
63 const_cast<Eigen::MatrixBase<MatrixType1>&
> (baumgarte_partial_dq)
64 = frame_a_partial_dq_.template topRows<3>();
65 const_cast<Eigen::MatrixBase<MatrixType1>&
> (baumgarte_partial_dq).noalias()
66 += v_angular_skew_ * frame_v_partial_dq_.template topRows<3>();
67 const_cast<Eigen::MatrixBase<MatrixType1>&
> (baumgarte_partial_dq).noalias()
68 -= v_linear_skew_ * frame_v_partial_dq_.template bottomRows<3>();
69 const_cast<Eigen::MatrixBase<MatrixType2>&
> (baumgarte_partial_dv)
70 = frame_a_partial_dv_.template topRows<3>();
71 const_cast<Eigen::MatrixBase<MatrixType2>&
> (baumgarte_partial_dv).noalias()
72 += v_angular_skew_ * J_frame_.template topRows<3>();
73 const_cast<Eigen::MatrixBase<MatrixType2>&
> (baumgarte_partial_dv).noalias()
74 -= v_linear_skew_ * J_frame_.template bottomRows<3>();
75 const_cast<Eigen::MatrixBase<MatrixType3>&
> (baumgarte_partial_da)
76 = frame_a_partial_da_.template topRows<3>();
77 (
const_cast<Eigen::MatrixBase<MatrixType1>&
> (baumgarte_partial_dq)).noalias()
79 * frame_v_partial_dq_.template topRows<3>();
80 (
const_cast<Eigen::MatrixBase<MatrixType2>&
> (baumgarte_partial_dv)).noalias()
82 * frame_a_partial_da_.template topRows<3>();
83 (
const_cast<Eigen::MatrixBase<MatrixType1>&
> (baumgarte_partial_dq)).noalias()
85 * J_frame_.template topRows<3>();
89template <
typename VectorType>
91 const pinocchio::Model& model,
const pinocchio::Data& data,
92 const Eigen::MatrixBase<VectorType>& velocity_residual)
const {
93 assert(velocity_residual.size() == 3);
94 const_cast<Eigen::MatrixBase<VectorType>&
> (velocity_residual).noalias()
95 = pinocchio::getFrameVelocity(model, data, contact_frame_id_,
96 pinocchio::LOCAL).linear();
100template <
typename MatrixType1,
typename MatrixType2>
102 const pinocchio::Model& model, pinocchio::Data& data,
103 const Eigen::MatrixBase<MatrixType1>& velocity_partial_dq,
104 const Eigen::MatrixBase<MatrixType2>& velocity_partial_dv) {
105 assert(velocity_partial_dq.cols() == dimv_);
106 assert(velocity_partial_dv.cols() == dimv_);
107 assert(velocity_partial_dq.rows() == 3);
108 assert(velocity_partial_dv.rows() == 3);
109 pinocchio::getFrameVelocityDerivatives(model, data, contact_frame_id_,
112 frame_a_partial_da_);
113 (
const_cast<Eigen::MatrixBase<MatrixType1>&
> (velocity_partial_dq)).noalias()
114 = frame_v_partial_dq_.template topRows<3>();
115 (
const_cast<Eigen::MatrixBase<MatrixType2>&
> (velocity_partial_dv)).noalias()
116 = frame_a_partial_da_.template topRows<3>();
120template <
typename VectorType1,
typename VectorType2>
122 const pinocchio::Model& model,
const pinocchio::Data& data,
123 const Eigen::MatrixBase<VectorType1>& desired_contact_position,
124 const Eigen::MatrixBase<VectorType2>& position_residual)
const {
125 assert(desired_contact_position.size() == 3);
126 assert(position_residual.size() == 3);
127 (
const_cast<Eigen::MatrixBase<VectorType2>&
> (position_residual))
128 = (data.oMf[contact_frame_id_].translation()-desired_contact_position);
132template <
typename MatrixType>
134 const pinocchio::Model& model, pinocchio::Data& data,
135 const Eigen::MatrixBase<MatrixType>& position_partial_dq) {
136 assert(position_partial_dq.cols() == dimv_);
137 assert(position_partial_dq.rows() == 3);
138 pinocchio::getFrameJacobian(model, data, contact_frame_id_,
139 pinocchio::LOCAL, J_frame_);
140 (
const_cast<Eigen::MatrixBase<MatrixType>&
> (position_partial_dq)).noalias()
141 = data.oMf[contact_frame_id_].rotation() * J_frame_.template topRows<3>();
Definition: constraint_component_base.hpp:17