This readme contains information specific to Window 10. For general information, please see README.md.
We assume that working directory is C:\dev
and we are using ROS2 galactic
(replace with foxy
or humble
where applicable).
It is necessary to complete all the steps for ros2cs
Prerequisites and consider Important notices sections.
- Make sure long paths on Windows are enabled
- Make sure you open
Developer PowerShell for VS
with administrator privileges - For
ros2 galactic
distribution, it is best to create aC:\ci\ws\install\include
directory - Clone this project.
git clone git@github.com:RobotecAI/ros2-for-unity.git C:\dev\ros2-for-unity
- Source your ROS2 installation (
C:\dev\ros2_foxy\local_setup.ps1
) in the terminal before you proceed.C:\dev\ros2_foxy\local_setup.ps1
- Enter
Ros2ForUnity
working directory.cd C:\dev\ros2-for-unity
- Set up you custom messages in
ros2_for_unity_custom_messages.repos
- Import necessary and custom messages repositories.
.\pull_repositories.ps1
NOTE
pull_repositories.ps1
script doesn't update already existing repositories, you have to removesrc\ros2cs
folder to re-import new versions. - Build
Ros2ForUnty
. You can build it in standalone or overlay mode.# standalone mode ./build.ps1 -standalone # overlay mode ./build.ps1
- You can build with
-clean_install
to make sure your installation directory is cleaned before deploying.
- You can build with
- Unity Asset is ready to import into your Unity project. You can find it in
install/asset/
directory. - (optionally) To create
.unitypackage
ininstall/unity_package
create_unity_package.ps1
NOTE Please provide path to your Unity executable when prompted. Unity license is required. In case your Unity license has expired, the
create_unity_package.ps1
won't throw any errors butRos2ForUnity.unitypackage
won't be generated too.
- If you see one of the following errors:
<script_name> is not digitally signed
<script_name> cannot be loaded because running scripts is disabled on this system
Please execute Set-ExecutionPolicy Bypass -Scope Process
in PS shell session to enable third party scripts execution only for this session. Otherwise please refer to official Execution Policies.
- If you see the following error:
[4.437s] Traceback (most recent call last): [4.437s] File "<string>", line 1, in <module> [4.437s] File "C:\Python38\lib\site-packages\numpy\__init__.py", line 148, in <module> [4.437s] from . import _distributor_init [4.437s] File "C:\Python38\lib\site-packages\numpy\_distributor_init.py", line 26, in <module> [4.437s] WinDLL(os.path.abspath(filename)) [4.437s] File "C:\Python38\lib\ctypes\__init__.py", line 373, in __init__ [4.453s] self._handle = _dlopen(self._name, mode) [4.453s] OSError: [WinError 193] %1 is not a valid Win32 application [4.469s] CMake Error at C:/dev/ros2_foxy/share/rosidl_generator_py/cmake/rosidl_generator_py_generate_interfaces.cmake:213 (message) [4.469s] execute_process(C:/Python38/python.exe -c 'import [4.469s] numpy;print(numpy.get_include())') returned error code 1 [4.469s] Call Stack (most recent call first): [4.469s] C:/dev/ros2_foxy/share/ament_cmake_core/cmake/core/ament_execute_extensions.cmake:48 (include) [4.469s] C:/dev/ros2_foxy/share/rosidl_cmake/cmake/rosidl_generate_interfaces.cmake:286 (ament_execute_extensions) [4.484s] CMakeLists.txt:16 (rosidl_generate_interfaces)
Please reinstall numpy
package from python by typing:
pip uninstall numpy
pip install numpy
If no solution of your problem is present in the section above, please make sure to check out ros2cs
Troubleshooting section
If the Asset is built with
-standalone
flag (the default), then nothing extra needs to be done. Otherwise, you have to source your ros distribution before launching either Unity3D Editor or Application.
Note that after you build the Asset, you can use it on a machine that has no ros2 installation (if built with
-standalone
).
You can simply copy over the
Ros2ForUnity
subdirectory to update your Asset.