...
language | cpp |
---|
...
This code creates two cat models that can achieve a flipping maneuver. The first is simply two segments connected by a 2-degree-of-freedom
...
(no
...
twist)
...
joint.
...
It
...
exhibits
...
the
...
counter-rotation
...
mechanism
...
of
...
flipping.
...
The
...
second builds on top of the first with actuate-able
...
legs
...
, and a twist degree of freedom between the model's
...
two
...
halves.
...
This
...
model
...
exhibits
...
both the counter-rotation and variable-
...
inertia mechanisms of flipping.
Code Block | ||
---|---|---|
| ||
#include <OpenSim/OpenSim.h> int main(int argc, char *argv[]) { // First model: exhibiting the counter-rotation mechanism of flipping // ======================================================================== // PropertiesMass and // ------------------------------------------------------------------------ // Basicsgeometry properties // ------------------------------------------------------------------------ // Create the cat model. OpenSim::Model cat; // Name the cat after the founder of Stanford University. // This model will be able to hunch and wag (see the joints below). cat.setName("Leland_hunch_wag"); // 'Turn off' gravity so it's easier to watch an animation of the flip. using SimTK::Vec3; cat.setGravity(Vec3(0, 0, 0)); // Define anterior and posterior halves of the cat // ------------------------------------------------------------------------ // ********** PART A.1 ********** // Define joints between bodies (ground and two halves) // ------------------------------------------------------------------------ // ********** PART A.2 ********** // Add bodies to the model // ------------------------------------------------------------------------ // ********** PART A.3 ********** // Display geometry // ------------------------------------------------------------------------ // ********** PART A.4 ********** // Actuation // ------------------------------------------------------------------------ // ********** PART A.5 ********** // Print the model // ------------------------------------------------------------------------ cat.print("flippinfelines_hunch_wag.osim"); // Second model: adding legs for the variable-inertia mechanism of flipping // ======================================================================== return EXIT_SUCCESS; }; | ||
Code Block | ||
| ||
#include <OpenSim/OpenSim.h> /** * Creates two cat models for flipping. The first is simply two segments * connected by a 2-degree-of-freedom (no twist) joint. It exhibits the * counter-rotation mechanism of flipping. The second adds actuate-able * legs to the first model, as well as unlocking the twist degree of * freedom between the model's two halves. This model exhibits the variable- * inertia mechanism of flipping. * */ int main(int argc, char *argv[]) { // ********** PART B ********** return EXIT_SUCCESS; }; |
Code Block | ||
---|---|---|
| ||
// First model: exhibiting the counter-rotation mechanism of flipping // ======================================================================== // Properties // ------------------------------------------------------------------------ // Basics // ------------------------------------------------------------------------ // Create the cat model. OpenSim::Model cat; // Name the cat after the founder of Stanford University. // This model will be able to hunch and wag (see the joints below). cat.setName("Leland_hunch_wag"); // 'Turn off' gravity so it's easier to watch an animation of the flip. using SimTK::Vec3; cat.setGravity(Vec3(0, 0, 0)); // Define anterior and posterior halves of the cat // ------------------------------------------------------------------------ // Define joints between bodies (ground and two halves) // ------------------------------------------------------------------------ // Add bodies to the model // ------------------------------------------------------------------------ // Display geometry // ------------------------------------------------------------------------ // Actuation // ------------------------------------------------------------------------ // Print the model // ------------------------------------------------------------------------ ********** PART A ********** // Second model: adding legs for the variable-inertia mechanism of flipping // ======================================================================== // Leg properties // ------------------------------------------------------------------------ // Define leg bodies // ------------------------------------------------------------------------ // Define leg joints (i.e., between legs and two halves of cat) // ------------------------------------------------------------------------ // Add bodies to the model // ------------------------------------------------------------------------ // ...now that we have connected the bodies via joints. // Display goemetry geometry // ------------------------------------------------------------------------ // Actuation // ------------------------------------------------------------------------ // Enforce joint limits on the legs // ------------------------------------------------------------------------ // Print the model // ------------------------------------------------------------------------ return EXIT_SUCCESS; }; |