Cheetah Software  1.0
DrawList Class Reference

#include <DrawList.h>

+ Collaboration diagram for DrawList:

Public Member Functions

 DrawList ()
 
size_t addCheetah3 (Vec4< float > color, bool useOld)
 
size_t addMiniCheetah (Vec4< float > color, bool useOld)
 
void buildDrawList ()
 
void loadFiles ()
 
size_t addCheckerboard (Checkerboard &checkerBoard)
 
size_t addDebugSphere (float radius)
 
void addBox (double depth, double width, double height, const Vec3< double > &pos, const Mat3< double > &ori, bool transparent)
 
void addMesh (double grid_size, const Vec3< double > &left_corner, const DMat< double > &height_map, bool transparent)
 
void resize (size_t nUniqueObject, size_t nTotalObjects)
 
size_t getNumObjectsToDraw ()
 
size_t getGLDrawArrayOffset (size_t i)
 
size_t getGLDrawArraySize (size_t i)
 
float * getVertexArray ()
 
float * getNormalArray ()
 
size_t getSizeOfAllData ()
 
float * getColorArray ()
 
QMatrix4x4 & getModelBaseTransform (size_t i)
 
QMatrix4x4 & getModelKinematicTransform (size_t i)
 
float getGLDataSizeMB ()
 
bool needsReload ()
 
template<typename T >
void updateRobotFromModel (DynamicsSimulator< T > &model, size_t id, bool updateOrigin=false)
 
template<typename T >
void updateAdditionalInfo (DynamicsSimulator< T > &model)
 
template<typename T >
void updateCheckerboardFromCollisionPlane (CollisionPlane< T > &model, size_t id)
 
template<typename T >
void updateCheckerboard (T height, size_t id)
 
template<typename T >
void updateDebugSphereLocation (Vec3< T > &position, size_t id)
 
const size_t & getTotalNumGC ()
 
const std::vector< double > & getGCPos (size_t idx)
 
const std::vector< double > & getGCForce (size_t idx)
 
const std::vector< BoxInfo > & getBoxInfoList ()
 
const DMat< double > & getHeightMap ()
 
const Vec3< double > & getHeightMapLeftCorner ()
 
const double & getHeightMapMax ()
 
const double & getHeightMapMin ()
 
const double & getGridSize ()
 
const Vec3< double > & getCameraOrigin ()
 

Static Public Member Functions

static void setSolidColor (std::vector< float > &data, size_t size, float r, float g, float b)
 

Public Attributes

VisualizationData_visualizationData
 
vectorAligned< SolidColor_instanceColor
 
std::vector< QMatrix4x4 > _kinematicXform
 

Private Attributes

size_t _nUnique = 0
 
size_t _nTotal = 0
 
std::vector< std::vector< float > > _vertexData
 
std::vector< std::vector< float > > _normalData
 
std::vector< std::vector< float > > _colorData
 
vectorAligned< Mat4< float > > _offsetXforms
 
std::string _baseFileName = "../resources/"
 
std::vector< size_t > _objectMap
 
std::vector< size_t > _glArrayOffsets
 
std::vector< size_t > _glArraySizes
 
std::vector< float > _glVertexData
 
std::vector< float > _glNormalData
 
std::vector< float > _glColorData
 
std::vector< QMatrix4x4 > _modelOffsets
 
bool _reloadNeeded = false
 
bool _additionalInfoFirstVisit = true
 
size_t _nTotalGC = 0
 
std::vector< bool > _cp_touch
 
std::vector< std::vector< double > > _cp_pos
 
std::vector< std::vector< double > > _cp_force
 
std::vector< BoxInfo_box_list
 
double _grid_size
 
Vec3< double > _height_map_left_corner
 
DMat< double > _height_map
 
double _height_map_max
 
double _height_map_min
 
Vec3< double > _cameraOrigin
 
size_t _cheetah3LoadIndex = 0
 
size_t _miniCheetahLoadIndex = 0
 
size_t _sphereLoadIndex = 0
 
size_t _cubeLoadIndex = 0
 

Detailed Description

Definition at line 49 of file DrawList.h.

Constructor & Destructor Documentation

DrawList::DrawList ( )
inline

Definition at line 53 of file DrawList.h.

References BoxInfo::depth, BoxInfo::height, and BoxInfo::width.

53  {
55  loadFiles();
56  }
typename Eigen::Matrix< T, 3, 1 > Vec3
Definition: cppTypes.h:26
void loadFiles()
Definition: DrawList.cpp:10
Vec3< double > _cameraOrigin
Definition: DrawList.h:315

Member Function Documentation

void DrawList::addBox ( double  depth,
double  width,
double  height,
const Vec3< double > &  pos,
const Mat3< double > &  ori,
bool  transparent 
)

Definition at line 288 of file DrawList.cpp.

References _box_list, _cubeLoadIndex, _instanceColor, _kinematicXform, _modelOffsets, _nTotal, _objectMap, BoxInfo::depth, disgustingGreen, BoxInfo::frame, BoxInfo::height, SolidColor::rgba, ori::rotationMatrixToQuaternion(), SolidColor::useSolidColor, and BoxInfo::width.

