### Install C++ Examples and Source Files (CMake) Source: https://github.com/rdiankov/openrave/blob/master/src/CMakeLists.txt Installs C++ example source files, headers, and related resource files (XML, TXT) from the 'cppexamples' directory to the OpenRAVE share directory. It specifically includes files matching patterns like '*.cpp', '*.xml', '*.h', and '*.txt', while excluding '.svn' directories. ```cmake install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/cppexamples DESTINATION ${OPENRAVE_SHARE_DIR} COMPONENT ${COMPONENT_PREFIX}devFILES_MATCHING PATTERN "*.cpp" PATTERN "*.xml" PATTERN "*.h" PATTERN "*.txt" PATTERN ".svn" EXCLUDE) ``` -------------------------------- ### Run OpenRAVE Example Source: https://github.com/rdiankov/openrave/blob/master/docs/source/tutorials/openravepy_beginning.rst Executes a specific OpenRAVE example script, such as the 'hanoi' planning example. This command launches the OpenRAVE simulator and demonstrates robot arm manipulation. ```bash openrave.py --example hanoi ``` -------------------------------- ### CMake Build Configuration for C Examples with OpenRAVE Source: https://github.com/rdiankov/openrave/blob/master/src/cexamples/CMakeLists.txt This snippet configures CMake for building C examples. It finds the OpenRAVE package, sets compiler flags and include paths, and defines a macro for building OpenRAVE C executables. It requires CMake version 2.6.0 or higher and the OpenRAVE library to be installed. ```cmake cmake_minimum_required (VERSION 2.6.0) project (cexamples) set(CMAKE_PREFIX_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../..) # only used for cexamples! find_package(OpenRAVE REQUIRED) if( CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX ) add_definitions("-fno-strict-aliasing -Wall") endif( CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX ) include_directories(${OpenRAVE_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR} ) link_directories(${OpenRAVE_LIBRARY_DIRS}) message(STATUS "lib ${OpenRAVE_CORE_C_LIBRARIES}") macro(build_openrave_executable name) add_executable(${name} ${name}.c) set_target_properties(${name} PROPERTIES COMPILE_FLAGS "${OpenRAVE_CXX_FLAGS} -DOPENRAVE_C_DLL -DOPENRAVE_C_CORE_DLL") set_target_properties(${name} PROPERTIES LINK_FLAGS "${OpenRAVE_LINK_FLAGS}") target_link_libraries(${name} ${OpenRAVE_CORE_C_LIBRARIES} -lm) install(TARGETS ${name} DESTINATION . ) endmacro(build_openrave_executable) build_openrave_executable(orc_bodyfunctions) build_openrave_executable(orc_customgeometry) build_openrave_executable(orc_rrtplanning) ``` -------------------------------- ### Use BiRRT Planner in OpenRAVEpy Source: https://github.com/rdiankov/openrave/blob/master/docs/source/tutorials/openravepy_examples.rst Shows how to use the BiRRT motion planning algorithm within OpenRAVE. This typically involves specifying start and goal configurations for a robot to find a collision-free path. ```python import openravepy import numpy as np openravepy.RaveInitialize() env = openravepy.Environment() env.Load("data/pr2.env") # Get the robot robot = env.GetRobots()[0] # Create a motion planning problem with env: # Use a 'with' statement for environment context # Set a random goal configuration goal_config = robot.GetDOFValues(robot.GetActiveDOFIndices()) goal_config[0] += np.pi # Example: change a joint value robot.SetDOFValues(goal_config, 1) # Create a planner planner = openravepy.RaveCreatePlanner(env, 'birrt') # Initialize the planner with the environment and start/goal start_config = robot.GetDOFValues(robot.GetActiveDOFIndices()) planner.InitPlan(robot, start_config, goal_config) # Execute the planning traj = planner.PlanPath() if traj: print("Path planned successfully.") # You can now use the trajectory, e.g., execute it # robot.ExecuteTrajectory(traj) else: print("Path planning failed.") ``` -------------------------------- ### OpenRAVE Configuration Utility Usage Source: https://github.com/rdiankov/openrave/blob/master/docs/mainpage.dox This demonstrates the usage of the `openrave-config` utility. It lists the available command-line options for the utility, including options for specifying installation prefixes, displaying the version, and getting compiler flags and library paths. These options allow developers to integrate OpenRAVE into their projects. ```Bash openrave-config [--prefix[=DIR]] [--exec-prefix[=DIR]] [--version] [--cflags] [--libs] [--libs-core] [--libs-only-l] [--libs-only-L] [--cflags-only-I] [--shared-libs] [--python-dir] [--octave-dir] [--matlab-dir] [--usage | --help] ``` -------------------------------- ### Configure PQPRAVE OpenRAVE Plugin Build Source: https://github.com/rdiankov/openrave/blob/master/plugins/pqprave/CMakeLists.txt This snippet configures the build for the pqprave OpenRAVE plugin using CMake. It adds a subdirectory for the PQP library, defines the pqprave shared library, links against necessary OpenRAVE and PQP libraries, sets compile and link flags, and specifies the installation directory and component. ```cmake add_subdirectory(pqp) add_library(pqprave SHARED pqprave.cpp collisionPQP.h plugindefs.h) target_link_libraries(pqprave PRIVATE boost_assertion_failed PUBLIC libopenrave PQP) set_target_properties(pqprave PROPERTIES COMPILE_FLAGS "${PLUGIN_COMPILE_FLAGS}" LINK_FLAGS "${PLUGIN_LINK_FLAGS}") install(TARGETS pqprave DESTINATION ${OPENRAVE_PLUGINS_INSTALL_DIR} COMPONENT ${COMPONENT_PREFIX}plugin-pqprave) # don't return the component since cannot distribute this library ``` -------------------------------- ### Install setup.py File with CMake Source: https://github.com/rdiankov/openrave/blob/master/3rdparty/flann-1.6.6/src/python/CMakeLists.txt This CMake command installs the generated setup.py file to a specified destination directory within the installation path. It ensures that the Python setup script is available in the target installation environment. ```cmake INSTALL ( FILES setup.py DESTINATION ${OPENRAVEPY_INSTALL_DIR}/pyflann ) ``` -------------------------------- ### Build OpenRAVE C++ Examples with CMake Source: https://github.com/rdiankov/openrave/blob/master/docs/mainpage.dox This code snippet provides instructions on how to build the C++ examples included with OpenRAVE using CMake. It involves creating a build directory, navigating into it, running CMake to configure the build, and then using make to compile the examples. The examples are located within the OpenRAVE share directory. ```CMake mkdir cppexamplesbuild cd cppexamplesbuild cmake `openrave-config --share-dir`/cppexamples make ``` -------------------------------- ### Install Dependencies for openrave.org Source: https://github.com/rdiankov/openrave/blob/master/docs/source/devel/website.rst Installs necessary system packages and Python dependencies for deploying openrave.org. It also includes steps for Apache web server deployment. ```bash apt-get install postgresql postgresql-client libpq-dev memcached python-dev gettext pip install -r deploy-requirements.txt # For Apache Webserver Deployment: apt-get install libapache2-mod-wsgi a2enmod wsgi ``` -------------------------------- ### C++ OpenRAVE Plugin Example Source: https://github.com/rdiankov/openrave/blob/master/docs/mainpage.dox Example C++ code demonstrating how to create a simple OpenRAVE plugin. It includes necessary includes, defining module commands, providing implementations, and exporting plugin attributes. ```cpp #include #include void MyModule(OpenRAVE::EnvironmentBasePtr menv, std::istream& ss) { // Module logic here } OpenRAVE::InterfaceBasePtr CreateInterfaceValidated(OpenRAVE::InterfaceType type, const std::string& name, OpenRAVEInterfaceBasePtr binder) { if (type == OpenRAVE::InterfaceType_Module && name == "MyModule") { return OpenRAVE::InterfaceBasePtr(new OpenRAVE::ModuleBase(binder)); } return OpenRAVE::InterfaceBasePtr(); } void GetPluginAttributesValidated(OpenRAVE:: PLUGIN_API* plugin_api) { plugin_api->SetDescription("MyModule", "A simple example module."); plugin_api->SetAuthorName("Your Name"); plugin_api->SetVersion("1.0.0"); } // Placeholder for actual module implementation and command registration // Example structure: // class MyModuleImpl : public OpenRAVE::ModuleBase { // public: // MyModuleImpl(OpenRAVE::InterfaceBasePtr binder) : OpenRAVE::ModuleBase(binder) {} // bool Command(std::basic_string& s) { // // Handle commands like 'numbodies' or 'load' // return true; // } // }; ``` -------------------------------- ### Configuring CMake Build Options for OpenRAVE Source: https://github.com/rdiankov/openrave/blob/master/docs/install.dox Demonstrates how to set various CMake options to customize the OpenRAVE build process. Options can be set during initial CMake configuration or by modifying them via `ccmake` after the build directory is created. The examples show how to disable video recording, enable double precision, build static libraries, and skip plugin compilation. ```bash cd build; cmake -DCMAKE_INSTALL_PREFIX=/my/new/install/dir -DCMAKE_BUILD_TYPE=Debug .. ``` ```bash cmake -DOPT_VIDEORECORDING=OFF .. ``` ```bash cmake -DOPT_DOUBLE_PRECISION=ON .. ``` ```bash cmake -DOPT_STATIC=ON .. ``` ```bash cmake -DOPT_PLUGINS=OFF .. ``` -------------------------------- ### Define Example Binaries in CMake Source: https://github.com/rdiankov/openrave/blob/master/3rdparty/zlib/CMakeLists.txt Defines example executable targets like `example` and `minigzip`, linking them against the `zlib` library. It also includes optional targets like `example64` and `minigzip64` for systems with large file support. ```cmake #add_executable(example example.c) #target_link_libraries(example zlib) #add_test(example example) # #add_executable(minigzip minigzip.c) #target_link_libraries(minigzip zlib) # #if(HAVE_OFF64_T) # add_executable(example64 example.c) # target_link_libraries(example64 zlib) # set_target_properties(example64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64") # add_test(example64 example64) # # add_executable(minigzip64 minigzip.c) # target_link_libraries(minigzip64 zlib) ``` -------------------------------- ### CMake: Installation Rules Source: https://github.com/rdiankov/openrave/blob/master/3rdparty/flann-1.6.6/src/cpp/CMakeLists.txt Defines rules for installing the built libraries and headers. It specifies destinations for runtime, library, archive, and include files, with conditional installation for C bindings and platform-specific handling for Windows. ```cmake #if(WIN32) #if (BUILD_C_BINDINGS) # install ( # TARGETS flann # RUNTIME DESTINATION share/flann/matlab # ) #endif() ;#endif(WIN32) # # #install ( # TARGETS flann_cpp flann_cpp_s # RUNTIME DESTINATION bin # LIBRARY DESTINATION ${FLANN_LIB_INSTALL_DIR} # ARCHIVE DESTINATION ${FLANN_LIB_INSTALL_DIR} #) # #if (BUILD_C_BINDINGS) # install ( # TARGETS flann flann_s # RUNTIME DESTINATION bin # LIBRARY DESTINATION ${FLANN_LIB_INSTALL_DIR} # ARCHIVE DESTINATION ${FLANN_LIB_INSTALL_DIR} # ) #endif() # #install ( # DIRECTORY flann # DESTINATION include # FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp" #) ``` -------------------------------- ### openrave-config: Installation Path Information Source: https://github.com/rdiankov/openrave/blob/master/docs/source/command_line_tools.rst The openrave-config tool is used to retrieve information about the OpenRAVE installation, including directories, used libraries, headers, and shared files. ```bash openrave-config --help ``` -------------------------------- ### Basic Function String Examples Source: https://github.com/rdiankov/openrave/blob/master/3rdparty/fparser-4.5.2/docs/fparser.html Provides examples of valid function strings that can be parsed by OpenRAVE. These illustrate basic arithmetic operations, function calls, and the use of variables like 'x' and 'y'. ```OpenRAVE Function String "1+2" ``` ```OpenRAVE Function String "x-1" ``` ```OpenRAVE Function String "-sin(sqrt(x^2+y^2))" ``` ```OpenRAVE Function String "sqrt(XCoord*XCoord + YCoord*YCoord)" ``` -------------------------------- ### Initial and Future Database Setup for openrave.org Source: https://github.com/rdiankov/openrave/blob/master/docs/source/devel/website.rst Commands to set up and update the database for the openrave.org Django project. Covers initial synchronization and future migrations. ```bash # Initial DB Setup: ./manage.py syncdb ./manage.py convert_to_south docs # Future DB Update: ./manage.py syncdb ./manage.py migrate ``` -------------------------------- ### Install MATLAB Source Files and Scripts Source: https://github.com/rdiankov/openrave/blob/master/octave_matlab/matlab/CMakeLists.txt This section handles the installation of MATLAB-related files. It installs the C++ source files and header for MEX creation, along with a 'runmex.bat' script for Windows. It also installs example files and configures component dependencies for packaging. ```cmake else() message(STATUS "MATLAB installation not found, is ${MEX_EXECUTABLE} in the system path?") endif() # because MATLAB is non-free, have to distribute the source files set(CPACK_COMPONENT_${COMPONENT_PREFIX_UPPER}MATLAB_DEPENDS ${COMPONENT_PREFIX}base PARENT_SCOPE) set(CPACK_COMPONENT_${COMPONENT_PREFIX_UPPER}MATLAB_DISPLAY_NAME "Matlab Bindings" PARENT_SCOPE) set(CPACK_COMPONENTS_ALL ${CPACK_COMPONENTS_ALL} ${COMPONENT_PREFIX}matlab PARENT_SCOPE) install(FILES "${OCTAVEMATLAB_FILES_DIR}/orcreate.cpp" "${OCTAVEMATLAB_FILES_DIR}/socketconnect.h" "${OCTAVEMATLAB_FILES_DIR}/orread.cpp" "${OCTAVEMATLAB_FILES_DIR}/orwrite.cpp" DESTINATION ${OPENRAVE_MATLAB_INSTALL_DIR} COMPONENT ${COMPONENT_PREFIX}matlab) if( WIN32 OR WIN64 ) install(FILES runmex.bat DESTINATION ${OPENRAVE_MATLAB_INSTALL_DIR} COMPONENT ${COMPONENT_PREFIX}matlab) endif() install(FILES ${OCTAVEMATLAB_FILES} DESTINATION ${OPENRAVE_MATLAB_INSTALL_DIR} COMPONENT ${COMPONENT_PREFIX}matlab) install(DIRECTORY "${OCTAVEMATLAB_FILES_DIR}/examples" DESTINATION ${OPENRAVE_MATLAB_INSTALL_DIR} COMPONENT ${COMPONENT_PREFIX}matlab PATTERN ".svn" EXCLUDE) ``` -------------------------------- ### Directly Launch Planners in OpenRAVEpy Source: https://github.com/rdiankov/openrave/blob/master/docs/source/tutorials/openravepy_examples.rst Demonstrates how to directly invoke and use specific motion planning algorithms available in OpenRAVE, bypassing higher-level abstractions if needed. ```python import openravepy import numpy as np openravepy.RaveInitialize() env = openravepy.Environment() env.Load("data/pr2.env") robot = env.GetRobots()[0] # Get a specific planner by its name (e.g., 'birrt', '્યાં') try: planner = openravepy.RaveCreatePlanner(env, 'birrt') print("Planner 'birrt' created directly.") # Initialize and plan as usual start_config = robot.GetDOFValues(robot.GetActiveDOFIndices()) goal_config = start_config.copy() goal_config[0] += np.pi with env: planner.InitPlan(robot, start_config, goal_config) traj = planner.PlanPath() if traj: print("Path planned using directly launched planner.") else: print("Planning failed.") except openravepy.openrave_exception as e: print(f"Failed to create planner: {e}") ``` -------------------------------- ### Install OpenRAVE Python 3 Bindings Source: https://github.com/rdiankov/openrave/blob/master/python/CMakeLists.txt Installs Python 3 files and directories for OpenRAVE bindings. Similar to Python 2 installation, this includes the main package, utility scripts, examples, interfaces, and databases. It is conditional on the OPT_PYTHON3 flag being set. ```cmake if (OPT_PYTHON3) install(FILES ${OPENRAVEPY_INIT} DESTINATION ${OPENRAVEPY3_INSTALL_DIR} COMPONENT openrave-python-minimal) install(FILES metaclass.py openravepy_ext.py misc.py trajectoryutils.py pyANN.py DESTINATION ${OPENRAVEPY3_VER_INSTALL_DIR} COMPONENT ${COMPONENT_PREFIX}python) install(FILES openravepy.__init__.py DESTINATION ${OPENRAVEPY3_VER_INSTALL_DIR} COMPONENT ${COMPONENT_PREFIX}python RENAME __init__.py) install(FILES ${OPENRAVEPY_MAIN} ${OPENRAVEPY_ROBOT} ${OPENRAVEPY_CREATEPLUGIN} DESTINATION ${OPENRAVEPY3_VER_INSTALL_DIR} COMPONENT ${COMPONENT_PREFIX}python) install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/examples" DESTINATION ${OPENRAVEPY3_VER_INSTALL_DIR} FILE_PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ COMPONENT ${COMPONENT_PREFIX}python PATTERN ".svn" EXCLUDE PATTERN ".pyc" EXCLUDE) install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/interfaces" DESTINATION ${OPENRAVEPY3_VER_INSTALL_DIR} FILE_PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ COMPONENT ${COMPONENT_PREFIX}python PATTERN ".svn" EXCLUDE PATTERN ".pyc" EXCLUDE) install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/databases" DESTINATION ${OPENRAVEPY3_VER_INSTALL_DIR} FILE_PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ COMPONENT ${COMPONENT_PREFIX}python PATTERN ".svn" EXCLUDE PATTERN ".pyc" EXCLUDE) endif() ``` -------------------------------- ### Initialize and Load Specific OpenRAVE Plugins Source: https://github.com/rdiankov/openrave/blob/master/docs/source/tutorials/openravepy_beginning.rst Initializes the OpenRAVE runtime and selectively loads plugins, such as 'libbasemanipulation'. This allows for a customized OpenRAVE setup, potentially improving startup time and reducing resource usage by loading only necessary components. ```python try: RaveInitialize(load_all_plugins=False) success = RaveLoadPlugin('libbasemanipulation') # do work finally: RaveDestroy() # destroy the runtime ``` -------------------------------- ### Install Python Bindings Include Directories (CMake) Source: https://github.com/rdiankov/openrave/blob/master/CMakeLists.txt Installs the include directories for Python bindings, differentiating between pybind11 and Boost.Python setups. This ensures that external projects can find the necessary header files. ```cmake add_subdirectory(python) if (pybind11_FOUND) install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/python/bindings/include/openravepy/pybind11 DESTINATION include/${OPENRAVE_INCLUDE_INSTALL_DIR}/openravepy) else() install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/python/bindings/include/openravepy/boostpython DESTINATION include/${OPENRAVE_INCLUDE_INSTALL_DIR}/openravepy) endif() ``` -------------------------------- ### Load Simple Environment in OpenRAVEpy Source: https://github.com/rdiankov/openrave/blob/master/docs/source/tutorials/openravepy_examples.rst Loads a basic environment into OpenRAVE. This is a foundational step for most OpenRAVE operations, setting up the scene for further manipulation or planning. ```python import openravepy # Initialize OpenRAVE openravepy.RaveInitialize() # Create a new environment env = openravepy.Environment() # Load a simple environment (replace with your .env file) env.Load("data/pr2.env") # Print success message print("Environment loaded successfully.") # You can now interact with the loaded environment ``` -------------------------------- ### Install OpenRAVE Python 2 Bindings Source: https://github.com/rdiankov/openrave/blob/master/python/CMakeLists.txt Installs Python 2 files and directories for OpenRAVE bindings. This includes the main Python package, utility scripts, examples, interfaces, and databases. It is conditional on the OPT_PYTHON flag being set. ```cmake if (OPT_PYTHON) install(FILES ${OPENRAVEPY_INIT} DESTINATION ${OPENRAVEPY2_INSTALL_DIR} COMPONENT openrave-python-minimal) install(FILES metaclass.py openravepy_ext.py misc.py trajectoryutils.py pyANN.py DESTINATION ${OPENRAVEPY2_VER_INSTALL_DIR} COMPONENT ${COMPONENT_PREFIX}python) install(FILES openravepy.__init__.py DESTINATION ${OPENRAVEPY2_VER_INSTALL_DIR} COMPONENT ${COMPONENT_PREFIX}python RENAME __init__.py) install(FILES ${OPENRAVEPY_MAIN} ${OPENRAVEPY_ROBOT} ${OPENRAVEPY_CREATEPLUGIN} DESTINATION ${OPENRAVEPY2_VER_INSTALL_DIR} COMPONENT ${COMPONENT_PREFIX}python) install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/examples" DESTINATION ${OPENRAVEPY2_VER_INSTALL_DIR} FILE_PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ COMPONENT ${COMPONENT_PREFIX}python PATTERN ".svn" EXCLUDE PATTERN ".pyc" EXCLUDE) install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/interfaces" DESTINATION ${OPENRAVEPY2_VER_INSTALL_DIR} FILE_PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ COMPONENT ${COMPONENT_PREFIX}python PATTERN ".svn" EXCLUDE PATTERN ".pyc" EXCLUDE) install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/databases" DESTINATION ${OPENRAVEPY2_VER_INSTALL_DIR} FILE_PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ COMPONENT ${COMPONENT_PREFIX}python PATTERN ".svn" EXCLUDE PATTERN ".pyc" EXCLUDE) endif() ``` -------------------------------- ### OpenRAVE Basic Planner Usage (C++) Source: https://github.com/rdiankov/openrave/blob/master/docs/architecture.dox Illustrates a basic example of using a planner in OpenRAVE, setting robot-specific parameters, initial configuration, and goal configuration. ```C++ PlannerBase::PlannerParametersPtr params(new PlannerBase::PlannerParameters); params->SetRobotActiveJoints(robot); robot->GetActiveDOFValues(params.vinitialconfig); params.vgoalconfig = activegoal; ``` -------------------------------- ### Python 2 Bindings Setup (CMake) Source: https://github.com/rdiankov/openrave/blob/master/CMakeLists.txt Configures the build environment for Python 2 bindings. This includes finding Python 2, its development components, and NumPy. It also determines the installation path for Python 2 site-packages and sets up necessary variables for linking and installation. ```cmake if (OPT_PYTHON) find_package(Python2 2.7 REQUIRED COMPONENTS Interpreter Development NumPy) message(STATUS "Python 2 version is ${Python2_VERSION}") execute_process( COMMAND ${Python2_EXECUTABLE} -c "import distutils.sysconfig as sysconf; import os; \n print(os.path.relpath(sysconf.get_python_lib(1, prefix='${CMAKE_INSTALL_PREFIX}'), '${CMAKE_INSTALL_PREFIX}'))" OUTPUT_VARIABLE OPENRAVE_PYTHON2_INSTALL_DIR OUTPUT_STRIP_TRAILING_WHITESPACE WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" ) message(STATUS "Python2 site-packages path is ${OPENRAVE_PYTHON2_INSTALL_DIR}") set(OPENRAVEPY2_INSTALL_DIR "${OPENRAVE_PYTHON2_INSTALL_DIR}/openravepy" CACHE PATH "OpenRAVE Python bindings installation directory") set(OPENRAVEPY2_VER_INSTALL_DIR "${OPENRAVEPY2_INSTALL_DIR}/${OPENRAVEPY_VER_NAME}") # used by openrave-config.cmake # Backward compat set(OPENRAVE_PYTHON_INSTALL_DIR ${OPENRAVE_PYTHON2_INSTALL_DIR}) set(OPENRAVEPY_INSTALL_DIR ${OPENRAVEPY2_INSTALL_DIR}) set(OPENRAVEPY_VER_INSTALL_DIR ${OPENRAVEPY2_VER_INSTALL_DIR}) set(PYTHON_EXECUTABLE ${Python2_EXECUTABLE}) # get the sympy version execute_process( COMMAND ${Python2_EXECUTABLE} -c "import sympy; print(sympy.__version__)" OUTPUT_VARIABLE _sympy_version OUTPUT_STRIP_TRAILING_WHITESPACE RESULT_VARIABLE _sympy_version_failed ) set(OPENRAVE_USE_LOCAL_SYMPY 1) if( ${_sympy_version_failed} EQUAL 0 ) message(STATUS "Found sympy version '${_sympy_version}'") if( "${_sympy_version}" VERSION_GREATER "0.6.3" OR "${_sympy_version}" VERSION_EQUAL "0.6.3" ) set(OPENRAVE_USE_LOCAL_SYMPY 0) if( "${_sympy_version}" VERSION_LESS "0.6.7" OR "${_sympy_version}" VERSION_EQUAL "0.6.7" ) message(STATUS "Found sympy version 0.6.x, will patch this instead of installing local version") else() message(STATUS "Assuming sympy version 0.7.x or greater") endif() endif() else() message(STATUS "failed to find python sympy system installation") endif() if( OPENRAVE_USE_LOCAL_SYMPY ) message(STATUS "System sympy (v=${_sympy_version}) is not right version, using local sympy") # extract sympy if( NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/sympy/__init__.py" OR NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/sympy/solvers/tests") message(STATUS "extracting sympy to ${CMAKE_CURRENT_SOURCE_DIR}") execute_process( COMMAND ${CMAKE_COMMAND} -E tar xzf "${CMAKE_CURRENT_SOURCE_DIR}/sympy_0.7.1.tgz" WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}") endif() install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/sympy" DESTINATION ${OPENRAVE_PYTHON2_INSTALL_DIR} COMPONENT ${COMPONENT_PREFIX}python PATTERN ".svn" EXCLUDE) endif() add_library(openravepy2_meta INTERFACE) target_include_directories(openravepy2_meta INTERFACE $ $ $ $ $ $ $ $ ) install(TARGETS openravepy2_meta EXPORT openrave-targets) set(PYBIND11_NOPYTHON ON) find_package(pybind11 2.9.2) # 2.9.2 is the last version of pybind11 to support Python 2. if (pybind11_FOUND) target_link_libraries(openravepy2_meta INTERFACE rt Python2::Module Python2::NumPy pybind11::module libopenrave libopenrave-core) target_compile_options(openravepy2_meta INTERFACE "-fvisibility=hidden") # pybind11 requires less visibility target_compile_definitions(openravepy2_meta INTERFACE "OPENRAVE_CORE_DLL=1" "USE_PYBIND11_PYTHON_BINDINGS=1") set(USE_PYBIND11_PYTHON_BINDINGS ON) else() find_package(Boost REQUIRED COMPONENTS python thread) target_link_libraries(openravepy2_meta INTERFACE rt Python2::Module Python2::NumPy Boost::python Boost::thread libopenrave libopenrave-core) target_compile_definitions(openravepy2_meta INTERFACE "OPENRAVE_CORE_DLL=1") set(USE_PYBIND11_PYTHON_BINDINGS OFF) endif() endif() ``` -------------------------------- ### Qhull Library Integration with qh_new_qhull() Source: https://github.com/rdiankov/openrave/blob/master/3rdparty/qhull/Changes.txt This snippet demonstrates how to integrate the Qhull library into a C program using the `qh_new_qhull()` function. It requires including the Qhull header file and provides a basic example of how to call Qhull and access its functionality. The `user_eg.c` example is updated to use this new entry point. ```c #include int main() { // Example usage of qh_new_qhull() would go here // ... return 0; } ``` -------------------------------- ### Generate and Install Windows Batch File (CMake) Source: https://github.com/rdiankov/openrave/blob/master/src/CMakeLists.txt This CMake code configures a Windows-specific batch file for running examples when the MSVC compiler is detected. It uses `configure_file` to process a template and then installs the generated batch file to the OpenRAVE share directory. It depends on the MSVC compiler being available. ```cmake if( MSVC ) configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cppexamples/runcmake_win.bat.in" "${CMAKE_CURRENT_BINARY_DIR}/cppexamples/runcmake_win.bat" IMMEDIATE @ONLY) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cppexamples/runcmake_win.bat DESTINATION ${OPENRAVE_SHARE_DIR}/cppexamples COMPONENT ${COMPONENT_PREFIX}dev) endif() ``` -------------------------------- ### CMakeLists.txt for OpenRAVE Plugin Source: https://github.com/rdiankov/openrave/blob/master/docs/mainpage.dox Example CMakeLists.txt file for compiling a shared library plugin for OpenRAVE. It uses FindOpenRAVE.cmake to locate OpenRAVE installation directories and include/library paths. ```cmake cmake_minimum_required (VERSION 2.6) project (plugincpp) find_package(OpenRAVE REQUIRED) include_directories(${OpenRAVE_INCLUDE_DIRS}) link_directories(${OpenRAVE_LIBRARY_DIRS}) add_library(plugincpp SHARED plugincpp.cpp) ``` -------------------------------- ### Get OpenRAVE Python Directory Source: https://github.com/rdiankov/openrave/blob/master/docs/source/tutorials/openravepy_beginning.rst Retrieves the directory where OpenRAVE Python bindings are installed. This path is necessary for setting the PYTHONPATH environment variable. It is commonly used on Unix-based systems. ```bash openrave-config --python-dir ``` -------------------------------- ### Grab Object with Planner in OpenRAVEpy Source: https://github.com/rdiankov/openrave/blob/master/docs/source/tutorials/openravepy_examples.rst Demonstrates planning a grasp for an object and moving the robot to execute the grasp. This involves identifying grasp poses and integrating them into motion planning. ```python import openravepy import numpy as np openravepy.RaveInitialize() env = openravepy.Environment() env.Load("data/pr2.env") robot = env.GetRobots()[0] obj = env.GetBodies()[1] # Assuming the second body is the object # Get the manipulator (e.g., the first one) manips = robot.GetManipulators()[0] # Find grasp poses for the object grasp_poses = obj.ComputeGrasp(manips.GetEndEffector().GetName()) if not grasp_poses: print("No grasp poses found.") else: # Select a grasp pose (e.g., the first one) grasp_transform = grasp_poses[0] # Plan a motion to approach the grasp pose # This requires defining pre-grasp and grasp configurations with env: planner = openravepy.RaveCreatePlanner(env, 'birrt') # Define goal configuration for grasping robot.SetTransform(grasp_transform) goal_config = robot.GetDOFValues(robot.GetActiveDOFIndices()) # Plan path to the grasp configuration planner.InitPlan(robot, robot.GetDOFValues(robot.GetActiveDOFIndices()), goal_config) traj = planner.PlanPath() if traj: print("Grasping path planned.") # robot.ExecuteTrajectory(traj) # Perform grasp action else: print("Failed to plan grasping path.") ``` -------------------------------- ### Plan to End Effector Position in OpenRAVEpy Source: https://github.com/rdiankov/openrave/blob/master/docs/source/tutorials/openravepy_examples.rst Plans a robot motion to reach a specific end-effector position. This combines motion planning with inverse kinematics to guide the robot's end-effector. ```python import openravepy import numpy as np openravepy.RaveInitialize() env = openravepy.Environment() env.Load("data/pr2.env") robot = env.GetRobots()[0] manips = robot.GetManipulators()[0] # Define a target end-effector position target_position = [0.6, 0.6, 0.7] # Convert position to a transform matrix with identity rotation target_transform = openravepy.matrixFromTranslation(target_position) # Get the current robot configuration start_config = robot.GetDOFValues(robot.GetActiveDOFIndices()) # Use the planner to find a path to the target end-effector pose # This requires specifying the manipulator and the goal pose with env: planner = openravepy.RaveCreatePlanner(env, 'birrt') # Or another planner planner.InitPlan(robot, start_config, []) # Empty goal config, will be determined by IK # Use a specific planning method that considers end-effector goals # This is a conceptual example, actual method might vary # Example: planning to a specific FK pose robot.SetDOFValues(start_config, 1) goal_ik = manips.FindIKSolution(target_transform, 0) if goal_ik is None: print("Could not find IK for target position.") else: traj = planner.PlanPath(goal_config=goal_ik) if traj: print("Path to end-effector position planned.") # robot.ExecuteTrajectory(traj) else: print("Failed to plan path to end-effector position.") ``` -------------------------------- ### C++ OpenRAVE Environment, IKFast, and Planning Source: https://context7.com/rdiankov/openrave/llms.txt Initializes OpenRAVE, loads a scene, sets up a robot manipulator, integrates the IKFast solver, and performs motion planning within a C++ application. This code requires OpenRAVE core libraries and headers. ```cpp #include #include #include using namespace OpenRAVE; using namespace std; int main(int argc, char** argv) { // Initialize OpenRAVE RaveInitialize(true); // Create environment EnvironmentBasePtr penv = RaveCreateEnvironment(); // Load scene penv->Load("data/pa10grasp2.env.xml"); // Get robot vector vrobots; penv->GetRobots(vrobots); RobotBasePtr probot = vrobots.at(0); // Set active manipulator for(size_t i = 0; i < probot->GetManipulators().size(); ++i) { if(probot->GetManipulators()[i]->GetName().find("arm") != string::npos) { probot->SetActiveManipulator(probot->GetManipulators()[i]); break; } } RobotBase::ManipulatorPtr pmanip = probot->GetActiveManipulator(); // Load IKFast solver ModuleBasePtr pikfast = RaveCreateModule(penv, "ikfast"); penv->Add(pikfast, true, ""); stringstream ssin, ssout; ssin << "LoadIKFastSolver " << probot->GetName() << " " << (int)IKP_Transform6D; if(!pikfast->SendCommand(ssout, ssin)) { RAVELOG_ERROR("Failed to load IK solver\n"); return 1; } // Create base manipulation module ModuleBasePtr pbasemanip = RaveCreateModule(penv, "basemanipulation"); penv->Add(pbasemanip, true, probot->GetName()); // Planning loop while(true) { { EnvironmentLock lock(penv->GetMutex()); // Generate random target transform Transform t = pmanip->GetTransform(); t.trans += Vector( RaveRandomFloat() - 0.5f, RaveRandomFloat() - 0.5f, RaveRandomFloat() - 0.5f ); t.rot = quatMultiply( t.rot, quatFromAxisAngle(Vector( RaveRandomFloat() - 0.5f, RaveRandomFloat() - 0.5f, RaveRandomFloat() - 0.5f ) * 0.2f) ); // Plan to target ssin.str(""); ssin.clear(); ssin << "MoveToHandPosition pose " << t; RAVELOG_INFO("%s\n", ssin.str().c_str()); if(!pbasemanip->SendCommand(ssout, ssin)) { continue; } } // Wait for motion to complete while(!probot->GetController()->IsDone()) { std::this_thread::sleep_for(std::chrono::milliseconds(1)); } } RaveDestroy(); return 0; } ``` -------------------------------- ### Install OpenRAVE Header Files Source: https://github.com/rdiankov/openrave/blob/master/CMakeLists.txt This snippet handles the installation of OpenRAVE's header files. It installs the main 'openrave' headers and conditionally installs 'openrave_c' headers if C bindings are enabled. It also configures and installs a 'config.h' file with build-specific settings. ```cmake install(DIRECTORY ${CMAKE_SOURCE_DIR}/include/openrave/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${OPENRAVE_INCLUDE_INSTALL_DIR}/openrave) if (OPT_CBINDINGS) install(DIRECTORY ${CMAKE_SOURCE_DIR}/include/openrave_c/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${OPENRAVE_INCLUDE_INSTALL_DIR}/openrave_c) endif() configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/include/openrave/config.h IMMEDIATE @ONLY) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/include/openrave/config.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${OPENRAVE_INCLUDE_INSTALL_DIR}/openrave) ``` -------------------------------- ### openrave-createplugin.py: Help and Command-Line Interface Source: https://github.com/rdiankov/openrave/blob/master/docs/source/command_line_tools.rst Shows the command-line interface for the openrave-createplugin.py script, outlining its parameters for plugin project generation. ```bash python3 -m openravepy.createplugin --help ``` -------------------------------- ### Clone OpenRAVE Source Code using Git Source: https://github.com/rdiankov/openrave/blob/master/docs/source/install.rst Clones the latest stable version of the OpenRAVE source code from the official GitHub repository. This is useful for users who want to compile OpenRAVE from source or access the most up-to-date development version. The '--branch latest_stable' flag ensures you get the most recent stable release. ```bash git clone --branch latest_stable https://github.com/rdiankov/openrave.git ``` -------------------------------- ### Generate Robot Database Webpages with make ikfast Source: https://github.com/rdiankov/openrave/blob/master/docs/source/devel/documentation_system.rst This command generates webpages for each robot using statistics from test/test_ikfast.py. It involves navigating to the 'docs' directory, setting the language to English, and executing 'make ikfaststats=ikfaststats.pp ikfast'. This process is essential for visualizing robot data. ```bash cd docs LANG=en_US.UTF-8 make ikfaststats=ikfaststats.pp ikfast ``` -------------------------------- ### Install OpenRAVE from Ubuntu PPA Source: https://github.com/rdiankov/openrave/blob/master/docs/source/install.rst Adds the official OpenRAVE PPA to your system and installs the latest stable release using apt-get. This method requires an Ubuntu-based Linux distribution. It fetches the repository key, adds the repository, updates the package list, and then installs the 'openrave' package. ```bash sudo add-apt-repository ppa:openrave/release sudo apt-get update sudo apt-get install openrave ``` -------------------------------- ### Configure Include Directory Installation in CMake Source: https://github.com/rdiankov/openrave/blob/master/src/libopenrave/CMakeLists.txt This CMake code configures the installation destination for header files. It uses CMAKE_INSTALL_INCLUDEDIR and a custom variable OPENRAVE_INCLUDE_INSTALL_DIR to define the final path where headers will be installed. This is crucial for ensuring that installed libraries can find their associated header files. ```cmake INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${OPENRAVE_INCLUDE_INSTALL_DIR} ) endif() ``` -------------------------------- ### Load and Update Documentation for openrave.org Source: https://github.com/rdiankov/openrave/blob/master/docs/source/devel/website.rst Commands to load initial documentation data and update the documentation for the openrave.org website. ```bash # For Docs: ./manage.py loaddata doc_releases.json ./manage.py update_docs ``` -------------------------------- ### Setup GCC Enhancements for OpenRAVE Development Source: https://github.com/rdiankov/openrave/blob/master/docs/source/devel/working_with_sources.rst Configures development environment with colorgcc and ccache by executing a bash script. This script is intended to be sourced from ~/.bashrc and creates symbolic links to compilers in /usr/local/bin for easier development. It assumes the existence of a setupgcc.bash script. ```bash source ../../../sandbox/setupgcc.bash ``` -------------------------------- ### Install pyflann Directory with Exclusions using CMake Source: https://github.com/rdiankov/openrave/blob/master/3rdparty/flann-1.6.6/src/python/CMakeLists.txt This CMake command installs the 'pyflann' directory to the installation path. It includes various patterns to exclude specific file types such as compiled code (.cpp, .so, .a), data files (.dat), templates (.tpl), temporary files (~), test directories (_tests), and version control directories (.svn). This ensures only necessary source and header files are installed. ```cmake INSTALL ( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/pyflann DESTINATION ${OPENRAVEPY_INSTALL_DIR} PATTERN *.cpp EXCLUDE PATTERN *.so EXCLUDE PATTERN *.a EXCLUDE PATTERN *.dat EXCLUDE PATTERN *.txt EXCLUDE PATTERN *.tpl EXCLUDE PATTERN *~ EXCLUDE PATTERN _tests EXCLUDE PATTERN ".svn" EXCLUDE ) ``` -------------------------------- ### openrave: Basic Environment Execution Source: https://github.com/rdiankov/openrave/blob/master/docs/source/command_line_tools.rst The 'openrave' executable is a C++ program for starting an OpenRAVE environment and loading modules. It allows for simple configuration of parameters for testing purposes. ```bash openrave --help ``` -------------------------------- ### Initialize and Execute OpenRAVE Planner Source: https://github.com/rdiankov/openrave/blob/master/docs/architecture.dox This snippet demonstrates the basic workflow of initializing an RRT planner, executing a plan, and then executing the resulting trajectory on a robot. It involves creating a planner and trajectory, initializing the plan with robot and parameters, and checking for a successful solution before activating the motion. ```cpp PlannerBasePtr rrtplanner = RaveCreatePlanner(GetEnv(),"rBiRRT"); TrajectoryBasePtr ptraj = RaveCreateTrajectory(GetEnv(),robot->GetActiveDOF()); if( !rrtplanner->InitPlan(robot, params) ) { return false; } PlannerStatus status = rrtplanner->Plan(ptraj); if( status & PS_HasSolution ) { robot->SetActiveMotion(ptraj); // trajectory is done, execute on the robot } ``` -------------------------------- ### Install OpenRAVE CMake Module (CMake) Source: https://github.com/rdiankov/openrave/blob/master/src/CMakeLists.txt This snippet installs the 'FindOpenRAVE.cmake' module, which is essential for other CMake projects to find and use the OpenRAVE library. The file is installed into the OpenRAVE share directory under 'cppexamples'. ```cmake install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/cppexamples/FindOpenRAVE.cmake" DESTINATION ${OPENRAVE_SHARE_DIR}/cppexamples COMPONENT ${COMPONENT_PREFIX}dev) ``` -------------------------------- ### OpenRAVE: Create Environment and Load Scene (Python) Source: https://context7.com/rdiankov/openrave/llms.txt Demonstrates how to create an OpenRAVE simulation environment, load robot models and other bodies from XML files, access robot data, and set up visualization. It also shows how to lock the environment for thread-safe operations and print end-effector positions. ```python from openravepy import * import numpy as np # Create environment env = Environment() # Load a robot scene env.Load('data/pr2test1.env.xml') # Get all robots in scene robots = env.GetRobots() robot = robots[0] # Load additional bodies kinbody = env.ReadKinBodyXMLFile('data/mug1.kinbody.xml') env.Add(kinbody) # Lock environment for thread-safe operations with env: robot.SetDOFValues([0, 1.5, -0.5, 0]) transform = robot.GetActiveManipulator().GetTransform() print(f"End effector position: {transform[0:3,3]}") # Set viewer for visualization env.SetViewer('qtcoin') ``` -------------------------------- ### OpenRAVE High-Level Manipulation Interface Setup Source: https://context7.com/rdiankov/openrave/llms.txt Sets up the environment for high-level manipulation tasks in OpenRAVE. This includes loading a robot, setting the active manipulator, and generating an Inverse Kinematics (IK) model. Requires `openravepy`, `numpy`, and `time`. ```python from openravepy import * import numpy as np import time def waitrobot(robot): """Wait for robot controller to finish""" while not robot.GetController().IsDone(): time.sleep(0.01) env = Environment() env.SetViewer('qtcoin') env.Load('data/pr2test2.env.xml') robot = env.GetRobots()[0] mip = robot.SetActiveManipulator('leftarm_torso') ikmodel = databases.inversekinematics.InverseKinematicsModel( robot, iktype=IkParameterization.Type.Transform6D ) if not ikmodel.load(): ikmodel.autogenerate() ``` -------------------------------- ### Install OpenRAVE Python Bindings Headers (CMake) Source: https://github.com/rdiankov/openrave/blob/master/python/bindings/CMakeLists.txt This CMake command installs the necessary header files for the OpenRAVE Python 3 bindings. It uses 'file(GLOB ...)' to find all .h files in the 'include/openravepy' directory and installs them along with a generated 'openravepy_config.h' file to the specified destination directory. This is part of the Python component installation. ```cmake message(STATUS "Can successfully build OpenRAVE Python bindings; will install headers for python bindings of other modules") file(GLOB openravepy_headers include/openravepy/*.h) install( FILES ${openravepy_headers} ${CMAKE_CURRENT_BINARY_DIR}/include/openravepy/openravepy_config.h DESTINATION include/${OPENRAVE_INCLUDE_INSTALL_DIR}/openravepy COMPONENT ${COMPONENT_PREFIX}python ) ``` -------------------------------- ### openrave.py: Help and Command-Line Interface Source: https://github.com/rdiankov/openrave/blob/master/docs/source/command_line_tools.rst This shows the command-line interface for the openrave.py script, providing details on available options and usage. ```bash python3 -m openravepy --help ``` -------------------------------- ### Loading OpenRAVE Plugins via Command Line Source: https://github.com/rdiankov/openrave/blob/master/docs/mainpage.dox Demonstrates different command-line methods to load a compiled OpenRAVE plugin. This includes using an absolute or relative path to the shared object file. ```bash openrave --loadplugin $SOMEPATH/libplugincpp openrave --loadplugin $SOMEPATH/libplugincpp.so openrave --loadplugin ./libplugincpp.so ``` -------------------------------- ### OpenRAVE Plugin Creation Script Source: https://github.com/rdiankov/openrave/blob/master/docs/source/changelog.rst Presents the openrave-createplugin.py script, designed to help new users easily set up plugin directories and create executable plugins. Bash completion is also provided. ```shell # To create a new plugin: openrave-createplugin.py MyNewPlugin # This script will set up the necessary directory structure and build files. ``` -------------------------------- ### Install baserobots Plugin - CMake Source: https://github.com/rdiankov/openrave/blob/master/plugins/baserobots/CMakeLists.txt This CMake instruction installs the built 'baserobots' shared library to a specified destination directory within the OpenRAVE plugin installation path. It assigns the plugin to a specific component for package management. ```cmake install(TARGETS baserobots DESTINATION ${OPENRAVE_PLUGINS_INSTALL_DIR} COMPONENT ${PLUGINS_BASE}) ```