44 #include "LinearMath/btVector3.h"
53 tetra.
addNode(0.0, v_size, v_size / 2.0);
54 tetra.
addNode(-v_size, 0.0, -v_size);
55 tetra.
addNode(v_size, 0.0, -v_size);
56 #if (0) // Attempt at compliant rib attachments
57 tetra.
addNode(-v_size / 5.0, 0.0, 0.0);
58 tetra.
addNode(v_size / 5.0, 0.0, 0.0);
62 void ellipseNodes(
tgStructure& tetra,
double a,
double b,
double startT,
double endT,
size_t n)
64 double rodL = (endT - startT) / (
double) n;
66 for(
size_t i = 0; i < n; i++)
68 double x = a * cos( startT + i * rodL);
69 double y = b * sin( startT + i * rodL);
71 tgNode node( btVector3( x, y, 0.0));
76 double x = a * cos( startT + (n - 1) * rodL);
77 double y = b * sin( startT + (n - 1) * rodL) - 0.5;
78 tgNode node( btVector3( x, y, 0.0));
88 tetra.
addPair(0,3,
"right rod");
89 #if (0) // extra connection points for muscles
90 tetra.
addPair(0,4,
"leftRib rod");
91 tetra.
addPair(0,5,
"rightRib rod");
99 std::cout <<
"Nodes size is " << n << std::endl;
100 for(std::size_t i = 1; i < n; i++) {
106 const tgStructure& ribs,
double edge,
size_t segmentCount)
108 const btVector3 offset(0, 0, -edge * 1.3);
109 const btVector3 rotAxis(0, 1.0, 0);
110 for (
size_t i = 0; i < segmentCount; ++i)
124 size_t r02End = r02.getNodes().size();
127 t->
addPair(t01[0], r01[0],
"multiMuscle connect");
128 t->
addPair(t01[0], r02[0],
"multiMuscle connect");
130 t->
addPair(t01[0], r01[0],
"rod connect");
131 t->
addPair(t01[0], r02[0],
"rod connect");
136 t->addTags(
tgString(
"segment num", i + 1));
137 t->move((i + 1) * offset);
146 const std::vector<tgStructure*> children = snake.
getChildren();
147 for (
size_t i = 1; i < children.size(); ++i)
149 tgNodes n0 = children[i-1]->getNodes();
150 tgNodes n1 = children[i ]->getNodes();
152 const std::vector<tgStructure*> subChildren1 = children[i-1]->getChildren();
153 const std::vector<tgStructure*> subChildren2 = children[i]->getChildren();
155 tgNodes r10 = subChildren1[0]->getNodes();
156 tgNodes r11 = subChildren1[1]->getNodes();
157 tgNodes r20 = subChildren2[0]->getNodes();
158 tgNodes r21 = subChildren2[1]->getNodes();
172 else if (i == children.size() - 1)
205 std::cout <<
"StructureInfo:" << std::endl
206 << structureInfo << std::endl
207 <<
"Model: " << std::endl
208 << model << std::endl;
210 const std::vector<tgSpringCableActuator*> outerMuscles =
212 for (
size_t i = 0; i < outerMuscles.size(); ++i)
215 assert(pMuscle != NULL);
216 std::cout <<
"Outer muscle: " << *pMuscle << std::endl;
222 RibModelMixedContact::RibModelMixedContact(
int segments) :
227 RibModelMixedContact::~RibModelMixedContact()
237 addNodes(vertebrae, v_size);
242 vertebrae.move(btVector3(0.0, 2 * v_size, v_size * m_segments));
245 double majorAxis = 6.0;
246 double minorAxis = 4.0;
247 double startTheta = M_PI / 2.0;
248 double endTheta = 5.0 * M_PI / 4.0;
252 ellipseNodes(ribs, majorAxis, minorAxis, startTheta, endTheta, segs);
255 #if (0) // Attempt at compliant rib attachments
256 ribs.move(btVector3(v_size / 3.0, 2 * v_size - minorAxis, v_size * m_segments));
258 ribs.move(btVector3(0.0, 2 * v_size - minorAxis -.3, v_size * m_segments));
262 addSegments(snake, vertebrae, ribs, v_size, m_segments);
264 snake.move(btVector3(0.0, majorAxis, 0.0));
270 const double density = 4.2 / 300.0;
271 const double radius = 0.5;
272 const double friction = 0.5;
273 const double rollFriction = 0.5;
274 const double restitution = 0.0;
276 const tgRod::Config rodConfig(radius, density, friction, rollFriction, restitution);
278 spec.addBuilder(
"rod",
new tgRodInfo(rodConfig));
280 const double elasticity = 500.0;
281 const double elasticityAct = 1000.0;
282 const double damping = 5.0;
283 const double dampingAct = 10.0;
284 const double pretension = 0.0;
285 const bool history =
true;
286 const double maxTens = 1000.0;
287 const double maxTensAct = 7000.0;
288 const double maxSpeed = 100.0;
289 const double maxSpeedAct = 24.0;
291 const double mRad = 1.0;
292 const double motorFriction = 10.0;
293 const double motorInertia = 1.0;
294 const bool backDrivable =
false;
297 #if (0) //Replacing with tgKinematicActuator, leaving option to turn it off. 9/9/15.
299 mRad, motorFriction, motorInertia, backDrivable,
300 history, maxTens, maxSpeed);
304 mRad, motorFriction, motorInertia, backDrivable,
305 history, maxTensAct, maxSpeedAct);
315 #if (0) // Compliant Rib Attachments
316 const double stiffness = 1000;
317 const double damping = .01 * stiffness;
337 m_allMuscles = find<tgSpringCableActuator> (
"muscleAct");
338 m_allSegments = find<tgModel> (
"segment");
341 trace(structureInfo, *
this);
359 throw std::invalid_argument(
"dt is not positive");
const std::vector< tgStructure * > & getChildren() const
void addChild(tgStructure *child)
Definition of class tgRodInfo.
Convenience function for combining strings with ints, mostly for naming structures.
Utility class for class casting and filtering collections by type.
virtual void setup(tgWorld &world)
const tgNodes & getNodes() const
Definition of class tgBasicActuatorInfo.
void addPair(int fromNodeIdx, int toNodeIdx, std::string tags="")
Contains the definition of abstract base class tgSpringCableActuator. Assumes that the string is line...
void addRotation(const btVector3 &fixedPoint, const btVector3 &axis, double angle)
std::string tgString(std::string s, int i)
Definition of class tgStructure.
std::vector< T * > find(const tgTagSearch &tagSearch)
Definition of class tgStructureInfo.
Definition of class tgKinematicActuatorInfo.
Rand seeding simular to the evolution and terrain classes.
Definition of class tgBuildSpec.
virtual void step(double dt)
void buildInto(tgModel &model, tgWorld &world)
void addNode(double x, double y, double z, std::string tags="")