How to add shared Library (/usr/local/lib) and colcon build
OS: Ubuntu20.04 arch: x86-64 dist:ROS2 Galactic device: Odyssey X86 J4125
I would like to use c-periphery to control GPIO from a ROS node. Please help me as I am failing to build it in any way.
The shared library of c-periphery is created in /usr/local/lib/libperiphery.so. When I build it, I get an error in the function gpio_new() which is a function in c-periphery.
ERROR CODE
--- stderr: robot_controller
/usr/bin/ld: CMakeFiles/interface_controller.dir/src/interface_controller.cpp.o: in function `InterfaceController::InterfaceController(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
/opt/fig/chaser_ros2/src/robot_controller/src/interface_controller.cpp:160: undefined reference to `gpio_new'
CMakeListes
cmake_minimum_required(VERSION 3.5)
project(robot_controller)
unset( CATKIN_INSTALL_INTO_PREFIX_ROOT )
find_package(ament_cmake_auto REQUIRED)
ament_auto_find_build_dependencies()
add_definitions(-DPERIPHERY_GPIO_CDEV_SUPPORT=true)
ament_auto_add_executable(interface_controller src/interface_controller.cpp )
ament_auto_add_executable(diff_drive_controller src/diff_drive_controller.cpp)
target_link_libraries (diff_drive_controller
modbus
)
if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
ament_lint_auto_find_test_dependencies()
endif()
ament_auto_package()
packges.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>robot_controller</name>
<version>0.0.0</version>
<description>TODO: Package description</description>
<maintainer email="tokumei">fig</maintainer>
<license>TODO: License declaration</license>
<buildtool_depend>ament_cmake</buildtool_depend>
<depend>ament_lint_auto</depend>
<depend>ament_lint_common</depend>
<depend>rclcpp</depend>
<depend>gpio</depend>
<depend>rclcpp_components</depend>
<depend>std_msgs</depend>
<depend>geometry_msgs</depend>
<depend>nav_msgs</depend>
<depend>nav2_msgs</depend>
<depend>tf2</depend>
<depend>tf2_ros</depend>
<depend>tf2_geometry_msgs</depend>
<depend>chaser_msgs</depend>
<depend>caos_msgs</depend>
<depend>OpenCV</depend>
<depend>periphery</depend>
<depend>common_pkg</depend>
<depend>ament_cmake_auto</depend>
<depend>modbus</depend>
<export>
<build_type>ament_cmake</build_type>
</export>
</package>
Asked by hamada on 2022-08-11 00:45:40 UTC
Comments
this errror code gpio_t *gpio_in= gpio_new();
Asked by hamada on 2022-08-11 00:46:40 UTC