micro-ROS / micro-ROS-demos

Sample code using rclc and rclcpp implementations.
Apache License 2.0
84 stars 24 forks source link

Windows builds: any special infrastructure needed? #54

Closed gavanderhoorn closed 1 year ago

gavanderhoorn commented 2 years ago

More of a question, not an actual issue, but Discussions is not enabled, so here goes.

(if this is an RTFM, please point me to it)

I'd be interested in building the demos on a Windows machine, targetting Windows.

The readme seems to suggest this is possible in Run demonstration (Windows), but I don't see this mentioned anywhere else.

The Previous Step section links to a microROS/micro-ROS-doc repository, but that doesn't appear to be around any more.

Could you perhaps give a few hints on what would be needed? I imagine a working Windows-based ROS 2 dev env, but what else?

ted-miller commented 2 years ago

I have attempted to load the agent (foxy branch) on Windows 10. I get a message that Windows is an unsupported OS.

T:\Projects\ROS-2\uros_agent_test>git clone -b foxy https://github.com/micro-ROS/micro_ros_setup.git src/micro_ros_setup
Cloning into 'src/micro_ros_setup'...
remote: Enumerating objects: 2797, done.
remote: Counting objects: 100% (579/579), done.
remote: Compressing objects: 100% (321/321), done.
remote: Total 2797 (delta 392), reused 377 (delta 253), pack-reused 2218
Receiving objects: 100% (2797/2797), 588.26 KiB | 0 bytes/s, done.
Resolving deltas: 100% (1900/1900), done.

T:\Projects\ROS-2\uros_agent_test>rosdep install --from-path src --ignore-src -y
ERROR: the following packages/stacks could not have their rosdep keys resolved
to system dependencies:
micro_ros_setup: Unsupported OS [windows]

But, if I ignore the error and trudge on, in the hopes that I already have the required dependency packages, I fail at the create_agent_ws step.

T:\Projects\ROS-2\uros_agent_test>ros2 run micro_ros_setup create_agent_ws.sh
Traceback (most recent call last):
  File "T:\Projects\ROS-2\ros2-windows\Scripts\ros2-script.py", line 33, in <module>
    sys.exit(load_entry_point('ros2cli==0.9.8', 'console_scripts', 'ros2')())
  File "T:\Projects\ROS-2\ros2-windows\Lib\site-packages\ros2cli\cli.py", line 67, in main
    rc = extension.main(parser=parser, args=args)
  File "T:\Projects\ROS-2\ros2-windows\Lib\site-packages\ros2run\command\run.py", line 70, in main
    return run_executable(path=path, argv=args.argv, prefix=prefix)
  File "T:\Projects\ROS-2\ros2-windows\Lib\site-packages\ros2run\api\__init__.py", line 61, in run_executable
    process = subprocess.Popen(cmd)
  File "c:\python38\lib\subprocess.py", line 854, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "c:\python38\lib\subprocess.py", line 1307, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
OSError: [WinError 193] %1 is not a valid Win32 application

I'm assuming that the %1 is referencing some executable that is missing. (Presumably something that should have been fetched by rosdep.) Perhaps I'm missing something obvious, but I can't figure out what "%1" is supposed to be. Is it one of the items in agent_uros_packages.repos?

ted-miller commented 2 years ago

I can't figure out what "%1" is supposed to be. Is it one of the items in agent_uros_packages.repos?

I went ahead and manually pulled down those packages and attempted to build. But, they appear to have a lot of other sub dependencies, as I got a lot of linker errors when trying to build. events.log

pablogs9 commented 2 years ago

@ted-miller Could you try to build the micro-ROS Agent as a common ROS 2 package? Just add it to a workspace, make sure that micro_ros_msgs is installed via rosdep or cloning the repo in the workspace and build it normally using colcon. Does this approach have any problem?

I'm not sure if micro_ros_setup is fully compatible with Windows 10 due to the scripts used.

gavanderhoorn commented 2 years ago

@ted-miller: the rosdep step is not important, it's a minor inconvenience.

@pablogs9: I'll try building the agent with the dev env I have now.

Could you confirm a regular ROS 2 Windows dev env should be sufficient?

I'm not sure if micro_ros_setup is fully compatible with Windows 10 due to the scripts used.

No, it's not. Would be great to have though.

How were the demos in this repository configured / build?

