36 #include "LinearMath/btVector3.h"
69 double targetVelocity;
86 #if (0) // Acceleration limit removed 12/10/14
114 const double half_length = c.rod_length / 2;
116 s.
addNode(-c.rod_space, -half_length, 0);
117 s.
addNode(-c.rod_space, half_length, 0);
118 s.
addNode( c.rod_space, -half_length, 0);
119 s.
addNode( c.rod_space, half_length, 0);
120 s.
addNode(0, -c.rod_space, -half_length);
121 s.
addNode(0, -c.rod_space, half_length);
122 s.
addNode(0, c.rod_space, -half_length);
123 s.
addNode(0, c.rod_space, half_length);
124 s.
addNode(-half_length, 0, c.rod_space);
125 s.
addNode( half_length, 0, c.rod_space);
126 s.
addNode(-half_length, 0, -c.rod_space);
127 s.
addNode( half_length, 0, -c.rod_space);
180 const tgRod::Config rodConfig(c.radius, c.density, c.friction,
181 c.rollFriction, c.restitution);
185 c.maxTens, c.targetVelocity);
196 s.move(btVector3(0, 10, 0));
200 btVector3 rotationPoint = btVector3(0, 0, 0);
201 btVector3 rotationAxis = btVector3(0, 1, 0);
202 double rotationAngle = M_PI/2;
203 s.
addRotation(rotationPoint, rotationAxis, rotationAngle);
207 spec.addBuilder(
"rod",
new tgRodInfo(rodConfig));
216 structureInfo.buildInto(*
this, world);
220 allMuscles = tgCast::filter<tgModel, tgBasicActuator> (
getDescendants());
234 throw std::invalid_argument(
"dt is not positive");
263 std::vector <tgRod*> rods = find<tgRod>(
"rod");
264 assert(!rods.empty());
266 btVector3 ballCenterOfMass(0, 0, 0);
267 double ballMass = 0.0;
268 for (std::size_t i = 0; i < rods.size(); i++) {
269 const tgRod*
const rod = rods[i];
271 const double rodMass = rod->
mass();
273 ballCenterOfMass += rodCenterOfMass * rodMass;
277 assert(ballMass > 0.0);
278 ballCenterOfMass /= ballMass;
281 std::vector<double> result(3);
282 for (
size_t i = 0; i < 3; ++i) { result[i] = ballCenterOfMass[i]; }
Contains the definition of class EscapeModel. $Id$.
virtual void setup(tgWorld &world)
Definition of class tgRodInfo.
virtual void step(double dt)
virtual void step(double dt)
virtual btVector3 centerOfMass() const
Definition of class tgBasicActuatorInfo.
virtual void onVisit(const tgModelVisitor &r) const
void addPair(int fromNodeIdx, int toNodeIdx, std::string tags="")
void addRotation(const btVector3 &fixedPoint, const btVector3 &axis, double angle)
Contains the definition of class tgBasicActuator.
virtual void onVisit(tgModelVisitor &r)
Definition of class tgStructure.
const std::vector< tgBasicActuator * > & getAllMuscles() const
Definition of class tgStructureInfo.
virtual double mass() const
virtual void setup(tgWorld &world)
Contains the definition of class tgRod.
Definition of class tgBuildSpec.
std::vector< double > getBallCOM()
void notifyStep(double dt)
std::vector< tgModel * > getDescendants() const
void addNode(double x, double y, double z, std::string tags="")