UBCSailbot / raye-global-pathfinding

UBC Sailbot's Global Pathfinding Repository: A* pathfinding that creates sailing paths with minimized length and desirable wind speeds throughout.
MIT License
5 stars 1 forks source link

Wind csv #40

Closed tylerlum closed 3 years ago

tylerlum commented 3 years ago

READY FOR REVIEW.

The purpose of this PR is to allow for csv writing and reading for custom weather tests.

There are three possible options:

  1. Do not pass anything to -g. Eg. ./build/bin/pathfinder_cli -p 8 --navigate 48 235 21 203
  2. Pass in a grb file to -g. Eg. ./build/bin/pathfinder_cli -p 8 --navigate 48 235 21 203 -g mydata.grb
  3. Pass in a csv file to -g. Eg. ./build/bin/pathfinder_cli -p 8 --navigate 48 235 21 203 -g csv (not path to csv file, just exactly csv)

In options 1 and 2, it saves the weather data into the output_csvs directory in the following files:

angles2d-0.csv  angles2d-1.csv  angles2d-2.csv  angles2d-3.csv  lats2d.csv  lons2d.csv  magnitudes2d-0.csv  magnitudes2d-1.csv  magnitudes2d-2.csv  magnitudes2d-3.csv

In option 3, it reads from input_csvs those same filenames. Those files can be modified to make custom tests.

An example of input_csvs are included in this PR, and can be modified as desired.

May want to find a cleaner way to pass in custom files and save custom files. For now, just modify the files in input_csvs as needed.

tylerlum commented 3 years ago

Good idea from Kieran:

tylerlum commented 3 years ago

image

Example of usage. Change the magnitudes.csv and run ./build/bin/pathfinder_cli -p 8 --navigate 48 235 21 203 -g csv

tylerlum commented 3 years ago

image

tylerlum commented 3 years ago

Still have some questions about how this works. For instance, the time steps only work for the first 4. Maybe that's all that can be gotten? If that's the case, it seems like the 4th row is the one that matters most

tylerlum commented 3 years ago

Notes from discussion:

image image image

Summary: Change from huge row to more clear xy coordinates so that magnitudes can be modified more easily.

tylerlum commented 3 years ago

Found bug! Reading csv wrong, missing last element on each row.

CSV

|
readCSV
|
Nice Intuitive 2D Representation From CSV
lats2d = [[  22,    22,   22,  22]
               [  21,    21,   21,  21]]
lons2d = [[203, 204, 205, 206]
                [203, 204, 205, 206]]
mags2d =[[  14,    15,   16,  17]
                 [  10,    11,   12,  13]]
Angs2d = [[ 00,    00,    00,     00]
         [  00,    00,    00,    00]]
|
reverseColumns
|
2D Representation Just Before 1D Conversion
lats2d = [[  21,    21,   21,  21]
               [  22,    22,   22,  22]]
lons2d = [[203, 204, 205, 206]
                [203, 204, 205, 206]]
mags2d =[[  10,    11,   12,  13]
                 [  14,    15,   16,  17]]
Angs2d = [[ 00,    00,    00,     00]
         [  00,    00,    00,    00]]
|
convert2Dto1D
|
WHAT THE GRIBPARSE CLASS ACTUALLY HAS
lats =   [  21,   21,   21,   21,   22,   22,   22,   22]
lons =  [203, 204, 205, 206, 203, 204, 205, 206]
mags = [  10,   11,   12,  13,   10,   11,   12,   13]
angs =  [  00,   00,   00,  00,   00,   00,   00,   00]

south = 21
north = 22
west = 203
east = 206

What is gribIndex of (lat=22, lon=204)?
gi = (22-21)*(206-203+1) + (204-203) = 1(4) + 1 = 5
What is gribIndex of (lat=21, lon=206)?
gi = (21-21)*(206-203+1) + (206-203) = 0(4) + 3 = 3
      gribIndex = (lat-south) * (east-west+1) + (lon-west);

TEST OUTPUT

intuitiveLats
22.000000,22.000000,22.000000,
21.000000,21.000000,21.000000,
intuitiveLons
203.000000,204.000000,205.000000,
203.000000,204.000000,205.000000,
intuitiveMags3
14.000000,15.000000,16.000000,
10.000000,11.000000,12.000000,
intuitiveAngs3
0.000000,0.000000,0.000000,
0.000000,0.000000,0.000000,
reversedLats
21.000000,21.000000,21.000000,
22.000000,22.000000,22.000000,
reversedLons
203.000000,204.000000,205.000000,
203.000000,204.000000,205.000000,
reversedMags3
10.000000,11.000000,12.000000,
14.000000,15.000000,16.000000,
reversedAngs3
0.000000,0.000000,0.000000,
0.000000,0.000000,0.000000,
readyLats
21.000000,21.000000,21.000000,22.000000,22.000000,22.000000,
readyLons
203.000000,204.000000,205.000000,203.000000,204.000000,205.000000,
readyMags3
10.000000,11.000000,12.000000,14.000000,15.000000,16.000000,
readyAngs3
0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,
tylerlum commented 3 years ago

image

FIXED! @kpfgallagher thank you for the debugging skills :D

tylerlum commented 3 years ago

@kpfgallagher ready for re-review

kpfgallagher commented 3 years ago

Seems like there is a visible difference in the paths when presented with an obstacle, although it doesn't avoid it fully. This is with a weather factor of 3000.

Screenshot from 2021-05-22 11-19-24 Screenshot from 2021-05-22 11-22-48

kpfgallagher commented 3 years ago

And this is with a weather factor of 10000 - even more avoidance.

Screenshot from 2021-05-22 11-27-29

tylerlum commented 3 years ago

Great! Will get this merged in. Will be good to add some README info in another PR