[PYTHON] From ROS for Windows installation to operation check

Introduction

In this article, I would like to install ROS for Windows and do the tutorial Try running a simple Publisher and Subscriber to check the operation. I think. This is a memorandum article when ROS for Windows is installed. Note that in this article we will install ROS directly on Windows instead of installing it on WSL. There were many installation articles on WSL, but there are few articles that install directly on Windows, so I'm not sure if there is demand, but I will write it.

Installation

Install as officially. Install ROS noetic here. http://wiki.ros.org/Installation/Windows

Install Visual Studio 2019

If you have already installed it, skip it. Download from here.

The following must be included during installation:

--Desktop development with C ++ --English language pack

Restart your PC when the installation is complete.

Installing the package manager (Chocolatey)

Start Visual Studio Command Prompt with administrator privileges and copy and paste the following.

@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"

Please note that the command may not be executed due to the real-time scan of antivirus software. In that case, either disable it temporarily or exclude C: \ opt from the real-time scan.

Then restart Visual Studio Command Prompt with administrator privileges to install git. If it is already installed, it will be skipped.

choco upgrade git -y

Installation confirmation

git --version

ROS installation

To install ROS1, run the following command.

mkdir c:\opt\chocolatey
set ChocolateyInstall=c:\opt\chocolatey
choco source add -n=ros-win -s="https://aka.ms/ros/public" --priority=1
choco upgrade ros-noetic-desktop_full -y --execution-timeout=0

If you get an error above, go below. (I got an error in my environment, so I installed it with the following command)

mkdir c:\opt\chocolatey
set ChocolateyInstall=c:\opt\chocolatey
choco source add -n=ros-win -s="https://aka.ms/ros/public" --priority=1
choco upgrade ros-noetic-desktop_full -y --execution-timeout=0 --pre

