tiiuae / rclgo

ROS Client Library for Golang
Apache License 2.0
81 stars 14 forks source link

Trouble running examples/custom_message_package on Windows 11 #15

Closed aeites closed 1 year ago

aeites commented 1 year ago

Hi,

I'm running into some trouble running the example message generator.

I managed to set up ROS2 with the following specs for my machine:

OS: Windows 11 CPU Architecture: x86_64 ROS2 Version: Humble

When building the Go message bindings go generate within the greeter directory, I ran into a couple of problems, but most of the time I'm met with an empty message definition. I've properly sourced the ROS2 overlay but somehow the message keeps generating nothing.

Here is a snippet of some commands I've been running. Is there anything out of the ordinary happening here?

C:\Projects\LearnGoRos2Client\rclgo>call C:\dev\ros2_humble\local_setup.bat 
"[rti_connext_dds_cmake_module][warning] RTI Connext DDS environment script not found (\resource\scripts\rtisetenv_x64Win64VS2017.bat). RTI Connext DDS will not be available at runtime, unless you already configured PATH manually." 
**********************************************************************
** Visual Studio 2019 Developer Command Prompt v16.11.18
** Copyright (c) 2021 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x86_x64'

C:\Projects\LearnGoRos2Client\rclgo>cd examples\custom_message_package\greeting_msgs

C:\Projects\LearnGoRos2Client\rclgo\examples\custom_message_package\greeting_msgs>colcon build
Starting >>> greeting_msgs
--- stderr: greeting_msgs
CMake Warning (dev) at C:/dev/ros2_humble/share/rosidl_generator_py/cmake/rosidl_generator_py_generate_interfaces.cmake:20 (find_package):
  Policy CMP0148 is not set: The FindPythonInterp and FindPythonLibs modules
  are removed.  Run "cmake --help-policy CMP0148" for policy details.  Use
  the cmake_policy command to set the policy and suppress this warning.

Call Stack (most recent call first):
  C:/dev/ros2_humble/share/ament_cmake_core/cmake/core/ament_execute_extensions.cmake:48 (include)
  C:/dev/ros2_humble/share/rosidl_cmake/cmake/rosidl_generate_interfaces.cmake:286 (ament_execute_extensions)
  CMakeLists.txt:12 (rosidl_generate_interfaces)
This warning is for project developers.  Use -Wno-dev to suppress it.

CMake Warning (dev) at C:/dev/ros2_humble/share/python_cmake_module/cmake/Modules/FindPythonExtra.cmake:52 (find_package):
  Policy CMP0148 is not set: The FindPythonInterp and FindPythonLibs modules
  are removed.  Run "cmake --help-policy CMP0148" for policy details.  Use
  the cmake_policy command to set the policy and suppress this warning.

Call Stack (most recent call first):
  C:/dev/ros2_humble/share/rosidl_generator_py/cmake/rosidl_generator_py_generate_interfaces.cmake:23 (find_package)
  C:/dev/ros2_humble/share/ament_cmake_core/cmake/core/ament_execute_extensions.cmake:48 (include)
  C:/dev/ros2_humble/share/rosidl_cmake/cmake/rosidl_generate_interfaces.cmake:286 (ament_execute_extensions)
  CMakeLists.txt:12 (rosidl_generate_interfaces)
This warning is for project developers.  Use -Wno-dev to suppress it.

CMake Warning (dev) at C:/dev/ros2_humble/share/python_cmake_module/cmake/Modules/FindPythonExtra.cmake:140 (find_package):
  Policy CMP0148 is not set: The FindPythonInterp and FindPythonLibs modules
  are removed.  Run "cmake --help-policy CMP0148" for policy details.  Use
  the cmake_policy command to set the policy and suppress this warning.

Call Stack (most recent call first):
  C:/dev/ros2_humble/share/rosidl_generator_py/cmake/rosidl_generator_py_generate_interfaces.cmake:23 (find_package)
  C:/dev/ros2_humble/share/ament_cmake_core/cmake/core/ament_execute_extensions.cmake:48 (include)
  C:/dev/ros2_humble/share/rosidl_cmake/cmake/rosidl_generate_interfaces.cmake:286 (ament_execute_extensions)
  CMakeLists.txt:12 (rosidl_generate_interfaces)
This warning is for project developers.  Use -Wno-dev to suppress it.

---
Finished <<< greeting_msgs [9.42s]

Summary: 1 package finished [9.66s]
  1 package had stderr output: greeting_msgs
WNDPROC return value cannot be converted to LRESULT
TypeError: WPARAM is simple, so must be an int object (got NoneType)

