50 #include "LinearMath/btVector3.h"
58 BigPuppySymmetricArching::BigPuppySymmetricArching(
int segments,
int hips,
int legs,
int feet) :
63 m_subStructures = segments + hips + legs + feet;
66 BigPuppySymmetricArching::~BigPuppySymmetricArching()
70 void BigPuppySymmetricArching::addNodesFoot(
tgStructure& s,
double r1,
double r2){
81 void BigPuppySymmetricArching::addRodsFoot(
tgStructure& s){
92 void BigPuppySymmetricArching::addNodesLeg(
tgStructure& s,
double r){
101 void BigPuppySymmetricArching::addRodsLeg(
tgStructure& s){
109 void BigPuppySymmetricArching::addNodesHip(
tgStructure& s,
double r){
116 void BigPuppySymmetricArching::addRodsHip(
tgStructure& s){
122 void BigPuppySymmetricArching::addNodesVertebra(
tgStructure& s,
double r){
130 void BigPuppySymmetricArching::addRodsVertebra(
tgStructure& s){
139 const double offsetDist = r+1;
140 const double offsetDist2 = offsetDist*6;
141 const double offsetDist3 = offsetDist2+2;
142 const double yOffset_leg = -(2*r+1);
143 const double yOffset_foot = -(2*r+6);
146 btVector3 offset(offsetDist,0.0,0);
148 btVector3 offset1(offsetDist*2,0.0,offsetDist);
149 btVector3 offset2(offsetDist2,0.0,offsetDist);
150 btVector3 offset3(offsetDist*2,0.0,-offsetDist);
151 btVector3 offset4(offsetDist2,0.0,-offsetDist);
153 btVector3 offset5(offsetDist3,yOffset_leg,offsetDist);
154 btVector3 offset6(offsetDist3,yOffset_leg,-offsetDist);
155 btVector3 offset7(r*2,yOffset_leg,offsetDist);
156 btVector3 offset8(r*2,yOffset_leg,-offsetDist);
158 btVector3 offset9(offsetDist3+1,yOffset_foot,offsetDist);
159 btVector3 offset10(offsetDist3+1,yOffset_foot,-offsetDist);
160 btVector3 offset11(r*2+1,yOffset_foot,offsetDist);
161 btVector3 offset12(r*2+1,yOffset_foot,-offsetDist);
163 for(std::size_t i = 0; i < m_segments; i++) {
165 t->addTags(
tgString(
"spine segment num", i + 1));
166 t->move((i + 1)*offset);
170 t->
addRotation(btVector3((i + 1) * offsetDist, 0.0, 0.0), btVector3(1, 0, 0), 0.0);
175 t->
addRotation(btVector3((i + 1) * offsetDist, 0.0, 0.0), btVector3(1, 0, 0), M_PI/2.0);
182 for(std::size_t i = m_segments; i < (m_segments + 2); i++) {
184 t->addTags(
tgString(
"segment num", i + 1));
188 t->
addRotation(btVector3(offsetDist2, 0.0, offsetDist), btVector3(0, 1, 0), M_PI);
193 t->
addRotation(btVector3(offsetDist*2, 0.0, offsetDist), btVector3(0, 1, 0), M_PI);
199 for(std::size_t i = (m_segments + 2); i < (m_segments + m_hips); i++) {
201 t->addTags(
tgString(
"segment num", i + 1));
214 for(std::size_t i = (m_segments + m_hips); i < (m_segments + m_hips + 2); i++) {
216 t->addTags(
tgString(
"segment num", i + 1));
220 t->
addRotation(btVector3(offsetDist3, yOffset_leg, offsetDist), btVector3(0, 1, 0), M_PI);
225 t->
addRotation(btVector3(r*2, yOffset_leg, offsetDist), btVector3(0, 1, 0), M_PI);
234 for(std::size_t i = (m_segments + m_hips + 2); i < (m_segments + m_hips + m_legs); i++) {
236 t->addTags(
tgString(
"segment num", i + 1));
240 t->
addRotation(btVector3(offsetDist3, yOffset_leg, -offsetDist), btVector3(0, 1, 0), M_PI);
245 t->
addRotation(btVector3(r*2, yOffset_leg, -offsetDist), btVector3(0, 1, 0), M_PI);
251 for(std::size_t i = (m_segments + m_hips + m_legs); i < (m_segments + m_hips + m_legs + 2); i++) {
253 t->addTags(
tgString(
"segment num", i + 1));
257 t->
addRotation(btVector3(offsetDist3+1, yOffset_foot, offsetDist), btVector3(0, 1, 0), 0.0);
262 t->
addRotation(btVector3(r*2+1, yOffset_foot, offsetDist), btVector3(0, 1, 0), 0.0);
268 for(std::size_t i = (m_segments + m_hips + m_legs + 2); i < (m_segments + m_hips + m_legs + m_feet); i++) {
270 t->addTags(
tgString(
"segment num", i + 1));
274 t->
addRotation(btVector3(offsetDist3+1, yOffset_foot, -offsetDist), btVector3(0, 1, 0), 0.0);
279 t->
addRotation(btVector3(r*2+1, yOffset_foot, -offsetDist), btVector3(0, 1, 0), 0.0);
286 void BigPuppySymmetricArching::addMuscles(
tgStructure& puppy){
288 std::vector<tgStructure*> children = puppy.
getChildren();
289 for(std::size_t i = 2; i < (children.size() - (m_hips + m_legs + m_feet)); i++) {
291 tgNodes n0 = children[i-2]->getNodes();
292 tgNodes n1 = children[i-1]->getNodes();
293 tgNodes n2 = children[i]->getNodes();
298 puppy.
addPair(n0[3], n1[3],
tgString(
"spine main front upper right muscleAct seg", i-2) +
tgString(
" seg", i-1));
299 puppy.
addPair(n0[3], n1[4],
tgString(
"spine main front upper left muscleAct seg", i-2) +
tgString(
" seg", i-1));
301 puppy.
addPair(n0[4], n1[3],
tgString(
"spine main front lower right muscleAct seg", i-2) +
tgString(
" seg", i-1));
302 puppy.
addPair(n0[4], n1[4],
tgString(
"spine main front lower left muscleAct seg", i-2) +
tgString(
" seg", i-1));
310 puppy.
addPair(n0[1], n1[3],
tgString(
"spine main front lower right muscleAct seg", i-2) +
tgString(
" seg", i-1));
311 puppy.
addPair(n0[1], n1[4],
tgString(
"spine main front lower left muscleAct seg", i-2) +
tgString(
" seg", i-1));
312 puppy.
addPair(n0[2], n1[3],
tgString(
"spine main front upper right muscleAct seg", i-2) +
tgString(
" seg", i-1));
313 puppy.
addPair(n0[2], n1[4],
tgString(
"spine main front upper left muscleAct seg", i-2) +
tgString(
" seg", i-1));
316 puppy.
addPair(n0[1], n1[3],
tgString(
"spine main rear upper left muscleAct seg", i-2) +
tgString(
" seg", i-1));
317 puppy.
addPair(n0[1], n1[4],
tgString(
"spine main rear lower left muscleAct seg", i-2) +
tgString(
" seg", i-1));
318 puppy.
addPair(n0[2], n1[3],
tgString(
"spine main rear upper right muscleAct seg", i-2) +
tgString(
" seg", i-1));
319 puppy.
addPair(n0[2], n1[4],
tgString(
"spine main rear lower right muscleAct seg", i-2) +
tgString(
" seg", i-1));
342 puppy.
addPair(n1[1], n2[3],
tgString(
"spine main front lower right muscleAct seg", i-1) +
tgString(
" seg", i));
344 puppy.
addPair(n1[2], n2[3],
tgString(
"spine main front upper right muscleAct seg", i-1) +
tgString(
" seg", i));
360 tgNodes n0 = children[0]->getNodes();
361 tgNodes n1 = children[1]->getNodes();
362 tgNodes n2 = children[2]->getNodes();
363 tgNodes n3 = children[3]->getNodes();
364 tgNodes n4 = children[4]->getNodes();
365 tgNodes n5 = children[5]->getNodes();
366 tgNodes n6 = children[6]->getNodes();
367 tgNodes n7 = children[7]->getNodes();
368 tgNodes n8 = children[8]->getNodes();
369 tgNodes n9 = children[9]->getNodes();
370 tgNodes n10 = children[10]->getNodes();
371 tgNodes n11 = children[11]->getNodes();
372 tgNodes n12 = children[12]->getNodes();
373 tgNodes n13 = children[13]->getNodes();
374 tgNodes n14 = children[14]->getNodes();
505 for(std::size_t i = (m_segments + m_hips + m_legs); i < children.size(); i++) {
506 tgNodes ni = children[i]->getNodes();
507 tgNodes ni4 = children[i-4]->getNodes();
540 const double density = 4.2/300.0;
541 const double radius = 0.5;
542 const double rod_space = 10.0;
543 const double rod_space2 = 8.0;
544 const double friction = 0.5;
545 const double rollFriction = 0.0;
546 const double restitution = 0.0;
548 const tgRod::Config rodConfig(radius, density, friction, rollFriction, restitution);
550 const double stiffness = 1000.0;
551 const double stiffnessPassive = 4000.0;
552 const double damping = .01*stiffness;
553 const double pretension = 0.0;
554 const bool history =
true;
555 const double maxTens = 7000.0;
556 const double maxSpeed = 12.0;
558 const double passivePretension = 1000;
559 const double passivePretension2 = 3500;
560 const double passivePretension3 = 3500;
564 const double mRad = 1.0;
565 const double motorFriction = 10.0;
566 const double motorInertia = 1.0;
567 const bool backDrivable =
false;
568 #ifdef PASSIVE_STRUCTURE
570 mRad, motorFriction, motorInertia, backDrivable,
571 history, maxTens, maxSpeed);
573 mRad, motorFriction, motorInertia, backDrivable,
574 history, maxTens, maxSpeed);
577 mRad, motorFriction, motorInertia, backDrivable,
578 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);
592 mRad, motorFriction, motorInertia, backDrivable,
593 history, maxTens, maxSpeed);
595 mRad, motorFriction, motorInertia, backDrivable,
596 history, maxTens, maxSpeed);
601 #ifdef PASSIVE_STRUCTURE
618 addNodesFoot(foot,rod_space,rod_space2);
623 addNodesLeg(leg,rod_space);
628 addNodesVertebra(vertebra,rod_space);
629 addRodsVertebra(vertebra);
633 addNodesHip(hip,rod_space);
639 const double yOffset_foot = -(2*rod_space+6);
641 addSegments(puppy,vertebra,hip,leg,foot,rod_space);
643 puppy.move(btVector3(0.0,-yOffset_foot,0.0));
648 std::vector<tgStructure*> children = puppy.
getChildren();
652 spec.addBuilder(
"rod",
new tgRodInfo(rodConfig));
656 #ifdef PASSIVE_STRUCTURE
670 #ifdef PASSIVE_STRUCTURE
694 m_allMuscles = tgCast::filter<tgModel, tgSpringCableActuator> (
getDescendants());
696 m_allSegments = this->find<tgModel> (
"segment");
709 throw std::invalid_argument(
"dt is not positive");
const std::vector< tgStructure * > & getChildren() const
void addChild(tgStructure *child)
Definition of class tgRodInfo.
Implementing the Flemons quadruped model (roughly), but as a subclass of Brian's BaseSpineModelLearni...
virtual void setup(tgWorld &world)
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...
virtual void setup(tgWorld &world)
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.
Definition of class tgKinematicActuatorInfo.
virtual void step(double dt)
Contains the definition of class tgRod.
Definition of class tgBuildSpec.
std::vector< tgModel * > getDescendants() const
void buildInto(tgModel &model, tgWorld &world)
void addNode(double x, double y, double z, std::string tags="")