robotoc
robotoc - efficient ROBOT Optimal Control solvers
Loading...
Searching...
No Matches
surface_contact.hpp
Go to the documentation of this file.
1#ifndef ROBOTOC_SURFACE_CONTACT_HPP_
2#define ROBOTOC_SURFACE_CONTACT_HPP_
3
4#include "Eigen/Core"
5#include "pinocchio/multibody/model.hpp"
6#include "pinocchio/multibody/data.hpp"
7#include "pinocchio/container/aligned-vector.hpp"
8#include "pinocchio/spatial/force.hpp"
9
11#include "robotoc/robot/se3.hpp"
12
13#include <iostream>
14
15
16namespace robotoc {
17
23public:
24 using Vector6d = Eigen::Matrix<double, 6, 1>;
25 using Matrix66d = Eigen::Matrix<double, 6, 6>;
26 using Matrix6xd = Eigen::Matrix<double, 6, Eigen::Dynamic>;
27
34 SurfaceContact(const pinocchio::Model& model,
35 const ContactModelInfo& contact_model_info);
36
41
45 ~SurfaceContact() = default;
46
50 SurfaceContact(const SurfaceContact&) = default;
51
56
60 SurfaceContact(SurfaceContact&&) noexcept = default;
61
65 SurfaceContact& operator=(SurfaceContact&&) noexcept = default;
66
74 const Vector6d& contact_wrench,
75 pinocchio::container::aligned_vector<pinocchio::Force>& joint_forces) const;
76
88 template <typename VectorType>
90 const pinocchio::Model& model, const pinocchio::Data& data,
91 const SE3& desired_contact_placement,
92 const Eigen::MatrixBase<VectorType>& baumgarte_residual);
93
108 template <typename MatrixType1, typename MatrixType2, typename MatrixType3>
110 const pinocchio::Model& model, pinocchio::Data& data,
111 const Eigen::MatrixBase<MatrixType1>& baumgarte_partial_dq,
112 const Eigen::MatrixBase<MatrixType2>& baumgarte_partial_dv,
113 const Eigen::MatrixBase<MatrixType3>& baumgarte_partial_da);
114
123 template <typename VectorType>
125 const pinocchio::Model& model, const pinocchio::Data& data,
126 const Eigen::MatrixBase<VectorType>& velocity_residual) const;
127
139 template <typename MatrixType1, typename MatrixType2>
141 const pinocchio::Model& model, pinocchio::Data& data,
142 const Eigen::MatrixBase<MatrixType1>& velocity_partial_dq,
143 const Eigen::MatrixBase<MatrixType2>& velocity_partial_dv);
144
155 template <typename VectorType>
157 const pinocchio::Model& model, const pinocchio::Data& data,
158 const SE3& desired_contact_placement,
159 const Eigen::MatrixBase<VectorType>& position_residual);
160
171 template <typename MatrixType>
173 const pinocchio::Model& model, pinocchio::Data& data,
174 const Eigen::MatrixBase<MatrixType>& position_partial_dq);
175
183 const SE3& contactPlacement(const pinocchio::Data& data) const;
184
192 void setBaumgarteGains(const double baumgarte_position_gain,
193 const double baumgarte_velocity_gain);
194
199 int contactFrameId() const;
200
206 int parentJointId() const;
207
213
217 void disp(std::ostream& os) const;
218
219 friend std::ostream& operator<<(std::ostream& os,
220 const SurfaceContact& surface_contact);
221
222 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
223
224private:
225 ContactModelInfo info_;
226 int contact_frame_id_, parent_joint_id_, dimv_;
227 pinocchio::SE3 jXf_, X_diff_;
228 Matrix6xd J_frame_, frame_v_partial_dq_, frame_a_partial_dq_,
229 frame_a_partial_dv_, frame_a_partial_da_;
230 Matrix66d Jlog6_;
231};
232
233} // namespace robotoc
234
235#include "robotoc/robot/surface_contact.hxx"
236
237#endif // ROBOTOC_SURFACE_CONTACT_HPP_
Kinematics and dynamic model of a surface contact.
Definition: surface_contact.hpp:22
Eigen::Matrix< double, 6, 1 > Vector6d
Definition: surface_contact.hpp:24
~SurfaceContact()=default
Destructor.
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
SurfaceContact & operator=(const SurfaceContact &)=default
Default copy assign operator.
void computeJointForceFromContactWrench(const Vector6d &contact_wrench, pinocchio::container::aligned_vector< pinocchio::Force > &joint_forces) const
Converts the 6D contact wrench in the local coordinate to the corresponding joint spatial forces.
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
Eigen::Matrix< double, 6, 6 > Matrix66d
Definition: surface_contact.hpp:25
SurfaceContact(SurfaceContact &&) noexcept=default
Default move constructor.
int contactFrameId() const
Returns contact frame id, i.e., the index of the contact frame.
SurfaceContact()
Default constructor.
SurfaceContact(const pinocchio::Model &model, const ContactModelInfo &contact_model_info)
Construct a surface contact model.
int parentJointId() const
Returns parent joint id, i.e., the index of the parent joint of the contact frame.
SurfaceContact(const SurfaceContact &)=default
Default copy constructor.
void setBaumgarteGains(const double baumgarte_position_gain, const double baumgarte_velocity_gain)
Sets the gain parameters of the Baumgarte's stabilization method.
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
const SE3 & contactPlacement(const pinocchio::Data &data) const
Returns the contact placement at the current kinematics of the robot. Before calling this function,...
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 disp(std::ostream &os) const
Displays the surface contact onto a ostream.
const ContactModelInfo & contactModelInfo() const
Gets the contact model info.
Eigen::Matrix< double, 6, Eigen::Dynamic > Matrix6xd
Definition: surface_contact.hpp:26
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
std::vector< T, Eigen::aligned_allocator< T > > aligned_vector
std vector with Eigen::aligned_allocator.
Definition: aligned_vector.hpp:14
pinocchio::SE3 SE3
Using pinocchio::SE3 without its namespace.
Definition: se3.hpp:15
Info of a contact model.
Definition: contact_model_info.hpp:12