Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SphericalCoordinate deprecation warning in DVL sensor #460

Merged
merged 2 commits into from
Aug 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions src/DopplerVelocityLog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1731,12 +1731,34 @@ namespace gz
samplePointInSensorFrame;

// Transform sample point to the environmental data frame
const gz::math::Vector3d samplePointInDataFrame =
const std::optional<gz::math::CoordinateVector3>
samplePointInDataFrameCoordVec =
this->worldState->origin.PositionTransform(
samplePointInWorldFrame,
gz::math::CoordinateVector3::Metric(samplePointInWorldFrame),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@iche033 Technically, if somebody used LOCAL for reference, this will probably silently change the behavior. It is possible this would go completely without a build warning if the value is read from SDF. But I haven't worked with DVL, so I don't know if setting LOCAL would make sense...

Copy link
Contributor Author

@iche033 iche033 Aug 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not very familiar with it as well. I looked at the possible frames that gz-sim eventually passes to DVL, and I think they are: GLOBAL, SPHERICAL, and ECEF (from the EnvironmentPreload system, and EnvironmentLoader GUI plugin). Maybe @arjo129 knows more about this and can chime in?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@arjo129 what do you think?

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);
Expand Down