ms-iot / ROSOnWindows

ROS on Windows Documentation Repository
https://aka.ms/ros/docs
MIT License
212 stars 48 forks source link

[Humble] Include ROS2 Humble in a VISUAL STUDIO 2019 C++ application #374

Open HectorPenades opened 2 years ago

HectorPenades commented 2 years ago

Hello,

I am trying to include ROS2 in a project created from VISUAL STUDIO 2019. Is it possible to include the ROS2 libraries in VS2019, can I compile the project with ROS2 from VS2019? I need to be able to publish and subscribe to topics from a program developed in C++ from VISUAL STUDIO 2019. Do you know any solution?

Is there a way to include ROS2 functionalities in my VISUAL STUDIO 2019 project? How I have to configure the properties of the project?

Thanks,

ROS2 Version: GALACTIC Type of installation: Windows (source)

Thanks

ooeygui commented 2 years ago

Hi @HectorPenades , Thank you for your interest in ROS2 and Windows.

For the ROS2 on Hololens project, we have a packaging of ROS2, which allows you to pub/sub (and eventually Services and Actions). It is packaged as a nuget and Unity package - (https://github.com/ms-iot/ros_msft_mrtk_native/releases).

There are releases for x64 Desktop and arm64 UWP. (To support Hololens development).

I'm going to leave this item open as I would love to make this officially supported.

HectorPenades commented 2 years ago

Hi @ooeygui This is so interesting but it is not what i am searching. I need to know how to configure the properties of C++ VS2019 project to use ROS2 Galactic.

I see this issue similar as mine: https://github.com/ms-iot/ROSOnWindows/issues/310

I need to do something similar as: https://github.com/ItsMeTheBee/VisualStudioROS

This example works for me with ROS2 foxy but when i try to configure my new project with ROS2 galactic y have some problems I am trying to configure the project how he is telling :

In a developer command prompt for vs 2019 source ROS and open VS with "devenv C/C++ > Additional Include Directories = C:\dev\ros2_galactic\include Linker > Additional Library Directories = C:\dev\ros2_galactic\Lib Linker > Input > Additional Dependencies = all .lib files in C:\dev\ros2_galactic\Lib "C:\dev\ros2_galactic\Lib*.lib" //Copied all .dll files to output (it is not needed) Using Release x64

After that I am trying to include: #include "rclcpp/rclcpp.hpp" but i have some problems... How I say if i make the same with ROS2 foxy it works for write a simple publisher in VS2019 C++

Estándar ISO C++14 (/std:c++14) Visual Studio 2019 (v142) Windows 10. Console Application C++

image

ooeygui commented 2 years ago

I'm not quite sure what the error message says, but I suspect it can't find std - did you include appropriate headers before rclcpp.h?

traversaro commented 2 years ago

I am not sure, but I suspect ROS2 Headers requires C++17 and the project is compiled with C++14 .

HectorPenades commented 2 years ago

Hello,

Forst of all, thanks for your comments.

Yes, I had tried to configure the project both ways. I have configured the project with c++17. But I keep getting compilation error: 'type' is not a memer of 'std' in service.hpp

image

image image

Estándar ISO C++17 (/std:c++17) Visual Studio 2019 (v142) Windows 10. Console Application C++ ROS2 Galactic

HectorPenades commented 2 years ago

If I modify the file of ros2 C:\ROS2\Galactic\include\rclcpp\service.hpp and delete de conflictive lines it works

image

image

ooeygui commented 1 year ago

Changing title since Galactic is EOL