-
Notifications
You must be signed in to change notification settings - Fork 3
Rework wind cost function in ompl objectives #817
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
base: main
Are you sure you want to change the base?
Changes from 6 commits
2b0902d
f48c7a0
cd822c1
983fce3
cfcbd13
0a5463b
ee01c43
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,6 +15,8 @@ | |
| ACCEPTABLE_COST_THRESHOLD = 0.85 | ||
| WIND_OBJECTIVE_WEIGHT = 0.85 | ||
| TIME_OBJECTIVE_WEIGHT = 0.15 | ||
| NO_GO_ZONE = math.pi / 4 | ||
| WIND_COST_SIN_EXPONENT = 80 | ||
|
|
||
|
|
||
| # Estimated Boat Speeds (kmph) as function of True Wind Speed (kmph) | ||
|
|
@@ -94,8 +96,14 @@ def motionCost(self, s1: ob.SE2StateSpace, s2: ob.SE2StateSpace) -> ob.Cost: | |
|
|
||
| @staticmethod | ||
| def wind_direction_cost(s1: cs.XY, s2: cs.XY, tw_direction_rad: float) -> float: | ||
| """Returns a high cost when the path segment from s1 to s2 is pointing directly | ||
| (or close to directly) upwind or downwind. | ||
| """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 | ||
| downwind), the cost is 1.0. | ||
| 2) Otherwise, the cost is sin(2θ) ** WIND_COST_SIN_EXPONENT. | ||
|
|
||
| The cost is symmetric about both upwind (0) and downwind (π) and always lies in [0, 1]. | ||
|
|
||
| Args: | ||
| s1 (cs.XY): The start point of the path segment | ||
|
|
@@ -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)) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. If you do look into this issue, please also change the naming of the winds to our new standard. Eg. |
||
| cos_angle = math.cos(tw_angle_rad) | ||
|
|
||
| if cos_angle > 0: | ||
| return UPWIND_COST_MULTIPLIER * cos_angle | ||
| else: | ||
| return DOWNWIND_COST_MULTIPLIER * abs(cos_angle) | ||
| # NO-GO ZONE | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
| if tw_angle_rad <= NO_GO_ZONE or tw_angle_rad >= math.pi - NO_GO_ZONE: | ||
| return 1.0 | ||
|
|
||
| cost = math.sin(2*tw_angle_rad) ** WIND_COST_SIN_EXPONENT | ||
| return cost | ||
|
|
||
|
|
||
| class TimeObjective(ob.OptimizationObjective): | ||
|
|
||
There was a problem hiding this comment.
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.