MCPcopy Create free account
hub / github.com/dartsim/dart / main

Function main

tutorials/tutorial_multi_pendulum_finished/main.cpp:413–456  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

411}
412
413int main(int argc, char* argv[])
414{
415 // Create an empty Skeleton with the name "pendulum"
416 SkeletonPtr pendulum = Skeleton::create("pendulum");
417
418 // Add each body to the last BodyNode in the pendulum
419 BodyNode* bn = makeRootBody(pendulum, "body1");
420 bn = addBody(pendulum, bn, "body2");
421 bn = addBody(pendulum, bn, "body3");
422 bn = addBody(pendulum, bn, "body4");
423 bn = addBody(pendulum, bn, "body5");
424
425 // Set the initial position of the first DegreeOfFreedom so that the pendulum
426 // starts to swing right away
427 pendulum->getDof(1)->setPosition(dart::math::toRadian(120.0));
428
429 // Create a world and add the pendulum to the world
430 WorldPtr world = World::create();
431 world->addSkeleton(pendulum);
432
433 // Create a window for rendering the world and handling user input
434 MyWindow window(world);
435
436 // Print instructions
437 std::cout << "space bar: simulation on/off" << std::endl;
438 std::cout << "'p': replay simulation" << std::endl;
439 std::cout << "'1' -> '9': apply torque to a pendulum body" << std::endl;
440 std::cout << "'-': Change sign of applied joint torques" << std::endl;
441 std::cout << "'q': Increase joint rest positions" << std::endl;
442 std::cout << "'a': Decrease joint rest positions" << std::endl;
443 std::cout << "'w': Increase joint spring stiffness" << std::endl;
444 std::cout << "'s': Decrease joint spring stiffness" << std::endl;
445 std::cout << "'e': Increase joint damping" << std::endl;
446 std::cout << "'d': Decrease joint damping" << std::endl;
447 std::cout << "'r': add/remove constraint on the end of the chain"
448 << std::endl;
449 std::cout << "'f': switch between applying joint torques and body forces"
450 << std::endl;
451
452 // Initialize glut, initialize the window, and begin the glut event loop
453 glutInit(&argc, argv);
454 window.initWindow(640, 480, "Multi-Pendulum Tutorial");
455 glutMainLoop();
456}

Callers

nothing calls this directly

Calls 7

toRadianFunction · 0.85
makeRootBodyFunction · 0.70
addBodyFunction · 0.70
setPositionMethod · 0.45
getDofMethod · 0.45
addSkeletonMethod · 0.45
initWindowMethod · 0.45

Tested by

no test coverage detected