Real Time in ROS2 – Intro

ROS2 Pendulum Real Time Demo

Written by Bayode Aderinola

25/11/2021

In this post, we will see how to implement Real Time in ROS2, using the ROS2 Pendulum Real Time demo.

Step 1: Grab a copy of the ROS Project containing the code

Click here to get your own copy of the project (PS: If you don’t have an account on the ROS Development Studio, you would need to create one. Once you create an account or log in, we will copy the project to your workspace).

Run ROS project

That done, open the project using the Run button. This might take a few moments, please be patient.

You should now see a notebook with detailed instructions. This post includes a summary of these instructions and some other tips.

Step 2: Start the Simulation

Start a web shell

Start a web shell from the bottom bar of the screen as shown above and run the following command:

cd ~/ros2_ws
source install/local_setup.bash
ros2 launch pendulum_bringup pendulum_bringup.launch.py rviz:=True

See the robot by clicking on the Graphical Tools icon on the bottom bar:

Open Graphical Tools

You should now see something like this (if you cannot see it, please ensure the ros2 launch command is still running and restart it if necessary):

ROS2 Pendulum

You might need to drag the window into focus and then maximize it.

Create new web shell

Move the robot by executing the following in a new terminal:

ros2 topic pub -1 /teleop pendulum2_msgs/msg/PendulumTeleop "cart_position: 5.0"

If you want to run the simulation on your local PC, then you need to run the commands given in the Setup section.

Step 3: Explore the source code using the IDE

Open Code Editor

Open the IDE by clicking on the icon as shown above. You should now see something similar to the image below:

View source code in the IDE

All the files used in the simulation are in the ros2_ws/src directory. Explore the files. Double-click to open a file in the editor. You will refer back to some of the files later on.

Step 4: Watch the video to understand how the simulation implemented Real Time in ROS2 with the Pendulum

Here you go:

Step 5: Consolidate your learning

  • Do you understand how to implement Real Time in ROS2 after watching the video? If not, have you gone over the video again?
  • Can you try to implement the simulation on your local PC?

Related Resources

Feedback

Did you like this post? Do you have any questions about the explanations? Whatever the case, please leave a comment on the comments section below, so we can interact and learn from each other.

If you want to learn about other ROS2 topics, please let us know in the comments area and we will do a video or post about it.

Check Out These Related Posts

0 Comments

Pin It on Pinterest

Share This