Skip to content
This repository has been archived by the owner on Jul 12, 2024. It is now read-only.

rcl_cpp::Node runtime error (InvalidNodeNameError) after compiling nugets successfully #19

Open
iqedgarmg opened this issue Dec 16, 2021 · 0 comments

Comments

@iqedgarmg
Copy link

iqedgarmg commented Dec 16, 2021

Hi everyone!, thanks a lot for this amazing project!

I am experiment some issues while tried to compile the project on a Windows 10 amd64 machine for UWP, particularly by running the script inittools.cmd at the command:

call colcon build --event-handlers console_cohesion+ --merge-install --build-base .\x64_build --install-base .\x64 --cmake-args -DCSHARP_PLATFORM=x64 -DDOTNET_CORE_ARCH=x64 -DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION=10.0 --no-warn-unused-cli -DCMAKE_BUILD_TYPE=RelWithDebInfo -Wno-dev

The following error appears:

 C:\ws_new\ros_msft_mrtk_native\tools\src\ament\ament_index\ament_index_cpp\src\get_resources.cpp(74,67): error C2664: 'HANDLE FindFirstFileW(LPCWSTR,LPWIN32_FIND_DATAW)': cannot convert argument 1 from 'const _Elem *' to 'LPCWSTR' [C:\ws_new\ros_msft_mrtk_native\tools\x64_build\ament_index_cpp\ament_index_cpp.vcxproj]
          with
          [
              _Elem=char
          ]

C:\ws\ros_msft_mrtk_native\tools\src\ament\ament_index\ament_index_cpp\src\get_resources.cpp(89,10): message : Reason: cannot convert from 'WCHAR [260]' to 'const std::basic_string<char,std::char_traits<char>,std::allocator<char>>' [C:\ws\ros_msft_mrtk_native\tools\x64_build\ament_index_cpp\ament_index_cpp.vcxproj]
C:\ws\ros_msft_mrtk_native\tools\src\ament\ament_index\ament_index_cpp\src\get_resources.cpp(89,10): message : No constructor could take the source type, or constructor overload resolution was ambiguous [C:\ws\ros_msft_mrtk_native\tools\x64_build\ament_index_cpp\ament_index_cpp.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\xtree(1370,25): message : see declaration of 'std::_Tree<std::_Tmap_traits<_Kty,_Ty,_Pr,_Alloc,false>>::find' [C:\ws\ros_msft_mrtk_native\tools\x64_build\ament_index_cpp\ament_index_cpp.vcxproj]

After looking solutions for the specific problem, I was able to fix it by modifying the file "ros_msft_mrtk_native\tools\src\ament\ament_index\ament_index_cpp\src\get_resources.cpp" to adding the following conversion functions:

std::wstring s2ws(const std::string& str)
{
    using convert_typeX = std::codecvt_utf8<wchar_t>;
    std::wstring_convert<convert_typeX, wchar_t> converterX;

    return converterX.from_bytes(str);
}

std::string ws2s(const std::wstring& wstr)
{
    using convert_typeX = std::codecvt_utf8<wchar_t>;
    std::wstring_convert<convert_typeX, wchar_t> converterX;

    return converterX.to_bytes(wstr);
}

and this modifications to convert from wstring to string:

#else

    std::string pattern = path + "/*";

    //---> Patch added
    std::wstring wpattern = s2ws(pattern);
    
    WIN32_FIND_DATA find_data;
    HANDLE find_handle = FindFirstFile(wpattern.c_str(), &find_data);
    if (find_handle == INVALID_HANDLE_VALUE) {
      continue;
    }
    do {
      // ignore directories
      if ((find_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
        continue;
      }

      // ignore files starting with a dot
      if (find_data.cFileName[0] == '.') {
        continue;
      }

      //---> Patch added
      if (resources.find(ws2s(find_data.cFileName)) == resources.end())
      {
          resources[ws2s(find_data.cFileName)] = base_path;
      }
       
    } while (FindNextFile(find_handle, &find_data));
    FindClose(find_handle);
#endif
  }
  return resources;
}

Then I was able to compile the nuget package for the /x64 architecture with no additional issues (just a warnings related to the googletest library), generating the file "Microsoft.ROS.MRTK.Foxy.x64.0.1.0.nupkg".

By looking at the uwp_cpp sample, I installed the generated nuget package and compiling for the /x64 architecture (using Visual Studio 2019) with no issues. Nevertheless, I get the following execution error when I try to run the uwp_cpp sample:

Exception thrown at 0x00007FFE7BC34F69 in uwp_cpp.exe: Microsoft C++ exception: rclcpp::exceptions::InvalidNodeNameError at memory location 0x0000008AB25FA820.

which is produced when an instance of the subscriber is created.

auto minSubscriber = std::make_shared<MinimalSubscriber>();

the error, is also produced if I try to create a simple ros2 node instance:

rclcpp::Node* node = new rclcpp::Node("node");

I also tried to generate the nuget using different architectures (/x86) and different Windows 10 machines (for debug and release modes), but the same error still persists.

Is there any clue of how to solve this problem?. I really appreciate any help.

Thanks in advance for your response!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant