From: Walter Fetter Lages Date: Thu, 12 Jun 2025 07:13:31 +0000 (-0300) Subject: Port to Jazzy. X-Git-Url: http://git.ece.ufrgs.br/?a=commitdiff_plain;p=nonsmooth_backstep_controller.git Port to Jazzy. --- diff --git a/include/nonsmooth_backstep_controller/nonsmooth_backstep_controller.hpp b/include/nonsmooth_backstep_controller/nonsmooth_backstep_controller.hpp index 629f788..35d19e2 100644 --- a/include/nonsmooth_backstep_controller/nonsmooth_backstep_controller.hpp +++ b/include/nonsmooth_backstep_controller/nonsmooth_backstep_controller.hpp @@ -1,7 +1,7 @@ /****************************************************************************** ROS 2 nonsmooth_backstep_controller Package Non-Smooth Backstepping Controller - Copyright (C) 2014..2022 Walter Fetter Lages + Copyright (C) 2014..2025 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,8 +28,8 @@ #include #include -#include -#include +#include +#include #include #include diff --git a/src/nonsmooth_backstep_controller.cpp b/src/nonsmooth_backstep_controller.cpp index 82dec52..3d318dc 100644 --- a/src/nonsmooth_backstep_controller.cpp +++ b/src/nonsmooth_backstep_controller.cpp @@ -1,7 +1,7 @@ /****************************************************************************** ROS 2 nonsmooth_backstep_controller Package Non-Smooth Backstepping Controller - Copyright (C) 2014..2022 Walter Fetter Lages + Copyright (C) 2014..2025 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 @@ -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()) {