45 #include "LinearMath/btVector3.h"
51 OctahedralComplex::OctahedralComplex(
int segments,
double goalAngle,
double startAngle) :
53 m_startAngle(startAngle)
57 OctahedralComplex::~OctahedralComplex()
67 const double density = 4.2/300.0;
68 const double radius = 0.5;
69 const double friction = 0.5;
70 const double rollFriction = 0.0;
71 const double restitution = 0.0;
72 const tgRod::Config rodConfig(radius, density, friction, rollFriction, restitution);
74 const double elasticity = 1000.0;
75 const double damping = 10.0;
76 const double pretension = 0.0;
77 const bool history =
false;
78 const double maxTens = 7000.0;
79 const double maxSpeed = 24.0;
81 const double mRad = 1.0;
82 const double motorFriction = 10.0;
83 const double motorInertia = 1.0;
84 const bool backDrivable =
false;
86 mRad, motorFriction, motorInertia, backDrivable,
87 history, maxTens, maxSpeed);
94 const double passivePretension = 700;
96 mRad, motorFriction, motorInertia, backDrivable,
97 history, maxTens, maxSpeed);
100 double v_size = 10.0;
106 tetra.
addNode(0.0, v_size, 0.0);
107 tetra.
addNode(0.0, -v_size, 0.0);
108 tetra.
addNode(0.0, 0.0, v_size);
109 tetra.
addNode(0.0, 0.0, -v_size);
110 tetra.
addNode(v_size, 0.0, 0.0);
111 tetra.
addNode(-v_size, 0.0, 0.0);
114 tetra.
addPair(0,2,
"bottom rod");
115 tetra.
addPair(0,3,
"front rod");
116 tetra.
addPair(0,4,
"back rod");
117 tetra.
addPair(0,5,
"right rod");
118 tetra.
addPair(0,6,
"left rod");
123 const double offsetDist = -v_size *1.25;
124 btVector3 offset(0,0,offsetDist);
125 for(std::size_t i = 0; i < m_segments; i++) {
128 t->addTags(
tgString(
"segment num", i + 1));
129 t->move((i + 1)*offset);
133 t->
addRotation(btVector3(0.0, 0.0, (i + 1) * offsetDist), btVector3(1, 0, 0), M_PI/4.0);
137 t->
addRotation(btVector3(0.0, 0.0, (i + 1) * offsetDist), btVector3(0, 1, 0), -M_PI/4.0);
147 snake.
addRotation(btVector3(0.0, 0.0, 0.0), btVector3(0, 0, 1), M_PI/4.0);
148 snake.move(btVector3(0.0,15.0,100.0));
154 std::vector<tgStructure*> children = snake.
getChildren();
155 for(std::size_t i = 1; i < children.size(); i++) {
156 tgNodes n0 = children[i-1]->getNodes();
157 tgNodes n1 = children[i]->getNodes();
167 #if (1) // Traditional interior crosslink
206 btVector3 fixedPoint(0.0, 0.0, 0.0);
207 btVector3 axis(0.0, 1.0, 0.0);
214 spec.addBuilder(
"rod",
new tgRodInfo(rodConfig));
231 m_allMuscles = find<tgSpringCableActuator> (
"muscle2");
232 m_saddleMuscles = find<tgSpringCableActuator> (
"muscle");
233 m_allSegments = this->find<tgModel> (
"segment");
237 std::cout <<
"StructureInfo:" << std::endl;
238 std::cout << structureInfo << std::endl;
240 std::cout <<
"Model: " << std::endl;
241 std::cout << *
this << std::endl;
Create a box shape as an obstacle or add it to your tensegrity.
const std::vector< tgStructure * > & getChildren() const
void addChild(tgStructure *child)
Definition of class tgRodInfo.
Implementing the cross-linked octahedral complex spine inspired by Tom Flemons.
virtual void setup(tgWorld &world)
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.
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="")
virtual void step(double dt)
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.
Definition of class tgStructureInfo.
Rand seeding simular to the evolution and terrain classes.
Definition of class tgBuildSpec.
void buildInto(tgModel &model, tgWorld &world)
void addNode(double x, double y, double z, std::string tags="")