From 07ccf707e76c06434b147a0b5e50ae869ef131bf Mon Sep 17 00:00:00 2001 From: hhenry01 Date: Thu, 2 Nov 2023 21:18:08 -0700 Subject: [PATCH] Bring in custom_interface updates --- lib/protofiles/sensors.proto | 14 +++++++------- .../local_transceiver/src/local_transceiver.cpp | 7 +++++-- .../test/test_local_transceiver.cpp | 1 - projects/remote_transceiver/src/sailbot_db.cpp | 8 ++------ .../test/test_remote_transceiver.cpp | 12 ++++++------ 5 files changed, 20 insertions(+), 22 deletions(-) diff --git a/lib/protofiles/sensors.proto b/lib/protofiles/sensors.proto index 136d60d..cdd307e 100755 --- a/lib/protofiles/sensors.proto +++ b/lib/protofiles/sensors.proto @@ -29,8 +29,8 @@ message Sensors uint32 id = 1; float latitude = 2; float longitude = 3; - float speed = 4; - float heading = 5; + float sog = 4; + float cog = 5; float rot = 6; float width = 7; float length = 8; @@ -49,10 +49,10 @@ message Sensors float longitude = 2; } - Gps gps = 1; - repeated Wind wind_sensors = 2; - repeated Battery batteries = 3; - repeated Ais ais_ships = 4; - repeated Generic data_sensors = 5; + Gps gps = 1; + repeated Wind wind_sensors = 2; + repeated Battery batteries = 3; + repeated Ais ais_ships = 4; + repeated Generic data_sensors = 5; repeated Path local_path_data = 6; } diff --git a/projects/local_transceiver/src/local_transceiver.cpp b/projects/local_transceiver/src/local_transceiver.cpp index ac2b147..ae8b7bf 100644 --- a/projects/local_transceiver/src/local_transceiver.cpp +++ b/projects/local_transceiver/src/local_transceiver.cpp @@ -38,10 +38,13 @@ void LocalTransceiver::SensorBuf::updateSensor(msg::AISShips ships) for (const msg::HelperAISShip & ship : ships.ships) { Sensors::Ais * new_ship = sensors_.add_ais_ships(); new_ship->set_id(ship.id); - new_ship->set_heading(ship.heading.heading); + new_ship->set_cog(ship.cog.heading); new_ship->set_latitude(ship.lat_lon.latitude); new_ship->set_longitude(ship.lat_lon.longitude); - new_ship->set_speed(ship.speed.speed); + new_ship->set_sog(ship.sog.speed); + new_ship->set_rot(ship.rot.rot); + new_ship->set_width(ship.width.dimension); + new_ship->set_length(ship.length.dimension); } } diff --git a/projects/local_transceiver/test/test_local_transceiver.cpp b/projects/local_transceiver/test/test_local_transceiver.cpp index 22e0f13..847a937 100644 --- a/projects/local_transceiver/test/test_local_transceiver.cpp +++ b/projects/local_transceiver/test/test_local_transceiver.cpp @@ -9,7 +9,6 @@ class TestLocalTransceiver : public ::testing::Test { protected: - // TestLocalTransceiver() : lcl_trns_(LocalTransceiver(LOCAL_TRANSCEIVER_TEST_PORT, SATELLITE_BAUD_RATE)) {} TestLocalTransceiver() { try { diff --git a/projects/remote_transceiver/src/sailbot_db.cpp b/projects/remote_transceiver/src/sailbot_db.cpp index 4c31cf4..8b9185a 100644 --- a/projects/remote_transceiver/src/sailbot_db.cpp +++ b/projects/remote_transceiver/src/sailbot_db.cpp @@ -79,15 +79,14 @@ bool SailbotDB::storeAis(const ProtoList & ais_ships_pb) // The BSON spec does not allow unsigned integers (throws exception), so cast our uint32s to sint64s ais_ships_doc_arr = ais_ships_doc_arr << bstream::open_document << "id" << static_cast(ais_ship.id()) << "latitude" - << ais_ship.latitude() << "longitude" << ais_ship.longitude() << "speed" << ais_ship.speed() - << "heading" << ais_ship.heading() << "rot" << ais_ship.rot() << "width" << ais_ship.width() + << ais_ship.latitude() << "longitude" << ais_ship.longitude() << "sog" << ais_ship.sog() + << "cog" << ais_ship.cog() << "rot" << ais_ship.rot() << "width" << ais_ship.width() << "length" << ais_ship.length() << bstream::close_document; } DocVal ais_ships_doc = ais_ships_doc_arr << bstream::close_array << bstream::finalize; return static_cast(ais_coll.insert_one(ais_ships_doc.view())); } - bool SailbotDB::storeGenericSensor(const ProtoList & generic_pb) { mongocxx::collection generic_coll = db_[COLLECTION_DATA_SENSORS]; @@ -101,7 +100,6 @@ bool SailbotDB::storeGenericSensor(const ProtoList & generic_p return static_cast(generic_coll.insert_one(generic_doc.view())); } - bool SailbotDB::storeBatteries(const ProtoList & battery_pb) { mongocxx::collection batteries_coll = db_[COLLECTION_BATTERIES]; @@ -115,7 +113,6 @@ bool SailbotDB::storeBatteries(const ProtoList & battery_pb) return static_cast(batteries_coll.insert_one(batteries_doc.view())); } - bool SailbotDB::storeWindSensor(const ProtoList & wind_pb) { mongocxx::collection wind_coll = db_[COLLECTION_WIND_SENSORS]; @@ -129,7 +126,6 @@ bool SailbotDB::storeWindSensor(const ProtoList & wind_pb) return static_cast(wind_coll.insert_one(wind_doc.view())); } - bool SailbotDB::storePathSensor(const ProtoList & path_pb) { mongocxx::collection path_coll = db_[COLLECTION_PATH]; diff --git a/projects/remote_transceiver/test/test_remote_transceiver.cpp b/projects/remote_transceiver/test/test_remote_transceiver.cpp index ef86162..b621bad 100644 --- a/projects/remote_transceiver/test/test_remote_transceiver.cpp +++ b/projects/remote_transceiver/test/test_remote_transceiver.cpp @@ -74,8 +74,8 @@ class TestDB : public SailbotDB ais_ship->set_id(static_cast(ais_ships_doc["id"].get_int64().value)); ais_ship->set_latitude(static_cast(ais_ships_doc["latitude"].get_double().value)); ais_ship->set_longitude(static_cast(ais_ships_doc["longitude"].get_double().value)); - ais_ship->set_speed(static_cast(ais_ships_doc["speed"].get_double().value)); - ais_ship->set_heading(static_cast(ais_ships_doc["heading"].get_double().value)); + ais_ship->set_sog(static_cast(ais_ships_doc["sog"].get_double().value)); + ais_ship->set_cog(static_cast(ais_ships_doc["cog"].get_double().value)); ais_ship->set_rot(static_cast(ais_ships_doc["rot"].get_double().value)); ais_ship->set_width(static_cast(ais_ships_doc["width"].get_double().value)); ais_ship->set_length(static_cast(ais_ships_doc["length"].get_double().value)); @@ -188,8 +188,8 @@ void genRandAisData(Sensors::Ais * ais_ship) ais_ship->set_id(id_dist(g_mt)); ais_ship->set_latitude(lat_dist(g_mt)); ais_ship->set_longitude(lon_dist(g_mt)); - ais_ship->set_speed(speed_dist(g_mt)); - ais_ship->set_heading(heading_dist(g_mt)); + ais_ship->set_sog(speed_dist(g_mt)); + ais_ship->set_cog(heading_dist(g_mt)); ais_ship->set_rot(rot_dist(g_mt)); ais_ship->set_width(width_dist(g_mt)); ais_ship->set_length(length_dist(g_mt)); @@ -325,8 +325,8 @@ TEST_F(TestRemoteTransceiver, TestStoreSensors) EXPECT_EQ(dumped_ais_ships.id(), rand_ais_ships.id()); EXPECT_FLOAT_EQ(dumped_ais_ships.latitude(), rand_ais_ships.latitude()); EXPECT_FLOAT_EQ(dumped_ais_ships.longitude(), rand_ais_ships.longitude()); - EXPECT_FLOAT_EQ(dumped_ais_ships.speed(), rand_ais_ships.speed()); - EXPECT_FLOAT_EQ(dumped_ais_ships.heading(), rand_ais_ships.heading()); + EXPECT_FLOAT_EQ(dumped_ais_ships.sog(), rand_ais_ships.sog()); + EXPECT_FLOAT_EQ(dumped_ais_ships.cog(), rand_ais_ships.cog()); EXPECT_FLOAT_EQ(dumped_ais_ships.rot(), rand_ais_ships.rot()); EXPECT_FLOAT_EQ(dumped_ais_ships.width(), rand_ais_ships.width()); EXPECT_FLOAT_EQ(dumped_ais_ships.length(), rand_ais_ships.length());