Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

436 task guidance node for autopilot #502

Closed
wants to merge 74 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
917d5bf
Modified guidance algorithim
AbubakarAliyuBadawi Oct 9, 2024
cd4d076
Automated autoyapf fixes
invalid-email-address Oct 9, 2024
7845070
added guidance action server
AbubakarAliyuBadawi Oct 11, 2024
7157c5c
Resolved merge conflict in guidance.py
AbubakarAliyuBadawi Oct 11, 2024
d7dd424
Automated autoyapf fixes
invalid-email-address Oct 11, 2024
cb2e138
Remove unwanted folder
AbubakarAliyuBadawi Oct 11, 2024
0e8585a
Merge remote-tracking branch 'origin/436-task-guidance-node-for-autop…
AbubakarAliyuBadawi Oct 11, 2024
6ab5edf
Develop (#487)
kluge7 Oct 13, 2024
cd7f490
Fix errors of no executable
AbubakarAliyuBadawi Oct 13, 2024
29c1ad3
trying to resolve merge
AbubakarAliyuBadawi Oct 13, 2024
07261ee
Automated autoyapf fixes
invalid-email-address Oct 13, 2024
1fb8b90
Made changes to guidance_action_server and guidance_los files
AbubakarAliyuBadawi Oct 21, 2024
d694e89
update guidance action server
AbubakarAliyuBadawi Oct 21, 2024
a007e80
Automated autoyapf fixes
invalid-email-address Oct 21, 2024
05ff163
Delete unnecessary files.
AbubakarAliyuBadawi Oct 21, 2024
f44e105
modification of the guidance
AbubakarAliyuBadawi Oct 23, 2024
9ca5b31
Fixed auto-pilot
AbubakarAliyuBadawi Oct 27, 2024
15fed69
Automated autoyapf fixes
invalid-email-address Oct 27, 2024
46455e6
intermediate commit
AbubakarAliyuBadawi Nov 3, 2024
9e7d7ba
Merge remote-tracking branch 'origin/485-task-auv-gui' into 436-task-…
AbubakarAliyuBadawi Nov 3, 2024
fc4780a
feat: create guidance action server
AbubakarAliyuBadawi Nov 10, 2024
79a48b2
Merge remote-tracking branch 'origin/develop' into 436-task-guidance-…
AbubakarAliyuBadawi Nov 10, 2024
acc38cb
Merge remote-tracking branch 'origin/develop' into 436-task-guidance-…
AbubakarAliyuBadawi Nov 10, 2024
bc076c6
fix(gui): resolve merge conflict in auv_gui.py, retain local updates
kluge7 Nov 11, 2024
9b49170
Modified LOS guidance action server with proper comments and doc strings
AbubakarAliyuBadawi Nov 16, 2024
2e9e1c8
Added comprehensive docstrings and comments to LOS guidance algorithm
AbubakarAliyuBadawi Nov 16, 2024
d1987fa
change LOS guidance to use third order low-pass filter
AbubakarAliyuBadawi Nov 17, 2024
ab21880
fix: vortex_msgs develop branch is target
Hallfred Nov 17, 2024
fa599fe
fix: added pyqt install script
Hallfred Nov 17, 2024
b695f1d
fix: correct ref
Hallfred Nov 17, 2024
03bb8d3
feat: removed tests
Hallfred Nov 17, 2024
992487d
refactor: applied formatting changes
AbubakarAliyuBadawi Nov 17, 2024
a4700f8
add stuff
AbubakarAliyuBadawi Nov 17, 2024
6ad96af
added stuff
AbubakarAliyuBadawi Nov 17, 2024
a78dc87
added stuff
AbubakarAliyuBadawi Nov 17, 2024
1bfc2ee
Fixed filter and remove tuple
AbubakarAliyuBadawi Nov 17, 2024
e614471
fix CMaklists
AbubakarAliyuBadawi Nov 17, 2024
d0061dc
Modified package.xml
AbubakarAliyuBadawi Nov 17, 2024
aa27f9f
remove unnecessary comments and added a readme.md file and a yaml fil…
AbubakarAliyuBadawi Dec 22, 2024
fd6db80
Apply pre-commit hook fixes
AbubakarAliyuBadawi Dec 26, 2024
2f4cfa9
Modified guidance action server node.
AbubakarAliyuBadawi Dec 28, 2024
2d4cadf
modify action server and launch file
AbubakarAliyuBadawi Jan 2, 2025
8ba17ba
working guidance action server
AbubakarAliyuBadawi Jan 7, 2025
3160f92
added goal callback
AbubakarAliyuBadawi Jan 7, 2025
afb0a89
added cancel request
AbubakarAliyuBadawi Jan 7, 2025
845e362
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 7, 2025
62b1fd8
refactor guidance action server
AbubakarAliyuBadawi Jan 7, 2025
3b5c8d9
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 7, 2025
f748524
feat: remove dependency on transforms3d
Andeshog Jan 8, 2025
87309ba
refactor: remove try-except block
Andeshog Jan 8, 2025
13d1e6f
refactor: correctly initialize new commands after new goal request
Andeshog Jan 8, 2025
e6e3e9f
modified guidance algorithm
AbubakarAliyuBadawi Jan 8, 2025
927b03a
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 8, 2025
3b80ce0
[pre-commit.ci] auto fixes from pre-commit.com hooks
Hallfred Jan 9, 2025
8301782
Modified guidance algorithm and action server (anderes)
AbubakarAliyuBadawi Jan 15, 2025
9467bfc
added variable surge velocity to the action server
AbubakarAliyuBadawi Jan 15, 2025
c0a40b1
Merge branch '436-task-guidance-node-for-autopilot' of github.com:vor…
Andeshog Jan 22, 2025
e8ab1f4
Merge remote-tracking branch 'origin/main' into 436-task-guidance-nod…
Andeshog Jan 22, 2025
1c3a504
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 22, 2025
a210bea
💚 ci(workflows): removed deprecated workflow and updated .repos to us…
kluge7 Jan 22, 2025
aa1fc7c
integrate vortex utils
Andeshog Jan 23, 2025
6d23e15
fixed unknown bug
Andeshog Jan 23, 2025
1b8e018
rectify vortex util
AbubakarAliyuBadawi Feb 6, 2025
a656d6c
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 6, 2025
68a021b
reduce deviation error
AbubakarAliyuBadawi Feb 6, 2025
5ae12ee
remove try and except
AbubakarAliyuBadawi Feb 6, 2025
bd9d5b4
Merge branch '436-task-guidance-node-for-autopilot' of github.com:vor…
AbubakarAliyuBadawi Feb 6, 2025
c4d8530
improve readme
AbubakarAliyuBadawi Feb 6, 2025
94775da
added more equations in the readme
AbubakarAliyuBadawi Feb 6, 2025
0500bca
add picture in the readme---no-verify
AbubakarAliyuBadawi Feb 6, 2025
3bf7576
there is something wrong with waypoint switching, I will check that t…
AbubakarAliyuBadawi Feb 7, 2025
cf8cd89
fixed some guidance equations
AbubakarAliyuBadawi Feb 9, 2025
76795e0
fixed 2D los
AbubakarAliyuBadawi Feb 9, 2025
6886022
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions guidance/guidance_los/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
cmake_minimum_required(VERSION 3.8)
project(guidance_los)

find_package(ament_cmake_python REQUIRED)
find_package(rclpy REQUIRED)
find_package(std_msgs REQUIRED)
find_package(nav_msgs REQUIRED)
find_package(geometry_msgs REQUIRED)
find_package(vortex_msgs REQUIRED)

ament_python_install_package(${PROJECT_NAME})

install(
PROGRAMS
scripts/los_guidance_action_server.py
RENAME
los_guidance_action_server
DESTINATION lib/${PROJECT_NAME}
)

install(
DIRECTORY
launch
config
DESTINATION share/${PROJECT_NAME}
)

ament_package()
Binary file added guidance/guidance_los/Images/LOS_IMAGE.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
178 changes: 178 additions & 0 deletions guidance/guidance_los/README.md
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Finish the README

Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
# LOS Guidance Action Server Implementation

A ROS2 implementation of a 3D Line-of-Sight (LOS) guidance for path following for autonomous underwater vehicles (AUVs).

## Overview

This package implements a **3D Line-of-Sight (LOS) guidance system** with adaptive parameter estimation and third-order filtering. The system calculates the desired heading (yaw), pitch, and surge velocity required for an AUV to follow a predefined path while minimizing cross-track errors. The package consists of two main components:

1. **LOS Guidance Algorithm** (`los_guidance_algorithm.py`) - Implements the core path-following logic.
2. **ROS2 Action Server** (`los_guidance_action_server.py`) - Provides a ROS2 interface for real-time guidance and control.

## Guidance Law Equations

The guidance system implements equations from *"Handbook of Marine Craft Hydrodynamics and Motion Control"* (Fossen, 2011).

![Alt text](Images/LOS_IMAGE.png)

The guidance law calculates the desired heading angle $\psi_d$ and desired pitch angle $\theta_d$. The crab angles $\beta_c$ and $\alpha_c$ are estimated adaptively. The guidance law is given as:

### Desired Heading and Pitch Angles

$$
\psi_d = \pi_h - \hat{\beta}_c - \tan^{-1}\left(\frac{y_e^p}{\Delta_h}\right)
$$

$$
\theta_d = \pi_v + \hat{\alpha}_c + \tan^{-1}\left(\frac{z_e^p}{\Delta_v}\right)
$$


### Adaptive Estimation of Crab Angles

$$
\dot{\hat{\beta}}_c = \gamma_h \frac{\Delta_h}{\sqrt{\Delta_h^2 + (y_e^p)^2}} y_e^p
$$

$$
\dot{\hat{\alpha}}_c = \gamma_v \frac{\Delta_v}{\sqrt{\Delta_v^2 + (z_e^p)^2}} z_e^p
$$

### Definitions

- $\Delta_h$ : Horizontal lookahead distance
- $\Delta_v$ : Vertical lookahead distance
- $\gamma_h, \gamma_v$ : Adaptive gains
- $y_e^p$ : Cross-track error
- $z_e^p$ : Vertical-track error

### Azimuth and Elevation Angles

The azimuth angle $\pi_h$ and the elevation angle $\pi_v$ are given by:

$$
\pi_h = \text{atan2}(y_{i+1}^n - y_i^n, x_{i+1}^n - x_i^n)
$$

$$
\pi_v = \text{atan2}(-(z_{i+1}^n - z_i^n), \sqrt{(x_{i+1}^n - x_i^n)^2 + (y_{i+1}^n - y_i^n)^2})
$$

where
- $P_i^n = (x_i^n, y_i^n, z_i^n)$ is the previous waypoint in the north-east-down (NED) frame.
- $P_{i+1}^n = (x_{i+1}^n, y_{i+1}^n, z_{i+1}^n)$ is the next waypoint in the NED frame.

### Path-Tangential Frame Errors

### Path-Tangential Reference Frame
The path-tangential coordinate system `{p}` has its origin at `(x_i, y_i, z_i)` with the `x_p`-axis pointing towards the next waypoint. The path-following errors are transformed using:

```math
\begin{bmatrix}
x_e^p \\
y_e^p \\
z_e^p
\end{bmatrix} =
\begin{bmatrix}
\cos(\pi_v) & 0 & \sin(\pi_v) \\
0 & 1 & 0 \\
-\sin(\pi_v) & 0 & \cos(\pi_v)
\end{bmatrix}
\begin{bmatrix}
\cos(\pi_h) & -\sin(\pi_h) & 0 \\
\sin(\pi_h) & \cos(\pi_h) & 0 \\
0 & 0 & 1
\end{bmatrix}
\begin{bmatrix}
x^n \\
y^n \\
z^n
\end{bmatrix}
```


The along-track, cross-track, and vertical-track errors in the path-tangential frame are computed as follows:

```math
\begin{bmatrix}
x_e^p \\ y_e^p \\ z_e^p
\end{bmatrix} = \mathbf{R}_{y, \pi_v}^\top \mathbf{R}_{z, \pi_h}^\top \left( \begin{bmatrix}
x^n \\ y^n \\ z^n
\end{bmatrix} - \begin{bmatrix}
x_i^n \\ y_i^n \\ z_i^n
\end{bmatrix}
\right)
```
where $P^n = (x^n, y^n, z^n)$ is the current position of the drone.

The **LOS Guidance Algorithm** is responsible for calculating the optimal control commands (surge speed, pitch, and yaw) to guide an AUV along a predefined path. It consists of:

#### Key Functionalities:
- **Distance-Based Velocity Control**: Adjusts speed based on distance to target.
- **Path-Following using LOS Guidance**: Computes desired heading and pitch angles.
- **Third-Order Reference Filtering**: Ensures smooth transitions in control commands.
- **Adaptive Sideslip Compensation**: Adjusts yaw to compensate for environmental disturbances (e.g., currents).

#### Key Classes:
- **`State`**: Represents the vehicle's state (position, orientation, velocity).
- **`LOSParameters`**: Stores configuration parameters for the LOS guidance behavior.
- **`FilterParameters`**: Holds parameters for the third-order filtering system.
- **`LOSGuidanceAlgorithm`**: The main class that computes guidance commands and applies filtering.

#### How It Works:
1. **Compute Raw Guidance Commands** (`compute_raw_los_guidance`)
- Determines the heading (yaw), pitch, and velocity required to reach the target.
- Uses the `ssa` (Smallest Signed Angle) function to normalize angles.

2. **Apply Reference Filtering** (`apply_reference_filter`)
- Uses a third-order filter to smooth control commands before sending them to the vehicle.
- Prevents abrupt changes in motion.

3. **Compute Final Guidance Commands** (`compute_guidance`)
- Integrates raw guidance commands with filtering for a smooth and accurate trajectory.

### 2. ROS2 Action Server

The **ROS2 Action Server** (`los_guidance_action_server.py`) serves as the interface between the guidance algorithm and ROS2. It:

- Receives **waypoints** and **odometry data**.
- Calls the **LOS guidance algorithm** to compute control commands.
- Publishes the **guidance commands** to the appropriate ROS2 topics.

#### Key Features:
- **Waypoint Navigation**: Moves the AUV from one waypoint to the next.
- **ROS2 Parameter Handling**: Loads and manages parameters from `los_guidance_params.yaml`.
- **Odometry Processing**: Estimates the vehicle's current state for accurate navigation.
- **Real-Time Command Publishing**: Sends filtered control commands to ROS topics for execution.

## Parameters

Parameters for the guidance system are stored in **`los_guidance_params.yaml`**, including:

- **Lookahead Distances (`delta_h`, `delta_v`)**: Determines how far ahead the vehicle looks when computing guidance commands.
- **Adaptive Gains (`gamma_h`, `gamma_v`)**: Controls responsiveness to disturbances.
- **Speed Constraints (`nominal_speed`, `min_speed`)**: Defines the operating speed range.
- **Filter Settings (`omega_diag`, `zeta_diag`)**: Configures natural frequencies and damping ratios for smooth motion.
- **ROS2 Topics**: Specifies topic names for command publishing and debugging.

## ROS2 Topics

### **Published Topics**
| Topic Name | Type | Description |
|------------|------|-------------|
| `/guidance/los` | `State` | Guidance commands (surge, pitch, yaw) |
| `/guidance/debug/reference` | `State` | Reference tracking for debugging |
| `/guidance/debug/errors` | `State` | Error values for tuning |
| `/guidance/debug/logs` | `String` | Logs and diagnostics |

### **Subscribed Topics**
| Topic Name | Type | Description |
|------------|------|-------------|
| `/orca/odom` | `Odometry` | Vehicle odometry data |
| `/dvl/pose` | `Pose` | Position estimation |
| `/dvl/twist` | `Twist` | Velocity estimation |


## References
- *Fossen, T. I. (2011). Handbook of Marine Craft Hydrodynamics and Motion Control.*
- *Fossen, T. I. (2024). Slide 104: Guidance and Control for Marine Vehicles.*
27 changes: 27 additions & 0 deletions guidance/guidance_los/config/los_guidance_params.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
los_guidance_node:
ros__parameters:
los_guidance:
delta_h: 2.0 # Horizontal look-ahead distance
delta_v: 2.0 # Vertical look-ahead distance
gamma_h: 1.0 # Horizontal adaptive gain
gamma_v: 1.0 # Vertical adaptive gain
M_theta: 0.5 # Bound for parameter estimates
epsilon: 0.1 # Padding for parameter estimates
nominal_speed: 0.1 # Nominal surge speed
min_speed: 0.05 # Minimum allowable surge speed
dt: 0.01 # Time step for guidance updates
filter:
omega_diag: [2.5, 2.5, 2.5] # Natural frequencies for surge, pitch, and yaw
zeta_diag: [0.7, 0.7, 0.7] # Damping ratios for surge, pitch, and yaw

topics:
publishers:
los_commands: '/guidance/los'
debug:
reference: '/guidance/debug/reference'
errors: '/guidance/debug/errors'
logs: '/guidance/debug/logs'
subscribers:
odometry: '/orca/odom'
pose: '/dvl/pose'
twist: '/dvl/twist'
Comment on lines +17 to +27
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is now in orca.yaml, recommend adding from there 😄

Empty file.
Loading