0

I know there are many questions about this error specifically but I don't find a solution. I triple checked the names that I have used to define macros and the plugin a I think I have them well defined, so I guess I'm missing something here. I did a controller before with no problems and now the main difference is that I want to have 2 controllers to choose instead of 1. So, every time I launch the effort controllers this log appears:

[ERROR] [1675151078.128963342, 4.702000000]: Could not load class 'my_position_controller/MyEffortPositionController': Failed to load library /home/mikel/twodofrobot/devel/lib//libmy_position_controller_lib.so. 
Make sure that you are calling the PLUGINLIB_EXPORT_CLASS macro in the library code, and that names are consistent between this macro and your XML. 
Error string: Could not load library (Poco exception = /home/mikel/twodofrobot/devel/lib//libmy_position_controller_lib.so: undefined symbol: _ZN22my_position_controller26MyEffortPositionController8stoppingERKN3ros4TimeE)

[ERROR] [1675151078.129065115, 4.702000000]: Could not load controller 'joint_effort_position_controller' because controller type 'my_position_controller/MyEffortPositionController' does not exist.

[ERROR] [1675151078.129110615, 4.702000000]: Use 'rosservice call controller_manager/list_controller_types' to get the available types

Here the macro code for both controllers:

PLUGINLIB_EXPORT_CLASS(my_position_controller::MyEffortPositionController,controller_interface::ControllerBase)

PLUGINLIB_EXPORT_CLASS(my_position_controller::MyJointPositionController, controller_interface::ControllerBase)

The export at package.xml

 <export>
    <!-- Other tools can request additional information be placed here -->
      <controller_interface plugin="${prefix}/my_position_controller_plugin.xml"/>
 </export>

my plugin.xml


<library path="lib/libmy_position_controller_lib">

  <class name="my_position_controller/MyEffortPositionController" 
        type="my_position_controller::MyEffortPositionController" 
        base_class_type="controller_interface::ControllerBase">
    <description>
      a PID simple controller with effort
    </description>
  </class>

  <class name="my_position_controller/MyJointPositionController" 
        type="my_position_controller::MyJointPositionController" 
        base_class_type="controller_interface::ControllerBase">
    <description>
      a PID simple controller
    </description>
  </class>
</library>

my Cmakelist:

add_compile_options(-std=c++11)
add_library(my_position_controller_lib src/my_effort_position_controller.cpp
                                       src/my_joint_position_controller.cpp)

target_link_libraries(my_position_controller_lib ${catkin_LIBRARIES})

Here is my config file:

rrbot: 
  joint_state_controller: 
  type: joint_state_controller/JointStateController 
  publish_rate: 50

  joint_effort_position_controller:
    type: my_position_controller/MyEffortPositionController
    joint:
        - joint1
        - joint2
    kp: 
      - 10
      - 10
    kd: 
      - 1
      - 1
    ki: 
      - 0.1
      - 0.1

I see in the log something strange with the directories of the library but I'm not sure how to fix it. /home/mikel/twodofrobot/devel/lib**//**libmy_position_controller_lib.so. double slash is ok?

Thanks in advance!

I tried changing names for the library, namespace and class names but is not working

MIKEL LASS
  • 11
  • 3

1 Answers1

0

is the name of your ROS package "my_position_controller"? If yes, put it in the CMakelist it (instead of what you reported above):

add_compile_options(-std=c++11)
add_library(my_position_controller src/my_effort_position_controller.cpp
                                   src/my_joint_position_controller.cpp)

target_link_libraries(my_position_controller ${catkin_LIBRARIES})

MadBot97
  • 1
  • 1