290  {
291  if (transparent) {
292  BoxInfo tmp;
293  tmp.depth = depth;
294  tmp.width = width;
295  tmp.height = height;
296 
297  tmp.frame[3] = 0.;
298  tmp.frame[7] = 0.;
299  tmp.frame[11] = 0.;
300  tmp.frame[15] = 1.;
301 
302  for (size_t i(0); i < 3; ++i) {
303  for (size_t j(0); j < 3; ++j) {
304  tmp.frame[4 * i + j] = ori(j, i);
305  }
306  }
307  for (size_t i(0); i < 3; ++i) tmp.frame[12 + i] = pos[i];
308 
309  _box_list.push_back(tmp);
310  } else {
311  QMatrix4x4 offset;
312 
313  // scale box
314  offset.setToIdentity();
315  offset.scale(depth, width, height);
316  _modelOffsets.push_back(offset);
317 
318  // move box
319  offset.setToIdentity();
320  offset.translate(pos[0], pos[1], pos[2]);
322  QQuaternion qq(q[0], q[1], q[2], q[3]);
323  offset.rotate(qq);
324 
325  _kinematicXform.push_back(offset);
326 
327  SolidColor boxColor;
328  boxColor.rgba = Vec4<float>(disgustingGreen[0], disgustingGreen[1],
329  disgustingGreen[2], 1.f);
330  boxColor.useSolidColor = true;
331  _instanceColor.push_back(boxColor);
332 
333  _nTotal++;
334  _objectMap.push_back(_cubeLoadIndex);
335  }
336 }
static constexpr float disgustingGreen[]
Definition: Colors.h:12
double height
Definition: DrawList.h:33
double depth
Definition: DrawList.h:33
typename Eigen::Matrix< T, 4, 1 > Quat
Definition: cppTypes.h:58
vectorAligned< SolidColor > _instanceColor
Definition: DrawList.h:278
std::vector< BoxInfo > _box_list
Definition: DrawList.h:308
std::vector< QMatrix4x4 > _kinematicXform
Definition: DrawList.h:279
size_t _cubeLoadIndex
Definition: DrawList.h:318
Quat< typename T::Scalar > rotationMatrixToQuaternion(const Eigen::MatrixBase< T > &r1)
typename Eigen::Matrix< T, 4, 1 > Vec4
Definition: cppTypes.h:30
float frame[16]
Definition: DrawList.h:34
std::vector< size_t > _objectMap
Definition: DrawList.h:290
double width
Definition: DrawList.h:33
EIGEN_MAKE_ALIGNED_OPERATOR_NEW Vec4< float > rgba
Definition: DrawList.h:45
size_t _nTotal
Definition: DrawList.h:282
bool useSolidColor
Definition: DrawList.h:46
std::vector< QMatrix4x4 > _modelOffsets
Definition: DrawList.h:299

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

size_t DrawList::addCheckerboard ( Checkerboard checkerBoard)

Adds a checkerboard to the list of drawables. Uses an identity transformation. You must call updateCheckerboardFromCollisionPlane to set the actual transform.

Definition at line 215 of file DrawList.cpp.

References _colorData, _instanceColor, _kinematicXform, _modelOffsets, _normalData, _nTotal, _nUnique, _objectMap, _vertexData, Checkerboard::computeVertices(), Checkerboard::getSize(), and SolidColor::useSolidColor.

215  {
216  size_t j0 = _nTotal;
217  size_t i0 = _nUnique;
218 
219  SolidColor checkerColor;
220  checkerColor.useSolidColor = false;
221 
222  _nUnique++;
223  // add the object
224  _vertexData.emplace_back();
225  _normalData.emplace_back();
226  _colorData.emplace_back();
227  checkerBoard.computeVertices(_vertexData.back(), _normalData.back(),
228  _colorData.back());
229  QMatrix4x4 eye, offset;
230  eye.setToIdentity();
231  offset.setToIdentity();
232  offset.translate(-checkerBoard.getSize()[0] / 2,
233  -checkerBoard.getSize()[1] / 2);
234  _modelOffsets.push_back(offset);
235  _kinematicXform.push_back(eye);
236  _instanceColor.push_back(checkerColor);
237 
238  _nTotal++;
239  // add the instance
240  _objectMap.push_back(i0);
241  return j0;
242 }
std::vector< std::vector< float > > _normalData
Definition: DrawList.h:284
std::vector< std::vector< float > > _colorData
Definition: DrawList.h:285
size_t _nUnique
Definition: DrawList.h:282
void computeVertices(std::vector< float > &vertices, std::vector< float > &normals, std::vector< float > &colors)
const float * getSize()
Definition: Checkerboard.h:34
vectorAligned< SolidColor > _instanceColor
Definition: DrawList.h:278
std::vector< QMatrix4x4 > _kinematicXform
Definition: DrawList.h:279
std::vector< size_t > _objectMap
Definition: DrawList.h:290
size_t _nTotal
Definition: DrawList.h:282
bool useSolidColor
Definition: DrawList.h:46
std::vector< QMatrix4x4 > _modelOffsets
Definition: DrawList.h:299
std::vector< std::vector< float > > _vertexData
Definition: DrawList.h:283

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

size_t DrawList::addCheetah3 ( Vec4< float >  color,
bool  useOld 
)

Load the cheetah 3 model and build the draw list. Returns an index number that can later be used to update the position of the robot.

Definition at line 48 of file DrawList.cpp.

References _cheetah3LoadIndex, _instanceColor, _kinematicXform, _modelOffsets, _nTotal, _objectMap, buildDrawList(), f(), SolidColor::rgba, and SolidColor::useSolidColor.

