ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

ros2 control - linking system libraries in hardware_interface

asked 2023-03-29 10:02:25 -0500

Adude gravatar image

I have a ros2 control hardware interface which outputs to the system GPIOs. I'm currently using the libgpiod library, although the exact library isn't relevant.

The library is installed in the system (header file and .so file) and I can compile and run test scripts for controlling the GPIOs using g++ outside of ros.

As far as I'm aware, hardware interfaces are just compiled to libraries then loaded dynamically? How do I make the ros2 controller link a system library like libgpiod when it runs this specific interface?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2023-04-03 08:41:34 -0500

Adude gravatar image

In case this helps anyone, the solution was to include the target_link_libraries CMake command. Something like:

add_library(
    drive_hw_if
    SHARED
    src/drive_hw_if.cpp
)

target_link_libraries(
    drive_hw_if
    libgpiodcxx
)

Then include the library in the package.xml with the system install command, ie libgpiod-dev.

edit flag offensive delete link more

Comments

Can you please share your cmake file, I am stuck here too linking the second library for GPIO as first library which is for motor controller works fine but linking the second causes errors. It would be helpful to reference it !

Ani gravatar image Ani  ( 2023-05-22 22:13:45 -0500 )edit

I've put my CMake on this "pastebin". I never managed to properly link the system dependencies using find_package (although it works in the package.xml) but the rest worked, which was good enough.

Adude gravatar image Adude  ( 2023-05-23 04:31:04 -0500 )edit

Thanks Adude.

Ani gravatar image Ani  ( 2023-05-23 07:49:24 -0500 )edit

Question Tools

3 followers

Stats

Asked: 2023-03-29 10:02:25 -0500

Seen: 379 times

Last updated: Apr 03 '23