[Bug] [Bug] Unit7 - Loading controller

This is an error report.


Screenshot of the error


Error details

After following the Unit 7 without problems, the final steps ended up in the error in the image. Gazebo was launched, but when the robot is spawned, the gazebo terminal gives this error. I have checked, and PLUGINLIB_EXPORT_CLASS is at the end of the file. I have revisited all the files, re-copied them, restarted all the terminals, but the error continues. Any suggestions? Thank you!

Hi @clusher ,

I think you are missing a dependency either in your CMakeLists.txt file or package.xml file or in both.
If you could post your CMakeLists.txt, package.xml and the controller config yaml file here, that would be helpful to debug your issue.
Also, please post your file contents as pre-formatted text (markdown formatted code-block). Otherwise it will be hard to read and debug your issue.

Regards,
Girish

Here are the requested files. Altought I believe I copied them from the Unit book, maybe I missed something.

CMakeLists.txt:

cmake_minimum_required(VERSION 3.5)
project(rrbot_controller)

# Default to C++14
if(NOT CMAKE_CXX_STANDARD)
  set(CMAKE_CXX_STANDARD 14)
endif()

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  add_compile_options(-Wall -Wextra -Wpedantic)
endif()

# find dependencies
find_package(ament_cmake REQUIRED)
find_package(control_msgs REQUIRED)
find_package(controller_interface REQUIRED)
find_package(hardware_interface REQUIRED)
find_package(pluginlib REQUIRED)
find_package(rclcpp REQUIRED)
find_package(rclcpp_lifecycle REQUIRED)
find_package(realtime_tools REQUIRED)
find_package(example_interfaces REQUIRED)

add_library(
  rrbot_controller
  SHARED
  src/rrbot_controller.cpp
)
target_include_directories(
  rrbot_controller
  PUBLIC
  $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
  $<INSTALL_INTERFACE:include>
)
ament_target_dependencies(
  rrbot_controller
  control_msgs
  controller_interface
  hardware_interface
  pluginlib
  rclcpp
  rclcpp_lifecycle
  realtime_tools
)
# prevent pluginlib from using boost
target_compile_definitions(rrbot_controller PUBLIC "PLUGINLIB__DISABLE_BOOST_FUNCTIONS")

pluginlib_export_plugin_description_file(
  controller_interface rrbot_controller.xml)

install(
  TARGETS
  rrbot_controller
  RUNTIME DESTINATION bin
  ARCHIVE DESTINATION lib
  LIBRARY DESTINATION lib
)

install(
  DIRECTORY include/
  DESTINATION include
)

ament_export_include_directories(
  include
)
ament_export_libraries(
  rrbot_controller
)
ament_export_dependencies(
  control_msgs
  controller_interface
  hardware_interface
  pluginlib
  rclcpp
  rclcpp_lifecycle
  realtime_tools
)

ament_package()

package.xml

<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
  <name>rrbot_controller</name>
  <version>0.0.0</version>

  <description>Controller for exemplary RRBot robot.</description>

  <maintainer email="bence.magyar.robotics@gmail.com">Bence Magyar</maintainer>
  <maintainer email="denis@stogl.de">Denis Štogl</maintainer>

  <license>Apache License 2.0</license>

  <buildtool_depend>ament_cmake</buildtool_depend>

  <depend>control_msgs</depend>
  <depend>controller_interface</depend>
  <depend>hardware_interface</depend>
  <depend>pluginlib</depend>
  <depend>rclcpp</depend>
  <depend>rclcpp_lifecycle</depend>
  <depend>realtime_tools</depend>
  <depend>example_interfaces</depend>

  <test_depend>ament_cmake_gmock</test_depend>
  <test_depend>controller_manager</test_depend>
  <test_depend>hardware_interface</test_depend>
  <test_depend>ros2_control_test_assets</test_depend>

  <export>
    <build_type>ament_cmake</build_type>
  </export>
</package>

rrbot_controllers_custom.yaml:

# Controller manager configuration
controller_manager:
  ros__parameters:
    update_rate: 50  # Hz

    # Define a name for controllers that we plan to use
    joint_state_broadcaster:
      type: joint_state_broadcaster/JointStateBroadcaster

    rrbot_controller:
      type: rrbot_controller/RRBotController

# Properties of the custom controler and definition of joints to use
rrbot_controller:
  ros__parameters:
    joints:
      - joint1
      - joint2
    interface_name: 
        position

Hi,
I have checked your code and I can see two things:

  1. This kind of error (undefined symbol) usually happens when there is a problem with previous compilations which are mixing with the new ones. If this error happens to you, first thing is to delete the build and install directories and recompile from zero. Then try again. If the error still persists, then there is a problem with the libraries you need to be including.

I think in your case is just a compilation mixing. So I cleared your build and install and recompiled.

  1. Then after recompilation the error is different:
[gzserver-1] [INFO] [1713860746.099790429] [gazebo_ros2_control]: Loading parameter file /home/user/ros2_ws/install/rrbot_controller/share/rrbot_controller/config/rrbot_controllers_custom.yaml
[gzserver-1]
[gzserver-1] [ERROR] [1713860746.102681891] [gazebo_ros2_control]: parser error Couldn't parse params file: '--params-file /home/user/ros2_ws/install/rrbot_controller/share/rrbot_controller/config/rrbot_controllers_custom.yaml'. Error: Error opening YAML file, at /tmp/binarydeb/ros-galactic-rcl-yaml-param-parser-3.1.2/src/parser.c:270, at /tmp/binarydeb/ros-galactic-rcl-3.1.2/src/rcl/arguments.c:406

So you have an error in the configuration yaml file.

If you do an ls you will find that:

user:~$ ls /home/user/ros2_ws/install/rrbot_controller/share/rrbot_controller/config/rrbot_controllers_custom.yaml
ls: cannot access '/home/user/ros2_ws/install/rrbot_controller/share/rrbot_controller/config/rrbot_controllers_custom.yaml': No such file or directory

So your yaml config file is not being installed in the install directory. That is a problem with your CMakeLists.txt file. Please modify that file so the config file is installed and let me know if that works or still more problems there

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.