GraphicUI::GraphicUI(GraphicPresentation* Gui_presentation) { this->Gui_presentation = Gui_presentation; createActions(); createMenus(); createToolBars(); createGraphicsView(); //this->setWindowState(this->windowState() ^ Qt::WindowFullScreen); this->resize(LENGTH, WIDTH); this->setWindowTitle(WINDOWS_TITLE); setUnifiedTitleAndToolBarOnMac(true); }
bool AppTSGoal::setup() { // First create the world const double scale = 100; world = createWorld(); // Second create the view if (use_graphics) view = createGraphicsView(world); // For visual experimenting on one tensegrity else view = createView(world); // For running multiple episodes // Third create the simulation simulation = new tgSimulation(*view); // Fourth create the models with their controllers and add the models to the // simulation /// @todo add position and angle to configuration TetraSpineGoal* myModel = new TetraSpineGoal(nSegments, 0.0, scale); // Fifth create the controllers, attach to model if (add_controller) { const int segmentSpan = 3; const int numMuscles = 6; const int numParams = 2; const int segNumber = 5; // 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; const double tensionFeedback = 1000.0; #if (0) // Switch for .nnw or JSON based methods JSONGoalControl::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, tensionFeedback ); /// @todo fix memory leak that occurs here JSONGoalControl* const myControl = new JSONGoalControl(control_config, suffix, "bmirletz/Tetra_Goal/"); #else JSONFeedbackControl::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); /// @todo fix memory leak that occurs here JSONFeedbackControl * const myControl = new JSONFeedbackControl(control_config, suffix, "bmirletz/Tetra_Goal/"); #endif myModel->attach(myControl); } // Sixth add model & controller to simulation simulation->addModel(myModel); if (add_blocks) { tgModel* blockField = getBlocks(); simulation->addObstacle(blockField); } bSetup = true; return bSetup; }
bool AppGoalTension::setup() { // First create the world world = createWorld(); // Second create the view if (use_graphics) view = createGraphicsView(world); // For visual experimenting on one tensegrity else view = createView(world); // For running multiple episodes // Third create the simulation simulation = new tgSimulation(*view); // Fourth create the models with their controllers and add the models to the // simulation #if (0) startAngle = ((rand() / (double)RAND_MAX) - 0.5) * 3.1415; #endif FlemonsSpineModelGoal* myModel = new FlemonsSpineModelGoal(nSegments, goalAngle, startAngle); // Fifth create the controllers, attach to model if (add_controller) { Json::Value root; // will contains the root value after parsing. Json::Reader reader; std::string resourcePath = "bmirletz/TC_Tension/"; std::string controlFilePath = FileHelpers::getResourcePath(resourcePath); std::string controlFilename = controlFilePath + suffix; bool parsingSuccessful = reader.parse( FileHelpers::getFileString(controlFilename.c_str()), root ); if ( !parsingSuccessful ) { // report to the user the failure and their locations in the document. std::cout << "Failed to parse configuration\n" << reader.getFormattedErrorMessages(); throw std::invalid_argument("Bad filename for JSON"); } // Get the value of the member of root named 'encoding', return 'UTF-8' if there is no // such member. Json::Value impedenceVals = root.get("impedenceVals", "UTF-8"); impedenceVals = impedenceVals.get("params", "UTF-8"); // Keep drilling if necessary if (impedenceVals[0].isArray()) { impedenceVals = impedenceVals[0]; } const double impedanceMax = 2000.0; const int segmentSpan = 3; const int numMuscles = 8; const int numParams = 2; const int segNumber = 5; // 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; // JSONCPP's .get really wants this to be typed... int j = 0; const double kt = impedanceMax * (impedenceVals.get(j, 0.0)).asDouble(); const double kp = impedanceMax * (impedenceVals.get(1, 0.0)).asDouble(); const double kv = impedanceMax * (impedenceVals.get(2, 0.0)).asDouble(); 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 = -10.0; const double ffMax = 10.0; const double afMin = 0.0; const double afMax = 200.0; const double pfMin = 0.0; const double pfMax = 0.0; const double tensionFeedback = impedanceMax *(impedenceVals.get(3, 0.0)).asDouble(); JSONGoalControl::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, tensionFeedback ); /// @todo fix memory leak that occurs here JSONGoalTension* const myControl = new JSONGoalTension(control_config, suffix, resourcePath); myModel->attach(myControl); } // Sixth add model & controller to simulation simulation->addModel(myModel); if (add_blocks) { tgModel* blockField = getBlocks(); simulation->addObstacle(blockField); } bSetup = true; return bSetup; }
bool AppQuadControl::setup() { // First create the world world = createWorld(); // Second create the view if (use_graphics) view = createGraphicsView(world); // For visual experimenting on one tensegrity else view = createView(world); // For running multiple episodes // Third create the simulation simulation = new tgSimulation(*view); // Fourth create the models with their controllers and add the models to the // simulation /// @todo add position and angle to configuration //FlemonsSpineModelContact* myModel = //new FlemonsSpineModelContact(nSegments); //Parameters for the structure: const int segments = 7; const int hips = 4; const int legs = 4; const int feet = 4; BigPuppySymmetric* myModel = new BigPuppySymmetric(segments, hips, legs, feet); // Fifth create the controllers, attach to model if (add_controller) { const int segmentSpan = 3; //Not sure what this will be for mine! const int numMuscles = 8; //This may be ok, but confirm. 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; //May need to retune kt, kp, and kv 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... may need to retune 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; const double maxH = 60.0; const double minH = 1.0; JSONQuadFeedbackControl::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, maxH, minH); /// @todo fix memory leak that occurs here JSONQuadFeedbackControl* const myControl = new JSONQuadFeedbackControl(control_config, suffix, lowerPath); #if (0) tgCPGJSONLogger* const myLogger = new tgCPGJSONLogger("logs/CPGValues.txt"); myControl->attach(myLogger); #endif myModel->attach(myControl); } // Sixth add model & controller to simulation simulation->addModel(myModel); if (add_blocks) { tgModel* blockField = getBlocks(); simulation->addObstacle(blockField); } bSetup = true; return bSetup; }
bool AppMultiTerrain_OC::setup() { // First create the world world = createWorld(); // Second create the view if (use_graphics) view = createGraphicsView(world); // For visual experimenting on one tensegrity else view = createView(world); // For running multiple episodes // Third create the simulation simulation = new tgSimulation(*view); // Fourth create the models with their controllers and add the models to the // simulation // TODO properly add this to the header info and learning apparatus double goalAngle = -M_PI / 2.0; /// @todo add position and angle to configuration OctahedralComplex* myModel = new OctahedralComplex(nSegments, goalAngle); // Fifth create the controllers, attach to model if (add_controller) { const int segmentSpan = 3; const int numMuscles = 4; 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 = 210.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; const double tensionFeedback = 1000.0; #if (1) JSONGoalControl::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, tensionFeedback ); /// @todo fix memory leak that occurs here OctahedralGoalControl* const myControl = new OctahedralGoalControl(control_config, suffix, "bmirletz/OctaCL_6/"); #else 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/OctaCL_6/"); #endif myModel->attach(myControl); } // Sixth add model & controller to simulation simulation->addModel(myModel); if (add_blocks) { tgModel* blockField = getBlocks(); simulation->addObstacle(blockField); } bSetup = true; return bSetup; }
bool AppGoalOnline::setup() { // First create the world world = createWorld(); // Second create the view if (use_graphics) view = createGraphicsView(world); // For visual experimenting on one tensegrity else view = createView(world); // For running multiple episodes // Third create the simulation simulation = new tgSimulation(*view); // Fourth create the models with their controllers and add the models to the // simulation /// @todo add position and angle to configuration /// @todo Generalize angle code FlemonsSpineModelGoal* myModel = new FlemonsSpineModelGoal(nSegments, 0.0); // Fifth create the controllers, attach to model if (add_controller) { 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; const double tensionFeedback = 1000.0; // How often to check/change the controller during online learning const double feedbackTime = 3.0; SpineOnlineControl::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, tensionFeedback, feedbackTime ); /// @todo fix memory leak that occurs here SpineOnlineControl* const myControl = new SpineOnlineControl(control_config, suffix, "bmirletz/TetrahedralComplex_Online/"); myModel->attach(myControl); } // Sixth add model & controller to simulation simulation->addModel(myModel); if (add_blocks) { tgModel* blockField = getBlocks(); simulation->addObstacle(blockField); } bSetup = true; return bSetup; }