ros-controls / ros2_control

Generic and simple controls framework for ROS 2
https://control.ros.org
Apache License 2.0
515 stars 307 forks source link

Build failure from source: controller_manager: ```‘TEST_ACTUATOR_HARDWARE_PLUGIN_NAME’ has not been declared in ‘ros2_control_test_assets'``` #1787

Closed Mechazo11 closed 1 month ago

Mechazo11 commented 1 month ago

Describe the bug Hello,

I am building ros2 jazzy from source in Ubuntu 22.04 and added the ros2_control package using the following

ros2_control:
  type: git
  url: https://github.com/ros-controls/ros2_control.git
  version: master

The error I am encountering is with the controller_manager package which shows the following

/home/tigerwife/ubuntu22_jazzy_ws/src/ros2_control/controller_manager/test/test_hardware_management_srvs.cpp:41:33: error: ‘TEST_ACTUATOR_HARDWARE_PLUGIN_NAME’ has not been declared in ‘ros2_control_test_assets’
   41 | using ros2_control_test_assets::TEST_ACTUATOR_HARDWARE_PLUGIN_NAME;
      |                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/tigerwife/ubuntu22_jazzy_ws/src/ros2_control/controller_manager/test/test_hardware_management_srvs.cpp:46:33: error: ‘TEST_SENSOR_HARDWARE_PLUGIN_NAME’ has not been declared in ‘ros2_control_test_assets’
   46 | using ros2_control_test_assets::TEST_SENSOR_HARDWARE_PLUGIN_NAME;
      |                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/tigerwife/ubuntu22_jazzy_ws/src/ros2_control/controller_manager/test/test_hardware_management_srvs.cpp:51:33: error: ‘TEST_SYSTEM_HARDWARE_PLUGIN_NAME’ has not been declared in ‘ros2_control_test_assets’
   51 | using ros2_control_test_assets::TEST_SYSTEM_HARDWARE_PLUGIN_NAME;
      |                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/tigerwife/ubuntu22_jazzy_ws/src/ros2_control/controller_manager/test/test_hardware_management_srvs.cpp: In member function ‘void TestControllerManagerHWManagementSrvs::list_hardware_components_and_check(const std::vector<unsigned char, std::allocator<unsigned char> >&, const std::vector<std::__cxx11::basic_string<char> >&, const std::vector<std::vector<std::vector<bool, std::allocator<bool> > > >&, const std::vector<std::vector<std::vector<bool, std::allocator<bool> > > >&)’:
/home/tigerwife/ubuntu22_jazzy_ws/src/ros2_control/controller_manager/test/test_hardware_management_srvs.cpp:138:11: error: ‘TEST_ACTUATOR_HARDWARE_PLUGIN_NAME’ was not declared in this scope; did you mean ‘TEST_ACTUATOR_HARDWARE_NAME’?
  138 |           TEST_ACTUATOR_HARDWARE_PLUGIN_NAME, hw_state_ids[0], hw_state_labels[0]);
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |           TEST_ACTUATOR_HARDWARE_NAME
/home/tigerwife/ubuntu22_jazzy_ws/src/ros2_control/controller_manager/test/test_hardware_management_srvs.cpp:150:11: error: ‘TEST_SENSOR_HARDWARE_PLUGIN_NAME’ was not declared in this scope; did you mean ‘TEST_SENSOR_HARDWARE_NAME’?
  150 |           TEST_SENSOR_HARDWARE_PLUGIN_NAME, hw_state_ids[1], hw_state_labels[1]);
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |           TEST_SENSOR_HARDWARE_NAME
/home/tigerwife/ubuntu22_jazzy_ws/src/ros2_control/controller_manager/test/test_hardware_management_srvs.cpp:162:11: error: ‘TEST_SYSTEM_HARDWARE_PLUGIN_NAME’ was not declared in this scope; did you mean ‘TEST_SYSTEM_HARDWARE_NAME’?
  162 |           TEST_SYSTEM_HARDWARE_PLUGIN_NAME, hw_state_ids[2], hw_state_labels[2]);
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |           TEST_SYSTEM_HARDWARE_NAME
gmake[2]: *** [CMakeFiles/test_hardware_management_srvs.dir/build.make:76: CMakeFiles/test_hardware_management_srvs.dir/test/test_hardware_management_srvs.cpp.o] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:635: CMakeFiles/test_hardware_management_srvs.dir/all] Error 2
gmake: *** [Makefile:146: all] Error 2
---

Expected behavior All packages in ros2_control to build without any issues.

Environment (please complete the following information):

Additional context I am building a ROS 2 Jazzy workspace to integrate Gazebo Harmonic using the concept of overlaying ros workspaces in Ubuntu 22.04.

christophfroehlich commented 1 month ago

Have you installed older binaries of ros2_control* on your Ubuntu 22.04 (humble, iron)? Have you built the ros2_control_test_assets? (with colcon build --packages-up-to ros2_control for example)

Mechazo11 commented 1 month ago

Hi @christophfroehlich 1) Yes it may be the case. But to account for this, I made sure my terminal does not source the base ros2 humble workspace. 2) Haven't tried the second option, will give it a shot and report back

Mechazo11 commented 1 month ago

@christophfroehlich in the ros2_control_test_assets/descriptions.hpp I noticed the following

[[maybe_unused]] const std::string TEST_ACTUATOR_HARDWARE_NAME = "TestActuatorHardware";
[[maybe_unused]] const std::string TEST_ACTUATOR_HARDWARE_TYPE = "actuator";
[[maybe_unused]] const std::string TEST_ACTUATOR_HARDWARE_PLUGIN_NAME = "test_actuator";
[[maybe_unused]] const std::vector<std::string> TEST_ACTUATOR_HARDWARE_COMMAND_INTERFACES = {
  "joint1/position", "joint1/max_velocity"};
[[maybe_unused]] const std::vector<std::string> TEST_ACTUATOR_HARDWARE_STATE_INTERFACES = {
  "joint1/position", "joint1/velocity", "joint1/some_unlisted_interface"};

From this stackexchange post the [[maybe_unused]] keyword is mostly helpful if a variable is potentially not used anymore but from the problem above, it clearly is being used.

Could this keyword maybe the cause of this build failure?

Mechazo11 commented 1 month ago

@christophfroehlich I got ros2_control branch to build without any issues. Apparently the your first point was correct, there was a conflict between my global ROS 2 Humble and ROS 2 Jazzy workspaces. When I ensured that the global workspace is not sourced, ros2_control built without any issues. Closing this issue for now.