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

Implement Land Obstacles - 278 #436

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

Conversation

SPDonaghy
Copy link
Contributor

Description

Verification

  • Unit tests and visual testing in the same jupyter notebook

SPDonaghy and others added 30 commits March 12, 2024 10:50
and optimized etl script
@SPDonaghy
Copy link
Contributor Author

SPDonaghy commented Sep 27, 2024

Needed to create the pkl file in the stable environment defined by the Dockerfile + package.xml, otherwise things went haywire with dependencies

@SPDonaghy
Copy link
Contributor Author

Okay, yeah this is done

src/local_pathfinding/local_pathfinding/obstacles.py Outdated Show resolved Hide resolved
multi_poly = MultiPolygon(geoms)
multi_poly = multi_poly.buffer(0) # repairs invalid geometry
# this is to prevent geometry the crosses -180 longitude from being distorted by transforms
with open(INLAND_POLYGON, "r") as f:
Copy link
Contributor

Choose a reason for hiding this comment

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

Could add error handling here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure! which errors do you think we should plan for here?

Copy link
Contributor

Choose a reason for hiding this comment

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

The file cannot open exception error

@FireBoyAJ24
Copy link
Contributor

Will review the test cases later this week

@SPDonaghy
Copy link
Contributor Author

SPDonaghy commented Oct 9, 2024

Im gonna take another look at the function using map and see if I can simplify it

Copy link

@jamenkaye jamenkaye left a comment

Choose a reason for hiding this comment

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

Looks good! I don't think any of this is blocking but I'm interested in discussing this for my own curiosity :)

src/local_pathfinding/local_pathfinding/obstacles.py Outdated Show resolved Hide resolved
src/local_pathfinding/local_pathfinding/obstacles.py Outdated Show resolved Hide resolved
src/local_pathfinding/local_pathfinding/obstacles.py Outdated Show resolved Hide resolved

self.collision_zone = collision_zone.buffer(COLLISION_ZONE_SAFETY_BUFFER, join_style=2)
else:

Choose a reason for hiding this comment

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

We only need to update land collision zones when we reach a global waypoint right? I wonder if its worth restructuring a bit so to avoid spending the effort to update all the land obstacles more often than we need? If its not a big efficiency change then I don't mind going with whatever is most logical and readable :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah the decision of when to update will be up to the obstacle tracker. You update it directly using the update_collision_zone function or by updating the reference point. In practice, for the land obstacle, we should only be updating its collision zone through the update_reference_point function

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Clarification btw, at any time there will only be one land obstacle. A MultiPolygon containing 0 to n polygons

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah the decision of when to update will be up to the obstacle tracker. You update it directly using the update_collision_zone function or by updating the reference point. In practice, for the land obstacle, we should only be updating its collision zone through the update_reference_point function

Clarification btw, at any time there will only be one land obstacle. A MultiPolygon containing 0 to n polygons

def update_sailbot_data(
self, sailbot_position: HelperLatLon, sailbot_speed: Optional[float] = None
) -> None:
"""Updates Sailbot's position, and Sailbot's speed (if the caller is a Boat object).

Choose a reason for hiding this comment

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

Another good note! I was just about to ask why speed is optional

But now I'm a little confused from an architecture perspective why a Boat object (or also a land object?) would ask for the updated sailbot speed. I'd like to discuss this later, mostly for my own curiosity haha

Copy link
Contributor Author

@SPDonaghy SPDonaghy Oct 29, 2024

Choose a reason for hiding this comment

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

Boat objects need Sailbot's speed to calculate the size of the collision_zone for the moving ship. Land doesn't need Sailbot's speed, but still makes use of Sailbot's position when creating a state space like box in which it searches for intersections with land.

src/local_pathfinding/local_pathfinding/obstacles.py Outdated Show resolved Hide resolved
Comment on lines 222 to 228
if len(polygons) == 0:
return []

elif len(polygons) == 1:
return [_latlon_polygon_to_xy_polygon(polygons[0])]

return list(map(_latlon_polygon_to_xy_polygon, polygons))

Choose a reason for hiding this comment

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

What's the rationale for the different returns? I'm concerned the calling code will need to be more complicated to handle these cases

Copy link
Contributor Author

@SPDonaghy SPDonaghy Oct 29, 2024

Choose a reason for hiding this comment

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

The rationale is that based on the proximity to land and the shape of the coastline and state-space, we could be dealing with multiple polygons, a single polygon, or none so the function needs to consider those three possible cases. I get what you are saying, I'll just have the function do nothing if the list is empty or contains empty geometry. Only update_land_collision_zone will call this function. I am thinking of moving this function to coord_sytems.py thoughts? moved it.

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.

Implement Land Obstacle Class
4 participants