12 #include "views/proxy.h"
15 #include "nonstd/numerics.h"
35 template <
class CfgType>
47 DefaultWeight(
const std::string& _label =
"",
const double _w = 0,
48 const std::vector<CfgType>& _intermediates = std::vector<CfgType>());
85 const std::string&
GetLPLabel() const noexcept;
87 void SetLPLabel(const std::
string& _lpLabel) noexcept;
104 void SetWeight(const
double _w) noexcept;
116 bool IsChecked(const
int _mult) const noexcept;
143 virtual
void Read(std::istream& _is);
147 virtual
void Write(std::ostream& _os) const;
163 double Weight() const noexcept;
193 void define_type(stapl::typer &t)
204 template <
typename CfgType>
207 const std::vector<CfgType>& _intermediates) :
208 m_lpLabel(_label), m_weight(_w), m_intermediates(_intermediates) {
213 template <
typename CfgType>
231 template <
typename CfgType>
235 static constexpr
double tolerance = 100
236 * std::numeric_limits<double>::epsilon();
238 return nonstd::approx(m_weight, _w.GetWeight(), tolerance)
239 and m_intermediates == _w.GetIntermediates();
243 template <
typename CfgType>
247 return !(*
this == _w);
251 template <
typename CfgType>
255 return m_weight < _w.m_weight;
260 template <
typename CfgType>
268 template <
typename CfgType>
271 SetLPLabel(
const std::string& _label) noexcept {
276 template <
typename CfgType>
277 std::vector<CfgType>&
280 return m_intermediates;
284 template <
typename CfgType>
285 const std::vector<CfgType>&
288 return m_intermediates;
292 template <
typename CfgType>
296 m_intermediates = _intermediates;
300 template <
typename CfgType>
304 m_intermediates = std::move(_intermediates);
308 template <
typename CfgType>
316 template <
typename CfgType>
328 template <
typename CfgType>
335 template <
typename CfgType>
342 template <
typename CfgType>
352 template <
typename CfgType>
360 template <
typename CfgType>
367 template <
typename CfgType>
371 m_timeSteps = _steps;
375 template <
typename CfgType>
378 IsChecked(
const int _mult)
const noexcept {
379 return m_checkedMult <= _mult;
383 template <
typename CfgType>
387 m_checkedMult = std::min(m_checkedMult, _mult);
391 template <
typename CfgType>
399 template <
typename CfgType>
411 template <
typename CfgType>
417 m_intermediates.clear();
420 m_checkedMult = std::numeric_limits<int>::max();
421 m_clearance = std::numeric_limits<double>::infinity();
427 template <
typename CfgType>
434 template <
typename CfgType>
437 Read(std::istream& _is) {
440 <<
"we are reading for. Use inputRobot "
441 <<
"member to specify.";
446 size_t numIntermediates;
447 _is >> numIntermediates;
448 m_intermediates.clear();
450 CfgType tmp(inputRobot);
451 for(
size_t i = 0; i < numIntermediates; ++i) {
453 m_intermediates.push_back(tmp);
459 if(inputRobot->IsNonholonomic()) {
462 std::size_t numControls;
467 for(std::size_t i = 0; i < numControls; i++) {
477 if(label.compare(
"Coast") == 0)
480 con.
actuator = inputRobot->GetActuator(label);
484 std::size_t signalLength = inputRobot->GetMultiBody()->DOF();
485 con.
signal.resize(signalLength, 0);
486 for(std::size_t j = 0; j < signalLength; j++) {
496 m_controls.push_back(con);
506 template <
typename CfgType>
509 Write(std::ostream& _os)
const {
514 _os << m_intermediates.size() <<
" ";
515 for(
auto& cfg : m_intermediates)
517 _os << std::scientific << std::setprecision(16) << m_weight;
521 if(!m_controls.empty()) {
523 _os <<
" " << m_timeSteps <<
" " << m_controls.size() <<
" ";
527 for(
auto control : m_controls) {
530 _os << control.actuator->GetLabel() <<
" ";
537 for (
double& val : control.signal)
544 _os.unsetf(std::ios_base::floatfield);
549 template <
typename CfgType>
557 template <
typename CfgType>
566 template <
typename CfgType>
574 template <
typename CfgType>
582 template <
typename CfgType>
586 static constexpr
double max = std::numeric_limits<double>::max();
std::vector< Control > ControlSet
A discrete set of controls can be defined by a sequence of allowed controls.
Definition: Control.h:91
#define WHERE
Macro for retrieving info about file, function, and line number.
Definition: RuntimeUtils.h:32
std::ostream & operator<<(std::ostream &_os, const DefaultWeight< CfgType > &_w)
Definition: Weight.h:551
std::istream & operator>>(std::istream &_is, DefaultWeight< CfgType > &_w)
Definition: Weight.h:559
void SetLPLabel(const std::string &_lpLabel) noexcept
Set the string label value.
Definition: Weight.h:271
void SetTimeSteps(std::size_t _steps) noexcept
Definition: Weight.h:370
void SetControl(const Control &_c) noexcept
Set a singular control corresponding to the path given by the weight.
Definition: Weight.h:331
static Robot * inputRobot
Definition: Weight.h:151
virtual bool operator<(const DefaultWeight &_other) const noexcept
Definition: Weight.h:254
void SetChecked(const int _mult) noexcept
Definition: Weight.h:386
std::vector< CfgType > & GetIntermediates() noexcept
Definition: Weight.h:279
virtual const DefaultWeight & operator=(const DefaultWeight &_w)
Definition: Weight.h:216
virtual void Read(std::istream &_is)
Definition: Weight.h:437
std::string m_lpLabel
Label of local planner that built this edge.
Definition: Weight.h:173
double m_clearance
The clearance value, or inf if not evaluated.
Definition: Weight.h:182
void SetWeight(const double _w) noexcept
Set the numerical weight value.
Definition: Weight.h:319
DefaultWeight(const std::string &_label="", const double _w=0, const std::vector< CfgType > &_intermediates=std::vector< CfgType >())
Definition: Weight.h:206
bool IsChecked(const int _mult) const noexcept
Is the checked resolution multiple at most _mult?
Definition: Weight.h:378
const ControlSet & GetControlSet() const noexcept
Get a vector of controls corresponding to the path given by the weight.
Definition: Weight.h:338
const std::string & GetLPLabel() const noexcept
Get the string label value.
Definition: Weight.h:263
void SetIntermediates(const std::vector< CfgType > &_intermediates) noexcept
Set the intermediate configurations corresponding to the current weight.
Definition: Weight.h:295
virtual bool operator!=(const DefaultWeight &_w) const noexcept
Definition: Weight.h:246
virtual DefaultWeight operator+(const DefaultWeight &_other) const
This only adds weights, it doesn't take intermediates into account.
Definition: Weight.h:569
double Weight() const noexcept
Definition: Weight.h:577
virtual bool operator==(const DefaultWeight &_w) const noexcept
Definition: Weight.h:234
double GetWeight() const noexcept
Get the numerical weight value.
Definition: Weight.h:311
double GetClearance() const noexcept
Get the clearance value of the current weight.
Definition: Weight.h:394
void SetControlSet(const ControlSet &_c) noexcept
Set a vector of controls corresponding to the path given by the weight.
Definition: Weight.h:355
int m_checkedMult
The checked resolution multiple (for lazy query), or max if none.
Definition: Weight.h:179
void Clear()
Clear all of the contents of the object to a reinitialized state.
Definition: Weight.h:414
bool HasClearance() const noexcept
ControlSet m_controls
The controls used.
Definition: Weight.h:185
size_t GetTimeSteps() const noexcept
Definition: Weight.h:363
std::vector< CfgType > m_intermediates
Intermediate configurations.
Definition: Weight.h:176
size_t m_timeSteps
The number of timesteps to apply the controls.
Definition: Weight.h:186
void SetClearance(const double _c) noexcept
Definition: Weight.h:402
virtual ~DefaultWeight()=default
double m_weight
The edge length.
Definition: Weight.h:175
virtual void Write(std::ostream &_os) const
Definition: Weight.h:509
static DefaultWeight MaxWeight() noexcept
Definition: Weight.h:585
Actuator * actuator
The actuator for this control.
Definition: Control.h:34
Signal signal
The signal for this control.
Definition: Control.h:35
Definition: PMPLExceptions.h:62