Skip to content
  • Home
  • About the Blog
  • About the Author
  • Sitemap

Abdur Rosyid's Blog

Just a few notes on mechanical engineering and robotics

ROS2 & ROS1 CLI Commands

July 8, 2021 by Abdur Rosyid

The following are some common ROS1 and ROS2 CLI commands: ROS1 ROS2 Function rosrun ros2 run Running a node rosnode ros2 node Information about node rostopic ros2 topic Command for ROS topic roslaunch ros2 launch Command to launch a launch file rosservice ros2 service Command for ROS servide rospack ros2 pkg Information about package

Creating Python Service in ROS2

July 8, 2021 by Abdur Rosyid

Step 1: Create the service (.srv) file, namely ServiceName.srv, inside an “srv” folder. Step 2: Modify setup.py. Step 3: Modify package.xml. Step 4: Write the service_server node in the package subfolder inside the package folder. There are two ways to write a service_server node in Python: 1) old-school approach, and 2) member-function approach. The following …

Continue Reading

Creating C++ Service in ROS2

July 8, 2021 by Abdur Rosyid

Step 1: Create the service (.srv) file, namely ServiceName.srv, inside an “srv” folder.

Step 2: Modify CMakeLists.txt.

Add the following:

find_package(builtin_interfaces REQUIRED)
find_package(rosidl_default_generators REQUIRED)

# and put below before ament_package():
rosidl_generate_interfaces(ros2_exercise_cpp
  "srv/ServiceName.srv"
  DEPENDENCIES builtin_interfaces
)
(more…)
Continue Reading

Writing Python Subscriber in ROS2

July 8, 2021 by Abdur Rosyid

There are three ways to to write a Python publisher in ROS2, namely:

  • Old-school approach
  • Object-oriented (member-function) approach
  • Local function (lambda) approach

Below is an example of each approach to write a Python node listening to “Hello World” stream. The code is taken from here: https://github.com/ros2/examples/tree/foxy/rclpy/topics/minimal_subscriber/examples_rclpy_minimal_subscriber

(more…)
Continue Reading

Writing Python Publisher in ROS2

July 8, 2021 by Abdur Rosyid

There are three ways to to write a Python publisher in ROS2, namely:

  • Old-school approach
  • Object-oriented (member-function) approach
  • Local function approach

Below is an example of each approach to write a Python node publishing “Hello World”. The code is taken from here: https://github.com/ros2/examples/tree/foxy/rclpy/topics/minimal_publisher/examples_rclpy_minimal_publisher

(more…)
Continue Reading

Writing C++ Subscriber in ROS2

July 8, 2021 by Abdur Rosyid

There are three ways to to write a C++ publisher in ROS2, namely:

  • Old-school approach
  • Object-oriented (member-function) approach
  • Local function (lambda) approach

Below is an example of each approach to write a C++ node listening to “Hello World” stream. The code is taken from here: https://github.com/ros2/examples/tree/foxy/rclcpp/topics/minimal_subscriber

(more…)
Continue Reading

Writing C++ Publisher in ROS2

July 8, 2021 by Abdur Rosyid

There are three ways to to write a C++ publisher in ROS2, namely:

  • Old-school approach
  • Object-oriented (member-function) approach
  • Local function (lambda) approach

Below is an example of each approach to write a C++ node publishing “Hello World”. The code is taken from here: https://github.com/ros2/examples/tree/foxy/rclcpp/topics/minimal_publisher

(more…)
Continue Reading

Creating Packages in ROS2

July 8, 2021 by Abdur Rosyid

Creating a C++ package

Step 1: Create the package using the following CLI command:

cd ~/ros2_ws/src
ros2 pkg create [PACKAGE_NAME] --build-type ament_cmake --dependencies rclcpp std_msgs [OTHER_DEPENDENCY_PACKAGES]

Step 2: Modify package.xml file for package dependencies of the created node(s).

Step 3: Modify CMakeLists.txt.

(more…)
Continue Reading

ROS2 vs ROS1 Packages

July 8, 2021 by Abdur Rosyid

ROS2 build system is colcon. In ROS1, the build system is catkin. What is the difference between ROS1 and ROS2 packages? In ROS1, you can mix C++ and Python nodes in a single package. In ROS2, as a standard practice, you either make a C++ package or a Python package. [Although as a non-standard practice, …

Continue Reading

ROS2 vs ROS1 Overlay Workspace

July 8, 2021 by Abdur Rosyid

In ROS1, the structure of an overlay workspace, called the catkin workspace, looks like this: workspace_folder: |–src |–CMakeLists.txt |–package_1_folder |– |–package_n_folder |–devel |–build |–install The catkin workspace is built by running “catkin_make” command. To rebuild a catkin workspace, simply delete all the folders inside the workspace but the “src” folder and subsequently run the “catkin_make” …

Continue Reading

Posts pagination

  • Previous
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • …
  • 13
  • Next

Categories

  • STEM 101
  • Robotics
  • Kinematics
  • Dynamics
  • Control
  • Robot Operating System (ROS)
  • Robot Operating System (ROS2)
  • Software Development
  • Mechanics of Materials
  • Finite Element Analysis
  • Fluid Mechanics
  • Thermodynamics

Recent Posts

  • Pull Request on Github
  • Basics of Git and Github
  • Conda vs Docker
  • A Conda Cheat Sheet
  • Installing NVIDIA GPU Driver on Ubuntu

Archives

  • June 2025
  • July 2021
  • June 2021
  • March 2021
  • September 2020
  • April 2020
  • January 2015
  • April 2014
  • March 2014
  • March 2012
  • February 2012
  • June 2011
  • March 2008
© 2026 Abdur Rosyid's Blog | WordPress Theme by Superbthemes