Skip to content

Commit

Permalink
Merge pull request #90 from scpeters/unboost
Browse files Browse the repository at this point in the history
Unboost: bump version to 1.0 and use c++11
  • Loading branch information
scpeters authored Jul 20, 2016
2 parents 5efe7b6 + 59f3f05 commit 8b27e0b
Show file tree
Hide file tree
Showing 8 changed files with 292 additions and 99 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
15 changes: 7 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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})
Expand Down Expand Up @@ -35,17 +35,16 @@ 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})
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)
Expand Down
2 changes: 1 addition & 1 deletion cmake/urdfdom-config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
8 changes: 4 additions & 4 deletions urdf_parser/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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})

# --------------------------------
Expand Down
129 changes: 100 additions & 29 deletions urdf_parser/src/joint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@
/* Author: John Hsu */

#include <sstream>
#include <stdexcept>
#include <string>
#include <urdf_model/joint.h>
#include <boost/lexical_cast.hpp>
#include <console_bridge/console.h>
#include <tinyxml.h>
#include <urdf_parser/urdf_parser.h>
Expand All @@ -59,13 +60,18 @@ bool parseJointDynamics(JointDynamics &jd, TiXmlElement* config)
{
try
{
jd.damping = boost::lexical_cast<double>(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
Expand All @@ -78,13 +84,18 @@ bool parseJointDynamics(JointDynamics &jd, TiXmlElement* config)
{
try
{
jd.friction = boost::lexical_cast<double>(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)
Expand Down Expand Up @@ -112,13 +123,18 @@ bool parseJointLimits(JointLimits &jl, TiXmlElement* config)
{
try
{
jl.lower = boost::lexical_cast<double>(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
Expand All @@ -131,13 +147,18 @@ bool parseJointLimits(JointLimits &jl, TiXmlElement* config)
{
try
{
jl.upper = boost::lexical_cast<double>(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
Expand All @@ -150,13 +171,18 @@ bool parseJointLimits(JointLimits &jl, TiXmlElement* config)
{
try
{
jl.effort = boost::lexical_cast<double>(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
Expand All @@ -169,13 +195,18 @@ bool parseJointLimits(JointLimits &jl, TiXmlElement* config)
{
try
{
jl.velocity = boost::lexical_cast<double>(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;
Expand All @@ -196,13 +227,18 @@ bool parseJointSafety(JointSafety &js, TiXmlElement* config)
{
try
{
js.soft_lower_limit = boost::lexical_cast<double>(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
Expand All @@ -216,13 +252,18 @@ bool parseJointSafety(JointSafety &js, TiXmlElement* config)
{
try
{
js.soft_upper_limit = boost::lexical_cast<double>(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
Expand All @@ -236,13 +277,18 @@ bool parseJointSafety(JointSafety &js, TiXmlElement* config)
{
try
{
js.k_position = boost::lexical_cast<double>(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");
Expand All @@ -255,13 +301,18 @@ bool parseJointSafety(JointSafety &js, TiXmlElement* config)
{
try
{
js.k_velocity = boost::lexical_cast<double>(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;
Expand All @@ -282,13 +333,18 @@ bool parseJointCalibration(JointCalibration &jc, TiXmlElement* config)
{
try
{
jc.rising.reset(new double(boost::lexical_cast<double>(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
Expand All @@ -302,13 +358,18 @@ bool parseJointCalibration(JointCalibration &jc, TiXmlElement* config)
{
try
{
jc.falling.reset(new double(boost::lexical_cast<double>(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;
Expand Down Expand Up @@ -341,13 +402,18 @@ bool parseJointMimic(JointMimic &jm, TiXmlElement* config)
{
try
{
jm.multiplier = boost::lexical_cast<double>(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;
}
}


Expand All @@ -362,13 +428,18 @@ bool parseJointMimic(JointMimic &jm, TiXmlElement* config)
{
try
{
jm.offset = boost::lexical_cast<double>(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;
Expand Down
Loading

0 comments on commit 8b27e0b

Please sign in to comment.