CoPTask.h
Go to the documentation of this file.
1 /*
2  * Copyright 2015-2019 CNRS-UM LIRMM, CNRS-AIST JRL
3  */
4 
5 #pragma once
6 
7 #include <mc_tasks/DampingTask.h>
8 
9 namespace mc_tasks
10 {
11 
12 namespace force
13 {
14 
29 {
30 public:
31  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
32 
44  CoPTask(const mc_rbdyn::RobotFrame & frame, double stiffness = 5.0, double weight = 1000.0);
45 
75  CoPTask(const std::string & robotSurface,
76  const mc_rbdyn::Robots & robots,
77  unsigned robotIndex,
78  double stiffness = 5.0,
79  double weight = 1000.0);
80 
88  void reset() override;
89 
96  std::function<bool(const mc_tasks::MetaTask &, std::string &)> buildCompletionCriteria(
97  double dt,
98  const mc_rtc::Configuration & config) const override;
99 
105  inline void useTargetPressure(bool s) noexcept { useTargetPressure_ = s; }
106 
110  inline bool useTargetPressure() const noexcept { return useTargetPressure_; }
111 
115  Eigen::Vector2d measuredCoP() const { return frame_->cop(); }
116 
120  Eigen::Vector3d measuredCoPW() const { return frame_->copW(); }
121 
126  {
127  AdmittanceTask::targetWrench(sva::ForceVecd{Eigen::Vector6d::Zero()});
128  targetCoP(Eigen::Vector2d::Zero());
129  }
130 
132  const Eigen::Vector2d & targetCoP() const { return targetCoP_; }
133 
135  Eigen::Vector3d targetCoPW() const
136  {
137  Eigen::Vector3d cop_s;
138  cop_s << targetCoP_, 0.;
139  sva::PTransformd X_0_s = frame_->position();
140  return X_0_s.translation() + X_0_s.rotation().transpose() * cop_s;
141  }
142 
148  void targetCoP(const Eigen::Vector2d & targetCoP) { targetCoP_ = targetCoP; }
149 
151  const Eigen::Vector3d & targetForce() const { return targetForce_; }
152 
158  void targetForce(const Eigen::Vector3d & targetForce) { targetForce_ = targetForce; }
159 
164  void targetForceW(const Eigen::Vector3d & targetForceW)
165  {
166  const auto & X_0_rh = frame_->position();
167  targetForce(X_0_rh.dualMul(sva::ForceVecd(Eigen::Vector3d::Zero(), targetForceW)).force());
168  }
169 
173  const sva::ForceVecd & targetWrench() const { return AdmittanceTask::targetWrench(); }
174 
176  void load(mc_solver::QPSolver & solver, const mc_rtc::Configuration & config) override;
177 
178 protected:
179  void addToLogger(mc_rtc::Logger & logger) override;
180  void addToGUI(mc_rtc::gui::StateBuilder & gui) override;
181 
182 private:
183  Eigen::Vector2d targetCoP_ = Eigen::Vector2d::Zero();
184  Eigen::Vector3d targetForce_ = Eigen::Vector3d::Zero();
185 
186  bool useTargetPressure_ = false;
187 
188  void update(mc_solver::QPSolver &) override;
189 
192 };
193 
194 } // namespace force
195 
196 } // namespace mc_tasks
mc_rtc::Configuration
Simplify access to values hold within a JSON file.
Definition: Configuration.h:165
mc_rbdyn::Robots
Definition: Robots.h:15
mc_tasks::MetaTask
Represents a generic task.
Definition: MetaTask.h:39
mc_tasks::force::CoPTask::targetForce
const Eigen::Vector3d & targetForce() const
Get target force in the control frame.
Definition: CoPTask.h:151
mc_tasks::force::CoPTask::measuredCoP
Eigen::Vector2d measuredCoP() const
Measured CoP in target frame.
Definition: CoPTask.h:115
MC_TASKS_DLLAPI
#define MC_TASKS_DLLAPI
Definition: api.h:50
mc_solver::QPSolver
Definition: QPSolver.h:85
mc_tasks::force::AdmittanceTask::targetWrenchW
void targetWrenchW(const sva::ForceVecd &wrenchW)
Set the target wrench in world frame.
Definition: AdmittanceTask.h:123
mc_tasks::force::DampingTask
Hybrid position-force control on a contacting end-effector.
Definition: DampingTask.h:36
mc_tasks::force::CoPTask::targetForceW
void targetForceW(const Eigen::Vector3d &targetForceW)
Set target force in the world frame.
Definition: CoPTask.h:164
mc_tasks::force::CoPTask::targetCoP
const Eigen::Vector2d & targetCoP() const
Get target CoP in the control frame.
Definition: CoPTask.h:132
mc_rtc::Logger
Logs controller data to disk.
Definition: Logger.h:29
mc_tasks::force::CoPTask::useTargetPressure
void useTargetPressure(bool s) noexcept
Wether to compute the desired torque with the target pressure (true) of the measured one (false)
Definition: CoPTask.h:105
mc_tasks::force::CoPTask::setZeroTargetWrench
void setZeroTargetWrench()
Set targent wrench to zero.
Definition: CoPTask.h:125
mc_tasks::force::CoPTask::targetCoP
void targetCoP(const Eigen::Vector2d &targetCoP)
Set target CoP in the control frame.
Definition: CoPTask.h:148
mc_tasks::force::CoPTask::targetForce
void targetForce(const Eigen::Vector3d &targetForce)
Set target force in the control frame.
Definition: CoPTask.h:158
mc_rbdyn::RobotFrame
Definition: RobotFrame.h:21
DampingTask.h
mc_rtc::gui::StateBuilder
Definition: StateBuilder.h:27
mc_tasks::force::CoPTask::useTargetPressure
bool useTargetPressure() const noexcept
Wether the computeddesired torque is done with the target pressure (true) of the measured one (false)
Definition: CoPTask.h:110
mc_tasks::force::CoPTask::targetWrench
const sva::ForceVecd & targetWrench() const
Get target wrench in the control frame.
Definition: CoPTask.h:173
mc_tasks::force::CoPTask::measuredCoPW
Eigen::Vector3d measuredCoPW() const
Measured CoP in world frame.
Definition: CoPTask.h:120
mc_tasks::force::CoPTask::targetCoPW
Eigen::Vector3d targetCoPW() const
Get target CoP in the world frame.
Definition: CoPTask.h:135
mc_tasks::force::CoPTask
Track center-of-pressure (CoP) references at contact.
Definition: CoPTask.h:28
mc_tasks
Definition: StabilizerStandingState.h:11
mc_tasks::force::AdmittanceTask::targetWrench
const sva::ForceVecd & targetWrench() const
Get the target wrench in the control frame.
Definition: AdmittanceTask.h:117