48  {
49  size_t i0 = _cheetah3LoadIndex;
50  size_t j0 = _nTotal;
51 
52  // set model offsets:
53  QMatrix4x4 bodyOffset, abadOffset, lowerOffset, eye;
54  eye.setToIdentity();
55  QMatrix4x4 upperOffsets[2];
56 
57  // body
58  bodyOffset.setToIdentity();
59  bodyOffset.rotate(90, 1, 0, 0);
60  bodyOffset.rotate(90, 0, 0, 1);
61 
62  // abad
63  abadOffset.setToIdentity();
64 
65  // upper link
66  upperOffsets[0].setToIdentity();
67  upperOffsets[0].rotate(-180, 0, 1, 0);
68  upperOffsets[0].translate(0, -.045f, 0);
69  upperOffsets[0].rotate(-180, 0, 0, 1);
70 
71  upperOffsets[1].setToIdentity();
72  upperOffsets[1].rotate(-180, 0, 1, 0);
73  upperOffsets[1].translate(0, .045f, 0);
74 
75  lowerOffset.setToIdentity();
76  lowerOffset.rotate(180, 0, 1, 0);
77  lowerOffset.translate(0, 0, 0);
78 
79  SolidColor bodyColor, abadColor, link1Color, link2Color;
80  bodyColor.rgba = useOld ? Vec4<float>(.2, .2, .2, .6) : color;
81  bodyColor.useSolidColor = true;
82 
83  abadColor.rgba = useOld ? Vec4<float>(.3, .2, .2, .6) : color;
84  abadColor.useSolidColor = true;
85 
86  link1Color.rgba = useOld ? Vec4<float>(.2, .3, .2, .6) : color;
87  link1Color.useSolidColor = true;
88 
89  link2Color.rgba = useOld ? Vec4<float>(.2, .2, .3, .6) : color;
90  link2Color.useSolidColor = true;
91 
92  // add bodies
93  _objectMap.push_back(i0 + 0);
94  _modelOffsets.push_back(bodyOffset);
95  _kinematicXform.push_back(eye);
96  _instanceColor.push_back(bodyColor);
97  _nTotal++;
98 
99  for (int i = 0; i < 4; i++) {
100  _objectMap.push_back(i0 + 1);
101  _modelOffsets.push_back(abadOffset);
102  _kinematicXform.push_back(eye);
103  _instanceColor.push_back(abadColor);
104 
105  _objectMap.push_back(i0 + 2);
106  _modelOffsets.push_back(upperOffsets[i % 2]);
107  _kinematicXform.push_back(eye);
108  _instanceColor.push_back(link1Color);
109 
110  _objectMap.push_back(i0 + 3);
111  _modelOffsets.push_back(lowerOffset);
112  _kinematicXform.push_back(eye);
113  _instanceColor.push_back(link2Color);
114  _nTotal += 3;
115  }
116 
117  printf("size of kinematicXform: %lu, j0: %lu\n", _kinematicXform.size(), j0);
118 
119  buildDrawList();
120  return j0;
121 }
vectorAligned< SolidColor > _instanceColor
Definition: DrawList.h:278
std::vector< QMatrix4x4 > _kinematicXform
Definition: DrawList.h:279
typename Eigen::Matrix< T, 4, 1 > Vec4
Definition: cppTypes.h:30
void buildDrawList()
Definition: DrawList.cpp:266
std::vector< size_t > _objectMap
Definition: DrawList.h:290
size_t _cheetah3LoadIndex
Definition: DrawList.h:317
EIGEN_MAKE_ALIGNED_OPERATOR_NEW Vec4< float > rgba
Definition: DrawList.h:45
size_t _nTotal
Definition: DrawList.h:282
bool useSolidColor
Definition: DrawList.h:46
std::vector< QMatrix4x4 > _modelOffsets
Definition: DrawList.h:299
MX f(const MX &x, const MX &u)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

size_t DrawList::addDebugSphere ( float  radius)

Adds a sphere to the list of drawables.

Definition at line 247 of file DrawList.cpp.

References _kinematicXform, _modelOffsets, _nTotal, _objectMap, and _sphereLoadIndex.

247  {
248  assert(false);
249  size_t j0 = _nTotal;
250 
251  QMatrix4x4 offset;
252  offset.setToIdentity();
253  _kinematicXform.push_back(offset);
254  offset.scale(radius);
255  _modelOffsets.push_back(offset);
256 
257  _nTotal++;
258  _objectMap.push_back(_sphereLoadIndex);
259  return j0;
260 }
std::vector< QMatrix4x4 > _kinematicXform
Definition: DrawList.h:279
std::vector< size_t > _objectMap
Definition: DrawList.h:290
size_t _nTotal
Definition: DrawList.h:282
size_t _sphereLoadIndex
Definition: DrawList.h:318
std::vector< QMatrix4x4 > _modelOffsets
Definition: DrawList.h:299
void DrawList::addMesh ( double  grid_size,
const Vec3< double > &  left_corner,
const DMat< double > &  height_map,
bool  transparent 
)

Definition at line 338 of file DrawList.cpp.

References _grid_size, _height_map, _height_map_left_corner, _height_map_max, and _height_map_min.

