Debian Codegraph @

examples/deprecated_examples/glut_hybrid_dynamics/Main.cpp

raw symbols SCIP
1 /*
2 * Copyright (c) 2011-2022, The DART development contributors
3 * All rights reserved.
4 *
5 * The list of contributors can be found at:
6 * https://github.com/dartsim/dart/blob/master/LICENSE
7 *
8 * This file is provided under the following "BSD-style" License:
9 * Redistribution and use in source and binary forms, with or
10 * without modification, are permitted provided that the following
11 * conditions are met:
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * * Redistributions in binary form must reproduce the above
15 * copyright notice, this list of conditions and the following
16 * disclaimer in the documentation and/or other materials provided
17 * with the distribution.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
19 * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
20 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
26 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
27 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
29 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 */
32
33 #include <iostream>
34
35 #include <dart/dart.hpp>
36 #include <dart/utils/utils.hpp>
37
38 #include "MyWindow.hpp"
39
40 int main(int argc, char* argv[])
41 {
42 // create and initialize the world
43 dart::simulation::WorldPtr myWorld
44 = dart::utils::SkelParser::readWorld("dart://sample/skel/fullbody1.skel");
45 assert(myWorld != nullptr);
46 Eigen::Vector3d gravity(0.0, -9.81, 0.0);
47 myWorld->setGravity(gravity);
48
49 dart::dynamics::SkeletonPtr skel = myWorld->getSkeleton(1);
50
51 std::vector<std::size_t> genCoordIds;
52 genCoordIds.push_back(1);
53 genCoordIds.push_back(6); // left hip
54 genCoordIds.push_back(9); // left knee
55 genCoordIds.push_back(10); // left ankle
56 genCoordIds.push_back(13); // right hip
57 genCoordIds.push_back(16); // right knee
58 genCoordIds.push_back(17); // right ankle
59 genCoordIds.push_back(21); // lower back
60 Eigen::VectorXd initConfig(8);
61 initConfig << -0.2, 0.15, -0.4, 0.25, 0.15, -0.4, 0.25, 0.0;
62 skel->setPositions(genCoordIds, initConfig);
63
64 dart::dynamics::Joint* joint0 = skel->getJoint(0);
65 joint0->setActuatorType(dart::dynamics::Joint::PASSIVE);
66 for (std::size_t i = 1; i < skel->getNumBodyNodes(); ++i)
67 {
68 dart::dynamics::Joint* joint = skel->getJoint(i);
69 joint->setActuatorType(dart::dynamics::Joint::VELOCITY);
70 }
71
72 // create a window and link it to the world
73 MyWindow window;
74 window.setWorld(myWorld);
75
76 std::cout << "space bar: simulation on/off" << std::endl;
77 std::cout << "'p': playback/stop" << std::endl;
78 std::cout << "'[' and ']': play one frame backward and forward" << std::endl;
79 std::cout << "'v': visualization on/off" << std::endl;
80 std::cout << "'1'--'4': programmed interaction" << std::endl;
81 std::cout << "'h': harness on/off" << std::endl;
82
83 glutInit(&argc, argv);
84 window.initWindow(640, 480, "Hybrid Dynamics");
85 glutMainLoop();
86
87 return 0;
88 }