robotoc
robotoc - efficient ROBOT Optimal Control solvers
Loading...
Searching...
No Matches
surface_contact.hxx
Go to the documentation of this file.
1#ifndef ROBOTOC_SURFACE_CONTACT_HXX_
2#define ROBOTOC_SURFACE_CONTACT_HXX_
3
5
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"
10
11#include <cassert>
12
13
14namespace robotoc {
15
16template <typename VectorType>
18 const pinocchio::Model& model, const pinocchio::Data& data,
19 const SE3& desired_contact_placement,
20 const Eigen::MatrixBase<VectorType>& baumgarte_residual) {
21 assert(baumgarte_residual.size() == 6);
22 const_cast<Eigen::MatrixBase<VectorType>&> (baumgarte_residual).noalias()
23 = pinocchio::getFrameAcceleration(model, data, contact_frame_id_,
24 pinocchio::LOCAL).toVector();
25 (const_cast<Eigen::MatrixBase<VectorType>&> (baumgarte_residual)).noalias()
27 * pinocchio::getFrameVelocity(model, data, contact_frame_id_,
28 pinocchio::LOCAL).toVector();
29 X_diff_ = desired_contact_placement.inverse() * data.oMf[contact_frame_id_];
30 (const_cast<Eigen::MatrixBase<VectorType>&> (baumgarte_residual)).noalias()
31 += info_.baumgarte_position_gain * Log6Map(X_diff_);
32}
33
34
35template <typename MatrixType1, typename MatrixType2, typename MatrixType3>
37 const pinocchio::Model& model, pinocchio::Data& data,
38 const Eigen::MatrixBase<MatrixType1>& baumgarte_partial_dq,
39 const Eigen::MatrixBase<MatrixType2>& baumgarte_partial_dv,
40 const Eigen::MatrixBase<MatrixType3>& baumgarte_partial_da) {
41 assert(baumgarte_partial_dq.cols() == dimv_);
42 assert(baumgarte_partial_dv.cols() == dimv_);
43 assert(baumgarte_partial_da.cols() == dimv_);
44 assert(baumgarte_partial_dq.rows() == 6);
45 assert(baumgarte_partial_dv.rows() == 6);
46 assert(baumgarte_partial_da.rows() == 6);
47 pinocchio::getFrameAccelerationDerivatives(model, data, contact_frame_id_,
48 pinocchio::LOCAL,
49 frame_v_partial_dq_,
50 frame_a_partial_dq_,
51 frame_a_partial_dv_,
52 frame_a_partial_da_);
53 // Skew matrices and LOCAL frame Jacobian are needed to convert the
54 // frame acceleration derivatives into the "classical" acceleration
55 // derivatives.
56 pinocchio::getFrameJacobian(model, data, contact_frame_id_,
57 pinocchio::LOCAL, J_frame_);
58 const_cast<Eigen::MatrixBase<MatrixType1>&> (baumgarte_partial_dq)
59 = frame_a_partial_dq_;
60 const_cast<Eigen::MatrixBase<MatrixType1>&> (baumgarte_partial_dv)
61 = frame_a_partial_dv_;
62 const_cast<Eigen::MatrixBase<MatrixType3>&> (baumgarte_partial_da)
63 = frame_a_partial_da_;
64 (const_cast<Eigen::MatrixBase<MatrixType1>&> (baumgarte_partial_dq)).noalias()
65 += info_.baumgarte_velocity_gain * frame_v_partial_dq_;
66 (const_cast<Eigen::MatrixBase<MatrixType2>&> (baumgarte_partial_dv)).noalias()
67 += info_.baumgarte_velocity_gain * frame_a_partial_da_;
68 computeJLog6Map(X_diff_, Jlog6_);
69 (const_cast<Eigen::MatrixBase<MatrixType1>&> (baumgarte_partial_dq)).noalias()
70 += info_.baumgarte_position_gain * Jlog6_ * J_frame_;
71}
72
73
74template <typename VectorType>
76 const pinocchio::Model& model, const pinocchio::Data& data,
77 const Eigen::MatrixBase<VectorType>& velocity_residual) const {
78 assert(velocity_residual.size() == 6);
79 const_cast<Eigen::MatrixBase<VectorType>&> (velocity_residual).noalias()
80 = pinocchio::getFrameVelocity(model, data, contact_frame_id_,
81 pinocchio::LOCAL).toVector();
82}
83
84
85template <typename MatrixType1, typename MatrixType2>
87 const pinocchio::Model& model, pinocchio::Data& data,
88 const Eigen::MatrixBase<MatrixType1>& velocity_partial_dq,
89 const Eigen::MatrixBase<MatrixType2>& velocity_partial_dv) {
90 assert(velocity_partial_dq.cols() == dimv_);
91 assert(velocity_partial_dv.cols() == dimv_);
92 assert(velocity_partial_dq.rows() == 6);
93 assert(velocity_partial_dv.rows() == 6);
94 pinocchio::getFrameVelocityDerivatives(model, data, contact_frame_id_,
95 pinocchio::LOCAL,
96 frame_v_partial_dq_,
97 frame_a_partial_da_);
98 (const_cast<Eigen::MatrixBase<MatrixType1>&> (velocity_partial_dq)).noalias()
99 = frame_v_partial_dq_;
100 (const_cast<Eigen::MatrixBase<MatrixType2>&> (velocity_partial_dv)).noalias()
101 = frame_a_partial_da_;
102}
103
104
105template <typename VectorType>
107 const pinocchio::Model& model, const pinocchio::Data& data,
108 const SE3& desired_contact_placement,
109 const Eigen::MatrixBase<VectorType>& position_residual) {
110 assert(position_residual.size() == 6);
111 X_diff_ = desired_contact_placement.inverse() * data.oMf[contact_frame_id_];
112 (const_cast<Eigen::MatrixBase<VectorType>&> (position_residual))
113 = Log6Map(X_diff_);
114}
115
116
117template <typename MatrixType>
119 const pinocchio::Model& model, pinocchio::Data& data,
120 const Eigen::MatrixBase<MatrixType>& position_partial_dq) {
121 assert(position_partial_dq.cols() == dimv_);
122 assert(position_partial_dq.rows() == 6);
123 pinocchio::getFrameJacobian(model, data, contact_frame_id_,
124 pinocchio::LOCAL, J_frame_);
125 computeJLog6Map(X_diff_, Jlog6_);
126 (const_cast<Eigen::MatrixBase<MatrixType>&> (position_partial_dq)).noalias()
127 = Jlog6_ * J_frame_;
128}
129
130} // namespace robotoc
131
132#endif // ROBOTOC_SURFACE_CONTACT_HXX_
void computeContactVelocityDerivatives(const pinocchio::Model &model, pinocchio::Data &data, const Eigen::MatrixBase< MatrixType1 > &velocity_partial_dq, const Eigen::MatrixBase< MatrixType2 > &velocity_partial_dv)
Computes the partial derivatives of the contact velocity constraints. Before calling this function,...
Definition: surface_contact.hxx:86
void computeContactPositionResidual(const pinocchio::Model &model, const pinocchio::Data &data, const SE3 &desired_contact_placement, const Eigen::MatrixBase< VectorType > &position_residual)
Computes the residual of the contact position constraints. Before calling this function,...
Definition: surface_contact.hxx:106
void computeBaumgarteResidual(const pinocchio::Model &model, const pinocchio::Data &data, const SE3 &desired_contact_placement, const Eigen::MatrixBase< VectorType > &baumgarte_residual)
Computes the residual of the contact constraints considered by the Baumgarte's stabilization method....
Definition: surface_contact.hxx:17
void computeBaumgarteDerivatives(const pinocchio::Model &model, pinocchio::Data &data, const Eigen::MatrixBase< MatrixType1 > &baumgarte_partial_dq, const Eigen::MatrixBase< MatrixType2 > &baumgarte_partial_dv, const Eigen::MatrixBase< MatrixType3 > &baumgarte_partial_da)
Computes the partial derivatives of the contact constraints considered by the Baumgarte's stabilizati...
Definition: surface_contact.hxx:36
void computeContactVelocityResidual(const pinocchio::Model &model, const pinocchio::Data &data, const Eigen::MatrixBase< VectorType > &velocity_residual) const
Computes the residual of the contact velocity constraints. Before calling this function,...
Definition: surface_contact.hxx:75
void computeContactPositionDerivative(const pinocchio::Model &model, pinocchio::Data &data, const Eigen::MatrixBase< MatrixType > &position_partial_dq)
Computes the partial derivative of the contact position constraint with respect to the configuratio...
Definition: surface_contact.hxx:118
Definition: constraint_component_base.hpp:17
void computeJLog6Map(const SE3Type &SE3_obj, const Eigen::MatrixBase< MatrixType > &J)
Computes the Jacobian of the Log6 map.
Definition: se3.hpp:33
const Eigen::Matrix< double, 6, 1 > Log6Map(const SE3Type &SE3_obj)
Applies Log6 map that transforms the SE3 into 6-dimensional vector.
Definition: se3.hpp:23
pinocchio::SE3 SE3
Using pinocchio::SE3 without its namespace.
Definition: se3.hpp:15
double baumgarte_velocity_gain
The velocity gain of the Baumgarte's stabilization method. Default is 0.0.
Definition: contact_model_info.hpp:78
double baumgarte_position_gain
The position gain of the Baumgarte's stabilization method. Default is 0.0.
Definition: contact_model_info.hpp:72