339  {
340  (void)transparent;
341 
342  _grid_size = grid_size;
343  _height_map_left_corner = left_corner;
344  _height_map = height_map;
345  _height_map_min = 1.e5;
346  _height_map_max = -1.e5;
347 
348  for (int i(0); i < height_map.rows(); ++i) {
349  for (int j(0); j < height_map.cols(); ++j) {
350  if (height_map(i, j) > _height_map_max) {
351  _height_map_max = height_map(i, j);
352  }
353  if (height_map(i, j) < _height_map_min) {
354  _height_map_min = height_map(i, j);
355  }
356  }
357  }
358 }
double _height_map_max
Definition: DrawList.h:313
Vec3< double > _height_map_left_corner
Definition: DrawList.h:311
DMat< double > _height_map
Definition: DrawList.h:312
double _height_map_min
Definition: DrawList.h:313
double _grid_size
Definition: DrawList.h:310

+ Here is the caller graph for this function:

size_t DrawList::addMiniCheetah ( Vec4< float >  color,
bool  useOld 
)

Load the mini cheetah model and builds the draw list. Returns an index number that can later be used to update the position of the robot. TODO check all this once the mini cheetah dynamics model exists again

Definition at line 129 of file DrawList.cpp.

References _instanceColor, _kinematicXform, _miniCheetahLoadIndex, _modelOffsets, _nTotal, _objectMap, f(), SolidColor::rgba, and SolidColor::useSolidColor.

129  {
130  size_t i0 = _miniCheetahLoadIndex; // todo don't hard code this
131  size_t j0 = _nTotal;
132 
133  // set model offsets:
134  QMatrix4x4 bodyOffset, upper, lower, eye;
135  QMatrix4x4 abadOffsets[4];
136  eye.setToIdentity();
137 
138  // body
139  bodyOffset.setToIdentity();
140 
141  // abads (todo, check these)
142  abadOffsets[0].setToIdentity(); // n
143  abadOffsets[0].rotate(-90, 0, 0, 1);
144  abadOffsets[0].translate(0, -.0565f, 0);
145  abadOffsets[0].rotate(180, 0, 1, 0);
146 
147  abadOffsets[1].setToIdentity(); // p
148  abadOffsets[1].rotate(-90, 0, 0, 1);
149  abadOffsets[1].translate(0, -.0565f, 0);
150  abadOffsets[1].rotate(0, 0, 1, 0);
151 
152  abadOffsets[2].setToIdentity(); // n
153  abadOffsets[2].rotate(90, 0, 0, 1);
154  abadOffsets[2].translate(0, -.0565f, 0);
155  abadOffsets[2].rotate(0, 0, 1, 0);
156 
157  abadOffsets[3].setToIdentity(); // p
158  abadOffsets[3].rotate(90, 0, 0, 1);
159  abadOffsets[3].translate(0, -.0565f, 0);
160  abadOffsets[3].rotate(180, 0, 1, 0);
161 
162  // upper
163  upper.setToIdentity();
164  upper.rotate(-90, 0, 1, 0);
165 
166  // lower
167  lower.setToIdentity();
168  lower.rotate(180, 0, 1, 0);
169 
170  SolidColor bodyColor, abadColor, link1Color, link2Color;
171  bodyColor.rgba = useOld ? Vec4<float>(.2, .2, .2, .6) : color;
172  bodyColor.useSolidColor = true;
173 
174  abadColor.rgba = useOld ? Vec4<float>(.3, .2, .2, .6) : color;
175  abadColor.useSolidColor = true;
176 
177  link1Color.rgba = useOld ? Vec4<float>(.2, .3, .2, .6) : color;
178  link1Color.useSolidColor = true;
179 
180  link2Color.rgba = useOld ? Vec4<float>(.2, .2, .3, .6) : color;
181  link2Color.useSolidColor = true;
182 
183  // add objects
184  _objectMap.push_back(i0 + 0);
185  _modelOffsets.push_back(bodyOffset);
186  _kinematicXform.push_back(eye);
187  _instanceColor.push_back(bodyColor);
188  _nTotal++;
189 
190  for (int i = 0; i < 4; i++) {
191  _objectMap.push_back(i0 + 1);
192  _modelOffsets.push_back(abadOffsets[i]);
193  _kinematicXform.push_back(eye);
194  _instanceColor.push_back(abadColor);
195 
196  _objectMap.push_back(i0 + 2);
197  _modelOffsets.push_back(upper);
198  _kinematicXform.push_back(eye);
199  _instanceColor.push_back(link1Color);
200 
201  _objectMap.push_back(i0 + 3);
202  _modelOffsets.push_back(lower);
203  _kinematicXform.push_back(eye);
204  _instanceColor.push_back(link2Color);
205  _nTotal += 3;
206  }
207  return j0;
208 }
size_t _miniCheetahLoadIndex
Definition: DrawList.h:317
vectorAligned< SolidColor > _instanceColor
Definition: DrawList.h:278
std::vector< QMatrix4x4 > _kinematicXform
Definition: DrawList.h:279
typename Eigen::Matrix< T, 4, 1 > Vec4
Definition: cppTypes.h:30
std::vector< size_t > _objectMap
Definition: DrawList.h:290
EIGEN_MAKE_ALIGNED_OPERATOR_NEW Vec4< float > rgba
Definition: DrawList.h:45
size_t _nTotal
Definition: DrawList.h:282
bool useSolidColor
Definition: DrawList.h:46
std::vector< QMatrix4x4 > _modelOffsets
Definition: DrawList.h:299
MX f(const MX &x, const MX &u)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void DrawList::buildDrawList ( )

