| 345 | } |
| 346 | |
| 347 | int main(int argc, char* argv[]) |
| 348 | { |
| 349 | // Create an empty Skeleton with the name "pendulum" |
| 350 | SkeletonPtr pendulum = Skeleton::create("pendulum"); |
| 351 | |
| 352 | // Add each body to the last BodyNode in the pendulum |
| 353 | BodyNode* bn = makeRootBody(pendulum, "body1"); |
| 354 | bn = addBody(pendulum, bn, "body2"); |
| 355 | bn = addBody(pendulum, bn, "body3"); |
| 356 | bn = addBody(pendulum, bn, "body4"); |
| 357 | bn = addBody(pendulum, bn, "body5"); |
| 358 | |
| 359 | // Set the initial position of the first DegreeOfFreedom so that the pendulum |
| 360 | // starts to swing right away |
| 361 | pendulum->getDof(1)->setPosition(dart::math::toRadian(120.0)); |
| 362 | |
| 363 | // Create a world and add the pendulum to the world |
| 364 | WorldPtr world = World::create(); |
| 365 | world->addSkeleton(pendulum); |
| 366 | |
| 367 | // Create a window for rendering the world and handling user input |
| 368 | MyWindow window(world); |
| 369 | |
| 370 | // Print instructions |
| 371 | std::cout << "space bar: simulation on/off" << std::endl; |
| 372 | std::cout << "'p': replay simulation" << std::endl; |
| 373 | std::cout << "'1' -> '9': apply torque to a pendulum body" << std::endl; |
| 374 | std::cout << "'-': Change sign of applied joint torques" << std::endl; |
| 375 | std::cout << "'q': Increase joint rest positions" << std::endl; |
| 376 | std::cout << "'a': Decrease joint rest positions" << std::endl; |
| 377 | std::cout << "'w': Increase joint spring stiffness" << std::endl; |
| 378 | std::cout << "'s': Decrease joint spring stiffness" << std::endl; |
| 379 | std::cout << "'e': Increase joint damping" << std::endl; |
| 380 | std::cout << "'d': Decrease joint damping" << std::endl; |
| 381 | std::cout << "'r': add/remove constraint on the end of the chain" |
| 382 | << std::endl; |
| 383 | std::cout << "'f': switch between applying joint torques and body forces" |
| 384 | << std::endl; |
| 385 | |
| 386 | // Initialize glut, initialize the window, and begin the glut event loop |
| 387 | glutInit(&argc, argv); |
| 388 | window.initWindow(640, 480, "Multi-Pendulum Tutorial"); |
| 389 | glutMainLoop(); |
| 390 | } |
nothing calls this directly
no test coverage detected