From f6830b9982cbb7f52f75a9ed6dbc4f7af1b57adb Mon Sep 17 00:00:00 2001 From: Chris Lalancette Date: Fri, 8 Dec 2023 19:44:38 +0000 Subject: [PATCH] Deprecate the APIs that we think are unused. In an earlier commit, we changed from tinyxml -> tinyxml2 in the public API because we thought that there were no users of these APIs. Codify that here by marking these APIs as deprecated; if a user comes along and says that they are actually using it, we can undeprecated it. Note that in order to avoid deprecations from within the library, I had to add a bit of additional indirection here. If we remove the APIs in the future, we can also remove this indirection. Signed-off-by: Chris Lalancette --- urdf_parser/include/urdf_parser/urdf_parser.h | 14 ++++++++++++ urdf_parser/src/joint.cpp | 4 ++-- urdf_parser/src/link.cpp | 8 +++---- urdf_parser/src/model.cpp | 10 +++++++-- urdf_parser/src/pose.cpp | 7 +++++- urdf_parser/src/urdf_sensor.cpp | 22 ++++++++++++++----- 6 files changed, 50 insertions(+), 15 deletions(-) diff --git a/urdf_parser/include/urdf_parser/urdf_parser.h b/urdf_parser/include/urdf_parser/urdf_parser.h index 0ea27df1..240e9df3 100644 --- a/urdf_parser/include/urdf_parser/urdf_parser.h +++ b/urdf_parser/include/urdf_parser/urdf_parser.h @@ -149,12 +149,26 @@ namespace urdf{ URDFDOM_DLLAPI ModelInterfaceSharedPtr parseURDF(const std::string &xml_string); URDFDOM_DLLAPI ModelInterfaceSharedPtr parseURDFFile(const std::string &path); + + [[deprecated("File an issue at https://github.com/ros/urdfdom if you rely on this")]] URDFDOM_DLLAPI tinyxml2::XMLDocument* exportURDF(ModelInterfaceSharedPtr &model); + + [[deprecated("File an issue at https://github.com/ros/urdfdom if you rely on this")]] URDFDOM_DLLAPI tinyxml2::XMLDocument* exportURDF(const ModelInterface &model); + + [[deprecated("File an issue at https://github.com/ros/urdfdom if you rely on this")]] URDFDOM_DLLAPI bool parsePose(Pose&, tinyxml2::XMLElement*); + + [[deprecated("File an issue at https://github.com/ros/urdfdom if you rely on this")]] URDFDOM_DLLAPI bool parseCamera(Camera&, tinyxml2::XMLElement*); + + [[deprecated("File an issue at https://github.com/ros/urdfdom if you rely on this")]] URDFDOM_DLLAPI bool parseRay(Ray&, tinyxml2::XMLElement*); + + [[deprecated("File an issue at https://github.com/ros/urdfdom if you rely on this")]] URDFDOM_DLLAPI bool parseSensor(Sensor&, tinyxml2::XMLElement*); + + [[deprecated("File an issue at https://github.com/ros/urdfdom if you rely on this")]] URDFDOM_DLLAPI bool parseModelState(ModelState&, tinyxml2::XMLElement*); } diff --git a/urdf_parser/src/joint.cpp b/urdf_parser/src/joint.cpp index 7668350f..614c44b6 100644 --- a/urdf_parser/src/joint.cpp +++ b/urdf_parser/src/joint.cpp @@ -45,7 +45,7 @@ namespace urdf{ -bool parsePose(Pose &pose, tinyxml2::XMLElement* xml); +bool parsePoseInternal(Pose &pose, tinyxml2::XMLElement* xml); bool parseJointDynamics(JointDynamics &jd, tinyxml2::XMLElement* config) { @@ -356,7 +356,7 @@ bool parseJoint(Joint &joint, tinyxml2::XMLElement* config) } else { - if (!parsePose(joint.parent_to_joint_origin_transform, origin_xml)) + if (!parsePoseInternal(joint.parent_to_joint_origin_transform, origin_xml)) { joint.parent_to_joint_origin_transform.clear(); CONSOLE_BRIDGE_logError("Malformed parent origin element for joint [%s]", joint.name.c_str()); diff --git a/urdf_parser/src/link.cpp b/urdf_parser/src/link.cpp index 85dafd44..483cf00d 100644 --- a/urdf_parser/src/link.cpp +++ b/urdf_parser/src/link.cpp @@ -50,7 +50,7 @@ namespace urdf{ -bool parsePose(Pose &pose, tinyxml2::XMLElement* xml); +bool parsePoseInternal(Pose &pose, tinyxml2::XMLElement* xml); bool parseMaterial(Material &material, tinyxml2::XMLElement *config, bool only_name_is_ok) { @@ -274,7 +274,7 @@ bool parseInertial(Inertial &i, tinyxml2::XMLElement *config) tinyxml2::XMLElement *o = config->FirstChildElement("origin"); if (o) { - if (!parsePose(i.origin, o)) + if (!parsePoseInternal(i.origin, o)) return false; } @@ -353,7 +353,7 @@ bool parseVisual(Visual &vis, tinyxml2::XMLElement *config) // Origin tinyxml2::XMLElement *o = config->FirstChildElement("origin"); if (o) { - if (!parsePose(vis.origin, o)) + if (!parsePoseInternal(vis.origin, o)) return false; } @@ -395,7 +395,7 @@ bool parseCollision(Collision &col, tinyxml2::XMLElement* config) // Origin tinyxml2::XMLElement *o = config->FirstChildElement("origin"); if (o) { - if (!parsePose(col.origin, o)) + if (!parsePoseInternal(col.origin, o)) return false; } diff --git a/urdf_parser/src/model.cpp b/urdf_parser/src/model.cpp index fb49ecca..5236668a 100644 --- a/urdf_parser/src/model.cpp +++ b/urdf_parser/src/model.cpp @@ -273,7 +273,8 @@ ModelInterfaceSharedPtr parseURDF(const std::string &xml_string) bool exportMaterial(Material &material, tinyxml2::XMLElement *config); bool exportLink(Link &link, tinyxml2::XMLElement *config); bool exportJoint(Joint &joint, tinyxml2::XMLElement *config); -tinyxml2::XMLDocument* exportURDF(const ModelInterface &model) + +tinyxml2::XMLDocument* exportURDFInternal(const ModelInterface &model) { tinyxml2::XMLDocument *doc = new tinyxml2::XMLDocument(); @@ -303,9 +304,14 @@ tinyxml2::XMLDocument* exportURDF(const ModelInterface &model) return doc; } +tinyxml2::XMLDocument* exportURDF(const ModelInterface &model) +{ + return exportURDFInternal(model); +} + tinyxml2::XMLDocument* exportURDF(ModelInterfaceSharedPtr &model) { - return exportURDF(*model); + return exportURDFInternal(*model); } diff --git a/urdf_parser/src/pose.cpp b/urdf_parser/src/pose.cpp index 87479f39..85c4ec97 100644 --- a/urdf_parser/src/pose.cpp +++ b/urdf_parser/src/pose.cpp @@ -87,7 +87,7 @@ std::string values2str(double d) namespace urdf{ -bool parsePose(Pose &pose, tinyxml2::XMLElement* xml) +bool parsePoseInternal(Pose &pose, tinyxml2::XMLElement* xml) { pose.clear(); if (xml) @@ -119,6 +119,11 @@ bool parsePose(Pose &pose, tinyxml2::XMLElement* xml) return true; } +bool parsePose(Pose &pose, tinyxml2::XMLElement* xml) +{ + return parsePoseInternal(pose, xml); +} + bool exportPose(Pose &pose, tinyxml2::XMLElement* xml) { tinyxml2::XMLElement* origin = xml->GetDocument()->NewElement("origin"); diff --git a/urdf_parser/src/urdf_sensor.cpp b/urdf_parser/src/urdf_sensor.cpp index 8332920c..f9588235 100644 --- a/urdf_parser/src/urdf_sensor.cpp +++ b/urdf_parser/src/urdf_sensor.cpp @@ -49,9 +49,9 @@ namespace urdf{ -bool parsePose(Pose &pose, tinyxml2::XMLElement* xml); +bool parsePoseInternal(Pose &pose, tinyxml2::XMLElement* xml); -bool parseCamera(Camera &camera, tinyxml2::XMLElement* config) +bool parseCameraInternal(Camera &camera, tinyxml2::XMLElement* config) { camera.clear(); camera.type = VisualSensor::CAMERA; @@ -173,7 +173,12 @@ bool parseCamera(Camera &camera, tinyxml2::XMLElement* config) return true; } -bool parseRay(Ray &ray, tinyxml2::XMLElement* config) +bool parseCamera(Camera &camera, tinyxml2::XMLElement* config) +{ + return parseCameraInternal(camera, config); +} + +bool parseRayInternal(Ray &ray, tinyxml2::XMLElement* config) { ray.clear(); ray.type = VisualSensor::RAY; @@ -292,6 +297,11 @@ bool parseRay(Ray &ray, tinyxml2::XMLElement* config) return false; } +bool parseRay(Ray &ray, tinyxml2::XMLElement* config) +{ + return parseRayInternal(ray, config); +} + VisualSensorSharedPtr parseVisualSensor(tinyxml2::XMLElement *g) { VisualSensorSharedPtr visual_sensor; @@ -303,7 +313,7 @@ VisualSensorSharedPtr parseVisualSensor(tinyxml2::XMLElement *g) Camera *camera = new Camera(); visual_sensor.reset(camera); sensor_xml = g->FirstChildElement("camera"); - if (!parseCamera(*camera, sensor_xml)) + if (!parseCameraInternal(*camera, sensor_xml)) visual_sensor.reset(); } else if (g->FirstChildElement("ray")) @@ -311,7 +321,7 @@ VisualSensorSharedPtr parseVisualSensor(tinyxml2::XMLElement *g) Ray *ray = new Ray(); visual_sensor.reset(ray); sensor_xml = g->FirstChildElement("ray"); - if (!parseRay(*ray, sensor_xml)) + if (!parseRayInternal(*ray, sensor_xml)) visual_sensor.reset(); } else @@ -347,7 +357,7 @@ bool parseSensor(Sensor &sensor, tinyxml2::XMLElement* config) tinyxml2::XMLElement *o = config->FirstChildElement("origin"); if (o) { - if (!parsePose(sensor.origin, o)) + if (!parsePoseInternal(sensor.origin, o)) return false; }