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

Remove deprecations: tock #2703

Merged
merged 3 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
28 changes: 28 additions & 0 deletions Migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,34 @@ 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 Sim 9.x to 10.0

### Removals

- **config.hh**:
+ The macro `GZ_SIM_GUI_CONFIG_PATH` has been removed.
Please use `gz::sim::getGUIConfigPath()` instead.

+ The macro `GZ_SIM_SYSTEM_CONFIG_PATH` has been removed.
Please use `gz::sim::getSystemConfigPath()` instead.

+ The macro `GZ_SIM_SERVER_CONFIG_PATH` has been removed.
Please use `gz::sim::getServerConfigPath()` instead.

+ The macro `GZ_SIM_GUI_PLUGIN_INSTALL_DIR` has been removed.
Please use `gz::sim::getGUIPluginInstallDir()` instead.

+ The macro `GZ_SIM_WORLD_INSTALL_DIR` has been removed.
Please use `gz::sim::getWorldInstallDir()` instead.

**components/Factory.hh**:
+ `gz::sim::components::Factory::Register(const std::string &_type, ComponentDescriptorBase *_compDesc)` and
`gz::sim::components::Factory::Register(const std::string &_type, ComponentDescriptorBase *_compDesc, RegistrationObjectId _regObjId)`
have been removed. Instead, please use
`gz::sim::components::Factory::Register(const char *_type, ComponentDescriptorBase *_compDesc, RegistrationObjectId _regObjId)`
+ `gz::sim::components::Factory::Unregister()` has been removed. Instead, please use
`gz::sim::components::Factory::Unregister(RegistrationObjectId _regObjId)`.

## Gazebo Sim 8.x to 9.0

* **Modified**:
Expand Down
55 changes: 0 additions & 55 deletions include/gz/sim/components/Factory.hh
Original file line number Diff line number Diff line change
Expand Up @@ -205,39 +205,6 @@ namespace components
/// \brief Get an instance of the singleton
public: GZ_SIM_VISIBLE static Factory *Instance();

/// \brief Register a component so that the factory can create instances
/// of the component based on an ID.
/// \param[in] _type Type of component to register.
/// \param[in] _compDesc Object to manage the creation of ComponentTypeT
/// objects.
/// \tparam ComponentTypeT Type of component to register.
// Deprecated in favor of overload that takes _regObjId
public: template <typename ComponentTypeT>
void GZ_DEPRECATED(8) Register(const std::string &_type,
ComponentDescriptorBase *_compDesc)
{
const char* typeDup = strdup(_type.c_str());
this->Register<ComponentTypeT>(typeDup, _compDesc,
RegistrationObjectId{nullptr});
}
/// \brief Register a component so that the factory can create instances
/// of the component based on an ID.
/// \param[in] _type Type of component to register.
/// \param[in] _compDesc Object to manage the creation of ComponentTypeT
/// objects.
/// \param[in] _regObjId An ID that identifies the registration object. This
/// is generally derived from the `this` pointer of the static component
/// registration object created when calling GZ_SIM_REGISTER_COMPONENT.
/// \tparam ComponentTypeT Type of component to register.
// Deprecated in favor of overload that takes `const char *_type`
public: template <typename ComponentTypeT>
void GZ_DEPRECATED(8) Register(const std::string &_type,
ComponentDescriptorBase *_compDesc, RegistrationObjectId _regObjId)
{
const char* typeDup = strdup(_type.c_str());
this->Register<ComponentTypeT>(typeDup, _compDesc, _regObjId);
}

/// \brief Register a component so that the factory can create instances
/// of the component based on an ID.
/// \param[in] _type Type of component to register.
Expand Down Expand Up @@ -295,16 +262,6 @@ namespace components
runtimeNamesById[ComponentTypeT::typeId] = runtimeName;
}

/// \brief Unregister a component so that the factory can't create instances
/// of the component anymore.
/// \tparam ComponentTypeT Type of component to unregister.
// Deprecated in favor of overload that takes _regObjId
public: template <typename ComponentTypeT>
void GZ_DEPRECATED(8) Unregister()
{
this->Unregister<ComponentTypeT>(RegistrationObjectId{nullptr});
}

