46 #include "LinearMath/btVector3.h"
58 const std::vector<tgStructure*> children = structure.
getChildren();
61 for(
int i = 0; i < segments; i++)
63 std::cout <<
"Rigid size " << model.getAllRigids().size() << std::endl;
64 btRigidBody* firstBody = model.getAllRigids()[4 * i]->getPRigidBody();
65 tgNodes n0 = children[i]->getNodes();
67 abstractMarker marker1(firstBody, n0[2] - firstBody->getCenterOfMassPosition (), btVector3(1, 0, 0), 0);
69 model.addMarker(marker1);
71 abstractMarker marker2(firstBody, n0[4] - firstBody->getCenterOfMassPosition (), btVector3(1, 0, 0), 0);
73 model.addMarker(marker2);
80 FlemonsSpineModelGoal::FlemonsSpineModelGoal(
int segments,
double goalAngle,
double startAngle) :
82 m_startAngle(startAngle)
86 FlemonsSpineModelGoal::~FlemonsSpineModelGoal()
98 const double density = 4.2/300.0;
99 const double radius = 0.5;
100 const double friction = 0.5;
101 const double rollFriction = 0.0;
102 const double restitution = 0.0;
103 const tgRod::Config rodConfig(radius, density, friction, rollFriction, restitution);
105 const double elasticity = 1000.0;
106 const double damping = 10.0;
107 const double pretension = 0.0;
108 const bool history =
true;
109 const double maxTens = 7000.0;
110 const double maxSpeed = 12.0;
112 const double mRad = 1.0;
113 const double motorFriction = 10.0;
114 const double motorInertia = 1.0;
115 const bool backDrivable =
false;
117 mRad, motorFriction, motorInertia, backDrivable,
118 history, maxTens, maxSpeed);
121 double v_size = 10.0;
127 tetra.
addNode( v_size, v_size, v_size);
128 tetra.
addNode( v_size, -v_size, -v_size);
129 tetra.
addNode(-v_size, v_size, -v_size);
130 tetra.
addNode(-v_size, -v_size, v_size);
132 tetra.
addPair(0, 1,
"front rod");
133 tetra.
addPair(0, 2,
"right rod");
134 tetra.
addPair(0, 3,
"back rod");
135 tetra.
addPair(0, 4,
"left rod");
139 tetra.move(btVector3(0.0,15.0,50.0));
145 btVector3 offset(0.0, 0.0, -v_size * 1.15);
146 for (std::size_t i = 0; i < m_segments; i++)
152 p->addTags(
tgString(
"segment num", i + 1));
153 p->move((i + 1.0) * offset);
161 std::vector<tgStructure*> children = snake.
getChildren();
162 for (std::size_t i = 1; i < children.size(); i++)
164 tgNodes n0 = children[i - 1]->getNodes();
165 tgNodes n1 = children[i]->getNodes();
168 tgString(
"outer front muscle seg", i));
170 tgString(
"outer right muscle seg", i));
172 tgString(
"outer back muscle seg", i));
174 tgString(
"outer top muscle seg", i));
177 tgString(
"inner front muscle seg", i));
179 tgString(
"inner right muscle seg", i));
181 tgString(
"inner left muscle seg", i));
183 tgString(
"inner back muscle seg", i));
188 btVector3 fixedPoint(0.0, 0.0, 0.0);
189 btVector3 axis(0.0, 1.0, 0.0);
195 spec.addBuilder(
"rod",
new tgRodInfo(rodConfig));
210 m_allMuscles = tgCast::filter<tgModel, tgSpringCableActuator> (
getDescendants());
212 m_allSegments = this->find<tgModel> (
"segment");
218 std::cout <<
"StructureInfo:" << std::endl;
219 std::cout << structureInfo << std::endl;
221 std::cout <<
"Model: " << std::endl;
222 std::cout << *
this << std::endl;
224 std::cout <<
"Spine Length: " << getSpineLength() << std::endl;
227 std::vector<tgBaseRigid*> myRigids = this->getAllRigids();
229 for (
int i =0; i < myRigids.size(); i++)
231 std::cout << myRigids[i]->mass() <<
" " <<myRigids[i]->getPRigidBody() << std::endl;
virtual void setup(tgWorld &world)
const std::vector< tgStructure * > & getChildren() const
void addChild(tgStructure *child)
Definition of class tgRodInfo.
virtual void setup(tgWorld &world)
Convenience function for combining strings with ints, mostly for naming structures.
Utility class for class casting and filtering collections by type.
Implementing the tetrahedral complex spine inspired by Tom Flemons.
Markers for specific places on a tensegrity.
virtual void step(double dt)
Definition of class tgBasicActuatorInfo.
Class that interfaces with Bullet to build the boxes.
void addPair(int fromNodeIdx, int toNodeIdx, std::string tags="")
Contains the definition of abstract base class tgSpringCableActuator. Assumes that the string is line...
virtual void step(double dt)
void addRotation(const btVector3 &fixedPoint, const btVector3 &axis, double angle)
std::string tgString(std::string s, int i)
Definition of class tgStructure.
Definition of class tgStructureInfo.
Definition of class tgKinematicActuatorInfo.
Rand seeding simular to the evolution and terrain classes.
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="")