hpp-rbprm  4.12.0
Implementation of RB-PRM planner using hpp.
rbprm-state.hh
Go to the documentation of this file.
1 //
2 // Copyright (c) 2014 CNRS
3 // Authors: Steve Tonneau (steve.tonneau@laas.fr)
4 //
5 // This file is part of hpp-rbprm.
6 // hpp-rbprm is free software: you can redistribute it
7 // and/or modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation, either version
9 // 3 of the License, or (at your option) any later version.
10 //
11 // hpp-rbprm is distributed in the hope that it will be
12 // useful, but WITHOUT ANY WARRANTY; without even the implied warranty
13 // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // General Lesser Public License for more details. You should have
15 // received a copy of the GNU Lesser General Public License along with
16 // hpp-core If not, see
17 // <http://www.gnu.org/licenses/>.
18 
19 #ifndef HPP_RBPRM_STATE_HH
20 #define HPP_RBPRM_STATE_HH
21 
22 #include <hpp/rbprm/config.hh>
23 #include <hpp/pinocchio/device.hh>
24 #include <hpp/rbprm/rbprm-limb.hh>
25 
26 #include <queue>
27 #include <algorithm>
28 
29 namespace hpp {
30 namespace rbprm {
31 struct State;
32 typedef std::vector<State> T_State;
33 typedef T_State::const_iterator CIT_State;
34 typedef std::pair<pinocchio::value_type, rbprm::State> StateFrame;
35 typedef std::vector<StateFrame> T_StateFrame;
36 typedef T_StateFrame::const_iterator CIT_StateFrame;
37 
41  State() : nbContacts(0), stable(false) {}
42  State(const State& other);
43  ~State() {}
44 
45  State& operator=(const State& other);
46 
51  bool RemoveContact(const std::string& contactId);
52 
58  std::string RemoveFirstContact();
59 
63  std::vector<std::string> contactVariations(const State& previous) const;
64 
69  std::vector<std::string> freeVariations(const State& previous, const std::vector<std::string>& allEffectors) const;
70 
75  std::vector<std::string> allVariations(const State& previous, const std::vector<std::string>& allEffectors) const;
76 
81  std::vector<std::string> fixedContacts(const State& previous) const;
82 
86  void contactCreations(const State& previous, std::vector<std::string>& outList) const;
87 
91  std::vector<std::string> contactCreations(const State& previous) const;
92 
96  std::vector<std::string> contactBreaks(const State& previous) const;
97 
101  void contactBreaks(const State& previous, std::vector<std::string>& outList) const;
102 
103  void print() const;
104  void print(std::stringstream& ss) const;
105  void print(std::stringstream& ss, const State& previous) const;
106  void printInternal(std::stringstream& ss) const;
107 
108  hpp::pinocchio::Configuration_t configuration_;
109  std::map<std::string, bool> contacts_;
110  std::map<std::string, fcl::Vec3f> contactNormals_;
111  std::map<std::string, fcl::Vec3f> contactPositions_;
112  std::map<std::string, fcl::Matrix3f> contactRotation_;
113  std::queue<std::string> contactOrder_;
114  std::size_t nbContacts;
115  bool stable;
116  double robustness;
117 }; // struct State
120 HPP_RBPRM_DLLAPI pinocchio::value_type effectorDistance(const State& from, const State& to);
121 
126 template <typename Iter>
127 HPP_RBPRM_DLLAPI std::vector<std::string> freeEffectors(const State& state, Iter start, Iter end) {
128  std::vector<std::string> res;
129  for (Iter it = start; it != end; ++it) {
130  const std::string& eff = *it;
131  std::map<std::string, bool>::const_iterator cit = state.contacts_.find(eff);
132  if (cit == state.contacts_.end() || !cit->second) {
133  res.push_back(eff);
134  }
135  }
136  return res;
137 }
138 } // namespace rbprm
139 } // namespace hpp
140 
141 #endif // HPP_RBPRM_STATE_HH
#define HPP_RBPRM_DLLAPI
Definition: config.hh:64
T_StateFrame::const_iterator CIT_StateFrame
Definition: rbprm-state.hh:36
Definition: algorithm.hh:27
std::vector< StateFrame > T_StateFrame
Definition: rbprm-state.hh:35
double robustness
Definition: rbprm-state.hh:116
~State()
Definition: rbprm-state.hh:43
std::queue< std::string > contactOrder_
Definition: rbprm-state.hh:113
HPP_RBPRM_DLLAPI pinocchio::value_type effectorDistance(const State &from, const State &to)
T_State::const_iterator CIT_State
Definition: rbprm-state.hh:33
State()
Definition: rbprm-state.hh:41
std::map< std::string, bool > contacts_
Definition: rbprm-state.hh:109
HPP_RBPRM_DLLAPI std::vector< std::string > freeEffectors(const State &state, Iter start, Iter end)
Definition: rbprm-state.hh:127
std::vector< State > T_State
Definition: rbprm-state.hh:31
std::map< std::string, fcl::Vec3f > contactPositions_
Definition: rbprm-state.hh:111
bool stable
Definition: rbprm-state.hh:115
std::pair< pinocchio::value_type, rbprm::State > StateFrame
Definition: rbprm-state.hh:34
std::size_t nbContacts
Definition: rbprm-state.hh:114
Definition: rbprm-state.hh:40
std::map< std::string, fcl::Vec3f > contactNormals_
Definition: rbprm-state.hh:110
hpp::pinocchio::Configuration_t configuration_
Definition: rbprm-state.hh:108
std::map< std::string, fcl::Matrix3f > contactRotation_
Definition: rbprm-state.hh:112