...
Code Block | ||||
---|---|---|---|---|
| ||||
void constructProperties() { constructProperty_results_directory("results"); constructProperty_model_filename("flippinfelines_*FILL THIS IN*.osim"); constructProperty_num_optim_spline_points(20); constructProperty_anterior_legs_down_weight(1.0); constructProperty_posterior_legs_down_weight(1.0); constructProperty_sagittal_symmetry_weight(1.0); constructProperty_use_coordinate_limit_forces(true); constructProperty_initial_parameters_filename(""); } |
A sample
...
input file
Below is what the XML serialization of this class looks like. This is exactly what we meant by the optimizer_setup_file.xml
above. This is a simplified version of what's generated by the executable optimize_input_template, which is generated from optimize_input_template.cpp. We've given you this file, but we do not discuss it in this tutorial.
...
Code Block | ||||
---|---|---|---|---|
| ||||
/** * Finds a control input history that achieves certain desired features * of a cat's flipping maneuver, as determined by the objective function. * The control of the system is performed via a PrescribedController that * uses a spline for all actuators. * * Parameters are ordered by actuator, then by spline point index for a * given actuator. Parameters are nondimensionalized by the min or max * control values for the associated actuator. * */ class FlippinFelinesOptimizerSystem : public SimTK::OptimizerSystem { public: FlippinFelinesOptimizerSystem(OpenSim::FlippinFelinesOptimizerTool & tool) : _tool(tool), _duration(1.0), _objectiveCalls(0), _objectiveFcnValueBestYet(SimTK::Infinity), { // Parse inputs & prepare output // -------------------------------------------------------------------- // ********** PART C.1 ********** // Add a controller to the model to control theits actuators it has // -------------------------------------------------------------------- // ********** PART C.2 ********** // Set parameter limits/bounds for the optimization. // -------------------------------------------------------------------- // ********** PART C.3 ********** } SimTK::Vector initialParameters() { // ********** PART C.4 ********** } /** * Defines desired features for the cat model's flip. Each call to this * function updates the model's control, runs a forward dynamic simulation * with this control, computes the objective value resulting from the * simulation, and saves the results to output. * */ int objectiveFunc(const SimTK::Vector & parameters, bool new_parameters, SimTK::Real & f) const { // ... // Unpack parameters into the model (i.e., update spline points) // -------------------------------------------------------------------- // ********** PART C.5 ********** // Run a forward dynamicsdynamic simulation // -------------------------------------------------------------------- // ********** PART C.6 ********** // Construct the objective function, term by term // -------------------------------------------------------------------- // ********** PART C.7 ********** // Update the log and outputs with the objective function value // -------------------------------------------------------------------- // ********** PART C.8 ********** } // Miscellaneous functions (used, but uninteresting) // ------------------------------------------------------------------------ // ********** PART C.10 ********** private: // Objective function terms // ------------------------------------------------------------------------ // ********** PART C.7 ********** // Member variables // ------------------------------------------------------------------------ // ********** PART C.9 ********** }; |
TODO why you would look at the member variables section.
C.1
...
: Parse inputs and prepare output
C.2: Add a controller to the model to control its actuators
C.3: Set parameter limits/bounds for the optimization
C.4: Initial parameters
C.5: Unpack parameters into the model
C.6: Run a forward dynamic simulation
TODO MUTABLES
TODO talk about controls
TODO talk about how the parameters work.
...