pablogs9 commented 2 years ago

@gavanderhoorn it should since the agent does not depend on external packages (only micro_ros_msgs and it is integrated at the list in the apt repos of ROS 2)

I'm seeing that the README.md instruction of this repo has been outdated for a long time. I'm not sure if now is straightforward to compile micro-ROS-demos for Windows.

But maybe, creating a workspace that contains RCLC, this repo, and the other dependencies it should work. As far as I know, for example @norro uses RCLC in Windows.

gavanderhoorn commented 2 years ago

I'll give it a try and report back.

If @norro could share his experiences that would be greatly appreciated.

The end goal here would be to be able to do something similar to the host option in micro_ros_setup, but on Windows. On-device debugging is non-trivial, so being able to migrate some of the development to a Windows host hopefully allows us to avoid that as much as possible.

norro commented 2 years ago

Sure thing! I'm not that much using rclc on Windows, but rather have a rclc installation on Windows, just to make sure that it is working (compile and tests). If you want me to share my experience: it's bad! :D But just because of the general software development experience on Windows (at least for me).

I pretty much followed these steps and it was working after some fumbling around. Is there anything concrete you want me to share?

gavanderhoorn commented 2 years ago

Ok, thanks.

So essentially a working ROS 2 dev env on Windows 10 can be used to build (at least) the Agent.

Have you tried building any of the demos in this repository?

How did you fetch all the required packages (for the Agent and/or the demos)? Just manually going through each manifest and git clone the hosting repository?

If you want me to share my experience: it's bad! :D But just because of the general software development experience on Windows (at least for me).

I have to say I agree.

But then again: I know people who say the same thing about other platforms, so I guess it just depends on what you're used to.

ted-miller commented 2 years ago

@ted-miller Could you try to build the micro-ROS Agent as a common ROS 2 package? Just add it to a workspace, make sure that micro_ros_msgs is installed via rosdep or cloning the repo in the workspace and build it normally using colcon. Does this approach have any problem?

I have not tried this. I'll give it a shot on monday or tuesday.

ted-miller commented 2 years ago

Could you try to build the micro-ROS Agent as a common ROS 2 package? Just add it to a workspace, make sure that micro_ros_msgs is installed via rosdep or cloning the repo in the workspace and build it normally using colcon. Does this approach have any problem?

I have not been successful in this. I have fumbled into quite a few issues while testing. (I think most were self inflicted, due to inexperience.)

At this point, I cannot get past some linking errors for microxrcedds_agent. It is failing to find some functions from the fmt and spdlog libraries. I have tried downloading the source for those libs and explicitly adding the library in [workspace]\build\micro_ros_agent\agent\src\xrceagent\CMakeLists.txt. But, the linking errors persist. So, I don't know if there is a specific version required or what the deal is.

But, I've got an Ubuntu system that is working. So, I'll just continue development on that.

pablogs9 commented 2 years ago

Both micro-ROS agent and Micro XRCE-DDS Agent use a CMake superbuild approach that should resolve automatically all the dependencies. In fact, Micro XRCE-DDS Agent has full support for Windows: http://jenkins.eprosima.com:8080/view/Micro%20XRCE/job/Micro-XRCE-DDS-Agent%20Manual%20Windows/

Could you detail which errors did you have building the Micro XRCE-DDS Agent?

gavanderhoorn commented 2 years ago

Just did a quick test using the superbuild.

