Skip to content

Commit 1778b70

Browse files
authored
Merge branch 'main' into Jay/update-codeowner-package-json-fix
2 parents 9004013 + 960d6a8 commit 1778b70

File tree

2 files changed

+42
-5
lines changed

2 files changed

+42
-5
lines changed

src/local_pathfinding/local_pathfinding/visualizer.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,14 @@ def __init__(self, msgs: List[ci.LPathData]):
8383
*[self._split_coordinates(waypoints) for waypoints in self.all_wp_xy]
8484
)
8585

86+
# AIS ships
87+
self.ais_ships = self.curr_msg.ais_ships.ships
88+
ais_ship_latlons = [ship.lat_lon for ship in self.ais_ships]
89+
self.ais_ship_ids = [ship.id for ship in self.ais_ships]
90+
ais_ship_xy = cs.latlon_list_to_xy_list(self.reference_latlon, ais_ship_latlons)
91+
self.ais_pos_x, self.ais_pos_y = self._split_coordinates(ais_ship_xy)
92+
self.ais_headings = [ship.cog.heading for ship in self.ais_ships]
93+
8694
# TODO: Include other LPathData attributes for plotting their data
8795

8896
# Process land obstacles
@@ -508,6 +516,35 @@ def live_update_plot(state: VisualizerState) -> go.Figure:
508516
y_min = min(state.final_local_wp_y) - 10
509517
y_max = max(state.final_local_wp_y) + 10
510518

519+
# Display AIS Ships
520+
for x_val, y_val, heading, ais_id in zip(
521+
state.ais_pos_x, state.ais_pos_y, state.ais_headings, state.ais_ship_ids
522+
):
523+
fig.add_trace(
524+
go.Scatter(
525+
x=[x_val],
526+
y=[y_val],
527+
mode="markers",
528+
name=f"AIS {str(ais_id)}",
529+
hovertemplate=(
530+
f"<b>🚢 AIS Ship {str(ais_id)}</b><br>"
531+
f"X: {x_val:.2f}<br>"
532+
f"Y: {y_val:.2f}<br>"
533+
f"Heading: {heading:.1f}°<extra></extra>"
534+
),
535+
marker=dict(
536+
symbol="arrow-wide",
537+
line_color="orange",
538+
color="orange",
539+
line_width=2,
540+
size=15,
541+
angleref="up",
542+
angle=cs.true_bearing_to_plotly_cartesian(heading),
543+
),
544+
showlegend=False,
545+
)
546+
)
547+
511548
# Update Layout
512549
fig.update_layout(
513550
title="Path Planning",
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
id,latitude,longitude,heading,speed,rot,width,height
2-
1,45.0,0.0,90.0,1.0,1,1.0,1.0
3-
2,45.0,2.0,90.0,15.0,2,2.0,2.0
4-
3,45.0,3.0,3.0,3.0,3,3.0,3.0
5-
4,45.0,4.0,4.0,4.0,4,4.0,4.0
6-
5,45.0,5.0,5.0,5.0,5,5.0,5.0
2+
1,49.01261318191024,-135.65593922412154,90.0,40.0,30,1.0,1.0
3+
2,48.67919212345747,-132.94724986187234,90.0,40.0,50,2.0,2.0
4+
3,48.11352031871804,-135.67990496461405,30,80.0,-50,3,3.0
5+
4,48.1970229368345,-128.93710143805356,4.0,20.0,-30,4.0,4.0
6+
5,48.51027819947852,-126.15925374786544,5.0,10.0,20,5.0,5.0

0 commit comments

Comments
 (0)