50 #include "LinearMath/btVector3.h"
58 BigDoxieNoFeet::BigDoxieNoFeet(
int segments,
int hips,
int legs,
int feet) :
66 BigDoxieNoFeet::~BigDoxieNoFeet()
70 void BigDoxieNoFeet::addNodesFoot(
tgStructure& s,
double r1,
double r2){
88 void BigDoxieNoFeet::addNodesLeg(
tgStructure& s,
double r){
105 void BigDoxieNoFeet::addNodesHip(
tgStructure& s,
double r){
118 void BigDoxieNoFeet::addNodesVertebra(
tgStructure& s,
double r){
126 void BigDoxieNoFeet::addRodsVertebra(
tgStructure& s){
135 const double offsetDist = r+1;
136 const double offsetDist2 = offsetDist*8;
137 const double offsetDist3 = offsetDist2+4;
138 const double yOffset_leg = -(2*r+1);
139 const double yOffset_foot = -(2*r+6);
142 btVector3 offset(offsetDist,0.0,0);
144 btVector3 offset1(offsetDist*2,0.0,offsetDist);
145 btVector3 offset2(offsetDist2,0.0,offsetDist);
146 btVector3 offset3(offsetDist*2,0.0,-offsetDist);
147 btVector3 offset4(offsetDist2,0.0,-offsetDist);
149 btVector3 offset5(offsetDist3,yOffset_leg,offsetDist);
150 btVector3 offset6(offsetDist3,yOffset_leg,-offsetDist);
151 btVector3 offset7(r*2,yOffset_leg,offsetDist);
152 btVector3 offset8(r*2,yOffset_leg,-offsetDist);
154 btVector3 offset9(offsetDist3+1,yOffset_foot,offsetDist);
155 btVector3 offset10(offsetDist3+1,yOffset_foot,-offsetDist);
156 btVector3 offset11(r*2+1,yOffset_foot,offsetDist);
157 btVector3 offset12(r*2+1,yOffset_foot,-offsetDist);
159 for(std::size_t i = 0; i < m_segments; i++) {
161 t->addTags(
tgString(
"spine segment num", i + 1));
162 t->move((i + 1)*offset);
166 t->
addRotation(btVector3((i + 1) * offsetDist, 0.0, 0.0), btVector3(1, 0, 0), 0.0);
171 t->
addRotation(btVector3((i + 1) * offsetDist, 0.0, 0.0), btVector3(1, 0, 0), M_PI/2.0);
178 for(std::size_t i = m_segments; i < (m_segments + 2); i++) {
180 t->addTags(
tgString(
"segment num", i + 1));
184 t->
addRotation(btVector3(offsetDist2, 0.0, offsetDist), btVector3(0, 1, 0), M_PI);
189 t->
addRotation(btVector3(offsetDist*2, 0.0, offsetDist), btVector3(0, 1, 0), M_PI);
195 for(std::size_t i = (m_segments + 2); i < (m_segments + m_hips); i++) {
197 t->addTags(
tgString(
"segment num", i + 1));
210 for(std::size_t i = (m_segments + m_hips); i < (m_segments + m_hips + 2); i++) {
212 t->addTags(
tgString(
"segment num", i + 1));
216 t->
addRotation(btVector3(offsetDist3, yOffset_leg, offsetDist), btVector3(0, 1, 0), M_PI);
221 t->
addRotation(btVector3(r*2, yOffset_leg, offsetDist), btVector3(0, 1, 0), M_PI);
230 for(std::size_t i = (m_segments + m_hips + 2); i < (m_segments + m_hips + m_legs); i++) {
232 t->addTags(
tgString(
"segment num", i + 1));
236 t->
addRotation(btVector3(offsetDist3, yOffset_leg, -offsetDist), btVector3(0, 1, 0), M_PI);
241 t->
addRotation(btVector3(r*2, yOffset_leg, -offsetDist), btVector3(0, 1, 0), M_PI);
282 void BigDoxieNoFeet::addMuscles(
tgStructure& puppy){
284 std::vector<tgStructure*> children = puppy.
getChildren();
285 for(std::size_t i = 2; i < (children.size() - (m_hips + m_legs)); i++) {
287 tgNodes n0 = children[i-2]->getNodes();
288 tgNodes n1 = children[i-1]->getNodes();
289 tgNodes n2 = children[i]->getNodes();
329 if(i > 0 && i < m_segments){
344 if (i >= 2 && i < m_segments){
350 if(i == m_segments - 1){
362 tgNodes n0 = children[0]->getNodes();
363 tgNodes n1 = children[1]->getNodes();
364 tgNodes n2 = children[2]->getNodes();
365 tgNodes n3 = children[3]->getNodes();
366 tgNodes n4 = children[4]->getNodes();
367 tgNodes n5 = children[5]->getNodes();
368 tgNodes n6 = children[6]->getNodes();
369 tgNodes n7 = children[7]->getNodes();
370 tgNodes n8 = children[8]->getNodes();
371 tgNodes n9 = children[9]->getNodes();
372 tgNodes n10 = children[10]->getNodes();
373 tgNodes n11 = children[11]->getNodes();
374 tgNodes n12 = children[12]->getNodes();
375 tgNodes n13 = children[13]->getNodes();
376 tgNodes n14 = children[14]->getNodes();
377 tgNodes n15 = children[15]->getNodes();
378 tgNodes n16 = children[16]->getNodes();
445 puppy.
addPair(n13[4], n1[4],
tgString(
"right front abdomen connection muscle3 seg", 13) +
tgString(
" seg", 1));
446 puppy.
addPair(n13[3], n1[1],
tgString(
"all left foreleg limb front abdomen connection muscle3 seg", 13) +
tgString(
" seg", 1));
447 puppy.
addPair(n13[2], n1[4],
tgString(
"all left foreleg limb front abdomen connection muscle3 seg", 13) +
tgString(
" seg", 1));
462 puppy.
addPair(n15[3], n1[2],
tgString(
"all right foreleg limb front abdomen connection muscle3 seg", 15) +
tgString(
" seg", 1));
463 puppy.
addPair(n15[2], n1[3],
tgString(
"all right foreleg limb front abdomen connection muscle3 seg", 15) +
tgString(
" seg", 1));
544 const double density = 4.2/300.0;
545 const double radius = 0.5;
546 const double rod_space = 10.0;
547 const double rod_space2 = 8.0;
548 const double friction = 0.5;
549 const double rollFriction = 0.0;
550 const double restitution = 0.0;
552 const tgRod::Config rodConfig(radius, density, friction, rollFriction, restitution);
554 const double stiffness = 1000.0;
555 const double stiffnessPassive = 5000.0;
556 const double stiffnessPassive4 = 3000.0;
557 const double damping = .01*stiffness;
558 const double pretension = 0.0;
559 const bool history =
true;
560 const double maxTens = 7000.0;
561 const double maxSpeed = 12.0;
563 const double passivePretension = 1000;
564 const double passivePretension2 = 2500;
565 const double passivePretension3 = 13000;
566 const double passivePretension4 = 4000;
570 const double mRad = 1.0;
571 const double motorFriction = 10.0;
572 const double motorInertia = 1.0;
573 const bool backDrivable =
false;
574 #ifdef PASSIVE_STRUCTURE
576 mRad, motorFriction, motorInertia, backDrivable,
577 history, maxTens, maxSpeed);
580 mRad, motorFriction, motorInertia, backDrivable,
581 history, maxTens, maxSpeed);
584 mRad, motorFriction, motorInertia, backDrivable,
585 history, maxTens, maxSpeed);
588 mRad, motorFriction, motorInertia, backDrivable,
589 history, maxTens, maxSpeed);
591 mRad, motorFriction, motorInertia, backDrivable,
592 history, maxTens, maxSpeed);
595 mRad, motorFriction, motorInertia, backDrivable,
596 history, maxTens, maxSpeed);
599 mRad, motorFriction, motorInertia, backDrivable,
600 history, maxTens, maxSpeed);
603 mRad, motorFriction, motorInertia, backDrivable,
604 history, maxTens, maxSpeed);
607 mRad, motorFriction, motorInertia, backDrivable,
608 history, maxTens, maxSpeed);
610 mRad, motorFriction, motorInertia, backDrivable,
611 history, maxTens, maxSpeed);
616 #ifdef PASSIVE_STRUCTURE
634 addNodesFoot(foot,rod_space,rod_space2);
639 addNodesLeg(leg,rod_space);
644 addNodesVertebra(vertebra,rod_space);
645 addRodsVertebra(vertebra);
649 addNodesHip(hip,rod_space);
655 const double yOffset_foot = -(2*rod_space+6);
657 addSegments(puppy,vertebra,hip,leg,foot,rod_space);
659 puppy.move(btVector3(0.0,-yOffset_foot,0.0));
664 std::vector<tgStructure*> children = puppy.
getChildren();
668 spec.addBuilder(
"rod",
new tgRodInfo(rodConfig));
672 #ifdef PASSIVE_STRUCTURE
688 #ifdef PASSIVE_STRUCTURE
714 m_allMuscles = tgCast::filter<tgModel, tgSpringCableActuator> (
getDescendants());
716 m_allSegments = this->find<tgModel> (
"spine segment");
729 throw std::invalid_argument(
"dt is not positive");
const std::vector< tgStructure * > & getChildren() const
void addChild(tgStructure *child)
Definition of class tgRodInfo.
virtual void step(double dt)
Implementing the Flemons quadruped model (roughly), but as a subclass of Brian's BaseSpineModelLearni...
Convenience function for combining strings with ints, mostly for naming structures.
virtual void setup(tgWorld &world)
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.
virtual void setup(tgWorld &world)
Definition of class tgKinematicActuatorInfo.
Contains the definition of class tgRod.
Definition of class tgBuildSpec.
virtual void step(double dt)
std::vector< tgModel * > getDescendants() const
void buildInto(tgModel &model, tgWorld &world)
void addNode(double x, double y, double z, std::string tags="")