NTRT Simulator
 All Classes Files Functions Variables Typedefs Friends Pages
tgRigidAutoCompound.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2012, United States Government, as represented by the
3  * Administrator of the National Aeronautics and Space Administration.
4  * All rights reserved.
5  *
6  * The NASA Tensegrity Robotics Toolkit (NTRT) v1 platform is licensed
7  * under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * http://www.apache.org/licenses/LICENSE-2.0.
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
15  * either express or implied. See the License for the specific language
16  * governing permissions and limitations under the License.
17 */
18 
26 #ifndef TG_RIGID_AUTO_COMPOUND_H
27 #define TG_RIGID_AUTO_COMPOUND_H
28 
29 #include <vector>
30 #include <deque>
31 
32 class tgRigidInfo;
33 class btRigidBody;
34 
42 public:
43 
44 public:
45  // @todo: we want to start using this and get rid of the set-based constructor, but until we can refactor...
46  tgRigidAutoCompound(std::vector<tgRigidInfo*> rigids);
47 
48  tgRigidAutoCompound(std::deque<tgRigidInfo*> rigids);
49 
51  {
52  }
53 
54  std::vector< tgRigidInfo* > execute();
55 
56 protected:
57 
58  // @todo: we probably don't need this any more -- this will be taken care of in the tgRigidInfo => tgModel step
59  // @todo: NOTE: we need to have a way to check to see if a rigid has already been instantiated -- maybe just check get
60  void setRigidBodyForGroup(btRigidBody* body, std::deque<tgRigidInfo*>& group);
61 
62  void setRigidInfoForGroup(tgRigidInfo* rigidInfo, std::deque<tgRigidInfo*>& group);
63 
64  void groupRigids();
65 
66  // Find all rigids that should be in a group with the given rigid
67  // @todo: This may contain an off-by-one error (the last rigid may not be grouped properly...)
68  std::deque<tgRigidInfo*> findGroup(tgRigidInfo* rigid, std::deque<tgRigidInfo*>& ungrouped);
69 
70  void createCompounds();
71 
72  tgRigidInfo* createCompound(std::deque<tgRigidInfo*> rigids);
73 
74  bool rigidBelongsIn(tgRigidInfo* rigid, std::deque<tgRigidInfo*> group);
75 
76  // Doesn't look like we own these
77  std::deque<tgRigidInfo*> m_rigids;
78  std::vector< std::deque<tgRigidInfo*> > m_groups;
79  std::vector< tgRigidInfo* > m_compounded; // temporary set of compounded rigids. Same keys as m_groups
80 
81 };
82 
83 
84 
85 #endif