Rebuilds the drawing list and sets the flag indicating that model data must be reloaded.

Definition at line 266 of file DrawList.cpp.

References _colorData, _glArrayOffsets, _glArraySizes, _glColorData, _glNormalData, _glVertexData, _normalData, _nUnique, _reloadNeeded, and _vertexData.

266  {
267  _glVertexData.clear();
268  _glColorData.clear();
269  _glNormalData.clear();
270  _glArrayOffsets.clear();
271  _glArraySizes.clear();
272 
273  for (size_t i = 0; i < _nUnique; i++) {
274  _glArrayOffsets.push_back(_glVertexData.size());
275  _glArraySizes.push_back(_vertexData.at(i).size());
276  // add the data for the objects
277  _glVertexData.insert(_glVertexData.end(), _vertexData.at(i).begin(),
278  _vertexData.at(i).end());
279  _glColorData.insert(_glColorData.end(), _colorData.at(i).begin(),
280  _colorData.at(i).end());
281  _glNormalData.insert(_glNormalData.end(), _normalData.at(i).begin(),
282  _normalData.at(i).end());
283  }
284 
285  _reloadNeeded = true;
286 }
std::vector< size_t > _glArrayOffsets
Definition: DrawList.h:292
std::vector< std::vector< float > > _normalData
Definition: DrawList.h:284
std::vector< std::vector< float > > _colorData
Definition: DrawList.h:285
size_t _nUnique
Definition: DrawList.h:282
bool _reloadNeeded
Definition: DrawList.h:301
std::vector< size_t > _glArraySizes
Definition: DrawList.h:293
std::vector< float > _glColorData
Definition: DrawList.h:297
std::vector< float > _glNormalData
Definition: DrawList.h:296
std::vector< float > _glVertexData
Definition: DrawList.h:295
std::vector< std::vector< float > > _vertexData
Definition: DrawList.h:283

+ Here is the caller graph for this function:

const std::vector<BoxInfo>& DrawList::getBoxInfoList ( )
inline

Definition at line 267 of file DrawList.h.

267 { return _box_list; }
std::vector< BoxInfo > _box_list
Definition: DrawList.h:308

+ Here is the caller graph for this function:

const Vec3<double>& DrawList::getCameraOrigin ( )
inline

Definition at line 277 of file DrawList.h.

277 { return _cameraOrigin; }
Vec3< double > _cameraOrigin
Definition: DrawList.h:315

+ Here is the caller graph for this function:

float* DrawList::getColorArray ( )
inline

Get the array containing all color data.

Definition at line 121 of file DrawList.h.

121 { return _glColorData.data(); }
std::vector< float > _glColorData
Definition: DrawList.h:297

+ Here is the caller graph for this function:

const std::vector<double>& DrawList::getGCForce ( size_t  idx)
inline

Definition at line 266 of file DrawList.h.

266 { return _cp_force[idx]; }
std::vector< std::vector< double > > _cp_force
Definition: DrawList.h:307

+ Here is the caller graph for this function:

const std::vector<double>& DrawList::getGCPos ( size_t  idx)
inline

Definition at line 265 of file DrawList.h.

265 { return _cp_pos[idx]; }
std::vector< std::vector< double > > _cp_pos
Definition: DrawList.h:306

+ Here is the caller graph for this function:

float DrawList::getGLDataSizeMB ( )
inline

Get size of data used by the GPU in megabytes For debugging

Definition at line 142 of file DrawList.h.

142  {
143  size_t bytes =
144  _glColorData.size() + _glNormalData.size() + _glVertexData.size();
145  bytes = bytes * sizeof(float);
146  return (float)bytes / float(1 << 20);
147  }
std::vector< float > _glColorData
Definition: DrawList.h:297
std::vector< float > _glNormalData
Definition: DrawList.h:296
std::vector< float > _glVertexData
Definition: DrawList.h:295

+ Here is the caller graph for this function:

size_t DrawList::getGLDrawArrayOffset ( size_t  i)
inline

For the i-th object, get the offset into the model data. For use with the glDrawArrays function. Note that several objects may have the same geometry, so this will return the same value for these objects!

Definition at line 93 of file DrawList.h.

93  {
94  return _glArrayOffsets.at(_objectMap.at(i));
95  }
std::vector< size_t > _glArrayOffsets
Definition: DrawList.h:292
std::vector< size_t > _objectMap
Definition: DrawList.h:290

+ Here is the caller graph for this function:

size_t DrawList::getGLDrawArraySize ( size_t  i)
inline

For the i-th object, get the size of the model data array

Definition at line 100 of file DrawList.h.

100  {
101  return _glArraySizes.at(_objectMap.at(i));
102  }
std::vector< size_t > _glArraySizes
Definition: DrawList.h:293
std::vector< size_t > _objectMap
Definition: DrawList.h:290

+ Here is the caller graph for this function:

const double& DrawList::getGridSize ( )
inline

Definition at line 275 of file DrawList.h.

275 { return _grid_size; }
double _grid_size
Definition: DrawList.h:310

+ Here is the caller graph for this function:

const DMat<double>& DrawList::getHeightMap ( )
inline

Definition at line 269 of file DrawList.h.

269 { return _height_map; }
DMat< double > _height_map
Definition: DrawList.h:312

+ Here is the caller graph for this function:

const Vec3<double>& DrawList::getHeightMapLeftCorner ( )
inline

Definition at line 270 of file DrawList.h.

