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.
The installation method introduced below is as of August 10, 2020. Be sure to check the Official Installation Method before installing.
Not all ROS functions can be used with ROS for Windows at this time.
Install as officially. Install ROS noetic here. http://wiki.ros.org/Installation/Windows
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.
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
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
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.
Right-click anywhere in Explorer (or desktop)
New> Shortcut
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
Set the name to "ROS" (optional)
Right-click on the shortcut and select Properties> Advanced
Check "Run as administrator"
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
.
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
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
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.
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
You can uninstall it with the following command after checking if ROS is running.
rmdir /s /q c:\opt
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.
devel / setup.bat
every time you open a command windowThis 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
You can see the familiar turtle on Windows with the following command.
rosrun turtlesim turtlesim_node
Recommended Posts