Skip to content

Commit

Permalink
digitraffic added
Browse files Browse the repository at this point in the history
  • Loading branch information
TedSjoblom committed Aug 21, 2024
1 parent 05e01eb commit a22942c
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 12 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ python3 bin/main.py --log-level 10 -r rise -e ted --publish log --subscribe digi
```


## Record

```bash
sudo docker run --rm --network host --name mcap-logger --volume ~/rec:/rec ghcr.io/rise-maritime/keelson:0.3.7-pre.51 "mcap-record --output_path rec -k rise/v0/ted/**"
```



Expand Down
63 changes: 51 additions & 12 deletions bin/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,41 +159,80 @@ def sub_digitraffic_data(data):
payload_target_description.data_source.source.append(DataSource.Source.AIS_PROVIDER)
payload_target_description.timestamp.FromNanoseconds(time_now)

# MMSI
mmsi = str(data.key_expr).split("/")[-2]
payload_target.mmsi = int(mmsi)
payload_target_description.mmsi = int(mmsi)




if str(data.key_expr).split("/")[-1] == "location":

logging.debug(f"Location: {data_dict}")

mmsi = str(data.key_expr).split("/")[-2]
payload_target.mmsi = int(mmsi)

# NAVIGATIONN STATUS
status = data_dict.navStat
status = data_dict["navStat"]
payload_target.navigation_status = set_navigation_status_enum(status)

# ROT, SOG, COG, HDG
payload_target.rate_of_turn_degrees_per_minute = data_dict.rot
payload_target.speed_over_ground_knots = data_dict.sog
payload_target.course_over_ground_knots = data_dict.cog
payload_target.heading_degrees = data_dict.heading
payload_target.rate_of_turn_degrees_per_minute = data_dict["rot"]
payload_target.speed_over_ground_knots = data_dict["sog"]
payload_target.course_over_ground_knots = data_dict["cog"]
payload_target.heading_degrees = data_dict["heading"]

if AIS_DB.get(str(mmsi)):
latitude_adj, longitude_adj = position_to_common_center_point(data_dict.lat, data_dict.lon, data_dict.heading, AIS_DB[str(
latitude_adj, longitude_adj = position_to_common_center_point(data_dict["lat"], data_dict["lon"], data_dict["heading"], AIS_DB[str(
mmsi)]["to_bow"], AIS_DB[str(mmsi)]["to_stern"], AIS_DB[str(mmsi)]["to_port"], AIS_DB[str(mmsi)]["to_starboard"])
payload_target.latitude_degrees = latitude_adj
payload_target.longitude_degrees = longitude_adj

else:
payload_target.latitude_degrees = data_dict.lat
payload_target.longitude_degrees = data_dict.lon
payload_target.latitude_degrees = data_dict["lat"]
payload_target.longitude_degrees = data_dict["lon"]

publish_message(payload_target, "target", mmsi, session, args, logging)

elif str(data.key_expr).split("/")[-1] == "metadata":
logging.debug(f"Metadata: {data_dict}")

# MMSI
mmsi = str(data.key_expr).split("/")[-2]
payload_target.mmsi = int(mmsi)
payload_target_description.mmsi = int(mmsi)

payload_target_description.name = data_dict["name"]
payload_target_description.callsign = data_dict["callSign"]
payload_target_description.vessel_type = set_target_type_enum(data_dict["type"])
payload_target_description.imo = data_dict["imo"]

width = data_dict["refC"] + data_dict["refD"]
length = data_dict["refB"] + data_dict["refA"]

new_to_bow = length / 2
new_to_stern = -length / 2
new_to_starboard = width / 2
new_to_port = -width / 2

payload_target_description.to_bow_meters = new_to_bow
payload_target_description.to_stern_meters = new_to_stern
payload_target_description.to_starboard_meters = new_to_starboard
payload_target_description.to_port_meters = new_to_port

payload_target_description.destination = data_dict["destination"]
payload_target_description.draft_meters = data_dict["draught"]
payload_target_description.estimated_time_of_arrival = str(data_dict["eta"])

# for AIS position correction
AIS_DB[str(mmsi)] = {
"to_bow": data_dict["refA"],
"to_stern": data_dict["refB"],
"to_starboard": data_dict["refD"],
"to_port": data_dict["refC"]
}
publish_message(payload_target_description, "target_description",
mmsi, session, args, logging)


else:
logging.warning(f"Unknown data: {data_dict}")

Expand Down

0 comments on commit a22942c

Please sign in to comment.