diff options
-rw-r--r-- | LocomotorPrimitives.cpp | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/LocomotorPrimitives.cpp b/LocomotorPrimitives.cpp index cf6ed91..b72199c 100644 --- a/LocomotorPrimitives.cpp +++ b/LocomotorPrimitives.cpp @@ -25,6 +25,8 @@ static const double INTEGRATOR_ACCURACY = 1.0e-3; static Logger &logger = Logger::getInstance(); static LocomotorPrimitivesManager *manager = NULL; +static bool yes = false; + static void signal_handler(int signr) { switch (signr) { @@ -46,7 +48,8 @@ static void constructModel(OpenSim::Model &model, OpenSim::Storage actData) control->setActuators(model.updActuators()); if (control->checkControls() != 0) { logger.err("Control data for some muscles in the model is missing. Press ENTER to continue, ^-C to quit."); - std::cin.get(); + if (!yes) + std::cin.get(); } model.addController(control); @@ -160,6 +163,7 @@ static void usage() << " -m FILE specify .osim to use as model" << std::endl << " -o DIR set output directory to DIR (default: current directory)" << std::endl << " -s N set fixed step size for integrator to N (default: dynamic)" << std::endl + << " -y don't prompt for any input on errors and finishing" << std::endl << " -h show this help and exit" << std::endl; } @@ -189,6 +193,9 @@ int main(int argc, char **argv) case 's': fixed_step_size = strtod(argv[++i], NULL); break; + case 'y': + yes = true; + break; case 'h': usage(); exit(0); @@ -228,20 +235,24 @@ int main(int argc, char **argv) simulateModel(osimModel, initial_time, final_time, fixed_step_size, output_dir); } catch (OpenSim::Exception ex) { logger.err("Exception: %s. Press ENTER to quit", ex.getMessage()); - std::cin.get(); + if (!yes) + std::cin.get(); return 1; } catch (std::exception ex) { logger.err("Exception: %s. Press ENTER to quit", ex.what()); - std::cin.get(); + if (!yes) + std::cin.get(); return 1; } catch (...) { logger.err("Unrecognized Exception. Press ENTER to quit"); - std::cin.get(); + if (!yes) + std::cin.get(); return 1; } logger.log("Total runtime = %fms\n", 1.e3 * (clock() - ts_start) / CLOCKS_PER_SEC); logger.log("Simulation %s completed successfully. Press ENTER to quit", MODEL_NAME.c_str()); - std::cin.get(); + if (!yes) + std::cin.get(); return 0; } |