ContactFunction.h
Go to the documentation of this file.
1 /*
2  * Copyright 2015-2022 CNRS-UM LIRMM, CNRS-AIST JRL
3  */
4 
5 #pragma once
6 
7 #include <mc_tvm/api.h>
8 #include <mc_tvm/fwd.h>
9 
10 #include <mc_rbdyn/fwd.h>
11 
12 #include <tvm/function/abstract/Function.h>
13 
14 #include <RBDyn/Jacobian.h>
15 
16 namespace mc_tvm
17 {
18 
39 class MC_TVM_DLLAPI ContactFunction : public tvm::function::abstract::Function
40 {
41 public:
42  using Output = tvm::function::abstract::Function::Output;
43  DISABLE_OUTPUTS(Output::JDot)
44  SET_UPDATES(ContactFunction, Value, Derivatives)
45 
46 
56  const mc_rbdyn::Frame & f2,
57  const Eigen::Vector6d & dof = Eigen::Vector6d::Ones());
58 
60  inline const Eigen::Vector6d & dof() const noexcept { return dof_; }
61 
63  inline void dof(const Eigen::Vector6d & dof) noexcept { dof_ = dof; }
64 
65 private:
66  const Frame * f1_;
67  const Frame * f2_;
68  Eigen::Vector6d dof_;
69 
70  bool use_f1_ = false;
71  rbd::Jacobian f1Jacobian_;
72  bool use_f2_ = false;
73  rbd::Jacobian f2Jacobian_;
74  sva::PTransformd X_0_cf_;
75  sva::PTransformd X_cf_f1_;
76  sva::PTransformd X_cf_f2_;
77 
78  Eigen::MatrixXd jacTmp_;
79  Eigen::MatrixXd jac_;
80 
81  void updateValue();
82  // Derivatives update involve many intermediary that are used for all computations
83  void updateDerivatives();
84 };
85 
86 using ContactFunctionPtr = std::shared_ptr<mc_tvm::ContactFunction>;
87 
88 } // namespace mc_tvm
mc_tvm::ContactFunction::dof
void dof(const Eigen::Vector6d &dof) noexcept
Definition: ContactFunction.h:63
MC_TVM_DLLAPI
#define MC_TVM_DLLAPI
Definition: api.h:47
mc_tvm::ContactFunction
Definition: ContactFunction.h:39
mc_rbdyn::Frame
Definition: Frame.h:27
mc_tvm
Definition: CollisionFunction.h:15
fwd.h
fwd.h
mc_tvm::ContactFunction::Output
tvm::function::abstract::Function::Output Output
Definition: ContactFunction.h:42
mc_tvm::ContactFunction::dof
const Eigen::Vector6d & dof() const noexcept
Definition: ContactFunction.h:60
mc_tvm::Frame
Definition: Frame.h:33
api.h
mc_tvm::ContactFunctionPtr
std::shared_ptr< mc_tvm::ContactFunction > ContactFunctionPtr
Definition: ContactFunction.h:86