nodes_variables_phase_based.h
Go to the documentation of this file.
00001 /******************************************************************************
00002 Copyright (c) 2018, Alexander W. Winkler. All rights reserved.
00003 
00004 Redistribution and use in source and binary forms, with or without
00005 modification, are permitted provided that the following conditions are met:
00006 
00007 * Redistributions of source code must retain the above copyright notice, this
00008   list of conditions and the following disclaimer.
00009 
00010 * Redistributions in binary form must reproduce the above copyright notice,
00011   this list of conditions and the following disclaimer in the documentation
00012   and/or other materials provided with the distribution.
00013 
00014 * Neither the name of the copyright holder nor the names of its
00015   contributors may be used to endorse or promote products derived from
00016   this software without specific prior written permission.
00017 
00018 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00019 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00020 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00021 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
00022 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00023 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00024 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00025 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00026 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00027 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
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 } /* namespace towr */
00218 
00219 #endif /* TOWR_VARIABLES_PHASE_NODES_H_ */


towr
Author(s): Alexander W. Winkler
autogenerated on Mon Apr 15 2019 02:42:32