Skip to content

Commit

Permalink
Deprecate LOCAL2 in SphericalCoordinates (#451)
Browse files Browse the repository at this point in the history
* Deprecate LOCAL2 in `SphericalCoordinates`

With the introduction of gazebosim/gz-math#616.
We will be deprecating `LOCAL2` as a work around in favor or `LOCAL`. As
part of this change, its probably a good idea to update `gz-msgs` as
well.

Signed-off-by: Arjo Chakravarty <[email protected]>

* Fix deprecation warnings resulting from the deprecation of SphericalCoordinates enum field.

Signed-off-by: Martin Pecka <[email protected]>

---------

Signed-off-by: Arjo Chakravarty <[email protected]>
Signed-off-by: Martin Pecka <[email protected]>
Co-authored-by: Arjo Chakravarty <[email protected]>
  • Loading branch information
peci1 and arjo129 authored Aug 22, 2024
1 parent 3d18b1e commit e99b705
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 3 deletions.
6 changes: 6 additions & 0 deletions Migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ Deprecated code produces compile-time warnings. These warning serve as
notification to users that their code should be upgraded. The next major
release will remove the deprecated code.

## Gazebo Msgs 10.X to 11.X
### Deprecations

1. **spherical_coordinates.proto**
+ The `LOCAL2` field in `SphericalCoordinatesType` is deprecated, use `LOCAL` instead. See https://github.com/gazebosim/gz-math/pull/616 for more details

## Gazebo Msgs 9.X to 10.X

### Modifications
Expand Down
3 changes: 3 additions & 0 deletions core/generator/Generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,11 @@ bool Generator::Generate(const FileDescriptor *_file,
#include <memory>
#include <gz/msgs/Export.hh>
#include <gz/utils/SuppressWarning.hh>
GZ_UTILS_WARN_IGNORE__DEPRECATED_DECLARATION
#include <$detail_header$>
GZ_UTILS_WARN_RESUME__DEPRECATED_DECLARATION
)");

auto ns = getNamespaces(_file->package());
Expand Down
8 changes: 8 additions & 0 deletions core/include/gz/msgs/convert/SphericalCoordinates.hh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ inline namespace GZ_MSGS_VERSION_NAMESPACE {
inline msgs::SphericalCoordinatesType ConvertCoord(
const math::SphericalCoordinates::CoordinateType &_sc)
{
GZ_UTILS_WARN_IGNORE__DEPRECATED_DECLARATION
auto result = msgs::SphericalCoordinatesType::LOCAL2;
GZ_UTILS_WARN_RESUME__DEPRECATED_DECLARATION
switch (_sc)
{
case math::SphericalCoordinates::CoordinateType::ECEF:
Expand All @@ -49,9 +51,11 @@ inline msgs::SphericalCoordinatesType ConvertCoord(
case math::SphericalCoordinates::CoordinateType::LOCAL:
result = msgs::SphericalCoordinatesType::LOCAL;
break;
GZ_UTILS_WARN_IGNORE__DEPRECATED_DECLARATION
case math::SphericalCoordinates::CoordinateType::LOCAL2:
result = msgs::SphericalCoordinatesType::LOCAL2;
break;
GZ_UTILS_WARN_RESUME__DEPRECATED_DECLARATION
default:
std::cerr << "Invalid coordinate type passed" << std::endl;
}
Expand All @@ -72,12 +76,16 @@ inline math::SphericalCoordinates::CoordinateType Convert(
return math::SphericalCoordinates::CoordinateType::SPHERICAL;
case msgs::SphericalCoordinatesType::LOCAL:
return math::SphericalCoordinates::CoordinateType::LOCAL;
GZ_UTILS_WARN_IGNORE__DEPRECATED_DECLARATION
case msgs::SphericalCoordinatesType::LOCAL2:
return math::SphericalCoordinates::CoordinateType::LOCAL2;
GZ_UTILS_WARN_RESUME__DEPRECATED_DECLARATION
default:
std::cerr << "Invalid coordinate type passed" << std::endl;
}
GZ_UTILS_WARN_IGNORE__DEPRECATED_DECLARATION
return math::SphericalCoordinates::CoordinateType::LOCAL2;
GZ_UTILS_WARN_RESUME__DEPRECATED_DECLARATION
}

/////////////////////////////////
Expand Down
4 changes: 1 addition & 3 deletions proto/gz/msgs/spherical_coordinates.proto
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,10 @@ enum SphericalCoordinatesType
GLOBAL = 2;

/// \brief Heading-adjusted tangent plane (X, Y, Z)
/// This has kept a bug for backwards compatibility, use
/// LOCAL2 for the correct behaviour.
LOCAL = 3;

/// \brief Heading-adjusted tangent plane (X, Y, Z)
LOCAL2 = 4;
LOCAL2 = 4 [deprecated=true];
}

message SphericalCoordinates
Expand Down
9 changes: 9 additions & 0 deletions test/integration/Utility_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -354,8 +354,10 @@ TEST(MsgsTest, ConvertMathSphericalCoordinatesToMsgs)
msgs::ConvertCoord(math::SphericalCoordinates::CoordinateType::SPHERICAL));
EXPECT_EQ(msgs::SphericalCoordinatesType::LOCAL,
msgs::ConvertCoord(math::SphericalCoordinates::CoordinateType::LOCAL));
GZ_UTILS_WARN_IGNORE__DEPRECATED_DECLARATION
EXPECT_EQ(msgs::SphericalCoordinatesType::LOCAL2,
msgs::ConvertCoord(math::SphericalCoordinates::CoordinateType::LOCAL2));
GZ_UTILS_WARN_RESUME__DEPRECATED_DECLARATION

EXPECT_EQ(math::SphericalCoordinates::CoordinateType::ECEF,
msgs::Convert(msgs::SphericalCoordinatesType::ECEF));
Expand All @@ -365,8 +367,11 @@ TEST(MsgsTest, ConvertMathSphericalCoordinatesToMsgs)
msgs::Convert(msgs::SphericalCoordinatesType::SPHERICAL));
EXPECT_EQ(math::SphericalCoordinates::CoordinateType::LOCAL,
msgs::Convert(msgs::SphericalCoordinatesType::LOCAL));
GZ_UTILS_WARN_IGNORE__DEPRECATED_DECLARATION
EXPECT_EQ(math::SphericalCoordinates::CoordinateType::LOCAL2,
msgs::Convert(msgs::SphericalCoordinatesType::LOCAL2));
GZ_UTILS_WARN_RESUME__DEPRECATED_DECLARATION