/// \brief Unregister a component so that the factory can't create instances
/// of the component anymore.
/// \tparam ComponentTypeT Type of component to unregister.
Expand All @@ -317,18 +274,6 @@ namespace components
this->Unregister(ComponentTypeT::typeId, _regObjId);
}

/// \brief Unregister a component so that the factory can't create instances
/// of the component anymore.
/// \details This function will not reset the `typeId` static variable
/// within the component type itself. Prefer using the templated
/// `Unregister` function when possible.
/// \param[in] _typeId Type of component to unregister.
// Deprecated in favor of overload that takes _regObjId
public: void GZ_DEPRECATED(8) Unregister(ComponentTypeId _typeId)
{
this->Unregister(_typeId, RegistrationObjectId{nullptr});
}

/// \brief Unregister a component so that the factory can't create instances
/// of the component anymore.
/// \details This function will not reset the `typeId` static variable
Expand Down
5 changes: 0 additions & 5 deletions include/gz/sim/config.hh.in
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,7 @@

#define GZ_SIM_VERSION_HEADER "Gazebo Sim, version ${PROJECT_VERSION_FULL}\nCopyright (C) 2018 Open Source Robotics Foundation.\nReleased under the Apache 2.0 License.\n\n"

#define GZ_SIM_GUI_CONFIG_PATH _Pragma ("GCC warning \"'GZ_SIM_GUI_CONFIG_PATH' macro is deprecated, use gz::sim::getGUIConfigPath() function instead. \"") "${CMAKE_INSTALL_PREFIX}/${GZ_DATA_INSTALL_DIR}/gui"
#define GZ_SIM_SYSTEM_CONFIG_PATH _Pragma ("GCC warning \"'GZ_SIM_SYSTEM_CONFIG_PATH' macro is deprecated, use gz::sim::getSystemConfigPath() function instead. \"") "${CMAKE_INSTALL_PREFIX}/${GZ_DATA_INSTALL_DIR}/systems"
#define GZ_SIM_SERVER_CONFIG_PATH _Pragma ("GCC warning \"'GZ_SIM_SERVER_CONFIG_PATH' macro is deprecated, use gz::sim::getServerConfigPath() function instead. \"") "${CMAKE_INSTALL_PREFIX}/${GZ_DATA_INSTALL_DIR}"
#define GZ_SIM_PLUGIN_INSTALL_DIR _Pragma ("GCC warning \"'GZ_SIM_PLUGIN_INSTALL_DIR' macro is deprecated, use gz::sim::getPluginInstallDir() function instead. \"") "${CMAKE_INSTALL_PREFIX}/${GZ_LIB_INSTALL_DIR}/gz-${GZ_DESIGNATION}-${PROJECT_VERSION_MAJOR}/plugins"
Copy link
Contributor

Choose a reason for hiding this comment

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

remove this C++ macro as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, removed in 952f598

#define GZ_SIM_GUI_PLUGIN_INSTALL_DIR _Pragma ("GCC warning \"'GZ_SIM_GUI_PLUGIN_INSTALL_DIR' macro is deprecated, use gz::sim::getGUIPluginInstallDir() function instead. \"") "${CMAKE_INSTALL_PREFIX}/${GZ_LIB_INSTALL_DIR}/gz-${GZ_DESIGNATION}-${PROJECT_VERSION_MAJOR}/plugins/gui"
#define GZ_SIM_WORLD_INSTALL_DIR _Pragma ("GCC warning \"'GZ_SIM_WORLD_INSTALL_DIR' macro is deprecated, use gz::sim::getWorldInstallDir() function instead. \"") "${CMAKE_INSTALL_PREFIX}/${GZ_DATA_INSTALL_DIR}/worlds"
#define GZ_DISTRIBUTION "${GZ_DISTRIBUTION}"

