Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef TOWR_VARIABLES_NODE_VALUES_H_
00031 #define TOWR_VARIABLES_NODE_VALUES_H_
00032
00033 #include <ifopt/variable_set.h>
00034
00035 #include "state.h"
00036 #include "nodes_observer.h"
00037
00038 namespace towr {
00039
00071 class NodesVariables : public ifopt::VariableSet {
00072 public:
00073 using Ptr = std::shared_ptr<NodesVariables>;
00074 using VecDurations = std::vector<double>;
00075 using ObserverPtr = NodesObserver*;
00076
00085 struct NodeValueInfo {
00086 int id_;
00087 Dx deriv_;
00088 int dim_;
00089
00090 NodeValueInfo() = default;
00091 NodeValueInfo(int node_id, Dx deriv, int node_dim);
00092 int operator==(const NodeValueInfo& right) const;
00093 };
00094
00105 virtual std::vector<NodeValueInfo> GetNodeValuesInfo(int opt_idx) const = 0;
00106
00114 int GetOptIndex(const NodeValueInfo& nvi) const;
00115 static const int NodeValueNotOptimized = -1;
00116
00125 VectorXd GetValues () const override;
00126
00137 void SetVariables (const VectorXd&x) override;
00138
00142 VecBound GetBounds () const override;
00143
00147 const std::vector<Node> GetNodes() const;
00148
00152 int GetPolynomialCount() const;
00153
00157 const std::vector<Node> GetBoundaryNodes(int poly_id) const;
00158
00159 enum Side {Start=0, End};
00165 static int GetNodeId(int poly_id, Side side);
00166
00171 void AddObserver(ObserverPtr const spline);
00172
00176 int GetDim() const;
00177
00184 void SetByLinearInterpolation(const VectorXd& initial_val,
00185 const VectorXd& final_val,
00186 double t_total);
00187
00194 void AddStartBound (Dx deriv, const std::vector<int>& dimensions,
00195 const VectorXd& val);
00196
00203 void AddFinalBound(Dx deriv, const std::vector<int>& dimensions,
00204 const VectorXd& val);
00205
00206 protected:
00211 NodesVariables (const std::string& variable_name);
00212 virtual ~NodesVariables () = default;
00213
00214 VecBound bounds_;
00215 std::vector<Node> nodes_;
00216 int n_dim_;
00217
00218 private:
00222 void UpdateObservers() const;
00223 std::vector<ObserverPtr> observers_;
00224
00232 void AddBounds(int node_id, Dx deriv, const std::vector<int>& dim,
00233 const VectorXd& values);
00239 void AddBound(const NodeValueInfo& node_info, double value);
00240 };
00241
00242 }
00243
00244 #endif