NTRT Simulator  Version: Master
 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 // From the C++ standard library
31 #include <vector>
32 #include <deque>
33 #include <iostream> //for strings
34 
35 // Forward declarations for Bullet Physics
36 class tgRigidInfo;
37 class btCollisionObject;
38 class btRigidBody;
39 
47 public:
48 
49 public:
50  // @todo: we want to start using this and get rid of the set-based constructor, but until we can refactor...
51  tgRigidAutoCompound(std::vector<tgRigidInfo*> rigids);
52 
53  tgRigidAutoCompound(std::deque<tgRigidInfo*> rigids);
54 
56  {
57  }
58 
59  std::vector< tgRigidInfo* > execute();
60 
61 protected:
62 
63  // @todo: we probably don't need this any more -- this will be taken care of in the tgRigidInfo => tgModel step
64  // @todo: NOTE: we need to have a way to check to see if a rigid has already been instantiated -- maybe just check get
65  void setRigidBodyForGroup(btCollisionObject* body, std::deque<tgRigidInfo*>& group);
66 
67  void setRigidInfoForGroup(tgRigidInfo* rigidInfo, std::deque<tgRigidInfo*>& group);
68 
69  void groupRigids();
70 
71  // Find all rigids that should be in a group with the given rigid
72  // @todo: This may contain an off-by-one error (the last rigid may not be grouped properly...)
73  std::deque<tgRigidInfo*> findGroup(tgRigidInfo* rigid, std::deque<tgRigidInfo*>& ungrouped);
74 
82  void createCompounds();
83 
84  tgRigidInfo* createCompound(std::deque<tgRigidInfo*> rigids);
85 
86  bool rigidBelongsIn(tgRigidInfo* rigid, std::deque<tgRigidInfo*> group);
87 
93  std::string random_tag_hash();
94 
95  // Doesn't look like we own these
96  std::deque<tgRigidInfo*> m_rigids;
97  std::vector< std::deque<tgRigidInfo*> > m_groups;
98  std::vector< tgRigidInfo* > m_compounded; // temporary set of compounded rigids. Same keys as m_groups
99 
100 };
101 
102 
103 
104 #endif