Skip to content

Commit 4134022

Browse files
clalancetteharleylara
authored andcommitted
Deprecate the APIs that we think are unused. (ros#191)
* 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. * Properly export parsePoseInternal to make Windows happy. Signed-off-by: Chris Lalancette <[email protected]> Signed-off-by: harleylara <[email protected]>
1 parent 1e2932f commit 4134022

File tree

7 files changed

+99
-18
lines changed

7 files changed

+99
-18
lines changed

Diff for: urdf_parser/include/urdf_parser/urdf_parser.h

+14
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,26 @@ namespace urdf{
149149

150150
URDFDOM_DLLAPI ModelInterfaceSharedPtr parseURDF(const std::string &xml_string);
151151
URDFDOM_DLLAPI ModelInterfaceSharedPtr parseURDFFile(const std::string &path);
152+
153+
[[deprecated("File an issue at https://github.com/ros/urdfdom if you rely on this")]]
152154
URDFDOM_DLLAPI tinyxml2::XMLDocument* exportURDF(ModelInterfaceSharedPtr &model);
155+
156+
[[deprecated("File an issue at https://github.com/ros/urdfdom if you rely on this")]]
153157
URDFDOM_DLLAPI tinyxml2::XMLDocument* exportURDF(const ModelInterface &model);
158+
159+
[[deprecated("File an issue at https://github.com/ros/urdfdom if you rely on this")]]
154160
URDFDOM_DLLAPI bool parsePose(Pose&, tinyxml2::XMLElement*);
161+
162+
[[deprecated("File an issue at https://github.com/ros/urdfdom if you rely on this")]]
155163
URDFDOM_DLLAPI bool parseCamera(Camera&, tinyxml2::XMLElement*);
164+
165+
[[deprecated("File an issue at https://github.com/ros/urdfdom if you rely on this")]]
156166
URDFDOM_DLLAPI bool parseRay(Ray&, tinyxml2::XMLElement*);
167+
168+
[[deprecated("File an issue at https://github.com/ros/urdfdom if you rely on this")]]
157169
URDFDOM_DLLAPI bool parseSensor(Sensor&, tinyxml2::XMLElement*);
170+
171+
[[deprecated("File an issue at https://github.com/ros/urdfdom if you rely on this")]]
158172
URDFDOM_DLLAPI bool parseModelState(ModelState&, tinyxml2::XMLElement*);
159173
}
160174

Diff for: urdf_parser/src/joint.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@
4343
#include <tinyxml2.h>
4444
#include <urdf_parser/urdf_parser.h>
4545

46-
namespace urdf{
46+
#include "./pose.hpp"
4747

48-
bool parsePose(Pose &pose, tinyxml2::XMLElement* xml);
48+
namespace urdf{
4949

5050
bool parseJointDynamics(JointDynamics &jd, tinyxml2::XMLElement* config)
5151
{
@@ -356,7 +356,7 @@ bool parseJoint(Joint &joint, tinyxml2::XMLElement* config)
356356
}
357357
else
358358
{
359-
if (!parsePose(joint.parent_to_joint_origin_transform, origin_xml))
359+
if (!parsePoseInternal(joint.parent_to_joint_origin_transform, origin_xml))
360360
{
361361
joint.parent_to_joint_origin_transform.clear();
362362
CONSOLE_BRIDGE_logError("Malformed parent origin element for joint [%s]", joint.name.c_str());

Diff for: urdf_parser/src/link.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@
4848
#include <tinyxml2.h>
4949
#include <console_bridge/console.h>
5050

51-
namespace urdf{
51+
#include "./pose.hpp"
5252

53-
bool parsePose(Pose &pose, tinyxml2::XMLElement* xml);
53+
namespace urdf{
5454

5555
bool parseMaterial(Material &material, tinyxml2::XMLElement *config, bool only_name_is_ok)
5656
{
@@ -274,7 +274,7 @@ bool parseInertial(Inertial &i, tinyxml2::XMLElement *config)
274274
tinyxml2::XMLElement *o = config->FirstChildElement("origin");
275275
if (o)
276276
{
277-
if (!parsePose(i.origin, o))
277+
if (!parsePoseInternal(i.origin, o))
278278
return false;
279279
}
280280

@@ -353,7 +353,7 @@ bool parseVisual(Visual &vis, tinyxml2::XMLElement *config)
353353
// Origin
354354
tinyxml2::XMLElement *o = config->FirstChildElement("origin");
355355
if (o) {
356-
if (!parsePose(vis.origin, o))
356+
if (!parsePoseInternal(vis.origin, o))
357357
return false;
358358
}
359359

@@ -395,7 +395,7 @@ bool parseCollision(Collision &col, tinyxml2::XMLElement* config)
395395
// Origin
396396
tinyxml2::XMLElement *o = config->FirstChildElement("origin");
397397
if (o) {
398-
if (!parsePose(col.origin, o))
398+
if (!parsePoseInternal(col.origin, o))
399399
return false;
400400
}
401401

Diff for: urdf_parser/src/model.cpp

+8-2
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,8 @@ ModelInterfaceSharedPtr parseURDF(const std::string &xml_string)
273273
bool exportMaterial(Material &material, tinyxml2::XMLElement *config);
274274
bool exportLink(Link &link, tinyxml2::XMLElement *config);
275275
bool exportJoint(Joint &joint, tinyxml2::XMLElement *config);
276-
tinyxml2::XMLDocument* exportURDF(const ModelInterface &model)
276+
277+
tinyxml2::XMLDocument* exportURDFInternal(const ModelInterface &model)
277278
{
278279
tinyxml2::XMLDocument *doc = new tinyxml2::XMLDocument();
279280

@@ -303,9 +304,14 @@ tinyxml2::XMLDocument* exportURDF(const ModelInterface &model)
303304
return doc;
304305
}
305306

307+
tinyxml2::XMLDocument* exportURDF(const ModelInterface &model)
308+
{
309+
return exportURDFInternal(model);
310+
}
311+
306312
tinyxml2::XMLDocument* exportURDF(ModelInterfaceSharedPtr &model)
307313
{
308-
return exportURDF(*model);
314+
return exportURDFInternal(*model);
309315
}
310316

311317

Diff for: urdf_parser/src/pose.cpp

+8-1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@
4343
#include <tinyxml2.h>
4444
#include <urdf_parser/urdf_parser.h>
4545

46+
#include "./pose.hpp"
47+
4648
namespace urdf_export_helpers {
4749

4850
std::string values2str(unsigned int count, const double *values, double (*conv)(double))
@@ -87,7 +89,7 @@ std::string values2str(double d)
8789

8890
namespace urdf{
8991

90-
bool parsePose(Pose &pose, tinyxml2::XMLElement* xml)
92+
bool parsePoseInternal(Pose &pose, tinyxml2::XMLElement* xml)
9193
{
9294
pose.clear();
9395
if (xml)
@@ -119,6 +121,11 @@ bool parsePose(Pose &pose, tinyxml2::XMLElement* xml)
119121
return true;
120122
}
121123

124+
bool parsePose(Pose &pose, tinyxml2::XMLElement* xml)
125+
{
126+
return parsePoseInternal(pose, xml);
127+
}
128+
122129
bool exportPose(Pose &pose, tinyxml2::XMLElement* xml)
123130
{
124131
tinyxml2::XMLElement* origin = xml->GetDocument()->NewElement("origin");

Diff for: urdf_parser/src/pose.hpp

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*********************************************************************
2+
* Software License Agreement (BSD License)
3+
*
4+
* Copyright (c) 2008, Willow Garage, Inc.
5+
* All rights reserved.
6+
*
7+
* Redistribution and use in source and binary forms, with or without
8+
* modification, are permitted provided that the following conditions
9+
* are met:
10+
*
11+
* * Redistributions of source code must retain the above copyright
12+
* notice, this list of conditions and the following disclaimer.
13+
* * Redistributions in binary form must reproduce the above
14+
* copyright notice, this list of conditions and the following
15+
* disclaimer in the documentation and/or other materials provided
16+
* with the distribution.
17+
* * Neither the name of the Willow Garage nor the names of its
18+
* contributors may be used to endorse or promote products derived
19+
* from this software without specific prior written permission.
20+
*
21+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24+
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25+
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26+
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27+
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30+
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31+
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32+
* POSSIBILITY OF SUCH DAMAGE.
33+
*********************************************************************/
34+
35+
/* Author: Wim Meeussen, John Hsu */
36+
37+
#include <urdf_model/pose.h>
38+
#include <tinyxml2.h>
39+
40+
namespace urdf {
41+
42+
URDFDOM_DLLAPI bool parsePoseInternal(Pose &pose, tinyxml2::XMLElement* xml);
43+
44+
}

Diff for: urdf_parser/src/urdf_sensor.cpp

+17-7
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@
4747

4848
#include <urdf_parser/urdf_parser.h>
4949

50-
namespace urdf{
50+
#include "./pose.hpp"
5151

52-
bool parsePose(Pose &pose, tinyxml2::XMLElement* xml);
52+
namespace urdf{
5353

54-
bool parseCamera(Camera &camera, tinyxml2::XMLElement* config)
54+
bool parseCameraInternal(Camera &camera, tinyxml2::XMLElement* config)
5555
{
5656
camera.clear();
5757
camera.type = VisualSensor::CAMERA;
@@ -173,7 +173,12 @@ bool parseCamera(Camera &camera, tinyxml2::XMLElement* config)
173173
return true;
174174
}
175175

176-
bool parseRay(Ray &ray, tinyxml2::XMLElement* config)
176+
bool parseCamera(Camera &camera, tinyxml2::XMLElement* config)
177+
{
178+
return parseCameraInternal(camera, config);
179+
}
180+
181+
bool parseRayInternal(Ray &ray, tinyxml2::XMLElement* config)
177182
{
178183
ray.clear();
179184
ray.type = VisualSensor::RAY;
@@ -292,6 +297,11 @@ bool parseRay(Ray &ray, tinyxml2::XMLElement* config)
292297
return false;
293298
}
294299

300+
bool parseRay(Ray &ray, tinyxml2::XMLElement* config)
301+
{
302+
return parseRayInternal(ray, config);
303+
}
304+
295305
VisualSensorSharedPtr parseVisualSensor(tinyxml2::XMLElement *g)
296306
{
297307
VisualSensorSharedPtr visual_sensor;
@@ -303,15 +313,15 @@ VisualSensorSharedPtr parseVisualSensor(tinyxml2::XMLElement *g)
303313
Camera *camera = new Camera();
304314
visual_sensor.reset(camera);
305315
sensor_xml = g->FirstChildElement("camera");
306-
if (!parseCamera(*camera, sensor_xml))
316+
if (!parseCameraInternal(*camera, sensor_xml))
307317
visual_sensor.reset();
308318
}
309319
else if (g->FirstChildElement("ray"))
310320
{
311321
Ray *ray = new Ray();
312322
visual_sensor.reset(ray);
313323
sensor_xml = g->FirstChildElement("ray");
314-
if (!parseRay(*ray, sensor_xml))
324+
if (!parseRayInternal(*ray, sensor_xml))
315325
visual_sensor.reset();
316326
}
317327
else
@@ -347,7 +357,7 @@ bool parseSensor(Sensor &sensor, tinyxml2::XMLElement* config)
347357
tinyxml2::XMLElement *o = config->FirstChildElement("origin");
348358
if (o)
349359
{
350-
if (!parsePose(sensor.origin, o))
360+
if (!parsePoseInternal(sensor.origin, o))
351361
return false;
352362
}
353363

0 commit comments

Comments
 (0)