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

Open
wants to merge 74 commits into
base: main
Choose a base branch
from

Conversation

AbubakarAliyuBadawi
Copy link

No description provided.

AbubakarAliyuBadawi and others added 23 commits October 9, 2024 18:51
…ilot' into 436-task-guidance-node-for-autopilot
* ✨ feat: added the submodule for the perception

* ci: update clang-formatter and add python-formatter

* ci: explicitly checkout branch for black-format commit

* Committing black-format changes

* chore(pylint): add .pylintrc configuration file

* refactor: fix pylint warning W1510

* refactor: fix pylint warning C0116

* refactor: fix pylint warning C0411

* refactor: fix pylint warning R1731

* refactor: fix pylint warning R1705

* refactor: fix pylint warning W1514

* refactor: fix pylint warning C0200

* refactor: fix pylint warning W0611

* refactor: fix pylint warning W0702

* refactor: fix pylint warning C0121

* refactor: fix pylint warning W0107

* refactor: fix pylint warning R1714

* refactor: fix pylint warning C0201

* refactor: fix pylint warning C0303 and W0613

* refactor: fix pylint warning W0621

* refactor: fix pylint warning R0402

* refactor: fix pylint warning W0212

* chore(pylint): update rule adjustments and formatting

* style: format code with black

* style: format imports with isort

* ci: add isort and pylint to Python pipeline

* Committing black-format changes

* chore: add pyproject.toml for project configuration

* ci: update order of pipeline jobs

* ci: update pylint job and pylint rules

* ci: update which python versions pylint test

* ci: update python pipeline to only run on pull_request

* refactor: fix pylint warning C0103

* chore: update linting and project configuration rules in .pylintrc and pyproject.toml

* Rename files to snake_case

* ci: add pipeline for grammar in comments

* refactor: fix spelling mistakes in comments

* ci: update job codespell_fix to continue on error

* refactor: fix spelling mistakes in comments

* ci: update pipeline codespell to only have one job

* refactor: fix variable naming issues and adjust imports as per review

* Committing codespell fixes

* refactor: spelling correction

* ci: update CI file and job names for consistency

* ci: update CI file for more clarity

* chore: add codespell configuration and ignore list

* chore: add type hints and return types

* ci: add mypy.ini for type checking configuration

* ci: add mypy type checking workflow

* refactor: format code with black

* refactor: format all yaml files using prettier

* ci: add pipeline for yaml formatting using prettier

* ci: update yaml formatting pipeline to run on pull request

* refactor: remove deprecated typing

* refactor: fix import sorting

* ci: remove faulty ci pipelines and combine python pipelines into single file

* fix(security): replace subprocess call with safer alternative to remove shell=true

* feat: add pre-commit hooks for black, isort, and codespell

* ci: update python pipeline to use latest versions

* refactor: apply code formatting fixes via pre-commit hooks

* ci: split python ci/cd pipelines into multiple files

* ci: add ci pipeline for checking style clang-format

* refactor: remove unused config file for clang-format

* refactor: remove duplicate file

* ci: add ci pipeline that tests that codebase can build

* refactor: update ci-build pipeline to only run on pull request

* refactor: update clang-format config

* refactor: apply clang-format

* feat: update pipeline to build and run tests

* refactor: disable linting checks when running colcon test

* refactor: update .pre-commit-config file (#480)

* ci: add semver.yaml pipeline and .releaserc configuration

* ci: add semver.yaml pipeline and .releaserc configuration

* fix: semver pipeline runs when push to main

---------

Co-authored-by: Yauhen <[email protected]>
Co-authored-by: Black Robot <[email protected]>
Co-authored-by: Codespell Robot <[email protected]>
Co-authored-by: Sondre Haugen <[email protected]>
Copy link
Contributor

@Andeshog Andeshog left a comment

Choose a reason for hiding this comment

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

This is a start. Made some general comments. Will go more in-depth after you make these adjustments.

guidance/guidance_los/package.xml Outdated Show resolved Hide resolved
guidance/guidance_los/package.xml Outdated Show resolved Hide resolved
guidance/guidance_los/package.xml Outdated Show resolved Hide resolved
guidance/guidance_los/setup.py Outdated Show resolved Hide resolved
Copy link
Contributor

@kluge7 kluge7 left a comment

Choose a reason for hiding this comment

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

You need to fix the changes flagged by the pre-commit hooks! To solve them you need to open a terminal and run:
pip install pre-commit
and then navigate to the vortex-auv directory:
cd vortex-auv
and then run pre-commit hooks on all the files:
pre-commit run --all-files

It will fix some things automatically, but others you have to configure manually! Send me a message if anything is unclear:)

