NTRT Simulator  v1.1
 All Classes Namespaces 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 
27 #ifndef TG_RIGID_AUTO_COMPOUND_H
28 #define TG_RIGID_AUTO_COMPOUND_H
29 
30 #include <vector>
31 #include <deque>
32 
33 class tgRigidInfo;
34 class btCollisionObject;
35 class btRigidBody;
36 
44 public:
45 
46 public:
47  // @todo: we want to start using this and get rid of the set-based constructor, but until we can refactor...
48  tgRigidAutoCompound(std::vector<tgRigidInfo*> rigids);
49 
50  tgRigidAutoCompound(std::deque<tgRigidInfo*> rigids);
51 
53  {
54  }
55 
56  std::vector< tgRigidInfo* > execute();
57 
58 protected:
59 
60  // @todo: we probably don't need this any more -- this will be taken care of in the tgRigidInfo => tgModel step
61  // @todo: NOTE: we need to have a way to check to see if a rigid has already been instantiated -- maybe just check get
62  void setRigidBodyForGroup(btCollisionObject* body, std::deque<tgRigidInfo*>& group);
63 
64  void setRigidInfoForGroup(tgRigidInfo* rigidInfo, std::deque<tgRigidInfo*>& group);
65 
66  void groupRigids();
67 
68  // Find all rigids that should be in a group with the given rigid
69  // @todo: This may contain an off-by-one error (the last rigid may not be grouped properly...)
70  std::deque<tgRigidInfo*> findGroup(tgRigidInfo* rigid, std::deque<tgRigidInfo*>& ungrouped);
71 
72  void createCompounds();
73 
74  tgRigidInfo* createCompound(std::deque<tgRigidInfo*> rigids);
75 
76  bool rigidBelongsIn(tgRigidInfo* rigid, std::deque<tgRigidInfo*> group);
77 
78  // Doesn't look like we own these
79  std::deque<tgRigidInfo*> m_rigids;
80  std::vector< std::deque<tgRigidInfo*> > m_groups;
81  std::vector< tgRigidInfo* > m_compounded; // temporary set of compounded rigids. Same keys as m_groups
82 
83 };
84 
85 
86 
87 #endif