16#ifndef EASYNAV_SIMPLE_CONTROLLER__SIMPLECONTROLLER_HPP_
17#define EASYNAV_SIMPLE_CONTROLLER__SIMPLECONTROLLER_HPP_
22#include "geometry_msgs/msg/point.hpp"
23#include "geometry_msgs/msg/twist_stamped.hpp"
24#include "nav_msgs/msg/path.hpp"
26#include "easynav_core/ControllerMethodBase.hpp"
27#include "easynav_common/types/NavState.hpp"
48 void update_rt(NavState & nav_state)
override;
80 const nav_msgs::msg::Path & path,
87 double get_distance(
const geometry_msgs::msg::Pose & a,
const geometry_msgs::msg::Pose & b);
93 double get_angle(
const geometry_msgs::msg::Point & from,
const geometry_msgs::msg::Point & to);
100 const geometry_msgs::msg::Quaternion & a,
101 const geometry_msgs::msg::Quaternion & b);
Declaration of a simple PIDController class.
double linear_kd_
Derivative gain for linear PID.
Definition SimpleController.hpp:64
double final_goal_angle_tolerance_
Angular tolerance at the final goal in radians.
Definition SimpleController.hpp:61
double max_linear_speed_
Maximum linear speed in m/s.
Definition SimpleController.hpp:54
double linear_ki_
Integral gain for linear PID.
Definition SimpleController.hpp:63
double angular_kd_
Derivative gain for angular PID.
Definition SimpleController.hpp:67
double last_vlin_
Previous linear velocity for acceleration limiting.
Definition SimpleController.hpp:69
double max_angular_speed_
Maximum angular speed in rad/s.
Definition SimpleController.hpp:55
std::shared_ptr< PIDController > angular_pid_
PID controller for angular velocity.
Definition SimpleController.hpp:52
geometry_msgs::msg::Pose get_ref_pose(const nav_msgs::msg::Path &path, double look_ahead)
Gets the reference pose at look-ahead distance on the path.
Definition SimpleController.cpp:187
std::shared_ptr< PIDController > linear_pid_
PID controller for linear velocity.
Definition SimpleController.hpp:51
double get_angle(const geometry_msgs::msg::Point &from, const geometry_msgs::msg::Point &to)
Computes the angle between two points.
Definition SimpleController.cpp:214
double tolerance_dist_
Distance threshold to switch to orientation tracking.
Definition SimpleController.hpp:59
~SimpleController() override
Destructor.
double last_vrot_
Previous angular velocity for acceleration limiting.
Definition SimpleController.hpp:70
double max_angular_acc_
Maximum angular acceleration in rad/s².
Definition SimpleController.hpp:57
double k_rot_
Gain to reduce linear speed based on angular velocity.
Definition SimpleController.hpp:60
geometry_msgs::msg::TwistStamped twist_stamped_
Current velocity command.
Definition SimpleController.hpp:73
void update_rt(NavState &nav_state) override
Updates the controller using the given NavState.
Definition SimpleController.cpp:88
double get_distance(const geometry_msgs::msg::Pose &a, const geometry_msgs::msg::Pose &b)
Computes the Euclidean distance between two poses.
Definition SimpleController.cpp:204
double angular_ki_
Integral gain for angular PID.
Definition SimpleController.hpp:66
double angular_kp_
Proportional gain for angular PID.
Definition SimpleController.hpp:65
rclcpp::Time last_update_ts_
Timestamp of the last control update.
Definition SimpleController.hpp:72
double look_ahead_dist_
Distance ahead of the robot to track in meters.
Definition SimpleController.hpp:58
double get_diff_angle(const geometry_msgs::msg::Quaternion &a, const geometry_msgs::msg::Quaternion &b)
Computes the angular difference between two quaternions (yaw).
Definition SimpleController.cpp:222
void on_initialize() override
Initializes parameters and PID controllers.
Definition SimpleController.cpp:37
SimpleController()
Definition SimpleController.cpp:30
double linear_kp_
Proportional gain for linear PID.
Definition SimpleController.hpp:62
double max_linear_acc_
Maximum linear acceleration in m/s².
Definition SimpleController.hpp:56
Provides a mapping for often used cost values.
Definition cost_values.hpp:41