-
Notifications
You must be signed in to change notification settings - Fork 2
/
dynhop.cpp
61 lines (47 loc) · 1.89 KB
/
dynhop.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <OpenSim/OpenSim.h>
using namespace OpenSim;
using namespace SimTK;
int main()
{
Model model("dynhop.osim");
model.setUseVisualizer(true);
auto* forces = new ForceReporter();
forces->setName("forces");
model.addAnalysis(forces);
auto* pelviskin = new PointKinematics(&model);
pelviskin->setName("pelviskin");
pelviskin->setBodyPoint("Pelvis", Vec3(0));
pelviskin->setPointName("pelvis");
model.addAnalysis(pelviskin);
auto* kneekin = new PointKinematics(&model);
kneekin->setName("kneekin");
kneekin->setBodyPoint("LeftThigh", Vec3(0, -0.25, 0));
kneekin->setPointName("knee");
model.addAnalysis(kneekin);
auto* footkin = new PointKinematics(&model);
footkin->setName("footkin");
footkin->setBodyPoint("LeftShank", Vec3(0, -0.25, 0));
footkin->setPointName("foot");
model.addAnalysis(footkin);
auto* kin = new Kinematics();
kin->setName("kinematics");
model.addAnalysis(kin);
SimTK::State state = model.initSystem();
model.updMatterSubsystem().setShowDefaultGeometry(true);
auto& viz = model.updVisualizer().updSimbodyVisualizer();
viz.setMode(Visualizer::RealTime);
viz.setRealTimeScale(0.2);
RungeKuttaMersonIntegrator integrator(model.getMultibodySystem());
integrator.setAccuracy(1e-6);
Manager manager(model, integrator);
manager.setInitialTime(0); manager.setFinalTime(1.0);
manager.integrate(state);
manager.getStateStorage().print("dynhop_states.sto");
model.updAnalysisSet().get("forces").printResults("dynhop");
model.updAnalysisSet().get("pelviskin").printResults("dynhop");
model.updAnalysisSet().get("kneekin").printResults("dynhop");
model.updAnalysisSet().get("footkin").printResults("dynhop");
model.updAnalysisSet().get("kinematics").printResults("dynhop");
model.updForceSet().setSize(0);
model.print("dynhop_no_forces.osim");
}