Skip to content
This repository has been archived by the owner on Mar 23, 2024. It is now read-only.

Commit

Permalink
Bring in custom_interface updates
Browse files Browse the repository at this point in the history
  • Loading branch information
hhenry01 committed Nov 3, 2023
1 parent eea0f11 commit 07ccf70
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 22 deletions.
14 changes: 7 additions & 7 deletions lib/protofiles/sensors.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
7 changes: 5 additions & 2 deletions projects/local_transceiver/src/local_transceiver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
1 change: 0 additions & 1 deletion projects/local_transceiver/test/test_local_transceiver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
class TestLocalTransceiver : public ::testing::Test
{
protected:
// TestLocalTransceiver() : lcl_trns_(LocalTransceiver(LOCAL_TRANSCEIVER_TEST_PORT, SATELLITE_BAUD_RATE)) {}
TestLocalTransceiver()
{
try {
Expand Down
8 changes: 2 additions & 6 deletions projects/remote_transceiver/src/sailbot_db.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,14 @@ bool SailbotDB::storeAis(const ProtoList<Sensors::Ais> & 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<int64_t>(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<bool>(ais_coll.insert_one(ais_ships_doc.view()));
}


bool SailbotDB::storeGenericSensor(const ProtoList<Sensors::Generic> & generic_pb)
{
mongocxx::collection generic_coll = db_[COLLECTION_DATA_SENSORS];
Expand All @@ -101,7 +100,6 @@ bool SailbotDB::storeGenericSensor(const ProtoList<Sensors::Generic> & generic_p
return static_cast<bool>(generic_coll.insert_one(generic_doc.view()));
}


bool SailbotDB::storeBatteries(const ProtoList<Sensors::Battery> & battery_pb)
{
mongocxx::collection batteries_coll = db_[COLLECTION_BATTERIES];
Expand All @@ -115,7 +113,6 @@ bool SailbotDB::storeBatteries(const ProtoList<Sensors::Battery> & battery_pb)
return static_cast<bool>(batteries_coll.insert_one(batteries_doc.view()));
}


bool SailbotDB::storeWindSensor(const ProtoList<Sensors::Wind> & wind_pb)
{
mongocxx::collection wind_coll = db_[COLLECTION_WIND_SENSORS];
Expand All @@ -129,7 +126,6 @@ bool SailbotDB::storeWindSensor(const ProtoList<Sensors::Wind> & wind_pb)
return static_cast<bool>(wind_coll.insert_one(wind_doc.view()));
}


bool SailbotDB::storePathSensor(const ProtoList<Sensors::Path> & path_pb)
{
mongocxx::collection path_coll = db_[COLLECTION_PATH];
Expand Down
12 changes: 6 additions & 6 deletions projects/remote_transceiver/test/test_remote_transceiver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ class TestDB : public SailbotDB
ais_ship->set_id(static_cast<uint32_t>(ais_ships_doc["id"].get_int64().value));
ais_ship->set_latitude(static_cast<float>(ais_ships_doc["latitude"].get_double().value));
ais_ship->set_longitude(static_cast<float>(ais_ships_doc["longitude"].get_double().value));
ais_ship->set_speed(static_cast<float>(ais_ships_doc["speed"].get_double().value));
ais_ship->set_heading(static_cast<float>(ais_ships_doc["heading"].get_double().value));
ais_ship->set_sog(static_cast<float>(ais_ships_doc["sog"].get_double().value));
ais_ship->set_cog(static_cast<float>(ais_ships_doc["cog"].get_double().value));
ais_ship->set_rot(static_cast<float>(ais_ships_doc["rot"].get_double().value));
ais_ship->set_width(static_cast<float>(ais_ships_doc["width"].get_double().value));
ais_ship->set_length(static_cast<float>(ais_ships_doc["length"].get_double().value));
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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());
Expand Down

0 comments on commit 07ccf70

Please sign in to comment.