From b48bb23ea25cd3627cfcbc2a363b0063c44509db Mon Sep 17 00:00:00 2001 From: Bijou Abraham Date: Sat, 13 Sep 2025 18:51:40 -0700 Subject: [PATCH 1/2] Add class loader member variable instead of creating on stack --- moveit_ros/moveit_servo/include/moveit_servo/servo.hpp | 3 +++ moveit_ros/moveit_servo/src/servo.cpp | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/moveit_ros/moveit_servo/include/moveit_servo/servo.hpp b/moveit_ros/moveit_servo/include/moveit_servo/servo.hpp index 88a8f91665..28d5627cee 100644 --- a/moveit_ros/moveit_servo/include/moveit_servo/servo.hpp +++ b/moveit_ros/moveit_servo/include/moveit_servo/servo.hpp @@ -229,6 +229,9 @@ class Servo std::atomic collision_velocity_scale_ = 1.0; std::unique_ptr collision_monitor_; + // Plugin loader + std::unique_ptr> smoother_loader_; + // Pointer to the (optional) smoothing plugin. pluginlib::UniquePtr smoother_ = nullptr; diff --git a/moveit_ros/moveit_servo/src/servo.cpp b/moveit_ros/moveit_servo/src/servo.cpp index c62488660f..777dad4b2f 100644 --- a/moveit_ros/moveit_servo/src/servo.cpp +++ b/moveit_ros/moveit_servo/src/servo.cpp @@ -139,9 +139,9 @@ void Servo::setSmoothingPlugin() // Load the smoothing plugin try { - pluginlib::ClassLoader smoothing_loader( - "moveit_core", "online_signal_smoothing::SmoothingBaseClass"); - smoother_ = smoothing_loader.createUniqueInstance(servo_params_.smoothing_filter_plugin_name); + smoother_loader_ = std::make_unique>( + "moveit_core", "online_signal_smoothing::SmoothingBaseClass"); + smoother_ = smoother_loader_->createUniqueInstance(servo_params_.smoothing_filter_plugin_name); } catch (pluginlib::PluginlibException& ex) { From 6becd9d28175c04c151c07bba7e1a5d03d7b169a Mon Sep 17 00:00:00 2001 From: AndyZe Date: Sun, 14 Sep 2025 09:59:26 -0500 Subject: [PATCH 2/2] Fix formatting to satisfy clang --- moveit_ros/moveit_servo/src/servo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/moveit_ros/moveit_servo/src/servo.cpp b/moveit_ros/moveit_servo/src/servo.cpp index 777dad4b2f..22917e7bb5 100644 --- a/moveit_ros/moveit_servo/src/servo.cpp +++ b/moveit_ros/moveit_servo/src/servo.cpp @@ -140,7 +140,7 @@ void Servo::setSmoothingPlugin() try { smoother_loader_ = std::make_unique>( - "moveit_core", "online_signal_smoothing::SmoothingBaseClass"); + "moveit_core", "online_signal_smoothing::SmoothingBaseClass"); smoother_ = smoother_loader_->createUniqueInstance(servo_params_.smoothing_filter_plugin_name); } catch (pluginlib::PluginlibException& ex)