Skip to content

Commit

Permalink
urdf_parser: convert remaining files to HAVE_TINYXML
Browse files Browse the repository at this point in the history
  • Loading branch information
SMillerDev committed Feb 14, 2023
1 parent a65ae22 commit 1458ccd
Show file tree
Hide file tree
Showing 10 changed files with 1,238 additions and 17 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ endif (MSVC OR MSVC90 OR MSVC10)

set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")

if(DISABLE_TINYXML_SUPPORT)
if(NOT DISABLE_TINYXML_SUPPORT)
find_package(tinyxml_vendor QUIET)
find_package(TinyXML)
# bionic has not cmake module, workaround
Expand Down
4 changes: 2 additions & 2 deletions urdf_parser/include/urdf_parser/urdf_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ namespace urdf{
URDFDOM_DLLAPI bool parseSensor(Sensor&, TiXmlElement*);
URDFDOM_DLLAPI bool parseModelState(ModelState&, TiXmlElement*);
#endif
URDFDOM_DLLAPI void exportURDF(ModelInterfaceSharedPtr &model, XMLDocument &doc);
URDFDOM_DLLAPI void exportURDF(const ModelInterface &model, XMLDocument &doc);
URDFDOM_DLLAPI void exportURDF(ModelInterfaceSharedPtr &model, tinyxml2::XMLDocument &doc);
URDFDOM_DLLAPI void exportURDF(const ModelInterface &model, tinyxml2::XMLDocument &doc);
URDFDOM_DLLAPI bool parsePose(Pose&, tinyxml2::XMLElement*);
URDFDOM_DLLAPI bool parseCamera(Camera&, tinyxml2::XMLElement*);
URDFDOM_DLLAPI bool parseRay(Ray&, tinyxml2::XMLElement*);
Expand Down
56 changes: 55 additions & 1 deletion urdf_parser/src/joint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,11 @@
#include <string>
#include <urdf_model/joint.h>
#include <console_bridge/console.h>
#include <tinyxml2.h>
#include <urdf_parser/urdf_parser.h>
#ifdef HAVE_TINYXML
#include <tinyxml.h>
#endif
#include <tinyxml2.h>

using namespace tinyxml2;

Expand Down Expand Up @@ -653,4 +656,55 @@ bool exportJoint(Joint &joint, XMLElement* xml)



#ifdef HAVE_TINYXML
bool parsePose(Pose &pose, TiXmlElement* xml);

bool parseJointDynamics(JointDynamics &jd, TiXmlElement* config)
{
jd.clear();

// Get joint damping
const char* damping_str = config->Attribute("damping");
if (damping_str == NULL){
CONSOLE_BRIDGE_logDebug("urdfdom.joint_dynamics: no damping, defaults to 0");
jd.damping = 0;
}
else
{
try {
jd.damping = strToDouble(damping_str);
} catch(std::runtime_error &) {
CONSOLE_BRIDGE_logError("damping value (%s) is not a valid float", damping_str);
return false;
}
}

// Get joint friction
const char* friction_str = config->Attribute("friction");
if (friction_str == NULL){
CONSOLE_BRIDGE_logDebug("urdfdom.joint_dynamics: no friction, defaults to 0");
jd.friction = 0;
}
else
{
try {
jd.friction = strToDouble(friction_str);
} catch (std::runtime_error &) {
CONSOLE_BRIDGE_logError("friction value (%s) is not a valid float", friction_str);
return false;
}
}

if (damping_str == NULL && friction_str == NULL)
{
CONSOLE_BRIDGE_logError("joint dynamics element specified with no damping and no friction");
return false;
}
else{
CONSOLE_BRIDGE_logDebug("urdfdom.joint_dynamics: damping %f and friction %f", jd.damping, jd.friction);
return true;
}
}
#endif

}
Loading

0 comments on commit 1458ccd

Please sign in to comment.