Skip to content

Commit

Permalink
Deprecate the APIs that we think are unused.
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
clalancette committed Dec 8, 2023
1 parent fb7f8cb commit f6830b9
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 15 deletions.
14 changes: 14 additions & 0 deletions urdf_parser/include/urdf_parser/urdf_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -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*);
}

Expand Down
4 changes: 2 additions & 2 deletions urdf_parser/src/joint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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());
Expand Down
8 changes: 4 additions & 4 deletions urdf_parser/src/link.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down
10 changes: 8 additions & 2 deletions urdf_parser/src/model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

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


Expand Down
7 changes: 6 additions & 1 deletion urdf_parser/src/pose.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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");
Expand Down
22 changes: 16 additions & 6 deletions urdf_parser/src/urdf_sensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -303,15 +313,15 @@ 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"))
{
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
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit f6830b9

Please sign in to comment.