Skip to content
This repository has been archived by the owner on Jan 2, 2024. It is now read-only.

Create Land Obstacle #240

Merged
merged 16 commits into from
Oct 11, 2021
Merged

Create Land Obstacle #240

merged 16 commits into from
Oct 11, 2021

Conversation

patrick-5546
Copy link
Member

@patrick-5546 patrick-5546 commented Sep 28, 2021

Resolves #238

  • Created the GeneralPolygon obstacle in the visualizer to represent land
  • Created the land_mass_creator.py script to generate land mass input data (see discussion below)

Additional Dependencies

  • Shapely
    pip install shapely
    

Usage

The rosparam land_mass_file is a path (relative to this repo's root directory) to a land mass file containing its bounding latlons.

roslaunch local_pathfinding all.launch land_mass_file:=land_masses/land_mass_2.csv

image

@tylerlum
Copy link
Contributor

tylerlum commented Oct 2, 2021

Started debugging the issue. Nothing intelligent, just tons of prints with help of vim
image

Stops at

    state = sailbot.getCurrentState()

Further analysis of prints leads to finding the loop

image
image

Essentially, goal waypoint is always invalid. Must be something wrong with the new polygon

@tylerlum
Copy link
Contributor

tylerlum commented Oct 2, 2021

Played around with it a bit more and got it working! Will let you enjoy the fun of getting it working yourself ;)

@tylerlum
Copy link
Contributor

tylerlum commented Oct 2, 2021

Great work, very clean code additions

@tylerlum
Copy link
Contributor

tylerlum commented Oct 2, 2021

Because the above is a potentially infinite while loop, we should add rospy logs.

@patrick-5546 patrick-5546 marked this pull request as ready for review October 3, 2021 01:55
@patrick-5546
Copy link
Member Author

patrick-5546 commented Oct 5, 2021

land_mass_creator.py

Additional Dependencies

  • netCDF4
    sudo apt-get update
    sudo apt-get install python-netcdf4
    

Usage

❯ ./land_masses/land_mass_creator.py -h

usage: land_mass_creator.py [-h] [-d THRESHOLD_DEPTH] south north west east

Returns locations of shallow water or land, given coordinates

positional arguments:
  south                 bottom latitude bound
  north                 top latitude bound
  west                  left longitude bound
  east                  right longitude bound

optional arguments:
  -h, --help            show this help message and exit
  -d THRESHOLD_DEPTH, --threshold_depth THRESHOLD_DEPTH
                        maximum depth below sea level of the returned location
                        (in metres, exclusive, default 5)
❯ ./land_masses/land_mass_creator.py 49.115757 49.303264 -123.394709 -123.159747

netCDF dimensions: 48.0020833333 49.4979166667 -124.997916667 -123.002083333
nc index bounds: lat=[267,312) lon=[384,441)
Saved to land_masses/land_depth_5m_10_05_2021-00_02_47.(csv|kml)
Took 0.420228004456 seconds

Outputs

Max depth below sea level of land mass: 5m

  • Would this change substantially with the tide?
KML CSV -> Visualizer
image image

@patrick-5546
Copy link
Member Author

isValid() Performance

Methodology

import timeit
...
class GeneralPolygon(ObstacleInterface):
...
    def isValid(self, xy):
        start = timeit.default_timer()
        is_valid = not self.shapely_polygon.contains(ShapelyPoint(xy[0], xy[1]))
        stop = timeit.default_timer()
        rospy.logfatal('isValid() took {} seconds'.format(stop - start))
        return is_valid

Results

Note: these are upper bounds, average runtime is much faster

  • WedgeObstacle: < 5e-05 seconds
  • HybridCircleObstacle: < 8e-05 seconds
  • GeneralPolygon:
    • land_mass_1.csv (4 points): < 5e-04 seconds
    • land_mass_2.csv (40 points): < 5e-04 seconds
    • vancouver_depth_5m_10_11_2021-10_28_14.csv (84 points): < 7e-04 seconds

Conclusion

The runtime of isValid() in GeneralPolygon (which uses shapely.geometry.polygon.contains()) is an order of magnitude slower than WedgeObstacle. However, it is negligibly impacted by the complexity of a polygon that we would use for a land mass.

Copy link
Contributor

@tylerlum tylerlum left a comment

Choose a reason for hiding this comment

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

Impressive results and testing. Great work. Let's get this merged in :)

python/obstacles.py Outdated Show resolved Hide resolved
@patrick-5546 patrick-5546 merged commit 7a705f0 into master Oct 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ensure we don't hit land
3 participants