Skip to content

Commit 252576c

Browse files
committed
Fixed goal tolerance, now it properly gets tolerance from navstate
1 parent 7cb2969 commit 252576c

2 files changed

Lines changed: 36 additions & 29 deletions

File tree

controllers/easynav_serest_controller/include/easynav_serest_controller/SerestController.hpp

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
// Copyright 2025 Intelligent Robotics Lab
22
//
33
// This file is part of the project Easy Navigation (EasyNav in short)
4-
// Licensed under the Apache License, Version 2.0 (the "License");
5-
// you may not use this file except in compliance with the License.
6-
// You may obtain a copy of the License at
4+
// licensed under the GNU General Public License v3.0.
5+
// See <http://www.gnu.org/licenses/> for details.
76
//
8-
// http://www.apache.org/licenses/LICENSE-2.0
7+
// Easy Navigation program is free software: you can redistribute it and/or modify
8+
// it under the terms of the GNU General Public License as published by
9+
// the Free Software Foundation, either version 3 of the License, or
10+
// (at your option) any later version.
911
//
10-
// Unless required by applicable law or agreed to in writing, software
11-
// distributed under the License is distributed on an "AS IS" BASIS,
12-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
// See the License for the specific language governing permissions and
14-
// limitations under the License.
12+
// This program is distributed in the hope that it will be useful,
13+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
// GNU General Public License for more details.
16+
//
17+
// You should have received a copy of the GNU General Public License
18+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1519

1620
#ifndef EASYNAV_SEREST_CONTROLLER__SERESTCONTROLLER_HPP_
1721
#define EASYNAV_SEREST_CONTROLLER__SERESTCONTROLLER_HPP_
@@ -216,7 +220,8 @@ class SerestController : public ControllerMethodBase
216220
const Vec2 & robot_xy, double robot_yaw,
217221
double & dist_xy_goal, double & e_theta_goal,
218222
double & stop_r, double & slow_r, double & gamma_slow,
219-
Vec2 & goal_xy, double & yaw_goal) const;
223+
Vec2 & goal_xy, double & yaw_goal,
224+
double goal_pos_tol) const;
220225

221226
// Calcula límites de seguridad globales (distancia obstáculo, v_safe, v_curv).
222227
void safety_limits(
@@ -238,7 +243,7 @@ class SerestController : public ControllerMethodBase
238243
bool maybe_final_align_and_publish(
239244
NavState & nav_state, const nav_msgs::msg::Path & path,
240245
double dist_xy_goal, double stop_r, double e_theta_goal,
241-
double gamma_slow, double dt);
246+
double gamma_slow, double dt, double goal_yaw_tol);
242247

243248
// Aplica rate‑limit y saturaciones finales sobre (vlin, vrot) y actualiza last_*.
244249
void rate_limit_and_saturate(double dt, double & vlin, double & vrot);

controllers/easynav_serest_controller/src/easynav_serest_controller/SerestController.cpp

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
// Copyright 2025 Intelligent Robotics Lab
22
//
33
// This file is part of the project Easy Navigation (EasyNav in short)
4-
// Licensed under the Apache License, Version 2.0 (the "License");
5-
// you may not use this file except in compliance with the License.
6-
// You may obtain a copy of the License at
4+
// licensed under the GNU General Public License v3.0.
5+
// See <http://www.gnu.org/licenses/> for details.
76
//
8-
// http://www.apache.org/licenses/LICENSE-2.0
7+
// Easy Navigation program is free software: you can redistribute it and/or modify
8+
// it under the terms of the GNU General Public License as published by
9+
// the Free Software Foundation, either version 3 of the License, or
10+
// (at your option) any later version.
911
//
10-
// Unless required by applicable law or agreed to in writing, software
11-
// distributed under the License is distributed on an "AS IS" BASIS,
12-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
// See the License for the specific language governing permissions and
14-
// limitations under the License.
12+
// This program is distributed in the hope that it will be useful,
13+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
// GNU General Public License for more details.
16+
//
17+
// You should have received a copy of the GNU General Public License
18+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1519

1620
/// \file
1721
/// \brief Implementation of the SimpleController class.
@@ -415,7 +419,8 @@ SerestController::compute_goal_zone(
415419
const Vec2 & robot_xy, double robot_yaw,
416420
double & dist_xy_goal, double & e_theta_goal,
417421
double & stop_r, double & slow_r, double & gamma_slow,
418-
Vec2 & goal_xy, double & yaw_goal) const
422+
Vec2 & goal_xy, double & yaw_goal,
423+
double goal_pos_tol) const
419424
{
420425
const auto & pgoal = path.poses.back().pose.position;
421426
yaw_goal = tf2::getYaw(path.poses.back().pose.orientation);
@@ -424,10 +429,8 @@ SerestController::compute_goal_zone(
424429
dist_xy_goal = std::hypot(robot_xy.x - goal_xy.x, robot_xy.y - goal_xy.y);
425430
e_theta_goal = std::atan2(std::sin(robot_yaw - yaw_goal), std::cos(robot_yaw - yaw_goal));
426431

427-
// Use externally provided goal position tolerance when available (via update_rt),
428-
// which stores it in goal_pos_tol_. Here we only shape the radial zone using
429-
// the current value of goal_pos_tol_ as stop radius.
430-
stop_r = std::max(0.0, goal_pos_tol_);
432+
// Use the resolved goal position tolerance (from NavState if available, else parameter).
433+
stop_r = std::max(0.0, goal_pos_tol);
431434
slow_r = std::max(slow_radius_, stop_r + 0.05);
432435

433436
gamma_slow = 1.0;
@@ -518,9 +521,8 @@ bool
518521
SerestController::maybe_final_align_and_publish(
519522
NavState & nav_state, const nav_msgs::msg::Path & path,
520523
double dist_xy_goal, double stop_r, double e_theta_goal,
521-
double gamma_slow, double dt)
524+
double gamma_slow, double dt, double goal_yaw_tol)
522525
{
523-
const double goal_yaw_tol = goal_yaw_tol_deg_ * M_PI / 180.0;
524526

525527
if (dist_xy_goal > stop_r) {
526528
return false;
@@ -660,7 +662,7 @@ SerestController::update_rt(NavState & nav_state)
660662
double dist_xy_goal = 0.0, e_theta_goal = 0.0, stop_r = 0.0, slow_r = 0.0, gamma_slow = 1.0;
661663
Vec2 goal_xy; double yaw_goal = 0.0;
662664
compute_goal_zone(path, robot_xy, yaw, dist_xy_goal, e_theta_goal,
663-
stop_r, slow_r, gamma_slow, goal_xy, yaw_goal);
665+
stop_r, slow_r, gamma_slow, goal_xy, yaw_goal, goal_pos_tol);
664666

665667
// 6) Global safety limits derived from sensors and curvature
666668
double d_closest = 0.0, v_safe = 0.0, v_curv = 0.0;
@@ -763,7 +765,7 @@ SerestController::update_rt(NavState & nav_state)
763765

764766
// 8) Final alignment inside stop zone (publishes and returns if active)
765767
if (maybe_final_align_and_publish(
766-
nav_state, path, dist_xy_goal, stop_r, e_theta_goal, gamma_slow, dt))
768+
nav_state, path, dist_xy_goal, stop_r, e_theta_goal, gamma_slow, dt, goal_yaw_tol))
767769
{
768770
return;
769771
}

0 commit comments

Comments
 (0)