Trying Out ROS2 Part 1 (Environment Setup on Windows)

Info

This article is translated from Japanese to English.

https://404background.com/program/ros2-setup-1/

Introduction

In this post, I will be setting up the ROS2 environment. I have tried this several times in the past and ended up giving up, but this time I am determined to get it running properly.

At a recent ROS Japan UG (User Group) meeting I attended, I heard that migrating from ROS1 to ROS2 is quite a challenge. Apparently, it is much smoother to just start fresh with ROS2. So, I will begin my journey directly with ROS2.

▼I participated in this event:

https://rosjp.connpass.com/event/304753/

While several books on ROS2 have been published, the environment setup methods described in them can sometimes be outdated. This time, I will be building the environment by following the official documentation strictly.

Building the Environment

It appears that only Windows 10 is supported.

▼Official Documentation:

https://docs.ros.org/en/iron/Installation/Windows-Install-Binary.html

▼Initially, I accidentally read the older documentation. This version is no longer officially supported, though it often appears first in search results.

https://docs.ros.org/en/dashing/Installation/Windows-Install-Binary.html#

Installing Chocolatey

▼Installation instructions:

https://chocolatey.org/install#individual

There is a command to be executed in PowerShell.
▼The command:

▼When I ran it, I received the following error:

There was already a Chocolatey folder at C:\ProgramData\chocolatey. I deleted it once and ran the command again.

▼Then, I encountered this error:

It seems it cannot be executed without Administrative privileges. I was running it in the VS Code terminal PowerShell, so I restarted PowerShell as an Administrator.

▼You can select this by right-clicking Windows PowerShell in the Start menu.

I continued executing the following commands with Administrative privileges. I installed Python and the Visual C++ Redistributables.

Installing OpenSSL

▼Download link:

https://slproweb.com/products/Win32OpenSSL.html

I downloaded the Win64 OpenSSL v3.2.1 EXE file. Upon execution, it seemed a folder already existed for this as well. I reinstalled it.
▼Set the environment variable using setx:

Installing Visual Studio

▼Download link:

https://visualstudio.microsoft.com/ja/downloads/

"Desktop development with C++" for Visual Studio 2019 is required. Since I already had it installed, I launched the installer to verify.
▼You can check settings by selecting "Modify" in the installer.

▼"Desktop development with C++" is already installed.

Installing OpenCV

▼Clicking this link starts the download:

https://github.com/ros2/ros2/releases/download/opencv-archives/opencv-3.4.6-vc16.VS2019.zip

After extracting the downloaded file, move it directly under the C: drive.
▼Moved state:

▼Set the environment variable:

Installing Dependencies

▼Install CMake:

▼Download the necessary packages from this page:

https://github.com/ros2/choco-packages/releases/tag/2022-03-15

▼Required packages:

  • asio.1.12.1.nupkg
  • bullet.3.17.nupkg
  • cunit.2.1.3.nupkg
  • eigen-3.3.4.nupkg
  • tinyxml-usestl.2.6.2.nupkg
  • tinyxml2.6.0.0.nupkg

▼Install the downloaded packages. Replace <PATH\TO\DOWNLOADS> with your actual path.

In my case, the path was C:\Users\mgs_1\Downloads.

▼If packages are missing, an error will occur.

▼Install further dependencies. I received an error unless I upgraded pip first.

Installing xmllint

▼Download page:

https://www.zlatkovic.com/pub/libxml/64bit/

I downloaded libxml2-2.9.3-win32-x86_64.7z. As recommended, I created an xmllint folder directly under the C: drive and extracted it there.
▼The folder after extraction:

Following the instruction to "Add C:\xmllint\bin to the PATH," I added C:\xmllint\bin to the Environment Variables Path.

Installing Qt5

I installed it using the recommended "5.12.x Offline Installers." It took quite a long time.
▼After installation, I set the environment variables:

If you plan to use rqt_graph, Graphviz is required, so I installed that as well. It is used for visualizing node-to-node communication.
▼I downloaded the graphviz-9.0.0 (64-bit) EXE installer:

https://graphviz.org/download/

The installer asks about adding it to the environment variables, so I enabled that option.

Installing ROS2

▼Download link:

https://github.com/ros2/ros2/releases

I downloaded ros2-iron-20240209-windows-release-amd64.zip.
▼I placed it in the C:\dev\ros2_iron folder.

The documentation states that you should run call C:\dev\ros2_iron\local_setup.bat to set up the environment. However, I received an error saying call was not defined.

▼When I ran the .bat file without call, I got the following error:

However, running the .ps1 file followed by the ros2 command worked perfectly.
▼This command sequence worked:

▼"Hello World" is being Published!

Note that if you open a new PowerShell window, ros2 will be undefined unless you run the setup script again.

▼With the talker running, I opened another PowerShell and started the listener.

▼It is successfully receiving messages from the talker!

Addendum

Later, when I opened a new PowerShell, I couldn't run the commands immediately, so I re-verified the process.
▼For example, if you try to run a ros2 command without having executed local_setup.ps1, it is not recognized.

▼Furthermore, local_setup.ps1 could not be executed without changing the Execution Policy.

After changing the policy and running local_setup.ps1, I was able to call the ros2 command.
▼The commands executed in order:

▼The talker is running successfully.

Finally

Looking at the table of contents, there are certainly many things to install! I am a bit concerned about version dependencies.

For now, I think the Installation page is covered. Since I’ve only run a simple sample, I will try the tutorials next.
▼Tutorials page:

https://docs.ros.org/en/iron/Tutorials.html

I also hope to build this environment on a Raspberry Pi in the future.

Leave a Reply

Your email address will not be published. Required fields are marked *