From 692c5207e8733d80c9500a3920f92508dbeff3db Mon Sep 17 00:00:00 2001 From: Ian Chen Date: Fri, 23 Aug 2024 00:37:24 +0000 Subject: [PATCH 1/2] Fix deprecation warning Signed-off-by: Ian Chen --- src/DopplerVelocityLog.cc | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/DopplerVelocityLog.cc b/src/DopplerVelocityLog.cc index 4a01b73b..66d9ff1e 100644 --- a/src/DopplerVelocityLog.cc +++ b/src/DopplerVelocityLog.cc @@ -1731,12 +1731,34 @@ namespace gz samplePointInSensorFrame; // Transform sample point to the environmental data frame - const gz::math::Vector3d samplePointInDataFrame = + std::optional + samplePointInDataFrameCoordVec = this->worldState->origin.PositionTransform( - samplePointInWorldFrame, + gz::math::CoordinateVector3::Metric(samplePointInWorldFrame), gz::math::SphericalCoordinates::GLOBAL, this->waterVelocityReference); + if (!samplePointInDataFrameCoordVec.has_value()) + continue; + + gz::math::Vector3d samplePointInDataFrame; + if (samplePointInDataFrameCoordVec->IsSpherical()) + { + samplePointInDataFrame.Set( + samplePointInDataFrameCoordVec->Lat()->Radian(), + samplePointInDataFrameCoordVec->Lon()->Radian(), + *samplePointInDataFrameCoordVec->Z()); + } + else if (samplePointInDataFrameCoordVec->IsMetric()) + { + samplePointInDataFrame = + *samplePointInDataFrameCoordVec->AsMetricVector(); + } + else + { + continue; + } + // Sample water velocity in the world frame at sample point const gz::math::Vector3d sampledVelocityInWorldFrame = this->waterVelocity->LookUp(samplePointInDataFrame); From 18faa46c3d390f532dde6b934d0d100837d51fa3 Mon Sep 17 00:00:00 2001 From: Ian Chen Date: Fri, 23 Aug 2024 16:46:45 +0000 Subject: [PATCH 2/2] made const Signed-off-by: Ian Chen --- src/DopplerVelocityLog.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DopplerVelocityLog.cc b/src/DopplerVelocityLog.cc index 66d9ff1e..3f6854e2 100644 --- a/src/DopplerVelocityLog.cc +++ b/src/DopplerVelocityLog.cc @@ -1731,7 +1731,7 @@ namespace gz samplePointInSensorFrame; // Transform sample point to the environmental data frame - std::optional + const std::optional samplePointInDataFrameCoordVec = this->worldState->origin.PositionTransform( gz::math::CoordinateVector3::Metric(samplePointInWorldFrame),