36 #include "LinearMath/btVector3.h"
50 TetraSpineKinematic::TetraSpineKinematic(
size_t segments) :
55 TetraSpineKinematic::~TetraSpineKinematic()
60 void addNodes(
tgStructure& tetra,
double edge,
double height)
64 tetra.
addNode(-edge / 2.0, 0, 0,
"base");
66 tetra.
addNode( edge / 2.0, 0, 0,
"base");
68 tetra.
addNode(0, height, 0,
"base");
70 tetra.
addNode(0, edge / 2.0 * tan(M_PI / 6.0), 2.50 * 5.0,
"tip");
74 tgNode nn1 = (oldNodes[0] + oldNodes[2])/2.0;
77 tgNode nn2 = (oldNodes[1] + oldNodes[2])/2.0;
81 std::cout << (oldNodes[3] - oldNodes[2]).length() << std::endl;
82 std::cout << (oldNodes[3] - oldNodes[1]).length() << std::endl;
83 std::cout << (oldNodes[3] - oldNodes[0]).length() << std::endl;
89 tetra.
addPair(0, 1,
"back bottom rod");
90 tetra.
addPair(0, 4,
"back rightBottom rod");
91 tetra.
addPair(4, 2,
"back rightTop rod");
92 tetra.
addPair(0, 3,
"front right rod");
93 tetra.
addPair(1, 5,
"back leftBottom rod");
94 tetra.
addPair(5, 2,
"back leftTop rod");
95 tetra.
addPair(1, 3,
"front left rod");
96 tetra.
addPair(2, 3,
"front top rod");
103 const btVector3 offset(0, 0, -2.30 * 5.0);
104 for (
size_t i = 0; i < segmentCount; ++i)
109 t->addTags(
tgString(
"segment num", i ));
111 t->move((i + 1) * offset);
122 const std::vector<tgStructure*> children = snake.
getChildren();
123 for (
size_t i = 1; i < children.size(); ++i)
125 tgNodes n0 = children[i-1]->getNodes();
126 tgNodes n1 = children[i ]->getNodes();
138 void mapMuscles(TetraSpineKinematic::MuscleMap& muscleMap,
153 std::cout <<
"StructureInfo:" << std::endl
154 << structureInfo << std::endl
155 <<
"Model: " << std::endl
156 << model << std::endl;
158 const std::vector<tgSpringCableActuator*> outerMuscles =
160 for (
size_t i = 0; i < outerMuscles.size(); ++i)
163 assert(pMuscle != NULL);
164 std::cout <<
"Outer muscle: " << *pMuscle << std::endl;
174 const double edge = 3.8 * 5.0;
175 const double height = tgUtil::round(std::sqrt(3.0)/2 * edge);
176 std::cout <<
"edge: " << edge <<
"; height: " << height << std::endl;
180 addNodes(tetra, edge, height);
185 tetra.move(btVector3(0.0, 8.0, 10.0));
189 addSegments(snake, tetra, edge, m_segments);
197 const double radius = 0.635 / 2.0;
198 const double sphereRadius = 0.635 / 2.0;
199 const double density = .0201 / (pow(radius, 2) * M_PI * edge);
200 const double friction = 0.5;
203 spec.addBuilder(
"rod",
new tgRodInfo(rodConfig));
206 const double sphereVolume1 = 1000.0 * 4.0 / 3.0 * M_PI * pow(sphereRadius, 3);
207 const double sphereVolume2 = 1000.0 * 4.0 / 3.0 * M_PI * pow(sphereRadius, 3);
209 const double baseCornerMidD = 180.0 / sphereVolume1;
210 const tgSphere::Config baseCornerMidConfig(sphereRadius, baseCornerMidD, friction);
211 spec.addBuilder(
"base",
new tgSphereInfo(baseCornerMidConfig));
213 const double tipCornerMidD = 120.0 / sphereVolume1;
214 const tgSphere::Config tipCornerMidConfig(sphereRadius, tipCornerMidD, friction);
215 spec.addBuilder(
"tip",
new tgSphereInfo(tipCornerMidConfig));
217 const double PCBD = 70.0 / sphereVolume2;
223 const double elasticity = 229.16;
224 const double damping = 20;
225 const double pretension = 0.0;
226 const bool history =
false;
227 const double maxTens = 5000.0;
228 const double maxSpeed = 7.0;
230 const double mRad = 1.0;
231 const double motorFriction = 10.0;
232 const double motorInertia = 1.0;
233 const bool backDrivable =
false;
235 mRad, motorFriction, motorInertia, backDrivable,
236 history, maxTens, maxSpeed);
239 mRad, motorFriction, motorInertia, backDrivable,
240 history, maxTens, maxSpeed);
257 m_allMuscles = this->find<tgSpringCableActuator> (
"muscle");
258 m_allSegments = this->find<tgModel> (
"segment");
259 mapMuscles(m_muscleMap, *
this);
262 trace(structureInfo, *
this);
280 throw std::invalid_argument(
"dt is not positive");
const std::vector< tgStructure * > & getChildren() const
void addChild(tgStructure *child)
Definition of class tgRodInfo.
Definition of class tgSphereInfo.
Convenience function for combining strings with ints, mostly for naming structures.
Contains the definition of class tgSphere.
Utility class for class casting and filtering collections by type.
Markers for specific places on a tensegrity.
virtual void setup(tgWorld &world)
const tgNodes & getNodes() const
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 setup(tgWorld &world)
std::string tgString(std::string s, int i)
Definition of class tgStructure.
std::vector< T * > find(const tgTagSearch &tagSearch)
Definition of class tgStructureInfo.
Rand seeding simular to the evolution and terrain classes.
Middle segment of In Won's robot reconfigured with tgBulletContactSpringCable and more segments...
virtual void step(const double dt)
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="")