For ROS2: (I haven't tried this)

mkdir c:\opt\chocolatey
set ChocolateyInstall=c:\opt\chocolatey
choco source add -n=ros-win -s="https://aka.ms/ros/public" --priority=1
choco upgrade ros-eloquent-desktop -y --execution-timeout=0 --pre

Create shortcut for ROS command window

To use the ROS command, you need to execute the setup script every time you start the command prompt, so create a shortcut by following the steps below.

  1. Right-click anywhere in Explorer (or desktop)

  2. New> Shortcut

  3. Copy the following to the location of the item (for Visual Studio 2019 community version)

    C:\Windows\System32\cmd.exe /k "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Tools\VsDevCmd.bat" -arch=amd64 -host_arch=amd64&& set ChocolateyInstall=c:\opt\chocolatey&& c:\opt\ros\noetic\x64\setup.bat
    
  4. Set the name to "ROS" (optional)

  5. Right-click on the shortcut and select Properties> Advanced

  6. Check "Run as administrator"

Operation check

Basically, follow the Tutorials. Of course, the tutorial is a Linux command, so replace it with a Windows command as needed. Below, the workspace will be created in C: \ path \ to \ catkin_ws.

Create workspace

mkdir -p C:\path\to\catkin_ws\src
cd C:\path\to\catkin_ws\src
catkin_init_workspace
cd C:\path\to\catkin_ws
catkin_make
C:\path\to\catkin_ws\devel\setup.bat

Package creation

Create the beginner_tutorials package as you did in the tutorial.

cd C:\path\to\catkin_ws\src
catkin_create_pkg beginner_tutorials std_msgs rospy roscpp
cd C:\path\to\catkin_ws
catkin_make

You can check the package dependency with the following command as in the tutorial.

C:\path\to\catkin_ws\devel\setup.bat
rospack depends1 beginner_tutorials

Preparation of talker.py and listener.py

Change to the beginner_tutorials directory.

cd C:\path\to\catkin_ws\src\beginner_tutorials

I got an error when using roscd. The cause is unknown. (Please tell me)

>roscd beginner_tutorials
Traceback (most recent call last):
  File "C:\opt\ros\noetic\x64\bin\\rosfindpath.py", line 82, in <module>
    sys.exit(findpathmain(sys.argv[1:]))
  File "C:\opt\ros\noetic\x64\bin\\rosfindpath.py", line 74, in findpathmain
    rosdir = os.path.normpath(os.path.sep.join([package_dir, reldir]))
TypeError: sequence item 0: expected str instance, bytes found
(Is used incorrectly.

Next, create a directory to save the python code.

mkdir scripts
cd scripts

Download talker.py and listener.py. Here, instead of wget, we use bitsadmin, which is installed by default in windows.

bitsadmin.exe /TRANSFER getpythoncode https://raw.github.com/ros/ros_tutorials/indigo-devel/rospy_tutorials/001_talker_listener/talker.py C:\path\to\catkin_ws\src\beginner_tutorials\scripts\talker.py
bitsadmin.exe /TRANSFER getpythoncode https://raw.github.com/ros/ros_tutorials/indigo-devel/rospy_tutorials/001_talker_listener/listener.py C:\path\to\catkin_ws\src\beginner_tutorials\scripts\listener.py

Edit C: \ path \ to \ catkin_ws \ src \ beginner_tutorials \ CMakeLists.txt. Find catkin_install_python and uncomment it as follows.

catkin_install_python(PROGRAMS
  scripts/talker.py
  scripts/listener.py
  DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)

Build.

cd C:\path\to\catkin_ws
catkin_make

Open three command prompts from the shortcut and execute the following for each.

roscore
C:\path\to\catkin_ws\devel\setup.bat
rosrun beginner_tutorials talker.py
C:\path\to\catkin_ws\devel\setup.bat
rosrun beginner_tutorials listener.py

Then you can see the same operation as the Linux version. It's easy, but the operation check is complete.

When you want to update

You can update ROS by opening a command window from the shortcut and using the following command.

set ChocolateyInstall=c:\opt\chocolatey
choco upgrade all -y --execution-timeout=0

When you want to uninstall

You can uninstall it with the following command after checking if ROS is running.

rmdir /s /q c:\opt

Where in trouble

I can't use roscd

You can use ROS itself without it, but I still want it. If anyone knows the solution, please let me know. I haven't tried all ROS commands, so there may be other commands that I can't use.

Need to run devel / setup.bat every time you open a command window

This can be done by adding the following to the "item location" when creating the shortcut, but in my environment it could not be entered due to the character limit.

&& C:\path\to\catkin_ws\devel\setup.bat

Bonus (turtle)

You can see the familiar turtle on Windows with the following command.

rosrun turtlesim turtlesim_node

image.png

Recommended Posts

From ROS for Windows installation to operation check
pynq-z1 From purchase to operation check
Installation notes for TensorFlow for Windows
Django installation and operation check
JupyterLab3.0 Debugger Installation Method for Windows
OpenMPI installation from download to pass-through
Ssh connect to GCP from Windows
From ubuntu installation to running kinect with docker and ros (overview)
[Note] [PyTorch] From installation to easy usage
"Python AI programming" starting from 0 for windows
Elasticsearch installation and basic operation for ubuntu
How to install Windows Subsystem For Linux
Python> Output numbers from 1 to 100, 501 to 600> For csv
Flask tutorial (from installation to hello world)
Introduction to Scapy ① (From installation to execution of Scapy)
[2021 version] From Selenium Basic installation to Web scraping execution by Python Windows 10 (64bit)
[Ansible installation procedure] From installation to execution of playbook
ROS Package for getting RGB-D Images from RGB-D Sensor
Command operation to not move from home position
From 0 to Django development environment construction to basic operation
From easy git installation to docker startup python
Convert binary packages for windows to wheel format
Steps to build PyTorch 1.5 for CUDA 10.2 on Windows
A real way for people using python 3.8.0-2 from windows to work with multibyte characters
Python installation (Windows)
Sum from 1 to 10
How to check for missing values (Kaggle: House Prices)
From user to root ~ Searching for promotion ~ (TAMUctf 2020: Writeup)
RaspberryPi3 (STRETCH) setup from OS installation to Hello World
Python development environment construction 2020 [From Python installation to poetry introduction]
Articles to see when installation for Python + OpenCV fails
Python # How to check type and type for super beginners