270  {
272  }
Vec3< double > _height_map_left_corner
Definition: DrawList.h:311

+ Here is the caller graph for this function:

const double& DrawList::getHeightMapMax ( )
inline

Definition at line 273 of file DrawList.h.

273 { return _height_map_max; }
double _height_map_max
Definition: DrawList.h:313

+ Here is the caller graph for this function:

const double& DrawList::getHeightMapMin ( )
inline

Definition at line 274 of file DrawList.h.

274 { return _height_map_min; }
double _height_map_min
Definition: DrawList.h:313

+ Here is the caller graph for this function:

QMatrix4x4& DrawList::getModelBaseTransform ( size_t  i)
inline

Get the Qt transformation matrix which should be applied to the model geometry This is to correct for errors when exporting parts and shifts them all to the origin.

Definition at line 128 of file DrawList.h.

128 { return _modelOffsets[i]; }
std::vector< QMatrix4x4 > _modelOffsets
Definition: DrawList.h:299

+ Here is the caller graph for this function:

QMatrix4x4& DrawList::getModelKinematicTransform ( size_t  i)
inline

Get the Qt transformation matrix which should be applied to move a model from the origin to where it should be in the world

Definition at line 134 of file DrawList.h.

134  {
135  return _kinematicXform[i];
136  }
std::vector< QMatrix4x4 > _kinematicXform
Definition: DrawList.h:279

+ Here is the caller graph for this function:

float* DrawList::getNormalArray ( )
inline

Get the array containing all normal data. Use getGLDrawArrayOffset/Size to get indices and sizes for each object

Definition at line 114 of file DrawList.h.

114 { return _glNormalData.data(); }
std::vector< float > _glNormalData
Definition: DrawList.h:296

+ Here is the caller graph for this function:

size_t DrawList::getNumObjectsToDraw ( )
inline

Get the total number of objects to be drawn

Definition at line 85 of file DrawList.h.

85 { return _nTotal; }
size_t _nTotal
Definition: DrawList.h:282

+ Here is the caller graph for this function:

size_t DrawList::getSizeOfAllData ( )
inline

Definition at line 116 of file DrawList.h.

116 { return _glVertexData.size(); }
std::vector< float > _glVertexData
Definition: DrawList.h:295

+ Here is the caller graph for this function:

const size_t& DrawList::getTotalNumGC ( )
inline

Definition at line 264 of file DrawList.h.

264 { return _nTotalGC; }
size_t _nTotalGC
Definition: DrawList.h:304

+ Here is the caller graph for this function:

float* DrawList::getVertexArray ( )
inline

Get the array containing all vertex data. Use getGLDrawArrayOffset/Size to get indices and sizes for each object

Definition at line 108 of file DrawList.h.

108 { return _glVertexData.data(); }
std::vector< float > _glVertexData
Definition: DrawList.h:295

+ Here is the caller graph for this function:

void DrawList::loadFiles ( )

Definition at line 10 of file DrawList.cpp.

References _baseFileName, _cheetah3LoadIndex, _colorData, _cubeLoadIndex, _miniCheetahLoadIndex, _normalData, _nUnique, _sphereLoadIndex, _vertexData, debugRedColor, defaultRobotColor, disgustingGreen, load_obj_file(), and setSolidColor().

10  {
11  printf("[DrawList] Load object files...\n");
12  std::vector<std::string> names = {
13  "c3_body.obj", "mini_abad.obj",
14  "c3_upper_link.obj", "c3_lower_link.obj",
15  "mini_body.obj", "mini_abad.obj",
16  "mini_upper_link.obj", "mini_lower_link.obj",
17  "sphere.obj", "cube.obj"};
18  for (const auto& name : names) {
19  std::string filename = _baseFileName + name;
20  _vertexData.emplace_back();
21  _normalData.emplace_back();
22  _colorData.emplace_back();
23  load_obj_file(filename, _vertexData.back(), _normalData.back());
24  if (name == "sphere.obj") {
25  setSolidColor(_colorData.back(), _vertexData.back().size(),
26  debugRedColor[0], debugRedColor[1], debugRedColor[2]);
27  } else if (name == "cube.obj") {
28  setSolidColor(_colorData.back(), _vertexData.back().size(),
29  disgustingGreen[0], disgustingGreen[1], disgustingGreen[2]);
30  } else {
31  setSolidColor(_colorData.back(), _vertexData.back().size(),
33  defaultRobotColor[2]);
34  }
35 
36  _nUnique++;
37  }
38  _sphereLoadIndex = 8;
39  _cubeLoadIndex = 9;
42 }
static constexpr float disgustingGreen[]
Definition: Colors.h:12
std::vector< std::vector< float > > _normalData
Definition: DrawList.h:284
std::vector< std::vector< float > > _colorData
Definition: DrawList.h:285
size_t _nUnique
Definition: DrawList.h:282
static void setSolidColor(std::vector< float > &data, size_t size, float r, float g, float b)
Definition: DrawList.h:247
size_t _miniCheetahLoadIndex
Definition: DrawList.h:317
static constexpr float defaultRobotColor[]
Definition: Colors.h:15
void load_obj_file(std::string fileName, std::vector< float > &positions, std::vector< float > &normals)
Definition: obj_loader.cpp:19
static constexpr float debugRedColor[]
Definition: Colors.h:16
size_t _cubeLoadIndex
Definition: DrawList.h:318
std::string _baseFileName
Definition: DrawList.h:288
size_t _cheetah3LoadIndex
Definition: DrawList.h:317
size_t _sphereLoadIndex
Definition: DrawList.h:318
std::vector< std::vector< float > > _vertexData
Definition: DrawList.h:283

