PositionTask.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 
8 
10 
11 namespace mc_tasks
12 {
13 
16 {
17 public:
18  friend struct EndEffectorTask;
19 
28  PositionTask(const mc_rbdyn::RobotFrame & frame, double stiffness = 2.0, double weight = 500.0);
29 
43  PositionTask(const std::string & bodyName,
44  const mc_rbdyn::Robots & robots,
45  unsigned int robotIndex,
46  double stiffness = 2.0,
47  double weight = 500);
48 
49  virtual ~PositionTask() = default;
50 
55  void reset() override;
56 
58  inline const Eigen::Vector3d & position() const noexcept
59  {
60  switch(backend_)
61  {
62  case Backend::Tasks:
63  return static_cast<tasks::qp::PositionTask *>(errorT.get())->position();
64  case Backend::TVM:
65  return static_cast<mc_tvm::PositionFunction *>(errorT.get())->position();
66  default:
67  mc_rtc::log::error_and_throw("Not implemented");
68  }
69  }
70 
76  inline void position(const Eigen::Vector3d & pos) noexcept
77  {
78  switch(backend_)
79  {
80  case Backend::Tasks:
81  static_cast<tasks::qp::PositionTask *>(errorT.get())->position(pos);
82  break;
83  case Backend::TVM:
84  static_cast<mc_tvm::PositionFunction *>(errorT.get())->position(pos);
85  break;
86  default:
87  mc_rtc::log::error_and_throw("Not implemented");
88  }
89  }
90 
93  inline const Eigen::Vector3d & bodyPoint() const noexcept
94  {
95  switch(backend_)
96  {
97  case Backend::Tasks:
98  return static_cast<tasks::qp::PositionTask *>(errorT.get())->bodyPoint();
99  case Backend::TVM:
100  {
101  static Eigen::Vector3d res = Eigen::Vector3d::Zero();
102  return res;
103  }
104  default:
105  mc_rtc::log::error_and_throw("Not implemented");
106  }
107  }
108 
109  void addToGUI(mc_rtc::gui::StateBuilder & gui) override;
110 
111 protected:
113  void addToLogger(mc_rtc::Logger & logger) override;
114 };
115 
116 } // namespace mc_tasks
mc_rbdyn::Robots
Definition: Robots.h:15
mc_tasks::PositionTask::position
void position(const Eigen::Vector3d &pos) noexcept
Set the position target.
Definition: PositionTask.h:76
MC_TASKS_DLLAPI
#define MC_TASKS_DLLAPI
Definition: api.h:50
mc_tvm::PositionFunction
Definition: PositionFunction.h:18
mc_tasks::PositionTask::frame_
mc_rbdyn::ConstRobotFramePtr frame_
Definition: PositionTask.h:112
mc_tasks::PositionTask::bodyPoint
const Eigen::Vector3d & bodyPoint() const noexcept
Get the body point being controlled.
Definition: PositionTask.h:93
PositionFunction.h
mc_rtc::Logger
Logs controller data to disk.
Definition: Logger.h:29
mc_tasks::PositionTask
Control the position of a frame.
Definition: PositionTask.h:15
mc_rbdyn::RobotFrame
Definition: RobotFrame.h:21
mc_rtc::gui::StateBuilder
Definition: StateBuilder.h:27
mc_rtc::log::error_and_throw
void error_and_throw(Args &&... args)
Definition: logging.h:47
mc_rbdyn::ConstRobotFramePtr
std::shared_ptr< const RobotFrame > ConstRobotFramePtr
Definition: fwd.h:25
mc_tasks::PositionTask::position
const Eigen::Vector3d & position() const noexcept
Get the position target.
Definition: PositionTask.h:58
mc_tasks::EndEffectorTask
Controls an end-effector.
Definition: EndEffectorTask.h:19
mc_tasks
Definition: StabilizerStandingState.h:11
TrajectoryTaskGeneric.h
mc_tasks::TrajectoryTaskGeneric
Generic wrapper for a trajectory dynamic over an error function.
Definition: TrajectoryTaskGeneric.h:26