C:\Projects\LearnGoRos2Client\rclgo\examples\custom_message_package\greeting_msgs>.\install\setup.bat
"[rti_connext_dds_cmake_module][warning] RTI Connext DDS environment script not found (\resource\scripts\rtisetenv_x64Win64VS2017.bat). RTI Connext DDS will not be available at runtime, unless you already configured PATH manually."
om/tiiuae/rclgo/cmd/rclgo-gen generate -d msgs
Generating all importer: msgs\msgs.gen.go

C:\Projects\LearnGoRos2Client\rclgo\examples\custom_message_package\greeting_msgs>cd ../greeter

C:\Projects\LearnGoRos2Client\rclgo\examples\custom_message_package\greeter>go generate
go: updates to go.mod needed; to update it:
        go mod tidy

C:\Projects\LearnGoRos2Client\rclgo\examples\custom_message_package\greeter>go generate
Generating all importer: msgs\msgs.gen.go

C:\Projects\LearnGoRos2Client\rclgo\examples\custom_message_package\greeter>go mod tidy
go: finding module for package github.com/tiiuae/rclgo/examples/custom_message_package/greeter/msgs/greeting_msgs/msg
github.com/tiiuae/rclgo/examples/custom_message_package/greeter imports
        github.com/tiiuae/rclgo/examples/custom_message_package/greeter/msgs/greeting_msgs/msg: module github.com/tiiuae/rclgo@latest found (v0.0.0, replaced by ../../..), but does not contain package github.com/tiiuae/rclgo/examples/custom_message_package/greeter/msgs/greeting_msgs/msg     

C:\Projects\LearnGoRos2Client\rclgo\examples\custom_message_package\greeter>go run github.com/tiiuae/rclgo/cmd/rclgo-gen generate -d msgs
Generating all importer: msgs\msgs.gen.go

C:\Projects\LearnGoRos2Client\rclgo\examples\custom_message_package\greeter>echo %AMENT_PREFIX_PATH%
C:\Projects\LearnGoRos2Client\rclgo\examples\custom_message_package\greeting_msgs\install\greeting_msgs;C:\dev\ros2_humble

C:\Projects\LearnGoRos2Client\rclgo\examples\custom_message_package\greeter>go run github.com/tiiuae/rclgo/cmd/rclgo-gen generate -d msgs --root-path="%AMENT_PREFIX_PATH%"
Generating all importer: msgs\msgs.gen.go

Also here is the msgs.gen.go file, note that it generates an empty file:

/*
This file is part of rclgo

Copyright © 2021 Technology Innovation Institute, United Arab Emirates

Licensed under the Apache License, Version 2.0 (the "License");
    http://www.apache.org/licenses/LICENSE-2.0
*/

// Code generated by rclgo-gen. DO NOT EDIT.

package msgs

import (
)
lassilaiho commented 1 year ago

Hi, I made some fixes, can you try the newest version?

aeites commented 1 year ago

Hi,

It looks like you've fixed the file generation, nice!

But now I'm running into the same issue as described in issue #12. It looks like the headers of the Windows ROS2 libraries aren't set up properly, or perhaps I'm linking them incorrectly.

The environment setup:

SET GOOS=windows
SET GOARCH=386
SET CGO_ENABLED=1
SET CGO_CFLAGS=-IC:\dev\ros2_humble\include\rosidl_runtime_c -IC:\dev\ros2_humble\include\rcl_action -IC:\dev\ros2_humble\include\action_msgs -IC:\dev\ros2_humble\include\unique_identifier_msgs -IC:\dev\ros2_humble\include\builtin_interfaces -IC:\dev\ros2_humble\include\rosidl_typesupport_interface -IC:\dev\ros2_humble\include\rcl -IC:\dev\ros2_humble\include\rcutils -IC:\dev\ros2_humble\include\rmw -IC:\dev\ros2_humble\include\rcl_yaml_param_parser

SET CGO_LDFLAGS=-LC:\dev\ros2_humble\Lib -Wl,-rpath,li

Compiler: tdm-gcc

Then afterwards I receive the following errors when I go build

