Exemple #1
0
void QSegmentWidget::addSegment(int cyl, qreal startAngle, qreal stopAngle, QColor color)
{
//  Segment s(startAngle, stopAngle, color);
    QSegmentWidget::Segment s;
    s.first = startAngle;
    s.second = stopAngle;
    s.color = color;

  SegmentList sl;
  sl.push_back(s);
  addSegments(cyl, sl);
}
void NestedBoxTestModel::setup(tgWorld& world)
{
    const double edge = 30.0;
    const double height = tgUtil::round(std::sqrt(3.0)/2 * edge);
    std::cout << "edge: " << edge << "; height: " << height << std::endl;

    // Create the tetrahedra
    tgStructure tetra;
    addNodes(tetra, edge, height);
    addPairs(tetra);

    // Move the first one so we can create a longer snake.
    // Or you could move the snake at the end, up to you. 
    tetra.move(btVector3(0.0, 2.0, 100.0));

    // Create our snake segments
    tgStructure snake;
    addSegments(snake, tetra, edge, m_segments);
    addMuscles(snake);

    // Create the build spec that uses tags to turn the structure into a real model
    // Note: This needs to be high enough or things fly apart...
    const double density = 4.2 / 3000.0; // kg / length^3 - see app for length
    const double radius = 0.5;
    const double h  = 0.5;
    const tgBox::Config rodConfig(radius, density);
    tgBuildSpec spec;
    spec.addBuilder("rod", new tgBoxInfo(rodConfig));
    
    tgSpringCableActuator::Config muscleConfig(1000, 10);
    //spec.addBuilder("muscle", new tgBasicActuatorInfo(muscleConfig));
    
    const tgSphere::Config sphereConfig(0.5, 0.5);
    spec.addBuilder("light", new tgSphereInfo(sphereConfig));
    
    const tgSphere::Config sphereConfig2(0.5, 2.5);
    spec.addBuilder("light", new tgSphereInfo(sphereConfig2));
    
    // Create your structureInfo
    tgStructureInfo structureInfo(snake, spec);
    // Use the structureInfo to build ourselves
    structureInfo.buildInto(*this, world);

    // We could now use tgCast::filter or similar to pull out the models (e.g. muscles)
    // that we want to control.    
    allMuscles = tgCast::filter<tgModel, tgSpringCableActuator> (getDescendants());
    mapMuscles(muscleMap, *this);

    trace(structureInfo, *this);

    // Actually setup the children
    tgModel::setup(world);
}
Exemple #3
0
static void init()
{
	addSegments();

	self->dirX = self->face == LEFT ? -self->speed : self->speed;

	self->action = &headMove;

	if (self->mental >= 2)
	{
		self->touch = &greenTouch;
	}

	self->creditsAction = &creditsMove;
}
void BigDoxieNoFeet::setup(tgWorld& world)
{
    //Rod and Muscle configuration. 
    const double density = 4.2/300.0; //Note: this needs to be high enough or things fly apart...
    const double radius = 0.5;
    const double rod_space = 10.0;
    const double rod_space2 = 8.0;
    const double friction = 0.5;
    const double rollFriction = 0.0;
    const double restitution = 0.0;

    const tgRod::Config rodConfig(radius, density, friction, rollFriction, restitution);

    const double stiffness = 1000.0;
    const double stiffnessPassive = 5000.0;
    const double stiffnessPassive4 = 3000.0;
    const double damping = .01*stiffness;
    const double pretension = 0.0; //units of pretension is in Newtons.
    const bool   history = true;
    const double maxTens = 7000.0;
    const double maxSpeed = 12.0;

    const double passivePretension = 1000; 
    const double passivePretension2 = 2500;
    const double passivePretension3 = 13000; // was 2500
    const double passivePretension4 = 4000; 

#ifdef USE_KINEMATIC

    const double mRad = 1.0;
    const double motorFriction = 10.0;
    const double motorInertia = 1.0;
    const bool backDrivable = false;
    #ifdef PASSIVE_STRUCTURE
        tgKinematicActuator::Config motorConfigSpine(2*stiffness, damping, pretension,
                                            mRad, motorFriction, motorInertia, backDrivable,
                                            history, maxTens, maxSpeed);

	tgKinematicActuator::Config motorConfigStomach(3*stiffness, damping, passivePretension3,
                                            mRad, motorFriction, motorInertia, backDrivable,
                                            history, maxTens, maxSpeed);

	tgKinematicActuator::Config motorConfigOther(stiffnessPassive, damping, passivePretension2,
                                            mRad, motorFriction, motorInertia, backDrivable,
                                            history, maxTens, maxSpeed); 

	tgKinematicActuator::Config motorConfigFeet(stiffnessPassive, damping, passivePretension,
                                            mRad, motorFriction, motorInertia, backDrivable,
                                            history, maxTens, maxSpeed); 
	tgKinematicActuator::Config motorConfigLegs(stiffnessPassive4, damping, passivePretension4,
                                            mRad, motorFriction, motorInertia, backDrivable,
                                            history, maxTens, maxSpeed);
    #else
        tgKinematicActuator::Config motorConfigSpine(2*stiffness, damping, pretension,
                                            mRad, motorFriction, motorInertia, backDrivable,
                                            history, maxTens, maxSpeed); 

	tgKinematicActuator::Config motorConfigStomach(3*stiffness, damping, passivePretension3,
                                            mRad, motorFriction, motorInertia, backDrivable,
                                            history, maxTens, maxSpeed);

	tgKinematicActuator::Config motorConfigOther(stiffnessPassive, damping, passivePretension2,
                                            mRad, motorFriction, motorInertia, backDrivable,
                                            history, maxTens, maxSpeed); 

	tgKinematicActuator::Config motorConfigFeet(stiffnessPassive, damping, passivePretension,
                                            mRad, motorFriction, motorInertia, backDrivable,
                                            history, maxTens, maxSpeed); 
	tgKinematicActuator::Config motorConfigLegs(stiffnessPassive4, damping, passivePretension4,
                                            mRad, motorFriction, motorInertia, backDrivable,
                                            history, maxTens, maxSpeed);
    #endif

#else
    
    #ifdef PASSIVE_STRUCTURE
        tgSpringCableActuator::Config muscleConfigSpine(2*stiffness, damping, passivePretension);
	tgSpringCableActuator::Config muscleConfigStomach(2*stiffnessPassive, damping, passivePretension3);
	tgSpringCableActuator::Config muscleConfigOther(stiffnessPassive, damping, passivePretension2);
	tgSpringCableActuator::Config muscleConfigFeet(stiffnessPassive, damping, passivePretension); 
	tgSpringCableActuator::Config muscleConfigLegs(stiffnessPassive4, damping, passivePretension4);
    #else
        tgSpringCableActuator::Config muscleConfigSpine(2*stiffness, damping, pretension, history, maxTens, 2*maxSpeed);
	tgSpringCableActuator::Config muscleConfigStomach(3*stiffnessPassive, damping, passivePretension3, history, maxTens, 2*maxSpeed); 
	tgSpringCableActuator::Config muscleConfigOther(stiffnessPassive, damping, passivePretension2);
	tgSpringCableActuator::Config muscleConfigFeet(stiffnessPassive, damping, passivePretension); 
	tgSpringCableActuator::Config muscleConfigLegs(stiffnessPassive4, damping, passivePretension4);
    #endif

#endif

    //Foot:
    tgStructure foot;
    addNodesFoot(foot,rod_space,rod_space2);
    addRodsFoot(foot);

    //Leg:
    tgStructure leg;
    addNodesLeg(leg,rod_space);
    addRodsLeg(leg);

    //Create the basic unit of the puppy
    tgStructure vertebra;
    addNodesVertebra(vertebra,rod_space);
    addRodsVertebra(vertebra);

    //Create the basic unit for the hips/shoulders. 
    tgStructure hip;
    addNodesHip(hip,rod_space);
    addRodsHip(hip);

    //Build the puppy
    tgStructure puppy;

    const double yOffset_foot = -(2*rod_space+6);

    addSegments(puppy,vertebra,hip,leg,foot,rod_space); //,m_segments,m_hips,m_legs,m_feet

    puppy.move(btVector3(0.0,-yOffset_foot,0.0));

    addMuscles(puppy); //,m_segments,m_hips,m_legs,m_feet

    //Time to add the muscles to the structure. Todo: make this a function; also try to clean this up.
    std::vector<tgStructure*> children = puppy.getChildren();
   
    // Create the build spec that uses tags to turn the structure into a real model
    tgBuildSpec spec;
    spec.addBuilder("rod", new tgRodInfo(rodConfig));

#ifdef USE_KINEMATIC

    #ifdef PASSIVE_STRUCTURE
        spec.addBuilder("muscleAct1", new tgKinematicContactCableInfo(motorConfigSpine));
	spec.addBuilder("muscleAct2", new tgKinematicContactCableInfo(motorConfigStomach));
	spec.addBuilder("muscle ", new tgKinematicContactCableInfo(motorConfigOther));
	spec.addBuilder("muscle2 ", new tgKinematicContactCableInfo(motorConfigFeet));
	spec.addBuilder("muscle3 ", new tgKinematicContactCableInfo(motorConfigLegs));
    #else 
	spec.addBuilder("muscleAct1", new tgKinematicContactCableInfo(motorConfigSpine));
	spec.addBuilder("muscleAct2", new tgKinematicContactCableInfo(motorConfigStomach));
	spec.addBuilder("muscle ", new tgKinematicContactCableInfo(motorConfigOther));
	spec.addBuilder("muscle2 ", new tgKinematicContactCableInfo(motorConfigFeet));
	spec.addBuilder("muscle3 ", new tgKinematicContactCableInfo(motorConfigLegs));
	
    #endif

#else
    #ifdef PASSIVE_STRUCTURE
   	spec.addBuilder("muscleAct1", new tgBasicActuatorInfo(muscleConfigSpine));
	spec.addBuilder("muscleAct2", new tgBasicActuatorInfo(muscleConfigStomach));
	spec.addBuilder("muscle " , new tgBasicActuatorInfo(muscleConfigOther));
	spec.addBuilder("muscle2 " , new tgBasicActuatorInfo(muscleConfigFeet));
	spec.addBuilder("muscle3 " , new tgBasicActuatorInfo(muscleConfigLegs));
    #else 
	spec.addBuilder("muscleAct1" , new tgBasicActuatorInfo(muscleConfigSpine));
	spec.addBuilder("muscleAct2" , new tgBasicActuatorInfo(muscleConfigStomach));
	spec.addBuilder("muscle " , new tgBasicActuatorInfo(muscleConfigOther));
	spec.addBuilder("muscle2 " , new tgBasicActuatorInfo(muscleConfigFeet));
	spec.addBuilder("muscle3 " , new tgBasicActuatorInfo(muscleConfigLegs));
    #endif
    
#endif


    
    // Create your structureInfo
    tgStructureInfo structureInfo(puppy, spec);

    // Use the structureInfo to build ourselves
    structureInfo.buildInto(*this, world);

    // We could now use tgCast::filter or similar to pull out the
    // models (e.g. muscles) that we want to control. 
    m_allMuscles = tgCast::filter<tgModel, tgSpringCableActuator> (getDescendants());

    m_allSegments = this->find<tgModel> ("spine segment");
    
    // Actually setup the children, notify controller that the setup has finished
    BaseSpineModelLearning::setup(world);

    children.clear();
}
// This is basically a manual setup of a model.
// There are things that do this for us (@todo: reference the things that do this for us)
void TetraSpineGoal::setup(tgWorld& world)
{
    const double edge = 3.8 * scaleFactor;
    const double height = tgUtil::round(std::sqrt(3.0)/2 * edge);
    std::cout << "edge: " << edge << "; height: " << height << std::endl;
	
    // Create the tetrahedra
    tgStructure tetra;
    addNodes(tetra, edge, height, scaleFactor);
    addPairs(tetra);

    // Move the first one so we can create a longer snake.
    // Or you could move the snake at the end, up to you. 
    tetra.move(btVector3(0.0, 8.0, 10.0));

    // Create our snake segments
    tgStructure snake;
    addSegments(snake, tetra, -2.30 * scaleFactor, m_segments);
    addMuscles(snake);

    // Create the build spec that uses tags to turn the structure into a real model
    // Note: This needs to be high enough or things fly apart...
    

    // Params for In Won
    const double radius  = 0.635 * scaleFactor / 10.0;
    const double sphereRadius  = 0.635 * scaleFactor / (10.0);
    const double density = 2.0 *.0201 / (pow(radius, 2) * M_PI * edge); // Mass divided by volume... should there be a way to set this automatically??
    const double friction = 0.5;
    const tgRod::Config rodConfig(radius, density, friction);
    tgBuildSpec spec;
    spec.addBuilder("rod", new tgRodInfo(rodConfig));
    
    // 1000 is so the units below can be in grams
    const double sphereVolume1 = 1000.0 * 4.0 / 3.0 * M_PI * pow(sphereRadius, 3);
    const double sphereVolume2 = 1000.0 * 4.0 / 3.0 * M_PI * pow(sphereRadius, 3);
    
    const double baseCornerMidD = 180.0 / sphereVolume1;
    const tgSphere::Config baseCornerMidConfig(sphereRadius, baseCornerMidD, friction);
    spec.addBuilder("base", new tgSphereInfo(baseCornerMidConfig));

    const double tipCornerMidD = 120.0 / sphereVolume1;
    const tgSphere::Config tipCornerMidConfig(sphereRadius, tipCornerMidD, friction);
    spec.addBuilder("tip", new tgSphereInfo(tipCornerMidConfig));
    
    const double PCBD = 70.0 / sphereVolume2;
    const tgSphere::Config PCB_1_Config(radius, PCBD, friction);
    spec.addBuilder("PCB", new tgSphereInfo(PCB_1_Config));
    
    
        const double elasticity = 1000.0;
    const double damping = 10.0;
    const double pretension = 0.0;
    const bool   history = false;
    const double maxTens = 7000.0;
    const double maxSpeed = 12.0;

    const double mRad = 1.0;
    const double motorFriction = 10.0;
    const double motorInertia = 1.0;
    const bool backDrivable = false;
    
    tgKinematicActuator::Config motorConfig(elasticity, damping, pretension,
                                            mRad, motorFriction, motorInertia, backDrivable,
                                            history, maxTens, maxSpeed);
    
    spec.addBuilder("muscle", new tgKinematicContactCableInfo(motorConfig));

    // Create your structureInfo
    tgStructureInfo structureInfo(snake, spec);

    // Use the structureInfo to build ourselves
    structureInfo.buildInto(*this, world);

    // We could now use tgCast::filter or similar to pull out the models (e.g. muscles)
    // that we want to control.    
    m_allMuscles = this->find<tgSpringCableActuator> ("muscle");
    m_allSegments = this->find<tgModel> ("segment");
    mapMuscles(m_muscleMap, *this);
    
    //addMarkers(snake, *this);
    
    #if (0)
    trace(structureInfo, *this);
    #endif
    
    // Actually setup the children
    BaseSpineModelGoal::setup(world);
}
void RibModelMixedContact::setup(tgWorld& world)
{
    double v_size = 3.0;
    
    // Create the spinal processes
    tgStructure vertebrae;
    addNodes(vertebrae, v_size);
    addPairs(vertebrae);

    // Move the first one so we can create a longer snake.
    // Or you could move the snake at the end, up to you. 
    vertebrae.move(btVector3(0.0, 2 * v_size, v_size * m_segments));
    
    // Create ribs and add them to the vertebrae
    double majorAxis  = 6.0;
    double minorAxis  = 4.0;
    double startTheta = M_PI / 2.0;
    double endTheta   = 5.0 * M_PI / 4.0;
    size_t segs       = 15;
    
    tgStructure ribs;
    ellipseNodes(ribs, majorAxis, minorAxis, startTheta, endTheta, segs);
    makePairs(ribs);
    
    #if (0) // Attempt at compliant rib attachments
    ribs.move(btVector3(v_size / 3.0, 2 * v_size - minorAxis, v_size * m_segments));
    #else
    ribs.move(btVector3(0.0, 2 * v_size - minorAxis -.3, v_size * m_segments));
    #endif
    // Create our snake segments
    tgStructure snake;
    addSegments(snake, vertebrae, ribs, v_size, m_segments);
    
    snake.move(btVector3(0.0, majorAxis, 0.0));
    
    addMuscles(snake);

    // Create the build spec that uses tags to turn the structure into a real model
    // Note: This needs to be high enough or things fly apart...
    const double density = 4.2 / 300.0;
    const double radius  = 0.5;
    const double friction = 0.5; // Default is 0.5
    const double rollFriction  = 0.5; // Default is 0.0
    const double restitution  = 0.0; // Default
    
    const tgRod::Config rodConfig(radius, density, friction, rollFriction, restitution);
    tgBuildSpec spec;
    spec.addBuilder("rod", new tgRodInfo(rodConfig));  
    
    const double elasticity = 500.0;
    const double elasticityAct = 1000.0;
    const double damping = 5.0;
    const double dampingAct = 10.0;
    const double pretension = 0.0;
    const bool	 history = true;
    const double maxTens = 1000.0;
    const double maxTensAct = 7000.0;
    const double maxSpeed = 100.0;
    const double maxSpeedAct = 24.0;
    
    const double mRad = 1.0;
    const double motorFriction = 10.0;
    const double motorInertia = 1.0; 
    const bool backDrivable = false;
    

    #if (0) //Replacing with tgKinematicActuator, leaving option to turn it off. 9/9/15.
    tgKinematicActuator::Config muscleConfig(elasticity, damping, pretension,
                                            mRad, motorFriction, motorInertia, backDrivable,
                                            history, maxTens, maxSpeed);
    spec.addBuilder("muscle", new tgKinematicContactCableInfo(muscleConfig));

    tgKinematicActuator::Config muscleConfigAct(elasticityAct, dampingAct, pretension,
						mRad, motorFriction, motorInertia, backDrivable,
                                                history, maxTensAct, maxSpeedAct);
    spec.addBuilder("muscleAct", new tgKinematicContactCableInfo(muscleConfigAct));
    #else
    tgSpringCableActuator::Config muscleConfig(elasticity, damping, pretension, history);
    spec.addBuilder("muscle", new tgBasicContactCableInfo(muscleConfig));
    /// @todo acceleration constraint was removed on 12/10/14 Replace with tgKinematicActuator as appropreate
    tgSpringCableActuator::Config muscleConfigAct(elasticityAct, dampingAct, pretension, history, 7000, 24);
    spec.addBuilder("muscleAct", new tgBasicContactCableInfo(muscleConfigAct));
    #endif
    
    #if (0) // Compliant Rib Attachments
    const double stiffness = 1000;
    const double damping = .01 * stiffness;
    
    tgSpringCableActuator::Config muscleConfig1(stiffness, damping, -M_PI / 2.0);
    tgSpringCableActuator::Config muscleConfig2(stiffness, damping, M_PI / 2.0);
    tgSpringCableActuator::Config muscleConfig3(stiffness, damping, M_PI);
    tgSpringCableActuator::Config muscleConfig4(stiffness, damping, 0);
    
    spec.addBuilder("multiMuscle", new tgBasicActuatorInfo(muscleConfig1));
    spec.addBuilder("multiMuscle", new tgBasicActuatorInfo(muscleConfig2));
    spec.addBuilder("multiMuscle", new tgBasicActuatorInfo(muscleConfig3));
    spec.addBuilder("multiMuscle", new tgBasicActuatorInfo(muscleConfig4));
    #endif
    // Create your structureInfo
    tgStructureInfo structureInfo(snake, spec);

    // Use the structureInfo to build ourselves
    structureInfo.buildInto(*this, world);

    // We could now use tgCast::filter or similar to pull out the models (e.g. muscles)
    // that we want to control.    
    m_allMuscles = find<tgSpringCableActuator> ("muscleAct");
    m_allSegments = find<tgModel> ("segment");

    #if (0)
    trace(structureInfo, *this);
    #endif
   
    // Actually setup the children
    BaseSpineModelLearning::setup(world);
}
// This is basically a manual setup of a model.
// There are things that do this for us (@todo: reference the things that do this for us)
void TetraSpineStaticModel_hf::setup(tgWorld& world)
{
    const double edge = 38;
    const double height = tgUtil::round(std::sqrt(3.0)/2 * edge);
    std::cout << "edge: " << edge << "; height: " << height << std::endl;

    // Create the tetrahedra
    tgStructure tetra;
    addNodes(tetra, edge, height);
    addPairs(tetra);

    // Move the first one so we can create a longer snake.
    // Or you could move the snake at the end, up to you.
    tetra.move(btVector3(0.0, 2.0, 100.0));

    // Create our snake segments
    tgStructure snake;
    addSegments(snake, tetra, edge, m_segments);
    addMuscles(snake);

    // Create the build spec that uses tags to turn the structure into a real model
    // Note: This needs to be high enough or things fly apart...


    // Params for In Won
    const double oldDensity = .00311;
    const double radius  = 0.635 / 2.0;
    const double density = 0.0201 / (pow(radius, 2) * M_PI * edge); // Mass divided by volume... should there be a way to set this automatically??
    const double friction = 0.15;
    const tgRod::Config rodConfig(radius, density, friction);
    tgBuildSpec spec;
    spec.addBuilder("rod", new tgRodInfo(rodConfig));

    // 1000 is so the units below can be in grams
    const double sphereVolume = 1000.0 * 4.0 / 3.0 * M_PI * pow(radius, 3);

    const double baseCornerFrontD = 140.0 / sphereVolume;
    const tgSphere::Config baseCornerFrontConfig(radius, baseCornerFrontD, friction);
    spec.addBuilder("num0 base", new tgSphereInfo(baseCornerFrontConfig));

    const double baseCornerMidD = 180.0 / sphereVolume;
    const tgSphere::Config baseCornerMidConfig(radius, baseCornerMidD, friction);
    spec.addBuilder("num1 base", new tgSphereInfo(baseCornerMidConfig));

    const double baseCornerRearD = 100.0 / sphereVolume;
    const tgSphere::Config baseCornerRearConfig(radius, baseCornerRearD, friction);
    spec.addBuilder("num2 base", new tgSphereInfo(baseCornerRearConfig));

    const double tipCornerFrontD = 40.0 / sphereVolume;
    const tgSphere::Config tipCornerFrontConfig(radius, tipCornerFrontD, friction);
    spec.addBuilder("num0 tip", new tgSphereInfo(tipCornerFrontConfig));

    const double tipCornerMidD = 120.0 / sphereVolume;
    const tgSphere::Config tipCornerMidConfig(radius, tipCornerMidD, friction);
    spec.addBuilder("num1 tip", new tgSphereInfo(tipCornerMidConfig));
    spec.addBuilder("num2 tip", new tgSphereInfo(tipCornerMidConfig));

    const double PCBD = 70.0 / sphereVolume;
    const tgSphere::Config PCB_1_Config(radius, PCBD, friction);
    spec.addBuilder("PCB num0", new tgSphereInfo(PCB_1_Config));
    spec.addBuilder("PCB num1", new tgSphereInfo(PCB_1_Config));

    const double PCB2D = 95.0 / sphereVolume;
    const tgSphere::Config PCB_2_Config(radius, PCB2D, friction);
    spec.addBuilder("PCB num2", new tgSphereInfo(PCB_2_Config));

    // Two different string configs
    /// @todo acceleration constraint was removed on 12/10/14 Replace with tgKinematicActuator as appropreate
    tgSpringCableActuator::Config muscleConfig(229.16, 20, 2000.0, true, 5000, 7.0, 1.0, 1.0);
    tgSpringCableActuator::Config muscleConfig2(229.16, 20, 700.0, true, 5000, 7.0, 1.0, 1.0);
    spec.addBuilder("top muscle", new tgBasicActuatorInfo(muscleConfig));
    spec.addBuilder("left muscle", new tgBasicActuatorInfo(muscleConfig2));
    spec.addBuilder("right muscle", new tgBasicActuatorInfo(muscleConfig2));

    // Create your structureInfo
    tgStructureInfo structureInfo(snake, spec);

    // Use the structureInfo to build ourselves
    structureInfo.buildInto(*this, world);

    // We could now use tgCast::filter or similar to pull out the models (e.g. muscles)
    // that we want to control.
    m_allMuscles = this->find<tgSpringCableActuator> ("muscle");
    m_allSegments = this->find<tgModel> ("segment");
    mapMuscles(m_muscleMap, *this);

    addMarkers(snake, *this);

#if (0)
    trace(structureInfo, *this);
#endif

    // Actually setup the children
    BaseSpineModelLearning::setup(world);
}
/***************************************
 * The primary functions., called from other classes.
 **************************************/
void VerticalSpineModel::setup(tgWorld& world)
{
    // debugging output: edge and height length
    //std::cout << "edge: " << c.edge << "; height: " << c.height << std::endl;
    
    // Create the first fixed snake segment
    // @todo move these hard-coded parameters into config
    tgStructure tetraB;
    addNodes(tetraB, c.edge, c.height);
    addPairsB(tetraB);
    tetraB.move(btVector3(0.0, 2, 0));
    
    // Create our snake segments
    tgStructure snake;
    
    // add 1st child to snake
    tgStructure* const tB = new tgStructure(tetraB);
    snake.addChild(tB);
    tB->addTags(tgString("segment", 1));
    
    // Create the first non-fixed tetrahedra
    tgStructure tetra;
    addNodes(tetra, c.edge, c.height);
    addPairs(tetra);
    
    // Move the first tetrahedra
    // @todo move these hard-coded parameters into config
    tetra.move(btVector3(0.0, -6, 0));
    
    // add rest of segments using original tetra configuration
    addSegments(snake, tetra, c.edge, m_segments);
    
    addMuscles(snake);

    // Create the build spec that uses tags to turn the structure into a real model
    // Note: This needs to be high enough or things fly apart...
    
    // length of inner strut = 12.25 cm
    // m = 1 kg
    // volume of 1 rod = 9.62 cm^3
    // total volume = 38.48 cm^3
    //const double density = 1/38.48; = 0.026 // kg / length^3 - see app for length
    const tgRod::Config rodConfigA(c.radius, c.densityA, c.friction, 
				  c.rollFriction, c.restitution);
    const tgRod::Config rodConfigB(c.radius, c.densityB, c.friction, 
				  c.rollFriction, c.restitution);
    //holder
    const tgRod::Config rodConfigHA(0.1, c.densityA, c.friction,
				    c.rollFriction, c.restitution);
    const tgRod::Config rodConfigHB(0.1, c.densityB, c.friction,
				    c.rollFriction, c.restitution);
    tgBuildSpec spec;
    spec.addBuilder("rod", new tgRodInfo(rodConfigA));
    spec.addBuilder("rodB", new tgRodInfo(rodConfigB));


    // set muscle (string) parameters
    // @todo replace acceleration constraint with tgKinematicActuator if needed...
    tgSpringCableActuator::Config muscleConfig(c.stiffness, c.damping, c.pretension,
					 c.hist, c.maxTens, c.targetVelocity);
    spec.addBuilder("muscle", new tgBasicActuatorInfo(muscleConfig));

    
    // Create your structureInfo
    tgStructureInfo structureInfo(snake, spec);
    // Use the structureInfo to build ourselves
    structureInfo.buildInto(*this, world);

    // We could now use tgCast::filter or similar to pull out the models (e.g. muscles)
    // that we want to control.    
    allMuscles = tgCast::filter<tgModel, tgSpringCableActuator> (getDescendants());
    mapMuscles(muscleMap, *this, m_segments);

    //trace(structureInfo, *this);

    // Actually setup the children
    notifySetup();
    tgModel::setup(world);
}