Skip to content

Rework wind cost function in ompl objectives#817

Open
AMaharaj16 wants to merge 7 commits intomainfrom
AMaharaj16/wind-cost-rework-793
Open

Rework wind cost function in ompl objectives#817
AMaharaj16 wants to merge 7 commits intomainfrom
AMaharaj16/wind-cost-rework-793

Conversation

@AMaharaj16
Copy link
Contributor

The function wind_direction_cost() in ompl_objectives.py now correctly returns 1.0 when the segment heading lies within NO_GO_ZONE radians (45 degrees) of directly upwind (0) or directly downwind (π), and applies sin80(2θ) otherwise. Also replaced old test with new fully passing test suite for this improved implementation in test_ompl_objectives.py.

The wind cost function looks like this:
Screenshot 2026-02-18 222413

Copy link
Contributor

@raghumanimehta raghumanimehta left a comment

Choose a reason for hiding this comment

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

Please take a look at the longest comment I left on this review before anything else.

"""Computes a wind alignment cost based on the absolute angle θ between the segment
bearing and the true wind direction.

1) If θ ≤ NO_GO_ZONE or θ ≥ π − NO_GO_ZONE (i.e., within 45 degrees of directly upwind or
Copy link
Contributor

Choose a reason for hiding this comment

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

what is theta? Please define what you mean by theta here.

return UPWIND_COST_MULTIPLIER * cos_angle
else:
return DOWNWIND_COST_MULTIPLIER * abs(cos_angle)
# NO-GO ZONE
Copy link
Contributor

Choose a reason for hiding this comment

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

This comment, imo, is not required. The reader can understand what this is for by reading the if statement and the docs about the funciton.

@@ -107,12 +115,13 @@ def wind_direction_cost(s1: cs.XY, s2: cs.XY, tw_direction_rad: float) -> float:
"""
segment_true_bearing_rad = cs.get_path_segment_true_bearing(s1, s2, rad=True)
tw_angle_rad = abs(wcs.get_true_wind_angle(segment_true_bearing_rad, tw_direction_rad))
Copy link
Contributor

Choose a reason for hiding this comment

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

NOT YOUR FAULT.

While reviewing the PR, I realized that the conventions used in PATH are not consistent. Can you please look into it? Or let me know if you want me to look into it.
This funciton's example said that 0 degrees is from the bow. Other parts of the codebase are using 0 degrees as to the bow. This inconsistency is not nice. We should fix it asap. I am not going to review this PR for the time being.

If you do look into this issue, please also change the naming of the winds to our new standard. Eg. tw_speed_kmph_bcrather than wind_speed. There are also some cases where we name it as tw_speed_kmph, however notice the coordinate system is missing. Change these .i.e append bc or gc accordingly .

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.

2 participants