+ Here is the call graph for this function:

bool DrawList::needsReload ( )
inline

Returns true a single time if we have changed geometries and need to reload.

Definition at line 153 of file DrawList.h.

153  {
154  if (_reloadNeeded) {
155  _reloadNeeded = false;
156  return true;
157  }
158  return false;
159  }
bool _reloadNeeded
Definition: DrawList.h:301

+ Here is the caller graph for this function:

void DrawList::resize ( size_t  nUniqueObject,
size_t  nTotalObjects 
)
inline

Resize to hold size objects.

Definition at line 72 of file DrawList.h.

72  {
73  _nUnique = nUniqueObject;
74  _nTotal = nTotalObjects;
75  _vertexData.resize(nUniqueObject);
76  _normalData.resize(nUniqueObject);
77  _colorData.resize(nUniqueObject);
78  _offsetXforms.resize(nUniqueObject);
79  _objectMap.resize(nTotalObjects);
80  }
std::vector< std::vector< float > > _normalData
Definition: DrawList.h:284
std::vector< std::vector< float > > _colorData
Definition: DrawList.h:285
size_t _nUnique
Definition: DrawList.h:282
vectorAligned< Mat4< float > > _offsetXforms
Definition: DrawList.h:287
std::vector< size_t > _objectMap
Definition: DrawList.h:290
size_t _nTotal
Definition: DrawList.h:282
std::vector< std::vector< float > > _vertexData
Definition: DrawList.h:283
static void DrawList::setSolidColor ( std::vector< float > &  data,
size_t  size,
float  r,
float  g,
float  b 
)
inlinestatic

Fill color data with a solid color

Definition at line 247 of file DrawList.h.

248  {
249  data.clear();
250  data.resize(size);
251 
252  if ((size % 3) != 0) {
253  throw std::runtime_error("setSolidColor invalid size");
254  }
255 
256  for (size_t i = 0; i < size / 3; i++) {
257  data[i * 3 + 0] = r;
258  data[i * 3 + 1] = g;
259  data[i * 3 + 2] = b;
260  }
261  }

+ Here is the caller graph for this function:

template<typename T >
void DrawList::updateAdditionalInfo ( DynamicsSimulator< T > &  model)
inline

Update the additional information drawn by GUI Doesn't run the simulator

  • just pulls contact (or other in the future) data from the DynamicsSimulator
    Parameters
    model: the simulator

Definition at line 191 of file DrawList.h.

References DynamicsSimulator< T >::getContactForce(), DynamicsSimulator< T >::getModel(), and DynamicsSimulator< T >::getTotalNumGC().

191  {
193  _nTotalGC = model.getTotalNumGC();
194  _cp_touch.resize(_nTotalGC, false);
195  _cp_pos.resize(_nTotalGC);
196  _cp_force.resize(_nTotalGC);
197  std::vector<double> tmp(3);
198  for (size_t i(0); i < _nTotalGC; ++i) {
199  _cp_pos[i] = tmp;
200  _cp_force[i] = tmp;
201  }
203  }
204 
205  for (size_t i(0); i < _nTotalGC; ++i) {
206  // TODO: check touch boolean
207  _cp_touch[i] = true;
208  for (size_t j(0); j < 3; ++j) {
209  _cp_pos[i][j] = model.getModel()._pGC[i][j];
210  _cp_force[i][j] = model.getContactForce(i)[j];
211  }
212  }
213  }
std::vector< bool > _cp_touch
Definition: DrawList.h:305
size_t _nTotalGC
Definition: DrawList.h:304
const Vec3< T > & getContactForce(size_t idx)
std::vector< std::vector< double > > _cp_force
Definition: DrawList.h:307
const size_t & getTotalNumGC()
bool _additionalInfoFirstVisit
Definition: DrawList.h:302
std::vector< std::vector< double > > _cp_pos
Definition: DrawList.h:306
const FloatingBaseModel< T > & getModel()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<typename T >
void DrawList::updateCheckerboard ( height,
size_t  id 
)
inline

Definition at line 229 of file DrawList.h.

229  {
230  QMatrix4x4 H;
231  H.setToIdentity();
232  H.translate(0., 0., height);
233  _kinematicXform.at(id) = H;
234  }
std::vector< QMatrix4x4 > _kinematicXform
Definition: DrawList.h:279

+ Here is the caller graph for this function:

template<typename T >
void DrawList::updateCheckerboardFromCollisionPlane ( CollisionPlane< T > &  model,
size_t  id 
)
inline

Updates the position of a checkerboard to match an infinite collision plane The infinite collision plane only specifies orientation, so we

Parameters
model: the collision plane
id: the id retured from creating the checkerboard

Definition at line 222 of file DrawList.h.

References spatialTransformToQT().

223  {
224  // Mat4<T> H = sxformToHomogeneous(model.getLocation());
225  _kinematicXform.at(id) = spatialTransformToQT(model.getLocation());
226  }
std::vector< QMatrix4x4 > _kinematicXform
Definition: DrawList.h:279
QMatrix4x4 spatialTransformToQT(const Eigen::MatrixBase< T > &X)
Definition: sim_utilities.h:23

+ Here is the call graph for this function:

