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 density2 = 0;
74 const tgRod::Config rodConfig2(radius, density2, friction, rollFriction, restitution);
76 const double stiffness = 1000.0;
77 const double damping = .01*stiffness;
78 const double pretension = 0.0;
83 const double passivePretension = 700;
140 rightLeg2.
addNode(12,1.5,-3.5);
259 tetra.
addNode(v_size, 0, v_size);
260 tetra.
addNode(v_size, 0, -v_size);
261 tetra.
addNode(-v_size, 0, -v_size);
262 tetra.
addNode(-v_size, 0, v_size);
273 lHip.
addNode(0, v_size, v_size);
274 lHip.
addNode(0, -v_size, -v_size);
275 lHip.
addNode(0, -v_size, v_size);
284 rHip.
addNode(0, v_size, -v_size);
285 rHip.
addNode(0, -v_size, -v_size);
286 rHip.
addNode(0, -v_size, v_size);
294 const double offsetDist = v_size + 1;
295 const double offsetDist2 = v_size*5 + 5 + 3.3;
296 const double offsetDist3 = v_size*6;
297 std::size_t m_segments = 6;
298 std::size_t m_hips = 4;
299 std::size_t m_legs = 4;
301 btVector3 offset(offsetDist,0.0,0);
302 btVector3 offset1(offsetDist*2,0.0,offsetDist);
303 btVector3 offset2(offsetDist2,0.0,offsetDist);
304 btVector3 offset3(offsetDist*2,0.0,-offsetDist);
305 btVector3 offset4(offsetDist2,0.0,-offsetDist);
306 btVector3 offset5(offsetDist3,-21.0,offsetDist);
307 btVector3 offset6(offsetDist3,-21.0,-offsetDist);
308 btVector3 offset7(v_size*2,-21.0,offsetDist);
309 btVector3 offset8(v_size*2,-21.0,-offsetDist);
313 for(std::size_t i = 0; i < m_segments; i++) {
315 t->addTags(
tgString(
"segment num", i + 1));
316 t->move((i + 1)*offset);
320 t->
addRotation(btVector3((i + 1) * offsetDist, 0.0, 0.0), btVector3(1, 0, 0), 0.0);
325 t->
addRotation(btVector3((i + 1) * offsetDist, 0.0, 0.0), btVector3(1, 0, 0), M_PI/2.0);
332 for(std::size_t i = m_segments; i < (m_segments + 2); i++) {
334 t->addTags(
tgString(
"segment num", i + 1));
338 t->
addRotation(btVector3(offsetDist*2, 0.0, offsetDist), btVector3(1, 0, 0), 0.0);
342 t->
addRotation(btVector3(offsetDist2, 0.0, offsetDist), btVector3(0, 0, 1), M_PI*1/8);
348 for(std::size_t i = (m_segments + 2); i < (m_segments + m_hips); i++) {
350 t->addTags(
tgString(
"segment num", i + 1));
354 t->
addRotation(btVector3(offsetDist*2, 0.0, -offsetDist), btVector3(1, 0, 0), 0.0);
358 t->
addRotation(btVector3(offsetDist2, 0.0, -offsetDist), btVector3(0, 0, 1), M_PI*1/8);
365 for(std::size_t i = (m_segments + m_hips); i < (m_segments + m_hips + 2); i++) {
367 t->addTags(
tgString(
"segment num", i + 1));
371 t->addTags(
tgString(
"segment num", i + 1));
373 t->
addRotation(btVector3(v_size*2, -21.0, offsetDist), btVector3(0, 1, 0), M_PI);
378 t->addTags(
tgString(
"segment num", i + 1));
380 t->
addRotation(btVector3(offsetDist3, -21.0, offsetDist), btVector3(0, 1, 0), M_PI);
385 for(std::size_t i = (m_segments + m_hips + 2); i < (m_segments + m_hips + m_legs); i++) {
387 t->addTags(
tgString(
"segment num", i + 1));
391 t->addTags(
tgString(
"segment num", i + 1));
393 t->
addRotation(btVector3(v_size*2, -21.0, -offsetDist), btVector3(0, 1, 0), M_PI);
398 t->addTags(
tgString(
"segment num", i + 1));
400 t->
addRotation(btVector3(offsetDist3, -21.0, -offsetDist), btVector3(0, 1, 0), M_PI);
405 spine.move(btVector3(0.0,21.0,0.0));
408 std::vector<tgStructure*> children = spine.
getChildren();
409 for(std::size_t i = 2; i < (children.size() - (m_hips + m_legs)); i++) {
411 tgNodes n0 = children[i-2]->getNodes();
412 tgNodes n1 = children[i-1]->getNodes();
413 tgNodes n2 = children[i]->getNodes();
480 tgNodes n0 = children[0]->getNodes();
481 tgNodes n1 = children[1]->getNodes();
482 tgNodes n2 = children[2]->getNodes();
483 tgNodes n3 = children[3]->getNodes();
484 tgNodes n4 = children[4]->getNodes();
485 tgNodes n5 = children[5]->getNodes();
486 tgNodes n6 = children[6]->getNodes();
487 tgNodes n7 = children[7]->getNodes();
488 tgNodes n8 = children[8]->getNodes();
489 tgNodes n9 = children[9]->getNodes();
490 tgNodes n10 = children[10]->getNodes();
491 tgNodes n11 = children[11]->getNodes();
492 tgNodes n12 = children[12]->getNodes();
493 tgNodes n13 = children[13]->getNodes();
615 for(std::size_t i = (m_segments + m_hips); i < children.size(); i++) {
617 tgNodes ni = children[i]->getNodes();
619 if(i < (m_segments + m_legs + 2)){
621 spine.
addPair(ni[5], ni[7],
tgString(
"right leg big outer muscle seg", i));
622 spine.
addPair(ni[6], ni[8],
tgString(
"right leg little inner muscle seg", i));
623 spine.
addPair(ni[5], ni[6],
tgString(
"right leg big little muscle seg", i));
624 spine.
addPair(ni[0], ni[7],
tgString(
"right leg lower outer muscle seg", i));
625 spine.
addPair(ni[0], ni[8],
tgString(
"right leg lower inner muscle seg", i));
626 spine.
addPair(ni[2], ni[7],
tgString(
"right leg front outer muscle seg", i));
627 spine.
addPair(ni[2], ni[8],
tgString(
"right leg front inner muscle seg", i));
628 spine.
addPair(ni[3], ni[7],
tgString(
"right leg heel outer muscle seg", i));
629 spine.
addPair(ni[3], ni[8],
tgString(
"right leg heel inner muscle seg", i));
630 spine.
addPair(ni[4], ni[7],
tgString(
"right leg upper outer muscle seg", i));
631 spine.
addPair(ni[4], ni[8],
tgString(
"right leg upper inner muscle seg", i));
636 spine.
addPair(ni[5], ni[7],
tgString(
"left leg litte inner muscle seg", i));
637 spine.
addPair(ni[6], ni[8],
tgString(
"left leg big outer muscle seg", i));
638 spine.
addPair(ni[5], ni[6],
tgString(
"left leg big little muscle seg", i));
639 spine.
addPair(ni[0], ni[7],
tgString(
"left leg lower inner muscle seg", i));
640 spine.
addPair(ni[0], ni[8],
tgString(
"left leg lower outer muscle seg", i));
641 spine.
addPair(ni[2], ni[7],
tgString(
"left leg front inner muscle seg", i));
642 spine.
addPair(ni[2], ni[8],
tgString(
"left leg front outer muscle seg", i));
643 spine.
addPair(ni[3], ni[7],
tgString(
"left leg heel inner muscle seg", i));
644 spine.
addPair(ni[3], ni[8],
tgString(
"left leg heel outer muscle seg", i));
645 spine.
addPair(ni[4], ni[7],
tgString(
"left leg upper inner muscle seg", i));
646 spine.
addPair(ni[4], ni[8],
tgString(
"left leg upper outer muscle seg", i));
654 spec.addBuilder(
"rod",
new tgRodInfo(rodConfig));
655 spec.addBuilder(
"rod2",
new tgRodInfo(rodConfig2));
666 allActuators = tgCast::filter<tgModel, tgSpringCableActuator> (
getDescendants());
682 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 buildInto(tgModel &model, tgWorld &world)
void addNode(double x, double y, double z, std::string tags="")