iRobotEducation / create3_examples

Example nodes to drive the iRobot® Create® 3 Educational Robot
BSD 3-Clause "New" or "Revised" License
51 stars 12 forks source link

Building on Windows #52

Open scottcandy34 opened 4 months ago

scottcandy34 commented 4 months ago

So I am simply trying out RoboStack on windows 10; to see if I can use ROS on windows effectively. So far building packages irobot_create_msgs and all packages of create3_examples except for create3_coverage builds without errors. I installed ros2 humble using RoboStack and it works great so far.

The first error is this:

C:\***\irobot_create\src\create3_examples\create3_coverage\src\coverage_state_machine.cpp(214,48): error C2065: 'M_PI': undeclared identifier [C:\***\irobot_create\build\create3_coverage\create3_coverage_core.vcxproj]
C:\***\irobot_create\src\create3_examples\create3_coverage\src\coverage_state_machine.cpp(214,55): error C2065: 'M_PI': undeclared identifier [C:\***\irobot_create\build\create3_coverage\create3_coverage_core.vcxproj]

Which after doing my research is a common windows building issue and is fixable by adding #define _USE_MATH_DEFINES to the top of the file coverage_state_machine.cpp this tells windows cmake that M_PI is defined and not undeclared.

after that is fixed a second error appears:

create3_coverage_core.vcxproj -> C:\***\irobot_create\build\create3_coverage\Release\create3_coverage_core.dll
  Building Custom Rule C:/***/irobot_create/src/create3_examples/create3_coverage/CMakeLists.txt
  main.cpp
LINK : fatal error LNK1181: cannot open input file 'Release\create3_coverage_core.lib' [C:\***\irobot_create\build\create3_coverage\create3_coverage.vcxproj]

This is another very specific building bug. It builds the .dll file just fine but is missing the .lib file which causes this error when it tries to run target_link_libraries(). After endless digging to fine the problem. I added this line (set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)) above the add_library. Once added it builds without errors.

I verify it works by running call install\local_setup.bat in the CMD window for the project directory. Then run this command ros2 run create3_coverage create3_coverage from the readme.

(ros_env) C:\***\irobot_create>ros2 run create3_coverage create3_coverage
[INFO] [1707502413.216754600] [create3_coverage]: Node created!

So it works lol. The point I'm getting at is could you review this 2 changes and possibly add them to the codebase so for those that might wish to run on windows will not have issues building. Of course if necessary add checks so they only get added for windows builds.

I built using this colcon build --cmake-args -DPython3_FIND_VIRTUALENV="ONLY" this forces it to use the specific python from the RoboStack; which is very important.

So far so good I'll be able to control the BOT from windows without much problems now.