48 #include "LinearMath/btVector3.h"
53 BigPuppy::BigPuppy() :
66 const double density = 4.2/300.0;
67 const double radius = 0.5;
68 const double friction = 0.5;
69 const double rollFriction = 0.0;
70 const double restitution = 0.0;
71 const tgRod::Config rodConfig(radius, density, friction, rollFriction, restitution);
73 const double radius2 = 0.15;
74 const double density2 = 1;
77 const double stiffness = 1000.0;
78 const double damping = .01*stiffness;
79 const double pretension = 0.0;
84 const double passivePretension = 700;
176 tetra.
addNode(v_size, 0, v_size);
177 tetra.
addNode(v_size, 0, -v_size);
178 tetra.
addNode(-v_size, 0, -v_size);
179 tetra.
addNode(-v_size, 0, v_size);
190 lHip.
addNode(0, v_size, v_size);
191 lHip.
addNode(0, -v_size, -v_size);
192 lHip.
addNode(0, -v_size, v_size);
201 rHip.
addNode(0, v_size, -v_size);
202 rHip.
addNode(0, -v_size, -v_size);
203 rHip.
addNode(0, -v_size, v_size);
211 const double offsetDist = v_size + 1;
212 const double offsetDist2 = v_size*5 + 5 + 3.3;
213 const double offsetDist3 = v_size*6;
214 std::size_t m_segments = 6;
215 std::size_t m_hips = 4;
216 std::size_t m_legs = 4;
217 btVector3 offset(offsetDist,0.0,0);
218 btVector3 offset1(offsetDist*2,0.0,offsetDist);
219 btVector3 offset2(offsetDist2,0.0,offsetDist);
220 btVector3 offset3(offsetDist*2,0.0,-offsetDist);
221 btVector3 offset4(offsetDist2,0.0,-offsetDist);
222 btVector3 offset5(offsetDist3,-21.0,offsetDist);
223 btVector3 offset6(offsetDist3,-21.0,-offsetDist);
224 btVector3 offset7(v_size*2,-21.0,offsetDist);
225 btVector3 offset8(v_size*2,-21.0,-offsetDist);
227 for(std::size_t i = 0; i < m_segments; i++) {
229 t->addTags(
tgString(
"segment num", i + 1));
230 t->move((i + 1)*offset);
234 t->
addRotation(btVector3((i + 1) * offsetDist, 0.0, 0.0), btVector3(1, 0, 0), 0.0);
239 t->
addRotation(btVector3((i + 1) * offsetDist, 0.0, 0.0), btVector3(1, 0, 0), M_PI/2.0);
246 for(std::size_t i = m_segments; i < (m_segments + 2); i++) {
248 t->addTags(
tgString(
"segment num", i + 1));
252 t->
addRotation(btVector3(offsetDist*2, 0.0, offsetDist), btVector3(1, 0, 0), 0.0);
256 t->
addRotation(btVector3(offsetDist2, 0.0, offsetDist), btVector3(0, 0, 1), M_PI*1/8);
262 for(std::size_t i = (m_segments + 2); i < (m_segments + m_hips); i++) {
264 t->addTags(
tgString(
"segment num", i + 1));
268 t->
addRotation(btVector3(offsetDist*2, 0.0, -offsetDist), btVector3(1, 0, 0), 0.0);
272 t->
addRotation(btVector3(offsetDist2, 0.0, -offsetDist), btVector3(0, 0, 1), M_PI*1/8);
279 for(std::size_t i = (m_segments + m_hips); i < (m_segments + m_hips + 2); i++) {
281 t->addTags(
tgString(
"segment num", i + 1));
285 t->
addRotation(btVector3(v_size*2, -21.0, offsetDist), btVector3(0, 1, 0), M_PI);
289 t->
addRotation(btVector3(offsetDist3, -21.0, offsetDist), btVector3(0, 1, 0), M_PI);
295 for(std::size_t i = (m_segments + m_hips + 2); i < (m_segments + m_hips + m_legs); i++) {
297 t->addTags(
tgString(
"segment num", i + 1));
301 t->
addRotation(btVector3(v_size*2, -21.0, -offsetDist), btVector3(0, 1, 0), M_PI);
305 t->
addRotation(btVector3(offsetDist3, -21.0, -offsetDist), btVector3(0, 1, 0), M_PI);
311 spine.move(btVector3(0.0,21.0,0.0));
314 std::vector<tgStructure*> children = spine.
getChildren();
315 for(std::size_t i = 2; i < (children.size() - (m_hips + m_legs)); i++) {
317 tgNodes n0 = children[i-2]->getNodes();
318 tgNodes n1 = children[i-1]->getNodes();
319 tgNodes n2 = children[i]->getNodes();
389 tgNodes n0 = children[0]->getNodes();
390 tgNodes n1 = children[1]->getNodes();
391 tgNodes n2 = children[2]->getNodes();
392 tgNodes n3 = children[3]->getNodes();
393 tgNodes n4 = children[4]->getNodes();
394 tgNodes n5 = children[5]->getNodes();
395 tgNodes n6 = children[6]->getNodes();
396 tgNodes n7 = children[7]->getNodes();
397 tgNodes n8 = children[8]->getNodes();
398 tgNodes n9 = children[9]->getNodes();
399 tgNodes n10 = children[10]->getNodes();
400 tgNodes n11 = children[11]->getNodes();
401 tgNodes n12 = children[12]->getNodes();
402 tgNodes n13 = children[13]->getNodes();
524 for(std::size_t i = (m_segments + m_hips); i < children.size(); i++) {
526 tgNodes ni = children[i]->getNodes();
528 if(i < (m_segments + m_legs + 2)){
530 spine.
addPair(ni[5], ni[7],
tgString(
"right leg big outer muscle seg", i));
531 spine.
addPair(ni[6], ni[8],
tgString(
"right leg little inner muscle seg", i));
532 spine.
addPair(ni[5], ni[6],
tgString(
"right leg big little muscle seg", i));
533 spine.
addPair(ni[0], ni[7],
tgString(
"right leg lower outer muscle seg", i));
534 spine.
addPair(ni[0], ni[8],
tgString(
"right leg lower inner muscle seg", i));
535 spine.
addPair(ni[2], ni[7],
tgString(
"right leg front outer muscle seg", i));
536 spine.
addPair(ni[2], ni[8],
tgString(
"right leg front inner muscle seg", i));
537 spine.
addPair(ni[3], ni[7],
tgString(
"right leg heel outer muscle seg", i));
538 spine.
addPair(ni[3], ni[8],
tgString(
"right leg heel inner muscle seg", i));
539 spine.
addPair(ni[4], ni[7],
tgString(
"right leg upper outer muscle seg", i));
540 spine.
addPair(ni[4], ni[8],
tgString(
"right leg upper inner muscle seg", i));
545 spine.
addPair(ni[5], ni[7],
tgString(
"left leg litte inner muscle seg", i));
546 spine.
addPair(ni[6], ni[8],
tgString(
"left leg big outer muscle seg", i));
547 spine.
addPair(ni[5], ni[6],
tgString(
"left leg big little muscle seg", i));
548 spine.
addPair(ni[0], ni[7],
tgString(
"left leg lower inner muscle seg", i));
549 spine.
addPair(ni[0], ni[8],
tgString(
"left leg lower outer muscle seg", i));
550 spine.
addPair(ni[2], ni[7],
tgString(
"left leg front inner muscle seg", i));
551 spine.
addPair(ni[2], ni[8],
tgString(
"left leg front outer muscle seg", i));
552 spine.
addPair(ni[3], ni[7],
tgString(
"left leg heel inner muscle seg", i));
553 spine.
addPair(ni[3], ni[8],
tgString(
"left leg heel outer muscle seg", i));
554 spine.
addPair(ni[4], ni[7],
tgString(
"left leg upper inner muscle seg", i));
555 spine.
addPair(ni[4], ni[8],
tgString(
"left leg upper outer muscle seg", i));
563 spec.addBuilder(
"rod",
new tgRodInfo(rodConfig));
570 structureInfo.buildInto(*
this, world);
574 allActuators = tgCast::filter<tgModel, tgSpringCableActuator> (
getDescendants());
590 throw std::invalid_argument(
"dt is not positive");
const std::vector< tgStructure * > & getChildren() const
virtual void setup(tgWorld &world)
void addChild(tgStructure *child)
Definition of class tgRodInfo.
virtual void step(double dt)
const std::vector< tgSpringCableActuator * > & getAllActuators() const
Convenience function for combining strings with ints, mostly for naming structures.
virtual void step(double dt)
Definition of class tgBasicActuatorInfo.
Contains the definition of class tgSimulation.
Contains the definition of class tgModel.
void addPair(int fromNodeIdx, int toNodeIdx, std::string tags="")
Contains the definition of class tgSimViewGraphics.
Contains the definition of abstract base class tgSpringCableActuator. Assumes that the string is line...
void addRotation(const btVector3 &fixedPoint, const btVector3 &axis, double angle)
Contains the definition of class tgBasicActuator.
std::string tgString(std::string s, int i)
Contains the definition of class tgWorld $Id$.
Definition of class tgStructure.
Definition of class tgStructureInfo.
Contains the definition of class tgSimView.
Contains the definition of class tgRod.
Definition of class tgBuildSpec.
void notifyStep(double dt)
virtual void setup(tgWorld &world)
std::vector< tgModel * > getDescendants() const
void addNode(double x, double y, double z, std::string tags="")