16 #include <Tasks/QPTasks.h>
70 void reset()
override;
77 void refVel(
const Eigen::VectorXd & vel);
82 const Eigen::VectorXd & refVel()
const;
89 void refAccel(
const Eigen::VectorXd & accel);
94 const Eigen::VectorXd & refAccel()
const;
103 void stiffness(
double stiffness);
114 void stiffness(
const Eigen::VectorXd & stiffness);
121 void damping(
double damping);
130 void damping(
const Eigen::VectorXd & damping);
139 void setGains(
double stiffness,
double damping);
150 void setGains(
const Eigen::VectorXd & stiffness,
const Eigen::VectorXd & damping);
153 double stiffness()
const;
156 double damping()
const;
159 const Eigen::VectorXd & dimStiffness()
const;
162 const Eigen::VectorXd & dimDamping()
const;
169 void weight(
double w);
172 double weight()
const;
174 void dimWeight(
const Eigen::VectorXd & dimW)
override;
176 Eigen::VectorXd dimWeight()
const override;
191 void selectActiveJoints(
const std::vector<std::string> & activeJointsName,
192 const std::map<std::string, std::vector<std::array<int, 2>>> & activeDofs = {},
193 bool checkJoints =
true);
208 const std::vector<std::string> & activeJointsName,
209 const std::map<std::string, std::vector<std::array<int, 2>>> & activeDofs = {})
override;
224 void selectUnactiveJoints(
const std::vector<std::string> & unactiveJointsName,
225 const std::map<std::string, std::vector<std::array<int, 2>>> & unactiveDofs = {},
226 bool checkJoints =
true);
241 const std::vector<std::string> & unactiveJointsName,
242 const std::map<std::string, std::vector<std::array<int, 2>>> & unactiveDofs = {})
override;
244 virtual void resetJointsSelector();
248 Eigen::VectorXd eval()
const override;
250 Eigen::VectorXd speed()
const override;
252 const Eigen::VectorXd & normalAcc()
const;
265 template<Backend backend,
typename ErrorT,
typename... Args>
268 assert(backend == backend_);
269 errorT = mc_rtc::make_void_ptr<ErrorT>(std::forward<Args>(args)...);
270 if constexpr(backend == Backend::Tasks)
272 trajectoryT_ = mc_rtc::make_void_ptr<tasks::qp::TrajectoryTask>(
273 robots.mbs(), rIndex,
static_cast<ErrorT *
>(errorT.get()), stiffness_(0), damping_(0), weight_);
274 auto & trajectory = *
static_cast<tasks::qp::TrajectoryTask *
>(trajectoryT_.get());
275 stiffness_ = trajectory.stiffness();
276 damping_ = trajectory.damping();
277 if(refVel_.size() != trajectory.refVel().size()) { refVel_ = trajectory.refVel(); }
278 if(refAccel_.size() != trajectory.refAccel().size()) { refAccel_ = trajectory.refAccel(); }
280 else if constexpr(backend == Backend::TVM)
282 auto error =
static_cast<ErrorT *
>(errorT.get());
283 trajectoryT_ = mc_rtc::make_void_ptr<details::TVMTrajectoryTaskGenericPtr>(
284 std::make_shared<details::TVMTrajectoryTaskGeneric>());
286 int size =
error->size();
287 stiffness_ = Eigen::VectorXd::Constant(size, 1, stiffness_(0));
288 damping_ = Eigen::VectorXd::Constant(size, 1, damping_(0));
289 if constexpr(details::has_refVel_v<ErrorT>) { refVel_ =
error->refVel(); }
290 if constexpr(details::has_refAccel_v<ErrorT>) { refAccel_ =
error->refAccel(); }
299 std::function<bool(
const mc_tasks::MetaTask & task, std::string &)> buildCompletionCriteria(
312 bool inSolver_ =
false;