DynamicFunction.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 
9 #include <mc_rbdyn/fwd.h>
10 
11 #include <tvm/function/abstract/LinearFunction.h>
12 
13 #include <RBDyn/Jacobian.h>
14 
15 #include <SpaceVecAlg/SpaceVecAlg>
16 
17 namespace mc_tvm
18 {
19 
31 struct MC_TVM_DLLAPI DynamicFunction : public tvm::function::abstract::LinearFunction
32 {
33 public:
34  using Output = tvm::function::abstract::LinearFunction::Output;
35  DISABLE_OUTPUTS(Output::JDot)
36  SET_UPDATES(DynamicFunction, Jacobian, B)
37 
38 
39  DynamicFunction(const mc_rbdyn::Robot & robot);
40 
54  const tvm::VariableVector & addContact(const mc_rbdyn::RobotFrame & frame,
55  std::vector<sva::PTransformd> points,
56  double dir);
57 
62  void removeContact(const mc_rbdyn::RobotFrame & frame);
63 
70  sva::ForceVecd contactForce(const mc_rbdyn::RobotFrame & f) const;
71 
72 protected:
73  void updateb();
74 
76 
78  struct ForceContact
79  {
81  ForceContact(const mc_rbdyn::RobotFrame & frame, std::vector<sva::PTransformd> points, double dir);
82 
84  void updateJacobians(DynamicFunction & parent);
85 
87  sva::ForceVecd force() const;
88 
91 
93  tvm::VariableVector forces_;
94 
96  std::vector<sva::PTransformd> points_;
97 
99  double dir_;
100 
102  rbd::Jacobian jac_;
104  rbd::Blocks blocks_;
105 
107  Eigen::MatrixXd force_jac_;
108  Eigen::MatrixXd full_jac_;
109  };
110  std::vector<ForceContact> contacts_;
111 
112  std::vector<ForceContact>::const_iterator findContact(const mc_rbdyn::RobotFrame & frame) const;
113 
114  void updateJacobian();
115 };
116 
117 using DynamicFunctionPtr = std::shared_ptr<DynamicFunction>;
118 
119 } // namespace mc_tvm
mc_tvm::DynamicFunction::ForceContact::dir_
double dir_
Definition: DynamicFunction.h:99
mc_tvm::DynamicFunction::ForceContact::blocks_
rbd::Blocks blocks_
Definition: DynamicFunction.h:104
MC_TVM_DLLAPI
#define MC_TVM_DLLAPI
Definition: api.h:47
mc_rbdyn::Robot
Definition: Robot.h:62
mc_tvm::DynamicFunction::Output
tvm::function::abstract::LinearFunction::Output Output
Definition: DynamicFunction.h:34
mc_tvm::DynamicFunction::robot_
const mc_rbdyn::Robot & robot_
Definition: DynamicFunction.h:75
mc_tvm
Definition: CollisionFunction.h:15
mc_tvm::DynamicFunction::ForceContact::jac_
rbd::Jacobian jac_
Definition: DynamicFunction.h:102
mc_tvm::DynamicFunction::ForceContact
Definition: DynamicFunction.h:78
mc_tvm::DynamicFunction
Definition: DynamicFunction.h:31
mc_rbdyn::RobotFrame
Definition: RobotFrame.h:21
fwd.h
mc_rbdyn::ConstRobotFramePtr
std::shared_ptr< const RobotFrame > ConstRobotFramePtr
Definition: fwd.h:25
mc_tvm::DynamicFunction::ForceContact::points_
std::vector< sva::PTransformd > points_
Definition: DynamicFunction.h:96
mc_tvm::DynamicFunction::ForceContact::full_jac_
Eigen::MatrixXd full_jac_
Definition: DynamicFunction.h:108
mc_tvm::DynamicFunction::ForceContact::frame_
mc_rbdyn::ConstRobotFramePtr frame_
Definition: DynamicFunction.h:90
mc_tvm::DynamicFunctionPtr
std::shared_ptr< DynamicFunction > DynamicFunctionPtr
Definition: DynamicFunction.h:117
mc_tvm::DynamicFunction::ForceContact::forces_
tvm::VariableVector forces_
Definition: DynamicFunction.h:93
mc_tvm::DynamicFunction::contacts_
std::vector< ForceContact > contacts_
Definition: DynamicFunction.h:110
api.h
mc_tvm::DynamicFunction::ForceContact::force_jac_
Eigen::MatrixXd force_jac_
Definition: DynamicFunction.h:107