CoMInConvexFunction.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/CoM.h>
8 #include <mc_tvm/Robot.h>
9 
10 #include <mc_rbdyn/fwd.h>
11 
12 #include <tvm/function/abstract/Function.h>
13 #include <tvm/geometry/Plane.h>
14 
15 namespace mc_tvm
16 {
17 
23 struct MC_TVM_DLLAPI CoMInConvexFunction : public tvm::function::abstract::Function
24 {
25 public:
26  using Output = tvm::function::abstract::Function::Output;
27  DISABLE_OUTPUTS(Output::JDot)
28  SET_UPDATES(CoMInConvexFunction, Value, Velocity, Jacobian, NormalAcceleration)
29 
30 
35  CoMInConvexFunction(const mc_rbdyn::Robot & robot);
36 
43  void addPlane(tvm::geometry::PlanePtr plane);
44 
46  void reset();
47 
49  inline const mc_rbdyn::Robot & robot() const noexcept { return com_.robot().robot(); }
50 
52  inline const std::vector<tvm::geometry::PlanePtr> & planes() noexcept { return planes_; }
53 
55  inline tvm::geometry::Plane & plane(size_t i) noexcept
56  {
57  assert(i < planes_.size() && planes_[i]);
58  return *planes_[i];
59  }
60 
62  Eigen::VectorXd & selector() noexcept { return selector_; }
63 
65  const Eigen::VectorXd & selector() const noexcept { return selector_; }
66 
67 protected:
68  void updateValue();
69  void updateVelocity();
70  void updateJacobian();
71  void updateNormalAcceleration();
72 
74 
76  std::vector<tvm::geometry::PlanePtr> planes_;
77 
79  Eigen::VectorXd selector_;
80 };
81 
82 using CoMInConvexFunctionPtr = std::shared_ptr<CoMInConvexFunction>;
83 
84 } // namespace mc_tvm
mc_tvm::CoMInConvexFunctionPtr
std::shared_ptr< CoMInConvexFunction > CoMInConvexFunctionPtr
Definition: CoMInConvexFunction.h:82
mc_tvm::CoMInConvexFunction::planes
const std::vector< tvm::geometry::PlanePtr > & planes() noexcept
Definition: CoMInConvexFunction.h:52
Robot.h
mc_tvm::CoMInConvexFunction::Output
tvm::function::abstract::Function::Output Output
Definition: CoMInConvexFunction.h:26
mc_tvm::CoMInConvexFunction::plane
tvm::geometry::Plane & plane(size_t i) noexcept
Definition: CoMInConvexFunction.h:55
MC_TVM_DLLAPI
#define MC_TVM_DLLAPI
Definition: api.h:47
mc_tvm::CoMInConvexFunction::selector
const Eigen::VectorXd & selector() const noexcept
Definition: CoMInConvexFunction.h:65
mc_rbdyn::Robot
Definition: Robot.h:62
mc_tvm
Definition: CollisionFunction.h:15
mc_tvm::CoMInConvexFunction::selector
Eigen::VectorXd & selector() noexcept
Definition: CoMInConvexFunction.h:62
mc_tvm::CoMInConvexFunction
Definition: CoMInConvexFunction.h:23
CoM.h
fwd.h
mc_tvm::CoMInConvexFunction::com_
mc_tvm::CoM & com_
Definition: CoMInConvexFunction.h:73
mc_tvm::CoMInConvexFunction::selector_
Eigen::VectorXd selector_
Definition: CoMInConvexFunction.h:79
mc_tvm::CoM
Definition: CoM.h:33
mc_tvm::CoMInConvexFunction::planes_
std::vector< tvm::geometry::PlanePtr > planes_
Definition: CoMInConvexFunction.h:76
mc_tvm::CoMInConvexFunction::robot
const mc_rbdyn::Robot & robot() const noexcept
Definition: CoMInConvexFunction.h:49