From 6595a46ce1d21f1dd2d18a6465e4a590678e5f15 Mon Sep 17 00:00:00 2001 From: Steven Peters Date: Wed, 16 Mar 2016 17:19:49 -0700 Subject: [PATCH 1/5] Find urdfdom_headers 1.0, set c++11 flag --- CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2485b5dc..7113931a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,8 +35,11 @@ set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") find_package(TinyXML REQUIRED) include_directories(SYSTEM ${TinyXML_INCLUDE_DIRS}) -find_package(urdfdom_headers 0.4 REQUIRED) +find_package(urdfdom_headers 1.0 REQUIRED) include_directories(SYSTEM ${urdfdom_headers_INCLUDE_DIRS}) +if (NOT MSVC) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") +endif() find_package(console_bridge 0.3 REQUIRED) include_directories(SYSTEM ${console_bridge_INCLUDE_DIRS}) From 511d48f38537d224c58c81a9791be4e0dc8b3697 Mon Sep 17 00:00:00 2001 From: Steven Peters Date: Thu, 14 Jul 2016 11:20:35 -0700 Subject: [PATCH 2/5] Bump version to 1.0.0 --- CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7113931a..7ff30b08 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,9 +1,9 @@ cmake_minimum_required( VERSION 2.8 FATAL_ERROR ) project (urdfdom CXX C) -set (URDF_MAJOR_VERSION 0) -set (URDF_MINOR_VERSION 4) -set (URDF_PATCH_VERSION 2) +set (URDF_MAJOR_VERSION 1) +set (URDF_MINOR_VERSION 0) +set (URDF_PATCH_VERSION 0) set (URDF_VERSION ${URDF_MAJOR_VERSION}.${URDF_MINOR_VERSION}.${URDF_PATCH_VERSION}) set (URDF_MAJOR_MINOR_VERSION ${URDF_MAJOR_VERSION}.${URDF_MINOR_VERSION}) From 17d8c73b2a9e573f14c0603a37a1978c83ab64f6 Mon Sep 17 00:00:00 2001 From: Steven Peters Date: Mon, 22 Feb 2016 22:53:09 -0800 Subject: [PATCH 3/5] Replace boost::split with urdf::split_string Included from urdf_model/utils.h --- urdf_parser/src/urdf_model_state.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/urdf_parser/src/urdf_model_state.cpp b/urdf_parser/src/urdf_model_state.cpp index e9e1b267..5ceb25b8 100644 --- a/urdf_parser/src/urdf_model_state.cpp +++ b/urdf_parser/src/urdf_model_state.cpp @@ -36,9 +36,9 @@ #include +#include #include #include -#include #include #include #include @@ -92,7 +92,7 @@ bool parseModelState(ModelState &ms, TiXmlElement* config) { std::vector pieces; - boost::split( pieces, position_char, boost::is_any_of(" ")); + urdf::split_string( pieces, position_char, " "); for (unsigned int i = 0; i < pieces.size(); ++i){ if (pieces[i] != ""){ try { @@ -111,7 +111,7 @@ bool parseModelState(ModelState &ms, TiXmlElement* config) { std::vector pieces; - boost::split( pieces, velocity_char, boost::is_any_of(" ")); + urdf::split_string( pieces, velocity_char, " "); for (unsigned int i = 0; i < pieces.size(); ++i){ if (pieces[i] != ""){ try { @@ -130,7 +130,7 @@ bool parseModelState(ModelState &ms, TiXmlElement* config) { std::vector pieces; - boost::split( pieces, effort_char, boost::is_any_of(" ")); + urdf::split_string( pieces, effort_char, " "); for (unsigned int i = 0; i < pieces.size(); ++i){ if (pieces[i] != ""){ try { From 3dc7ee812827cc69ffa457ef01fe7b9623096aed Mon Sep 17 00:00:00 2001 From: Steven Peters Date: Tue, 23 Feb 2016 15:50:43 -0800 Subject: [PATCH 4/5] Replace boost::lexical_cast with std::sto* This requires catching an additional out_of_range exception. --- urdf_parser/src/joint.cpp | 129 +++++++++++++++++++++------ urdf_parser/src/link.cpp | 75 ++++++++++++---- urdf_parser/src/urdf_model_state.cpp | 32 +++++-- urdf_parser/src/urdf_sensor.cpp | 120 +++++++++++++++++++------ 4 files changed, 275 insertions(+), 81 deletions(-) diff --git a/urdf_parser/src/joint.cpp b/urdf_parser/src/joint.cpp index 71164de0..07cbeae1 100644 --- a/urdf_parser/src/joint.cpp +++ b/urdf_parser/src/joint.cpp @@ -35,8 +35,9 @@ /* Author: John Hsu */ #include +#include +#include #include -#include #include #include #include @@ -59,13 +60,18 @@ bool parseJointDynamics(JointDynamics &jd, TiXmlElement* config) { try { - jd.damping = boost::lexical_cast(damping_str); + jd.damping = std::stod(damping_str); } - catch (boost::bad_lexical_cast &e) + 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()); + return false; + } } // Get joint friction @@ -78,13 +84,18 @@ bool parseJointDynamics(JointDynamics &jd, TiXmlElement* config) { try { - jd.friction = boost::lexical_cast(friction_str); + jd.friction = std::stod(friction_str); } - catch (boost::bad_lexical_cast &e) + 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()); + return false; + } } if (damping_str == NULL && friction_str == NULL) @@ -112,13 +123,18 @@ bool parseJointLimits(JointLimits &jl, TiXmlElement* config) { try { - jl.lower = boost::lexical_cast(lower_str); + jl.lower = std::stod(lower_str); } - catch (boost::bad_lexical_cast &e) + 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()); + return false; + } } // Get upper joint limit @@ -131,13 +147,18 @@ bool parseJointLimits(JointLimits &jl, TiXmlElement* config) { try { - jl.upper = boost::lexical_cast(upper_str); + jl.upper = std::stod(upper_str); } - catch (boost::bad_lexical_cast &e) + 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()); + return false; + } } // Get joint effort limit @@ -150,13 +171,18 @@ bool parseJointLimits(JointLimits &jl, TiXmlElement* config) { try { - jl.effort = boost::lexical_cast(effort_str); + jl.effort = std::stod(effort_str); } - catch (boost::bad_lexical_cast &e) + 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()); + return false; + } } // Get joint velocity limit @@ -169,13 +195,18 @@ bool parseJointLimits(JointLimits &jl, TiXmlElement* config) { try { - jl.velocity = boost::lexical_cast(velocity_str); + jl.velocity = std::stod(velocity_str); } - catch (boost::bad_lexical_cast &e) + 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()); + return false; + } } return true; @@ -196,13 +227,18 @@ bool parseJointSafety(JointSafety &js, TiXmlElement* config) { try { - js.soft_lower_limit = boost::lexical_cast(soft_lower_limit_str); + js.soft_lower_limit = std::stod(soft_lower_limit_str); } - catch (boost::bad_lexical_cast &e) + 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()); + return false; + } } // Get soft_upper_limit joint limit @@ -216,13 +252,18 @@ bool parseJointSafety(JointSafety &js, TiXmlElement* config) { try { - js.soft_upper_limit = boost::lexical_cast(soft_upper_limit_str); + js.soft_upper_limit = std::stod(soft_upper_limit_str); } - catch (boost::bad_lexical_cast &e) + 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()); + return false; + } } // Get k_position_ safety "position" gain - not exactly position gain @@ -236,13 +277,18 @@ bool parseJointSafety(JointSafety &js, TiXmlElement* config) { try { - js.k_position = boost::lexical_cast(k_position_str); + js.k_position = std::stod(k_position_str); } - catch (boost::bad_lexical_cast &e) + 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()); + return false; + } } // Get k_velocity_ safety velocity gain const char* k_velocity_str = config->Attribute("k_velocity"); @@ -255,13 +301,18 @@ bool parseJointSafety(JointSafety &js, TiXmlElement* config) { try { - js.k_velocity = boost::lexical_cast(k_velocity_str); + js.k_velocity = std::stod(k_velocity_str); } - catch (boost::bad_lexical_cast &e) + 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()); + return false; + } } return true; @@ -282,13 +333,18 @@ bool parseJointCalibration(JointCalibration &jc, TiXmlElement* config) { try { - jc.rising.reset(new double(boost::lexical_cast(rising_position_str))); + jc.rising.reset(new double(std::stod(rising_position_str))); } - catch (boost::bad_lexical_cast &e) + 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()); + return false; + } } // Get falling edge position @@ -302,13 +358,18 @@ bool parseJointCalibration(JointCalibration &jc, TiXmlElement* config) { try { - jc.falling.reset(new double(boost::lexical_cast(falling_position_str))); + jc.falling.reset(new double(std::stod(falling_position_str))); } - catch (boost::bad_lexical_cast &e) + 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()); + return false; + } } return true; @@ -341,13 +402,18 @@ bool parseJointMimic(JointMimic &jm, TiXmlElement* config) { try { - jm.multiplier = boost::lexical_cast(multiplier_str); + jm.multiplier = std::stod(multiplier_str); } - catch (boost::bad_lexical_cast &e) + 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()); + return false; + } } @@ -362,13 +428,18 @@ bool parseJointMimic(JointMimic &jm, TiXmlElement* config) { try { - jm.offset = boost::lexical_cast(offset_str); + jm.offset = std::stod(offset_str); } - catch (boost::bad_lexical_cast &e) + 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()); + return false; + } } return true; diff --git a/urdf_parser/src/link.cpp b/urdf_parser/src/link.cpp index b603c519..0e8b8c30 100644 --- a/urdf_parser/src/link.cpp +++ b/urdf_parser/src/link.cpp @@ -39,7 +39,8 @@ #include #include #include -#include +#include +#include #include #include #include @@ -116,15 +117,22 @@ bool parseSphere(Sphere &s, TiXmlElement *c) try { - s.radius = boost::lexical_cast(c->Attribute("radius")); + s.radius = std::stod(c->Attribute("radius")); } - catch (boost::bad_lexical_cast &e) + 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) + { + std::stringstream stm; + stm << "radius [" << c->Attribute("radius") << "] is out of range: " << e.what(); + CONSOLE_BRIDGE_logError(stm.str().c_str()); + return false; + } return true; } @@ -166,27 +174,41 @@ bool parseCylinder(Cylinder &y, TiXmlElement *c) try { - y.length = boost::lexical_cast(c->Attribute("length")); + y.length = std::stod(c->Attribute("length")); } - catch (boost::bad_lexical_cast &/*e*/) + catch (std::invalid_argument &/*e*/) { 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 = boost::lexical_cast(c->Attribute("radius")); + y.radius = std::stod(c->Attribute("radius")); } - catch (boost::bad_lexical_cast &/*e*/) + catch (std::invalid_argument &/*e*/) { 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; } @@ -296,9 +318,9 @@ bool parseInertial(Inertial &i, TiXmlElement *config) try { - i.mass = boost::lexical_cast(mass_xml->Attribute("value")); + i.mass = std::stod(mass_xml->Attribute("value")); } - catch (boost::bad_lexical_cast &/*e*/) + catch (std::invalid_argument &/*e*/) { std::stringstream stm; stm << "Inertial: mass [" << mass_xml->Attribute("value") @@ -306,6 +328,14 @@ bool parseInertial(Inertial &i, TiXmlElement *config) 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) @@ -322,14 +352,14 @@ bool parseInertial(Inertial &i, TiXmlElement *config) } try { - i.ixx = boost::lexical_cast(inertia_xml->Attribute("ixx")); - i.ixy = boost::lexical_cast(inertia_xml->Attribute("ixy")); - i.ixz = boost::lexical_cast(inertia_xml->Attribute("ixz")); - i.iyy = boost::lexical_cast(inertia_xml->Attribute("iyy")); - i.iyz = boost::lexical_cast(inertia_xml->Attribute("iyz")); - i.izz = boost::lexical_cast(inertia_xml->Attribute("izz")); + 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 (boost::bad_lexical_cast &/*e*/) + catch (std::invalid_argument &/*e*/) { std::stringstream stm; stm << "Inertial: one of the inertia elements is not a valid double:" @@ -342,6 +372,19 @@ bool parseInertial(Inertial &i, TiXmlElement *config) CONSOLE_BRIDGE_logError(stm.str().c_str()); return false; } + catch (std::out_of_range &/*e*/) + { + 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; + } return true; } diff --git a/urdf_parser/src/urdf_model_state.cpp b/urdf_parser/src/urdf_model_state.cpp index 5ceb25b8..d9054dda 100644 --- a/urdf_parser/src/urdf_model_state.cpp +++ b/urdf_parser/src/urdf_model_state.cpp @@ -39,7 +39,8 @@ #include #include #include -#include +#include +#include #include #include #include @@ -62,13 +63,17 @@ bool parseModelState(ModelState &ms, TiXmlElement* config) if (time_stamp_char) { try { - double sec = boost::lexical_cast(time_stamp_char); + double sec = std::stod(time_stamp_char); ms.time_stamp.set(sec); } - catch (boost::bad_lexical_cast &e) { + 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()); + return false; + } } TiXmlElement *joint_state_elem = config->FirstChildElement("joint_state"); @@ -96,11 +101,14 @@ bool parseModelState(ModelState &ms, TiXmlElement* config) for (unsigned int i = 0; i < pieces.size(); ++i){ if (pieces[i] != ""){ try { - joint_state->position.push_back(boost::lexical_cast(pieces[i].c_str())); + joint_state->position.push_back(std::stod(pieces[i].c_str())); } - catch (boost::bad_lexical_cast &/*e*/) { + catch (std::invalid_argument &/*e*/) { 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"); + } } } } @@ -115,11 +123,14 @@ bool parseModelState(ModelState &ms, TiXmlElement* config) for (unsigned int i = 0; i < pieces.size(); ++i){ if (pieces[i] != ""){ try { - joint_state->velocity.push_back(boost::lexical_cast(pieces[i].c_str())); + joint_state->velocity.push_back(std::stod(pieces[i].c_str())); } - catch (boost::bad_lexical_cast &/*e*/) { + catch (std::invalid_argument &/*e*/) { 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"); + } } } } @@ -134,11 +145,14 @@ bool parseModelState(ModelState &ms, TiXmlElement* config) for (unsigned int i = 0; i < pieces.size(); ++i){ if (pieces[i] != ""){ try { - joint_state->effort.push_back(boost::lexical_cast(pieces[i].c_str())); + joint_state->effort.push_back(std::stod(pieces[i].c_str())); } - catch (boost::bad_lexical_cast &/*e*/) { + catch (std::invalid_argument &/*e*/) { 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 b280e350..71fc1e55 100644 --- a/urdf_parser/src/urdf_sensor.cpp +++ b/urdf_parser/src/urdf_sensor.cpp @@ -38,7 +38,8 @@ #include #include #include -#include +#include +#include #include #include #include @@ -60,13 +61,18 @@ bool parseCamera(Camera &camera, TiXmlElement* config) { try { - camera.width = boost::lexical_cast(width_char); + camera.width = std::stoul(width_char); } - catch (boost::bad_lexical_cast &e) + catch (std::invalid_argument &e) { CONSOLE_BRIDGE_logError("Camera image width [%s] is not a valid int: %s", width_char, e.what()); return false; } + catch (std::out_of_range &e) + { + CONSOLE_BRIDGE_logError("Camera image width [%s] is out of range: %s", width_char, e.what()); + return false; + } } else { @@ -79,13 +85,18 @@ bool parseCamera(Camera &camera, TiXmlElement* config) { try { - camera.height = boost::lexical_cast(height_char); + camera.height = std::stoul(height_char); } - catch (boost::bad_lexical_cast &e) + catch (std::invalid_argument &e) { CONSOLE_BRIDGE_logError("Camera image height [%s] is not a valid int: %s", height_char, e.what()); return false; } + catch (std::out_of_range &e) + { + CONSOLE_BRIDGE_logError("Camera image height [%s] is out of range: %s", height_char, e.what()); + return false; + } } else { @@ -107,13 +118,18 @@ bool parseCamera(Camera &camera, TiXmlElement* config) { try { - camera.hfov = boost::lexical_cast(hfov_char); + camera.hfov = std::stod(hfov_char); } - catch (boost::bad_lexical_cast &e) + 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()); + return false; + } } else { @@ -126,13 +142,18 @@ bool parseCamera(Camera &camera, TiXmlElement* config) { try { - camera.near = boost::lexical_cast(near_char); + camera.near = std::stod(near_char); } - catch (boost::bad_lexical_cast &e) + 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()); + return false; + } } else { @@ -145,13 +166,18 @@ bool parseCamera(Camera &camera, TiXmlElement* config) { try { - camera.far = boost::lexical_cast(far_char); + camera.far = std::stod(far_char); } - catch (boost::bad_lexical_cast &e) + 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()); + return false; + } } else { @@ -181,13 +207,18 @@ bool parseRay(Ray &ray, TiXmlElement* config) { try { - ray.horizontal_samples = boost::lexical_cast(samples_char); + ray.horizontal_samples = std::stoul(samples_char); } - catch (boost::bad_lexical_cast &e) + catch (std::invalid_argument &e) { CONSOLE_BRIDGE_logError("Ray horizontal samples [%s] is not a valid float: %s", samples_char, e.what()); return false; } + catch (std::out_of_range &e) + { + CONSOLE_BRIDGE_logError("Ray horizontal samples [%s] is out of range: %s", samples_char, e.what()); + return false; + } } const char* resolution_char = horizontal->Attribute("resolution"); @@ -195,13 +226,18 @@ bool parseRay(Ray &ray, TiXmlElement* config) { try { - ray.horizontal_resolution = boost::lexical_cast(resolution_char); + ray.horizontal_resolution = std::stod(resolution_char); } - catch (boost::bad_lexical_cast &e) + 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()); + return false; + } } const char* min_angle_char = horizontal->Attribute("min_angle"); @@ -209,13 +245,18 @@ bool parseRay(Ray &ray, TiXmlElement* config) { try { - ray.horizontal_min_angle = boost::lexical_cast(min_angle_char); + ray.horizontal_min_angle = std::stod(min_angle_char); } - catch (boost::bad_lexical_cast &e) + 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()); + return false; + } } const char* max_angle_char = horizontal->Attribute("max_angle"); @@ -223,13 +264,18 @@ bool parseRay(Ray &ray, TiXmlElement* config) { try { - ray.horizontal_max_angle = boost::lexical_cast(max_angle_char); + ray.horizontal_max_angle = std::stod(max_angle_char); } - catch (boost::bad_lexical_cast &e) + 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()); + return false; + } } } @@ -241,13 +287,18 @@ bool parseRay(Ray &ray, TiXmlElement* config) { try { - ray.vertical_samples = boost::lexical_cast(samples_char); + ray.vertical_samples = std::stoul(samples_char); } - catch (boost::bad_lexical_cast &e) + catch (std::invalid_argument &e) { CONSOLE_BRIDGE_logError("Ray vertical samples [%s] is not a valid float: %s", samples_char, e.what()); return false; } + catch (std::out_of_range &e) + { + CONSOLE_BRIDGE_logError("Ray vertical samples [%s] is out of range: %s", samples_char, e.what()); + return false; + } } const char* resolution_char = vertical->Attribute("resolution"); @@ -255,13 +306,18 @@ bool parseRay(Ray &ray, TiXmlElement* config) { try { - ray.vertical_resolution = boost::lexical_cast(resolution_char); + ray.vertical_resolution = std::stod(resolution_char); } - catch (boost::bad_lexical_cast &e) + 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()); + return false; + } } const char* min_angle_char = vertical->Attribute("min_angle"); @@ -269,13 +325,18 @@ bool parseRay(Ray &ray, TiXmlElement* config) { try { - ray.vertical_min_angle = boost::lexical_cast(min_angle_char); + ray.vertical_min_angle = std::stod(min_angle_char); } - catch (boost::bad_lexical_cast &e) + 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()); + return false; + } } const char* max_angle_char = vertical->Attribute("max_angle"); @@ -283,13 +344,18 @@ bool parseRay(Ray &ray, TiXmlElement* config) { try { - ray.vertical_max_angle = boost::lexical_cast(max_angle_char); + ray.vertical_max_angle = std::stod(max_angle_char); } - catch (boost::bad_lexical_cast &e) + 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()); + return false; + } } } return false; From 59f3f050bb4c2a34b43ce53c086afe289b8a5e82 Mon Sep 17 00:00:00 2001 From: Steven Peters Date: Wed, 13 Jul 2016 18:06:13 -0700 Subject: [PATCH 5/5] Remove all references to boost --- .travis.yml | 2 +- CMakeLists.txt | 4 ---- cmake/urdfdom-config.cmake.in | 2 +- urdf_parser/CMakeLists.txt | 8 ++++---- 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index 87b9ef8e..c711dc97 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,7 @@ compiler: script: "./.travis/build" before_install: - sudo apt-get update -qq - - sudo apt-get install -qq libboost-system-dev libboost-thread-dev libboost-test-dev libtinyxml-dev + - sudo apt-get install -qq libtinyxml-dev matrix: allow_failures: - compiler: clang diff --git a/CMakeLists.txt b/CMakeLists.txt index 7ff30b08..48b96d3b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,10 +45,6 @@ find_package(console_bridge 0.3 REQUIRED) include_directories(SYSTEM ${console_bridge_INCLUDE_DIRS}) link_directories(${console_bridge_LIBRARY_DIRS}) -find_package(Boost REQUIRED system thread) -include_directories(${Boost_INCLUDE_DIR}) -link_directories(${Boost_LIBRARY_DIRS}) - #In Visual Studio a special postfix for #libraries compiled in debug is used if(MSVC) diff --git a/cmake/urdfdom-config.cmake.in b/cmake/urdfdom-config.cmake.in index 43b7a065..fb81b476 100644 --- a/cmake/urdfdom-config.cmake.in +++ b/cmake/urdfdom-config.cmake.in @@ -3,7 +3,7 @@ if (@PKG_NAME@_CONFIG_INCLUDED) endif() set(@PKG_NAME@_CONFIG_INCLUDED TRUE) -set(@PKG_NAME@_INCLUDE_DIRS "@CMAKE_INSTALL_PREFIX@/include" "@Boost_INCLUDE_DIR@" "@TinyXML_INCLUDE_DIRS@") +set(@PKG_NAME@_INCLUDE_DIRS "@CMAKE_INSTALL_PREFIX@/include" "@TinyXML_INCLUDE_DIRS@") foreach(lib @PKG_LIBRARIES@) set(onelib "${lib}-NOTFOUND") diff --git a/urdf_parser/CMakeLists.txt b/urdf_parser/CMakeLists.txt index 75194857..333226e1 100644 --- a/urdf_parser/CMakeLists.txt +++ b/urdf_parser/CMakeLists.txt @@ -1,19 +1,19 @@ include_directories(include) add_library(urdfdom_world SHARED src/pose.cpp src/model.cpp src/link.cpp src/joint.cpp src/world.cpp) -target_link_libraries(urdfdom_world ${TinyXML_LIBRARIES} ${console_bridge_LIBRARIES} ${Boost_LIBRARIES}) +target_link_libraries(urdfdom_world ${TinyXML_LIBRARIES} ${console_bridge_LIBRARIES}) set_target_properties(urdfdom_world PROPERTIES SOVERSION ${URDF_MAJOR_MINOR_VERSION}) add_library(urdfdom_model SHARED src/pose.cpp src/model.cpp src/link.cpp src/joint.cpp) -target_link_libraries(urdfdom_model ${TinyXML_LIBRARIES} ${console_bridge_LIBRARIES} ${Boost_LIBRARIES}) +target_link_libraries(urdfdom_model ${TinyXML_LIBRARIES} ${console_bridge_LIBRARIES}) set_target_properties(urdfdom_model PROPERTIES SOVERSION ${URDF_MAJOR_MINOR_VERSION}) add_library(urdfdom_sensor SHARED src/urdf_sensor.cpp) -target_link_libraries(urdfdom_sensor urdfdom_model ${TinyXML_LIBRARIES} ${console_bridge_LIBRARIES} ${Boost_LIBRARIES}) +target_link_libraries(urdfdom_sensor urdfdom_model ${TinyXML_LIBRARIES} ${console_bridge_LIBRARIES}) set_target_properties(urdfdom_sensor PROPERTIES SOVERSION ${URDF_MAJOR_MINOR_VERSION}) add_library(urdfdom_model_state SHARED src/urdf_model_state.cpp src/twist.cpp) -target_link_libraries(urdfdom_model_state ${TinyXML_LIBRARIES} ${console_bridge_LIBRARIES} ${Boost_LIBRARIES}) +target_link_libraries(urdfdom_model_state ${TinyXML_LIBRARIES} ${console_bridge_LIBRARIES}) set_target_properties(urdfdom_model_state PROPERTIES SOVERSION ${URDF_MAJOR_MINOR_VERSION}) # --------------------------------