pointcloud_to_laserscan icon indicating copy to clipboard operation
pointcloud_to_laserscan copied to clipboard

Package failed with error "C2065: 'M_PI': undeclared identifier"

Open XavierTrudeau opened this issue 4 years ago • 3 comments

I was trying to build this package and was getting "Package failed" with no error message. I'm using ROS2 Foxy on Windows 10 with Visual Studio 2019.

By using this command while building: colcon build --packages-select pointcloud_to_laserscan --event-handlers console_cohesion+

I was able to find this error : "error C2065: 'M_PI': undeclared identifier [C:\nav2_ws\build\pointcloud_to_laserscan\pointcloud_to_laserscan.vcxproj]"

I was able to build it by adding this line to "pointcloud_to_laserscan/pointcloud_to_laserscan_node.cpp" : #define M_PI 3.14159265358979323846

I hope this helps. I'm not sure if that was the right approach as I'm quite new to ROS!

Regards, Xavier Trudeau

XavierTrudeau avatar Sep 28 '21 21:09 XavierTrudeau

Probably it's because the behavior of _USE_MATH_DEFINES is different between gcc and msvc? :thinking: https://docs.microsoft.com/en-us/cpp/c-runtime-library/math-constants?view=msvc-160

kenji-miyake avatar Sep 29 '21 00:09 kenji-miyake

That's right. Adding these lines to the header file also fixed it. #define _USE_MATH_DEFINES // for C++ #include

I'm now getting a crash when trying to run the sample launch file. Both pointcloud_to_laserscan_node and laserscan_to_pointcloud_node crash upon launch :

[ERROR] [pointcloud_to_laserscan_node.EXE-3]: process has died [pid 7072, exit code 3221226505, cmd 'c:\nav2_ws\install\lib\pointcloud_to_laserscan\pointcloud_to_laserscan_node.EXE --ros-args -r __node:=pointcloud_to_laserscan -r __node:=pointcloud_to_laserscan --params-file C:\Users\xaviert\AppData\Local\Temp\launch_params_45izntrr -r cloud_in:=scanner/cloud -r scan:=scanner/scan'].

Any idea what could cause this?

XavierTrudeau avatar Sep 29 '21 14:09 XavierTrudeau

@XavierTrudeau a backtrace would surely help.

hidmic avatar Oct 13 '21 20:10 hidmic