This is a PDF export of the talk slides.
You can ﬁnd the original slides, incl. videos, here:
https://docs.google.com/presentation/d/16ZQMB
7OVc1fkPRG1K7rQIWCd5zYWTj1hTaeI2rAjZSo/edit?usp=sharing

Learning Robotics
Fundamentals withROS 2 and modernGazebo
Andreas Bihlmaier

The goal

Exploring robotics fundamentals - interactively
Hands-On Learning: Engage in practical,
hands-on experience with robotics
fundamentals through interactive simulation
tools.
Real-Time Visualization: Gain a deeper
understanding of concepts by visualizing
robot movements, sensor data, andalgorithms in real-time through interactive
plotting.
Risk-Free Experimentation: Mitigate risks
associated with hardware experimentation byutilizing simulation environments, allowing
learners to experiment freely without fear ofdamaging physical components.

Scenario Exploration: Simulate diverse
scenarios and challenges, providing learners
with a broad range of experiences that may
not be easily achievable in a physical setting.
Familiarity with Tools: Building familiarity
with ROS 2 and Gazebo during the learning
phase enables individuals to eﬃciently
contribute to ongoing projects or start newones.

The tools

Leveraging the ROS 2 and Gazebo ecosystem
ROS 2
●
●
●
●Gazebo (modern)rclpy Python client libraryros2 command line tools
rosbag2 recording & playback
PlotJuggler advanced plotting●Connectors:●

Not used in this talk○○RViz 3D visualization

Turtlesim simple
simulation●●●

URDF and SDF
ros_gzgz_ros2_control

●
●
●
●
●
●

gz-physics physics engines(Bullet, DART, TPE)
gz-rendering rendering (OGRE)
gz-sensors sensor simulation
gz-gui GUI
Many existing systems andexample worlds
Custom systems (plugins)
Fuel simulation models

Learning aboutmath

Exploring math concepts in a robotics context●●

The derivative of a function describes the“instantaneous rate of change” of thefunction.
The time derivative of position is velocity○●

The derivative of velocity is acceleration○●●∫a = v

The integral of velocity is position○●p’’ = v’ = a

Integrals can be seen as antiderivative.
The time integral of acceleration is velocity○●p’ = v∫∫a = ∫v = p

In code, derivatives and integrals areusually calculated numerically.

A more fun alternative to Python + matplotlib
There is nothing wrong withgetting a better understanding ofbasic calculus using Python, e.g.
numpy + matplotlib (in Jupyternotebooks).
One can get a sense for a constantacceleration resulting in linear
velocity change that in turn resultsin quadratic position change.
But it is much more interestingand interactive using Gazebo andPlotJuggler.

gz: Velocity v to Position x | PJ: x to v to aGazebo (gz) world with a simple mobile robot with
VelocityControl system and PosePublisher
system.
ros_gz_bridge publishes Twist from ROS toGazebo and Pose from Gazebo to ROS TFMessage.
ros2 topic pub sends Twist command.

PlotJuggler (PJ) subscribed to ROS TFMessage topic’s
translation.x with custom series for ﬁrst
derivative v and ﬁlter for second derivative a.

M1: A gentle twist

1/2

Unless lower level controllers can properly
handle discontinuities in commanded twist,
commands should be acceleration limited(even better also jerk limited).
The noise in velocity and acceleration is dueto (double) numerical diﬀerentiation.
v [m/s]Discontinuity in velocity v results
in “unlimited” acceleration a.
Also in “unlimited” jerk j = a’

Aside: It is easy to create
the world’s fastest robot- in simulation.

M1: A gentle twist

2/2

def timer_callback(self):
if self.state == self.State.ACCELERATE:
twist.linear.x = min(self.linear_velocity, self.prev_twist.linear.x + self.linear_acceleration * self.timer_period)
elif self.state == self.State.DECELERATE:
twist.linear.x = max(0.0, self.prev_twist.linear.x - self.linear_acceleration * self.timer_period)Learning about
physics

P1: Watch the ball drop in free fall
Paused “empty” world in Gazebo
with a sphere at z = 100 m.
PosePublisher system andros_gz_bridge as before.
ros2 bag record the topic.
Open bag ﬁle in PlotJuggler,conﬁgure plot(s) and explore datawith the time tracker.

P2: Inertia and the inclined plane
The 3D inertia tensor for a solid
sphere of radius r and mass m is

The inertia for a solid cylinder ofradius r, height h and mass m is

via List of moments of inertia

What happens when both rolldown an inclined plane?
Aside: The unit matrix is not a good default value for robot links.

Learning aboutrobot physics

R1: The grandfather pendulum
Aside: Inertia parameters in standard model are completely oﬀ.
I’m sure there are reasons for the default - but they are not simulation realism.

Modiﬁed double_pendulum_with_basewith ApplyJointForce,JointStatePublisher andPosePublisher systems.
Here the lower_joint has
been made a fixed joint.
Single pendulum here.
The joints have no friction or damping.
Perpetuum mobile!
PlotJugger visualizing the periodic joint
position and XY plotting the lower_link.

R2: Friction and damping<friction>: Static friction<damping>: Viscous damping

Independent of joint velocity.

Relative to joint velocity.

R3: Inertia dependent on joint positions → M(q)A heavily damped version of the double
pendulum with two revolute joints.
upper_joint as before, lower_joint
controlled via JointPositionController
system. Lower joint at position q2 = 0.
r1 = 0.5 m

m1 = 10 kg
α=0.566

r2 = 1.5 mm2 = 3 kg

τ = (r1 * m1 * sin(α)+ r2 * m2 * sin(α))*g≅ 50 Nm

1/2

Starting from bottom position, applying atorque of 50 Nm to the upper joint.
Settles at an upper joint position of 0.566 rad.

R3: Inertia dependent on joint positions → M(q)2/2Lower joint at position q2 = π.

Lower joint at position q2 = π/2.

Settles at an upper joint position of 0.9 rad.

Settles at an upper joint position of 0.49 rad.

r1 = r2 = 0.5 m

m1 = 10 kg
m2 = 3 kg
α=0.9τ = (r1 * m1 * sin(α)+ r2 * m2 * sin(α))*g≅ 50 Nm

In summary,seen from theupper joint, therobot inertia depends
on other joint positions
and the relationshipis non-linear:q2 = 0 → α = 0.566
q2 = π/2 → α = 0.49
q2 = π → α = 0.9

Learning aboutcontrol

Closing the loop on control
Thus far we have sent commands to Gazebo
to cause actions and observed the results.
Now we make use of data about the eﬀects toinﬂuence our actions.
Instead of combining already seen Gazebosystems, we use ros2_control, more
speciﬁcally gz_ros2_control.
Note: As a consequence, the following example
requires much more infrastructure.

C1: Robots or stable pendulums
The ur_simulation_ignition
package uses theign_ros2_control/IgnitionSystem(aka gz_ros2_control::GazeboSimROS2ControlPlugin)for joint control.

It acts as ros2_control HW interface.
Commanding positions, velocities oreﬀorts and providing actual values backto the (closed-loop) controller.

There is much more to explore
at the intersection of robotics
fundamentals, ROS 2 andGazebo … enjoy exploring it!

Thanks!
https://gazebosim.org/api/physics/7/physicsconcepts.html

https://github.com/
andreasBihlmaier/robotics_fundamentals_ros_gazebo

https://www.allisonthackston.com/articles/ignition-vs-gazebo.html