Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
urdfdom debdiff
diff -Nru urdfdom-1.0.0/debian/changelog urdfdom-1.0.0/debian/changelog
--- urdfdom-1.0.0/debian/changelog 2018-03-02 07:13:43.000000000 +0000
+++ urdfdom-1.0.0/debian/changelog 2019-08-06 17:51:52.000000000 +0000
@@ -1,3 +1,9 @@
+urdfdom (1.0.0-2ubuntu1) bionic; urgency=medium
+
+ * Patch to avoid truncating problems on non english locale systems
+
+ -- Jose Luis Rivero <jrivero@osrfoundation.org> Tue, 06 Aug 2019 17:51:52 +0000
+
urdfdom (1.0.0-2build2) bionic; urgency=medium
* No-change rebuild against libconsole-bridge0.4
diff -Nru urdfdom-1.0.0/debian/control urdfdom-1.0.0/debian/control
--- urdfdom-1.0.0/debian/control 2018-03-02 07:13:43.000000000 +0000
+++ urdfdom-1.0.0/debian/control 2019-08-06 17:51:52.000000000 +0000
@@ -10,7 +10,7 @@
cmake,
libtinyxml-dev,
libconsole-bridge-dev,
- liburdfdom-headers-dev (>= 1.0),
+ liburdfdom-headers-dev (>= 1.0.0-1ubuntu1),
python-mock,
python-yaml,
python-lxml,
diff -Nru urdfdom-1.0.0/debian/patches/avoid_truncating_floating_values.patch urdfdom-1.0.0/debian/patches/avoid_truncating_floating_values.patch
--- urdfdom-1.0.0/debian/patches/avoid_truncating_floating_values.patch 1970-01-01 00:00:00.000000000 +0000
+++ urdfdom-1.0.0/debian/patches/avoid_truncating_floating_values.patch 2019-08-06 17:51:52.000000000 +0000
@@ -0,0 +1,856 @@
+Description: use helper function strToDouble for locale independent
+Author: Chris Lalancette <clalancette@openrobotics.org>
+Upstream: https://github.com/ros/urdfdom/pull/105
+
+diff --git a/urdf_parser/src/joint.cpp b/urdf_parser/src/joint.cpp
+index 07cbeae..102be3f 100644
+--- a/urdf_parser/src/joint.cpp
++++ b/urdf_parser/src/joint.cpp
+@@ -34,6 +34,7 @@
+
+ /* Author: John Hsu */
+
++#include <locale>
+ #include <sstream>
+ #include <stdexcept>
+ #include <string>
+@@ -58,18 +59,10 @@ bool parseJointDynamics(JointDynamics &jd, TiXmlElement* config)
+ }
+ else
+ {
+- try
+- {
+- jd.damping = std::stod(damping_str);
+- }
+- catch (std::invalid_argument &e)
+- {
+- CONSOLE_BRIDGE_logError("damping value (%s) is not a float: %s",damping_str, e.what());
+- return false;
+- }
+- catch (std::out_of_range &e)
+- {
+- CONSOLE_BRIDGE_logError("damping value (%s) out of range: %s",damping_str, e.what());
++ 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;
+ }
+ }
+@@ -82,18 +75,10 @@ bool parseJointDynamics(JointDynamics &jd, TiXmlElement* config)
+ }
+ else
+ {
+- try
+- {
+- jd.friction = std::stod(friction_str);
+- }
+- catch (std::invalid_argument &e)
+- {
+- CONSOLE_BRIDGE_logError("friction value (%s) is not a float: %s",friction_str, e.what());
+- return false;
+- }
+- catch (std::out_of_range &e)
+- {
+- CONSOLE_BRIDGE_logError("friction value (%s) out of range: %s",friction_str, e.what());
++ 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;
+ }
+ }
+@@ -121,18 +106,10 @@ bool parseJointLimits(JointLimits &jl, TiXmlElement* config)
+ }
+ else
+ {
+- try
+- {
+- jl.lower = std::stod(lower_str);
+- }
+- catch (std::invalid_argument &e)
+- {
+- CONSOLE_BRIDGE_logError("lower value (%s) is not a float: %s", lower_str, e.what());
+- return false;
+- }
+- catch (std::out_of_range &e)
+- {
+- CONSOLE_BRIDGE_logError("lower value (%s) out of range: %s",lower_str, e.what());
++ try {
++ jl.lower = strToDouble(lower_str);
++ } catch (std::runtime_error &) {
++ CONSOLE_BRIDGE_logError("lower value (%s) is not a valid float", lower_str);
+ return false;
+ }
+ }
+@@ -145,18 +122,10 @@ bool parseJointLimits(JointLimits &jl, TiXmlElement* config)
+ }
+ else
+ {
+- try
+- {
+- jl.upper = std::stod(upper_str);
+- }
+- catch (std::invalid_argument &e)
+- {
+- CONSOLE_BRIDGE_logError("upper value (%s) is not a float: %s",upper_str, e.what());
+- return false;
+- }
+- catch (std::out_of_range &e)
+- {
+- CONSOLE_BRIDGE_logError("upper value (%s) out of range: %s",upper_str, e.what());
++ try {
++ jl.upper = strToDouble(upper_str);
++ } catch(std::runtime_error &) {
++ CONSOLE_BRIDGE_logError("upper value (%s) is not a valid float", upper_str);
+ return false;
+ }
+ }
+@@ -169,18 +138,10 @@ bool parseJointLimits(JointLimits &jl, TiXmlElement* config)
+ }
+ else
+ {
+- try
+- {
+- jl.effort = std::stod(effort_str);
+- }
+- catch (std::invalid_argument &e)
+- {
+- CONSOLE_BRIDGE_logError("effort value (%s) is not a float: %s",effort_str, e.what());
+- return false;
+- }
+- catch (std::out_of_range &e)
+- {
+- CONSOLE_BRIDGE_logError("effort value (%s) out of range: %s",effort_str, e.what());
++ try {
++ jl.effort = strToDouble(effort_str);
++ } catch(std::runtime_error &) {
++ CONSOLE_BRIDGE_logError("effort value (%s) is not a valid float", effort_str);
+ return false;
+ }
+ }
+@@ -193,18 +154,10 @@ bool parseJointLimits(JointLimits &jl, TiXmlElement* config)
+ }
+ else
+ {
+- try
+- {
+- jl.velocity = std::stod(velocity_str);
+- }
+- catch (std::invalid_argument &e)
+- {
+- CONSOLE_BRIDGE_logError("velocity value (%s) is not a float: %s",velocity_str, e.what());
+- return false;
+- }
+- catch (std::out_of_range &e)
+- {
+- CONSOLE_BRIDGE_logError("velocity value (%s) out of range: %s",velocity_str, e.what());
++ try {
++ jl.velocity = strToDouble(velocity_str);
++ } catch(std::runtime_error &) {
++ CONSOLE_BRIDGE_logError("velocity value (%s) is not a valid float", velocity_str);
+ return false;
+ }
+ }
+@@ -225,18 +178,10 @@ bool parseJointSafety(JointSafety &js, TiXmlElement* config)
+ }
+ else
+ {
+- try
+- {
+- js.soft_lower_limit = std::stod(soft_lower_limit_str);
+- }
+- catch (std::invalid_argument &e)
+- {
+- CONSOLE_BRIDGE_logError("soft_lower_limit value (%s) is not a float: %s",soft_lower_limit_str, e.what());
+- return false;
+- }
+- catch (std::out_of_range &e)
+- {
+- CONSOLE_BRIDGE_logError("soft_lower_limit value (%s) out of range: %s",soft_lower_limit_str, e.what());
++ try {
++ js.soft_lower_limit = strToDouble(soft_lower_limit_str);
++ } catch(std::runtime_error &) {
++ CONSOLE_BRIDGE_logError("soft_lower_limit value (%s) is not a valid float", soft_lower_limit_str);
+ return false;
+ }
+ }
+@@ -250,18 +195,10 @@ bool parseJointSafety(JointSafety &js, TiXmlElement* config)
+ }
+ else
+ {
+- try
+- {
+- js.soft_upper_limit = std::stod(soft_upper_limit_str);
+- }
+- catch (std::invalid_argument &e)
+- {
+- CONSOLE_BRIDGE_logError("soft_upper_limit value (%s) is not a float: %s",soft_upper_limit_str, e.what());
+- return false;
+- }
+- catch (std::out_of_range &e)
+- {
+- CONSOLE_BRIDGE_logError("soft_upper_limit value (%s) out of range: %s",soft_upper_limit_str, e.what());
++ try {
++ js.soft_upper_limit = strToDouble(soft_upper_limit_str);
++ } catch(std::runtime_error &) {
++ CONSOLE_BRIDGE_logError("soft_upper_limit value (%s) is not a valid float", soft_upper_limit_str);
+ return false;
+ }
+ }
+@@ -275,18 +212,10 @@ bool parseJointSafety(JointSafety &js, TiXmlElement* config)
+ }
+ else
+ {
+- try
+- {
+- js.k_position = std::stod(k_position_str);
+- }
+- catch (std::invalid_argument &e)
+- {
+- CONSOLE_BRIDGE_logError("k_position value (%s) is not a float: %s",k_position_str, e.what());
+- return false;
+- }
+- catch (std::out_of_range &e)
+- {
+- CONSOLE_BRIDGE_logError("k_position value (%s) out of range: %s",k_position_str, e.what());
++ try {
++ js.k_position = strToDouble(k_position_str);
++ } catch(std::runtime_error &) {
++ CONSOLE_BRIDGE_logError("k_position value (%s) is not a valid float", k_position_str);
+ return false;
+ }
+ }
+@@ -299,18 +228,10 @@ bool parseJointSafety(JointSafety &js, TiXmlElement* config)
+ }
+ else
+ {
+- try
+- {
+- js.k_velocity = std::stod(k_velocity_str);
+- }
+- catch (std::invalid_argument &e)
+- {
+- CONSOLE_BRIDGE_logError("k_velocity value (%s) is not a float: %s",k_velocity_str, e.what());
+- return false;
+- }
+- catch (std::out_of_range &e)
+- {
+- CONSOLE_BRIDGE_logError("k_velocity value (%s) out of range: %s",k_velocity_str, e.what());
++ try {
++ js.k_velocity = strToDouble(k_velocity_str);
++ } catch(std::runtime_error &) {
++ CONSOLE_BRIDGE_logError("k_velocity value (%s) is not a valid float", k_velocity_str);
+ return false;
+ }
+ }
+@@ -331,18 +252,10 @@ bool parseJointCalibration(JointCalibration &jc, TiXmlElement* config)
+ }
+ else
+ {
+- try
+- {
+- jc.rising.reset(new double(std::stod(rising_position_str)));
+- }
+- catch (std::invalid_argument &e)
+- {
+- CONSOLE_BRIDGE_logError("risingvalue (%s) is not a float: %s",rising_position_str, e.what());
+- return false;
+- }
+- catch (std::out_of_range &e)
+- {
+- CONSOLE_BRIDGE_logError("risingvalue (%s) out of range: %s",rising_position_str, e.what());
++ try {
++ jc.rising.reset(new double(strToDouble(rising_position_str)));
++ } catch(std::runtime_error &) {
++ CONSOLE_BRIDGE_logError("rising value (%s) is not a valid float", rising_position_str);
+ return false;
+ }
+ }
+@@ -356,18 +269,10 @@ bool parseJointCalibration(JointCalibration &jc, TiXmlElement* config)
+ }
+ else
+ {
+- try
+- {
+- jc.falling.reset(new double(std::stod(falling_position_str)));
+- }
+- catch (std::invalid_argument &e)
+- {
+- CONSOLE_BRIDGE_logError("fallingvalue (%s) is not a float: %s",falling_position_str, e.what());
+- return false;
+- }
+- catch (std::out_of_range &e)
+- {
+- CONSOLE_BRIDGE_logError("fallingvalue (%s) out of range: %s",falling_position_str, e.what());
++ try {
++ jc.falling.reset(new double(strToDouble(falling_position_str)));
++ } catch(std::runtime_error &) {
++ CONSOLE_BRIDGE_logError("falling value (%s) is not a valid float", falling_position_str);
+ return false;
+ }
+ }
+@@ -400,18 +305,10 @@ bool parseJointMimic(JointMimic &jm, TiXmlElement* config)
+ }
+ else
+ {
+- try
+- {
+- jm.multiplier = std::stod(multiplier_str);
+- }
+- catch (std::invalid_argument &e)
+- {
+- CONSOLE_BRIDGE_logError("multiplier value (%s) is not a float: %s",multiplier_str, e.what());
+- return false;
+- }
+- catch (std::out_of_range &e)
+- {
+- CONSOLE_BRIDGE_logError("multiplier value (%s) out of range: %s",multiplier_str, e.what());
++ try {
++ jm.multiplier = strToDouble(multiplier_str);
++ } catch(std::runtime_error &) {
++ CONSOLE_BRIDGE_logError("multiplier value (%s) is not a valid float", multiplier_str);
+ return false;
+ }
+ }
+@@ -426,18 +323,10 @@ bool parseJointMimic(JointMimic &jm, TiXmlElement* config)
+ }
+ else
+ {
+- try
+- {
+- jm.offset = std::stod(offset_str);
+- }
+- catch (std::invalid_argument &e)
+- {
+- CONSOLE_BRIDGE_logError("offset value (%s) is not a float: %s",offset_str, e.what());
+- return false;
+- }
+- catch (std::out_of_range &e)
+- {
+- CONSOLE_BRIDGE_logError("offset value (%s) out of range: %s",offset_str, e.what());
++ try {
++ jm.offset = strToDouble(offset_str);
++ } catch(std::runtime_error &) {
++ CONSOLE_BRIDGE_logError("offset value (%s) is not a valid float", offset_str);
+ return false;
+ }
+ }
+diff --git a/urdf_parser/src/link.cpp b/urdf_parser/src/link.cpp
+index 0e8b8c3..993f6aa 100644
+--- a/urdf_parser/src/link.cpp
++++ b/urdf_parser/src/link.cpp
+@@ -38,9 +38,12 @@
+ #include <urdf_parser/urdf_parser.h>
+ #include <urdf_model/link.h>
+ #include <fstream>
++#include <locale>
+ #include <sstream>
+ #include <stdexcept>
+ #include <string>
++#include <utility>
++#include <vector>
+ #include <algorithm>
+ #include <tinyxml.h>
+ #include <console_bridge/console.h>
+@@ -115,25 +118,15 @@ bool parseSphere(Sphere &s, TiXmlElement *c)
+ return false;
+ }
+
+- try
+- {
+- s.radius = std::stod(c->Attribute("radius"));
+- }
+- catch (std::invalid_argument &e)
+- {
+- std::stringstream stm;
+- stm << "radius [" << c->Attribute("radius") << "] is not a valid float: " << e.what();
+- CONSOLE_BRIDGE_logError(stm.str().c_str());
+- return false;
+- }
+- catch (std::out_of_range &e)
+- {
++ try {
++ s.radius = strToDouble(c->Attribute("radius"));
++ } catch(std::runtime_error &) {
+ std::stringstream stm;
+- stm << "radius [" << c->Attribute("radius") << "] is out of range: " << e.what();
++ stm << "radius [" << c->Attribute("radius") << "] is not a valid float";
+ CONSOLE_BRIDGE_logError(stm.str().c_str());
+ return false;
+ }
+-
++
+ return true;
+ }
+
+@@ -172,43 +165,24 @@ bool parseCylinder(Cylinder &y, TiXmlElement *c)
+ return false;
+ }
+
+- try
+- {
+- y.length = std::stod(c->Attribute("length"));
+- }
+- catch (std::invalid_argument &/*e*/)
+- {
++ try {
++ y.length = strToDouble(c->Attribute("length"));
++ } catch(std::runtime_error &) {
+ std::stringstream stm;
+ stm << "length [" << c->Attribute("length") << "] is not a valid float";
+ CONSOLE_BRIDGE_logError(stm.str().c_str());
+ return false;
+ }
+- catch (std::out_of_range &/*e*/)
+- {
+- std::stringstream stm;
+- stm << "length [" << c->Attribute("length") << "] is out of range";
+- CONSOLE_BRIDGE_logError(stm.str().c_str());
+- return false;
+- }
+
+- try
+- {
+- y.radius = std::stod(c->Attribute("radius"));
+- }
+- catch (std::invalid_argument &/*e*/)
+- {
++ try {
++ y.radius = strToDouble(c->Attribute("radius"));
++ } catch(std::runtime_error &) {
+ std::stringstream stm;
+ stm << "radius [" << c->Attribute("radius") << "] is not a valid float";
+ CONSOLE_BRIDGE_logError(stm.str().c_str());
+ return false;
+ }
+- catch (std::out_of_range &/*e*/)
+- {
+- std::stringstream stm;
+- stm << "radius [" << c->Attribute("radius") << "] is out of range";
+- CONSOLE_BRIDGE_logError(stm.str().c_str());
+- return false;
+- }
++
+ return true;
+ }
+
+@@ -316,26 +290,15 @@ bool parseInertial(Inertial &i, TiXmlElement *config)
+ return false;
+ }
+
+- try
+- {
+- i.mass = std::stod(mass_xml->Attribute("value"));
+- }
+- catch (std::invalid_argument &/*e*/)
+- {
++ try {
++ i.mass = strToDouble(mass_xml->Attribute("value"));
++ } catch(std::runtime_error &) {
+ std::stringstream stm;
+ stm << "Inertial: mass [" << mass_xml->Attribute("value")
+ << "] is not a float";
+ CONSOLE_BRIDGE_logError(stm.str().c_str());
+ return false;
+ }
+- catch (std::out_of_range &/*e*/)
+- {
+- std::stringstream stm;
+- stm << "Inertial: mass [" << mass_xml->Attribute("value")
+- << "] is out of range";
+- CONSOLE_BRIDGE_logError(stm.str().c_str());
+- return false;
+- }
+
+ TiXmlElement *inertia_xml = config->FirstChildElement("inertia");
+ if (!inertia_xml)
+@@ -343,48 +306,43 @@ bool parseInertial(Inertial &i, TiXmlElement *config)
+ CONSOLE_BRIDGE_logError("Inertial element must have inertia element");
+ return false;
+ }
+- if (!(inertia_xml->Attribute("ixx") && inertia_xml->Attribute("ixy") && inertia_xml->Attribute("ixz") &&
+- inertia_xml->Attribute("iyy") && inertia_xml->Attribute("iyz") &&
+- inertia_xml->Attribute("izz")))
+- {
+- CONSOLE_BRIDGE_logError("Inertial: inertia element must have ixx,ixy,ixz,iyy,iyz,izz attributes");
+- return false;
+- }
+- try
+- {
+- i.ixx = std::stod(inertia_xml->Attribute("ixx"));
+- i.ixy = std::stod(inertia_xml->Attribute("ixy"));
+- i.ixz = std::stod(inertia_xml->Attribute("ixz"));
+- i.iyy = std::stod(inertia_xml->Attribute("iyy"));
+- i.iyz = std::stod(inertia_xml->Attribute("iyz"));
+- i.izz = std::stod(inertia_xml->Attribute("izz"));
+- }
+- catch (std::invalid_argument &/*e*/)
+- {
+- std::stringstream stm;
+- stm << "Inertial: one of the inertia elements is not a valid double:"
+- << " ixx [" << inertia_xml->Attribute("ixx") << "]"
+- << " ixy [" << inertia_xml->Attribute("ixy") << "]"
+- << " ixz [" << inertia_xml->Attribute("ixz") << "]"
+- << " iyy [" << inertia_xml->Attribute("iyy") << "]"
+- << " iyz [" << inertia_xml->Attribute("iyz") << "]"
+- << " izz [" << inertia_xml->Attribute("izz") << "]";
+- CONSOLE_BRIDGE_logError(stm.str().c_str());
+- return false;
+- }
+- catch (std::out_of_range &/*e*/)
++
++ std::vector<std::pair<std::string, double>> attrs{
++ std::make_pair("ixx", 0.0),
++ std::make_pair("ixy", 0.0),
++ std::make_pair("ixz", 0.0),
++ std::make_pair("iyy", 0.0),
++ std::make_pair("iyz", 0.0),
++ std::make_pair("izz", 0.0)
++ };
++
++ for (auto& attr : attrs)
+ {
+- std::stringstream stm;
+- stm << "Inertial: one of the inertia elements is out of range:"
+- << " ixx [" << inertia_xml->Attribute("ixx") << "]"
+- << " ixy [" << inertia_xml->Attribute("ixy") << "]"
+- << " ixz [" << inertia_xml->Attribute("ixz") << "]"
+- << " iyy [" << inertia_xml->Attribute("iyy") << "]"
+- << " iyz [" << inertia_xml->Attribute("iyz") << "]"
+- << " izz [" << inertia_xml->Attribute("izz") << "]";
+- CONSOLE_BRIDGE_logError(stm.str().c_str());
+- return false;
++ if (!inertia_xml->Attribute(attr.first))
++ {
++ std::stringstream stm;
++ stm << "Inertial: inertia element missing " << attr.first << " attribute";
++ CONSOLE_BRIDGE_logError(stm.str().c_str());
++ return false;
++ }
++
++ try {
++ attr.second = strToDouble(inertia_xml->Attribute(attr.first.c_str()));
++ } catch(std::runtime_error &) {
++ std::stringstream stm;
++ stm << "Inertial: inertia element " << attr.first << " is not a valid double";
++ CONSOLE_BRIDGE_logError(stm.str().c_str());
++ return false;
++ }
+ }
++
++ i.ixx = attrs[0].second;
++ i.ixy = attrs[1].second;
++ i.ixz = attrs[2].second;
++ i.iyy = attrs[3].second;
++ i.iyz = attrs[4].second;
++ i.izz = attrs[5].second;
++
+ return true;
+ }
+
+diff --git a/urdf_parser/src/urdf_model_state.cpp b/urdf_parser/src/urdf_model_state.cpp
+index d9054dd..aaaca76 100644
+--- a/urdf_parser/src/urdf_model_state.cpp
++++ b/urdf_parser/src/urdf_model_state.cpp
+@@ -38,6 +38,7 @@
+ #include <urdf_model_state/model_state.h>
+ #include <urdf_model/utils.h>
+ #include <fstream>
++#include <locale>
+ #include <sstream>
+ #include <stdexcept>
+ #include <string>
+@@ -63,15 +64,9 @@ bool parseModelState(ModelState &ms, TiXmlElement* config)
+ if (time_stamp_char)
+ {
+ try {
+- double sec = std::stod(time_stamp_char);
+- ms.time_stamp.set(sec);
+- }
+- catch (std::invalid_argument &e) {
+- CONSOLE_BRIDGE_logError("Parsing time stamp [%s] failed: %s", time_stamp_char, e.what());
+- return false;
+- }
+- catch (std::out_of_range &e) {
+- CONSOLE_BRIDGE_logError("Parsing time stamp [%s] failed, out of range: %s", time_stamp_char, e.what());
++ ms.time_stamp.set(strToDouble(time_stamp_char));
++ } catch(std::runtime_error &) {
++ CONSOLE_BRIDGE_logError("Parsing time stamp [%s] failed", time_stamp_char);
+ return false;
+ }
+ }
+@@ -101,14 +96,10 @@ bool parseModelState(ModelState &ms, TiXmlElement* config)
+ for (unsigned int i = 0; i < pieces.size(); ++i){
+ if (pieces[i] != ""){
+ try {
+- joint_state->position.push_back(std::stod(pieces[i].c_str()));
+- }
+- catch (std::invalid_argument &/*e*/) {
++ joint_state->position.push_back(strToDouble(pieces[i].c_str()));
++ } catch(std::runtime_error &) {
+ throw ParseError("position element ("+ pieces[i] +") is not a valid float");
+ }
+- catch (std::out_of_range &/*e*/) {
+- throw ParseError("position element ("+ pieces[i] +") is out of range");
+- }
+ }
+ }
+ }
+@@ -123,14 +114,10 @@ bool parseModelState(ModelState &ms, TiXmlElement* config)
+ for (unsigned int i = 0; i < pieces.size(); ++i){
+ if (pieces[i] != ""){
+ try {
+- joint_state->velocity.push_back(std::stod(pieces[i].c_str()));
+- }
+- catch (std::invalid_argument &/*e*/) {
++ joint_state->velocity.push_back(strToDouble(pieces[i].c_str()));
++ } catch(std::runtime_error &) {
+ throw ParseError("velocity element ("+ pieces[i] +") is not a valid float");
+ }
+- catch (std::out_of_range &/*e*/) {
+- throw ParseError("velocity element ("+ pieces[i] +") is out of range");
+- }
+ }
+ }
+ }
+@@ -145,14 +132,10 @@ bool parseModelState(ModelState &ms, TiXmlElement* config)
+ for (unsigned int i = 0; i < pieces.size(); ++i){
+ if (pieces[i] != ""){
+ try {
+- joint_state->effort.push_back(std::stod(pieces[i].c_str()));
+- }
+- catch (std::invalid_argument &/*e*/) {
++ joint_state->effort.push_back(strToDouble(pieces[i].c_str()));
++ } catch(std::runtime_error &) {
+ throw ParseError("effort element ("+ pieces[i] +") is not a valid float");
+ }
+- catch (std::out_of_range &/*e*/) {
+- throw ParseError("effort element ("+ pieces[i] +") is out of range");
+- }
+ }
+ }
+ }
+diff --git a/urdf_parser/src/urdf_sensor.cpp b/urdf_parser/src/urdf_sensor.cpp
+index 71fc1e5..29626f4 100644
+--- a/urdf_parser/src/urdf_sensor.cpp
++++ b/urdf_parser/src/urdf_sensor.cpp
+@@ -37,6 +37,7 @@
+
+ #include <urdf_sensor/sensor.h>
+ #include <fstream>
++#include <locale>
+ #include <sstream>
+ #include <stdexcept>
+ #include <string>
+@@ -116,18 +117,10 @@ bool parseCamera(Camera &camera, TiXmlElement* config)
+ const char* hfov_char = image->Attribute("hfov");
+ if (hfov_char)
+ {
+- try
+- {
+- camera.hfov = std::stod(hfov_char);
+- }
+- catch (std::invalid_argument &e)
+- {
+- CONSOLE_BRIDGE_logError("Camera image hfov [%s] is not a valid float: %s", hfov_char, e.what());
+- return false;
+- }
+- catch (std::out_of_range &e)
+- {
+- CONSOLE_BRIDGE_logError("Camera image hfov [%s] is out of range: %s", hfov_char, e.what());
++ try {
++ camera.hfov = strToDouble(hfov_char);
++ } catch(std::runtime_error &) {
++ CONSOLE_BRIDGE_logError("Camera image hfov [%s] is not a valid float", hfov_char);
+ return false;
+ }
+ }
+@@ -140,18 +133,10 @@ bool parseCamera(Camera &camera, TiXmlElement* config)
+ const char* near_char = image->Attribute("near");
+ if (near_char)
+ {
+- try
+- {
+- camera.near = std::stod(near_char);
+- }
+- catch (std::invalid_argument &e)
+- {
+- CONSOLE_BRIDGE_logError("Camera image near [%s] is not a valid float: %s", near_char, e.what());
+- return false;
+- }
+- catch (std::out_of_range &e)
+- {
+- CONSOLE_BRIDGE_logError("Camera image near [%s] is out of range: %s", near_char, e.what());
++ try {
++ camera.near = strToDouble(near_char);
++ } catch(std::runtime_error &) {
++ CONSOLE_BRIDGE_logError("Camera image near [%s] is not a valid float", near_char);
+ return false;
+ }
+ }
+@@ -164,18 +149,10 @@ bool parseCamera(Camera &camera, TiXmlElement* config)
+ const char* far_char = image->Attribute("far");
+ if (far_char)
+ {
+- try
+- {
+- camera.far = std::stod(far_char);
+- }
+- catch (std::invalid_argument &e)
+- {
+- CONSOLE_BRIDGE_logError("Camera image far [%s] is not a valid float: %s", far_char, e.what());
+- return false;
+- }
+- catch (std::out_of_range &e)
+- {
+- CONSOLE_BRIDGE_logError("Camera image far [%s] is out of range: %s", far_char, e.what());
++ try {
++ camera.far = strToDouble(far_char);
++ } catch(std::runtime_error &) {
++ CONSOLE_BRIDGE_logError("Camera image far [%s] is not a valid float", far_char);
+ return false;
+ }
+ }
+@@ -224,37 +201,21 @@ bool parseRay(Ray &ray, TiXmlElement* config)
+ const char* resolution_char = horizontal->Attribute("resolution");
+ if (resolution_char)
+ {
+- try
+- {
+- ray.horizontal_resolution = std::stod(resolution_char);
+- }
+- catch (std::invalid_argument &e)
+- {
+- CONSOLE_BRIDGE_logError("Ray horizontal resolution [%s] is not a valid float: %s", resolution_char, e.what());
+- return false;
+- }
+- catch (std::out_of_range &e)
+- {
+- CONSOLE_BRIDGE_logError("Ray horizontal resolution [%s] is out of range: %s", resolution_char, e.what());
++ try {
++ ray.horizontal_resolution = strToDouble(resolution_char);
++ } catch(std::runtime_error &) {
++ CONSOLE_BRIDGE_logError("Ray horizontal resolution [%s] is not a valid float", resolution_char);
+ return false;
+ }
+- }
+-
++ }
++
+ const char* min_angle_char = horizontal->Attribute("min_angle");
+ if (min_angle_char)
+ {
+- try
+- {
+- ray.horizontal_min_angle = std::stod(min_angle_char);
+- }
+- catch (std::invalid_argument &e)
+- {
+- CONSOLE_BRIDGE_logError("Ray horizontal min_angle [%s] is not a valid float: %s", min_angle_char, e.what());
+- return false;
+- }
+- catch (std::out_of_range &e)
+- {
+- CONSOLE_BRIDGE_logError("Ray horizontal min_angle [%s] is out of range: %s", min_angle_char, e.what());
++ try {
++ ray.horizontal_min_angle = strToDouble(min_angle_char);
++ } catch(std::runtime_error &) {
++ CONSOLE_BRIDGE_logError("Ray horizontal min_angle [%s] is not a valid float", min_angle_char);
+ return false;
+ }
+ }
+@@ -262,18 +223,10 @@ bool parseRay(Ray &ray, TiXmlElement* config)
+ const char* max_angle_char = horizontal->Attribute("max_angle");
+ if (max_angle_char)
+ {
+- try
+- {
+- ray.horizontal_max_angle = std::stod(max_angle_char);
+- }
+- catch (std::invalid_argument &e)
+- {
+- CONSOLE_BRIDGE_logError("Ray horizontal max_angle [%s] is not a valid float: %s", max_angle_char, e.what());
+- return false;
+- }
+- catch (std::out_of_range &e)
+- {
+- CONSOLE_BRIDGE_logError("Ray horizontal max_angle [%s] is out of range: %s", max_angle_char, e.what());
++ try {
++ ray.horizontal_max_angle = strToDouble(max_angle_char);
++ } catch(std::runtime_error &) {
++ CONSOLE_BRIDGE_logError("Ray horizontal max_angle [%s] is not a valid float", max_angle_char);
+ return false;
+ }
+ }
+@@ -304,37 +257,21 @@ bool parseRay(Ray &ray, TiXmlElement* config)
+ const char* resolution_char = vertical->Attribute("resolution");
+ if (resolution_char)
+ {
+- try
+- {
+- ray.vertical_resolution = std::stod(resolution_char);
+- }
+- catch (std::invalid_argument &e)
+- {
+- CONSOLE_BRIDGE_logError("Ray vertical resolution [%s] is not a valid float: %s", resolution_char, e.what());
+- return false;
+- }
+- catch (std::out_of_range &e)
+- {
+- CONSOLE_BRIDGE_logError("Ray vertical resolution [%s] is out of range: %s", resolution_char, e.what());
++ try {
++ ray.vertical_resolution = strToDouble(resolution_char);
++ } catch(std::runtime_error &) {
++ CONSOLE_BRIDGE_logError("Ray vertical resolution [%s] is not a valid float", resolution_char);
+ return false;
+ }
+- }
+-
++ }
++
+ const char* min_angle_char = vertical->Attribute("min_angle");
+ if (min_angle_char)
+ {
+- try
+- {
+- ray.vertical_min_angle = std::stod(min_angle_char);
+- }
+- catch (std::invalid_argument &e)
+- {
+- CONSOLE_BRIDGE_logError("Ray vertical min_angle [%s] is not a valid float: %s", min_angle_char, e.what());
+- return false;
+- }
+- catch (std::out_of_range &e)
+- {
+- CONSOLE_BRIDGE_logError("Ray vertical min_angle [%s] is out of range: %s", min_angle_char, e.what());
++ try {
++ ray.vertical_min_angle = strToDouble(min_angle_char);
++ } catch(std::runtime_error &) {
++ CONSOLE_BRIDGE_logError("Ray vertical min_angle [%s] is not a valid float", min_angle_char);
+ return false;
+ }
+ }
+@@ -342,18 +279,10 @@ bool parseRay(Ray &ray, TiXmlElement* config)
+ const char* max_angle_char = vertical->Attribute("max_angle");
+ if (max_angle_char)
+ {
+- try
+- {
+- ray.vertical_max_angle = std::stod(max_angle_char);
+- }
+- catch (std::invalid_argument &e)
+- {
+- CONSOLE_BRIDGE_logError("Ray vertical max_angle [%s] is not a valid float: %s", max_angle_char, e.what());
+- return false;
+- }
+- catch (std::out_of_range &e)
+- {
+- CONSOLE_BRIDGE_logError("Ray vertical max_angle [%s] is out of range: %s", max_angle_char, e.what());
++ try {
++ ray.vertical_max_angle = strToDouble(max_angle_char);
++ } catch(std::runtime_error &) {
++ CONSOLE_BRIDGE_logError("Ray vertical max_angle [%s] is not a valid float", max_angle_char);
+ return false;
+ }
+ }
diff -Nru urdfdom-1.0.0/debian/patches/series urdfdom-1.0.0/debian/patches/series
--- urdfdom-1.0.0/debian/patches/series 2016-09-14 17:00:50.000000000 +0000
+++ urdfdom-1.0.0/debian/patches/series 2019-08-06 17:51:52.000000000 +0000
@@ -1 +1,2 @@
0001-Fix-installed-CMake-module-to-cope-with-multiarch.patch
+avoid_truncating_floating_values.patch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment