Port to Jazzy. jazzy
authorWalter Fetter Lages <w.fetter@ieee.org>
Thu, 12 Jun 2025 07:13:31 +0000 (04:13 -0300)
committerWalter Fetter Lages <w.fetter@ieee.org>
Thu, 12 Jun 2025 07:13:31 +0000 (04:13 -0300)
include/nonsmooth_backstep_controller/nonsmooth_backstep_controller.hpp
src/nonsmooth_backstep_controller.cpp

index 629f788..35d19e2 100644 (file)
@@ -1,7 +1,7 @@
 /******************************************************************************
                    ROS 2 nonsmooth_backstep_controller Package
                      Non-Smooth Backstepping Controller
-          Copyright (C) 2014..2022 Walter Fetter Lages <w.fetter@ieee.org>
+          Copyright (C) 2014..2025 Walter Fetter Lages <w.fetter@ieee.org>
 
         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,8 +28,8 @@
 #include <tf2_msgs/msg/tf_message.hpp>
 
 #include <controller_interface/controller_interface.hpp>
-#include <realtime_tools/realtime_buffer.h>
-#include <realtime_tools/realtime_publisher.h>
+#include <realtime_tools/realtime_buffer.hpp>
+#include <realtime_tools/realtime_publisher.hpp>
 
 #include <arc_odometry/diff_odometry.hpp>
 #include <nonsmooth_backstep_controller_msgs/msg/non_smooth_backstep_controller_status.hpp>
index 82dec52..3d318dc 100644 (file)
@@ -1,7 +1,7 @@
 /******************************************************************************
                   ROS 2 nonsmooth_backstep_controller Package
                      Non-Smooth Backstepping Controller
-          Copyright (C) 2014..2022 Walter Fetter Lages <w.fetter@ieee.org>
+          Copyright (C) 2014..2025 Walter Fetter Lages <w.fetter@ieee.org>
 
         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
@@ -211,7 +211,7 @@ namespace effort_controllers
                eta_.setZero();
                lastSamplingTime_=get_node()->get_clock()->now();
                for(unsigned int i=0;i < joints_.size();i++)
-                       phi_[i]=state_interfaces_[i].get_value();
+                       phi_[i]=state_interfaces_[i].get_optional().value_or(phi_[i]);
 
                 struct sched_param param;
                 param.sched_priority=priority_;
@@ -225,7 +225,8 @@ namespace effort_controllers
        CallbackReturn NonSmoothBackstepController::on_deactivate(const rclcpp_lifecycle::State &/*previous_state*/)
        {
                for(unsigned int i=0;i < joints_.size();i++)
-                       command_interfaces_[i].set_value(0);
+                       if(!command_interfaces_[i].set_value(0.0))
+                               RCLCPP_WARN(get_node()->get_logger(),"Failed to set value to command interface.");
 
                return CallbackReturn::SUCCESS;
        }
@@ -245,7 +246,7 @@ namespace effort_controllers
                // phi[1] is the right wheel angular displacement
                Eigen::Vector2d deltaPhi=-phi_;
                for(unsigned int i=0;i < joints_.size();i++)
-                       phi_[i]=state_interfaces_[i].get_value();
+                       phi_[i]=state_interfaces_[i].get_optional().value_or(phi_[i]);
                deltaPhi+=phi_;
 
                odom_.update(deltaPhi,dt);
@@ -330,7 +331,8 @@ namespace effort_controllers
 
                // Apply torques
                for(unsigned int i=0;i < joints_.size();i++)
-                       command_interfaces_[i].set_value(torque[i]);
+                       if(!command_interfaces_[i].set_value(torque[i]))
+                               RCLCPP_WARN(get_node()->get_logger(),"Failed to set value to command interface.");
 
                 if(rt_status_publisher_ && rt_status_publisher_->trylock())
                 {