Imported Upstream version 1.1.0+ds1

parent a09584c2
......@@ -10,6 +10,7 @@ lib/
*.dylib
CMakeModules/ompl.pc
doc/markdown/api_overview.md
doc/markdown/CForest.md
doc/markdown/download.md
doc/markdown/mainpage.md
doc/header.html
......
sudo: false
cache:
apt: true
directories:
- /home/travis/build/ompl/ompl/build/pyplusplus
language: cpp
os:
- linux
- osx
env:
# - BUILD_TYPE=Debug
- BUILD_TYPE=Release
matrix:
allow_failures:
- os: osx
addons:
apt:
packages:
- libboost-all-dev
- python-dev
- libode-dev
- libeigen3-dev
install:
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then
brew update;
brew outdated boost || brew upgrade boost;
brew install ode eigen;
fi
script:
# Create build directory
- mkdir -p build
- cd build
# Configure
- cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DOMPL_LOCAL_PYPLUSPLUS_INSTALL=ON -DOMPL_REGISTRATION=OFF -DCMAKE_INSTALL_PREFIX=tmp ..
# Skip Python bindings on OS X, since brew doesn't have a compiler that can compile gccxml.
# On Linux, we need to make sure cmake finds the locally installed gccxml
# and not the one in /usr/bin
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then
if [ ! -x "pyplusplus/bin/gccxml" ]; then make installpyplusplus; fi;
rm CMakeCache.txt;
cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DOMPL_LOCAL_PYPLUSPLUS_INSTALL=ON -DOMPL_REGISTRATION=OFF -DCMAKE_INSTALL_PREFIX=tmp -DGCCXML=pyplusplus/bin/gccxml ..;
make -j2 update_bindings;
fi
# Build
- make -j4
# Run unit tests
# On OS X, exclude test_machine_specs; fails due to "lazy" memory freeing in Release mode (test passes in Debug builds).
# On OS X, exclude test_random; fails due to bug in Boost.Random in 1.56.
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then
ctest -E 'test_(machine_specs|random)';
else
ctest;
fi
......@@ -108,6 +108,13 @@ enable_testing()
find_package(Python QUIET)
find_package(Boost COMPONENTS python QUIET)
# Eigen is needed for the InformedStateSampler
find_package(Eigen3 QUIET)
if (EIGEN3_FOUND)
set(OMPL_HAVE_EIGEN3 1)
include_directories("${EIGEN3_INCLUDE_DIRS}")
endif()
# MORSE is only needed for Modular OpenRobots Simulation Engine bindings
find_package(MORSE QUIET)
set(OMPL_EXTENSION_MORSE ${MORSE_FOUND})
......@@ -133,6 +140,9 @@ if (FLANN_FOUND)
include_directories(SYSTEM "${FLANN_INCLUDE_DIRS}")
endif()
# R is needed for running Planner Arena locally
find_program(R_EXEC R)
option(OMPL_LOCAL_PYPLUSPLUS_INSTALL "Whether Py++ and dependencies should be installed in the build directory" OFF)
set(SUDO "sudo")
set(CMAKE_GCCXML_ARGS "")
......@@ -150,9 +160,10 @@ add_subdirectory(scripts)
add_subdirectory(doc)
if (NOT MSVC)
target_link_flags(ompl)
set(PKG_NAME "ompl")
set(PKG_DESC "The Open Motion Planning Library")
set(PKG_OMPL_LIBS "-lompl")
set(PKG_OMPL_LIBS "-lompl ${ompl_LINK_FLAGS}")
set(pkg_conf_file "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules/ompl.pc")
configure_file("${pkg_conf_file}.in" "${pkg_conf_file}" @ONLY)
install(FILES "${pkg_conf_file}"
......@@ -164,6 +175,10 @@ if (NOT MSVC)
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/ompl${OMPL_INSTALL_SUFFIX}"
COMPONENT ompl
RENAME ompl-config.cmake)
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/ompl.conf"
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/ompl${OMPL_INSTALL_SUFFIX}"
COMPONENT ompl)
endif()
# uninstall target
......
......@@ -32,8 +32,6 @@ set(CPACK_SOURCE_IGNORE_FILES
".orig$"
".log$"
".DS_Store"
".tm_properties"
"mkwebdocs.sh"
"/html/"
"/bindings/"
"TODO"
......@@ -47,9 +45,7 @@ set(CPACK_SOURCE_IGNORE_FILES
".registered$"
"download.md$"
"mainpage.md$"
"binding_generator.py$"
"gen_validatorv31.js"
"/php/")
"binding_generator.py$")
set(CPACK_SOURCE_GENERATOR "TGZ;ZIP")
set(CPACK_GENERATOR "TGZ")
......@@ -73,7 +69,7 @@ if(APPLE)
endif()
if(WIN32)
set(CPACK_GENERATOR "ZIP;${CPACK_GENERATOR}")
set(CPACK_GENERATOR "ZIP")
endif()
include(CPack)
......@@ -7,7 +7,7 @@ if(CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS_RELEASE "-O3 ${CMAKE_CXX_FLAGS_RELEASE}")
endif(CMAKE_COMPILER_IS_GNUCXX)
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
add_definitions(-W -Wall -Wextra -Wno-missing-field-initializers -Wno-unused -Wno-unused-parameter -Wno-delete-non-virtual-dtor -Wno-overloaded-virtual -Wno-unknown-pragmas -Qunused-arguments)
add_definitions(-W -Wall -Wextra -Wno-missing-field-initializers -Wno-unused -Wno-unused-parameter -Wno-delete-non-virtual-dtor -Wno-overloaded-virtual -Wno-unknown-pragmas -Qunused-arguments -Wno-c++11-extensions)
# prepend optimizion flag (in case the default setting doesn't include one)
set(CMAKE_CXX_FLAGS_RELEASE "-O3 ${CMAKE_CXX_FLAGS_RELEASE}")
endif()
......
include(FindPackageHandleStandardArgs)
find_package(PkgConfig)
if(PKG_CONFIG_FOUND)
pkg_check_modules(EIGEN3 eigen3)
endif()
find_package_handle_standard_args(Eigen3 DEFAULT_MSG EIGEN3_INCLUDE_DIRS)
# This code sets the following variables:
# PYTHON_EXEC - path to python executable
# PYTHON_LIBRARIES - path to the python library
# PYTHON_INCLUDE_DIRS - path to where Python.h is found
# PTYHON_SITE_MODULES - path to site-packages
# PYTHON_ARCH - name of architecture to be used for platform-specific
# binary modules
# PYTHON_VERSION - version of python
# PYTHON_FOUND - boolean that indicates success
# PYTHON_EXEC - path to python executable
# PYTHON_LIBRARIES - path to the python library
# PYTHON_INCLUDE_DIRS - path to where Python.h is found
# PYTHON_SITE_MODULES - path to site-packages
# PYTHON_ARCH - name of architecture to be used for platform-specific
# binary modules
# PYTHON_VERSION - version of python
# PYTHON_VERSION_MAJOR - major version number
# PYTHON_VERSION_MAJOR - minor version number
# PYTHON_VERSION_MICRO - micro version number
#
# You can optionally include the version number when using this package
# like so:
......@@ -13,10 +17,16 @@
#
# This code defines a helper function find_python_module(). It can be used
# like so:
# find_python_module(numpy)
# find_python_module(numpy [version] [REQUIRED|QUIET])
# If numpy is found, the variable PY_NUMPY contains the location of the numpy
# module. If the module is required add the keyword "REQUIRED":
# module. If a particular minimum version or higher is required, use the
# version argument:
# find_python_module(numpy 1.9.0)
# If the module is required add the keyword "REQUIRED":
# find_python_module(numpy REQUIRED)
# If no output should be displayed about whether the module is found, use the
# QUIET argument:
# find_python_module(numpy QUIET)
include(FindPackageHandleStandardArgs)
......@@ -28,6 +38,7 @@ endif (NOT PYTHON_EXEC)
if (NOT PYTHON_EXEC)
find_program(PYTHON_EXEC "python${Python_FIND_VERSION}"
PATHS
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\3.4\\InstallPath]
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\3.3\\InstallPath]
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\3.2\\InstallPath]
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\3.1\\InstallPath]
......@@ -62,10 +73,14 @@ string(REGEX REPLACE "/bin/python.*" "" PYTHON_PREFIX "${PYTHON_EXEC_}")
string(REGEX REPLACE "/bin/python.*" "" PYTHON_PREFIX2 "${PYTHON_EXEC}")
execute_process(COMMAND "${PYTHON_EXEC}" "-c"
"import sys; print('%d.%d' % (sys.version_info[0],sys.version_info[1]))"
OUTPUT_VARIABLE PYTHON_VERSION
"import sys; print('%d;%d;%d' % (sys.version_info[0],sys.version_info[1],sys.version_info[2]))"
OUTPUT_VARIABLE PYTHON_VERSION_INFO
OUTPUT_STRIP_TRAILING_WHITESPACE)
string(REPLACE "." "" PYTHON_VERSION_NO_DOTS ${PYTHON_VERSION})
list(GET PYTHON_VERSION_INFO 0 PYTHON_VERSION_MAJOR)
list(GET PYTHON_VERSION_INFO 1 PYTHON_VERSION_MINOR)
list(GET PYTHON_VERSION_INFO 2 PYTHON_VERSION_MICRO)
set(PYTHON_VERSION "${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}")
set(PYTHON_VERSION_NO_DOTS "${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}")
find_library(PYTHON_LIBRARIES
NAMES "python${PYTHON_VERSION_NO_DOTS}" "python${PYTHON_VERSION}" "python${PYTHON_VERSION}m"
......@@ -90,27 +105,55 @@ string(REGEX REPLACE "^${PYTHON_PREFIX2}/" "" PYTHON_SITE_MODULES "${PYTHON_SITE
function(find_python_module module)
string(TOUPPER ${module} module_upper)
if(ARGC GREATER 1)
set(_minversion "")
if(ARGC GREATER 2)
set(_minversion ${ARGV1})
if (ARGV2 STREQUAL "REQUIRED")
set(PY_${module}_FIND_REQUIRED TRUE)
elseif (ARGV2 STREQUAL "QUIET")
set(PY_${module}_FIND_QUIETLY TRUE)
endif()
elseif (ARGC GREATER 1)
if (ARGV1 STREQUAL "REQUIRED")
set(PY_${module}_FIND_REQUIRED TRUE)
elseif (ARGV1 STREQUAL "QUIET")
set(PY_${module}_FIND_QUIETLY TRUE)
else()
if (ARGV1 STREQUAL "QUIET")
set(PY_${module}_FIND_QUIETLY TRUE)
endif()
set(_minversion ${ARGV1})
endif()
endif()
if(NOT PY_${module_upper})
# A module's location is usually a directory, but for binary modules
# it's a .so file.
execute_process(COMMAND "${PYTHON_EXEC}" "-c"
"import re, ${module}; print(re.compile('/__init__.py.*').sub('',${module}.__file__))"
RESULT_VARIABLE _${module}_status
OUTPUT_VARIABLE _${module}_location
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
if(NOT _${module}_status)
set(PY_${module_upper} ${_${module}_location} CACHE STRING
"Location of Python module ${module}")
endif(NOT _${module}_status)
if (_minversion STREQUAL "")
execute_process(COMMAND "${PYTHON_EXEC}" "-c"
"import re, ${module}; print(re.compile('/__init__.py.*').sub('',${module}.__file__))"
RESULT_VARIABLE _status OUTPUT_VARIABLE _location
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
if(NOT _status)
set(PY_${module_upper} ${_location} CACHE STRING
"Location of Python module ${module}")
endif(NOT _status)
else (_minversion STREQUAL "")
execute_process(COMMAND "${PYTHON_EXEC}" "-c"
"import re, ${module}; print(re.compile('/__init__.py.*').sub('',${module}.__version__+';'+${module}.__file__))"
RESULT_VARIABLE _status
OUTPUT_VARIABLE _verloc
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
list(GET _verloc 1 _location)
list(GET _verloc 0 _version)
message("${_status} ${_verloc} ${_version}")
if(NOT _status)
if (NOT ${_version} VERSION_LESS ${_minversion})
set(PY_${module_upper} ${_location} CACHE STRING
"Location of Python module ${module}")
set(PY_${module_upper}_VERSION ${_version} CACHE STRING
"Version of Python module ${module}")
else()
message(SEND_ERROR "Module '${module}' version ${_version} found, but minimum version ${_minversion} required.")
endif()
endif(NOT _status)
endif (_minversion STREQUAL "")
endif(NOT PY_${module_upper})
find_package_handle_standard_args(PY_${module} DEFAULT_MSG PY_${module_upper})
endfunction(find_python_module)
......
......@@ -8,7 +8,7 @@ macro(add_ompl_test test_name)
${Boost_FILESYSTEM_LIBRARY}
${Boost_SYSTEM_LIBRARY}
${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
add_test(${test_name} ${EXECUTABLE_OUTPUT_PATH}/${test_name})
add_test(NAME ${test_name} COMMAND $<TARGET_FILE:${test_name}>)
endmacro(add_ompl_test)
macro(add_ompl_python_test test_file)
......@@ -16,6 +16,27 @@ macro(add_ompl_python_test test_file)
add_test(${test_name} "${PYTHON_EXEC}" "${CMAKE_CURRENT_SOURCE_DIR}/${test_file}" "-v")
endmacro(add_ompl_python_test)
function(target_link_flags)
set(_link_flags "")
foreach(_target ${ARGV})
get_target_property(_link_libs ${_target} LINK_LIBRARIES)
foreach(_lib ${_link_libs})
get_filename_component(_basename ${_lib} NAME_WE)
get_filename_component(_ext ${_lib} EXT)
if(_ext STREQUAL ${CMAKE_SHARED_LIBRARY_SUFFIX})
string(REPLACE ${CMAKE_SHARED_LIBRARY_PREFIX} "" _libname ${_basename})
list(APPEND _link_flags "-l${_libname}")
endif()
endforeach()
endforeach()
list(REMOVE_DUPLICATES _link_flags)
foreach(_flag ${_link_flags})
set(_link_flags_str "${_link_flags_str} ${_flag}")
endforeach()
string(STRIP "${_link_flags_str}" _link_flags_str)
set(${ARGV0}_LINK_FLAGS "${_link_flags_str}" PARENT_SCOPE)
endfunction()
option(OMPL_VERSIONED_INSTALL "Append version suffix to binaries, libraries, and include dir." OFF)
if (OMPL_VERSIONED_INSTALL)
set(OMPL_INSTALL_SUFFIX "-${OMPL_MAJOR_VERSION}.${OMPL_MINOR_VERSION}")
......
# set the version in a way CMake can use
set(OMPL_MAJOR_VERSION 1)
set(OMPL_MINOR_VERSION 0)
set(OMPL_MINOR_VERSION 1)
set(OMPL_PATCH_VERSION 0)
set(OMPL_VERSION "${OMPL_MAJOR_VERSION}.${OMPL_MINOR_VERSION}.${OMPL_PATCH_VERSION}")
# increment this when we have ABI changes
set(OMPL_ABI_VERSION 10)
set(OMPL_ABI_VERSION 11)
......@@ -20,6 +20,12 @@ if(APPLE)
set(PYOMPL_EXTRA_CFLAGS "-m64")
endif(APPLE)
# Trick gccxml to ignore some compiler intrinsics that are used in Boost.Atomic
# in Boost 1.55.
if(CMAKE_COMPILER_IS_GNUCXX AND Boost_VERSION VERSION_GREATER "105400")
set(PYOMPL_EXTRA_CFLAGS "${PYOMPL_EXTRA_CFLAGS} -DBOOST_INTEL_CXX_VERSION")
endif()
if(PYTHON_FOUND AND Boost_PYTHON_LIBRARY)
include_directories(${PYTHON_INCLUDE_DIRS})
# make sure target is defined only once
......@@ -59,7 +65,7 @@ function(create_module_header_file_target module dir)
endforeach(header)
# target for all-in-one header for module
add_custom_target(${module}.h
COMMAND ${CMAKE_COMMAND} -D module=${module}
COMMAND ${CMAKE_COMMAND} -D module=${module} -D exclude=${ARGV2}
-P "${OMPL_CMAKE_UTIL_DIR}/generate_header.cmake"
DEPENDS ${headers} WORKING_DIRECTORY "${dir}"
COMMENT "Preparing C++ header file for Python binding generation for module ${module}")
......@@ -85,7 +91,7 @@ function(create_module_code_generation_target module dir)
endfunction(create_module_code_generation_target)
function(create_module_generation_targets module dir)
create_module_header_file_target("${module}" "${dir}")
create_module_header_file_target("${module}" "${dir}" "${ARGV2}")
create_module_code_generation_target("${module}" "${dir}")
endfunction(create_module_generation_targets)
......
......@@ -3,6 +3,8 @@ separate_arguments(headers UNIX_COMMAND "${headers_string}")
set(module_header "bindings/${module}.h")
file(WRITE "${module_header}" "")
foreach(header ${headers})
file(READ "${header}" _header_txt)
file(APPEND "${module_header}" "${_header_txt}")
if(NOT exclude OR NOT header MATCHES "${exclude}")
file(READ "${header}" _header_txt)
file(APPEND "${module_header}" "${_header_txt}")
endif()
endforeach(header)
The Open Motion Planning Library (OMPL)
=======================================
Linux / OS X [![Build Status](https://travis-ci.org/ompl/ompl.svg?branch=master)](https://travis-ci.org/ompl/ompl)
Windows [![Build status](https://ci.appveyor.com/api/projects/status/valuv9sabye1y35n/branch/master?svg=true)](https://ci.appveyor.com/project/mamoll/ompl/branch/master)
Visit the [OMPL installation page](http://ompl.kavrakilab.org/core/installation.html) for
detailed installation instructions.
OMPL has the following required dependencies:
* [Boost](http://www.boost.org) (version 1.44 or higher)
* [CMake](http://www.cmake.org) (version 2.8.2 or higher)
* [Boost](http://www.boost.org) (version 1.48 or higher)
* [CMake](http://www.cmake.org) (version 2.8.7 or higher)
The following dependencies are optional:
......@@ -15,6 +18,7 @@ The following dependencies are optional:
* [Py++](https://bitbucket.org/ompl/pyplusplus) (needed to generate Python bindings)
* [Doxygen](http://www.doxygen.org) (needed to create a local copy of the documentation at
http://ompl.kavrakilab.org/core)
* [Eigen](http://eigen.tuxfamily.org) (needed for an informed sampling technique to improve the optimization of path length)
Once dependencies are installed, you can build OMPL on Linux, OS X,
and MS Windows. Go to the top-level directory of OMPL and type the
......
# AppVeyor file
# http://www.appveyor.com/docs/appveyor-yml
version: "{build}"
os: unstable
clone_folder: C:\projects\ompl
clone_depth: 1
branches:
only:
- master
platform: x64
environment:
CTEST_OUTPUT_ON_FAILURE: 1
BOOST_ROOT: C:\Libraries\boost
BOOST_LIBRARYDIR: C:\Libraries\boost\lib64-msvc-12.0
configuration: Release
before_build:
- cmd: set
- cmd: mkdir build
- cmd: cd build
- cmd: cmake -G "Visual Studio 12 Win64" -DCMAKE_BUILD_TYPE=%configuration% -DOMPL_REGISTRATION=OFF -DOMPL_BUILD_DEMOS=OFF -DBOOST_ROOT="%BOOST_ROOT%" -DBOOST_LIBRARYDIR="%BOOST_LIBRARYDIR%" ..
build:
project: C:\projects\ompl\build\ompl.sln
parallel: true
# after_build:
# - cmd: cmake --build . --target package --config %configuration%
# no time to run tests
# test_script:
# - cmd: cd build
# - cmd: ctest -C %configuration%
# artifacts:
# - path: ompl\*.zip
......@@ -27,6 +27,7 @@ if (OMPL_BUILD_DEMOS)
aux_source_directory(Koules Koules_SRC)
add_ompl_demo(demo_Koules ${Koules_SRC})
add_ompl_demo(demo_PlannerData PlannerData.cpp)
add_ompl_demo(demo_ThunderLightning ThunderLightning.cpp)
add_ompl_demo(demo_OptimalPlanning OptimalPlanning.cpp)
add_ompl_demo(demo_PlannerProgressProperties PlannerProgressProperties.cpp)
......
......@@ -106,6 +106,7 @@ int main(int argc, char **argv)
int run_count = 20;
ompl::tools::Benchmark::Request request(runtime_limit, memory_limit, run_count);
ompl::tools::Benchmark b(ss, "HyperCube");
b.addExperimentParameter("num_dims", "INTEGER", boost::lexical_cast<std::string>(ndim));
addPlanner(b, ompl::base::PlannerPtr(new ompl::geometric::STRIDE(ss.getSpaceInformation())), range);
addPlanner(b, ompl::base::PlannerPtr(new ompl::geometric::EST(ss.getSpaceInformation())), range);
......
......@@ -307,7 +307,8 @@ int main(int argc, char **argv)
double runtime_limit = 60, memory_limit = 1024;
int run_count = 20;
ompl::tools::Benchmark::Request request(runtime_limit, memory_limit, run_count, 0.5);
ompl::tools::Benchmark b(ss, boost::str(boost::format("KinematicChain%i") % numLinks));
ompl::tools::Benchmark b(ss, "KinematicChain");
b.addExperimentParameter("num_links", "INTEGER", boost::lexical_cast<std::string>(numLinks));
b.addPlanner(ompl::base::PlannerPtr(new ompl::geometric::STRIDE(ss.getSpaceInformation())));
b.addPlanner(ompl::base::PlannerPtr(new ompl::geometric::EST(ss.getSpaceInformation())));
......
......@@ -130,7 +130,9 @@ void benchmark(KoulesSetup& ks, ot::Benchmark::Request request,
const std::string& plannerName, const std::string& outputFile)
{
// Create a benchmark class
ompl::tools::Benchmark b(ks, "Koules experiment");
ompl::tools::Benchmark b(ks, "Koules");
b.addExperimentParameter("num_koules", "INTEGER", boost::lexical_cast<std::string>(
(ks.getStateSpace()->getDimension() - 5) / 4));
// Add the planner to evaluate
b.addPlanner(ks.getConfiguredPlannerInstance(plannerName));
// Start benchmark
......
This diff is collapsed.
......@@ -51,6 +51,7 @@ except:
from ompl import geometric as og
from math import sqrt
from sys import argv
import argparse
## @cond IGNORE
# Our "collision checker". For this demo, our robot's state space
......@@ -162,7 +163,39 @@ def getPathLengthObjWithCostToGo(si):
obj.setCostToGoHeuristic(ob.CostToGoHeuristic(ob.goalRegionCostToGo))
return obj
def plan(fname = None):
# Keep these in alphabetical order and all lower case
def allocatePlanner(si, plannerType):
if plannerType.lower() == "bitstar":
return og.BITstar(si)
elif plannerType.lower() == "fmtstar":
return og.FMT(si)
elif plannerType.lower() == "informedrrtstar":
return og.InformedRRTstar(si)
elif plannerType.lower() == "prmstar":
return og.PRMstar(si)
elif plannerType.lower() == "rrtstar":
return og.RRTstar(si)
else:
OMPL_ERROR("Planner-type is not implemented in allocation function.");
# Keep these in alphabetical order and all lower case
def allocateObjective(si, objectiveType):
if objectiveType.lower() == "pathclearance":
return getClearanceObjective(si)
elif objectiveType.lower() == "pathlength":
return getPathLengthObjective(si)
elif objectiveType.lower() == "thresholdpathlength":
return getThresholdPathLengthObj(si)
elif objectiveType.lower() == "weightedlengthandclearancecombo":
return getBalancedObjective1(si)
else:
OMPL_ERROR("Optimization-objective is not implemented in allocation function.");
def plan(runTime, plannerType, objectiveType, fname):
# Construct the robot state space in which we're planning. We're
# planning in [0,1]x[0,1], a subset of R^2.
space = ob.RealVectorStateSpace(2)
......@@ -197,31 +230,24 @@ def plan(fname = None):
# Set the start and goal states
pdef.setStartAndGoalStates(start, goal)
# Since we want to find an optimal plan, we need to define what
# is optimal with an OptimizationObjective structure. Un-comment
# exactly one of the following 6 lines to see some examples of
# optimization objectives.
pdef.setOptimizationObjective(getPathLengthObjective(si))
# pdef.setOptimizationObjective(getThresholdPathLengthObj(si))
# pdef.setOptimizationObjective(getClearanceObjective(si))
# pdef.setOptimizationObjective(getBalancedObjective1(si))
# pdef.setOptimizationObjective(getBalancedObjective2(si))
# pdef.setOptimizationObjective(getPathLengthObjWithCostToGo(si))
# Create the optimization objective specified by our command-line argument.
# This helper function is simply a switch statement.
pdef.setOptimizationObjective(allocateObjective(si, objectiveType))
# Construct our optimal planner using the RRTstar algorithm.
optimizingPlanner = og.RRTstar(si)
# Construct the optimal planner specified by our command line argument.
# This helper function is simply a switch statement.
optimizingPlanner = allocatePlanner(si, plannerType)
# Set the problem instance for our planner to solve
optimizingPlanner.setProblemDefinition(pdef)
optimizingPlanner.setup()
# attempt to solve the planning problem within one second of
# planning time
solved = optimizingPlanner.solve(10.0)
# attempt to solve the planning problem in the given runtime
solved = optimizingPlanner.solve(runTime)
if solved:
# Output the length of the path found
print("Found solution of path length %g" % pdef.getSolutionPath().length())
print("{0} found solution of path length {1:.4f} with an optimization objective value of {2:.4f}".format(optimizingPlanner.getName(), pdef.getSolutionPath().length(), pdef.getSolutionPath().cost(pdef.getOptimizationObjective()).value()))
# If a filename was specified, output the path as a matrix to
# that file for visualization
......@@ -232,7 +258,34 @@ def plan(fname = None):
print("No solution found.")
if __name__ == "__main__":
fname = None if len(argv)<2 else argv[1]
plan(fname)
# Create an argument parser
parser = argparse.ArgumentParser(description='Optimal motion planning demo program.')
# Add a filename argument
parser.add_argument('-t', '--runtime', type=float, default=1.0, help='(Optional) Specify the runtime in seconds. Defaults to 1 and must be greater than 0.')
parser.add_argument('-p', '--planner', default='RRTstar', choices=['BITstar', 'FMTstar', 'InformedRRTstar', 'PRMstar', 'RRTstar'], help='(Optional) Specify the optimal planner to use, defaults to RRTstar if not given.') # Alphabetical order
parser.add_argument('-o', '--objective', default='PathLength', choices=['PathClearance', 'PathLength', 'ThresholdPathLength', 'WeightedLengthAndClearanceCombo'], help='(Optional) Specify the optimization objective, defaults to PathLength if not given.') # Alphabetical order
parser.add_argument('-f', '--file', default=None, help='(Optional) Specify an output path for the found solution path.')
parser.add_argument('-i', '--info', type=int, default=0, choices=[0, 1, 2], help='(Optional) Set the OMPL log level. 0 for WARN, 1 for INFO, 2 for DEBUG. Defaults to WARN.')
# Parse the arguments
args = parser.parse_args()
# Check that time is positive
if args.runtime <= 0:
raise argparse.ArgumentTypeError("argument -t/--runtime: invalid choice: %r (choose a positive number greater than 0)"%(args.runtime,))
# Set the log level
if args.info == 0:
ou.setLogLevel(ou.LOG_WARN)
elif args.info == 1:
ou.setLogLevel(ou.LOG_INFO)
elif args.info == 2:
ou.setLogLevel(ou.LOG_DEBUG)
else:
OMPL_ERROR("Invalid log-level integer.");
# Solve the planning problem
plan(args.runtime, args.planner, args.objective, args.file)
## @endcond
/*********************************************************************
* Software License Agreement (BSD License)
*
* Copyright (c) 2015, Rice University
* All rights reserved.
*
* 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