Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support urdfdom_headers 1.0 #766

Merged
merged 3 commits into from
Aug 27, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@

* Fixed incorrect linking to flann library: [#761](https://github.com/dartsim/dart/pull/761)

* Parsers

* Added support of urdfdom_headers 1.0: [#766](https://github.com/dartsim/dart/pull/766)

* Misc improvements and bug fixes

* Made building with SIMD optional: [#765](https://github.com/dartsim/dart/pull/765), [#760](https://github.com/dartsim/dart/pull/760)
Expand Down
2 changes: 1 addition & 1 deletion cmake/DARTFindDependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ endif()
# urdfdom
find_package(urdfdom QUIET)
if(urdfdom_FOUND)
message(STATUS "Looking for urdfdom - found")
message(STATUS "Looking for urdfdom - ${urdfdom_headers_VERSION} found")
else()
message(STATUS "Looking for urdfdom - NOT found, please install liburdfdom-dev")
endif()
Expand Down
12 changes: 12 additions & 0 deletions dart/config.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,18 @@
(DART_MAJOR_VERSION < x || (DART_MAJOR_VERSION <= x && \
(DART_MINOR_VERSION < y || (DART_MINOR_VERSION <= y))))

/* urdfdom_headers Version number */
// We define the version numbers of urdfdom_headers here since it doesn't expose
// the version numbers itself in source level.
#define URDFDOM_HEADERS_MAJOR_VERSION @urdfdom_headers_VERSION_MAJOR@
#define URDFDOM_HEADERS_MINOR_VERSION @urdfdom_headers_VERSION_MINOR@
#define URDFDOM_HEADERS_PATCH_VERSION @urdfdom_headers_VERSION_PATCH@

#define URDFDOM_HEADERS_VERSION_AT_LEAST(x,y,z) \
(URDFDOM_HEADERS_MAJOR_VERSION > x || (URDFDOM_HEADERS_MAJOR_VERSION >= x && \
(URDFDOM_HEADERS_MINOR_VERSION > y || (URDFDOM_HEADERS_MINOR_VERSION >= y && \
URDFDOM_HEADERS_PATCH_VERSION >= z))))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this third part also have URDFDOM_HEADERS_MAJOR_VERSION >= x?

Copy link
Member Author

@jslee02 jslee02 Aug 28, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand your question correctly, it actually has URDFDOM_HEADERS_MAJOR_VERSION >= x. If it is reached to the last part (i.e., URDFDOM_HEADERS_PATCH_VERSION >= z), that means it's the case of URDFDOM_HEADERS_MAJOR_VERSION >= x AND URDFDOM_HEADERS_MINOR_VERSION >= y.

The logic expressed in C++ would be like:

if (major > x)
{
  return true;
}
else if (major >= x)
{
  if (minor > y)
  {
    return true;
  }
  else if (minor >= y)
  {
    // the third part
    if (patch >= z)
      return true;
    else
      return false;
  }
  else
  {
    return false;
  }
}
else
{
  return false;
}

I borrowed this from Eigen, but yeah it's pretty confusing.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the explanation. I guess I don't remember the order of precedence between || and && operators


// Detect the compiler
#if defined(__clang__)
#define DART_COMPILER_CLANG
Expand Down
5 changes: 3 additions & 2 deletions dart/utils/urdf/DartLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,14 @@
#include "dart/dynamics/CylinderShape.hpp"
#include "dart/dynamics/MeshShape.hpp"
#include "dart/simulation/World.hpp"
#include "dart/utils/urdf/URDFTypes.hpp"
#include "dart/utils/urdf/urdf_world_parser.hpp"

using ModelInterfacePtr = boost::shared_ptr<urdf::ModelInterface>;

namespace dart {
namespace utils {

using ModelInterfacePtr = urdf_shared_ptr<urdf::ModelInterface>;

DartLoader::DartLoader()
: mLocalRetriever(new common::LocalResourceRetriever),
mPackageRetriever(new utils::PackageResourceRetriever(mLocalRetriever)),
Expand Down
58 changes: 58 additions & 0 deletions dart/utils/urdf/URDFTypes.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* Copyright (c) 2016, Graphics Lab, Georgia Tech Research Corporation
* Copyright (c) 2016, Humanoid Lab, Georgia Tech Research Corporation
* Copyright (c) 2016, Personal Robotics Lab, Carnegie Mellon University
* All rights reserved.
*
* This file is provided under the following "BSD-style" License:
* Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the following
* conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef DART_UTILS_URDF_URDFTYPES_HPP_
#define DART_UTILS_URDF_URDFTYPES_HPP_

#include "dart/config.hpp"

#if URDFDOM_HEADERS_VERSION_AT_LEAST(1,0,0)
#include <memory>
#else
#include "boost/shared_ptr.hpp"
#include "boost/weak_ptr.hpp"
#endif

namespace dart {
namespace utils {

#if URDFDOM_HEADERS_VERSION_AT_LEAST(1,0,0)
template <typename T> using urdf_shared_ptr = std::shared_ptr<T>;
template <typename T> using urdf_weak_ptr = std::weak_ptr<T>;
#else
template <typename T> using urdf_shared_ptr = boost::shared_ptr<T>;
template <typename T> using urdf_weak_ptr = boost::weak_ptr<T>;
#endif

} // namespace utils
} // namespace dart

#endif // DART_UTILS_URDF_URDFTYPES_HPP_
3 changes: 2 additions & 1 deletion dart/utils/urdf/urdf_world_parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@

#include "dart/common/Uri.hpp"
#include "dart/common/ResourceRetriever.hpp"
#include "dart/utils/urdf/URDFTypes.hpp"

namespace dart {
namespace utils {
Expand All @@ -62,7 +63,7 @@ class Entity
/// Copy over a standard urdfEntity
Entity(const urdf::Entity& urdfEntity);

boost::shared_ptr<urdf::ModelInterface> model;
urdf_shared_ptr<urdf::ModelInterface> model;
urdf::Pose origin;
urdf::Twist twist;

Expand Down