Skip to content

Commit

Permalink
Merge branch 'master' into werror
Browse files Browse the repository at this point in the history
  • Loading branch information
jslee02 committed Mar 24, 2017
2 parents 3327066 + 963a5d7 commit e4b49a4
Show file tree
Hide file tree
Showing 19 changed files with 456 additions and 35 deletions.
86 changes: 86 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
---
BasedOnStyle: Google
AccessModifierOffset: -2
AlignAfterOpenBracket: Align
AlignEscapedNewlinesLeft: true
AlignOperands: true
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: false
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: true
BinPackArguments: false
BinPackParameters: false
BraceWrapping:
AfterClass: true
AfterControlStatement: true
AfterEnum: true
AfterFunction: true
AfterNamespace: false
AfterObjCDeclaration: true
AfterStruct: true
AfterUnion: true
BeforeCatch: true
BeforeElse: true
IndentBraces: false
BreakBeforeBinaryOperators: NonAssignment
BreakBeforeBraces: Custom
BreakBeforeTernaryOperators: false
BreakConstructorInitializersBeforeComma: true
ColumnLimit: 80
CommentPragmas: ''
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 2
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
# sort headers by main include file (implicit priority 0),
# then project and private includes, then system headers
IncludeCategories:
- Regex: '.*'
Priority: 1
- Regex: '^(<|"(gtest|isl|json)/)'
Priority: 2
- Regex: '^<([a-z]+)>'
Priority: 3
IndentCaseLabels: true
IndentFunctionDeclarationAfterType: false
IndentWidth: 2
IndentWrappedFunctionNames: false
KeepEmptyLinesAtTheStartOfBlocks: true
MacroBlockBegin: ''
MacroBlockEnd: ''
Language: Cpp
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
PenaltyBreakBeforeFirstCallParameter: 1
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 200
PointerAlignment: Left
SpaceAfterCStyleCast: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 2
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Auto
TabWidth: 2
UseTab: Never
...
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
## Aikido 0 (prerelease)

### 0.0.2 (2017-XX-XX)

* Fixed build issues on macOS: [#138](https://github.com/personalrobotics/aikido/pull/138)

### 0.0.1 (2017-03-10)

* Initial release

68 changes: 66 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,14 @@ project(aikido)
# If you change the version, please update the <version> tag in package.xml.
set(AIKIDO_MAJOR_VERSION "0")
set(AIKIDO_MINOR_VERSION "0")
set(AIKIDO_PATCH_VERSION "1")
set(AIKIDO_PATCH_VERSION "2")
set(AIKIDO_VERSION "${AIKIDO_MAJOR_VERSION}.${AIKIDO_MINOR_VERSION}.${AIKIDO_PATCH_VERSION}")

list(INSERT CMAKE_MODULE_PATH 0 "${PROJECT_SOURCE_DIR}/cmake")

#==============================================================================
# Configuration Options
#

set(INCLUDE_INSTALL_DIR "include")
set(LIBRARY_INSTALL_DIR "lib")
set(CONFIG_INSTALL_DIR "${LIBRARY_INSTALL_DIR}/${PROJECT_NAME}/cmake")
Expand Down Expand Up @@ -60,6 +59,29 @@ if(COVERALLS)
coveralls_turn_on_coverage()
endif()

#==============================================================================
# Automatic code formatting setup
#
define_property(GLOBAL PROPERTY CODE_FORMATTING_SOURCES
BRIEF_DOCS "Source files that are automatically formatted by clang-format."
FULL_DOCS "Source files that are automatically formatted by clang-format."
)

function(format_add_sources)
foreach(source ${ARGN})
get_filename_component(source_abs
"${CMAKE_CURRENT_LIST_DIR}/${source}" ABSOLUTE)
if(EXISTS "${source_abs}")
set_property(GLOBAL APPEND PROPERTY CODE_FORMATTING_SOURCES "${source_abs}")
else()
message(FATAL_ERROR
"Source file '${source}' does not exist at absolute path"
" '${source_abs}'. This should never happen. Did you recently delete"
" this file or modify 'CMAKE_CURRENT_LIST_DIR'")
endif()
endforeach()
endfunction()

#==============================================================================
# Helper functions.
#
Expand Down Expand Up @@ -249,6 +271,48 @@ if(COVERALLS)
"${PROJECT_SOURCE_DIR}/cmake")
endif()

#===============================================================================
# Automatic code formatting using clang-format.
#
find_program(
CLANG_FORMAT_EXECUTABLE
NAMES clang-format clang-format-3.9 clang-format-3.8
)

