Skip to content

Commit

Permalink
test: add tests for position correction
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardacoppo committed Jan 15, 2025
1 parent 00e97d0 commit dabadf9
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions test/AISTask_test.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true

using_task_library "nmea0183"
using_task_library "ais_base"

describe OroGen.nmea0183.AISTask do
run_live
Expand All @@ -11,6 +12,11 @@
@task = syskit_deploy(
OroGen.nmea0183.AISTask.deployed_as("ais_task")
)
@task.properties.utm_configuration = Types.gps_base.UTMConversionParameters.new(
nwu_origin: Eigen::Vector3.new(0, 0, 0),
utm_zone: 11,
utm_north: true
)

# This complicated setup works around that data readers and writers
# in Syskit connect themselves only when their target tasks are running
Expand Down Expand Up @@ -155,6 +161,33 @@
assert_equal 0, stats.ignored_messages
end

it "corrects vessel's coordinates to be in the world frame if " \
"corresponding VesselInformation exists" do
msg05 = "!AIVDM,2,1,,B,55MgK40000000000003wwwwww4000000000000000010000" \
"Ht0000000,0*49\r\n!AIVDM,2,2,,B,000000000000008,2*1F\r\n"

msg01 = "!AIVDM,1,1,,B,15MgK4?P1cGJch0Igth3Q?wh0000,0*0F\r\n"

info, _, _ = expect_execution do
syskit_write @io.out_port, make_packet(msg05)
end.to do
[have_one_new_sample(task.vessels_information_port),
have_one_new_sample(task.voyages_information_port),
have_one_new_sample(task.ais_stats_port)]
end

position, stats = expect_execution do
syskit_write @io.out_port, make_packet(msg01)
end.to do
[have_one_new_sample(task.positions_port),
have_one_new_sample(task.ais_stats_port)]
end

assert_equal 366_730_000, position.mmsi
assert_in_delta 44.9999 * Math::PI / 180, position.latitude.rad, 1e-4
assert_in_delta -120 * Math::PI / 180, position.longitude.rad, 1e-4
end

def make_packet(sentence)
Types.iodrivers_base.RawPacket.new(
time: Time.now,
Expand Down

0 comments on commit dabadf9

Please sign in to comment.