From: Walter Fetter Lages Date: Tue, 8 Sep 2026 06:18:41 +0000 (-0300) Subject: Port to Lyrical. X-Git-Url: http://git.ece.ufrgs.br/?a=commitdiff_plain;h=47d24dcf4051ab56dcec478eac9d7b51684962c8;p=pid_plus_gravity_controller.git Port to Lyrical. --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 2d5ff5a..82a7fa2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.8) +cmake_minimum_required(VERSION 3.20) project(pid_plus_gravity_controller) if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") @@ -20,22 +20,20 @@ find_package(orocos_kdl REQUIRED) find_package(realtime_tools REQUIRED) add_library(pid_plus_gravity_controller SHARED src/pid_plus_gravity_controller.cpp) -target_compile_features(pid_plus_gravity_controller PUBLIC c_std_99 cxx_std_17) # Require C99 and C++17 -target_include_directories(pid_plus_gravity_controller PRIVATE - $ - $) -ament_target_dependencies( +target_compile_features(pid_plus_gravity_controller PUBLIC c_std_17 cxx_std_20) # Require C17 and C++20 +target_include_directories(pid_plus_gravity_controller PRIVATE include) +target_link_libraries( pid_plus_gravity_controller - "rclcpp" - "controller_interface" - "controller_manager" - "control_toolbox" - "trajectory_msgs" - "control_msgs" - "urdf" - "kdl_parser" - "orocos_kdl" - "realtime_tools" + ${rclcpp_TARGETS} + ${controller_interface_TARGETS} + ${controller_manager_TARGETS} + ${control_toolbox_TARGETS} + ${trajectory_msgs_TARGETS} + ${control_msgs_TARGETS} + ${urdf_TARGETS} + ${kdl_parser_TARGETS} + ${orocos_kdl_TARGETS} + ${realtime_tools_TARGETS} ) # Causes the visibility macros to use dllexport rather than dllimport, diff --git a/include/pid_plus_gravity_controller/pid_plus_gravity_controller.hpp b/include/pid_plus_gravity_controller/pid_plus_gravity_controller.hpp index 4d689f4..eba2e1d 100644 --- a/include/pid_plus_gravity_controller/pid_plus_gravity_controller.hpp +++ b/include/pid_plus_gravity_controller/pid_plus_gravity_controller.hpp @@ -1,7 +1,7 @@ /****************************************************************************** ROS 2 pid_plus_gravity_controller Package PID+Gravity Compensation Controller - Copyright (C) 2017..2025 Walter Fetter Lages + Copyright (C) 2017..2026 Walter Fetter Lages This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -36,7 +36,7 @@ #include -namespace effort_controllers +namespace pid_plus_gravity_controller { class PidPlusGravityController: public controller_interface::ControllerInterface { diff --git a/package.xml b/package.xml index 2912fbd..5f58dec 100644 --- a/package.xml +++ b/package.xml @@ -2,7 +2,7 @@ pid_plus_gravity_controller - 2.1.0 + 2.2.0 A PID controller with gravity compensation Walter Fetter Lages GPL-3.0-only diff --git a/pid_plus_gravity_controller_plugin.xml b/pid_plus_gravity_controller_plugin.xml index dcedd9d..feedde0 100644 --- a/pid_plus_gravity_controller_plugin.xml +++ b/pid_plus_gravity_controller_plugin.xml @@ -1,6 +1,6 @@ - The PidPlusGravityController implements a PID controller with gravity diff --git a/src/pid_plus_gravity_controller.cpp b/src/pid_plus_gravity_controller.cpp index eb4a4ba..1db6478 100644 --- a/src/pid_plus_gravity_controller.cpp +++ b/src/pid_plus_gravity_controller.cpp @@ -1,7 +1,7 @@ /****************************************************************************** ROS 2 pid_plus_gravity_controller Package PID+Gravity Compensation Controller - Copyright (C) 2017..2025 Walter Fetter Lages + Copyright (C) 2017..2026 Walter Fetter Lages This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,7 +28,7 @@ #include -namespace effort_controllers +namespace pid_plus_gravity_controller { PidPlusGravityController::PidPlusGravityController(void): q_(0),qr_(0),gravity_(0),referencePoint_(nullptr) @@ -59,10 +59,11 @@ namespace effort_controllers rclcpp::QoS qos(rclcpp::KeepLast(1)); qos.transient_local(); auto robotDescriptionSubscriber=get_node()->create_subscription("robot_description",qos,std::bind(&PidPlusGravityController::robotDescriptionCB,this,std::placeholders::_1)); + rclcpp::executors::SingleThreadedExecutor executor; while(robotDescription_.empty()) { RCLCPP_WARN_SKIPFIRST_THROTTLE(get_node()->get_logger(),*get_node()->get_clock(),1000,"Waiting for robot model on /robot_description."); - rclcpp::spin_some(get_node()->get_node_base_interface()); + executor.spin_node_some(get_node()->get_node_base_interface()); } return controller_interface::CallbackReturn::SUCCESS; @@ -83,7 +84,7 @@ namespace effort_controllers { for(const auto &joint : jointNames_) { - auto pid=std::make_shared(get_node(),joint); + auto pid=std::make_shared(get_node(),joint,joint); pid->initialize_from_ros_parameters(); pid_.push_back(pid); } @@ -226,4 +227,4 @@ namespace effort_controllers } } -PLUGINLIB_EXPORT_CLASS(effort_controllers::PidPlusGravityController,controller_interface::ControllerInterface) +PLUGINLIB_EXPORT_CLASS(pid_plus_gravity_controller::PidPlusGravityController,controller_interface::ControllerInterface)