This repository has been archived by the owner on Mar 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Calculates current heading #88
Open
Krithik1
wants to merge
5
commits into
main
Choose a base branch
from
user/Krithik1/Publish_Desired_Heading
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.
Open
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
58cdc2f
Made changes to calculate current heading.
Krithik1 8788e40
Changes according to PR comments
Krithik1 2944157
Merge remote-tracking branch 'origin' into user/Krithik1/Publish_Desi…
Krithik1 c7fe341
Add named arguments in GEODESIC.inv function
Krithik1 052962f
Merge branch 'main' into user/Krithik1/Publish_Desired_Heading
patrick-5546 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 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,9 +1,11 @@ | ||
"""The main node of the local_pathfinding package, represented by the `Sailbot` class.""" | ||
|
||
import custom_interfaces.msg as ci | ||
import math | ||
|
||
import rclpy | ||
from rclpy.node import Node | ||
|
||
import custom_interfaces.msg as ci | ||
from local_pathfinding.local_path import LocalPath | ||
|
||
|
||
|
@@ -176,7 +178,22 @@ def get_desired_heading(self) -> float: | |
) | ||
|
||
# TODO: create function to compute the heading from current position to next local waypoint | ||
return 0.0 | ||
# Find index of self.gps in current waypoints | ||
current_waypoint = self.gps.lat_lon | ||
next_waypoint = None | ||
waypoints = self.local_path.waypoints | ||
for i in range(len(waypoints)): | ||
if waypoints[i] == current_waypoint and i != len(waypoints) - 1: | ||
Krithik1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
next_waypoint = waypoints[i+1] | ||
break | ||
if next_waypoint is None: | ||
return 0.0 | ||
heading = math.atan2( | ||
(next_waypoint.longitude-current_waypoint.longitude) * | ||
math.cos(current_waypoint.latitude), | ||
(next_waypoint.latitude-current_waypoint.latitude) | ||
) | ||
Krithik1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return heading | ||
Krithik1 marked this conversation as resolved.
Show resolved
Hide resolved
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. Would it be possible to add some tests for this function? 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. For the tests, should I create a new test_node_navigate.py file and manually set the value of self.gps to calculate the desired heading? 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. I think this would be the best way to test this:
|
||
|
||
def update_params(self): | ||
"""Update instance variables that depend on parameters if they have changed.""" | ||
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe
self.gps.lat_lon
is the current GPS position of the boat, which is generally not one of the waypoints. I think Jay might be working on code to determine the next local waypoint, but we can sync up with him tomorrow