@kluge7 kluge7 linked an issue Nov 11, 2024 that may be closed by this pull request
3 tasks
@AbubakarAliyuBadawi AbubakarAliyuBadawi force-pushed the 436-task-guidance-node-for-autopilot branch from 7efa0ce to 9467bfc Compare January 15, 2025 15:23
@AbubakarAliyuBadawi AbubakarAliyuBadawi force-pushed the 436-task-guidance-node-for-autopilot branch from d2ad008 to 6d23e15 Compare January 26, 2025 17:59
@vortexntnu vortexntnu deleted a comment from Andeshog Jan 26, 2025
@vortexntnu vortexntnu deleted a comment from Andeshog Jan 26, 2025
@vortexntnu vortexntnu deleted a comment from Andeshog Jan 26, 2025
Comment on lines 42 to 45
```latex
[x_e^p] [ cos(π_v) 0 sin(π_v)] [cos(π_h) -sin(π_h) 0] [x^n]
[y_e^p] = [ 0 1 0 ] [sin(π_h) cos(π_h) 0] [y^n]
[z_e^p] [-sin(π_v) 0 cos(π_v)] [ 0 0 1] [z^n]
Copy link
Contributor

@Andeshog Andeshog Jan 28, 2025

Choose a reason for hiding this comment

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

what you can do here instead is use math instead of latex

$$\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} \cdots$$

which is written like

\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}
\cdots

Copy link
Contributor

@Talhanc Talhanc left a comment

Choose a reason for hiding this comment

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

Maybe look at comments, remove some and add some more

Comment on lines +17 to +27
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'
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 😄

Comment on lines +1 to +3
from dataclasses import dataclass, field

import numpy as np
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe not have space here?

Comment on lines 6 to 5
@dataclass
class State:
x: float = 0.0
y: float = 0.0
z: float = 0.0
pitch: float = 0.0
yaw: float = 0.0
surge_vel: float = 0.0

def __add__(self, other: "State") -> "State":
return State(
x=self.x + other.x,
y=self.y + other.y,
z=self.z + other.z,
pitch=self.pitch + other.pitch,
yaw=self.yaw + other.yaw,
)

def __sub__(self, other: "State") -> "State":
return State(
x=self.x - other.x,
y=self.y - other.y,
z=self.z - other.z,
pitch=self.pitch - other.pitch,
yaw=self.yaw - other.yaw,
)

def as_los_array(self):
return np.array([self.surge_vel, self.pitch, self.yaw])

def as_pos_array(self):
return np.array([self.x, self.y, self.z])

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 already in vortex_utils, cough anders cough, maybe look at that.
If you want to keep this maybe rename surge_vel to u to be more correct with marine standard notations

Comment on lines 55 to 24
lookahead_distance_min: float = 2.0
lookahead_distance_max: float = 8.0
lookahead_distance_factor: float = 1.0
Copy link
Contributor

Choose a reason for hiding this comment

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

why is max so high? maybe use 3 as max or else you will get the guidance algorithm looking too far ahead and causing a swing too fast.

Comment on lines +58 to +26
nominal_speed: float = 1.0
min_speed: float = 0.1
Copy link
Contributor

Choose a reason for hiding this comment

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

Orca has max speed of 0.3 m/s, maybe set this down

Comment on lines 218 to 220
self.u = msg.twist.twist.linear.x
self.v = msg.twist.twist.linear.y
self.w = msg.twist.twist.linear.z
Copy link
Contributor

Choose a reason for hiding this comment

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

name consistence, u or surge_vel

Comment on lines 245 to 235
beta_c = self.guidance_calculator.calculate_beta_c(
self.u, self.v, self.w, self.phi, self.pitch, alpha_c
self.state.twist.linear_x,
self.state.twist.linear_y,
self.state.twist.linear_z,
self.state.pose.roll,
self.state.pose.pitch,
alpha_c,
)
Copy link
Contributor

Choose a reason for hiding this comment

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

isnt self.state.twist.linear_x, and self.u the same? and alpha_c is here two times

Comment on lines 276 to 263
yaw_error = ssa(psi_d - self.state.pose.yaw)
desired_surge = self.guidance_calculator.compute_desired_speed(
yaw_error, self.norm, crosstrack_y
)
unfiltered_commands = State(
surge_vel=self.desired_vel, pitch=theta_d, yaw=psi_d
)
filtered_commands = self.guidance_calculator.apply_reference_filter(
unfiltered_commands
)
return unfiltered_commands

unfiltered_commands = State()
unfiltered_commands.twist.linear_x = desired_surge
unfiltered_commands.pose.pitch = theta_d
unfiltered_commands.pose.yaw = psi_d

filtered_commands = self.guidance_calculator.apply_reference_filter(
unfiltered_commands
)
return filtered_commands
Copy link
Contributor

Choose a reason for hiding this comment

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

There is something going on here, but idk what it is. Maybe comment?
btw there are two returns here 😄

Comment on lines 422 to 354
msg.surge = commands.surge_vel
msg.pitch = commands.pitch
msg.yaw = commands.yaw
self.guidance_cmd_pub.publish(msg)
Copy link
Contributor

Choose a reason for hiding this comment

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

Surge_vel or u, you choose

Comment on lines 434 to 372

try:
executor.spin()
except Exception as e:
action_server.get_logger().error(f'Error: {str(e)}')
finally:
action_server.destroy_node()
if rclpy.ok():
rclpy.shutdown()

Copy link
Contributor

Choose a reason for hiding this comment

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

you can remove the try, if it dosent runt we start again 🤝

Copy link
Author

Choose a reason for hiding this comment

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

Got ya!

@AbubakarAliyuBadawi AbubakarAliyuBadawi force-pushed the 436-task-guidance-node-for-autopilot branch from 6324465 to 1b8e018 Compare February 6, 2025 20:27
@AbubakarAliyuBadawi AbubakarAliyuBadawi force-pushed the 436-task-guidance-node-for-autopilot branch from e821c91 to 0500bca Compare February 6, 2025 23:51
@AbubakarAliyuBadawi AbubakarAliyuBadawi force-pushed the 436-task-guidance-node-for-autopilot branch from 8c3b34d to 3bf7576 Compare February 7, 2025 00:04
@AbubakarAliyuBadawi AbubakarAliyuBadawi force-pushed the 436-task-guidance-node-for-autopilot branch from 7a2e900 to 76795e0 Compare February 9, 2025 05:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[TASK] Guidance node for autopilot
6 participants