50 #include "LinearMath/btVector3.h"
57 BigPuppy::BigPuppy() :
70 const double density = 4.2/300.0;
71 const double radius = 0.5;
72 const double rod_space = 10.0;
73 const double friction = 0.5;
74 const double rollFriction = 0.0;
75 const double restitution = 0.0;
76 const tgRod::Config rodConfig(radius, density, friction, rollFriction, restitution);
78 const double radius2 = 0.15;
79 const double density2 = 1;
82 const double stiffness = 1000.0;
83 const double damping = .01*stiffness;
84 const double pretension = 0.0;
85 const bool history =
false;
86 const double maxTens = 7000.0;
87 const double maxSpeed = 12.0;
89 const double passivePretension = 700;
93 const double mRad = 1.0;
94 const double motorFriction = 10.0;
95 const double motorInertia = 1.0;
96 const bool backDrivable =
false;
98 mRad, motorFriction, motorInertia, backDrivable,
99 history, maxTens, maxSpeed);
109 double v_size = 10.0;
122 foot.
addNode(0,rod_space/2,-4);
123 foot.
addNode(-4,rod_space/2,0);
185 tetra.
addNode(v_size, 0, v_size);
186 tetra.
addNode(v_size, 0, -v_size);
187 tetra.
addNode(-v_size, 0, -v_size);
188 tetra.
addNode(-v_size, 0, v_size);
199 lHip.
addNode(0, v_size, v_size);
200 lHip.
addNode(0, -v_size, -v_size);
201 lHip.
addNode(0, -v_size, v_size);
210 rHip.
addNode(0, v_size, -v_size);
211 rHip.
addNode(0, -v_size, -v_size);
212 rHip.
addNode(0, -v_size, v_size);
220 const double offsetDist = v_size + 1;
221 const double offsetDist2 = v_size*5 + 5 + 3.3;
222 const double offsetDist3 = v_size*6;
223 const double yOffset_leg = -21.0;
224 const double yOffset_foot = -26.0;
225 std::size_t m_segments = 6;
226 std::size_t m_hips = 4;
227 std::size_t m_legs = 4;
228 std::size_t m_feet = 4;
230 btVector3 offset(offsetDist,0.0,0);
232 btVector3 offset1(offsetDist*2,0.0,offsetDist);
233 btVector3 offset2(offsetDist2,0.0,offsetDist);
234 btVector3 offset3(offsetDist*2,0.0,-offsetDist);
235 btVector3 offset4(offsetDist2,0.0,-offsetDist);
237 btVector3 offset5(offsetDist3,yOffset_leg,offsetDist);
238 btVector3 offset6(offsetDist3,yOffset_leg,-offsetDist);
239 btVector3 offset7(v_size*2,yOffset_leg,offsetDist);
240 btVector3 offset8(v_size*2,yOffset_leg,-offsetDist);
242 btVector3 offset9(offsetDist3+1,yOffset_foot,offsetDist);
243 btVector3 offset10(offsetDist3+1,yOffset_foot,-offsetDist);
244 btVector3 offset11(v_size*2+1,yOffset_foot,offsetDist);
245 btVector3 offset12(v_size*2+1,yOffset_foot,-offsetDist);
248 for(std::size_t i = 0; i < m_segments; i++) {
250 t->addTags(
tgString(
"segment num", i + 1));
251 t->move((i + 1)*offset);
255 t->
addRotation(btVector3((i + 1) * offsetDist, 0.0, 0.0), btVector3(1, 0, 0), 0.0);
260 t->
addRotation(btVector3((i + 1) * offsetDist, 0.0, 0.0), btVector3(1, 0, 0), M_PI/2.0);
267 for(std::size_t i = m_segments; i < (m_segments + 2); i++) {
269 t->addTags(
tgString(
"segment num", i + 1));
273 t->
addRotation(btVector3(offsetDist*2, 0.0, offsetDist), btVector3(1, 0, 0), 0.0);
277 t->
addRotation(btVector3(offsetDist2, 0.0, offsetDist), btVector3(0, 0, 1), M_PI*1/8);
283 for(std::size_t i = (m_segments + 2); i < (m_segments + m_hips); i++) {
285 t->addTags(
tgString(
"segment num", i + 1));
289 t->
addRotation(btVector3(offsetDist*2, 0.0, -offsetDist), btVector3(1, 0, 0), 0.0);
293 t->
addRotation(btVector3(offsetDist2, 0.0, -offsetDist), btVector3(0, 0, 1), M_PI*1/8);
300 for(std::size_t i = (m_segments + m_hips); i < (m_segments + m_hips + 2); i++) {
302 t->addTags(
tgString(
"segment num", i + 1));
306 t->
addRotation(btVector3(v_size*2, yOffset_leg, offsetDist), btVector3(0, 1, 0), M_PI);
310 t->
addRotation(btVector3(offsetDist3, yOffset_leg, offsetDist), btVector3(0, 1, 0), M_PI);
316 for(std::size_t i = (m_segments + m_hips + 2); i < (m_segments + m_hips + m_legs); i++) {
318 t->addTags(
tgString(
"segment num", i + 1));
322 t->
addRotation(btVector3(v_size*2, yOffset_leg, -offsetDist), btVector3(0, 1, 0), M_PI);
326 t->
addRotation(btVector3(offsetDist3, yOffset_leg, -offsetDist), btVector3(0, 1, 0), M_PI);
332 for(std::size_t i = (m_segments + m_hips + m_legs); i < (m_segments + m_hips + m_legs + 2); i++) {
334 t->addTags(
tgString(
"segment num", i + 1));
338 t->
addRotation(btVector3(v_size*2+1, yOffset_foot, offsetDist), btVector3(0, 1, 0), 0.0);
342 t->
addRotation(btVector3(offsetDist3+1, yOffset_foot, offsetDist), btVector3(0, 1, 0), 0.0);
348 for(std::size_t i = (m_segments + m_hips + m_legs + 2); i < (m_segments + m_hips + m_legs + m_feet); i++) {
350 t->addTags(
tgString(
"segment num", i + 1));
354 t->
addRotation(btVector3(v_size*2+1, yOffset_foot, -offsetDist), btVector3(0, 1, 0), 0.0);
358 t->
addRotation(btVector3(offsetDist3+1, yOffset_foot, -offsetDist), btVector3(0, 1, 0), 0.0);
365 spine.move(btVector3(0.0,-yOffset_foot+5,0.0));
369 spine.move(btVector3(0.0,-yOffset_foot+12,0.0));
373 spine.move(btVector3(0.0,-yOffset_foot,0.0));
377 spine.move(btVector3(0.0,10.0,0.0));
381 spine.move(btVector3(0.0,0.0,0.0));
384 std::vector<tgStructure*> children = spine.
getChildren();
385 for(std::size_t i = 2; i < (children.size() - (m_hips + m_legs + m_feet)); i++) {
387 tgNodes n0 = children[i-2]->getNodes();
388 tgNodes n1 = children[i-1]->getNodes();
389 tgNodes n2 = children[i]->getNodes();
458 tgNodes n0 = children[0]->getNodes();
459 tgNodes n1 = children[1]->getNodes();
460 tgNodes n2 = children[2]->getNodes();
461 tgNodes n3 = children[3]->getNodes();
462 tgNodes n4 = children[4]->getNodes();
463 tgNodes n5 = children[5]->getNodes();
464 tgNodes n6 = children[6]->getNodes();
465 tgNodes n7 = children[7]->getNodes();
466 tgNodes n8 = children[8]->getNodes();
467 tgNodes n9 = children[9]->getNodes();
468 tgNodes n10 = children[10]->getNodes();
469 tgNodes n11 = children[11]->getNodes();
470 tgNodes n12 = children[12]->getNodes();
471 tgNodes n13 = children[13]->getNodes();
597 for(std::size_t i = (m_segments + m_hips + m_legs); i < children.size(); i++) {
598 tgNodes ni = children[i]->getNodes();
599 tgNodes ni4 = children[i-4]->getNodes();
649 spec.addBuilder(
"rod",
new tgRodInfo(rodConfig));
660 structureInfo.buildInto(*
this, world);
664 allActuators = tgCast::filter<tgModel, tgSpringCableActuator> (
getDescendants());
680 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.
Definition of class tgKinematicActuatorInfo.
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="")