if (CLANG_FORMAT_EXECUTABLE)
get_property(formatting_files GLOBAL PROPERTY CODE_FORMATTING_SOURCES)
list(LENGTH formatting_files formatting_files_length)

if (formatting_files)
add_custom_target(format
COMMAND ${CMAKE_COMMAND} -E echo "Formatting code style of"
"${formatting_files_length} files... "
COMMAND ${CLANG_FORMAT_EXECUTABLE} -style=file -i ${formatting_files}
COMMAND ${CMAKE_COMMAND} -E echo "Done."
DEPENDS ${CLANG_FORMAT_EXECUTABLE}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
add_custom_target(check-format
COMMAND ${CMAKE_COMMAND} -E echo "Checking code style of
${formatting_files_length} files... "
COMMAND ${CMAKE_SOURCE_DIR}/tools/check_code_format.sh
${CLANG_FORMAT_EXECUTABLE} ${formatting_files}
COMMAND ${CMAKE_COMMAND} -E echo "Done."
DEPENDS ${CLANG_FORMAT_EXECUTABLE}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
else()
add_custom_target(format
COMMAND ${CMAKE_COMMAND} -E echo "No file to format code style."
)
add_custom_target(check-format
COMMAND ${CMAKE_COMMAND} -E echo "No file to check code style."
)
endif()
else()
message(STATUS "Looking for clang-format - NOT found, please install clang-format to enable automatic code formatting")
endif()

#==============================================================================
# Installation.
#
Expand Down
2 changes: 2 additions & 0 deletions include/aikido/constraint/NonColliding.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ class NonColliding : public Testable
std::vector<std::shared_ptr<CollisionGroup>> groupsToSelfCheck;
};

using NonCollidingPtr = std::shared_ptr<NonColliding>;

} // constraint
} // aikido
#endif // AIKIDO_CONSTRAINT_NONCOLLIDING_HPP_
3 changes: 3 additions & 0 deletions include/aikido/constraint/TestableIntersection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ class TestableIntersection : public Testable

void testConstraintStateSpaceOrThrow(const TestablePtr& constraint);
};

using TestableIntersectionPtr = std::shared_ptr<TestableIntersection>;

} // constraint
} // aikido

Expand Down
115 changes: 115 additions & 0 deletions include/aikido/planner/ompl/BackwardCompatibility.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
// This header is for supporting OMPL across the multiple versions that include
// API breaking changes. Currently, the most part is to support changes from the
// usage of Boost to C++11 STL equivalents.

#ifndef AIKIDO_PLANNER_OMPL_BACKWARDCOMPATIBILITY_HPP_
#define AIKIDO_PLANNER_OMPL_BACKWARDCOMPATIBILITY_HPP_

#include <ompl/config.h>

#define OMPL_VERSION_AT_LEAST(x,y,z) \
(OMPL_MAJOR_VERSION > x || (OMPL_MAJOR_VERSION >= x && \
(OMPL_MINOR_VERSION > y || (OMPL_MINOR_VERSION >= y && \
OMPL_PATCH_VERSION >= z))))

#define OMPL_MAJOR_MINOR_VERSION_AT_LEAST(x,y) \
(OMPL_MAJOR_VERSION > x || (OMPL_MAJOR_VERSION >= x && \
(OMPL_MINOR_VERSION > y || (OMPL_MINOR_VERSION >= y))))

#define OMPL_VERSION_AT_MOST(x,y,z) \
(OMPL_MAJOR_VERSION < x || (OMPL_MAJOR_VERSION <= x && \
(OMPL_MINOR_VERSION < y || (OMPL_MINOR_VERSION <= y && \
OMPL_PATCH_VERSION <= z))))

#define OMPL_MAJOR_MINOR_VERSION_AT_MOST(x,y) \
(OMPL_MAJOR_VERSION < x || (OMPL_MAJOR_VERSION <= x && \
(OMPL_MINOR_VERSION < y || (OMPL_MINOR_VERSION <= y))))

#if OMPL_VERSION_AT_LEAST(1,2,0)
#include <memory>
#else
#include <boost/smart_ptr.hpp>
#include <boost/bind.hpp>
#endif

