Skip to content

Commit

Permalink
add frame in dvl
Browse files Browse the repository at this point in the history
Signed-off-by: Ian Chen <[email protected]>
  • Loading branch information
iche033 committed Jul 3, 2024
1 parent 615f3e7 commit e6568bd
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/DopplerVelocityLog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1946,6 +1946,9 @@ namespace gz
if (this->dataPtr->publishingEstimates)
{
auto * headerMessage = bottomModeMessage.mutable_header();
auto frame = headerMessage->add_data();
frame->set_key("frame_id");
frame->add_value(this->FrameId());
this->AddSequence(headerMessage, "doppler_velocity_log");
this->dataPtr->pub.Publish(bottomModeMessage);
}
Expand All @@ -1965,6 +1968,9 @@ namespace gz
if (this->dataPtr->publishingEstimates)
{
auto * headerMessage = waterMassModeMessage.mutable_header();
auto frame = headerMessage->add_data();
frame->set_key("frame_id");
frame->add_value(this->FrameId());
this->AddSequence(headerMessage, "doppler_velocity_log");
this->dataPtr->pub.Publish(waterMassModeMessage);
}
Expand Down
23 changes: 23 additions & 0 deletions test/integration/dvl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ using DopplerVelocityLog = sensors::DopplerVelocityLog;
struct DVLConfig
{
std::string name = "dvl";
std::string frameId = "dvl_frame";
std::string topic = "/gz/sensors/test/dvl";
double updateRate = 30; // Hz

Expand Down Expand Up @@ -75,6 +76,7 @@ sdf::ElementPtr MakeDVLSdf(const DVLConfig &_config)
<< " <model name='model'>"
<< " <link name='link'>"
<< " <sensor name='" << _config.name << "' type='custom' gz:type='dvl'>"
<< " <frame_id>" << _config.frameId << "</frame_id>"
<< " <always_on>" << _config.alwaysOn << "</always_on>"
<< " <update_rate>" << _config.updateRate << "</update_rate>"
<< " <topic>" << _config.topic << "</topic>"
Expand Down Expand Up @@ -345,6 +347,13 @@ TEST_P(DopplerVelocityLogTest, BottomTrackingWhileStatic)
}
EXPECT_EQ(0, message.status());

// check frame id
EXPECT_TRUE(message.has_header());
EXPECT_LT(1, message.header().data().size());
EXPECT_EQ("frame_id", message.header().data(0).key());
ASSERT_EQ(1, message.header().data(0).value().size());
EXPECT_EQ("dvl_frame", message.header().data(0).value(0));

this->manager.Remove(sensor->Id());
}

Expand Down Expand Up @@ -436,6 +445,13 @@ TEST_P(DopplerVelocityLogTest, WaterMassTrackingWhileStatic)
}
EXPECT_EQ(0, message.status());

// check frame id
EXPECT_TRUE(message.has_header());
EXPECT_LT(1, message.header().data().size());
EXPECT_EQ("frame_id", message.header().data(0).key());
ASSERT_EQ(1, message.header().data(0).value().size());
EXPECT_EQ("dvl_frame", message.header().data(0).value(0));

this->manager.Remove(sensor->Id());
}

Expand Down Expand Up @@ -519,6 +535,13 @@ TEST_P(DopplerVelocityLogTest, BottomTrackingWhileInMotion)
}
EXPECT_EQ(0, message.status());

// check frame id
EXPECT_TRUE(message.has_header());
EXPECT_LT(1, message.header().data().size());
EXPECT_EQ("frame_id", message.header().data(0).key());
ASSERT_EQ(1, message.header().data(0).value().size());
EXPECT_EQ("dvl_frame", message.header().data(0).value(0));

this->manager.Remove(sensor->Id());
}

Expand Down

0 comments on commit e6568bd

Please sign in to comment.