19 #include "RBStringTest.h"
21 #include "btBulletDynamicsCommon.h"
38 RBStringTest::Config::Config(
int segments,
41 double minTotalLength) :
44 m_stringConfig(stringConf),
45 m_minTotalLength(minTotalLength)
61 const double stiffness = m_config.m_stringConfig.
stiffness;
62 const double damping = m_config.m_stringConfig.
damping;
63 const double pretension = 0.0;
64 tgBasicActuator::Config muscleConfig1(stiffness, damping, pretension,
false, 1000.0, 100.0, 0.1, 0.1, -M_PI / 2.0);
65 tgBasicActuator::Config muscleConfig2(stiffness, damping, pretension,
false, 1000.0, 100.0, 0.1, 0.1, M_PI / 2.0);
70 double v_size = m_config.m_minTotalLength / (double) m_config.m_segments;
73 btVector3 buildVec = (*m_pEndNode - *m_pStartNode);
75 double spacing = buildVec.length() / (double) m_config.m_segments;
77 btVector3 offset = buildVec.normalize() * spacing;
83 tgNode endNode(v_size * buildVec);
89 tetra.move(*m_pStartNode);
96 for(
int i = 0; i < m_config.m_segments; i++) {
99 t->addTags(
tgString(
"segment num", i + 1));
100 t->move((i + 1)*offset);
105 std::vector<tgStructure*> children = snake.
getChildren();
106 for(
int i = 1; i < children.size(); i++) {
107 tgNodes n0 = children[i-1]->getNodes();
108 tgNodes n1 = children[i]->getNodes();
118 spec.addBuilder(
"rod",
new tgRodInfo(m_config.m_rodConfig));
129 structureInfo.buildInto(*
this, world);
132 allMuscles = tgCast::filter<tgModel, tgBasicActuator> (
getDescendants());
135 std::cout <<
"StructureInfo:" << std::endl;
136 std::cout << structureInfo << std::endl;
138 std::cout <<
"Model: " << std::endl;
139 std::cout << *
this << std::endl;
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.
virtual void step(double dt)
Utility class for class casting and filtering collections by type.
Definition of class tgBasicActuatorInfo.
void addPair(int fromNodeIdx, int toNodeIdx, std::string tags="")
virtual void step(double dt)
Definition of class tgConnectorInfo.
Definition of class tgNode.
std::string tgString(std::string s, int i)
Definition of class tgStructure.
Definition of class tgStructureInfo.
virtual void setup(tgWorld &world)
Contains the definition of class tgUtil and overloaded operator<<() free functions.
Definition of class tgBuildSpec.
Definition of class tgRigidAutoCompound.
void notifyStep(double dt)
std::vector< tgModel * > getDescendants() const
void addNode(double x, double y, double z, std::string tags="")