GazeFunction.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 #include <optional>
17 
18 namespace mc_tvm
19 {
20 
30 struct MC_TVM_DLLAPI GazeFunction : tvm::function::abstract::Function
31 {
32  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
33 
34  SET_UPDATES(GazeFunction, Value, Velocity, Jacobian, NormalAcceleration)
35 
36 
40  GazeFunction(const mc_rbdyn::RobotFrame & frame);
41 
43  inline void reset() { pointRef_ = point_; }
44 
49  void estimate(const Eigen::Vector2d & point, std::optional<double> depth = std::nullopt);
50 
55  void estimate(const Eigen::Vector3d & point);
56 
58  inline void target(const Eigen::Vector2d & ref) noexcept { pointRef_ = ref; }
59 
61  inline const Eigen::Vector2d & target() const noexcept { return pointRef_; }
62 
64  inline const mc_rbdyn::RobotFrame & frame() const noexcept { return *frame_; }
65 
66 protected:
69  rbd::Jacobian frameJac_;
70 
71  /* Inputs to the function */
72  Eigen::Vector2d point_ = Eigen::Vector2d::Zero();
73  Eigen::Vector2d pointRef_ = Eigen::Vector2d::Zero();
74  double depthEstimate_ = 1.0;
75 
76  /* Computation intermediates */
77  Eigen::Matrix<double, 2, 6> L_img_;
78  Eigen::Matrix<double, 6, 1> surfaceVelocity_;
79  Eigen::Matrix<double, 1, 6> L_Z_dot_;
80  Eigen::Matrix<double, 2, 6> L_img_dot_;
81 
82  /* TVM update methods */
83  void updateValue();
84  void updateVelocity();
85  void updateJacobian();
86  Eigen::MatrixXd shortJacMat_;
87  Eigen::MatrixXd jacMat_;
88  void updateNormalAcceleration();
89 
90  void setDepthEstimate(double depth);
91 };
92 
93 } // namespace mc_tvm
mc_tvm::GazeFunction::frame_
mc_rbdyn::ConstRobotFramePtr frame_
Definition: GazeFunction.h:67
mc_tvm::GazeFunction
Definition: GazeFunction.h:30
mc_tvm::GazeFunction::shortJacMat_
Eigen::MatrixXd shortJacMat_
Definition: GazeFunction.h:86
mc_tvm::GazeFunction::jacMat_
Eigen::MatrixXd jacMat_
Definition: GazeFunction.h:87
MC_TVM_DLLAPI
#define MC_TVM_DLLAPI
Definition: api.h:47
mc_tvm
Definition: CollisionFunction.h:15
mc_tvm::GazeFunction::tvm_frame_
mc_tvm::RobotFrame & tvm_frame_
Definition: GazeFunction.h:68
mc_tvm::GazeFunction::reset
void reset()
Definition: GazeFunction.h:43
mc_tvm::GazeFunction::target
void target(const Eigen::Vector2d &ref) noexcept
Definition: GazeFunction.h:58
mc_rbdyn::RobotFrame
Definition: RobotFrame.h:21
mc_tvm::GazeFunction::L_img_
Eigen::Matrix< double, 2, 6 > L_img_
Definition: GazeFunction.h:77
mc_tvm::GazeFunction::frameJac_
rbd::Jacobian frameJac_
Definition: GazeFunction.h:69
mc_tvm::GazeFunction::target
const Eigen::Vector2d & target() const noexcept
Definition: GazeFunction.h:61
mc_tvm::GazeFunction::L_Z_dot_
Eigen::Matrix< double, 1, 6 > L_Z_dot_
Definition: GazeFunction.h:79
fwd.h
fwd.h
mc_rbdyn::ConstRobotFramePtr
std::shared_ptr< const RobotFrame > ConstRobotFramePtr
Definition: fwd.h:25
mc_tvm::RobotFrame
Definition: RobotFrame.h:27
mc_tvm::GazeFunction::frame
const mc_rbdyn::RobotFrame & frame() const noexcept
Definition: GazeFunction.h:64
mc_tvm::GazeFunction::surfaceVelocity_
Eigen::Matrix< double, 6, 1 > surfaceVelocity_
Definition: GazeFunction.h:78
mc_tvm::GazeFunction::L_img_dot_
Eigen::Matrix< double, 2, 6 > L_img_dot_
Definition: GazeFunction.h:80
api.h