..\..\..\pkg\rclgo\action.go:416:12: could not determine kind of name for C.rcl_action_accept_new_goal
..\..\..\pkg\rclgo\action.go:649:9: could not determine kind of name for C.rcl_action_cancel_response_fini
..\..\..\pkg\rclgo\action.go:888:8: could not determine kind of name for C.rcl_action_client_fini
..\..\..\pkg\rclgo\action.go:862:8: could not determine kind of name for C.rcl_action_client_init
..\..\..\pkg\rclgo\action.go:1213:8: could not determine kind of name for C.rcl_action_client_wait_set_get_entities_ready
..\..\..\pkg\rclgo\action.go:535:9: could not determine kind of name for C.rcl_action_expire_goals
..\..\..\pkg\rclgo\action.go:693:8: could not determine kind of name for C.rcl_action_get_goal_status_array
..\..\..\pkg\rclgo\action.go:633:13: could not determine kind of name for C.rcl_action_get_zero_initialized_cancel_response
..\..\..\pkg\rclgo\action.go:829:16: could not determine kind of name for C.rcl_action_get_zero_initialized_client
..\..\..\pkg\rclgo\action.go:110:17: could not determine kind of name for C.rcl_action_get_zero_initialized_goal_info
..\..\..\pkg\rclgo\action.go:691:14: could not determine kind of name for C.rcl_action_get_zero_initialized_goal_status_array
..\..\..\pkg\rclgo\action.go:340:14: could not determine kind of name for C.rcl_action_get_zero_initialized_server

...

cgo:
gcc errors for preamble:
In file included from C:\dev\ros2_humble\include\rcutils/rcutils/allocator.h:28,
                 from C:\dev\ros2_humble\include\rcl/rcl/allocator.h:25,
                 from C:\dev\ros2_humble\include\rcl_action/rcl_action/types.h:30,
                 from C:\dev\ros2_humble\include\rcl_action/rcl_action/action_client.h:23,
                 from C:\dev\ros2_humble\include\rcl_action/rcl_action/rcl_action.h:50,
                 from ..\..\..\pkg\rclgo\action.go:6:
C:\dev\ros2_humble\include\rcutils/rcutils/macros.h:30:29: error: unknown type name '_Check_return_'
   30 | #define RCUTILS_WARN_UNUSED _Check_return_
      |                             ^~~~~~~~~~~~~~
C:\dev\ros2_humble\include\rcutils/rcutils/allocator.h:84:1: note: in expansion of macro 'RCUTILS_WARN_UNUSED'
   84 | RCUTILS_WARN_UNUSED
      | ^~~~~~~~~~~~~~~~~~~
In file included from C:\dev\ros2_humble\include\rcl/rcl/allocator.h:25,
                 from C:\dev\ros2_humble\include\rcl_action/rcl_action/types.h:30,
                 from C:\dev\ros2_humble\include\rcl_action/rcl_action/action_client.h:23,
                 from C:\dev\ros2_humble\include\rcl_action/rcl_action/rcl_action.h:50,
                 from ..\..\..\pkg\rclgo\action.go:6:
C:\dev\ros2_humble\include\rcutils/rcutils/allocator.h:86:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'rcutils_get_zero_initialized_allocator'
   86 | rcutils_get_zero_initialized_allocator(void);
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from C:\dev\ros2_humble\include\rcutils/rcutils/allocator.h:28,
                 from C:\dev\ros2_humble\include\rcl/rcl/allocator.h:25,
                 from C:\dev\ros2_humble\include\rcl_action/rcl_action/types.h:30,
                 from C:\dev\ros2_humble\include\rcl_action/rcl_action/action_client.h:23,
                 from C:\dev\ros2_humble\include\rcl_action/rcl_action/rcl_action.h:50,
                 from ..\..\..\pkg\rclgo\action.go:6:
C:\dev\ros2_humble\include\rcutils/rcutils/macros.h:30:29: error: unknown type name '_Check_return_'
   30 | #define RCUTILS_WARN_UNUSED _Check_return_
      |                             ^~~~~~~~~~~~~~
C:\dev\ros2_humble\include\rcutils/rcutils/allocator.h:107:1: note: in expansion of macro 'RCUTILS_WARN_UNUSED'
  107 | RCUTILS_WARN_UNUSED
      | ^~~~~~~~~~~~~~~~~~~
In file included from C:\dev\ros2_humble\include\rcl/rcl/allocator.h:25,
                 from C:\dev\ros2_humble\include\rcl_action/rcl_action/types.h:30,
                 from C:\dev\ros2_humble\include\rcl_action/rcl_action/action_client.h:23,
                 from C:\dev\ros2_humble\include\rcl_action/rcl_action/rcl_action.h:50,
                 from ..\..\..\pkg\rclgo\action.go:6:
                 
...

I'm going to try to run this in Ubuntu instead of Windows, but if you have any other suggestions to try I'm open to them.

aeites commented 1 year ago

It looks like the rclgo greeter example builds properly in Ubuntu 22.04 out of the box with a regular ROS2 install. I'm not sure what else we'd need in Windows to accomplish this, but it seems to be a problem in the ROS2 libraries in Windows.

For the time being though, I'll just use Ubuntu.