template<typename T >
void DrawList::updateDebugSphereLocation ( Vec3< T > &  position,
size_t  id 
)
inline

Definition at line 237 of file DrawList.h.

237  {
238  QMatrix4x4 H;
239  H.setToIdentity();
240  H.translate(position[0], position[1], position[2]);
241  _kinematicXform.at(id) = H;
242  }
std::vector< QMatrix4x4 > _kinematicXform
Definition: DrawList.h:279
template<typename T >
void DrawList::updateRobotFromModel ( DynamicsSimulator< T > &  model,
size_t  id,
bool  updateOrigin = false 
)
inline

Update the position of a robot's bodies using the result of a dynamics simulation. Doesn't run the simulator - just pulls _Xa from the DynamicsSimulator

Parameters
model: the simulator
id: the id returned from the loadCheetah3 or loadMiniCheetah function.

Definition at line 170 of file DrawList.h.

References DynamicsSimulator< T >::getModel(), DynamicsSimulator< T >::getNumBodies(), DynamicsSimulator< T >::getState(), and spatialTransformToQT().

171  {
172  for (size_t modelID = 5, graphicsID = id; modelID < model.getNumBodies();
173  modelID++, graphicsID++) {
174  _kinematicXform.at(graphicsID) =
175  spatialTransformToQT(model.getModel()._Xa.at(modelID));
176  }
177 
178  if (updateOrigin) {
179  _cameraOrigin = model.getState().bodyPosition.template cast<T>();
180  }
181  }
std::vector< QMatrix4x4 > _kinematicXform
Definition: DrawList.h:279
Vec3< double > _cameraOrigin
Definition: DrawList.h:315
const FBModelState< T > & getState() const
const FloatingBaseModel< T > & getModel()
QMatrix4x4 spatialTransformToQT(const Eigen::MatrixBase< T > &X)
Definition: sim_utilities.h:23

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

bool DrawList::_additionalInfoFirstVisit = true
private

Definition at line 302 of file DrawList.h.

std::string DrawList::_baseFileName = "../resources/"
private

Definition at line 288 of file DrawList.h.

std::vector<BoxInfo> DrawList::_box_list
private

Definition at line 308 of file DrawList.h.

Vec3<double> DrawList::_cameraOrigin
private

Definition at line 315 of file DrawList.h.

size_t DrawList::_cheetah3LoadIndex = 0
private

Definition at line 317 of file DrawList.h.

std::vector<std::vector<float> > DrawList::_colorData
private

Definition at line 285 of file DrawList.h.

std::vector<std::vector<double> > DrawList::_cp_force
private

Definition at line 307 of file DrawList.h.

std::vector<std::vector<double> > DrawList::_cp_pos
private

Definition at line 306 of file DrawList.h.

std::vector<bool> DrawList::_cp_touch
private

Definition at line 305 of file DrawList.h.

size_t DrawList::_cubeLoadIndex = 0
private

Definition at line 318 of file DrawList.h.

std::vector<size_t> DrawList::_glArrayOffsets
private

Definition at line 292 of file DrawList.h.

std::vector<size_t> DrawList::_glArraySizes
private

Definition at line 293 of file DrawList.h.

std::vector<float> DrawList::_glColorData
private

Definition at line 297 of file DrawList.h.

std::vector<float> DrawList::_glNormalData
private

Definition at line 296 of file DrawList.h.

std::vector<float> DrawList::_glVertexData
private

Definition at line 295 of file DrawList.h.

double DrawList::_grid_size
private

Definition at line 310 of file DrawList.h.

DMat<double> DrawList::_height_map
private

Definition at line 312 of file DrawList.h.

Vec3<double> DrawList::_height_map_left_corner
private

Definition at line 311 of file DrawList.h.

double DrawList::_height_map_max
private

Definition at line 313 of file DrawList.h.

double DrawList::_height_map_min
private

Definition at line 313 of file DrawList.h.

vectorAligned<SolidColor> DrawList::_instanceColor

Definition at line 278 of file DrawList.h.

std::vector<QMatrix4x4> DrawList::_kinematicXform

Definition at line 279 of file DrawList.h.

size_t DrawList::_miniCheetahLoadIndex = 0
private

Definition at line 317 of file DrawList.h.

std::vector<QMatrix4x4> DrawList::_modelOffsets
private

Definition at line 299 of file DrawList.h.

std::vector<std::vector<float> > DrawList::_normalData
private

Definition at line 284 of file DrawList.h.

size_t DrawList::_nTotal = 0
private

Definition at line 282 of file DrawList.h.

size_t DrawList::_nTotalGC = 0
private

Definition at line 304 of file DrawList.h.

size_t DrawList::_nUnique = 0
private

Definition at line 282 of file DrawList.h.

std::vector<size_t> DrawList::_objectMap
private

Definition at line 290 of file DrawList.h.

vectorAligned<Mat4<float> > DrawList::_offsetXforms
private

Definition at line 287 of file DrawList.h.

bool DrawList::_reloadNeeded = false
private

Definition at line 301 of file DrawList.h.

size_t DrawList::_sphereLoadIndex = 0
private

Definition at line 318 of file DrawList.h.

std::vector<std::vector<float> > DrawList::_vertexData
private

Definition at line 283 of file DrawList.h.

VisualizationData* DrawList::_visualizationData

Definition at line 51 of file DrawList.h.


The documentation for this class was generated from the following files: