/** * The entry point. * @param[in] argc the number of command-line arguments * @param[in] argv argv[0] is the executable name; argv[1], if supplied, is the * suffix for the controller * @return 0 */ int main(int argc, char** argv) { std::cout << "AppTetraSpineHT" << std::endl; // First create the world const tgWorld::Config config(981); // gravity, cm/sec^2 ; #if (1) btVector3 eulerAngles = btVector3(0.0, 0.0, 0.0); btScalar friction = 0.5; btScalar restitution = 0.0; btVector3 size = btVector3(500.0, 1.5, 500.0); btVector3 origin = btVector3(0.0, 0.0, 0.0); size_t nx = 50; size_t ny = 50; double margin = 0.2; double triangleSize = 12; double waveHeight = 5.0; double offset = 0.0; tgHillyGround::Config groundConfig(eulerAngles, friction, restitution, size, origin, nx, ny, margin, triangleSize, waveHeight, offset); tgHillyGround* ground = new tgHillyGround(groundConfig); tgWorld world(config, ground); #else tgWorld world(config); #endif // Second create the view const double stepSize = 1.0/500.0; // Seconds const double renderRate = 1.0/60.0; // Seconds tgSimViewGraphics view(world, stepSize, renderRate); // Third create the simulation tgSimulation simulation(view); // Fourth create the models with their controllers and add the models to the // simulation const int segments = 6; TetraSpineCollisions* myModel = new TetraSpineCollisions(segments); colSpineSine* const myControl = new colSpineSine(); myModel->attach(myControl); /* tgCPGLogger* const myLogger = new tgCPGLogger("logs/CPGValues.txt"); myControl->attach(myLogger); */ // Add obstacles btVector3 wallOrigin(0.0, 0.0, 50.0); Wall* myWall = new Wall(wallOrigin); simulation.addModel(myModel); simulation.addModel(myWall); int i = 0; while (i < 1) { simulation.run(240000); //simulation.reset(); i++; } /// @todo Does the model assume ownership of the controller? /** No - a single controller could be attached to multiple subjects * However, having this here causes a segfault, since there is a call * to onTeardown() when the simulation is deleted */ #if (0) delete myControl; #endif //Teardown is handled by delete, so that should be automatic return 0; }
/** * The entry point. * @param[in] argc the number of command-line arguments * @param[in] argv argv[0] is the executable name; argv[1], if supplied, is the * suffix for the controller * @return 0 */ int main(int argc, char** argv) { std::cout << "AppFlemonsSpineContact" << std::endl; // First create the world const tgWorld::Config config(981); // gravity, cm/sec^2 #if (1) btVector3 eulerAngles = btVector3(0.0, 0.0, 0.0); btScalar friction = 0.5; btScalar restitution = 0.0; btVector3 size = btVector3(500.0, 0.5, 500.0); btVector3 origin = btVector3(0.0, 0.0, 0.0); size_t nx = 100; size_t ny = 100; double margin = 0.5; double triangleSize = 5.0; double waveHeight = 3.0; double offset = 0.0; tgHillyGround::Config groundConfig(eulerAngles, friction, restitution, size, origin, nx, ny, margin, triangleSize, waveHeight, offset); tgHillyGround* ground = new tgHillyGround(groundConfig); tgWorld world(config, ground); #else tgWorld world(config); #endif // Second create the view const double stepSize = 1.0/1000.0; // Seconds const double renderRate = 1.0/60.0; // Seconds tgSimView view(world, stepSize, renderRate); // Third create the simulation tgSimulation simulation(view); // Fourth create the models with their controllers and add the models to the // simulation const int segments = 6; FlemonsSpineModelContact* myModel = new FlemonsSpineModelContact(segments); /* Required for setting up learning file input/output. */ const std::string suffix((argc > 1) ? argv[1] : "default"); const int segmentSpan = 3; const int numMuscles = 8; const int numParams = 2; const int segNumber = 0; // For learning results const double controlTime = .01; const double lowPhase = -1 * M_PI; const double highPhase = M_PI; const double lowAmplitude = 0.0; const double highAmplitude = 300.0; const double kt = 0.0; const double kp = 1000.0; const double kv = 200.0; const bool def = true; // Overridden by def being true const double cl = 10.0; const double lf = 0.0; const double hf = 30.0; // Feedback parameters const double ffMin = -0.5; const double ffMax = 10.0; const double afMin = 0.0; const double afMax = 200.0; const double pfMin = -0.5; const double pfMax = 6.28; SpineFeedbackControl::Config control_config(segmentSpan, numMuscles, numMuscles, numParams, segNumber, controlTime, lowAmplitude, highAmplitude, lowPhase, highPhase, kt, kp, kv, def, cl, lf, hf, ffMin, ffMax, afMin, afMax, pfMin, pfMax ); SpineFeedbackControl* const myControl = new SpineFeedbackControl(control_config, suffix, "bmirletz/TetrahedralComplex_Contact/"); myModel->attach(myControl); simulation.addModel(myModel); int i = 0; while (i < 30000) { try { simulation.run(30000); simulation.reset(); i++; } catch (std::runtime_error e) { simulation.reset(); } } /// @todo Does the model assume ownership of the controller? /** No - a single controller could be attached to multiple subjects * However, having this here causes a segfault, since there is a call * to onTeardown() when the simulation is deleted */ #if (0) delete myControl; #endif //Teardown is handled by delete, so that should be automatic return 0; }