establish struct cost pattern

for costs with multiple parameters, this option-style is more useful
than verbose getter/setter. There is nothing to hide here.
This commit is contained in:
v4hn 2020-06-30 11:10:33 +02:00
parent f9ba302728
commit cf0e4e3b01

View File

@ -8,15 +8,14 @@ namespace cost {
/// These structures all implement the Stage::CostTerm API and can be configured via Stage::setCostTerm() /// These structures all implement the Stage::CostTerm API and can be configured via Stage::setCostTerm()
/// add a constant cost to each solution /// add a constant cost to each solution
class ConstantCost struct ConstantCost
{ {
public: public:
ConstantCost(double cost) : cost_(cost) {} ConstantCost(double c) : cost(c) {}
double operator()(const SubTrajectory&) { return cost_; } double operator()(const SubTrajectory&, std::string& /* unused */) const { return cost; }
private: double cost;
double cost_;
}; };
/// execution duration of the whole trajectory /// execution duration of the whole trajectory