Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
2fb9d91
nye versjonen av guidance
Oct 19, 2025
064adef
los test
Oct 26, 2025
bbd8564
merging origin/main into anbit/guidance
Oct 28, 2025
e6ae145
Resolve stash conflicts: keep my YAML; keep main's joystick node
Oct 28, 2025
4d22267
fixing my error
Oct 28, 2025
3f3e671
maths behind proportional LOS
Oct 29, 2025
2688e27
refactor: change los structure
Nov 2, 2025
798542a
refactor: remove unused los package
Nov 2, 2025
3bb8926
fix: fix ignore lib
Nov 2, 2025
b7f63a9
Test: add test files for ALos and Plos
Nov 5, 2025
ee303e7
complete the restructuring of ros node
Nov 9, 2025
c687343
Complete los switchin
Nov 12, 2025
03560cf
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 12, 2025
66b252e
ci: trigger Industrial CI on PRs and main branch pushes
kluge7 Nov 12, 2025
a36297a
Add C++ and CMake pre-commit hooks (#568)
kluge7 Nov 12, 2025
a10e639
docs: add pre-commit CI badge to README
kluge7 Nov 12, 2025
b2e632b
refactor: merge the two pre-commit files to replace the pre-commit-ci…
kluge7 Nov 16, 2025
ef96e1e
Feat/waypoint manager (#645)
jorgenfj Dec 19, 2025
8f15552
Refactor/type rename (#647)
jorgenfj Dec 22, 2025
84ae150
refactor to new utils ros packages (#648)
jorgenfj Dec 25, 2025
cb4156b
Fix: Issues from feedback on PR draft
Jan 6, 2026
524a97e
fix git
Jan 6, 2026
8c61007
Start vector Feild LOS & Clean code
Jan 7, 2026
294ab77
Adda vector field LOS & Test
Jan 7, 2026
edc7185
Start quto-euler for graphing
Jan 8, 2026
763f784
Fix emailaddress error for git
anbit-adhi Jan 15, 2026
f073936
Fix building error
anbit-adhi Jan 16, 2026
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
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ install/
log/
build/
bin/
lib/
msg_gen/
srv_gen/
msg/*Action.msg
Expand Down
3 changes: 3 additions & 0 deletions auv_setup/config/robots/orca.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@
reference_filter: "reference_filter"
los: "los_guidance"

services: # Maybe not the right place for this?
los_mode: "set_los_mode"

fsm:
docking:
docking_station_offset: -1.0
Expand Down
24 changes: 21 additions & 3 deletions guidance/los_guidance/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,29 @@ find_package(rclcpp_action REQUIRED)
find_package(vortex_msgs REQUIRED)
find_package(vortex_utils_ros REQUIRED)
find_package(geometry_msgs REQUIRED)
find_package(nav_msgs REQUIRED)
find_package(Eigen3 REQUIRED)
find_package(spdlog REQUIRED)
find_package(fmt REQUIRED)
find_package(yaml-cpp REQUIRED)


include_directories(include)

set(LIB_NAME los_guidance_lib)
add_library(${LIB_NAME} SHARED
src/los_guidance.cpp
src/lib/proportional_los.cpp
src/lib/integral_los.cpp
src/lib/adaptive_los.cpp
src/los_guidance_ros.cpp
src/lib/vector_field_los.cpp
)

ament_target_dependencies(${LIB_NAME}
rclcpp
rclcpp_action
geometry_msgs
nav_msgs
vortex_msgs
vortex_utils_ros
Eigen3
Expand All @@ -42,7 +49,18 @@ add_executable(los_guidance_node
src/los_guidance_node.cpp
)

target_link_libraries(los_guidance_node ${LIB_NAME})
ament_target_dependencies(los_guidance_node
rclcpp
rclcpp_action
geometry_msgs
vortex_msgs
vortex_utils_ros
)

target_link_libraries(los_guidance_node
${LIB_NAME}
yaml-cpp
)

install(TARGETS
${LIB_NAME}
Expand All @@ -59,7 +77,7 @@ install(TARGETS

install(
DIRECTORY include/
DESTINATION include
DESTINATION include/
)

install(DIRECTORY
Expand Down
44 changes: 34 additions & 10 deletions guidance/los_guidance/config/guidance_params.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,34 @@
/**:
ros__parameters:
los:
lookahead_distance_h: 1.5
lookahead_distance_v: 0.6
gamma_h: 0.05
gamma_v: 0.1
time_step: 0.01
u_desired: 0.3
goal_reached_tol: 1.0
adaptive_los:
lookahead_distance_h: 1.5
lookahead_distance_v: 0.6
gamma_h: 0.05
gamma_v: 0.1

prop_los:
lookahead_distance_h: 1.5
lookahead_distance_v: 0.6
k_p_h: 0.5
k_p_v: 0.5

integer_los:
lookahead_distance_h: 1.5
lookahead_distance_v: 0.6
k_p_h: 0.5
k_p_v: 0.5
k_i_h: 0.1
k_i_v: 0.1

vector_field_los:
max_approach_angle_h: 1.0 # rad
max_approach_angle_v: 0.6 # rad
k_p_h: 0.5
k_p_v: 0.5

common:
active_los_method: 0 # 0: Proportional, 1: Integral, 2: Adaptive
u_desired: 0.3
goal_reached_tol: 1.0

debug:
enable_debug: true
debug_topic_name: "/los_guidance_debug"
49 changes: 49 additions & 0 deletions guidance/los_guidance/include/los_guidance/lib/adaptive_los.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#ifndef ADAPTIVE_LOS_GUIDANCE_HPP
#define ADAPTIVE_LOS_GUIDANCE_HPP

#include <cmath>
#include <eigen3/Eigen/Dense>
#include <eigen3/Eigen/Geometry>
#include "los_guidance/lib/types.hpp"

/**
* @brief Adaptive Line-of-Sight (LOS) guidance algorithm based on slide 113
* in "Fossen 2024 Lecture on 2D and 3D path-following control".
*/

namespace vortex::guidance::los {

struct AdaptiveLosParams {
double lookahead_distance_h{};
double lookahead_distance_v{};
double gamma_h{};
double gamma_v{};
double time_step{};
};

class AdaptiveLOSGuidance {
public:
AdaptiveLOSGuidance(const AdaptiveLosParams& params);
~AdaptiveLOSGuidance() = default;

types::Outputs calculate_outputs(const types::Inputs& inputs);

private:
void update_angles(const types::Inputs& inputs);
const types::CrossTrackError calculate_crosstrack_error(
const types::Inputs& inputs);
void update_adaptive_estimates(
const types::CrossTrackError& cross_track_error);

AdaptiveLosParams params_{};
Eigen::Matrix3d rotation_y_ = Eigen::Matrix3d::Zero();
Eigen::Matrix3d rotation_z_ = Eigen::Matrix3d::Zero();
double pi_h_{};
double pi_v_{};
double beta_c_hat_{};
double alpha_c_hat_{};

}; // namespace vortex::guidance::los

} // namespace vortex::guidance::los
#endif // LOS_GUIDANCE_HPP
45 changes: 45 additions & 0 deletions guidance/los_guidance/include/los_guidance/lib/integral_los.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#ifndef INTEGRAL_LOS_GUIDANCE_HPP
#define INTEGRAL_LOS_GUIDANCE_HPP

#include <cmath>
#include <eigen3/Eigen/Dense>
#include <eigen3/Eigen/Geometry>
#include "los_guidance/lib/types.hpp"

namespace vortex::guidance::los {

struct IntegralLosParams {
double lookahead_distance_h{};
double lookahead_distance_v{};
double k_p_h{};
double k_p_v{};
double k_i_h{};
double k_i_v{};
double time_step{};
};

class IntegralLOSGuidance {
public:
IntegralLOSGuidance(const IntegralLosParams& params);
~IntegralLOSGuidance() = default;

types::Outputs calculate_outputs(const types::Inputs& inputs);

private:
void update_angles(const types::Inputs& inputs);
types::CrossTrackError calculate_crosstrack_error(
const types::Inputs& inputs);

IntegralLosParams m_params{};

double int_h{};
double int_v{};
// again i dont know if i should have them here or just in the functions
double pi_h_{};
double pi_v_{};
Eigen::AngleAxisd rotation_y_{0.0, Eigen::Vector3d::UnitY()};
Eigen::AngleAxisd rotation_z_{0.0, Eigen::Vector3d::UnitZ()};
Comment on lines +37 to +41
Copy link
Contributor

Choose a reason for hiding this comment

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

It is a fair point, and it makes sense to have just have them as input/output for the calculations

};
} // namespace vortex::guidance::los

#endif // INTEGRAL_LOS_GUIDANCE_HPP
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#ifndef PROPORTIONAL_LOS_GUIDANCE_HPP
#define PROPORTIONAL_LOS_GUIDANCE_HPP

#include <cmath>
#include <eigen3/Eigen/Dense>
#include <eigen3/Eigen/Geometry>
#include "los_guidance/lib/types.hpp"

namespace vortex::guidance::los {
struct ProportionalLosParams {
double lookahead_distance_h{};
double lookahead_distance_v{};
double k_p_h{};
double k_p_v{};
double time_step{};
};

class ProportionalLOSGuidance {
public:
ProportionalLOSGuidance(const ProportionalLosParams& params);
~ProportionalLOSGuidance() = default;

types::Outputs calculate_outputs(const types::Inputs& inputs);

private:
void update_angles(const types::Inputs& inputs);
types::CrossTrackError calculate_crosstrack_error(
const types::Inputs& inputs) const;

ProportionalLosParams m_params{};
// again i dont know if i should have them here or just in the functions
double pi_h_{0.0};
double pi_v_{0.0};
Eigen::AngleAxisd rotation_y_{0.0, Eigen::Vector3d::UnitY()};
Eigen::AngleAxisd rotation_z_{0.0, Eigen::Vector3d::UnitZ()};
};

} // namespace vortex::guidance::los

#endif // PROPORTIONAL_LOS_GUIDANCE_HPP
58 changes: 58 additions & 0 deletions guidance/los_guidance/include/los_guidance/lib/types.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#ifndef TYPES_HPP
#define TYPES_HPP

#include <cmath>
#include <eigen3/Eigen/Dense>
#include <eigen3/Eigen/Geometry>
#include <geometry_msgs/msg/point_stamped.hpp>
#include <geometry_msgs/msg/pose_with_covariance_stamped.hpp>

namespace vortex::guidance::los::types {

struct Point {
double x{};
double y{};
double z{};

Point operator-(const Point& other) const {
return Point{x - other.x, y - other.y, z - other.z};
}

Eigen::Vector3d as_vector() const { return Eigen::Vector3d(x, y, z); }

static Point point_from_ros(const geometry_msgs::msg::Point& msg) {
return Point{msg.x, msg.y, msg.z};
}
};

struct CrossTrackError {
double x_e{};
double y_e{};
double z_e{};

inline static CrossTrackError from_vector(const Eigen::Vector3d& vector) {
return CrossTrackError{vector.x(), vector.y(), vector.z()};
}
};

struct Outputs {
double psi_d{};
double theta_d{};
};

struct Inputs {
Point prev_point{};
Point next_point{};
Point current_position{};
};

enum class ActiveLosMethod {
PROPORTIONAL, // 0
INTEGRAL, // 1
ADAPTIVE, // 2
VECTOR_FIELD // 3
};

} // namespace vortex::guidance::los::types

#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#ifndef VECTOR_FIELD_LOS_GUIDANCE_HPP
#define VECTOR_FIELD_LOS_GUIDANCE_HPP

#include <cmath>
#include <eigen3/Eigen/Dense>
#include <eigen3/Eigen/Geometry>
#include "los_guidance/lib/types.hpp"

namespace vortex::guidance::los {

struct VectorFieldLosParams {
double max_approach_angle_h{};
double max_approach_angle_v{};
double k_p_h{};
double k_p_v{};
double time_step{};
};

class VectorFieldLOSGuidance {
public:
VectorFieldLOSGuidance(const VectorFieldLosParams& params);
~VectorFieldLOSGuidance() = default;

types::Outputs calculate_outputs(const types::Inputs& inputs);

private:
void update_angles(const types::Inputs& inputs);
types::CrossTrackError calculate_crosstrack_error(
const types::Inputs& inputs) const;

VectorFieldLosParams m_params{};

double pi_h_{0.0};
double pi_v_{0.0};
Eigen::AngleAxisd rotation_y_{0.0, Eigen::Vector3d::UnitY()};
Eigen::AngleAxisd rotation_z_{0.0, Eigen::Vector3d::UnitZ()};
};

} // namespace vortex::guidance::los

#endif // VECTOR_FIELD_LOS_GUIDANCE_HPP
Loading
Loading