EasyNav Plugins
Loading...
Searching...
No Matches
SimpleController Class Reference

A simple path-following controller using PID and look-ahead strategy. More...

#include <SimpleController.hpp>

Inheritance diagram for SimpleController:
Collaboration diagram for SimpleController:

Public Member Functions

void on_initialize () override
 Initializes parameters and PID controllers.
 SimpleController ()
void update_rt (NavState &nav_state) override
 Updates the controller using the given NavState.
 ~SimpleController () override
 Destructor.

Protected Member Functions

double get_angle (const geometry_msgs::msg::Point &from, const geometry_msgs::msg::Point &to)
 Computes the angle between two points.
double get_diff_angle (const geometry_msgs::msg::Quaternion &a, const geometry_msgs::msg::Quaternion &b)
 Computes the angular difference between two quaternions (yaw).
double get_distance (const geometry_msgs::msg::Pose &a, const geometry_msgs::msg::Pose &b)
 Computes the Euclidean distance between two poses.
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.

Protected Attributes

double angular_kd_ {0.08}
 Derivative gain for angular PID.
double angular_ki_ {0.03}
 Integral gain for angular PID.
double angular_kp_ {1.5}
 Proportional gain for angular PID.
std::shared_ptr< PIDControllerangular_pid_
 PID controller for angular velocity.
double final_goal_angle_tolerance_ {0.1}
 Angular tolerance at the final goal in radians.
double k_rot_ {0.5}
 Gain to reduce linear speed based on angular velocity.
rclcpp::Time last_update_ts_
 Timestamp of the last control update.
double last_vlin_ {0.0}
 Previous linear velocity for acceleration limiting.
double last_vrot_ {0.0}
 Previous angular velocity for acceleration limiting.
double linear_kd_ {0.08}
 Derivative gain for linear PID.
double linear_ki_ {0.03}
 Integral gain for linear PID.
double linear_kp_ {0.95}
 Proportional gain for linear PID.
std::shared_ptr< PIDControllerlinear_pid_
 PID controller for linear velocity.
double look_ahead_dist_ {1.0}
 Distance ahead of the robot to track in meters.
double max_angular_acc_ {0.3}
 Maximum angular acceleration in rad/s².
double max_angular_speed_ {1.0}
 Maximum angular speed in rad/s.
double max_linear_acc_ {0.3}
 Maximum linear acceleration in m/s².
double max_linear_speed_ {1.0}
 Maximum linear speed in m/s.
double tolerance_dist_ {0.05}
 Distance threshold to switch to orientation tracking.
geometry_msgs::msg::TwistStamped twist_stamped_
 Current velocity command.

Detailed Description

A simple path-following controller using PID and look-ahead strategy.

Constructor & Destructor Documentation

◆ SimpleController()

SimpleController ( )

◆ ~SimpleController()

~SimpleController ( )
overridedefault

Destructor.

Member Function Documentation

◆ get_angle()

double get_angle ( const geometry_msgs::msg::Point & from,
const geometry_msgs::msg::Point & to )
protected

Computes the angle between two points.

Parameters
fromStart point.
toEnd point.
Returns
Angle in radians.

◆ get_diff_angle()

double get_diff_angle ( const geometry_msgs::msg::Quaternion & a,
const geometry_msgs::msg::Quaternion & b )
protected

Computes the angular difference between two quaternions (yaw).

Parameters
aFirst quaternion.
bSecond quaternion.
Returns
Angle difference in radians within [-π, π].

◆ get_distance()

double get_distance ( const geometry_msgs::msg::Pose & a,
const geometry_msgs::msg::Pose & b )
protected

Computes the Euclidean distance between two poses.

Parameters
aFirst pose.
bSecond pose.
Returns
Distance in meters.

◆ get_ref_pose()

geometry_msgs::msg::Pose get_ref_pose ( const nav_msgs::msg::Path & path,
double look_ahead )
protected

Gets the reference pose at look-ahead distance on the path.

Parameters
pathThe planned path.
look_aheadDistance to look ahead in meters.
Returns
PoseStamped representing the goal reference.

◆ on_initialize()

void on_initialize ( )
override

Initializes parameters and PID controllers.

Exceptions
std::runtime_erroron initialization error.

◆ update_rt()

void update_rt ( NavState & nav_state)
override

Updates the controller using the given NavState.

Parameters
nav_stateCurrent navigation state, including odometry and planned path.

Member Data Documentation

◆ angular_kd_

double angular_kd_ {0.08}
protected

Derivative gain for angular PID.

◆ angular_ki_

double angular_ki_ {0.03}
protected

Integral gain for angular PID.

◆ angular_kp_

double angular_kp_ {1.5}
protected

Proportional gain for angular PID.

◆ angular_pid_

std::shared_ptr<PIDController> angular_pid_
protected

PID controller for angular velocity.

◆ final_goal_angle_tolerance_

double final_goal_angle_tolerance_ {0.1}
protected

Angular tolerance at the final goal in radians.

◆ k_rot_

double k_rot_ {0.5}
protected

Gain to reduce linear speed based on angular velocity.

◆ last_update_ts_

rclcpp::Time last_update_ts_
protected

Timestamp of the last control update.

◆ last_vlin_

double last_vlin_ {0.0}
protected

Previous linear velocity for acceleration limiting.

◆ last_vrot_

double last_vrot_ {0.0}
protected

Previous angular velocity for acceleration limiting.

◆ linear_kd_

double linear_kd_ {0.08}
protected

Derivative gain for linear PID.

◆ linear_ki_

double linear_ki_ {0.03}
protected

Integral gain for linear PID.

◆ linear_kp_

double linear_kp_ {0.95}
protected

Proportional gain for linear PID.

◆ linear_pid_

std::shared_ptr<PIDController> linear_pid_
protected

PID controller for linear velocity.

◆ look_ahead_dist_

double look_ahead_dist_ {1.0}
protected

Distance ahead of the robot to track in meters.

◆ max_angular_acc_

double max_angular_acc_ {0.3}
protected

Maximum angular acceleration in rad/s².

◆ max_angular_speed_

double max_angular_speed_ {1.0}
protected

Maximum angular speed in rad/s.

◆ max_linear_acc_

double max_linear_acc_ {0.3}
protected

Maximum linear acceleration in m/s².

◆ max_linear_speed_

double max_linear_speed_ {1.0}
protected

Maximum linear speed in m/s.

◆ tolerance_dist_

double tolerance_dist_ {0.05}
protected

Distance threshold to switch to orientation tracking.

◆ twist_stamped_

geometry_msgs::msg::TwistStamped twist_stamped_
protected

Current velocity command.


The documentation for this class was generated from the following files: