50 #include "LinearMath/btVector3.h"
56 #define PASSIVE_STRUCTURE
58 BigPuppyRigidFeet::BigPuppyRigidFeet(
int segments,
int hips,
int legs,
int feet) :
66 BigPuppyRigidFeet::~BigPuppyRigidFeet()
70 void BigPuppyRigidFeet::addNodesFoot(
tgStructure& s,
double r1,
double r2){
81 void BigPuppyRigidFeet::addRodsFoot(
tgStructure& s){
88 void BigPuppyRigidFeet::addNodesLeg(
tgStructure& s,
double r){
102 void BigPuppyRigidFeet::addRodsLeg(
tgStructure& s){
120 void BigPuppyRigidFeet::addNodesHip(
tgStructure& s,
double r){
127 void BigPuppyRigidFeet::addRodsHip(
tgStructure& s){
133 void BigPuppyRigidFeet::addNodesVertebra(
tgStructure& s,
double r){
141 void BigPuppyRigidFeet::addRodsVertebra(
tgStructure& s){
150 const double offsetDist = r+1;
151 const double offsetDist2 = offsetDist*6;
152 const double offsetDist3 = offsetDist2+2;
153 const double yOffset_leg = -(2*r+1);
154 const double yOffset_foot = -(2*r+6);
157 btVector3 offset(offsetDist,0.0,0);
159 btVector3 offset1(offsetDist*2,0.0,offsetDist);
160 btVector3 offset2(offsetDist2,0.0,offsetDist);
161 btVector3 offset3(offsetDist*2,0.0,-offsetDist);
162 btVector3 offset4(offsetDist2,0.0,-offsetDist);
164 btVector3 offset5(offsetDist3,yOffset_leg,offsetDist);
165 btVector3 offset6(offsetDist3,yOffset_leg,-offsetDist);
166 btVector3 offset7(r*2,yOffset_leg,offsetDist);
167 btVector3 offset8(r*2,yOffset_leg,-offsetDist);
169 btVector3 offset9(offsetDist3+1,yOffset_foot,offsetDist);
170 btVector3 offset10(offsetDist3+1,yOffset_foot,-offsetDist);
171 btVector3 offset11(r*2+1,yOffset_foot,offsetDist);
172 btVector3 offset12(r*2+1,yOffset_foot,-offsetDist);
174 for(std::size_t i = 0; i < m_segments; i++) {
176 t->addTags(
tgString(
"spine segment num", i + 1));
177 t->move((i + 1)*offset);
181 t->
addRotation(btVector3((i + 1) * offsetDist, 0.0, 0.0), btVector3(1, 0, 0), 0.0);
186 t->
addRotation(btVector3((i + 1) * offsetDist, 0.0, 0.0), btVector3(1, 0, 0), M_PI/2.0);
193 for(std::size_t i = m_segments; i < (m_segments + 2); i++) {
195 t->addTags(
tgString(
"segment num", i + 1));
199 t->
addRotation(btVector3(offsetDist2, 0.0, offsetDist), btVector3(0, 1, 0), M_PI);
204 t->
addRotation(btVector3(offsetDist*2, 0.0, offsetDist), btVector3(0, 1, 0), M_PI);
210 for(std::size_t i = (m_segments + 2); i < (m_segments + m_hips); i++) {
212 t->addTags(
tgString(
"segment num", i + 1));
225 for(std::size_t i = (m_segments + m_hips); i < (m_segments + m_hips + 2); i++) {
227 t->addTags(
tgString(
"segment num", i + 1));
231 t->
addRotation(btVector3(offsetDist3, yOffset_leg, offsetDist), btVector3(0, 1, 0), M_PI);
236 t->
addRotation(btVector3(r*2, yOffset_leg, offsetDist), btVector3(0, 1, 0), M_PI);
245 for(std::size_t i = (m_segments + m_hips + 2); i < (m_segments + m_hips + m_legs); i++) {
247 t->addTags(
tgString(
"segment num", i + 1));
251 t->
addRotation(btVector3(offsetDist3, yOffset_leg, -offsetDist), btVector3(0, 1, 0), M_PI);
256 t->
addRotation(btVector3(r*2, yOffset_leg, -offsetDist), btVector3(0, 1, 0), M_PI);
297 void BigPuppyRigidFeet::addMuscles(
tgStructure& puppy){
299 std::vector<tgStructure*> children = puppy.
getChildren();
300 for(std::size_t i = 2; i < (children.size() - (m_hips + m_legs)); i++) {
302 tgNodes n0 = children[i-2]->getNodes();
303 tgNodes n1 = children[i-1]->getNodes();
304 tgNodes n2 = children[i]->getNodes();
371 tgNodes n0 = children[0]->getNodes();
372 tgNodes n1 = children[1]->getNodes();
373 tgNodes n2 = children[2]->getNodes();
374 tgNodes n3 = children[3]->getNodes();
375 tgNodes n4 = children[4]->getNodes();
376 tgNodes n5 = children[5]->getNodes();
377 tgNodes n6 = children[6]->getNodes();
378 tgNodes n7 = children[7]->getNodes();
379 tgNodes n8 = children[8]->getNodes();
380 tgNodes n9 = children[9]->getNodes();
381 tgNodes n10 = children[10]->getNodes();
382 tgNodes n11 = children[11]->getNodes();
383 tgNodes n12 = children[12]->getNodes();
384 tgNodes n13 = children[13]->getNodes();
385 tgNodes n14 = children[14]->getNodes();
545 const double density = 4.2/300.0;
546 const double radius = 0.5;
547 const double rod_space = 10.0;
548 const double rod_space2 = 8.0;
549 const double friction = 0.5;
550 const double rollFriction = 0.0;
551 const double restitution = 0.0;
553 const tgRod::Config rodConfig(radius, density, friction, rollFriction, restitution);
555 const double stiffness = 1000.0;
556 const double stiffnessPassive = 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 = 2500;
569 const double mRad = 1.0;
570 const double motorFriction = 10.0;
571 const double motorInertia = 1.0;
572 const bool backDrivable =
false;
573 #ifdef PASSIVE_STRUCTURE
575 mRad, motorFriction, motorInertia, backDrivable,
576 history, maxTens, maxSpeed);
579 mRad, motorFriction, motorInertia, backDrivable,
580 history, maxTens, maxSpeed);
583 mRad, motorFriction, motorInertia, backDrivable,
584 history, maxTens, maxSpeed);
586 mRad, motorFriction, motorInertia, backDrivable,
587 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);
602 mRad, motorFriction, motorInertia, backDrivable,
603 history, maxTens, maxSpeed);
608 #ifdef PASSIVE_STRUCTURE
630 addNodesLeg(leg,rod_space);
635 addNodesVertebra(vertebra,rod_space);
636 addRodsVertebra(vertebra);
640 addNodesHip(hip,rod_space);
646 const double yOffset_foot = -(2*rod_space+6);
648 addSegments(puppy,vertebra,hip,leg,rod_space);
650 puppy.move(btVector3(0.0,26,0.0));
655 std::vector<tgStructure*> children = puppy.
getChildren();
659 spec.addBuilder(
"rod",
new tgRodInfo(rodConfig));
663 #ifdef PASSIVE_STRUCTURE
677 #ifdef PASSIVE_STRUCTURE
701 m_allMuscles = tgCast::filter<tgModel, tgSpringCableActuator> (
getDescendants());
703 m_allSegments = this->find<tgModel> (
"spine segment");
716 throw std::invalid_argument(
"dt is not positive");
const std::vector< tgStructure * > & getChildren() const
Implementing the Flemons quadruped model (roughly), but as a subclass of Brian's BaseSpineModelLearni...
void addChild(tgStructure *child)
Definition of class tgRodInfo.
virtual void setup(tgWorld &world)
Convenience function for combining strings with ints, mostly for naming structures.
virtual void setup(tgWorld &world)
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.
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="")