42 #include "LinearMath/btVector3.h"
48 FlemonsSpineModelLearningCL::FlemonsSpineModelLearningCL(
int segments) :
53 FlemonsSpineModelLearningCL::~FlemonsSpineModelLearningCL()
63 const double density = 4.2/300.0;
64 const double radius = 0.5;
65 const double friction = 0.5;
66 const double rollFriction = 0.0;
67 const double restitution = 0.0;
68 const tgRod::Config rodConfig(radius, density, friction, rollFriction, restitution);
70 const double radius2 = 0.15;
71 const double density2 = 1;
74 const double stiffness = 1000.0;
75 const double damping = .01*stiffness;
76 const double pretension = 0.0;
82 const double passivePretension = 700;
92 tetra.
addNode(0.0, v_size, 0.0);
93 tetra.
addNode(0.0, -v_size, 0.0);
94 tetra.
addNode(0.0, 0.0, v_size);
95 tetra.
addNode(0.0, 0.0, -v_size);
96 tetra.
addNode(v_size, 0.0, 0.0);
97 tetra.
addNode(-v_size, 0.0, 0.0);
100 tetra.
addPair(0,2,
"bottom rod");
101 tetra.
addPair(0,3,
"front rod");
102 tetra.
addPair(0,4,
"back rod");
103 tetra.
addPair(0,5,
"right rod");
104 tetra.
addPair(0,6,
"left rod");
109 const double offsetDist = -v_size *1.25;
110 btVector3 offset(0,0,offsetDist);
111 for(std::size_t i = 0; i < m_segments; i++) {
114 t->addTags(
tgString(
"segment num", i + 1));
115 t->move((i + 1)*offset);
119 t->
addRotation(btVector3(0.0, 0.0, (i + 1) * offsetDist), btVector3(1, 0, 0), M_PI/4.0);
123 t->
addRotation(btVector3(0.0, 0.0, (i + 1) * offsetDist), btVector3(0, 1, 0), -M_PI/4.0);
133 snake.
addRotation(btVector3(0.0, 0.0, 0.0), btVector3(0, 0, 1), M_PI/4.0);
134 snake.move(btVector3(0.0,15.0,100.0));
140 std::vector<tgStructure*> children = snake.
getChildren();
141 for(std::size_t i = 1; i < children.size(); i++) {
142 tgNodes n0 = children[i-1]->getNodes();
143 tgNodes n1 = children[i]->getNodes();
153 #if (1) // Traditional interior crosslink
193 spec.addBuilder(
"rod",
new tgRodInfo(rodConfig));
207 structureInfo.buildInto(*
this, world);
210 m_allMuscles = find<tgSpringCableActuator> (
"muscle2");
211 m_allSegments = this->find<tgModel> (
"segment");
215 std::cout <<
"StructureInfo:" << std::endl;
216 std::cout << structureInfo << std::endl;
218 std::cout <<
"Model: " << std::endl;
219 std::cout << *
this << std::endl;
const std::vector< tgStructure * > & getChildren() const
virtual void setup(tgWorld &world)
void addChild(tgStructure *child)
Definition of class tgRodInfo.
Implementing the cross-linked octahedral complex spine inspired by Tom Flemons.
Convenience function for combining strings with ints, mostly for naming structures.
virtual void step(double dt)
Utility class for class casting and filtering collections by type.
virtual void setup(tgWorld &world)
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.
Definition of class tgStructureInfo.
Contains the definition of class tgUtil and overloaded operator<<() free functions.
Definition of class tgBuildSpec.
virtual void step(double dt)
void addNode(double x, double y, double z, std::string tags="")