Following basically Installing the Agent standalone (git clone https://github.com/eProsima/Micro-XRCE-DDS-Agent.git, mkdir build, cd build, running the CMake commands shown on that page), CMake complains about the following during configuration:

CMake Error at C:/Users/user/cmake-3.21.3-windows-x86_64/share/cmake-3.21/Modules/ExternalProject.cmake:1738 (file):
  file problem creating directory: C:/Program Files (x86)/uagent_superbuild
Call Stack (most recent call first):
  C:/Users/user/cmake-3.21.3-windows-x86_64/share/cmake-3.21/Modules/ExternalProject.cmake:3652 (_ep_set_directories)
  cmake/SuperBuild.cmake:29 (ExternalProject_Add)
  CMakeLists.txt:28 (include)

CMake Error at C:/Users/user/cmake-3.21.3-windows-x86_64/share/cmake-3.21/Modules/ExternalProject.cmake:1740 (message):
  dir 'C:/Program Files (x86)/uagent_superbuild' does not exist after
  file(MAKE_DIRECTORY)
Call Stack (most recent call first):
  C:/Users/user/cmake-3.21.3-windows-x86_64/share/cmake-3.21/Modules/ExternalProject.cmake:3652 (_ep_set_directories)
  cmake/SuperBuild.cmake:29 (ExternalProject_Add)
  CMakeLists.txt:28 (include)

-- Configuring incomplete, errors occurred!

It seems to try to create a directory in a non-writable location.

Perhaps ExternalProject_Add(..) needs to be passed a different location for the build dir?


Edit: seems CMAKE_INSTALL_PREFIX is set to C:/Program Files (x86)/uagent_superbuild, which my user can't write to. It's set to that value here.

Commenting those lines makes the configuration step complete successfully. The build still fails with some other error. Trying to see what's going wrong.


Edit 2: should these lines be set to ON? At least on this test system, there is no system-install of either FastDDS or FastCDR.

On a system with ROS 2 installed (and with FastDDS available) the Agent could of course use the system-install of FastDDS and FastCDR. This test-system doesn't have ROS 2 installed, so that's why it was failing.

With cmake -DCMAKE_INSTALL_PREFIX=C:\some\path .. (and overriding UAGENT_USE_SYSTEM_FASTDDS and UAGENT_USE_SYSTEM_FASTCDR) the XRCE-DDS Agent builds. Except the Micro-ROS Agent of course, as there is no ROS 2 on this system.


Edit 3: CMAKE_INSTALL_PREFIX would also not point to C:/Program Files (x86) on a system with ROS 2 installed (and 'activated').

I guess it wouldn't make much sense for micro_ros_agent to be built on a system where ROS 2 itself is not installed.

The error messages are a little obscure though. I'm wondering if they could be improved in any way.

ted-miller commented 2 years ago

Could you detail which errors did you have building the Micro XRCE-DDS Agent?

Open elevated command prompt

"C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
"T:\Projects\ROS-2\ros2-foxy-windows\local_setup.bat"
cd T:\Projects\ROS-2\uros_win_ws
git clone -b foxy https://github.com/micro-ROS/micro_ros_msgs.git src/micro_ros_msgs
git clone -b foxy https://github.com/micro-ROS/micro-ROS-Agent.git src/micro-ROS-Agent
colcon build --merge-install

Starting >>> micro_ros_msgs
[Processing: micro_ros_msgs]
Finished <<< micro_ros_msgs [46.6s]
Starting >>> micro_ros_agent
[Processing: micro_ros_agent]
[Processing: micro_ros_agent]
[Processing: micro_ros_agent]
[Processing: micro_ros_agent]
Failed   <<< micro_ros_agent [2min 16s, exited with code 1]

Summary: 1 package finished [3min 4s]
  1 package failed: micro_ros_agent

Sample of linking errors:

Creating library T:/Projects/ROS-2/uros_win_ws/build/micro_ros_agent/agent/src/xrceagent-build/Release/microxrcedds_agent-2.0.lib and object T:/Projects/ROS-2/uros_win_ws/build/micro_ros_agent/agent/src/xrceagent-build/Release/microxrcedds_agent-2.0.exp
FastEntities.obj : error LNK2019: unresolved external symbol "protected: void __cdecl spdlog::logger::log_it_(struct spdlog::details::log_msg const &,bool,bool)" (?log_it_@logger@spdlog@@IEAAXAEBUlog_msg@details@2@_N1@Z) referenced in function "public: void __cdecl fmt::v6::internal::basic_writer<class fmt::v6::internal::output_range<class std::back_insert_iterator<class fmt::v6::internal::buffer<char> >,char> >::write_padded<struct fmt::v6::internal::basic_writer<class fmt::v6::internal::output_range<class std::back_insert_iterator<class fmt::v6::internal::buffer<char> >,char> >::padded_int_writer<struct fmt::v6::internal::basic_writer<class fmt::v6::internal::output_range<class std::back_insert_iterator<class fmt::v6::internal::buffer<char> >,char> >::int_writer<char,struct fmt::v6::basic_format_specs<char> >::bin_writer<1> > >(struct fmt::v6::basic_format_specs<char> const &,struct fmt::v6::internal::basic_writer<class fmt::v6::internal::output_range<class std::back_insert_iterator<class fmt::v6::internal::buffer<char> >,char> >::padded_int_writer<struct fmt::v6::internal::basic_writer<class fmt::v6::internal::output_range<class std::back_insert_iterator<class fmt::v6::internal::buffer<char> >,char> >::int_writer<char,struct fmt::v6::basic_format_specs<char> >::bin_writer<1> > &&)" (??$write_padded@U?$padded_int_writer@U?$bin_writer@$00@?$int_writer@DU?$basic_format_specs@D@v6@fmt@@@?$basic_writer@V?$output_range@V?$back_insert_iterator@V?$buffer@D@internal@v6@fmt@@@std@@D@internal@v6@fmt@@@internal@v6@fmt@@@?$basic_writer@V?$output_range@V?$back_insert_iterator@V?$buffer@D@internal@v6@fmt@@@std@@D@internal@v6@fmt@@@internal@v6@fmt@@@?$basic_writer@V?$output_range@V?$back_insert_iterator@V?$buffer@D@internal@v6@fmt@@@std@@D@internal@v6@fmt@@@internal@v6@fmt@@QEAAXAEBU?$basic_format_specs@D@23@$$QEAU?$padded_int_writer@U?$bin_writer@$00@?$int_writer@DU?$basic_format_specs@D@v6@fmt@@@?$basic_writer@V?$output_range@V?$back_insert_iterator@V?$buffer@D@internal@v6@fmt@@@std@@D@internal@v6@fmt@@@internal@v6@fmt@@@0123@@Z) [T:\Projects\ROS-2\uros_win_ws\build\micro_ros_agent\agent\src\xrceagent-build\microxrcedds_agent.vcxproj] [T:\Projects\ROS-2\uros_win_ws\build\micro_ros_agent\agent\src\xrceagent-build\uagent.vcxproj] [T:\Projects\ROS-2\uros_win_ws\build\micro_ros_agent\xrceagent.vcxproj]
FastEntities.obj : error LNK2001: unresolved external symbol "int __cdecl fmt::v6::internal::snprintf_float<double>(double,int,struct fmt::v6::internal::float_specs,class fmt::v6::internal::buffer<char> &)" (??$snprintf_float@N@internal@v6@fmt@@YAHNHUfloat_specs@012@AEAV?$buffer@D@012@@Z) [T:\Projects\ROS-2\uros_win_ws\build\micro_ros_agent\agent\src\xrceagent-build\microxrcedds_agent.vcxproj] [T:\Projects\ROS-2\uros_win_ws\build\micro_ros_agent\agent\src\xrceagent-build\uagent.vcxproj] [T:\Projects\ROS-2\uros_win_ws\build\micro_ros_agent\xrceagent.vcxproj]
FastEntities.obj : error LNK2001: unresolved external symbol "int __cdecl fmt::v6::internal::format_float<double>(double,int,struct fmt::v6::internal::float_specs,class fmt::v6::internal::buffer<char> &)" (??$format_float@N@internal@v6@fmt@@YAHNHUfloat_specs@012@AEAV?$buffer@D@012@@Z) [T:\Projects\ROS-2\uros_win_ws\build\micro_ros_agent\agent\src\xrceagent-build\microxrcedds_agent.vcxproj] [T:\Projects\ROS-2\uros_win_ws\build\micro_ros_agent\agent\src\xrceagent-build\uagent.vcxproj] [T:\Projects\ROS-2\uros_win_ws\build\micro_ros_agent\xrceagent.vcxproj]

Full log: uros_win_ws\log\latest_build\micro_ros_agent stdout_stderr.log

It appears that others have had very similar issues, even on Ubuntu. https://issueexplorer.com/issue/micro-ROS/micro-ROS-Agent/50 https://githubmemory.com/repo/micro-ROS/micro-ROS.github.io/issues/303 Though, my Ubuntu system is working fine.

Both micro-ROS agent and Micro XRCE-DDS Agent use a CMake superbuild approach that should resolve automatically all the dependencies.

In the log, it does appear to be building these spdlog and fmt libraries. So, my best guess is that there's just a version conflict somewhere.

gavanderhoorn commented 1 year ago

@ted-miller: can this be closed?

In the end we did build the Agent on Windows, correct?

ted-miller commented 1 year ago

Yes, the agent will build successfully on Windows. https://github.com/Yaskawa-Global/motoros2#windows