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_PHASE_NODES_H_
00031 #define TOWR_VARIABLES_PHASE_NODES_H_
00032
00033 #include "nodes_variables.h"
00034
00035 namespace towr {
00036
00059 class NodesVariablesPhaseBased : public NodesVariables {
00060 public:
00061 using Ptr = std::shared_ptr<NodesVariablesPhaseBased>;
00062 using NodeIds = std::vector<int>;
00063 using OptIndexMap = std::map<int, std::vector<NodeValueInfo> >;
00064
00068 struct PolyInfo {
00069 int phase_;
00070 int poly_in_phase_;
00071 int n_polys_in_phase_;
00072 bool is_constant_;
00073 PolyInfo(int phase, int poly_in_phase, int n_polys_in_phase, bool is_const);
00074 };
00075
00084 NodesVariablesPhaseBased (int phase_count,
00085 bool first_phase_constant,
00086 const std::string& var_name,
00087 int n_polys_in_changing_phase);
00088
00089 virtual ~NodesVariablesPhaseBased() = default;
00090
00094 Eigen::Vector3d GetValueAtStartOfPhase(int phase) const;
00095
00099 int GetNodeIDAtStartOfPhase(int phase) const;
00100
00106 int GetPhase(int node_id) const;
00107
00112 virtual bool IsConstantNode(int node_id) const;
00113
00120 NodeIds GetIndicesOfNonConstantNodes() const;
00121
00128 virtual VecDurations
00129 ConvertPhaseToPolyDurations(const VecDurations& phase_durations) const;
00130
00139 virtual double
00140 GetDerivativeOfPolyDurationWrtPhaseDuration(int polynomial_id) const;
00141
00150 virtual int
00151 GetNumberOfPrevPolynomialsInPhase(int polynomial_id) const;
00152
00157 virtual bool IsInConstantPhase(int polynomial_id) const;
00158
00159 protected:
00167 OptIndexMap index_to_node_value_info_;
00168 std::vector<NodeValueInfo> GetNodeValuesInfo(int idx) const override {
00169 return index_to_node_value_info_.at(idx);
00170 }
00171
00172 void SetNumberOfVariables(int n_variables);
00173
00174 private:
00176 std::vector<PolyInfo> polynomial_info_;
00177
00179 int GetPolyIDAtStartOfPhase(int phase) const;
00180
00182 std::vector<int> GetAdjacentPolyIds(int node_id) const;
00183 };
00184
00185
00191 class NodesVariablesEEMotion : public NodesVariablesPhaseBased {
00192 public:
00193 NodesVariablesEEMotion(int phase_count,
00194 bool is_in_contact_at_start,
00195 const std::string& name,
00196 int n_polys_in_changing_phase);
00197 virtual ~NodesVariablesEEMotion() = default;
00198 OptIndexMap GetPhaseBasedEEParameterization ();
00199 };
00200
00201
00207 class NodesVariablesEEForce : public NodesVariablesPhaseBased {
00208 public:
00209 NodesVariablesEEForce(int phase_count,
00210 bool is_in_contact_at_start,
00211 const std::string& name,
00212 int n_polys_in_changing_phase);
00213 virtual ~NodesVariablesEEForce() = default;
00214 OptIndexMap GetPhaseBasedEEParameterization ();
00215 };
00216
00217 }
00218
00219 #endif