namespace aikido {
namespace planner {
namespace ompl {

#if OMPL_VERSION_AT_LEAST(1,2,0)

#define OMPL_PLACEHOLDER(ph) std::placeholders::ph

template <class T>
using ompl_shared_ptr = std::shared_ptr<T>;

template <class T>
using ompl_weak_ptr = std::weak_ptr<T>;

template <class T, class... Args>
ompl_shared_ptr<T> ompl_make_shared(Args&&... args)
{
return std::make_shared<T>(std::forward<Args>(args)...);
}

template <class T, class U>
ompl_shared_ptr<T> ompl_dynamic_pointer_cast(const ompl_shared_ptr<U>& r)
{
return std::dynamic_pointer_cast<T>(r);
}

template <class T, class U>
ompl_shared_ptr<T> ompl_static_pointer_cast(const ompl_shared_ptr<U>& r)
{
return std::static_pointer_cast<T>(r);
}

template <class F, class... Args>
auto ompl_bind(F&& f, Args&&... args)
-> decltype(std::bind(std::forward<F>(f), std::forward<Args>(args)...))
{
return std::bind(std::forward<F>(f), std::forward<Args>(args)...);
}

#else // OMPL_VERSION_AT_LEAST(1,2,0)

#define OMPL_PLACEHOLDER(ph) ph

template <class T>
using ompl_shared_ptr = boost::shared_ptr<T>;

template <class T>
using ompl_weak_ptr = boost::weak_ptr<T>;

template <class T, class... Args>
ompl_shared_ptr<T> ompl_make_shared(Args&&... args)
{
return boost::make_shared<T>(std::forward<Args>(args)...);
}

template <class T, class U>
ompl_shared_ptr<T> ompl_dynamic_pointer_cast(const ompl_shared_ptr<U>& r)
{
return boost::dynamic_pointer_cast<T>(r);
}

template <class T, class U>
ompl_shared_ptr<T> ompl_static_pointer_cast(const ompl_shared_ptr<U>& r)
{
return boost::static_pointer_cast<T>(r);
}

template <class F, class... Args>
auto ompl_bind(F&& f, Args&&... args)
-> decltype(boost::bind(std::forward<F>(f), std::forward<Args>(args)...))
{
return boost::bind(std::forward<F>(f), std::forward<Args>(args)...);
}

#endif // OMPL_VERSION_AT_LEAST(1,2,0)

} // namespace ompl
} // namespace planner
} // namespace aikido

#endif // AIKIDO_PLANNER_OMPL_BACKWARDCOMPATIBILITY_HPP_
3 changes: 2 additions & 1 deletion include/aikido/planner/ompl/CRRT.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <ompl/geometric/planners/PlannerIncludes.h>
#include <ompl/datastructures/NearestNeighbors.h>

#include "../../planner/ompl/BackwardCompatibility.hpp"
#include "../../constraint/Projectable.hpp"

namespace aikido {
Expand Down Expand Up @@ -147,7 +148,7 @@ class CRRT : public ::ompl::base::Planner


/// A nearest-neighbor datastructure representing a tree of motions */
using TreeData = boost::shared_ptr<::ompl::NearestNeighbors<Motion *>>;
using TreeData = ompl_shared_ptr<::ompl::NearestNeighbors<Motion *>>;

/// A nearest-neighbors datastructure containing the tree of motions
TreeData mStartTree;
Expand Down
4 changes: 2 additions & 2 deletions include/aikido/planner/ompl/Planner.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
#include "../../constraint/Sampleable.hpp"
#include "../../constraint/Projectable.hpp"
#include "../../trajectory/Interpolated.hpp"
#include "../../planner/ompl/BackwardCompatibility.hpp"

#include <ompl/base/Planner.h>
#include <ompl/base/ProblemDefinition.h>
#include <ompl/base/SpaceInformation.h>
#include <ompl/base/goals/GoalRegion.h>
#include <boost/make_shared.hpp>

namespace aikido {
namespace planner {
Expand Down Expand Up @@ -221,7 +221,7 @@ ::ompl::base::SpaceInformationPtr getSpaceInformation(
/// \param _si Information about the planning space
/// \param _goalTestable A Testable constraint that can determine if a given state is a goal state
/// \param _goalSampler A Sampleable capable of sampling states that satisfy _goalTestable
boost::shared_ptr<::ompl::base::GoalRegion>
ompl_shared_ptr<::ompl::base::GoalRegion>
getGoalRegion(::ompl::base::SpaceInformationPtr _si,
constraint::TestablePtr _goalTestable,
constraint::SampleablePtr _goalSampler);
Expand Down

0 comments on commit e4b49a4

Please sign in to comment.