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

incoming wave height service #152

Merged
merged 20 commits into from
Sep 7, 2023
Merged

incoming wave height service #152

merged 20 commits into from
Sep 7, 2023

Conversation

andermi
Copy link
Collaborator

@andermi andermi commented Jul 12, 2023

Adds ROS 2 service to check incoming wave height and normal vector (slope of wave) at an array of points.

requires osrf/mbari_wec_utils#53 and hamilton8415/FreeSurfaceHydrodynamics#5

NOTE: had to change the LinearIncidentWave object in ECM to non-pointer... need to get to the bottom of that if we want to keep it as a pointer.

for testing:
send_iwh_req.py.zip

@andermi andermi changed the base branch from main to andermi/atsea_spring July 12, 2023 19:09
@andermi andermi marked this pull request as ready for review August 28, 2023 22:27
Signed-off-by: Michael Anderson <[email protected]>
Base automatically changed from andermi/atsea_spring to andermi/fix_fshydro_includes August 30, 2023 23:21
Base automatically changed from andermi/fix_fshydro_includes to main August 31, 2023 06:26
@andermi
Copy link
Collaborator Author

andermi commented Sep 6, 2023

@hamilton8415 I'm adding a stamp to evaluate the height at a specific time, and was wondering if I should make it relative to current time or absolute? I feel like relative to current time would be more useful... e.g. evaluate 10 seconds from now

… request points in relative_time to current sim time

Signed-off-by: Michael Anderson <[email protected]>
Signed-off-by: Michael Anderson <[email protected]>
@andermi
Copy link
Collaborator Author

andermi commented Sep 6, 2023

@hamilton8415 I made it relative for now (easily changed)

@hamilton8415
Copy link
Collaborator

Yes, I think that's a reasonable choice.

@hamilton8415
Copy link
Collaborator

Only hiccup would be if there's a question of when "now" is, presumably it will return relative to the sim time when the service request is handled, that may be slightly different than the time in user-code, which would be when the last ROS messages were sent out. Small differences though, using absolute time may alleviate that. May, I need to think more...

@andermi
Copy link
Collaborator Author

andermi commented Sep 6, 2023

In the response, I'm having it return the requested relative_time value as well as the simulation time it was computed

@andermi
Copy link
Collaborator Author

andermi commented Sep 6, 2023

So, a user could see when exactly that height is valid using stamp + relative_tine

@andermi
Copy link
Collaborator Author

andermi commented Sep 6, 2023

@hamilton8415
unzip this and use for testing:
send_iwh_req.py.zip

./send_iwh_req.py -x 1 2 3 -y 4 5 6 -t 5.0 --use_buoy_origin

heights:
- relative_time: 5.0
  use_buoy_origin: true
  pose:
    header:
      stamp:
        sec: 1942
        nanosec: 610000000
      frame_id: ''
    pose:
      position:
        x: 1.0
        y: 4.0
        z: 0.4209758150407607
      orientation:
        x: -0.005023644234914708
        y: -0.006724968921953192
        z: -3.378504167932509e-05
        w: 0.9999647677044281
- relative_time: 5.0
  use_buoy_origin: true
  pose:
    header:
      stamp:
        sec: 1942
        nanosec: 610000000
      frame_id: ''
    pose:
      position:
        x: 2.0
        y: 5.0
        z: 0.39561125637893335
      orientation:
        x: -0.005473899615728417
        y: -0.0073276819083833425
        z: -4.01126731328616e-05
        w: 0.9999581690709967
- relative_time: 5.0
  use_buoy_origin: true
  pose:
    header:
      stamp:
        sec: 1942
        nanosec: 610000000
      frame_id: ''
    pose:
      position:
        x: 3.0
        y: 6.0
        z: 0.3735285312008714
      orientation:
        x: -0.003536647965169145
        y: -0.00473442910203527
        z: -1.6744301432939676e-05
        w: 0.9999825383584839
valid: true
$ ./send_iwh_req.py -h
usage: send_iwh_req.py [-h] [-x X [X ...]] [-y Y [Y ...]] [--use_buoy_origin] [-t T]

options:
  -h, --help         show this help message and exit
  -x X [X ...]       one or more x points to evaluate wave height
  -y Y [Y ...]       one or more y points to evaluate wave height
  --use_buoy_origin  points are relative to buoy origin (world otherwise)
  -t T               enter relative time (+/-) in decimal seconds from sim time to compute height

@hamilton8415
Copy link
Collaborator

