/** * 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 tgWorld world(config); // 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 = 3; TetraSpineStaticModel_hf* myModel = new TetraSpineStaticModel_hf(segments); htSpineSine* const myControl = new htSpineSine(); myModel->attach(myControl); /* tgCPGLogger* const myLogger = new tgCPGLogger("logs/CPGValues.txt"); myControl->attach(myLogger); */ simulation.addModel(myModel); int i = 0; while (i < 1) { simulation.run(60000); //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 << "AppTetraSpineHardwareLearning" << std::endl; // First create the world const tgWorld::Config config(981); // gravity, cm/sec^2 tgWorld world(config); // 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 = 3; TetraSpineStaticModel_hf* myModel = new TetraSpineStaticModel_hf(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 = 6; const int numParams = 2; const int segment = 1; const double controlTime = .001; BaseSpineCPGControl::Config control_config(segmentSpan, numMuscles, numMuscles, numParams, segment, controlTime); LearningSpineJSON* const myControl = new LearningSpineJSON(control_config, suffix); myModel->attach(myControl); tgCPGLogger* const myLogger = new tgCPGLogger("logs/CPGValues.txt"); myControl->attach(myLogger); simulation.addModel(myModel); int i = 0; while (i < 1) { simulation.run(60000); 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; }