-
Notifications
You must be signed in to change notification settings - Fork 24
Anbit/guidance #642
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
Draft
anbit-adhi
wants to merge
27
commits into
main
Choose a base branch
from
anbit/guidance
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Anbit/guidance #642
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
2fb9d91
nye versjonen av guidance
064adef
los test
bbd8564
merging origin/main into anbit/guidance
e6ae145
Resolve stash conflicts: keep my YAML; keep main's joystick node
4d22267
fixing my error
3f3e671
maths behind proportional LOS
2688e27
refactor: change los structure
798542a
refactor: remove unused los package
3bb8926
fix: fix ignore lib
b7f63a9
Test: add test files for ALos and Plos
ee303e7
complete the restructuring of ros node
c687343
Complete los switchin
03560cf
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 66b252e
ci: trigger Industrial CI on PRs and main branch pushes
kluge7 a36297a
Add C++ and CMake pre-commit hooks (#568)
kluge7 a10e639
docs: add pre-commit CI badge to README
kluge7 b2e632b
refactor: merge the two pre-commit files to replace the pre-commit-ci…
kluge7 ef96e1e
Feat/waypoint manager (#645)
jorgenfj 8f15552
Refactor/type rename (#647)
jorgenfj 84ae150
refactor to new utils ros packages (#648)
jorgenfj cb4156b
Fix: Issues from feedback on PR draft
524a97e
fix git
8c61007
Start vector Feild LOS & Clean code
294ab77
Adda vector field LOS & Test
edc7185
Start quto-euler for graphing
763f784
Fix emailaddress error for git
anbit-adhi f073936
Fix building error
anbit-adhi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,7 +9,6 @@ install/ | |
| log/ | ||
| build/ | ||
| bin/ | ||
| lib/ | ||
| msg_gen/ | ||
| srv_gen/ | ||
| msg/*Action.msg | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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
49
guidance/los_guidance/include/los_guidance/lib/adaptive_los.hpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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
45
guidance/los_guidance/include/los_guidance/lib/integral_los.hpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
40 changes: 40 additions & 0 deletions
40
guidance/los_guidance/include/los_guidance/lib/proportional_los.hpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
41 changes: 41 additions & 0 deletions
41
guidance/los_guidance/include/los_guidance/lib/vector_field_los.hpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.