auto msg = msgs::Convert(
math::SphericalCoordinates(
Expand Down Expand Up @@ -452,10 +457,12 @@ TEST(MsgsTest, ConvertMsgsSphericalCoordinatesTypeToMath)
math::SphericalCoordinates::CoordinateType::SPHERICAL);
EXPECT_EQ(Convert(msgs::SphericalCoordinatesType::LOCAL),
math::SphericalCoordinates::CoordinateType::LOCAL);
GZ_UTILS_WARN_IGNORE__DEPRECATED_DECLARATION
EXPECT_EQ(Convert(msgs::SphericalCoordinatesType::LOCAL2),
math::SphericalCoordinates::CoordinateType::LOCAL2);
EXPECT_EQ(Convert((msgs::SphericalCoordinatesType)500000),
math::SphericalCoordinates::CoordinateType::LOCAL2);
GZ_UTILS_WARN_RESUME__DEPRECATED_DECLARATION
}

/////////////////////////////////////////////////
Expand All @@ -473,12 +480,14 @@ TEST(MsgsTest, ConvertMathSphericalCoordinatedTypeToMsg)
EXPECT_EQ(msgs::ConvertCoord(
math::SphericalCoordinates::CoordinateType::LOCAL),
msgs::SphericalCoordinatesType::LOCAL);
GZ_UTILS_WARN_IGNORE__DEPRECATED_DECLARATION
EXPECT_EQ(msgs::ConvertCoord(
math::SphericalCoordinates::CoordinateType::LOCAL2),
msgs::SphericalCoordinatesType::LOCAL2);
EXPECT_EQ(msgs::ConvertCoord(
(math::SphericalCoordinates::CoordinateType)500000),
msgs::SphericalCoordinatesType::LOCAL2);
GZ_UTILS_WARN_RESUME__DEPRECATED_DECLARATION
}

/////////////////////////////////////////////////
Expand Down

0 comments on commit e99b705

Please sign in to comment.