#endif
15 changes: 0 additions & 15 deletions python/src/gz/sim/Joint.cc
Original file line number Diff line number Diff line change
Expand Up @@ -94,21 +94,6 @@ void defineSimJoint(py::object module)
py::arg("ecm"),
py::arg("limits"),
"Set the effort limits on a joint axis.")
.def("set_position_imits",
[](pybind11::object &self, EntityComponentManager &_ecm,
const std::vector<math::Vector2d> &_limits)
{
auto warnings = pybind11::module::import("warnings");
auto builtins = pybind11::module::import("builtins");
warnings.attr("warn")(
"set_position_imits() is deprecated, use set_position_limits() instead.",
builtins.attr("DeprecationWarning"));

return self.attr("set_position_limits")(_ecm, _limits);
},
py::arg("ecm"),
py::arg("limits"),
"Set the position limits on a joint axis.")
.def("set_position_limits", &gz::sim::Joint::SetPositionLimits,
py::arg("ecm"),
py::arg("limits"),
Expand Down
63 changes: 0 additions & 63 deletions src/ComponentFactory_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -94,69 +94,6 @@ TEST_F(ComponentFactoryTest, Register)
EXPECT_EQ(registeredCount + 1, ids.size());
}

/////////////////////////////////////////////////
TEST_F(ComponentFactoryTest, DeprecatedRegister)
{
auto factory = components::Factory::Instance();

// Create a custom component.
using MyDeprecatedCustom =
components::Component<components::NoData, class MyDeprecatedCustomTag>;

// Check it has no type id yet
EXPECT_EQ(0u, MyDeprecatedCustom::typeId);
EXPECT_EQ(nullptr, MyDeprecatedCustom::typeName);
EXPECT_EQ("", factory->Name(MyDeprecatedCustom::typeId));

// Store number of registered component types
auto registeredCount = factory->TypeIds().size();

GZ_UTILS_WARN_IGNORE__DEPRECATED_DECLARATION
factory->Register<MyDeprecatedCustom>("gz_sim_components.MyDeprecatedCustom",
new components::ComponentDescriptor<MyDeprecatedCustom>());
GZ_UTILS_WARN_RESUME__DEPRECATED_DECLARATION

// Check now it has type id
EXPECT_NE(0u, MyDeprecatedCustom::typeId);
EXPECT_STREQ("gz_sim_components.MyDeprecatedCustom",
MyDeprecatedCustom::typeName);
EXPECT_EQ("gz_sim_components.MyDeprecatedCustom",
factory->Name(MyDeprecatedCustom::typeId));

// Check factory knows id
auto ids = factory->TypeIds();
EXPECT_EQ(registeredCount + 1, ids.size());
EXPECT_NE(ids.end(),
std::find(ids.begin(), ids.end(), MyDeprecatedCustom::typeId));

// Registering the component twice doesn't change the number of type ids.
GZ_UTILS_WARN_IGNORE__DEPRECATED_DECLARATION
factory->Register<MyDeprecatedCustom>("gz_sim_components.MyDeprecatedCustom",
new components::ComponentDescriptor<MyDeprecatedCustom>());
GZ_UTILS_WARN_RESUME__DEPRECATED_DECLARATION

EXPECT_EQ(registeredCount + 1, factory->TypeIds().size());

// Fail to register 2 components with same name
using Duplicate = components::Component<components::NoData,
class DuplicateTag>;

GZ_UTILS_WARN_IGNORE__DEPRECATED_DECLARATION
factory->Register<Duplicate>("gz_sim_components.MyDeprecatedCustom",
new components::ComponentDescriptor<Duplicate>());
GZ_UTILS_WARN_RESUME__DEPRECATED_DECLARATION

EXPECT_EQ(registeredCount + 1, factory->TypeIds().size());

// Unregister
GZ_UTILS_WARN_IGNORE__DEPRECATED_DECLARATION
factory->Unregister<MyDeprecatedCustom>();
GZ_UTILS_WARN_RESUME__DEPRECATED_DECLARATION

ids = factory->TypeIds();
EXPECT_EQ(registeredCount + 1, ids.size());
}

/////////////////////////////////////////////////
TEST_F(ComponentFactoryTest, New)
{
Expand Down
Loading