Skip to content

Commit 4877fc4

Browse files
committed
add comments to pendulum.py example #212
1 parent b875398 commit 4877fc4

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

src/docs/include/macros.py

+1-1
Large diffs are not rendered by default.

src/examples/pendulum.cpp

+5-2
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,21 @@ int main()
1414
ctrl << 0.0;
1515
// @SIMPLE_CONTROL@
1616
auto controller1 = std::make_shared<robot_dart::control::SimpleControl>(ctrl);
17+
// add the controller to the robot, with a default weight of 1.0
1718
robot->add_controller(controller1);
1819
// @SIMPLE_CONTROL_END@
1920
ctrl << -1.0;
2021
auto controller2 = std::make_shared<robot_dart::control::SimpleControl>(ctrl);
22+
// add the controller to the robot, with a weight of 5.0
2123
robot->add_controller(controller2, 5.);
2224

25+
// initialize the simulation with a default timestep of 0.015s
2326
robot_dart::RobotDARTSimu simu;
2427
#ifdef GRAPHIC
2528
simu.set_graphics(std::make_shared<robot_dart::gui::magnum::Graphics>());
2629
#endif
2730
simu.add_robot(robot);
28-
31+
// the the dimensions of the pendulum to calculate the end effector position
2932
Eigen::Vector3d size(0.0402, 0.05, 1);
3033
std::cout << (robot->body_pose("pendulum_link_1") * size).transpose() << std::endl;
3134
simu.run(2.5);
@@ -34,7 +37,7 @@ int main()
3437
controller1->set_parameters(ctrl);
3538
simu.run(2.5);
3639
std::cout << (robot->body_pose("pendulum_link_1") * size).transpose() << std::endl;
37-
40+
// reset the positions, velocities, and accelerations of the robot, clear internal and external forces, and also commands
3841
robot.reset();
3942
return 0;
4043
}

src/examples/python/pendulum.py

+5
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,20 @@
1010
ctrl = [0.0]
1111
# @SIMPLE_CONTROL_PYTHON@
1212
controller1 = rd.SimpleControl(ctrl)
13+
# add the controller to the robot, with a default weight of 1.0
1314
robot.add_controller(controller1)
1415
# @SIMPLE_CONTROL_PYTHON_END@
1516
ctrl = [-1.0]
1617
controller2 = rd.SimpleControl(ctrl)
18+
# add the controller to the robot, with a weight of 5.0
1719
robot.add_controller(controller2, 5.)
20+
# initialize the simulation with a default timestep of 0.015s
1821
simu = rd.RobotDARTSimu()
1922

2023
simu.set_graphics(rd.gui.Graphics())
2124

2225
simu.add_robot(robot)
26+
# the dimensions of the pendulum to calculate the end effector position
2327
size = [0.0402, 0.05, 1]
2428
print((robot.body_pose("pendulum_link_1").multiply(size)).transpose())
2529
simu.run(2.5)
@@ -29,4 +33,5 @@
2933
simu.run(2.5)
3034
print((robot.body_pose("pendulum_link_1").multiply(size)).transpose())
3135

36+
# reset the positions, velocities, and accelerations of the robot, clear internal and external forces, and also commands
3237
robot.reset()

0 commit comments

Comments
 (0)