Skip to content

Commit

Permalink
Shorten name to nav2_graceful_controller (#4105)
Browse files Browse the repository at this point in the history
* nav2_graceful_motion_controller->nav2_graceful_controller

* dos2unix
  • Loading branch information
mikeferguson authored Feb 6, 2024
1 parent 543c555 commit 960602d
Show file tree
Hide file tree
Showing 20 changed files with 679 additions and 679 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.5)
project(nav2_graceful_motion_controller)
project(nav2_graceful_controller)

find_package(ament_cmake REQUIRED)
find_package(nav2_common REQUIRED)
Expand Down Expand Up @@ -39,11 +39,11 @@ set(dependencies
add_library(smooth_control_law SHARED src/smooth_control_law.cpp)
ament_target_dependencies(smooth_control_law ${dependencies})

# Add Graceful Motion Controller
set(library_name nav2_graceful_motion_controller)
# Add Graceful Controller
set(library_name nav2_graceful_controller)

add_library(${library_name} SHARED
src/graceful_motion_controller.cpp
src/graceful_controller.cpp
src/parameter_handler.cpp
src/path_handler.cpp
src/utils.cpp
Expand Down
File renamed without changes.
7 changes: 7 additions & 0 deletions nav2_graceful_controller/graceful_controller_plugin.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<class_libraries>
<library path="nav2_graceful_controller">
<class type="nav2_graceful_controller::GracefulController" base_class_type="nav2_core::Controller">
<description>Graceful controller for Nav2</description>
</class>
</library>
</class_libraries>
Original file line number Diff line number Diff line change
@@ -1,91 +1,91 @@
// Copyright (c) 2023 Alberto J. Tudela Roldán
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef NAV2_GRACEFUL_MOTION_CONTROLLER__EGO_POLAR_COORDS_HPP_
#define NAV2_GRACEFUL_MOTION_CONTROLLER__EGO_POLAR_COORDS_HPP_

#include <math.h>

#include "angles/angles.h"
#include "geometry_msgs/msg/pose.hpp"
#include "tf2/utils.h"
#include "tf2/transform_datatypes.h"
#include "tf2_geometry_msgs/tf2_geometry_msgs.hpp"

namespace nav2_graceful_motion_controller
{

/**
* @brief Egocentric polar coordinates defined as the difference between the
* robot pose and the target pose relative to the robot position and orientation.
*/
struct EgocentricPolarCoordinates
{
float r; // Radial distance between the robot pose and the target pose.
// Negative value if the robot is moving backwards.
float phi; // Orientation of target with respect to the line of sight
// from the robot to the target.
float delta; // Steering angle of the robot with respect to the line of sight.

EgocentricPolarCoordinates(
const float & r_in = 0.0,
const float & phi_in = 0.0,
const float & delta_in = 0.0)
: r(r_in), phi(phi_in), delta(delta_in) {}

/**
* @brief Construct a new egocentric polar coordinates as the difference between the robot pose
* and the target pose relative to the robot position and orientation, both referenced to the same frame.
*
* Thus, r, phi and delta are always at the origin of the frame.
*
* @param target Target pose.
* @param current Current pose. Defaults to the origin.
* @param backward If true, the robot is moving backwards. Defaults to false.
*/
explicit EgocentricPolarCoordinates(
const geometry_msgs::msg::Pose & target,
const geometry_msgs::msg::Pose & current = geometry_msgs::msg::Pose(), bool backward = false)
{
// Compute the difference between the target and the current pose
float dX = target.position.x - current.position.x;
float dY = target.position.y - current.position.y;
// Compute the line of sight from the robot to the target
// Flip it if the robot is moving backwards
float line_of_sight = backward ? (std::atan2(-dY, dX) + M_PI) : std::atan2(-dY, dX);
// Compute the ego polar coordinates
r = sqrt(dX * dX + dY * dY);
phi = angles::normalize_angle(tf2::getYaw(target.orientation) + line_of_sight);
delta = angles::normalize_angle(tf2::getYaw(current.orientation) + line_of_sight);
// If the robot is moving backwards, flip the sign of the radial distance
r *= backward ? -1.0 : 1.0;
}

/**
* @brief Construct a new egocentric polar coordinates for the target pose.
*
* @param target Target pose.
* @param backward If true, the robot is moving backwards. Defaults to false.
*/
explicit EgocentricPolarCoordinates(
const geometry_msgs::msg::Pose & target,
bool backward = false)
{
EgocentricPolarCoordinates(target, geometry_msgs::msg::Pose(), backward);
}
};

} // namespace nav2_graceful_motion_controller

#endif // NAV2_GRACEFUL_MOTION_CONTROLLER__EGO_POLAR_COORDS_HPP_
// Copyright (c) 2023 Alberto J. Tudela Roldán
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef NAV2_GRACEFUL_CONTROLLER__EGO_POLAR_COORDS_HPP_
#define NAV2_GRACEFUL_CONTROLLER__EGO_POLAR_COORDS_HPP_

#include <math.h>

#include "angles/angles.h"
#include "geometry_msgs/msg/pose.hpp"
#include "tf2/utils.h"
#include "tf2/transform_datatypes.h"
#include "tf2_geometry_msgs/tf2_geometry_msgs.hpp"

namespace nav2_graceful_controller
{

/**
* @brief Egocentric polar coordinates defined as the difference between the
* robot pose and the target pose relative to the robot position and orientation.
*/
struct EgocentricPolarCoordinates
{
float r; // Radial distance between the robot pose and the target pose.
// Negative value if the robot is moving backwards.
float phi; // Orientation of target with respect to the line of sight
// from the robot to the target.
float delta; // Steering angle of the robot with respect to the line of sight.

EgocentricPolarCoordinates(
const float & r_in = 0.0,
const float & phi_in = 0.0,
const float & delta_in = 0.0)
: r(r_in), phi(phi_in), delta(delta_in) {}

/**
* @brief Construct a new egocentric polar coordinates as the difference between the robot pose
* and the target pose relative to the robot position and orientation, both referenced to the same frame.
*
* Thus, r, phi and delta are always at the origin of the frame.
*
* @param target Target pose.
* @param current Current pose. Defaults to the origin.
* @param backward If true, the robot is moving backwards. Defaults to false.
*/
explicit EgocentricPolarCoordinates(
const geometry_msgs::msg::Pose & target,
const geometry_msgs::msg::Pose & current = geometry_msgs::msg::Pose(), bool backward = false)
{
// Compute the difference between the target and the current pose
float dX = target.position.x - current.position.x;
float dY = target.position.y - current.position.y;
// Compute the line of sight from the robot to the target
// Flip it if the robot is moving backwards
float line_of_sight = backward ? (std::atan2(-dY, dX) + M_PI) : std::atan2(-dY, dX);
// Compute the ego polar coordinates
r = sqrt(dX * dX + dY * dY);
phi = angles::normalize_angle(tf2::getYaw(target.orientation) + line_of_sight);
delta = angles::normalize_angle(tf2::getYaw(current.orientation) + line_of_sight);
// If the robot is moving backwards, flip the sign of the radial distance
r *= backward ? -1.0 : 1.0;
}

/**
* @brief Construct a new egocentric polar coordinates for the target pose.
*
* @param target Target pose.
* @param backward If true, the robot is moving backwards. Defaults to false.
*/
explicit EgocentricPolarCoordinates(
const geometry_msgs::msg::Pose & target,
bool backward = false)
{
EgocentricPolarCoordinates(target, geometry_msgs::msg::Pose(), backward);
}
};

} // namespace nav2_graceful_controller

#endif // NAV2_GRACEFUL_CONTROLLER__EGO_POLAR_COORDS_HPP_
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef NAV2_GRACEFUL_MOTION_CONTROLLER__GRACEFUL_MOTION_CONTROLLER_HPP_
#define NAV2_GRACEFUL_MOTION_CONTROLLER__GRACEFUL_MOTION_CONTROLLER_HPP_
#ifndef NAV2_GRACEFUL_CONTROLLER__GRACEFUL_CONTROLLER_HPP_
#define NAV2_GRACEFUL_CONTROLLER__GRACEFUL_CONTROLLER_HPP_

#include <string>
#include <limits>
Expand All @@ -27,30 +27,30 @@
#include "rclcpp/rclcpp.hpp"
#include "pluginlib/class_loader.hpp"
#include "pluginlib/class_list_macros.hpp"
#include "nav2_graceful_motion_controller/path_handler.hpp"
#include "nav2_graceful_motion_controller/parameter_handler.hpp"
#include "nav2_graceful_motion_controller/smooth_control_law.hpp"
#include "nav2_graceful_motion_controller/utils.hpp"
#include "nav2_graceful_controller/path_handler.hpp"
#include "nav2_graceful_controller/parameter_handler.hpp"
#include "nav2_graceful_controller/smooth_control_law.hpp"
#include "nav2_graceful_controller/utils.hpp"

namespace nav2_graceful_motion_controller
namespace nav2_graceful_controller
{

/**
* @class nav2_graceful_motion_controller::GracefulMotionController
* @class nav2_graceful_controller::GracefulController
* @brief Graceful controller plugin
*/
class GracefulMotionController : public nav2_core::Controller
class GracefulController : public nav2_core::Controller
{
public:
/**
* @brief Constructor for nav2_graceful_motion_controller::GracefulMotionController
* @brief Constructor for nav2_graceful_controller::GracefulController
*/
GracefulMotionController() = default;
GracefulController() = default;

/**
* @brief Destructor for nav2_graceful_motion_controller::GracefulMotionController
* @brief Destructor for nav2_graceful_controller::GracefulController
*/
~GracefulMotionController() override = default;
~GracefulController() override = default;

/**
* @brief Configure controller state machine
Expand Down Expand Up @@ -158,7 +158,7 @@ class GracefulMotionController : public nav2_core::Controller
std::shared_ptr<nav2_costmap_2d::Costmap2DROS> costmap_ros_;
std::unique_ptr<nav2_costmap_2d::FootprintCollisionChecker<nav2_costmap_2d::Costmap2D *>>
collision_checker_;
rclcpp::Logger logger_{rclcpp::get_logger("GracefulMotionController")};
rclcpp::Logger logger_{rclcpp::get_logger("GracefulController")};

Parameters * params_;
double goal_dist_tolerance_;
Expand All @@ -170,11 +170,11 @@ class GracefulMotionController : public nav2_core::Controller
motion_target_pub_;
std::shared_ptr<rclcpp_lifecycle::LifecyclePublisher<visualization_msgs::msg::Marker>>
slowdown_pub_;
std::unique_ptr<nav2_graceful_motion_controller::PathHandler> path_handler_;
std::unique_ptr<nav2_graceful_motion_controller::ParameterHandler> param_handler_;
std::unique_ptr<nav2_graceful_motion_controller::SmoothControlLaw> control_law_;
std::unique_ptr<nav2_graceful_controller::PathHandler> path_handler_;
std::unique_ptr<nav2_graceful_controller::ParameterHandler> param_handler_;
std::unique_ptr<nav2_graceful_controller::SmoothControlLaw> control_law_;
};

} // namespace nav2_graceful_motion_controller
} // namespace nav2_graceful_controller

#endif // NAV2_GRACEFUL_MOTION_CONTROLLER__GRACEFUL_MOTION_CONTROLLER_HPP_
#endif // NAV2_GRACEFUL_CONTROLLER__GRACEFUL_CONTROLLER_HPP_
Loading

0 comments on commit 960602d

Please sign in to comment.