Thanks for the interrogation script. Working nicely. Two items...

  • I am still thinking about the relative/absolute time question. Use of this for model-predictive control will involve collecting a number of wave-heights at a series of times into the future (5-20 seconds worth), if the simulation advances while these requests are being made, there will be a small glitch in the even-spacing of the time-reports, if I understand correctly. For programmatic use, it might be best to do this as absolute time so that one really is sure to get what they are asking for.
  • Similarly for the position report, it seems to be reporting in whatever coordinate system the request is made in (buoy or world), I'm thinking it might be better to always report the sample position in world coordinates, that's new information rather than parroting back the request, and this then doubles as a way to find out where the buoy is. Might require a little thought to decide where the world origin is in the at-sea case...

Finally, I'm imagining that in an in-the-field case where there are wave-buoy measurement buoys, we'd set those sensors up to provide this same service, so the simulation/field difference is just who is providing the response.

@andermi
Copy link
Collaborator Author

andermi commented Sep 6, 2023

series of times into the future (5-20 seconds worth), if the simulation advances while these requests are being made

I had envisioned a single request for all rather than a series of requests. I could use an array for the relative_time to be 1-to-1 per point so it would be a snapshot and no advancement would happen... I just figured this would be less bookkeeping for the user. Absolute time would require them to still do the math on their end anyways?

For your second item (and setting up coords at-sea), there's a couple ways to do it...

  1. all bodies in lat/lon and Vincenty's formula for relative dist/az which could be converted to cartesian
  2. all bodies in local cartesian about fixed world lat/lon, so this would just be (1) with the cartesian conversion relative to the fixed world lat/lon rather than between bodies

@hamilton8415
Copy link
Collaborator

Ah yes, if an array of times at a single location is possible, that works fine then. I'm on the fence, so let's leave it relative for now.

I think option (2) for the locations, stick to cartessian, with a specified anchor location as the origin, that's certainly easiest in the simulator, and if outside wave-buoys report in lat/lon, then conversion relative to a fixed anchor point might be needed.

@andermi
Copy link
Collaborator Author

andermi commented Sep 6, 2023

I'm on the fence

When in doubt, do both! :-p

updated the python script:
send_iwh_req.py.zip

@andermi
Copy link
Collaborator Author

andermi commented Sep 6, 2023

still working on (2)

@hamilton8415
Copy link
Collaborator

Of course I knew you would do both. :)

@andermi
Copy link
Collaborator Author

andermi commented Sep 6, 2023

done with (2)

Signed-off-by: Michael Anderson <[email protected]>
@hamilton8415
Copy link
Collaborator

This is all working pretty nicely for me. I am a bit unsure how to access the absolute versus relative time request I thought you were hinting at. The lastest .py file didn't have an obvious option. Similarly, does that tool multiple location/time requests, and if so what's the syntax.

@andermi
Copy link
Collaborator Author

andermi commented Sep 7, 2023

oh, I can update the tool to do absolute_time... I just hardcoded relative

@andermi
Copy link
Collaborator Author

andermi commented Sep 7, 2023

latest python tool
send_iwh_req.py.zip

you can add multiple points by just making space-separated values after -x, -y, -abs_t/-rel_t

$ ./send_iwh_req.py -h
usage: send_iwh_req.py [-h] [-x X [X ...]] [-y Y [Y ...]] [--use_buoy_origin]
                       [--rel_t REL_T [REL_T ...]] [--abs_t ABS_T [ABS_T ...]]

options:
  -h, --help            show this help message and exit
  -x X [X ...]          one or more x points to evaluate wave height
  -y Y [Y ...]          one or more y points to evaluate wave height
  --use_buoy_origin     points are relative to buoy origin (world otherwise)
  --rel_t REL_T [REL_T ...]
                        enter one or more relative time (+/-) values in decimal seconds from sim
                        time to compute height
  --abs_t ABS_T [ABS_T ...]
                        enter one or more absolute time values in decimal seconds to compute height

$ ./send_iwh_req.py -x 1 2 3 -y 4 5 6 --rel_t 0.0 0.0 0.0 --use_buoy_origin

@hamilton8415
Copy link
Collaborator

Got it. All features are evident to me now. Looks great, the flexibility here should cover all of the cases I can imagine. Ship it. :)

Remove temporary checkout of utils branch
@andermi andermi enabled auto-merge (squash) September 7, 2023 05:24
@andermi andermi merged commit d846f5d into main Sep 7, 2023
2 checks passed
@andermi andermi deleted the andermi/incoming_wave_service branch September 7, 2023 06:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants