From 341623412dbec7cb1eb136ab75c11918bb2b3d96 Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Tue, 9 Apr 2013 16:22:45 +0200 Subject: LocomotorPrimitives: Check success of simulation --- LocomotorPrimitives.cpp | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) (limited to 'LocomotorPrimitives.cpp') diff --git a/LocomotorPrimitives.cpp b/LocomotorPrimitives.cpp index 8ceafea..967513e 100644 --- a/LocomotorPrimitives.cpp +++ b/LocomotorPrimitives.cpp @@ -87,19 +87,19 @@ static void constructModel(OpenSim::Model &model, OpenSim::Storage actData) logger.log("Finished constructing model\n"); } -void simulateModel(OpenSim::Model &model, const double initial_time, - const double final_time, double fixed_step_size, - std::string output_dir) +int simulateModel(OpenSim::Model &model, const double initial_time, + const double final_time, double fixed_step_size, + std::string output_dir) { if (NO_SIM) { logger.log("Skipping simulation as per NO_SIM=%d\n", NO_SIM); - return; + return 1; } std::string cwd = OpenSim::IO::getCwd(); if (OpenSim::IO::chDir(output_dir) != 0) { logger.err("Failed to change to output directory %s", output_dir.c_str()); - return; + return 1; } logger.log("Simulating model %s\n", MODEL_NAME.c_str()); @@ -107,6 +107,13 @@ void simulateModel(OpenSim::Model &model, const double initial_time, logger.log("+ Initializing system\n"); SimTK::State &si = model.initSystem(); + if (!model.isValidSystem()) { + logger.err("Loaded invalid model. Press ENTER to quit"); + if (!yes) + std::cin.get(); + return 1; + } + // std::cout << "=== MODEL SUMMARY ===" << std::endl; // model.printDetailedInfo(si, std::cout); // std::cout << "=== END MODEL SUMMARY ===" << std::endl << std::endl; @@ -129,6 +136,7 @@ void simulateModel(OpenSim::Model &model, const double initial_time, manager->integrate(si); } catch (...) { logger.log("Got exception during integration\n"); + return 1; } // Save the model states from forward integration @@ -154,6 +162,8 @@ void simulateModel(OpenSim::Model &model, const double initial_time, // TODO logger.log("Finished simulating model\n"); + + return 0; } static void usage() @@ -222,7 +232,7 @@ int main(int argc, char **argv) saction.sa_flags = SA_RESTART; sigaction(SIGINT, &saction, NULL); - logger.log("Starting simulation %s with model file %s, actuation data file %s\n, fixed step size: %f\n", MODEL_NAME.c_str(), model_file.c_str(), data_file.c_str(), fixed_step_size); + logger.log("Starting simulation %s with model file %s, actuation data file %s, fixed step size: %f\n", MODEL_NAME.c_str(), model_file.c_str(), data_file.c_str(), fixed_step_size); try { // Create an OpenSim model and set its name @@ -232,7 +242,12 @@ int main(int argc, char **argv) osimModel.setUseVisualizer(false); constructModel(osimModel, actData); - simulateModel(osimModel, initial_time, final_time, fixed_step_size, output_dir); + if (simulateModel(osimModel, initial_time, final_time, fixed_step_size, output_dir)) { + logger.err("Something went wrong during simulation. Press ENTER to quit"); + if (!yes) + std::cin.get(); + return 1; + } } catch (OpenSim::Exception ex) { logger.err("Exception: %s. Press ENTER to quit", ex.getMessage()); if (!yes) -- cgit v1.2.3-54-g00ecf me='id' value='e70cf54073acb6494620620af2ab993d57ae8d3f'/>
context:
space:
mode:
authorChris Metcalf <cmetcalf@tilera.com>2012-09-24 14:57:58 -0400
committerChris Metcalf <cmetcalf@tilera.com>2012-09-24 15:11:53 -0400
commite70cf54073acb6494620620af2ab993d57ae8d3f (patch)
tree3d4bb0253ec7eeee40ad344bc9d2d701115e0109 /arch/tile/include/gxio
parent979570e02981d4a8fc20b3cc8fd651856c98ee9d (diff)
tile: gxio iorpc numbering change for TRIO interface
An ABI numbering change was made in the hypervisor for Tilera's 4.1 MDE release (just shipped). It's incompatible with the previous 4.0 release ABI numbering, so we track the new numbering going forward. We plan to avoid modifying ABI numbering for these interfaces again. Signed-off-by: Chris Metcalf <cmetcalf@tilera.com>
Diffstat (limited to 'arch/tile/include/gxio')