diff --git a/.docker/README.md b/.docker/README.md index a0cf726f20..b24af099ec 100644 --- a/.docker/README.md +++ b/.docker/README.md @@ -1,3 +1,3 @@ -# MoveIt! Docker Containers +# MoveIt Docker Containers For more information see [Continuous Integration and Docker](http://moveit.ros.org/documentation/contributing/continuous_integration.html) documentation. diff --git a/.docker/ci/Dockerfile b/.docker/ci/Dockerfile index dd4c77c91f..830c8abd09 100644 --- a/.docker/ci/Dockerfile +++ b/.docker/ci/Dockerfile @@ -33,7 +33,7 @@ RUN \ clang clang-format-3.9 clang-tidy clang-tools \ ccache && \ # - # Download all dependencies of MoveIt! + # Download all dependencies of MoveIt rosdep update && \ rosdep install -y --from-paths . --ignore-src --rosdistro ${ROS_DISTRO} --as-root=apt:false && \ # diff --git a/.docker/release/Dockerfile b/.docker/release/Dockerfile index e06998b1a2..4611c98b20 100644 --- a/.docker/release/Dockerfile +++ b/.docker/release/Dockerfile @@ -1,5 +1,5 @@ # moveit/moveit:melodic-release -# Full debian-based install of MoveIt! using apt-get +# Full debian-based install of MoveIt using apt-get FROM ros:melodic-ros-base MAINTAINER Dave Coleman dave@picknik.ai diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index a6d58c6912..ca05e3da91 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,4 +1,4 @@ -# MoveIt! is a large project with pull requests being created often. In order +# MoveIt is a large project with pull requests being created often. In order # to ensure quick review turn around time from our maintainer team, we're # leveraging an automated "triage" approach to auto-assign reviews to new pull # requests. If you already know who should review your PR, then you can assign diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 81764f54b6..e653cc1ef4 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -4,11 +4,10 @@ Please explain the changes you made, including a reference to the related issue ### Checklist - [ ] **Required by CI**: Code is auto formatted using [clang-format](http://moveit.ros.org/documentation/contributing/code) -- [ ] Extended the tutorials / documentation, if necessary [reference](http://moveit.ros.org/documentation/contributing/) +- [ ] Extend the tutorials / documentation [reference](http://moveit.ros.org/documentation/contributing/) +- [ ] Document API changes relevant to the user in the MIGRATION.md notes +- [ ] Create tests, which fail without this PR [reference](https://ros-planning.github.io/moveit_tutorials/) - [ ] Include a screenshot if changing a GUI -- [ ] Document API changes relevant to the user in the moveit/MIGRATION.md notes -- [ ] Created tests, which fail without this PR [reference](http://docs.ros.org/kinetic/api/moveit_tutorials/html/doc/tests.html) -- [ ] Decide if this should be cherry-picked to other current ROS branches -- [ ] While waiting for someone to review your request, please consider reviewing [another open pull request](https://github.com/ros-planning/moveit/pulls) to support the maintainers +- [ ] While waiting for someone to review your request, please help review [another open pull request](https://github.com/ros-planning/moveit/pulls) to support the maintainers [//]: # "You can expect a response from a maintainer within 7 days. If you haven't heard anything by then, feel free to ping the thread. Thank you!" diff --git a/.github/config.yml b/.github/config.yml index fed71ab355..2810cc56b6 100644 --- a/.github/config.yml +++ b/.github/config.yml @@ -11,12 +11,12 @@ newIssueWelcomeComment: > # Comment to be posted to on PRs from first time contributors in your repository newPRWelcomeComment: > - Thanks for helping in improving MoveIt! + Thanks for helping in improving MoveIt # Configuration for first-pr-merge - https://github.com/behaviorbot/first-pr-merge # Comment to be posted to on pull requests merged by a first time user firstPRMergeComment: > - Congrats on getting your first MoveIt! pull request merged and improving open source robotics! + Congrats on getting your first MoveIt pull request merged and improving open source robotics! # It is recommended to include as many gifs and emojis as possible! diff --git a/.gitignore b/.gitignore index 9877f9248d..808fe85341 100644 --- a/.gitignore +++ b/.gitignore @@ -51,10 +51,10 @@ qtcreator-* # Vim *.swp -# Catkin custom files -CATKIN_IGNORE - # Continous Integration .moveit_ci *.pyc + +#gdb +*.gdb diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index eeafb30ddf..609c244cf6 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,4 +1,4 @@ -# Contributing to MoveIt! +# Contributing to MoveIt Thanks for getting involved! Information on contributing can be found at [http://moveit.ros.org/documentation/contributing/](http://moveit.ros.org/documentation/contributing/) diff --git a/MIGRATION.md b/MIGRATION.md index 05740746a4..00cf53f4fb 100644 --- a/MIGRATION.md +++ b/MIGRATION.md @@ -1,6 +1,6 @@ # Migration Notes -API changes in MoveIt! releases +API changes in MoveIt releases ## ROS Noetic (upcoming changes in master) - Extended the return value of `MoveitCommander.MoveGroup.plan()` from `trajectory` to a tuple of `(success, trajectory, planning_time, error_code)` to better match the C++ MoveGroupInterface ([790](https://github.com/ros-planning/moveit/pull/790/)) @@ -8,6 +8,7 @@ API changes in MoveIt! releases - Moved the example package `moveit_controller_manager_example` into [moveit_tutorials](https://github.com/ros-planning/moveit_tutorials) - Requests to `get_planning_scene` service without explicitly setting "components" now return full scene - `moveit_ros_plannning` no longer depends on `moveit_ros_perception` +- `CollisionRobot` and `CollisionWorld` are combined into a single `CollisionEnv` class. This applies for all derived collision checkers as `FCL`, `ALL_VALID`, `HYBRID` and `DISTANCE_FIELD`. Consequently, `getCollisionRobot[Unpadded] / getCollisionWorld` functions are replaced through a `getCollisionEnv` in the planning scene and return the new combined environment. This unified collision environment provides the union of all member functions of `CollisionRobot` and `CollisionWorld`. Note that calling `checkRobotCollision` of the `CollisionEnv` does not take a `CollisionRobot` as an argument anymore as it is implicitly contained in the `CollisionEnv`. ## ROS Melodic diff --git a/README.md b/README.md index 0ffd0e0e3b..0b330cc1bc 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ -MoveIt! Logo +MoveIt Logo -The MoveIt! Motion Planning Framework +The MoveIt Motion Planning Framework -Currently we support ROS Indigo, Kinetic, and Melodic. +Currently we support ROS Kinetic and Melodic for ROS 1. -- [Overview of MoveIt!](http://moveit.ros.org) +- [Overview of MoveIt](http://moveit.ros.org) - [Installation Instructions](http://moveit.ros.org/install/) - [Documentation](http://moveit.ros.org/documentation/) - [Get Involved](http://moveit.ros.org/documentation/contributing/) @@ -20,43 +20,52 @@ For MoveIt 2.0 development, see [moveit2](https://github.com/ros-planning/moveit ## Continuous Integration Status -service | Indigo | Kinetic | Melodic | Master ----------- | ------ | ------- | ------- | ------ -Travis | [![Build Status](https://travis-ci.org/ros-planning/moveit.svg?branch=indigo-devel)](https://travis-ci.org/ros-planning/moveit/branches) | [![Build Status](https://travis-ci.org/ros-planning/moveit.svg?branch=kinetic-devel)](https://travis-ci.org/ros-planning/moveit/branches) | [![Build Status](https://travis-ci.org/ros-planning/moveit.svg?branch=melodic-devel)](https://travis-ci.org/ros-planning/moveit/branches) | [![Build Status](https://travis-ci.org/ros-planning/moveit.svg?branch=master)](https://travis-ci.org/ros-planning/moveit/branches) | -build farm | [![Build Status](http://build.ros.org/buildStatus/icon?job=Idev__moveit__ubuntu_trusty_amd64)](http://build.ros.org/job/Idev__moveit__ubuntu_trusty_amd64) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Kdev__moveit__ubuntu_xenial_amd64)](http://build.ros.org/job/Kdev__moveit__ubuntu_xenial_amd64) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Mdev__moveit__ubuntu_bionic_amd64)](http://build.ros.org/job/Mdev__moveit__ubuntu_bionic_amd64) | N/A | +service | Kinetic | Melodic | Master +---------- | ------- | ------- | ------ +Travis | [![Build Status](https://travis-ci.org/ros-planning/moveit.svg?branch=kinetic-devel)](https://travis-ci.org/ros-planning/moveit/branches) | [![Build Status](https://travis-ci.org/ros-planning/moveit.svg?branch=melodic-devel)](https://travis-ci.org/ros-planning/moveit/branches) | [![Build Status](https://travis-ci.org/ros-planning/moveit.svg?branch=master)](https://travis-ci.org/ros-planning/moveit/branches) | +build farm | [![Build Status](http://build.ros.org/buildStatus/icon?job=Kdev__moveit__ubuntu_xenial_amd64)](http://build.ros.org/job/Kdev__moveit__ubuntu_xenial_amd64) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Mdev__moveit__ubuntu_bionic_amd64)](http://build.ros.org/job/Mdev__moveit__ubuntu_bionic_amd64) | N/A | +## Licenses + +[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fros-planning%2Fmoveit.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Fros-planning%2Fmoveit?ref=badge_shield) ## Docker Containers [![Docker Build](https://img.shields.io/docker/build/moveit/moveit.svg)](https://hub.docker.com/r/moveit/moveit/builds) [![Docker Automated build](https://img.shields.io/docker/automated/moveit/moveit.svg?maxAge=2592000)](https://hub.docker.com/r/moveit/moveit/) [![Docker Pulls](https://img.shields.io/docker/pulls/moveit/moveit.svg?maxAge=2592000)](https://hub.docker.com/r/moveit/moveit/) [![Docker Stars](https://img.shields.io/docker/stars/moveit/moveit.svg)](https://registry.hub.docker.com/moveit/moveit/) + ## ROS Buildfarm -MoveIt! Package | Indigo Source | Indigo Debian | Kinetic Source | Kinetic Debian | Melodic Source | Melodic Debian ---------------- | ------------- | ------------- | -------------- | -------------- | -------------- | -------------- -moveit | [![Build Status](http://build.ros.org/buildStatus/icon?job=Isrc_uT__moveit__ubuntu_trusty__source)](http://build.ros.org/view/Isrc_uT/job/Isrc_uT__moveit__ubuntu_trusty__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Ibin_uT64__moveit__ubuntu_trusty_amd64__binary)](http://build.ros.org/view/Ibin_uT64/job/Ibin_uT64__moveit__ubuntu_trusty_amd64__binary) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Ksrc_uX__moveit__ubuntu_xenial__source)](http://build.ros.org/view/Ksrc_uX/job/Ksrc_uX__moveit__ubuntu_xenial__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Kbin_uX64__moveit__ubuntu_xenial_amd64__binary)](http://build.ros.org/view/Kbin_uX64/job/Kbin_uX64__moveit__ubuntu_xenial_amd64__binary) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Msrc_uB__moveit__ubuntu_bionic__source)](http://build.ros.org/view/Msrc_uB/job/Msrc_uB__moveit__ubuntu_bionic__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Mbin_uB64__moveit__ubuntu_bionic_amd64__binary)](http://build.ros.org/view/Mbin_uB64/job/Mbin_uB64__moveit__ubuntu_bionic_amd64__binary) -moveit_chomp_optimizer_adapter | | | | | [![Build Status](http://build.ros.org/buildStatus/icon?job=Msrc_uB__moveit_chomp_optimizer_adapter__ubuntu_bionic__source)](http://build.ros.org/view/Msrc_uB/job/Msrc_uB__moveit_chomp_optimizer_adapter__ubuntu_bionic__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Mbin_uB64__moveit_chomp_optimizer_adapter__ubuntu_bionic_amd64__binary)](http://build.ros.org/view/Mbin_uB64/job/Mbin_uB64__moveit_chomp_optimizer_adapter__ubuntu_bionic_amd64__binary) -moveit_commander | [![Build Status](http://build.ros.org/buildStatus/icon?job=Isrc_uT__moveit_commander__ubuntu_trusty__source)](http://build.ros.org/view/Isrc_uT/job/Isrc_uT__moveit_commander__ubuntu_trusty__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Ibin_uT64__moveit_commander__ubuntu_trusty_amd64__binary)](http://build.ros.org/view/Ibin_uT64/job/Ibin_uT64__moveit_commander__ubuntu_trusty_amd64__binary) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Ksrc_uX__moveit_commander__ubuntu_xenial__source)](http://build.ros.org/view/Ksrc_uX/job/Ksrc_uX__moveit_commander__ubuntu_xenial__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Kbin_uX64__moveit_commander__ubuntu_xenial_amd64__binary)](http://build.ros.org/view/Kbin_uX64/job/Kbin_uX64__moveit_commander__ubuntu_xenial_amd64__binary) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Msrc_uB__moveit_commander__ubuntu_bionic__source)](http://build.ros.org/view/Msrc_uB/job/Msrc_uB__moveit_commander__ubuntu_bionic__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Mbin_uB64__moveit_commander__ubuntu_bionic_amd64__binary)](http://build.ros.org/view/Mbin_uB64/job/Mbin_uB64__moveit_commander__ubuntu_bionic_amd64__binary) -moveit_core | [![Build Status](http://build.ros.org/buildStatus/icon?job=Isrc_uT__moveit_core__ubuntu_trusty__source)](http://build.ros.org/view/Isrc_uT/job/Isrc_uT__moveit_core__ubuntu_trusty__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Ibin_uT64__moveit_core__ubuntu_trusty_amd64__binary)](http://build.ros.org/view/Ibin_uT64/job/Ibin_uT64__moveit_core__ubuntu_trusty_amd64__binary) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Ksrc_uX__moveit_core__ubuntu_xenial__source)](http://build.ros.org/view/Ksrc_uX/job/Ksrc_uX__moveit_core__ubuntu_xenial__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Kbin_uX64__moveit_core__ubuntu_xenial_amd64__binary)](http://build.ros.org/view/Kbin_uX64/job/Kbin_uX64__moveit_core__ubuntu_xenial_amd64__binary) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Msrc_uB__moveit_core__ubuntu_bionic__source)](http://build.ros.org/view/Msrc_uB/job/Msrc_uB__moveit_core__ubuntu_bionic__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Mbin_uB64__moveit_core__ubuntu_bionic_amd64__binary)](http://build.ros.org/view/Mbin_uB64/job/Mbin_uB64__moveit_core__ubuntu_bionic_amd64__binary) -moveit_experimental | | | [![Build Status](http://build.ros.org/buildStatus/icon?job=Ksrc_uX__moveit_experimental__ubuntu_xenial__source)](http://build.ros.org/view/Ksrc_uX/job/Ksrc_uX__moveit_experimental__ubuntu_xenial__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Kbin_uX64__moveit_experimental__ubuntu_xenial_amd64__binary)](http://build.ros.org/view/Kbin_uX64/job/Kbin_uX64__moveit_experimental__ubuntu_xenial_amd64__binary) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Msrc_uB__moveit_experimental__ubuntu_bionic__source)](http://build.ros.org/view/Msrc_uB/job/Msrc_uB__moveit_experimental__ubuntu_bionic__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Mbin_uB64__moveit_experimental__ubuntu_bionic_amd64__binary)](http://build.ros.org/view/Mbin_uB64/job/Mbin_uB64__moveit_experimental__ubuntu_bionic_amd64__binary) -moveit_fake_controller_manager | [![Build Status](http://build.ros.org/buildStatus/icon?job=Isrc_uT__moveit_fake_controller_manager__ubuntu_trusty__source)](http://build.ros.org/view/Isrc_uT/job/Isrc_uT__moveit_fake_controller_manager__ubuntu_trusty__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Ibin_uT64__moveit_fake_controller_manager__ubuntu_trusty_amd64__binary)](http://build.ros.org/view/Ibin_uT64/job/Ibin_uT64__moveit_fake_controller_manager__ubuntu_trusty_amd64__binary) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Ksrc_uX__moveit_fake_controller_manager__ubuntu_xenial__source)](http://build.ros.org/view/Ksrc_uX/job/Ksrc_uX__moveit_fake_controller_manager__ubuntu_xenial__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Kbin_uX64__moveit_fake_controller_manager__ubuntu_xenial_amd64__binary)](http://build.ros.org/view/Kbin_uX64/job/Kbin_uX64__moveit_fake_controller_manager__ubuntu_xenial_amd64__binary) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Msrc_uB__moveit_fake_controller_manager__ubuntu_bionic__source)](http://build.ros.org/view/Msrc_uB/job/Msrc_uB__moveit_fake_controller_manager__ubuntu_bionic__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Mbin_uB64__moveit_fake_controller_manager__ubuntu_bionic_amd64__binary)](http://build.ros.org/view/Mbin_uB64/job/Mbin_uB64__moveit_fake_controller_manager__ubuntu_bionic_amd64__binary) -moveit_kinematics | [![Build Status](http://build.ros.org/buildStatus/icon?job=Isrc_uT__moveit_kinematics__ubuntu_trusty__source)](http://build.ros.org/view/Isrc_uT/job/Isrc_uT__moveit_kinematics__ubuntu_trusty__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Ibin_uT64__moveit_kinematics__ubuntu_trusty_amd64__binary)](http://build.ros.org/view/Ibin_uT64/job/Ibin_uT64__moveit_kinematics__ubuntu_trusty_amd64__binary) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Ksrc_uX__moveit_kinematics__ubuntu_xenial__source)](http://build.ros.org/view/Ksrc_uX/job/Ksrc_uX__moveit_kinematics__ubuntu_xenial__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Kbin_uX64__moveit_kinematics__ubuntu_xenial_amd64__binary)](http://build.ros.org/view/Kbin_uX64/job/Kbin_uX64__moveit_kinematics__ubuntu_xenial_amd64__binary) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Msrc_uB__moveit_kinematics__ubuntu_bionic__source)](http://build.ros.org/view/Msrc_uB/job/Msrc_uB__moveit_kinematics__ubuntu_bionic__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Mbin_uB64__moveit_kinematics__ubuntu_bionic_amd64__binary)](http://build.ros.org/view/Mbin_uB64/job/Mbin_uB64__moveit_kinematics__ubuntu_bionic_amd64__binary) -moveit_planners | [![Build Status](http://build.ros.org/buildStatus/icon?job=Isrc_uT__moveit_planners__ubuntu_trusty__source)](http://build.ros.org/view/Isrc_uT/job/Isrc_uT__moveit_planners__ubuntu_trusty__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Ibin_uT64__moveit_planners__ubuntu_trusty_amd64__binary)](http://build.ros.org/view/Ibin_uT64/job/Ibin_uT64__moveit_planners__ubuntu_trusty_amd64__binary) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Ksrc_uX__moveit_planners__ubuntu_xenial__source)](http://build.ros.org/view/Ksrc_uX/job/Ksrc_uX__moveit_planners__ubuntu_xenial__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Kbin_uX64__moveit_planners__ubuntu_xenial_amd64__binary)](http://build.ros.org/view/Kbin_uX64/job/Kbin_uX64__moveit_planners__ubuntu_xenial_amd64__binary) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Msrc_uB__moveit_planners__ubuntu_bionic__source)](http://build.ros.org/view/Msrc_uB/job/Msrc_uB__moveit_planners__ubuntu_bionic__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Mbin_uB64__moveit_planners__ubuntu_bionic_amd64__binary)](http://build.ros.org/view/Mbin_uB64/job/Mbin_uB64__moveit_planners__ubuntu_bionic_amd64__binary) -moveit_planners_chomp | | | [![Build Status](http://build.ros.org/buildStatus/icon?job=Ksrc_uX__moveit_planners_chomp__ubuntu_xenial__source)](http://build.ros.org/view/Ksrc_uX/job/Ksrc_uX__moveit_planners_chomp__ubuntu_xenial__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Kbin_uX64__moveit_planners_chomp__ubuntu_xenial_amd64__binary)](http://build.ros.org/view/Kbin_uX64/job/Kbin_uX64__moveit_planners_chomp__ubuntu_xenial_amd64__binary) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Msrc_uB__moveit_planners_chomp__ubuntu_bionic__source)](http://build.ros.org/view/Msrc_uB/job/Msrc_uB__moveit_planners_chomp__ubuntu_bionic__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Mbin_uB64__moveit_planners_chomp__ubuntu_bionic_amd64__binary)](http://build.ros.org/view/Mbin_uB64/job/Mbin_uB64__moveit_planners_chomp__ubuntu_bionic_amd64__binary) -moveit_planners_ompl | [![Build Status](http://build.ros.org/buildStatus/icon?job=Isrc_uT__moveit_planners_ompl__ubuntu_trusty__source)](http://build.ros.org/view/Isrc_uT/job/Isrc_uT__moveit_planners_ompl__ubuntu_trusty__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Ibin_uT64__moveit_planners_ompl__ubuntu_trusty_amd64__binary)](http://build.ros.org/view/Ibin_uT64/job/Ibin_uT64__moveit_planners_ompl__ubuntu_trusty_amd64__binary) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Ksrc_uX__moveit_planners_ompl__ubuntu_xenial__source)](http://build.ros.org/view/Ksrc_uX/job/Ksrc_uX__moveit_planners_ompl__ubuntu_xenial__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Kbin_uX64__moveit_planners_ompl__ubuntu_xenial_amd64__binary)](http://build.ros.org/view/Kbin_uX64/job/Kbin_uX64__moveit_planners_ompl__ubuntu_xenial_amd64__binary) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Msrc_uB__moveit_planners_ompl__ubuntu_bionic__source)](http://build.ros.org/view/Msrc_uB/job/Msrc_uB__moveit_planners_ompl__ubuntu_bionic__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Mbin_uB64__moveit_planners_ompl__ubuntu_bionic_amd64__binary)](http://build.ros.org/view/Mbin_uB64/job/Mbin_uB64__moveit_planners_ompl__ubuntu_bionic_amd64__binary) -moveit_plugins | [![Build Status](http://build.ros.org/buildStatus/icon?job=Isrc_uT__moveit_plugins__ubuntu_trusty__source)](http://build.ros.org/view/Isrc_uT/job/Isrc_uT__moveit_plugins__ubuntu_trusty__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Ibin_uT64__moveit_plugins__ubuntu_trusty_amd64__binary)](http://build.ros.org/view/Ibin_uT64/job/Ibin_uT64__moveit_plugins__ubuntu_trusty_amd64__binary) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Ksrc_uX__moveit_plugins__ubuntu_xenial__source)](http://build.ros.org/view/Ksrc_uX/job/Ksrc_uX__moveit_plugins__ubuntu_xenial__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Kbin_uX64__moveit_plugins__ubuntu_xenial_amd64__binary)](http://build.ros.org/view/Kbin_uX64/job/Kbin_uX64__moveit_plugins__ubuntu_xenial_amd64__binary) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Msrc_uB__moveit_plugins__ubuntu_bionic__source)](http://build.ros.org/view/Msrc_uB/job/Msrc_uB__moveit_plugins__ubuntu_bionic__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Mbin_uB64__moveit_plugins__ubuntu_bionic_amd64__binary)](http://build.ros.org/view/Mbin_uB64/job/Mbin_uB64__moveit_plugins__ubuntu_bionic_amd64__binary) -moveit_ros | [![Build Status](http://build.ros.org/buildStatus/icon?job=Isrc_uT__moveit_ros__ubuntu_trusty__source)](http://build.ros.org/view/Isrc_uT/job/Isrc_uT__moveit_ros__ubuntu_trusty__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Ibin_uT64__moveit_ros__ubuntu_trusty_amd64__binary)](http://build.ros.org/view/Ibin_uT64/job/Ibin_uT64__moveit_ros__ubuntu_trusty_amd64__binary) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Ksrc_uX__moveit_ros__ubuntu_xenial__source)](http://build.ros.org/view/Ksrc_uX/job/Ksrc_uX__moveit_ros__ubuntu_xenial__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Kbin_uX64__moveit_ros__ubuntu_xenial_amd64__binary)](http://build.ros.org/view/Kbin_uX64/job/Kbin_uX64__moveit_ros__ubuntu_xenial_amd64__binary) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Msrc_uB__moveit_ros__ubuntu_bionic__source)](http://build.ros.org/view/Msrc_uB/job/Msrc_uB__moveit_ros__ubuntu_bionic__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Mbin_uB64__moveit_ros__ubuntu_bionic_amd64__binary)](http://build.ros.org/view/Mbin_uB64/job/Mbin_uB64__moveit_ros__ubuntu_bionic_amd64__binary) -moveit_ros_benchmarks | [![Build Status](http://build.ros.org/buildStatus/icon?job=Isrc_uT__moveit_ros_benchmarks__ubuntu_trusty__source)](http://build.ros.org/view/Isrc_uT/job/Isrc_uT__moveit_ros_benchmarks__ubuntu_trusty__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Ibin_uT64__moveit_ros_benchmarks__ubuntu_trusty_amd64__binary)](http://build.ros.org/view/Ibin_uT64/job/Ibin_uT64__moveit_ros_benchmarks__ubuntu_trusty_amd64__binary) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Ksrc_uX__moveit_ros_benchmarks__ubuntu_xenial__source)](http://build.ros.org/view/Ksrc_uX/job/Ksrc_uX__moveit_ros_benchmarks__ubuntu_xenial__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Kbin_uX64__moveit_ros_benchmarks__ubuntu_xenial_amd64__binary)](http://build.ros.org/view/Kbin_uX64/job/Kbin_uX64__moveit_ros_benchmarks__ubuntu_xenial_amd64__binary) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Msrc_uB__moveit_ros_benchmarks__ubuntu_bionic__source)](http://build.ros.org/view/Msrc_uB/job/Msrc_uB__moveit_ros_benchmarks__ubuntu_bionic__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Mbin_uB64__moveit_ros_benchmarks__ubuntu_bionic_amd64__binary)](http://build.ros.org/view/Mbin_uB64/job/Mbin_uB64__moveit_ros_benchmarks__ubuntu_bionic_amd64__binary) -moveit_ros_control_interface | [![Build Status](http://build.ros.org/buildStatus/icon?job=Isrc_uT__moveit_ros_control_interface__ubuntu_trusty__source)](http://build.ros.org/view/Isrc_uT/job/Isrc_uT__moveit_ros_control_interface__ubuntu_trusty__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Ibin_uT64__moveit_ros_control_interface__ubuntu_trusty_amd64__binary)](http://build.ros.org/view/Ibin_uT64/job/Ibin_uT64__moveit_ros_control_interface__ubuntu_trusty_amd64__binary) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Ksrc_uX__moveit_ros_control_interface__ubuntu_xenial__source)](http://build.ros.org/view/Ksrc_uX/job/Ksrc_uX__moveit_ros_control_interface__ubuntu_xenial__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Kbin_uX64__moveit_ros_control_interface__ubuntu_xenial_amd64__binary)](http://build.ros.org/view/Kbin_uX64/job/Kbin_uX64__moveit_ros_control_interface__ubuntu_xenial_amd64__binary) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Msrc_uB__moveit_ros_control_interface__ubuntu_bionic__source)](http://build.ros.org/view/Msrc_uB/job/Msrc_uB__moveit_ros_control_interface__ubuntu_bionic__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Mbin_uB64__moveit_ros_control_interface__ubuntu_bionic_amd64__binary)](http://build.ros.org/view/Mbin_uB64/job/Mbin_uB64__moveit_ros_control_interface__ubuntu_bionic_amd64__binary) -moveit_ros_manipulation | [![Build Status](http://build.ros.org/buildStatus/icon?job=Isrc_uT__moveit_ros_manipulation__ubuntu_trusty__source)](http://build.ros.org/view/Isrc_uT/job/Isrc_uT__moveit_ros_manipulation__ubuntu_trusty__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Ibin_uT64__moveit_ros_manipulation__ubuntu_trusty_amd64__binary)](http://build.ros.org/view/Ibin_uT64/job/Ibin_uT64__moveit_ros_manipulation__ubuntu_trusty_amd64__binary) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Ksrc_uX__moveit_ros_manipulation__ubuntu_xenial__source)](http://build.ros.org/view/Ksrc_uX/job/Ksrc_uX__moveit_ros_manipulation__ubuntu_xenial__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Kbin_uX64__moveit_ros_manipulation__ubuntu_xenial_amd64__binary)](http://build.ros.org/view/Kbin_uX64/job/Kbin_uX64__moveit_ros_manipulation__ubuntu_xenial_amd64__binary) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Msrc_uB__moveit_ros_manipulation__ubuntu_bionic__source)](http://build.ros.org/view/Msrc_uB/job/Msrc_uB__moveit_ros_manipulation__ubuntu_bionic__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Mbin_uB64__moveit_ros_manipulation__ubuntu_bionic_amd64__binary)](http://build.ros.org/view/Mbin_uB64/job/Mbin_uB64__moveit_ros_manipulation__ubuntu_bionic_amd64__binary) -moveit_ros_move_group | [![Build Status](http://build.ros.org/buildStatus/icon?job=Isrc_uT__moveit_ros_move_group__ubuntu_trusty__source)](http://build.ros.org/view/Isrc_uT/job/Isrc_uT__moveit_ros_move_group__ubuntu_trusty__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Ibin_uT64__moveit_ros_move_group__ubuntu_trusty_amd64__binary)](http://build.ros.org/view/Ibin_uT64/job/Ibin_uT64__moveit_ros_move_group__ubuntu_trusty_amd64__binary) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Ksrc_uX__moveit_ros_move_group__ubuntu_xenial__source)](http://build.ros.org/view/Ksrc_uX/job/Ksrc_uX__moveit_ros_move_group__ubuntu_xenial__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Kbin_uX64__moveit_ros_move_group__ubuntu_xenial_amd64__binary)](http://build.ros.org/view/Kbin_uX64/job/Kbin_uX64__moveit_ros_move_group__ubuntu_xenial_amd64__binary) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Msrc_uB__moveit_ros_move_group__ubuntu_bionic__source)](http://build.ros.org/view/Msrc_uB/job/Msrc_uB__moveit_ros_move_group__ubuntu_bionic__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Mbin_uB64__moveit_ros_move_group__ubuntu_bionic_amd64__binary)](http://build.ros.org/view/Mbin_uB64/job/Mbin_uB64__moveit_ros_move_group__ubuntu_bionic_amd64__binary) -moveit_ros_perception | [![Build Status](http://build.ros.org/buildStatus/icon?job=Isrc_uT__moveit_ros_perception__ubuntu_trusty__source)](http://build.ros.org/view/Isrc_uT/job/Isrc_uT__moveit_ros_perception__ubuntu_trusty__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Ibin_uT64__moveit_ros_perception__ubuntu_trusty_amd64__binary)](http://build.ros.org/view/Ibin_uT64/job/Ibin_uT64__moveit_ros_perception__ubuntu_trusty_amd64__binary) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Ksrc_uX__moveit_ros_perception__ubuntu_xenial__source)](http://build.ros.org/view/Ksrc_uX/job/Ksrc_uX__moveit_ros_perception__ubuntu_xenial__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Kbin_uX64__moveit_ros_perception__ubuntu_xenial_amd64__binary)](http://build.ros.org/view/Kbin_uX64/job/Kbin_uX64__moveit_ros_perception__ubuntu_xenial_amd64__binary) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Msrc_uB__moveit_ros_perception__ubuntu_bionic__source)](http://build.ros.org/view/Msrc_uB/job/Msrc_uB__moveit_ros_perception__ubuntu_bionic__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Mbin_uB64__moveit_ros_perception__ubuntu_bionic_amd64__binary)](http://build.ros.org/view/Mbin_uB64/job/Mbin_uB64__moveit_ros_perception__ubuntu_bionic_amd64__binary) -moveit_ros_planning | [![Build Status](http://build.ros.org/buildStatus/icon?job=Isrc_uT__moveit_ros_planning__ubuntu_trusty__source)](http://build.ros.org/view/Isrc_uT/job/Isrc_uT__moveit_ros_planning__ubuntu_trusty__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Ibin_uT64__moveit_ros_planning__ubuntu_trusty_amd64__binary)](http://build.ros.org/view/Ibin_uT64/job/Ibin_uT64__moveit_ros_planning__ubuntu_trusty_amd64__binary) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Ksrc_uX__moveit_ros_planning__ubuntu_xenial__source)](http://build.ros.org/view/Ksrc_uX/job/Ksrc_uX__moveit_ros_planning__ubuntu_xenial__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Kbin_uX64__moveit_ros_planning__ubuntu_xenial_amd64__binary)](http://build.ros.org/view/Kbin_uX64/job/Kbin_uX64__moveit_ros_planning__ubuntu_xenial_amd64__binary) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Msrc_uB__moveit_ros_planning__ubuntu_bionic__source)](http://build.ros.org/view/Msrc_uB/job/Msrc_uB__moveit_ros_planning__ubuntu_bionic__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Mbin_uB64__moveit_ros_planning__ubuntu_bionic_amd64__binary)](http://build.ros.org/view/Mbin_uB64/job/Mbin_uB64__moveit_ros_planning__ubuntu_bionic_amd64__binary) -moveit_ros_planning_interface | [![Build Status](http://build.ros.org/buildStatus/icon?job=Isrc_uT__moveit_ros_planning_interface__ubuntu_trusty__source)](http://build.ros.org/view/Isrc_uT/job/Isrc_uT__moveit_ros_planning_interface__ubuntu_trusty__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Ibin_uT64__moveit_ros_planning_interface__ubuntu_trusty_amd64__binary)](http://build.ros.org/view/Ibin_uT64/job/Ibin_uT64__moveit_ros_planning_interface__ubuntu_trusty_amd64__binary) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Ksrc_uX__moveit_ros_planning_interface__ubuntu_xenial__source)](http://build.ros.org/view/Ksrc_uX/job/Ksrc_uX__moveit_ros_planning_interface__ubuntu_xenial__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Kbin_uX64__moveit_ros_planning_interface__ubuntu_xenial_amd64__binary)](http://build.ros.org/view/Kbin_uX64/job/Kbin_uX64__moveit_ros_planning_interface__ubuntu_xenial_amd64__binary) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Msrc_uB__moveit_ros_planning_interface__ubuntu_bionic__source)](http://build.ros.org/view/Msrc_uB/job/Msrc_uB__moveit_ros_planning_interface__ubuntu_bionic__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Mbin_uB64__moveit_ros_planning_interface__ubuntu_bionic_amd64__binary)](http://build.ros.org/view/Mbin_uB64/job/Mbin_uB64__moveit_ros_planning_interface__ubuntu_bionic_amd64__binary) -moveit_ros_robot_interaction | [![Build Status](http://build.ros.org/buildStatus/icon?job=Isrc_uT__moveit_ros_robot_interaction__ubuntu_trusty__source)](http://build.ros.org/view/Isrc_uT/job/Isrc_uT__moveit_ros_robot_interaction__ubuntu_trusty__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Ibin_uT64__moveit_ros_robot_interaction__ubuntu_trusty_amd64__binary)](http://build.ros.org/view/Ibin_uT64/job/Ibin_uT64__moveit_ros_robot_interaction__ubuntu_trusty_amd64__binary) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Ksrc_uX__moveit_ros_robot_interaction__ubuntu_xenial__source)](http://build.ros.org/view/Ksrc_uX/job/Ksrc_uX__moveit_ros_robot_interaction__ubuntu_xenial__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Kbin_uX64__moveit_ros_robot_interaction__ubuntu_xenial_amd64__binary)](http://build.ros.org/view/Kbin_uX64/job/Kbin_uX64__moveit_ros_robot_interaction__ubuntu_xenial_amd64__binary) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Msrc_uB__moveit_ros_robot_interaction__ubuntu_bionic__source)](http://build.ros.org/view/Msrc_uB/job/Msrc_uB__moveit_ros_robot_interaction__ubuntu_bionic__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Mbin_uB64__moveit_ros_robot_interaction__ubuntu_bionic_amd64__binary)](http://build.ros.org/view/Mbin_uB64/job/Mbin_uB64__moveit_ros_robot_interaction__ubuntu_bionic_amd64__binary) -moveit_ros_visualization | [![Build Status](http://build.ros.org/buildStatus/icon?job=Isrc_uT__moveit_ros_visualization__ubuntu_trusty__source)](http://build.ros.org/view/Isrc_uT/job/Isrc_uT__moveit_ros_visualization__ubuntu_trusty__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Ibin_uT64__moveit_ros_visualization__ubuntu_trusty_amd64__binary)](http://build.ros.org/view/Ibin_uT64/job/Ibin_uT64__moveit_ros_visualization__ubuntu_trusty_amd64__binary) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Ksrc_uX__moveit_ros_visualization__ubuntu_xenial__source)](http://build.ros.org/view/Ksrc_uX/job/Ksrc_uX__moveit_ros_visualization__ubuntu_xenial__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Kbin_uX64__moveit_ros_visualization__ubuntu_xenial_amd64__binary)](http://build.ros.org/view/Kbin_uX64/job/Kbin_uX64__moveit_ros_visualization__ubuntu_xenial_amd64__binary) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Msrc_uB__moveit_ros_visualization__ubuntu_bionic__source)](http://build.ros.org/view/Msrc_uB/job/Msrc_uB__moveit_ros_visualization__ubuntu_bionic__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Mbin_uB64__moveit_ros_visualization__ubuntu_bionic_amd64__binary)](http://build.ros.org/view/Mbin_uB64/job/Mbin_uB64__moveit_ros_visualization__ubuntu_bionic_amd64__binary) -moveit_ros_warehouse | [![Build Status](http://build.ros.org/buildStatus/icon?job=Isrc_uT__moveit_ros_warehouse__ubuntu_trusty__source)](http://build.ros.org/view/Isrc_uT/job/Isrc_uT__moveit_ros_warehouse__ubuntu_trusty__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Ibin_uT64__moveit_ros_warehouse__ubuntu_trusty_amd64__binary)](http://build.ros.org/view/Ibin_uT64/job/Ibin_uT64__moveit_ros_warehouse__ubuntu_trusty_amd64__binary) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Ksrc_uX__moveit_ros_warehouse__ubuntu_xenial__source)](http://build.ros.org/view/Ksrc_uX/job/Ksrc_uX__moveit_ros_warehouse__ubuntu_xenial__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Kbin_uX64__moveit_ros_warehouse__ubuntu_xenial_amd64__binary)](http://build.ros.org/view/Kbin_uX64/job/Kbin_uX64__moveit_ros_warehouse__ubuntu_xenial_amd64__binary) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Msrc_uB__moveit_ros_warehouse__ubuntu_bionic__source)](http://build.ros.org/view/Msrc_uB/job/Msrc_uB__moveit_ros_warehouse__ubuntu_bionic__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Mbin_uB64__moveit_ros_warehouse__ubuntu_bionic_amd64__binary)](http://build.ros.org/view/Mbin_uB64/job/Mbin_uB64__moveit_ros_warehouse__ubuntu_bionic_amd64__binary) -moveit_runtime | [![Build Status](http://build.ros.org/buildStatus/icon?job=Isrc_uT__moveit_runtime__ubuntu_trusty__source)](http://build.ros.org/view/Isrc_uT/job/Isrc_uT__moveit_runtime__ubuntu_trusty__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Ibin_uT64__moveit_runtime__ubuntu_trusty_amd64__binary)](http://build.ros.org/view/Ibin_uT64/job/Ibin_uT64__moveit_runtime__ubuntu_trusty_amd64__binary) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Ksrc_uX__moveit_runtime__ubuntu_xenial__source)](http://build.ros.org/view/Ksrc_uX/job/Ksrc_uX__moveit_runtime__ubuntu_xenial__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Kbin_uX64__moveit_runtime__ubuntu_xenial_amd64__binary)](http://build.ros.org/view/Kbin_uX64/job/Kbin_uX64__moveit_runtime__ubuntu_xenial_amd64__binary) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Msrc_uB__moveit_runtime__ubuntu_bionic__source)](http://build.ros.org/view/Msrc_uB/job/Msrc_uB__moveit_runtime__ubuntu_bionic__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Mbin_uB64__moveit_runtime__ubuntu_bionic_amd64__binary)](http://build.ros.org/view/Mbin_uB64/job/Mbin_uB64__moveit_runtime__ubuntu_bionic_amd64__binary) -moveit_setup_assistant | [![Build Status](http://build.ros.org/buildStatus/icon?job=Isrc_uT__moveit_setup_assistant__ubuntu_trusty__source)](http://build.ros.org/view/Isrc_uT/job/Isrc_uT__moveit_setup_assistant__ubuntu_trusty__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Ibin_uT64__moveit_setup_assistant__ubuntu_trusty_amd64__binary)](http://build.ros.org/view/Ibin_uT64/job/Ibin_uT64__moveit_setup_assistant__ubuntu_trusty_amd64__binary) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Ksrc_uX__moveit_setup_assistant__ubuntu_xenial__source)](http://build.ros.org/view/Ksrc_uX/job/Ksrc_uX__moveit_setup_assistant__ubuntu_xenial__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Kbin_uX64__moveit_setup_assistant__ubuntu_xenial_amd64__binary)](http://build.ros.org/view/Kbin_uX64/job/Kbin_uX64__moveit_setup_assistant__ubuntu_xenial_amd64__binary) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Msrc_uB__moveit_setup_assistant__ubuntu_bionic__source)](http://build.ros.org/view/Msrc_uB/job/Msrc_uB__moveit_setup_assistant__ubuntu_bionic__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Mbin_uB64__moveit_setup_assistant__ubuntu_bionic_amd64__binary)](http://build.ros.org/view/Mbin_uB64/job/Mbin_uB64__moveit_setup_assistant__ubuntu_bionic_amd64__binary) -moveit_simple_controller_manager | [![Build Status](http://build.ros.org/buildStatus/icon?job=Isrc_uT__moveit_simple_controller_manager__ubuntu_trusty__source)](http://build.ros.org/view/Isrc_uT/job/Isrc_uT__moveit_simple_controller_manager__ubuntu_trusty__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Ibin_uT64__moveit_simple_controller_manager__ubuntu_trusty_amd64__binary)](http://build.ros.org/view/Ibin_uT64/job/Ibin_uT64__moveit_simple_controller_manager__ubuntu_trusty_amd64__binary) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Ksrc_uX__moveit_simple_controller_manager__ubuntu_xenial__source)](http://build.ros.org/view/Ksrc_uX/job/Ksrc_uX__moveit_simple_controller_manager__ubuntu_xenial__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Kbin_uX64__moveit_simple_controller_manager__ubuntu_xenial_amd64__binary)](http://build.ros.org/view/Kbin_uX64/job/Kbin_uX64__moveit_simple_controller_manager__ubuntu_xenial_amd64__binary) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Msrc_uB__moveit_simple_controller_manager__ubuntu_bionic__source)](http://build.ros.org/view/Msrc_uB/job/Msrc_uB__moveit_simple_controller_manager__ubuntu_bionic__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Mbin_uB64__moveit_simple_controller_manager__ubuntu_bionic_amd64__binary)](http://build.ros.org/view/Mbin_uB64/job/Mbin_uB64__moveit_simple_controller_manager__ubuntu_bionic_amd64__binary) -chomp_motion_planner | | | [![Build Status](http://build.ros.org/buildStatus/icon?job=Ksrc_uX__chomp_motion_planner__ubuntu_xenial__source)](http://build.ros.org/view/Ksrc_uX/job/Ksrc_uX__chomp_motion_planner__ubuntu_xenial__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Kbin_uX64__chomp_motion_planner__ubuntu_xenial_amd64__binary)](http://build.ros.org/view/Kbin_uX64/job/Kbin_uX64__chomp_motion_planner__ubuntu_xenial_amd64__binary) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Msrc_uB__chomp_motion_planner__ubuntu_bionic__source)](http://build.ros.org/view/Msrc_uB/job/Msrc_uB__chomp_motion_planner__ubuntu_bionic__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Mbin_uB64__chomp_motion_planner__ubuntu_bionic_amd64__binary)](http://build.ros.org/view/Mbin_uB64/job/Mbin_uB64__chomp_motion_planner__ubuntu_bionic_amd64__binary) +MoveIt Package | Kinetic Source | Kinetic Debian | Melodic Source | Melodic Debian +--------------- | -------------- | -------------- | -------------- | -------------- +moveit | [![Build Status](http://build.ros.org/buildStatus/icon?job=Ksrc_uX__moveit__ubuntu_xenial__source)](http://build.ros.org/view/Ksrc_uX/job/Ksrc_uX__moveit__ubuntu_xenial__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Kbin_uX64__moveit__ubuntu_xenial_amd64__binary)](http://build.ros.org/view/Kbin_uX64/job/Kbin_uX64__moveit__ubuntu_xenial_amd64__binary) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Msrc_uB__moveit__ubuntu_bionic__source)](http://build.ros.org/view/Msrc_uB/job/Msrc_uB__moveit__ubuntu_bionic__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Mbin_uB64__moveit__ubuntu_bionic_amd64__binary)](http://build.ros.org/view/Mbin_uB64/job/Mbin_uB64__moveit__ubuntu_bionic_amd64__binary) +moveit_chomp_optimizer_adapter | [![Build Status](http://build.ros.org/buildStatus/icon?job=Ksrc_uX__moveit_chomp_optimizer_adapter__ubuntu_xenial__source)](http://build.ros.org/view/Ksrc_uX/job/Ksrc_uX__moveit_chomp_optimizer_adapter__ubuntu_xenial__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Kbin_uX64__moveit_chomp_optimizer_adapter__ubuntu_xenial_amd64__binary)](http://build.ros.org/view/Kbin_uX64/job/Kbin_uX64__moveit_chomp_optimizer_adapter__ubuntu_xenial_amd64__binary) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Msrc_uB__moveit_chomp_optimizer_adapter__ubuntu_bionic__source)](http://build.ros.org/view/Msrc_uB/job/Msrc_uB__moveit_chomp_optimizer_adapter__ubuntu_bionic__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Mbin_uB64__moveit_chomp_optimizer_adapter__ubuntu_bionic_amd64__binary)](http://build.ros.org/view/Mbin_uB64/job/Mbin_uB64__moveit_chomp_optimizer_adapter__ubuntu_bionic_amd64__binary) +moveit_commander | [![Build Status](http://build.ros.org/buildStatus/icon?job=Ksrc_uX__moveit_commander__ubuntu_xenial__source)](http://build.ros.org/view/Ksrc_uX/job/Ksrc_uX__moveit_commander__ubuntu_xenial__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Kbin_uX64__moveit_commander__ubuntu_xenial_amd64__binary)](http://build.ros.org/view/Kbin_uX64/job/Kbin_uX64__moveit_commander__ubuntu_xenial_amd64__binary) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Msrc_uB__moveit_commander__ubuntu_bionic__source)](http://build.ros.org/view/Msrc_uB/job/Msrc_uB__moveit_commander__ubuntu_bionic__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Mbin_uB64__moveit_commander__ubuntu_bionic_amd64__binary)](http://build.ros.org/view/Mbin_uB64/job/Mbin_uB64__moveit_commander__ubuntu_bionic_amd64__binary) +moveit_core | [![Build Status](http://build.ros.org/buildStatus/icon?job=Ksrc_uX__moveit_core__ubuntu_xenial__source)](http://build.ros.org/view/Ksrc_uX/job/Ksrc_uX__moveit_core__ubuntu_xenial__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Kbin_uX64__moveit_core__ubuntu_xenial_amd64__binary)](http://build.ros.org/view/Kbin_uX64/job/Kbin_uX64__moveit_core__ubuntu_xenial_amd64__binary) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Msrc_uB__moveit_core__ubuntu_bionic__source)](http://build.ros.org/view/Msrc_uB/job/Msrc_uB__moveit_core__ubuntu_bionic__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Mbin_uB64__moveit_core__ubuntu_bionic_amd64__binary)](http://build.ros.org/view/Mbin_uB64/job/Mbin_uB64__moveit_core__ubuntu_bionic_amd64__binary) +moveit_experimental | [![Build Status](http://build.ros.org/buildStatus/icon?job=Ksrc_uX__moveit_experimental__ubuntu_xenial__source)](http://build.ros.org/view/Ksrc_uX/job/Ksrc_uX__moveit_experimental__ubuntu_xenial__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Kbin_uX64__moveit_experimental__ubuntu_xenial_amd64__binary)](http://build.ros.org/view/Kbin_uX64/job/Kbin_uX64__moveit_experimental__ubuntu_xenial_amd64__binary) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Msrc_uB__moveit_experimental__ubuntu_bionic__source)](http://build.ros.org/view/Msrc_uB/job/Msrc_uB__moveit_experimental__ubuntu_bionic__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Mbin_uB64__moveit_experimental__ubuntu_bionic_amd64__binary)](http://build.ros.org/view/Mbin_uB64/job/Mbin_uB64__moveit_experimental__ubuntu_bionic_amd64__binary) +moveit_fake_controller_manager | [![Build Status](http://build.ros.org/buildStatus/icon?job=Ksrc_uX__moveit_fake_controller_manager__ubuntu_xenial__source)](http://build.ros.org/view/Ksrc_uX/job/Ksrc_uX__moveit_fake_controller_manager__ubuntu_xenial__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Kbin_uX64__moveit_fake_controller_manager__ubuntu_xenial_amd64__binary)](http://build.ros.org/view/Kbin_uX64/job/Kbin_uX64__moveit_fake_controller_manager__ubuntu_xenial_amd64__binary) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Msrc_uB__moveit_fake_controller_manager__ubuntu_bionic__source)](http://build.ros.org/view/Msrc_uB/job/Msrc_uB__moveit_fake_controller_manager__ubuntu_bionic__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Mbin_uB64__moveit_fake_controller_manager__ubuntu_bionic_amd64__binary)](http://build.ros.org/view/Mbin_uB64/job/Mbin_uB64__moveit_fake_controller_manager__ubuntu_bionic_amd64__binary) +moveit_kinematics | [![Build Status](http://build.ros.org/buildStatus/icon?job=Ksrc_uX__moveit_kinematics__ubuntu_xenial__source)](http://build.ros.org/view/Ksrc_uX/job/Ksrc_uX__moveit_kinematics__ubuntu_xenial__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Kbin_uX64__moveit_kinematics__ubuntu_xenial_amd64__binary)](http://build.ros.org/view/Kbin_uX64/job/Kbin_uX64__moveit_kinematics__ubuntu_xenial_amd64__binary) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Msrc_uB__moveit_kinematics__ubuntu_bionic__source)](http://build.ros.org/view/Msrc_uB/job/Msrc_uB__moveit_kinematics__ubuntu_bionic__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Mbin_uB64__moveit_kinematics__ubuntu_bionic_amd64__binary)](http://build.ros.org/view/Mbin_uB64/job/Mbin_uB64__moveit_kinematics__ubuntu_bionic_amd64__binary) +moveit_msgs | [![Build Status](http://build.ros.org/buildStatus/icon?job=Ksrc_uX__moveit_msgs__ubuntu_xenial__source)](http://build.ros.org/view/Ksrc_uX/job/Ksrc_uX__moveit_msgs__ubuntu_xenial__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Kbin_uX64__moveit_msgs__ubuntu_xenial_amd64__binary)](http://build.ros.org/view/Kbin_uX64/job/Kbin_uX64__moveit_msgs__ubuntu_xenial_amd64__binary) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Msrc_uB__moveit_msgs__ubuntu_bionic__source)](http://build.ros.org/view/Msrc_uB/job/Msrc_uB__moveit_msgs__ubuntu_bionic__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Mbin_uB64__moveit_msgs__ubuntu_bionic_amd64__binary)](http://build.ros.org/view/Mbin_uB64/job/Mbin_uB64__moveit_msgs__ubuntu_bionic_amd64__binary) +moveit_planners | [![Build Status](http://build.ros.org/buildStatus/icon?job=Ksrc_uX__moveit_planners__ubuntu_xenial__source)](http://build.ros.org/view/Ksrc_uX/job/Ksrc_uX__moveit_planners__ubuntu_xenial__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Kbin_uX64__moveit_planners__ubuntu_xenial_amd64__binary)](http://build.ros.org/view/Kbin_uX64/job/Kbin_uX64__moveit_planners__ubuntu_xenial_amd64__binary) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Msrc_uB__moveit_planners__ubuntu_bionic__source)](http://build.ros.org/view/Msrc_uB/job/Msrc_uB__moveit_planners__ubuntu_bionic__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Mbin_uB64__moveit_planners__ubuntu_bionic_amd64__binary)](http://build.ros.org/view/Mbin_uB64/job/Mbin_uB64__moveit_planners__ubuntu_bionic_amd64__binary) +moveit_planners_chomp | [![Build Status](http://build.ros.org/buildStatus/icon?job=Ksrc_uX__moveit_planners_chomp__ubuntu_xenial__source)](http://build.ros.org/view/Ksrc_uX/job/Ksrc_uX__moveit_planners_chomp__ubuntu_xenial__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Kbin_uX64__moveit_planners_chomp__ubuntu_xenial_amd64__binary)](http://build.ros.org/view/Kbin_uX64/job/Kbin_uX64__moveit_planners_chomp__ubuntu_xenial_amd64__binary) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Msrc_uB__moveit_planners_chomp__ubuntu_bionic__source)](http://build.ros.org/view/Msrc_uB/job/Msrc_uB__moveit_planners_chomp__ubuntu_bionic__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Mbin_uB64__moveit_planners_chomp__ubuntu_bionic_amd64__binary)](http://build.ros.org/view/Mbin_uB64/job/Mbin_uB64__moveit_planners_chomp__ubuntu_bionic_amd64__binary) +moveit_planners_ompl | [![Build Status](http://build.ros.org/buildStatus/icon?job=Ksrc_uX__moveit_planners_ompl__ubuntu_xenial__source)](http://build.ros.org/view/Ksrc_uX/job/Ksrc_uX__moveit_planners_ompl__ubuntu_xenial__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Kbin_uX64__moveit_planners_ompl__ubuntu_xenial_amd64__binary)](http://build.ros.org/view/Kbin_uX64/job/Kbin_uX64__moveit_planners_ompl__ubuntu_xenial_amd64__binary) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Msrc_uB__moveit_planners_ompl__ubuntu_bionic__source)](http://build.ros.org/view/Msrc_uB/job/Msrc_uB__moveit_planners_ompl__ubuntu_bionic__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Mbin_uB64__moveit_planners_ompl__ubuntu_bionic_amd64__binary)](http://build.ros.org/view/Mbin_uB64/job/Mbin_uB64__moveit_planners_ompl__ubuntu_bionic_amd64__binary) +moveit_plugins | [![Build Status](http://build.ros.org/buildStatus/icon?job=Ksrc_uX__moveit_plugins__ubuntu_xenial__source)](http://build.ros.org/view/Ksrc_uX/job/Ksrc_uX__moveit_plugins__ubuntu_xenial__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Kbin_uX64__moveit_plugins__ubuntu_xenial_amd64__binary)](http://build.ros.org/view/Kbin_uX64/job/Kbin_uX64__moveit_plugins__ubuntu_xenial_amd64__binary) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Msrc_uB__moveit_plugins__ubuntu_bionic__source)](http://build.ros.org/view/Msrc_uB/job/Msrc_uB__moveit_plugins__ubuntu_bionic__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Mbin_uB64__moveit_plugins__ubuntu_bionic_amd64__binary)](http://build.ros.org/view/Mbin_uB64/job/Mbin_uB64__moveit_plugins__ubuntu_bionic_amd64__binary) +moveit_resources | [![Build Status](http://build.ros.org/buildStatus/icon?job=Ksrc_uX__moveit_resources__ubuntu_xenial__source)](http://build.ros.org/view/Ksrc_uX/job/Ksrc_uX__moveit_resources__ubuntu_xenial__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Kbin_uX64__moveit_resources__ubuntu_xenial_amd64__binary)](http://build.ros.org/view/Kbin_uX64/job/Kbin_uX64__moveit_resources__ubuntu_xenial_amd64__binary) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Msrc_uB__moveit_resources__ubuntu_bionic__source)](http://build.ros.org/view/Msrc_uB/job/Msrc_uB__moveit_resources__ubuntu_bionic__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Mbin_uB64__moveit_resources__ubuntu_bionic_amd64__binary)](http://build.ros.org/view/Mbin_uB64/job/Mbin_uB64__moveit_resources__ubuntu_bionic_amd64__binary) +moveit_ros | [![Build Status](http://build.ros.org/buildStatus/icon?job=Ksrc_uX__moveit_ros__ubuntu_xenial__source)](http://build.ros.org/view/Ksrc_uX/job/Ksrc_uX__moveit_ros__ubuntu_xenial__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Kbin_uX64__moveit_ros__ubuntu_xenial_amd64__binary)](http://build.ros.org/view/Kbin_uX64/job/Kbin_uX64__moveit_ros__ubuntu_xenial_amd64__binary) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Msrc_uB__moveit_ros__ubuntu_bionic__source)](http://build.ros.org/view/Msrc_uB/job/Msrc_uB__moveit_ros__ubuntu_bionic__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Mbin_uB64__moveit_ros__ubuntu_bionic_amd64__binary)](http://build.ros.org/view/Mbin_uB64/job/Mbin_uB64__moveit_ros__ubuntu_bionic_amd64__binary) +moveit_ros_benchmarks | [![Build Status](http://build.ros.org/buildStatus/icon?job=Ksrc_uX__moveit_ros_benchmarks__ubuntu_xenial__source)](http://build.ros.org/view/Ksrc_uX/job/Ksrc_uX__moveit_ros_benchmarks__ubuntu_xenial__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Kbin_uX64__moveit_ros_benchmarks__ubuntu_xenial_amd64__binary)](http://build.ros.org/view/Kbin_uX64/job/Kbin_uX64__moveit_ros_benchmarks__ubuntu_xenial_amd64__binary) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Msrc_uB__moveit_ros_benchmarks__ubuntu_bionic__source)](http://build.ros.org/view/Msrc_uB/job/Msrc_uB__moveit_ros_benchmarks__ubuntu_bionic__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Mbin_uB64__moveit_ros_benchmarks__ubuntu_bionic_amd64__binary)](http://build.ros.org/view/Mbin_uB64/job/Mbin_uB64__moveit_ros_benchmarks__ubuntu_bionic_amd64__binary) +moveit_ros_control_interface | [![Build Status](http://build.ros.org/buildStatus/icon?job=Ksrc_uX__moveit_ros_control_interface__ubuntu_xenial__source)](http://build.ros.org/view/Ksrc_uX/job/Ksrc_uX__moveit_ros_control_interface__ubuntu_xenial__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Kbin_uX64__moveit_ros_control_interface__ubuntu_xenial_amd64__binary)](http://build.ros.org/view/Kbin_uX64/job/Kbin_uX64__moveit_ros_control_interface__ubuntu_xenial_amd64__binary) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Msrc_uB__moveit_ros_control_interface__ubuntu_bionic__source)](http://build.ros.org/view/Msrc_uB/job/Msrc_uB__moveit_ros_control_interface__ubuntu_bionic__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Mbin_uB64__moveit_ros_control_interface__ubuntu_bionic_amd64__binary)](http://build.ros.org/view/Mbin_uB64/job/Mbin_uB64__moveit_ros_control_interface__ubuntu_bionic_amd64__binary) +moveit_ros_manipulation | [![Build Status](http://build.ros.org/buildStatus/icon?job=Ksrc_uX__moveit_ros_manipulation__ubuntu_xenial__source)](http://build.ros.org/view/Ksrc_uX/job/Ksrc_uX__moveit_ros_manipulation__ubuntu_xenial__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Kbin_uX64__moveit_ros_manipulation__ubuntu_xenial_amd64__binary)](http://build.ros.org/view/Kbin_uX64/job/Kbin_uX64__moveit_ros_manipulation__ubuntu_xenial_amd64__binary) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Msrc_uB__moveit_ros_manipulation__ubuntu_bionic__source)](http://build.ros.org/view/Msrc_uB/job/Msrc_uB__moveit_ros_manipulation__ubuntu_bionic__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Mbin_uB64__moveit_ros_manipulation__ubuntu_bionic_amd64__binary)](http://build.ros.org/view/Mbin_uB64/job/Mbin_uB64__moveit_ros_manipulation__ubuntu_bionic_amd64__binary) +moveit_ros_move_group | [![Build Status](http://build.ros.org/buildStatus/icon?job=Ksrc_uX__moveit_ros_move_group__ubuntu_xenial__source)](http://build.ros.org/view/Ksrc_uX/job/Ksrc_uX__moveit_ros_move_group__ubuntu_xenial__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Kbin_uX64__moveit_ros_move_group__ubuntu_xenial_amd64__binary)](http://build.ros.org/view/Kbin_uX64/job/Kbin_uX64__moveit_ros_move_group__ubuntu_xenial_amd64__binary) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Msrc_uB__moveit_ros_move_group__ubuntu_bionic__source)](http://build.ros.org/view/Msrc_uB/job/Msrc_uB__moveit_ros_move_group__ubuntu_bionic__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Mbin_uB64__moveit_ros_move_group__ubuntu_bionic_amd64__binary)](http://build.ros.org/view/Mbin_uB64/job/Mbin_uB64__moveit_ros_move_group__ubuntu_bionic_amd64__binary) +moveit_ros_perception | [![Build Status](http://build.ros.org/buildStatus/icon?job=Ksrc_uX__moveit_ros_perception__ubuntu_xenial__source)](http://build.ros.org/view/Ksrc_uX/job/Ksrc_uX__moveit_ros_perception__ubuntu_xenial__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Kbin_uX64__moveit_ros_perception__ubuntu_xenial_amd64__binary)](http://build.ros.org/view/Kbin_uX64/job/Kbin_uX64__moveit_ros_perception__ubuntu_xenial_amd64__binary) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Msrc_uB__moveit_ros_perception__ubuntu_bionic__source)](http://build.ros.org/view/Msrc_uB/job/Msrc_uB__moveit_ros_perception__ubuntu_bionic__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Mbin_uB64__moveit_ros_perception__ubuntu_bionic_amd64__binary)](http://build.ros.org/view/Mbin_uB64/job/Mbin_uB64__moveit_ros_perception__ubuntu_bionic_amd64__binary) +moveit_ros_planning | [![Build Status](http://build.ros.org/buildStatus/icon?job=Ksrc_uX__moveit_ros_planning__ubuntu_xenial__source)](http://build.ros.org/view/Ksrc_uX/job/Ksrc_uX__moveit_ros_planning__ubuntu_xenial__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Kbin_uX64__moveit_ros_planning__ubuntu_xenial_amd64__binary)](http://build.ros.org/view/Kbin_uX64/job/Kbin_uX64__moveit_ros_planning__ubuntu_xenial_amd64__binary) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Msrc_uB__moveit_ros_planning__ubuntu_bionic__source)](http://build.ros.org/view/Msrc_uB/job/Msrc_uB__moveit_ros_planning__ubuntu_bionic__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Mbin_uB64__moveit_ros_planning__ubuntu_bionic_amd64__binary)](http://build.ros.org/view/Mbin_uB64/job/Mbin_uB64__moveit_ros_planning__ubuntu_bionic_amd64__binary) +moveit_ros_planning_interface | [![Build Status](http://build.ros.org/buildStatus/icon?job=Ksrc_uX__moveit_ros_planning_interface__ubuntu_xenial__source)](http://build.ros.org/view/Ksrc_uX/job/Ksrc_uX__moveit_ros_planning_interface__ubuntu_xenial__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Kbin_uX64__moveit_ros_planning_interface__ubuntu_xenial_amd64__binary)](http://build.ros.org/view/Kbin_uX64/job/Kbin_uX64__moveit_ros_planning_interface__ubuntu_xenial_amd64__binary) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Msrc_uB__moveit_ros_planning_interface__ubuntu_bionic__source)](http://build.ros.org/view/Msrc_uB/job/Msrc_uB__moveit_ros_planning_interface__ubuntu_bionic__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Mbin_uB64__moveit_ros_planning_interface__ubuntu_bionic_amd64__binary)](http://build.ros.org/view/Mbin_uB64/job/Mbin_uB64__moveit_ros_planning_interface__ubuntu_bionic_amd64__binary) +moveit_ros_robot_interaction | [![Build Status](http://build.ros.org/buildStatus/icon?job=Ksrc_uX__moveit_ros_robot_interaction__ubuntu_xenial__source)](http://build.ros.org/view/Ksrc_uX/job/Ksrc_uX__moveit_ros_robot_interaction__ubuntu_xenial__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Kbin_uX64__moveit_ros_robot_interaction__ubuntu_xenial_amd64__binary)](http://build.ros.org/view/Kbin_uX64/job/Kbin_uX64__moveit_ros_robot_interaction__ubuntu_xenial_amd64__binary) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Msrc_uB__moveit_ros_robot_interaction__ubuntu_bionic__source)](http://build.ros.org/view/Msrc_uB/job/Msrc_uB__moveit_ros_robot_interaction__ubuntu_bionic__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Mbin_uB64__moveit_ros_robot_interaction__ubuntu_bionic_amd64__binary)](http://build.ros.org/view/Mbin_uB64/job/Mbin_uB64__moveit_ros_robot_interaction__ubuntu_bionic_amd64__binary) +moveit_ros_visualization | [![Build Status](http://build.ros.org/buildStatus/icon?job=Ksrc_uX__moveit_ros_visualization__ubuntu_xenial__source)](http://build.ros.org/view/Ksrc_uX/job/Ksrc_uX__moveit_ros_visualization__ubuntu_xenial__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Kbin_uX64__moveit_ros_visualization__ubuntu_xenial_amd64__binary)](http://build.ros.org/view/Kbin_uX64/job/Kbin_uX64__moveit_ros_visualization__ubuntu_xenial_amd64__binary) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Msrc_uB__moveit_ros_visualization__ubuntu_bionic__source)](http://build.ros.org/view/Msrc_uB/job/Msrc_uB__moveit_ros_visualization__ubuntu_bionic__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Mbin_uB64__moveit_ros_visualization__ubuntu_bionic_amd64__binary)](http://build.ros.org/view/Mbin_uB64/job/Mbin_uB64__moveit_ros_visualization__ubuntu_bionic_amd64__binary) +moveit_ros_warehouse | [![Build Status](http://build.ros.org/buildStatus/icon?job=Ksrc_uX__moveit_ros_warehouse__ubuntu_xenial__source)](http://build.ros.org/view/Ksrc_uX/job/Ksrc_uX__moveit_ros_warehouse__ubuntu_xenial__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Kbin_uX64__moveit_ros_warehouse__ubuntu_xenial_amd64__binary)](http://build.ros.org/view/Kbin_uX64/job/Kbin_uX64__moveit_ros_warehouse__ubuntu_xenial_amd64__binary) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Msrc_uB__moveit_ros_warehouse__ubuntu_bionic__source)](http://build.ros.org/view/Msrc_uB/job/Msrc_uB__moveit_ros_warehouse__ubuntu_bionic__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Mbin_uB64__moveit_ros_warehouse__ubuntu_bionic_amd64__binary)](http://build.ros.org/view/Mbin_uB64/job/Mbin_uB64__moveit_ros_warehouse__ubuntu_bionic_amd64__binary) +moveit_runtime | [![Build Status](http://build.ros.org/buildStatus/icon?job=Ksrc_uX__moveit_runtime__ubuntu_xenial__source)](http://build.ros.org/view/Ksrc_uX/job/Ksrc_uX__moveit_runtime__ubuntu_xenial__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Kbin_uX64__moveit_runtime__ubuntu_xenial_amd64__binary)](http://build.ros.org/view/Kbin_uX64/job/Kbin_uX64__moveit_runtime__ubuntu_xenial_amd64__binary) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Msrc_uB__moveit_runtime__ubuntu_bionic__source)](http://build.ros.org/view/Msrc_uB/job/Msrc_uB__moveit_runtime__ubuntu_bionic__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Mbin_uB64__moveit_runtime__ubuntu_bionic_amd64__binary)](http://build.ros.org/view/Mbin_uB64/job/Mbin_uB64__moveit_runtime__ubuntu_bionic_amd64__binary) +moveit_setup_assistant | [![Build Status](http://build.ros.org/buildStatus/icon?job=Ksrc_uX__moveit_setup_assistant__ubuntu_xenial__source)](http://build.ros.org/view/Ksrc_uX/job/Ksrc_uX__moveit_setup_assistant__ubuntu_xenial__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Kbin_uX64__moveit_setup_assistant__ubuntu_xenial_amd64__binary)](http://build.ros.org/view/Kbin_uX64/job/Kbin_uX64__moveit_setup_assistant__ubuntu_xenial_amd64__binary) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Msrc_uB__moveit_setup_assistant__ubuntu_bionic__source)](http://build.ros.org/view/Msrc_uB/job/Msrc_uB__moveit_setup_assistant__ubuntu_bionic__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Mbin_uB64__moveit_setup_assistant__ubuntu_bionic_amd64__binary)](http://build.ros.org/view/Mbin_uB64/job/Mbin_uB64__moveit_setup_assistant__ubuntu_bionic_amd64__binary) +moveit_simple_controller_manager | [![Build Status](http://build.ros.org/buildStatus/icon?job=Ksrc_uX__moveit_simple_controller_manager__ubuntu_xenial__source)](http://build.ros.org/view/Ksrc_uX/job/Ksrc_uX__moveit_simple_controller_manager__ubuntu_xenial__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Kbin_uX64__moveit_simple_controller_manager__ubuntu_xenial_amd64__binary)](http://build.ros.org/view/Kbin_uX64/job/Kbin_uX64__moveit_simple_controller_manager__ubuntu_xenial_amd64__binary) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Msrc_uB__moveit_simple_controller_manager__ubuntu_bionic__source)](http://build.ros.org/view/Msrc_uB/job/Msrc_uB__moveit_simple_controller_manager__ubuntu_bionic__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Mbin_uB64__moveit_simple_controller_manager__ubuntu_bionic_amd64__binary)](http://build.ros.org/view/Mbin_uB64/job/Mbin_uB64__moveit_simple_controller_manager__ubuntu_bionic_amd64__binary) +moveit_visual_tools | [![Build Status](http://build.ros.org/buildStatus/icon?job=Ksrc_uX__moveit_visual_tools__ubuntu_xenial__source)](http://build.ros.org/view/Ksrc_uX/job/Ksrc_uX__moveit_visual_tools__ubuntu_xenial__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Kbin_uX64__moveit_visual_tools__ubuntu_xenial_amd64__binary)](http://build.ros.org/view/Kbin_uX64/job/Kbin_uX64__moveit_visual_tools__ubuntu_xenial_amd64__binary) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Msrc_uB__moveit_visual_tools__ubuntu_bionic__source)](http://build.ros.org/view/Msrc_uB/job/Msrc_uB__moveit_visual_tools__ubuntu_bionic__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Mbin_uB64__moveit_visual_tools__ubuntu_bionic_amd64__binary)](http://build.ros.org/view/Mbin_uB64/job/Mbin_uB64__moveit_visual_tools__ubuntu_bionic_amd64__binary) +chomp_motion_planner | [![Build Status](http://build.ros.org/buildStatus/icon?job=Ksrc_uX__chomp_motion_planner__ubuntu_xenial__source)](http://build.ros.org/view/Ksrc_uX/job/Ksrc_uX__chomp_motion_planner__ubuntu_xenial__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Kbin_uX64__chomp_motion_planner__ubuntu_xenial_amd64__binary)](http://build.ros.org/view/Kbin_uX64/job/Kbin_uX64__chomp_motion_planner__ubuntu_xenial_amd64__binary) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Msrc_uB__chomp_motion_planner__ubuntu_bionic__source)](http://build.ros.org/view/Msrc_uB/job/Msrc_uB__chomp_motion_planner__ubuntu_bionic__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Mbin_uB64__chomp_motion_planner__ubuntu_bionic_amd64__binary)](http://build.ros.org/view/Mbin_uB64/job/Mbin_uB64__chomp_motion_planner__ubuntu_bionic_amd64__binary) +geometric_shapes | [![Build Status](http://build.ros.org/buildStatus/icon?job=Ksrc_uX__geometric_shapes__ubuntu_xenial__source)](http://build.ros.org/view/Ksrc_uX/job/Ksrc_uX__geometric_shapes__ubuntu_xenial__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Kbin_uX64__geometric_shapes__ubuntu_xenial_amd64__binary)](http://build.ros.org/view/Kbin_uX64/job/Kbin_uX64__geometric_shapes__ubuntu_xenial_amd64__binary) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Msrc_uB__geometric_shapes__ubuntu_bionic__source)](http://build.ros.org/view/Msrc_uB/job/Msrc_uB__geometric_shapes__ubuntu_bionic__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Mbin_uB64__geometric_shapes__ubuntu_bionic_amd64__binary)](http://build.ros.org/view/Mbin_uB64/job/Mbin_uB64__geometric_shapes__ubuntu_bionic_amd64__binary) +srdfdom | [![Build Status](http://build.ros.org/buildStatus/icon?job=Ksrc_uX__srdfdom__ubuntu_xenial__source)](http://build.ros.org/view/Ksrc_uX/job/Ksrc_uX__srdfdom__ubuntu_xenial__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Kbin_uX64__srdfdom__ubuntu_xenial_amd64__binary)](http://build.ros.org/view/Kbin_uX64/job/Kbin_uX64__srdfdom__ubuntu_xenial_amd64__binary) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Msrc_uB__srdfdom__ubuntu_bionic__source)](http://build.ros.org/view/Msrc_uB/job/Msrc_uB__srdfdom__ubuntu_bionic__source) | [![Build Status](http://build.ros.org/buildStatus/icon?job=Mbin_uB64__srdfdom__ubuntu_bionic_amd64__binary)](http://build.ros.org/view/Mbin_uB64/job/Mbin_uB64__srdfdom__ubuntu_bionic_amd64__binary) \ No newline at end of file diff --git a/moveit.rosinstall b/moveit.rosinstall index f0ef21afa0..cca53db4e4 100644 --- a/moveit.rosinstall +++ b/moveit.rosinstall @@ -1,9 +1,9 @@ -# This file is intended for users who want to build MoveIt! from source. -# Used with wstool, users can download source of all packages of MoveIt!. +# This file is intended for users who want to build MoveIt from source. +# Used with wstool, users can download source of all packages of MoveIt. - git: local-name: moveit_msgs uri: https://github.com/ros-planning/moveit_msgs.git - version: melodic-devel + version: master - git: local-name: geometric_shapes uri: https://github.com/ros-planning/geometric_shapes.git diff --git a/moveit/CHANGELOG.rst b/moveit/CHANGELOG.rst index 9f03a155e1..482cd91835 100644 --- a/moveit/CHANGELOG.rst +++ b/moveit/CHANGELOG.rst @@ -64,7 +64,7 @@ Changelog for package moveit 0.10.2 (2018-10-24) ------------------- -* [fix] Text refrences to MoveIt! (`#1020 `_) +* [fix] Text refrences to MoveIt (`#1020 `_) * [fix] Eigen alignment issuses due to missing aligned allocation (`#1039 `_) * [fix][chomp] changelogs: migration from tf -> tf2 only accidentally became part of 0.9.12's changelog * [fix] Chomp package handling issue `#1086 `_ that was introduced in `ubi-agni/hotfix-#1012 `_ @@ -82,7 +82,7 @@ Changelog for package moveit * [capability][chomp] Failure recovery options for CHOMP by tweaking parameters (`#987 `_) * [capability] New screen for automatically generating interfaces to low level controllers(`#951 `_, `#994 `_, `#908 `_) * [capability][moveit_setup_assistant] Perception screen for using laser scanner point clouds. (`#969 `_) -* [enhancement][GUI][moveit_setup_assistant] Logo for MoveIt! 2.0, cleanup appearance (`#1059 `_) +* [enhancement][GUI][moveit_setup_assistant] Logo for MoveIt 2.0, cleanup appearance (`#1059 `_) * [enhancement][GUI][moveit_setup_assistant] added a setup assistant window icon (`#1028 `_) * [capability][chomp] Addition of CHOMP planning adapter for optimizing result of other planners (`#1012 `_) * [capability][chomp] Failure recovery options for CHOMP by tweaking parameters (`#987 `_) diff --git a/moveit/package.xml b/moveit/package.xml index 0a60b4860e..5a50dbd315 100644 --- a/moveit/package.xml +++ b/moveit/package.xml @@ -2,7 +2,7 @@ moveit 1.0.1 - Meta package that contains all essential package of MoveIt!. Until Summer 2016 MoveIt! had been developed over multiple repositories, where developers' usability and maintenance effort was non-trivial. See the detailed discussion for the merge of several repositories. + Meta package that contains all essential package of MoveIt. Until Summer 2016 MoveIt had been developed over multiple repositories, where developers' usability and maintenance effort was non-trivial. See the detailed discussion for the merge of several repositories. Dave Coleman Michael Ferguson Michael Görner diff --git a/moveit/scripts/README.md b/moveit/scripts/README.md index ddc705b86f..e2da938586 100644 --- a/moveit/scripts/README.md +++ b/moveit/scripts/README.md @@ -1,8 +1,8 @@ -# Utility Scripts for MoveIt! +# Utility Scripts for MoveIt ## README Markdown Buildfarm Table Generator -This Python script will generate Github-style Markdown table with Jenkins badges for every package recursively from the current folder. It will order all packages alphabetically, but start with all MoveIt! packages first. For generating an updated README for a new ROS distribution, first update the `create_readme_table.py` script and add/remove the current MoveIt!-supported ROS distros and their corresponding Ubuntu distribution in the specified Python dictionary. Then, in the main MoveIt! `README.md` file, remove the "## ROS Buildfarm" header and the following table. Finally, from your catkin workspace with every MoveIt! package, run the `create_readme_table.py` script. For example: +This Python script will generate Github-style Markdown table with Jenkins badges for every package recursively from the current folder. It will order all packages alphabetically, but start with all MoveIt packages first. For generating an updated README for a new ROS distribution, first update the `create_readme_table.py` script and add/remove the current MoveIt-supported ROS distros and their corresponding Ubuntu distribution in the specified Python dictionary. Then, in the main MoveIt `README.md` file, remove the "## ROS Buildfarm" header and the following table. Finally, from your catkin workspace with every MoveIt package, run the `create_readme_table.py` script. For example: cd ~/ws_moveit/src python moveit/moveit/scripts/create_readme_table.py >> moveit/README.md diff --git a/moveit/scripts/create_maintainer_table.py b/moveit/scripts/create_maintainer_table.py index af7615c2a9..1557530ee2 100644 --- a/moveit/scripts/create_maintainer_table.py +++ b/moveit/scripts/create_maintainer_table.py @@ -98,7 +98,7 @@ def populate_package_data(path, package): def list_moveit_packages(): """ - Creates MoveIt! List + Creates MoveIt List """ output = '' packages = find_packages(os.getcwd()) diff --git a/moveit/scripts/create_readme_table.py b/moveit/scripts/create_readme_table.py index 9a5af08554..9cbaed3e52 100644 --- a/moveit/scripts/create_readme_table.py +++ b/moveit/scripts/create_readme_table.py @@ -11,7 +11,7 @@ def create_header(ros_ubuntu_dict): ros_distros = sorted(ros_ubuntu_dict.keys()) section_header = "## ROS Buildfarm\n" - header="MoveIt! Package" + header="MoveIt Package" header_lines = '-'*len(header) for ros in ros_distros: source = ' '.join([ros.capitalize(), "Source"]) @@ -49,13 +49,13 @@ def create_line(package, ros_ubuntu_dict): def create_moveit_buildfarm_table(): """ - Creates MoveIt! buildfarm badge table + Creates MoveIt buildfarm badge table """ # Update the following dictionary with the appropriate ROS-Ubuntu # combinations for supported distribitions. For instance, in Noetic, # remove {"indigo":"trusty"} and add {"noetic":"fbuntu"} with "fbuntu" # being whatever the 20.04 distro is named - supported_distro_ubuntu_dict = {"indigo":"trusty", "kinetic":"xenial", "melodic":"bionic"} + supported_distro_ubuntu_dict = {"kinetic":"xenial", "melodic":"bionic"} all_packages = sorted([package.name for _, package in find_packages(os.getcwd()).items()]) moveit_packages = list() diff --git a/moveit/scripts/maintainer_table_template.html b/moveit/scripts/maintainer_table_template.html index b5c94f4020..584b1d68d6 100644 --- a/moveit/scripts/maintainer_table_template.html +++ b/moveit/scripts/maintainer_table_template.html @@ -2,7 +2,7 @@ - MoveIt! Package Tracking + MoveIt Package Tracking @@ -23,7 +23,7 @@ -

MoveIt! Package Tracking

+

MoveIt Package Tracking

diff --git a/moveit_commander/CMakeLists.txt b/moveit_commander/CMakeLists.txt index 70ba103732..74a0c315af 100644 --- a/moveit_commander/CMakeLists.txt +++ b/moveit_commander/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8.3) +cmake_minimum_required(VERSION 3.1.3) project(moveit_commander) find_package(catkin REQUIRED) diff --git a/moveit_commander/README.md b/moveit_commander/README.md index ecd51ed3b1..1b8f538576 100644 --- a/moveit_commander/README.md +++ b/moveit_commander/README.md @@ -1 +1 @@ -# MoveIt! Commander +# MoveIt Commander diff --git a/moveit_commander/bin/moveit_commander_cmdline.py b/moveit_commander/bin/moveit_commander_cmdline.py index eb3c524c74..61a37e8898 100755 --- a/moveit_commander/bin/moveit_commander_cmdline.py +++ b/moveit_commander/bin/moveit_commander_cmdline.py @@ -4,7 +4,10 @@ import roslib import rospy -import readline +try: + import readline +except ImportError: + import pyreadline as readline # for Windows import sys import os import signal @@ -151,7 +154,7 @@ def sigint_handler(signal, frame): rospy.init_node('move_group_interface_cmdline', anonymous=True, disable_signals=True) parser = argparse.ArgumentParser(usage = """%(prog)s [options] []""", - description = "Command Line Interface to MoveIt!") + description = "Command Line Interface to MoveIt") parser.add_argument("-i", "--interactive", action="store_true", dest="interactive", default=True, help="Run the command processing script in interactive mode (default)") parser.add_argument("-s", "--service", action="store_true", dest="service", default=False, diff --git a/moveit_commander/package.xml b/moveit_commander/package.xml index 6680232adc..a962c6a2df 100644 --- a/moveit_commander/package.xml +++ b/moveit_commander/package.xml @@ -7,7 +7,7 @@ Michael Görner Robert Haschke - MoveIt! Release Team + MoveIt Release Team BSD diff --git a/moveit_commander/src/moveit_commander/interpreter.py b/moveit_commander/src/moveit_commander/interpreter.py index 3505e6deb5..02cc10e4d4 100644 --- a/moveit_commander/src/moveit_commander/interpreter.py +++ b/moveit_commander/src/moveit_commander/interpreter.py @@ -336,11 +336,11 @@ def execute_group_command(self, g, cmdorig): if clist[1] == "rand" or clist[1] == "random": vals = g.get_random_joint_values() g.set_joint_value_target(vals) - self._last_plan = g.plan() + self._last_plan = g.plan()[1] # The trajectory msg else: try: g.set_named_target(clist[1]) - self._last_plan = g.plan() + self._last_plan = g.plan()[1] # The trajectory msg except MoveItCommanderException as e: return (MoveGroupInfoLevel.WARN, "Planning to " + clist[1] + ": " + str(e)) except: diff --git a/moveit_commander/src/moveit_commander/move_group.py b/moveit_commander/src/moveit_commander/move_group.py index a05c23cf85..0799e77c50 100644 --- a/moveit_commander/src/moveit_commander/move_group.py +++ b/moveit_commander/src/moveit_commander/move_group.py @@ -596,7 +596,7 @@ def retime_trajectory(self, ref_state_in, traj_in, velocity_scaling_factor=1.0, traj_out.deserialize(ser_traj_out) return traj_out - def get_jacobian_matrix(self, joint_values): + def get_jacobian_matrix(self, joint_values, reference_point=None): """ Get the jacobian matrix of the group as a list""" - return self._g.get_jacobian_matrix(joint_values) + return self._g.get_jacobian_matrix(joint_values, [0.0, 0.0, 0.0] if reference_point is None else reference_point) diff --git a/moveit_commander/src/moveit_commander/planning_scene_interface.py b/moveit_commander/src/moveit_commander/planning_scene_interface.py index a7fa6c9ad2..e0093e1508 100644 --- a/moveit_commander/src/moveit_commander/planning_scene_interface.py +++ b/moveit_commander/src/moveit_commander/planning_scene_interface.py @@ -69,7 +69,7 @@ def __init__(self, ns='', synchronous=False, service_timeout=5.0): def __submit(self, collision_object, attach=False): if self.__synchronous: - diff_req = self.__make_planning_scene_diff_req(collision_object) + diff_req = self.__make_planning_scene_diff_req(collision_object, attach) self._apply_planning_scene_diff.call(diff_req) else: if attach: @@ -306,10 +306,14 @@ def __make_cylinder(name, pose, height, radius): return co @staticmethod - def __make_planning_scene_diff_req(collision_object): + def __make_planning_scene_diff_req(collision_object, attach=False): scene = PlanningScene() scene.is_diff = True - scene.world.collision_objects = [collision_object] + scene.robot_state.is_diff = True + if attach: + scene.robot_state.attached_collision_objects = [collision_object] + else: + scene.world.collision_objects = [collision_object] planning_scene_diff_req = ApplyPlanningSceneRequest() planning_scene_diff_req.scene = scene return planning_scene_diff_req diff --git a/moveit_core/CMakeLists.txt b/moveit_core/CMakeLists.txt index 9fd0c3bc6e..813c41187e 100644 --- a/moveit_core/CMakeLists.txt +++ b/moveit_core/CMakeLists.txt @@ -1,7 +1,8 @@ -cmake_minimum_required(VERSION 2.8.12) +cmake_minimum_required(VERSION 3.1.3) project(moveit_core) -add_compile_options(-std=c++14) +set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_EXTENSIONS OFF) # Warnings add_compile_options(-Wall -Wextra @@ -174,7 +175,7 @@ string(REGEX REPLACE "^[0-9]+\\.([0-9]+).*" "\\1" MOVEIT_VERSION_MINOR "${${PROJ string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" MOVEIT_VERSION_PATCH "${${PROJECT_NAME}_VERSION}") set(MOVEIT_VERSION_EXTRA "Alpha") set(MOVEIT_VERSION "${MOVEIT_VERSION_MAJOR}.${MOVEIT_VERSION_MINOR}.${MOVEIT_VERSION_PATCH}-${MOVEIT_VERSION_EXTRA}") -message(STATUS " *** Building MoveIt! ${MOVEIT_VERSION} ***") +message(STATUS " *** Building MoveIt ${MOVEIT_VERSION} ***") configure_file("version/version.h.in" "${VERSION_FILE_PATH}/moveit/version.h") #catkin_lint: ignore_once external_file install(FILES "${VERSION_FILE_PATH}/moveit/version.h" DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}/moveit) diff --git a/moveit_core/README.md b/moveit_core/README.md index 2a54efedd4..5e602a457c 100644 --- a/moveit_core/README.md +++ b/moveit_core/README.md @@ -1,4 +1,4 @@ -# MoveIt! Core +# MoveIt Core This repository includes core libraries used by MoveIt: - representation of kinematic models diff --git a/moveit_core/background_processing/CMakeLists.txt b/moveit_core/background_processing/CMakeLists.txt index 0e09ddc409..f0b7ab4712 100644 --- a/moveit_core/background_processing/CMakeLists.txt +++ b/moveit_core/background_processing/CMakeLists.txt @@ -7,6 +7,7 @@ target_link_libraries(${MOVEIT_LIB_NAME} ${catkin_LIBRARIES} ${urdfdom_LIBRARIES install(TARGETS ${MOVEIT_LIB_NAME} ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} - LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}) + LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}) install(DIRECTORY include/ DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}) diff --git a/moveit_core/background_processing/include/moveit/background_processing/background_processing.h b/moveit_core/background_processing/include/moveit/background_processing/background_processing.h index 30cd7380ae..b87a82f997 100644 --- a/moveit_core/background_processing/include/moveit/background_processing/background_processing.h +++ b/moveit_core/background_processing/include/moveit/background_processing/background_processing.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_BACKGROUND_PROCESSING_ -#define MOVEIT_BACKGROUND_PROCESSING_ +#pragma once #include #include @@ -47,7 +46,7 @@ namespace moveit { /** \brief This namespace includes classes and functions that are - helpful in the implementation of other MoveIt! components. This is + helpful in the implementation of other MoveIt components. This is not code specific to the functionality provided by MoveIt. */ namespace tools { @@ -113,5 +112,3 @@ class BackgroundProcessing : private boost::noncopyable }; } } - -#endif diff --git a/moveit_core/backtrace/include/moveit/backtrace/backtrace.h b/moveit_core/backtrace/include/moveit/backtrace/backtrace.h index c00033f9bc..224c0fe2dc 100644 --- a/moveit_core/backtrace/include/moveit/backtrace/backtrace.h +++ b/moveit_core/backtrace/include/moveit/backtrace/backtrace.h @@ -32,8 +32,7 @@ * POSSIBILITY OF SUCH DAMAGE. *********************************************************************/ -#ifndef MOVEIT_BACKTRACE_ -#define MOVEIT_BACKTRACE_ +#pragma once #include @@ -63,5 +62,3 @@ void get_backtrace(std::ostream& out) } #endif } - -#endif diff --git a/moveit_core/collision_detection/CMakeLists.txt b/moveit_core/collision_detection/CMakeLists.txt index bfc4e8db6b..262db3780d 100644 --- a/moveit_core/collision_detection/CMakeLists.txt +++ b/moveit_core/collision_detection/CMakeLists.txt @@ -1,15 +1,13 @@ set(MOVEIT_LIB_NAME moveit_collision_detection) add_library(${MOVEIT_LIB_NAME} - src/allvalid/collision_robot_allvalid.cpp - src/allvalid/collision_world_allvalid.cpp + src/allvalid/collision_env_allvalid.cpp src/collision_matrix.cpp src/collision_octomap_filter.cpp - src/collision_robot.cpp src/collision_tools.cpp - src/collision_world.cpp src/world.cpp src/world_diff.cpp + src/collision_env.cpp ) set_target_properties(${MOVEIT_LIB_NAME} PROPERTIES VERSION "${${PROJECT_NAME}_VERSION}") @@ -31,6 +29,7 @@ endif() install(TARGETS ${MOVEIT_LIB_NAME} LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} - ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}) + ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}) install(DIRECTORY include/ DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}) diff --git a/moveit_core/collision_detection/include/moveit/collision_detection/allvalid/collision_detector_allocator_allvalid.h b/moveit_core/collision_detection/include/moveit/collision_detection/allvalid/collision_detector_allocator_allvalid.h index 549a6d6990..7782670035 100644 --- a/moveit_core/collision_detection/include/moveit/collision_detection/allvalid/collision_detector_allocator_allvalid.h +++ b/moveit_core/collision_detection/include/moveit/collision_detection/allvalid/collision_detector_allocator_allvalid.h @@ -34,23 +34,18 @@ /* Author: Acorn Pooley, Ioan Sucan */ -#ifndef MOVEIT_COLLISION_DETECTION_COLLISION_DETECTOR_ALL_VALID_H_ -#define MOVEIT_COLLISION_DETECTION_COLLISION_DETECTOR_ALL_VALID_H_ +#pragma once #include -#include -#include +#include namespace collision_detection { /** \brief An allocator for AllValid collision detectors */ class CollisionDetectorAllocatorAllValid - : public CollisionDetectorAllocatorTemplate + : public CollisionDetectorAllocatorTemplate { public: - static const std::string NAME; // defined in collision_world_allvalid.cpp + static const std::string NAME; // defined in collision_env_allvalid.cpp }; } - -#endif diff --git a/moveit_core/collision_detection/include/moveit/collision_detection/allvalid/collision_world_allvalid.h b/moveit_core/collision_detection/include/moveit/collision_detection/allvalid/collision_env_allvalid.h similarity index 55% rename from moveit_core/collision_detection/include/moveit/collision_detection/allvalid/collision_world_allvalid.h rename to moveit_core/collision_detection/include/moveit/collision_detection/allvalid/collision_env_allvalid.h index c950579668..024a59496b 100644 --- a/moveit_core/collision_detection/include/moveit/collision_detection/allvalid/collision_world_allvalid.h +++ b/moveit_core/collision_detection/include/moveit/collision_detection/allvalid/collision_env_allvalid.h @@ -32,48 +32,45 @@ * POSSIBILITY OF SUCH DAMAGE. *********************************************************************/ -/* Author: Ioan Sucan */ +/* Author: Ioan Sucan, Jia Pan, Jens Petit */ -#ifndef MOVEIT_COLLISION_DETECTION_ALLVALID_COLLISION_WORLD_ALLVALID_ -#define MOVEIT_COLLISION_DETECTION_ALLVALID_COLLISION_WORLD_ALLVALID_ +#pragma once -#include +#include namespace collision_detection { -class CollisionRobotAllValid; - -class CollisionWorldAllValid : public CollisionWorld +/** \brief Collision environment which always just returns no collisions. + * + * This can be used to save resources if collision checking is not important. */ +class CollisionEnvAllValid : public CollisionEnv { public: - CollisionWorldAllValid(); - explicit CollisionWorldAllValid(const WorldPtr& world); - CollisionWorldAllValid(const CollisionWorld& other, const WorldPtr& world); + CollisionEnvAllValid(const robot_model::RobotModelConstPtr& robot_model, double padding = 0.0, double scale = 1.0); + CollisionEnvAllValid(const robot_model::RobotModelConstPtr& robot_model, const WorldPtr& world, double padding = 0.0, + double scale = 1.0); + CollisionEnvAllValid(const CollisionEnv& other, const WorldPtr& world); - void checkRobotCollision(const CollisionRequest& req, CollisionResult& res, const CollisionRobot& robot, + void checkRobotCollision(const CollisionRequest& req, CollisionResult& res, const robot_state::RobotState& state) const override; - void checkRobotCollision(const CollisionRequest& req, CollisionResult& res, const CollisionRobot& robot, - const robot_state::RobotState& state, const AllowedCollisionMatrix& acm) const override; - void checkRobotCollision(const CollisionRequest& req, CollisionResult& res, const CollisionRobot& robot, - const robot_state::RobotState& state1, const robot_state::RobotState& state2) const override; - void checkRobotCollision(const CollisionRequest& req, CollisionResult& res, const CollisionRobot& robot, - const robot_state::RobotState& state1, const robot_state::RobotState& state2, - const AllowedCollisionMatrix& acm) const override; - - void checkWorldCollision(const CollisionRequest& req, CollisionResult& res, - const CollisionWorld& other_world) const override; - void checkWorldCollision(const CollisionRequest& req, CollisionResult& res, const CollisionWorld& other_world, + void checkRobotCollision(const CollisionRequest& req, CollisionResult& res, const robot_state::RobotState& state, const AllowedCollisionMatrix& acm) const override; + void checkRobotCollision(const CollisionRequest& req, CollisionResult& res, const robot_state::RobotState& state1, + const robot_state::RobotState& state2) const override; + void checkRobotCollision(const CollisionRequest& req, CollisionResult& res, const robot_state::RobotState& state1, + const robot_state::RobotState& state2, const AllowedCollisionMatrix& acm) const override; - virtual double distanceRobot(const CollisionRobot& robot, const robot_state::RobotState& state) const; - virtual double distanceRobot(const CollisionRobot& robot, const robot_state::RobotState& state, - const AllowedCollisionMatrix& acm) const; - void distanceRobot(const DistanceRequest& req, DistanceResult& res, const CollisionRobot& robot, + virtual double distanceRobot(const robot_state::RobotState& state) const; + virtual double distanceRobot(const robot_state::RobotState& state, const AllowedCollisionMatrix& acm) const; + void distanceRobot(const DistanceRequest& req, DistanceResult& res, const robot_state::RobotState& state) const override; - virtual double distanceWorld(const CollisionWorld& world) const; - virtual double distanceWorld(const CollisionWorld& world, const AllowedCollisionMatrix& acm) const; - void distanceWorld(const DistanceRequest& req, DistanceResult& res, const CollisionWorld& world) const override; + + void checkSelfCollision(const CollisionRequest& req, CollisionResult& res, + const robot_state::RobotState& state) const override; + void checkSelfCollision(const CollisionRequest& req, CollisionResult& res, const robot_state::RobotState& state, + const AllowedCollisionMatrix& acm) const override; + + void distanceSelf(const DistanceRequest& req, DistanceResult& res, + const robot_state::RobotState& state) const override; }; } - -#endif diff --git a/moveit_core/collision_detection/include/moveit/collision_detection/allvalid/collision_robot_allvalid.h b/moveit_core/collision_detection/include/moveit/collision_detection/allvalid/collision_robot_allvalid.h deleted file mode 100644 index 9ac86aa6bb..0000000000 --- a/moveit_core/collision_detection/include/moveit/collision_detection/allvalid/collision_robot_allvalid.h +++ /dev/null @@ -1,88 +0,0 @@ -/********************************************************************* - * Software License Agreement (BSD License) - * - * Copyright (c) 2011, Willow Garage, Inc. - * 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 and/or other materials provided - * with the distribution. - * * Neither the name of Willow Garage nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 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 OWNER 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. - *********************************************************************/ - -/* Author: Ioan Sucan */ - -#ifndef MOVEIT_COLLISION_DETECTION_ALLVALID_COLLISION_ROBOT_ALLVALID_ -#define MOVEIT_COLLISION_DETECTION_ALLVALID_COLLISION_ROBOT_ALLVALID_ - -#include - -namespace collision_detection -{ -class CollisionRobotAllValid : public CollisionRobot -{ -public: - CollisionRobotAllValid(const robot_model::RobotModelConstPtr& robot_model, double padding = 0.0, double scale = 1.0); - CollisionRobotAllValid(const CollisionRobot& other); - - void checkSelfCollision(const CollisionRequest& req, CollisionResult& res, - const robot_state::RobotState& state) const override; - void checkSelfCollision(const CollisionRequest& req, CollisionResult& res, const robot_state::RobotState& state, - const AllowedCollisionMatrix& acm) const override; - void checkSelfCollision(const CollisionRequest& req, CollisionResult& res, const robot_state::RobotState& state1, - const robot_state::RobotState& state2) const override; - void checkSelfCollision(const CollisionRequest& req, CollisionResult& res, const robot_state::RobotState& state1, - const robot_state::RobotState& state2, const AllowedCollisionMatrix& acm) const override; - - void checkOtherCollision(const CollisionRequest& req, CollisionResult& res, const robot_state::RobotState& state, - const CollisionRobot& other_robot, - const robot_state::RobotState& other_state) const override; - void checkOtherCollision(const CollisionRequest& req, CollisionResult& res, const robot_state::RobotState& state, - const CollisionRobot& other_robot, const robot_state::RobotState& other_state, - const AllowedCollisionMatrix& acm) const override; - void checkOtherCollision(const CollisionRequest& req, CollisionResult& res, const robot_state::RobotState& state1, - const robot_state::RobotState& state2, const CollisionRobot& other_robot, - const robot_state::RobotState& other_state1, - const robot_state::RobotState& other_state2) const override; - void checkOtherCollision(const CollisionRequest& req, CollisionResult& res, const robot_state::RobotState& state1, - const robot_state::RobotState& state2, const CollisionRobot& other_robot, - const robot_state::RobotState& other_state1, const robot_state::RobotState& other_state2, - const AllowedCollisionMatrix& acm) const override; - - virtual double distanceSelf(const robot_state::RobotState& state) const; - virtual double distanceSelf(const robot_state::RobotState& state, const AllowedCollisionMatrix& acm) const; - void distanceSelf(const DistanceRequest& req, DistanceResult& res, - const robot_state::RobotState& state) const override; - - virtual double distanceOther(const robot_state::RobotState& state, const CollisionRobot& other_robot, - const robot_state::RobotState& other_state) const; - virtual double distanceOther(const robot_state::RobotState& state, const CollisionRobot& other_robot, - const robot_state::RobotState& other_state, const AllowedCollisionMatrix& acm) const; - void distanceOther(const DistanceRequest& req, DistanceResult& res, const robot_state::RobotState& state, - const CollisionRobot& other_robot, const robot_state::RobotState& other_state) const override; -}; -} - -#endif diff --git a/moveit_core/collision_detection/include/moveit/collision_detection/collision_common.h b/moveit_core/collision_detection/include/moveit/collision_detection/collision_common.h index 601755b0bb..2991951395 100644 --- a/moveit_core/collision_detection/include/moveit/collision_detection/collision_common.h +++ b/moveit_core/collision_detection/include/moveit/collision_detection/collision_common.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_COLLISION_DETECTION_COLLISION_COMMON_ -#define MOVEIT_COLLISION_DETECTION_COLLISION_COMMON_ +#pragma once #include #include @@ -162,11 +161,10 @@ struct CollisionResult /** \brief Number of contacts returned */ std::size_t contact_count; - /** \brief A map returning the pairs of ids of the bodies in contact, plus information about the contacts themselves - */ + /** \brief A map returning the pairs of body ids in contact, plus their contact details */ ContactMap contacts; - /** \brief When costs are computed, the individual cost sources are */ + /** \brief These are the individual cost sources when costs are computed */ std::set cost_sources; }; @@ -197,7 +195,7 @@ struct CollisionRequest /** \brief If true, a collision cost is computed */ bool cost; - /** \brief If true, compute contacts */ + /** \brief If true, compute contacts. Otherwise only a binary collision yes/no is reported. */ bool contacts; /** \brief Overall maximum number of contacts to compute */ @@ -224,14 +222,15 @@ namespace DistanceRequestTypes { enum DistanceRequestType { - GLOBAL, /// Find the global minimum - SINGLE, /// Find the global minimum for each pair - LIMITED, /// Find a limited(max_contacts_per_body) set of contacts for a given pair - ALL /// Find all the contacts for a given pair + GLOBAL, ///< Find the global minimum + SINGLE, ///< Find the global minimum for each pair + LIMITED, ///< Find a limited(max_contacts_per_body) set of contacts for a given pair + ALL ///< Find all the contacts for a given pair }; } typedef DistanceRequestTypes::DistanceRequestType DistanceRequestType; +/** \brief Representation of a distance-reporting request */ struct DistanceRequest { DistanceRequest() @@ -264,7 +263,7 @@ struct DistanceRequest /// Indicate the type of distance request. If using type=ALL, it is /// recommended to set max_contacts_per_body to the expected number - /// of contacts per pair becaused it is uesed to reserving space. + /// of contacts per pair because it is used to reserve space. DistanceRequestType type; /// Maximum number of contacts to store for bodies (multiple bodies may be within distance threshold) @@ -280,7 +279,7 @@ struct DistanceRequest const AllowedCollisionMatrix* acm; /// Only calculate distances for objects within this threshold to each other. - /// If set this can significantly to reduce number of queries. + /// If set, this can significantly reduce the number of queries. double distance_threshold; /// Log debug information @@ -291,6 +290,7 @@ struct DistanceRequest bool compute_gradient; }; +/** \brief Generic representation of the distance information for a pair of objects */ struct DistanceResultsData { DistanceResultsData() @@ -356,8 +356,10 @@ struct DistanceResultsData } }; +/** \brief Mapping between the names of the collision objects and the DistanceResultData. */ typedef std::map, std::vector > DistanceMap; +/** \brief Result of a distance request. */ struct DistanceResult { DistanceResult() : collision(false) @@ -382,5 +384,3 @@ struct DistanceResult } }; } - -#endif diff --git a/moveit_core/collision_detection/include/moveit/collision_detection/collision_detector_allocator.h b/moveit_core/collision_detection/include/moveit/collision_detection/collision_detector_allocator.h index aed7eac019..cbfb39a161 100644 --- a/moveit_core/collision_detection/include/moveit/collision_detection/collision_detector_allocator.h +++ b/moveit_core/collision_detection/include/moveit/collision_detection/collision_detector_allocator.h @@ -34,11 +34,9 @@ /* Author: Acorn Pooley, Ioan Sucan */ -#ifndef MOVEIT_COLLISION_DETECTION_COLLISION_DETECTOR_ -#define MOVEIT_COLLISION_DETECTION_COLLISION_DETECTOR_ +#pragma once -#include -#include +#include #include namespace collision_detection @@ -57,22 +55,20 @@ class CollisionDetectorAllocator virtual const std::string& getName() const = 0; /** create a new CollisionWorld for checking collisions with the supplied world. */ - virtual CollisionWorldPtr allocateWorld(const WorldPtr& world) const = 0; + virtual CollisionEnvPtr allocateEnv(const WorldPtr& world, + const robot_model::RobotModelConstPtr& robot_model) const = 0; /** create a new CollisionWorld by copying an existing CollisionWorld of the same type.s * The world must be either the same world as used by \orig or a copy of that world which has not yet been modified. */ - virtual CollisionWorldPtr allocateWorld(const CollisionWorldConstPtr& orig, const WorldPtr& world) const = 0; + virtual CollisionEnvPtr allocateEnv(const CollisionEnvConstPtr& orig, const WorldPtr& world) const = 0; - /** create a new CollisionRobot given a robot_model */ - virtual CollisionRobotPtr allocateRobot(const robot_model::RobotModelConstPtr& robot_model) const = 0; - - /** create a new CollisionRobot by copying an existing CollisionRobot of the same type. */ - virtual CollisionRobotPtr allocateRobot(const CollisionRobotConstPtr& orig) const = 0; + /** create a new CollisionEnv given a robot_model with a new empty world */ + virtual CollisionEnvPtr allocateEnv(const robot_model::RobotModelConstPtr& robot_model) const = 0; }; /** \brief Template class to make it easy to create an allocator for a specific CollisionWorld/CollisionRobot pair. */ -template +template class CollisionDetectorAllocatorTemplate : public CollisionDetectorAllocator { public: @@ -81,32 +77,25 @@ class CollisionDetectorAllocatorTemplate : public CollisionDetectorAllocator return CollisionDetectorAllocatorType::NAME; } - CollisionWorldPtr allocateWorld(const WorldPtr& world) const override + CollisionEnvPtr allocateEnv(const WorldPtr& world, const robot_model::RobotModelConstPtr& robot_model) const override { - return CollisionWorldPtr(new CollisionWorldType(world)); + return CollisionEnvPtr(new CollisionEnvType(robot_model, world)); } - CollisionWorldPtr allocateWorld(const CollisionWorldConstPtr& orig, const WorldPtr& world) const override + CollisionEnvPtr allocateEnv(const CollisionEnvConstPtr& orig, const WorldPtr& world) const override { - return CollisionWorldPtr(new CollisionWorldType(dynamic_cast(*orig), world)); + return CollisionEnvPtr(new CollisionEnvType(dynamic_cast(*orig), world)); } - CollisionRobotPtr allocateRobot(const robot_model::RobotModelConstPtr& robot_model) const override + CollisionEnvPtr allocateEnv(const robot_model::RobotModelConstPtr& robot_model) const override { - return CollisionRobotPtr(new CollisionRobotType(robot_model)); + return CollisionEnvPtr(new CollisionEnvType(robot_model)); } - CollisionRobotPtr allocateRobot(const CollisionRobotConstPtr& orig) const override - { - return CollisionRobotPtr(new CollisionRobotType(dynamic_cast(*orig))); - } - - /** Create an allocator for FCL collision detectors */ + /** Create an allocator for collision detectors. */ static CollisionDetectorAllocatorPtr create() { return CollisionDetectorAllocatorPtr(new CollisionDetectorAllocatorType()); } }; } - -#endif diff --git a/moveit_core/collision_detection/include/moveit/collision_detection/collision_robot.h b/moveit_core/collision_detection/include/moveit/collision_detection/collision_env.h similarity index 60% rename from moveit_core/collision_detection/include/moveit/collision_detection/collision_robot.h rename to moveit_core/collision_detection/include/moveit/collision_detection/collision_env.h index 1b6d476a89..c634ca8597 100644 --- a/moveit_core/collision_detection/include/moveit/collision_detection/collision_robot.h +++ b/moveit_core/collision_detection/include/moveit/collision_detection/collision_env.h @@ -14,7 +14,7 @@ * copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials provided * with the distribution. - * * Neither the name of Willow Garage nor the names of its + * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * @@ -32,44 +32,52 @@ * POSSIBILITY OF SUCH DAMAGE. *********************************************************************/ -/* Author: Ioan Sucan */ +/* Author: Ioan Sucan, Jens Petit */ -#ifndef MOVEIT_COLLISION_DETECTION_COLLISION_ROBOT_ -#define MOVEIT_COLLISION_DETECTION_COLLISION_ROBOT_ +#pragma once #include #include #include #include #include +#include namespace collision_detection { -MOVEIT_CLASS_FORWARD(CollisionRobot); +MOVEIT_CLASS_FORWARD(CollisionEnv); -/** @brief This class represents a collision model of the robot and can be used for self collision checks - (to check if the robot is in collision with itself) or in collision checks with a different robot. Collision checks - with - the environment are performed using the CollisionWorld class. */ -class CollisionRobot +/** \brief Provides the interface to the individual collision checking libraries. */ +class CollisionEnv { public: + CollisionEnv() = delete; + /** @brief Constructor * @param model A robot model to construct the collision robot from * @param padding The padding to use for all objects/links on the robot * @scale scale A common scaling to use for all objects/links on the robot */ - CollisionRobot(const robot_model::RobotModelConstPtr& model, double padding = 0.0, double scale = 1.0); + CollisionEnv(const robot_model::RobotModelConstPtr& model, double padding = 0.0, double scale = 1.0); - /** @brief A copy constructor*/ - CollisionRobot(const CollisionRobot& other); + /** @brief Constructor + * @param model A robot model to construct the collision robot from + * @param padding The padding to use for all objects/links on the robot + * @scale scale A common scaling to use for all objects/links on the robot + */ + CollisionEnv(const robot_model::RobotModelConstPtr& model, const WorldPtr& world, double padding = 0.0, + double scale = 1.0); + + /** \brief Copy constructor */ + CollisionEnv(const CollisionEnv& other, const WorldPtr& world); - virtual ~CollisionRobot() + virtual ~CollisionEnv() { } - /** @brief Check for self collision. Any collision between any pair of links is checked for, NO collisions are + /** @brief Check for robot self collision. Any collision between any pair of links is checked for, NO collisions are * ignored. + * * @param req A CollisionRequest object that encapsulates the collision request * @param res A CollisionResult object that encapsulates the collision result * @param state The kinematic state for which checks are being made */ @@ -85,82 +93,75 @@ class CollisionRobot virtual void checkSelfCollision(const CollisionRequest& req, CollisionResult& res, const robot_state::RobotState& state, const AllowedCollisionMatrix& acm) const = 0; - /** @brief Check for self collision in a continuous manner. Any collision between any pair of links is checked for, - * NO collisions are ignored. + /** \brief Check whether the robot model is in collision with itself or the world at a particular state. + * Any collision between any pair of links is checked for, NO collisions are ignored. * @param req A CollisionRequest object that encapsulates the collision request * @param res A CollisionResult object that encapsulates the collision result - * @param state1 The kinematic state at the start of the segment for which checks are being made - * @param state2 The kinematic state at the end of the segment for which checks are being made */ - virtual void checkSelfCollision(const CollisionRequest& req, CollisionResult& res, - const robot_state::RobotState& state1, - const robot_state::RobotState& state2) const = 0; + * @param state The kinematic state for which checks are being made */ + virtual void checkCollision(const CollisionRequest& req, CollisionResult& res, + const robot_state::RobotState& state) const; - /** \brief Check for self collision. Allowed collisions specified by the allowed collision matrix are - * taken into account. + /** \brief Check whether the robot model is in collision with itself or the world at a particular state. + * Allowed collisions specified by the allowed collision matrix are taken into account. * @param req A CollisionRequest object that encapsulates the collision request * @param res A CollisionResult object that encapsulates the collision result - * @param state1 The kinematic state at the start of the segment for which checks are being made - * @param state2 The kinematic state at the end of the segment for which checks are being made + * @param state The kinematic state for which checks are being made * @param acm The allowed collision matrix. */ - virtual void checkSelfCollision(const CollisionRequest& req, CollisionResult& res, - const robot_state::RobotState& state1, const robot_state::RobotState& state2, - const AllowedCollisionMatrix& acm) const = 0; + virtual void checkCollision(const CollisionRequest& req, CollisionResult& res, const robot_state::RobotState& state, + const AllowedCollisionMatrix& acm) const; - /** \brief Check for collision with a different robot (possibly a different kinematic model as well). - * Any collision between any pair of links is checked for, NO collisions are ignored. + /** \brief Check whether the robot model is in collision with the world. Any collisions between a robot link + * and the world are considered. Self collisions are not checked. * @param req A CollisionRequest object that encapsulates the collision request * @param res A CollisionResult object that encapsulates the collision result - * @param state The kinematic state for which checks are being made. - * @param other_robot The collision representation for the other robot - * @param other_state The kinematic state corresponding to the other robot */ - virtual void checkOtherCollision(const CollisionRequest& req, CollisionResult& res, - const robot_state::RobotState& state, const CollisionRobot& other_robot, - const robot_state::RobotState& other_state) const = 0; - - /** \brief Check for collision with a different robot (possibly a different kinematic model as well). - * Allowed collisions specified by the allowed collision matrix are taken into account. + * @robot robot The collision model for the robot + * @param state The kinematic state for which checks are being made + */ + virtual void checkRobotCollision(const CollisionRequest& req, CollisionResult& res, + const robot_state::RobotState& state) const = 0; + + /** \brief Check whether the robot model is in collision with the world. + * Allowed collisions are ignored. Self collisions are not checked. * @param req A CollisionRequest object that encapsulates the collision request * @param res A CollisionResult object that encapsulates the collision result - * @param state The kinematic state for which checks are being made. - * @param other_robot The collision representation for the other robot - * @param other_state The kinematic state corresponding to the other robot - * @param acm The allowed collision matrix. */ - virtual void checkOtherCollision(const CollisionRequest& req, CollisionResult& res, - const robot_state::RobotState& state, const CollisionRobot& other_robot, - const robot_state::RobotState& other_state, - const AllowedCollisionMatrix& acm) const = 0; + * @robot robot The collision model for the robot + * @param state The kinematic state for which checks are being made + * @param acm The allowed collision matrix.*/ + virtual void checkRobotCollision(const CollisionRequest& req, CollisionResult& res, + const robot_state::RobotState& state, const AllowedCollisionMatrix& acm) const = 0; - /** \brief Check for collision with a different robot (possibly a different kinematic model as well), in a continuous - * fashion. - * Any collision between any pair of links is checked for, NO collisions are ignored. + /** \brief Check whether the robot model is in collision with the world in a continuous manner (between two robot + * states). + * Allowed collisions are ignored. Self collisions are not checked. * @param req A CollisionRequest object that encapsulates the collision request * @param res A CollisionResult object that encapsulates the collision result - * @param state1 The kinematic state at the start of the segment for which checks are being made (this robot) - * @param state2 The kinematic state at the end of the segment for which checks are being made (this robot) - * @param other_robot The collision representation for the other robot - * @param other_state1 The kinematic state at the start of the segment for which checks are being made (other robot) - * @param other_state2 The kinematic state at the end of the segment for which checks are being made (other robot) */ - virtual void checkOtherCollision(const CollisionRequest& req, CollisionResult& res, + * @robot robot The collision model for the robot + * @param state1 The kinematic state at the start of the segment for which checks are being made + * @param state2 The kinematic state at the end of the segment for which checks are being made + * @param acm The allowed collision matrix.*/ + virtual void checkRobotCollision(const CollisionRequest& req, CollisionResult& res, const robot_state::RobotState& state1, const robot_state::RobotState& state2, - const CollisionRobot& other_robot, const robot_state::RobotState& other_state1, - const robot_state::RobotState& other_state2) const = 0; + const AllowedCollisionMatrix& acm) const = 0; - /** \brief Check for collision with a different robot (possibly a different kinematic model as well), in a continuous - * fashion. - * Allowed collisions specified by the allowed collision matrix are taken into account. + /** \brief Check whether the robot model is in collision with the world in a continuous manner (between two robot + * states). + * Allowed collisions are ignored. Self collisions are not checked. * @param req A CollisionRequest object that encapsulates the collision request * @param res A CollisionResult object that encapsulates the collision result - * @param state1 The kinematic state at the start of the segment for which checks are being made (this robot) - * @param state2 The kinematic state at the end of the segment for which checks are being made (this robot) - * @param other_robot The collision representation for the other robot - * @param other_state1 The kinematic state at the start of the segment for which checks are being made (other robot) - * @param other_state2 The kinematic state at the end of the segment for which checks are being made (other robot) - * @param acm The allowed collision matrix. */ - virtual void checkOtherCollision(const CollisionRequest& req, CollisionResult& res, - const robot_state::RobotState& state1, const robot_state::RobotState& state2, - const CollisionRobot& other_robot, const robot_state::RobotState& other_state1, - const robot_state::RobotState& other_state2, - const AllowedCollisionMatrix& acm) const = 0; + * @robot robot The collision model for the robot + * @param state1 The kinematic state at the start of the segment for which checks are being made + * @param state2 The kinematic state at the end of the segment for which checks are being made + * @param acm The allowed collision matrix.*/ + virtual void checkRobotCollision(const CollisionRequest& req, CollisionResult& res, + const robot_state::RobotState& state1, + const robot_state::RobotState& state2) const = 0; + + /** \brief The distance to self-collision given the robot is at state \e state. + @param req A DistanceRequest object that encapsulates the distance request + @param res A DistanceResult object that encapsulates the distance result + @param state The state of this robot to consider */ + virtual void distanceSelf(const DistanceRequest& req, DistanceResult& res, + const robot_state::RobotState& state) const = 0; /** \brief The distance to self-collision given the robot is at state \e state. */ inline double distanceSelf(const robot_state::RobotState& state) const @@ -186,58 +187,69 @@ class CollisionRobot return res.minimum_distance.distance; } - /** \brief The distance to self-collision given the robot is at state \e state. - @param req A DistanceRequest object that encapsulates the distance request - @param res A DistanceResult object that encapsulates the distance result - @param state The state of this robot to consider */ - virtual void distanceSelf(const DistanceRequest& req, DistanceResult& res, - const robot_state::RobotState& state) const = 0; - - /** \brief The distance to another robot instance. - - - @param state The state of this robot to consider - @param other_robot The other robot instance to measure distance to - @param other_state The state of the other robot */ - inline double distanceOther(const robot_state::RobotState& state, const CollisionRobot& other_robot, - const robot_state::RobotState& other_state) const + /** \brief Compute the distance between a robot and the world + * @param req A DistanceRequest object that encapsulates the distance request + * @param res A DistanceResult object that encapsulates the distance result + * @param robot The robot to check distance for + * @param state The state for the robot to check distances from */ + virtual void distanceRobot(const DistanceRequest& req, DistanceResult& res, + const robot_state::RobotState& state) const = 0; + + /** \brief Compute the shortest distance between a robot and the world + * @param robot The robot to check distance for + * @param state The state for the robot to check distances from + * @param verbose Output debug information about distance checks */ + inline double distanceRobot(const robot_state::RobotState& state, bool verbose = false) const { DistanceRequest req; DistanceResult res; + req.verbose = verbose; req.enableGroup(getRobotModel()); - distanceOther(req, res, state, other_robot, other_state); + + distanceRobot(req, res, state); return res.minimum_distance.distance; } - /** \brief The distance to another robot instance, ignoring distances between links that are allowed to always - collide. - - - @param state The state of this robot to consider - @param other_robot The other robot instance to measure distance to - @param other_state The state of the other robot - @param acm The collision matrix specifying which links are allowed to always collide */ - inline double distanceOther(const robot_state::RobotState& state, const CollisionRobot& other_robot, - const robot_state::RobotState& other_state, const AllowedCollisionMatrix& acm) const + /** \brief Compute the shortest distance between a robot and the world + * @param robot The robot to check distance for + * @param state The state for the robot to check distances from + * @param acm Using an allowed collision matrix has the effect of ignoring distances from links that are always + * allowed to be in collision. + * @param verbose Output debug information about distance checks */ + inline double distanceRobot(const robot_state::RobotState& state, const AllowedCollisionMatrix& acm, + bool verbose = false) const { DistanceRequest req; DistanceResult res; - req.enableGroup(getRobotModel()); req.acm = &acm; - distanceOther(req, res, state, other_robot, other_state); + req.verbose = verbose; + req.enableGroup(getRobotModel()); + + distanceRobot(req, res, state); return res.minimum_distance.distance; } - /** \brief The distance to self-collision given the robot is at state \e state. - @param req A DistanceRequest object that encapsulates the distance request - @param res A DistanceResult object that encapsulates the distance result - @param state The state of this robot to consider - @param other_robot The other robot instance to measure distance to - @param other_state The state of the other robot */ - virtual void distanceOther(const DistanceRequest& req, DistanceResult& res, const robot_state::RobotState& state, - const CollisionRobot& other_robot, const robot_state::RobotState& other_state) const = 0; + /** set the world to use. + * This can be expensive unless the new and old world are empty. + * Passing NULL will result in a new empty world being created. */ + virtual void setWorld(const WorldPtr& world); + + /** access the world geometry */ + const WorldPtr& getWorld() + { + return world_; + } + + /** access the world geometry */ + const WorldConstPtr& getWorld() const + { + return world_const_; + } + + typedef World::ObjectPtr ObjectPtr; + typedef World::ObjectConstPtr ObjectConstPtr; /** @brief The kinematic model corresponding to this collision model*/ const robot_model::RobotModelConstPtr& getRobotModel() const @@ -307,7 +319,9 @@ class CollisionRobot /** @brief The internally maintained map (from link names to scaling)*/ std::map link_scale_; + +private: + WorldPtr world_; // The world always valid, never nullptr. + WorldConstPtr world_const_; // always same as world_ }; } - -#endif diff --git a/moveit_core/collision_detection/include/moveit/collision_detection/collision_matrix.h b/moveit_core/collision_detection/include/moveit/collision_detection/collision_matrix.h index 59eb26e535..1b9e36e36e 100644 --- a/moveit_core/collision_detection/include/moveit/collision_detection/collision_matrix.h +++ b/moveit_core/collision_detection/include/moveit/collision_detection/collision_matrix.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan, E. Gil Jones */ -#ifndef MOVEIT_COLLISION_DETECTION_COLLISION_MATRIX_ -#define MOVEIT_COLLISION_DETECTION_COLLISION_MATRIX_ +#pragma once #include #include @@ -278,5 +277,3 @@ class AllowedCollisionMatrix std::map default_allowed_contacts_; }; } - -#endif diff --git a/moveit_core/collision_detection/include/moveit/collision_detection/collision_octomap_filter.h b/moveit_core/collision_detection/include/moveit/collision_detection/collision_octomap_filter.h index 466d58a685..ed36a81113 100644 --- a/moveit_core/collision_detection/include/moveit/collision_detection/collision_octomap_filter.h +++ b/moveit_core/collision_detection/include/moveit/collision_detection/collision_octomap_filter.h @@ -34,11 +34,10 @@ /* Author: Adam Leeper */ -#ifndef MOVEIT_COLLISION_DETECTION_COLLISION_OCTOMAP_FILTER_ -#define MOVEIT_COLLISION_DETECTION_COLLISION_OCTOMAP_FILTER_ +#pragma once #include -#include +#include namespace collision_detection { @@ -62,5 +61,3 @@ int refineContactNormals(const World::ObjectConstPtr& object, CollisionResult& r double cell_bbx_search_distance = 1.0, double allowed_angle_divergence = 0.0, bool estimate_depth = false, double iso_value = 0.5, double metaball_radius_multiple = 1.5); } - -#endif diff --git a/moveit_core/collision_detection/include/moveit/collision_detection/collision_plugin.h b/moveit_core/collision_detection/include/moveit/collision_detection/collision_plugin.h index 156318f4bc..320265eb6b 100644 --- a/moveit_core/collision_detection/include/moveit/collision_detection/collision_plugin.h +++ b/moveit_core/collision_detection/include/moveit/collision_detection/collision_plugin.h @@ -32,12 +32,10 @@ * POSSIBILITY OF SUCH DAMAGE. *********************************************************************/ -#ifndef MOVEIT_COLLISION_DETECTION_COLLISION_PLUGIN_H -#define MOVEIT_COLLISION_DETECTION_COLLISION_PLUGIN_H +#pragma once #include -#include -#include +#include #include namespace collision_detection @@ -53,8 +51,7 @@ MOVEIT_CLASS_FORWARD(CollisionPlugin); * { * * class MyCollisionDetectorAllocator : - * public collision_detection::CollisionDetectorAllocatorTemplate + * public collision_detection::CollisionDetectorAllocatorTemplate * { * public: * static const std::string NAME_; @@ -94,5 +91,3 @@ class CollisionPlugin }; } // namespace collision_detection - -#endif // MOVEIT_COLLISION_DETECTION_COLLISION_PLUGIN_H diff --git a/moveit_core/collision_detection/include/moveit/collision_detection/collision_tools.h b/moveit_core/collision_detection/include/moveit/collision_detection/collision_tools.h index 6893c41444..8b06686148 100644 --- a/moveit_core/collision_detection/include/moveit/collision_detection/collision_tools.h +++ b/moveit_core/collision_detection/include/moveit/collision_detection/collision_tools.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_COLLISION_DETECTION_COLLISION_TOOLS_ -#define MOVEIT_COLLISION_DETECTION_COLLISION_TOOLS_ +#pragma once #include #include @@ -72,5 +71,3 @@ bool getSensorPositioning(geometry_msgs::Point& point, const std::set - -#include -#include -#include -#include - -/** \brief Generic interface to collision detection */ -namespace collision_detection -{ -MOVEIT_CLASS_FORWARD(CollisionWorld); - -/** \brief Perform collision checking with the environment. The - * collision world maintains a representation of the environment - * that the robot is operating in. */ -class CollisionWorld : private boost::noncopyable -{ -public: - CollisionWorld(); - - explicit CollisionWorld(const WorldPtr& world); - - /** \brief A copy constructor. \e other should not be changed while the copy constructor is running. - * world must be the same world as used by other or a (not-yet-modified) copy of the world used by other */ - CollisionWorld(const CollisionWorld& other, const WorldPtr& world); - - virtual ~CollisionWorld() - { - } - - /**********************************************************************/ - /* Collision Checking Routines */ - /**********************************************************************/ - - /** \brief Check whether the robot model is in collision with itself or the world at a particular state. - * Any collision between any pair of links is checked for, NO collisions are ignored. - * @param req A CollisionRequest object that encapsulates the collision request - * @param res A CollisionResult object that encapsulates the collision result - * @param state The kinematic state for which checks are being made */ - virtual void checkCollision(const CollisionRequest& req, CollisionResult& res, const CollisionRobot& robot, - const robot_state::RobotState& state) const; - - /** \brief Check whether the robot model is in collision with itself or the world at a particular state. - * Allowed collisions specified by the allowed collision matrix are taken into account. - * @param req A CollisionRequest object that encapsulates the collision request - * @param res A CollisionResult object that encapsulates the collision result - * @param state The kinematic state for which checks are being made - * @param acm The allowed collision matrix. */ - virtual void checkCollision(const CollisionRequest& req, CollisionResult& res, const CollisionRobot& robot, - const robot_state::RobotState& state, const AllowedCollisionMatrix& acm) const; - - /** \brief Check whether the robot model is in collision with itself or the world in a continuous manner - * (between two robot states) - * Any collision between any pair of links is checked for, NO collisions are ignored. - * @param req A CollisionRequest object that encapsulates the collision request - * @param res A CollisionResult object that encapsulates the collision result - * @param state1 The kinematic state at the start of the segment for which checks are being made - * @param state2 The kinematic state at the end of the segment for which checks are being made */ - virtual void checkCollision(const CollisionRequest& req, CollisionResult& res, const CollisionRobot& robot, - const robot_state::RobotState& state1, const robot_state::RobotState& state2) const; - - /** \brief Check whether the robot model is in collision with itself or the world in a continuous manner - * (between two robot states). - * Allowed collisions specified by the allowed collision matrix are taken into account. - * @param req A CollisionRequest object that encapsulates the collision request - * @param res A CollisionResult object that encapsulates the collision result - * @param state1 The kinematic state at the start of the segment for which checks are being made - * @param state2 The kinematic state at the end of the segment for which checks are being made - * @param acm The allowed collision matrix. */ - virtual void checkCollision(const CollisionRequest& req, CollisionResult& res, const CollisionRobot& robot, - const robot_state::RobotState& state1, const robot_state::RobotState& state2, - const AllowedCollisionMatrix& acm) const; - - /** \brief Check whether the robot model is in collision with the world. Any collisions between a robot link - * and the world are considered. Self collisions are not checked. - * @param req A CollisionRequest object that encapsulates the collision request - * @param res A CollisionResult object that encapsulates the collision result - * @robot robot The collision model for the robot - * @param state The kinematic state for which checks are being made - */ - virtual void checkRobotCollision(const CollisionRequest& req, CollisionResult& res, const CollisionRobot& robot, - const robot_state::RobotState& state) const = 0; - - /** \brief Check whether the robot model is in collision with the world. - * Allowed collisions are ignored. Self collisions are not checked. - * @param req A CollisionRequest object that encapsulates the collision request - * @param res A CollisionResult object that encapsulates the collision result - * @robot robot The collision model for the robot - * @param state The kinematic state for which checks are being made - * @param acm The allowed collision matrix.*/ - virtual void checkRobotCollision(const CollisionRequest& req, CollisionResult& res, const CollisionRobot& robot, - const robot_state::RobotState& state, const AllowedCollisionMatrix& acm) const = 0; - - /** \brief Check whether the robot model is in collision with the world in a continuous manner (between two robot - * states). - * Any collisions between a robot link and the world are considered. Self collisions are not checked. - * @param req A CollisionRequest object that encapsulates the collision request - * @param res A CollisionResult object that encapsulates the collision result - * @robot robot The collision model for the robot - * @param state1 The kinematic state at the start of the segment for which checks are being made - * @param state2 The kinematic state at the end of the segment for which checks are being made */ - virtual void checkRobotCollision(const CollisionRequest& req, CollisionResult& res, const CollisionRobot& robot, - const robot_state::RobotState& state1, - const robot_state::RobotState& state2) const = 0; - - /** \brief Check whether the robot model is in collision with the world in a continuous manner (between two robot - * states). - * Allowed collisions are ignored. Self collisions are not checked. - * @param req A CollisionRequest object that encapsulates the collision request - * @param res A CollisionResult object that encapsulates the collision result - * @robot robot The collision model for the robot - * @param state1 The kinematic state at the start of the segment for which checks are being made - * @param state2 The kinematic state at the end of the segment for which checks are being made - * @param acm The allowed collision matrix.*/ - virtual void checkRobotCollision(const CollisionRequest& req, CollisionResult& res, const CollisionRobot& robot, - const robot_state::RobotState& state1, const robot_state::RobotState& state2, - const AllowedCollisionMatrix& acm) const = 0; - - /** \brief Check whether a given set of objects is in collision with objects from another world. - * Any contacts are considered. - * @param req A CollisionRequest object that encapsulates the collision request - * @param res A CollisionResult object that encapsulates the collision result - * @param other_world The other collision world - */ - virtual void checkWorldCollision(const CollisionRequest& req, CollisionResult& res, - const CollisionWorld& other_world) const = 0; - - /** \brief Check whether a given set of objects is in collision with objects from another world. - * Allowed collisions are ignored. Any contacts are considered. - * @param req A CollisionRequest object that encapsulates the collision request - * @param res A CollisionResult object that encapsulates the collision result - * @param other_world The other collision world - * @param acm The allowed collision matrix.*/ - virtual void checkWorldCollision(const CollisionRequest& req, CollisionResult& res, const CollisionWorld& other_world, - const AllowedCollisionMatrix& acm) const = 0; - - /** \brief Compute the shortest distance between a robot and the world - * @param robot The robot to check distance for - * @param state The state for the robot to check distances from - * @param verbose Output debug information about distance checks */ - inline double distanceRobot(const CollisionRobot& robot, const robot_state::RobotState& state, - bool verbose = false) const - { - DistanceRequest req; - DistanceResult res; - - req.verbose = verbose; - req.enableGroup(robot.getRobotModel()); - - distanceRobot(req, res, robot, state); - return res.minimum_distance.distance; - } - - /** \brief Compute the shortest distance between a robot and the world - * @param robot The robot to check distance for - * @param state The state for the robot to check distances from - * @param acm Using an allowed collision matrix has the effect of ignoring distances from links that are always - * allowed to be in collision. - * @param verbose Output debug information about distance checks */ - inline double distanceRobot(const CollisionRobot& robot, const robot_state::RobotState& state, - const AllowedCollisionMatrix& acm, bool verbose = false) const - { - DistanceRequest req; - DistanceResult res; - - req.acm = &acm; - req.verbose = verbose; - req.enableGroup(robot.getRobotModel()); - - distanceRobot(req, res, robot, state); - return res.minimum_distance.distance; - } - - /** \brief Compute the distance between a robot and the world - * @param req A DistanceRequest object that encapsulates the distance request - * @param res A DistanceResult object that encapsulates the distance result - * @param robot The robot to check distance for - * @param state The state for the robot to check distances from */ - virtual void distanceRobot(const DistanceRequest& req, DistanceResult& res, const CollisionRobot& robot, - const robot_state::RobotState& state) const = 0; - - /** \brief The shortest distance to another world instance (\e world) - * @param verbose Output debug information about distance checks */ - inline double distanceWorld(const CollisionWorld& world, bool verbose = false) const - { - DistanceRequest req; - DistanceResult res; - - req.verbose = verbose; - distanceWorld(req, res, world); - - return res.minimum_distance.distance; - } - - /** \brief The shortest distance to another world instance (\e world), ignoring the distances between world elements - * that are allowed to collide (as specified by \e acm) - * @param verbose Output debug information about distance checks */ - inline double distanceWorld(const CollisionWorld& world, const AllowedCollisionMatrix& acm, - bool verbose = false) const - { - DistanceRequest req; - DistanceResult res; - - req.acm = &acm; - req.verbose = verbose; - distanceWorld(req, res, world); - - return res.minimum_distance.distance; - } - - /** \brief Compute the distance between another world - * @param req A DistanceRequest object that encapsulates the distance request - * @param res A DistanceResult object that encapsulates the distance result - * @param world The world to check distance for */ - virtual void distanceWorld(const DistanceRequest& req, DistanceResult& res, const CollisionWorld& world) const = 0; - - /** set the world to use. - * This can be expensive unless the new and old world are empty. - * Passing NULL will result in a new empty world being created. */ - virtual void setWorld(const WorldPtr& world); - - /** access the world geometry */ - const WorldPtr& getWorld() - { - return world_; - } - - /** access the world geometry */ - const WorldConstPtr& getWorld() const - { - return world_const_; - } - - typedef World::ObjectPtr ObjectPtr; - typedef World::ObjectConstPtr ObjectConstPtr; - -private: - WorldPtr world_; // The world. Always valid. Never NULL. - WorldConstPtr world_const_; // always same as world_ -}; -} - -#endif diff --git a/moveit_core/collision_detection/include/moveit/collision_detection/world.h b/moveit_core/collision_detection/include/moveit/collision_detection/world.h index f461043f4a..ad21d3a034 100644 --- a/moveit_core/collision_detection/include/moveit/collision_detection/world.h +++ b/moveit_core/collision_detection/include/moveit/collision_detection/world.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan, Acorn Pooley, Sachin Chitta */ -#ifndef MOVEIT_COLLISION_DETECTION_WORLD_ -#define MOVEIT_COLLISION_DETECTION_WORLD_ +#pragma once #include @@ -288,7 +287,7 @@ class World /** The objects maintained in the world */ std::map objects_; - /* observers to call when something changes */ + /** Wrapper for a callback function to call when something changes in the world */ class Observer { public: @@ -297,8 +296,8 @@ class World } ObserverCallbackFn callback_; }; + + /// All registered observers of this world representation std::vector observers_; }; } - -#endif diff --git a/moveit_core/collision_detection/include/moveit/collision_detection/world_diff.h b/moveit_core/collision_detection/include/moveit/collision_detection/world_diff.h index 5f2013d7f0..84ae6a522c 100644 --- a/moveit_core/collision_detection/include/moveit/collision_detection/world_diff.h +++ b/moveit_core/collision_detection/include/moveit/collision_detection/world_diff.h @@ -34,8 +34,7 @@ /* Author: Acorn Pooley, Ioan Sucan, Sachin Chitta */ -#ifndef MOVEIT_COLLISION_DETECTION_WORLD_DIFF_ -#define MOVEIT_COLLISION_DETECTION_WORLD_DIFF_ +#pragma once #include #include @@ -126,5 +125,3 @@ class WorldDiff WorldWeakPtr world_; }; } - -#endif diff --git a/moveit_core/collision_detection/src/allvalid/collision_world_allvalid.cpp b/moveit_core/collision_detection/src/allvalid/collision_env_allvalid.cpp similarity index 53% rename from moveit_core/collision_detection/src/allvalid/collision_world_allvalid.cpp rename to moveit_core/collision_detection/src/allvalid/collision_env_allvalid.cpp index 023f308a62..bf84110b23 100644 --- a/moveit_core/collision_detection/src/allvalid/collision_world_allvalid.cpp +++ b/moveit_core/collision_detection/src/allvalid/collision_env_allvalid.cpp @@ -32,118 +32,104 @@ * POSSIBILITY OF SUCH DAMAGE. *********************************************************************/ -/* Author: Ioan Sucan */ +/* Author: Ioan Sucan, Jia Pan, Jens Petit */ -#include +#include +#include -collision_detection::CollisionWorldAllValid::CollisionWorldAllValid() : CollisionWorld() -{ -} +const std::string collision_detection::CollisionDetectorAllocatorAllValid::NAME("ALL_VALID"); -collision_detection::CollisionWorldAllValid::CollisionWorldAllValid(const WorldPtr& world) : CollisionWorld(world) +collision_detection::CollisionEnvAllValid::CollisionEnvAllValid(const robot_model::RobotModelConstPtr& robot_model, + double padding, double scale) + : CollisionEnv(robot_model, padding, scale) { } -collision_detection::CollisionWorldAllValid::CollisionWorldAllValid(const CollisionWorld& other, const WorldPtr& world) - : CollisionWorld(other, world) +collision_detection::CollisionEnvAllValid::CollisionEnvAllValid(const robot_model::RobotModelConstPtr& robot_model, + const WorldPtr& world, double padding, double scale) + : CollisionEnv(robot_model, world, padding, scale) { } -void collision_detection::CollisionWorldAllValid::checkRobotCollision(const CollisionRequest& req, CollisionResult& res, - const CollisionRobot& robot, - const robot_state::RobotState& state) const +collision_detection::CollisionEnvAllValid::CollisionEnvAllValid(const CollisionEnv& other, const WorldPtr& world) + : CollisionEnv(other, world) { - res.collision = false; - if (req.verbose) - ROS_INFO_NAMED("collision_detection", "Using AllValid collision detection. No collision checking is performed."); } -void collision_detection::CollisionWorldAllValid::checkRobotCollision(const CollisionRequest& req, CollisionResult& res, - const CollisionRobot& robot, - const robot_state::RobotState& state, - const AllowedCollisionMatrix& acm) const +void collision_detection::CollisionEnvAllValid::checkRobotCollision(const CollisionRequest& req, CollisionResult& res, + const robot_state::RobotState& state) const { res.collision = false; if (req.verbose) ROS_INFO_NAMED("collision_detection", "Using AllValid collision detection. No collision checking is performed."); } -void collision_detection::CollisionWorldAllValid::checkRobotCollision(const CollisionRequest& req, CollisionResult& res, - const CollisionRobot& robot, - const robot_state::RobotState& state1, - const robot_state::RobotState& state2) const +void collision_detection::CollisionEnvAllValid::checkRobotCollision(const CollisionRequest& req, CollisionResult& res, + const robot_state::RobotState& state, + const AllowedCollisionMatrix& acm) const { res.collision = false; if (req.verbose) ROS_INFO_NAMED("collision_detection", "Using AllValid collision detection. No collision checking is performed."); } -void collision_detection::CollisionWorldAllValid::checkRobotCollision(const CollisionRequest& req, CollisionResult& res, - const CollisionRobot& robot, - const robot_state::RobotState& state1, - const robot_state::RobotState& state2, - const AllowedCollisionMatrix& acm) const +void collision_detection::CollisionEnvAllValid::checkRobotCollision(const CollisionRequest& req, CollisionResult& res, + const robot_state::RobotState& state1, + const robot_state::RobotState& state2) const { res.collision = false; if (req.verbose) ROS_INFO_NAMED("collision_detection", "Using AllValid collision detection. No collision checking is performed."); } -void collision_detection::CollisionWorldAllValid::checkWorldCollision(const CollisionRequest& req, CollisionResult& res, - const CollisionWorld& other_world) const +void collision_detection::CollisionEnvAllValid::checkRobotCollision(const CollisionRequest& req, CollisionResult& res, + const robot_state::RobotState& state1, + const robot_state::RobotState& state2, + const AllowedCollisionMatrix& acm) const { res.collision = false; if (req.verbose) ROS_INFO_NAMED("collision_detection", "Using AllValid collision detection. No collision checking is performed."); } -void collision_detection::CollisionWorldAllValid::checkWorldCollision(const CollisionRequest& req, CollisionResult& res, - const CollisionWorld& other_world, - const AllowedCollisionMatrix& acm) const +void collision_detection::CollisionEnvAllValid::distanceRobot(const collision_detection::DistanceRequest& req, + collision_detection::DistanceResult& res, + const moveit::core::RobotState& state) const { res.collision = false; - if (req.verbose) - ROS_INFO_NAMED("collision_detection", "Using AllValid collision detection. No collision checking is performed."); } -double collision_detection::CollisionWorldAllValid::distanceRobot(const CollisionRobot& robot, - const robot_state::RobotState& state) const +double collision_detection::CollisionEnvAllValid::distanceRobot(const robot_state::RobotState& state) const { return 0.0; } -double collision_detection::CollisionWorldAllValid::distanceRobot(const CollisionRobot& robot, - const robot_state::RobotState& state, - const AllowedCollisionMatrix& acm) const +double collision_detection::CollisionEnvAllValid::distanceRobot(const robot_state::RobotState& state, + const AllowedCollisionMatrix& acm) const { return 0.0; } -void collision_detection::CollisionWorldAllValid::distanceRobot(const collision_detection::DistanceRequest& req, - collision_detection::DistanceResult& res, - const collision_detection::CollisionRobot& robot, - const moveit::core::RobotState& state) const +void collision_detection::CollisionEnvAllValid::checkSelfCollision(const CollisionRequest& req, CollisionResult& res, + const robot_state::RobotState& state) const { res.collision = false; + if (req.verbose) + ROS_INFO_NAMED("collision_detection", "Using AllValid collision detection. No collision checking is performed."); } -double collision_detection::CollisionWorldAllValid::distanceWorld(const CollisionWorld& world) const -{ - return 0.0; -} - -double collision_detection::CollisionWorldAllValid::distanceWorld(const CollisionWorld& world, - const AllowedCollisionMatrix& acm) const +void collision_detection::CollisionEnvAllValid::checkSelfCollision(const CollisionRequest& req, CollisionResult& res, + const robot_state::RobotState& state, + const AllowedCollisionMatrix& acm) const { - return 0.0; + res.collision = false; + if (req.verbose) + ROS_INFO_NAMED("collision_detection", "Using AllValid collision detection. No collision checking is performed."); } -void collision_detection::CollisionWorldAllValid::distanceWorld(const collision_detection::DistanceRequest& req, - collision_detection::DistanceResult& res, - const collision_detection::CollisionWorld& world) const +void collision_detection::CollisionEnvAllValid::distanceSelf(const collision_detection::DistanceRequest& req, + collision_detection::DistanceResult& res, + const moveit::core::RobotState& state) const { res.collision = false; } - -#include -const std::string collision_detection::CollisionDetectorAllocatorAllValid::NAME("ALL_VALID"); diff --git a/moveit_core/collision_detection/src/allvalid/collision_robot_allvalid.cpp b/moveit_core/collision_detection/src/allvalid/collision_robot_allvalid.cpp deleted file mode 100644 index 963f374711..0000000000 --- a/moveit_core/collision_detection/src/allvalid/collision_robot_allvalid.cpp +++ /dev/null @@ -1,171 +0,0 @@ -/********************************************************************* - * Software License Agreement (BSD License) - * - * Copyright (c) 2011, Willow Garage, Inc. - * 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 and/or other materials provided - * with the distribution. - * * Neither the name of Willow Garage nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 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 OWNER 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. - *********************************************************************/ - -/* Author: Ioan Sucan, Jia Pan */ - -#include - -collision_detection::CollisionRobotAllValid::CollisionRobotAllValid(const robot_model::RobotModelConstPtr& robot_model, - double padding, double scale) - : CollisionRobot(robot_model, padding, scale) -{ -} - -collision_detection::CollisionRobotAllValid::CollisionRobotAllValid(const CollisionRobot& other) : CollisionRobot(other) -{ -} - -void collision_detection::CollisionRobotAllValid::checkSelfCollision(const CollisionRequest& req, CollisionResult& res, - const robot_state::RobotState& state) const -{ - res.collision = false; - if (req.verbose) - ROS_INFO_NAMED("collision_detection", "Using AllValid collision detection. No collision checking is performed."); -} - -void collision_detection::CollisionRobotAllValid::checkSelfCollision(const CollisionRequest& req, CollisionResult& res, - const robot_state::RobotState& state, - const AllowedCollisionMatrix& acm) const -{ - res.collision = false; - if (req.verbose) - ROS_INFO_NAMED("collision_detection", "Using AllValid collision detection. No collision checking is performed."); -} - -void collision_detection::CollisionRobotAllValid::checkSelfCollision(const CollisionRequest& req, CollisionResult& res, - const robot_state::RobotState& state1, - const robot_state::RobotState& state2) const -{ - res.collision = false; - if (req.verbose) - ROS_INFO_NAMED("collision_detection", "Using AllValid collision detection. No collision checking is performed."); -} - -void collision_detection::CollisionRobotAllValid::checkSelfCollision(const CollisionRequest& req, CollisionResult& res, - const robot_state::RobotState& state1, - const robot_state::RobotState& state2, - const AllowedCollisionMatrix& acm) const -{ - res.collision = false; - if (req.verbose) - ROS_INFO_NAMED("collision_detection", "Using AllValid collision detection. No collision checking is performed."); -} - -void collision_detection::CollisionRobotAllValid::checkOtherCollision(const CollisionRequest& req, CollisionResult& res, - const robot_state::RobotState& state, - const CollisionRobot& other_robot, - const robot_state::RobotState& other_state) const -{ - res.collision = false; - if (req.verbose) - ROS_INFO_NAMED("collision_detection", "Using AllValid collision detection. No collision checking is performed."); -} - -void collision_detection::CollisionRobotAllValid::checkOtherCollision(const CollisionRequest& req, CollisionResult& res, - const robot_state::RobotState& state, - const CollisionRobot& other_robot, - const robot_state::RobotState& other_state, - const AllowedCollisionMatrix& acm) const -{ - res.collision = false; - if (req.verbose) - ROS_INFO_NAMED("collision_detection", "Using AllValid collision detection. No collision checking is performed."); -} - -void collision_detection::CollisionRobotAllValid::checkOtherCollision(const CollisionRequest& req, CollisionResult& res, - const robot_state::RobotState& state1, - const robot_state::RobotState& state2, - const CollisionRobot& other_robot, - const robot_state::RobotState& other_state1, - const robot_state::RobotState& other_state2) const -{ - res.collision = false; - if (req.verbose) - ROS_INFO_NAMED("collision_detection", "Using AllValid collision detection. No collision checking is performed."); -} - -void collision_detection::CollisionRobotAllValid::checkOtherCollision(const CollisionRequest& req, CollisionResult& res, - const robot_state::RobotState& state1, - const robot_state::RobotState& state2, - const CollisionRobot& other_robot, - const robot_state::RobotState& other_state1, - const robot_state::RobotState& other_state2, - const AllowedCollisionMatrix& acm) const -{ - res.collision = false; - if (req.verbose) - ROS_INFO_NAMED("collision_detection", "Using AllValid collision detection. No collision checking is performed."); -} - -double collision_detection::CollisionRobotAllValid::distanceSelf(const robot_state::RobotState& state) const -{ - return 0.0; -} - -double collision_detection::CollisionRobotAllValid::distanceSelf(const robot_state::RobotState& state, - const AllowedCollisionMatrix& acm) const -{ - return 0.0; -} - -void collision_detection::CollisionRobotAllValid::distanceSelf(const collision_detection::DistanceRequest& req, - collision_detection::DistanceResult& res, - const moveit::core::RobotState& state) const -{ - res.collision = false; -} - -double collision_detection::CollisionRobotAllValid::distanceOther(const robot_state::RobotState& state, - const CollisionRobot& other_robot, - const robot_state::RobotState& other_state) const -{ - return 0.0; -} - -double collision_detection::CollisionRobotAllValid::distanceOther(const robot_state::RobotState& state, - const CollisionRobot& other_robot, - const robot_state::RobotState& other_state, - const AllowedCollisionMatrix& acm) const -{ - return 0.0; -} - -void collision_detection::CollisionRobotAllValid::distanceOther(const collision_detection::DistanceRequest& req, - collision_detection::DistanceResult& res, - const moveit::core::RobotState& state, - const collision_detection::CollisionRobot& other_robot, - const moveit::core::RobotState& other_state) const -{ - res.collision = false; -} diff --git a/moveit_core/collision_detection/src/collision_robot.cpp b/moveit_core/collision_detection/src/collision_env.cpp similarity index 66% rename from moveit_core/collision_detection/src/collision_robot.cpp rename to moveit_core/collision_detection/src/collision_env.cpp index c3e27751a6..131b25676c 100644 --- a/moveit_core/collision_detection/src/collision_robot.cpp +++ b/moveit_core/collision_detection/src/collision_env.cpp @@ -14,7 +14,7 @@ * copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials provided * with the distribution. - * * Neither the name of Willow Garage nor the names of its + * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * @@ -32,9 +32,9 @@ * POSSIBILITY OF SUCH DAMAGE. *********************************************************************/ -/* Author: Ioan Sucan */ +/* Author: Ioan Sucan, Jens Petit */ -#include +#include #include static inline bool validateScale(double scale) @@ -69,8 +69,8 @@ static inline bool validatePadding(double padding) namespace collision_detection { -CollisionRobot::CollisionRobot(const robot_model::RobotModelConstPtr& model, double padding, double scale) - : robot_model_(model) +CollisionEnv::CollisionEnv(const robot_model::RobotModelConstPtr& model, double padding, double scale) + : robot_model_(model), world_(new World()), world_const_(world_) { if (!validateScale(scale)) scale = 1.0; @@ -85,13 +85,30 @@ CollisionRobot::CollisionRobot(const robot_model::RobotModelConstPtr& model, dou } } -CollisionRobot::CollisionRobot(const CollisionRobot& other) : robot_model_(other.robot_model_) +CollisionEnv::CollisionEnv(const robot_model::RobotModelConstPtr& model, const WorldPtr& world, double padding, + double scale) + : robot_model_(model), world_(world), world_const_(world_) +{ + if (!validateScale(scale)) + scale = 1.0; + if (!validatePadding(padding)) + padding = 0.0; + + const std::vector& links = robot_model_->getLinkModelsWithCollisionGeometry(); + for (auto link : links) + { + link_padding_[link->getName()] = padding; + link_scale_[link->getName()] = scale; + } +} + +CollisionEnv::CollisionEnv(const CollisionEnv& other, const WorldPtr& world) + : robot_model_(other.robot_model_), world_(world), world_const_(world) { link_padding_ = other.link_padding_; link_scale_ = other.link_scale_; } - -void CollisionRobot::setPadding(double padding) +void CollisionEnv::setPadding(double padding) { if (!validatePadding(padding)) return; @@ -107,7 +124,7 @@ void CollisionRobot::setPadding(double padding) updatedPaddingOrScaling(u); } -void CollisionRobot::setScale(double scale) +void CollisionEnv::setScale(double scale) { if (!validateScale(scale)) return; @@ -123,8 +140,9 @@ void CollisionRobot::setScale(double scale) updatedPaddingOrScaling(u); } -void CollisionRobot::setLinkPadding(const std::string& link_name, double padding) +void CollisionEnv::setLinkPadding(const std::string& link_name, double padding) { + validatePadding(padding); bool update = getLinkPadding(link_name) != padding; link_padding_[link_name] = padding; if (update) @@ -134,7 +152,7 @@ void CollisionRobot::setLinkPadding(const std::string& link_name, double padding } } -double CollisionRobot::getLinkPadding(const std::string& link_name) const +double CollisionEnv::getLinkPadding(const std::string& link_name) const { auto it = link_padding_.find(link_name); if (it != link_padding_.end()) @@ -143,11 +161,12 @@ double CollisionRobot::getLinkPadding(const std::string& link_name) const return 0.0; } -void CollisionRobot::setLinkPadding(const std::map& padding) +void CollisionEnv::setLinkPadding(const std::map& padding) { std::vector u; for (const auto& link_pad_pair : padding) { + validatePadding(link_pad_pair.second); bool update = getLinkPadding(link_pad_pair.first) != link_pad_pair.second; link_padding_[link_pad_pair.first] = link_pad_pair.second; if (update) @@ -157,13 +176,14 @@ void CollisionRobot::setLinkPadding(const std::map& padding updatedPaddingOrScaling(u); } -const std::map& CollisionRobot::getLinkPadding() const +const std::map& CollisionEnv::getLinkPadding() const { return link_padding_; } -void CollisionRobot::setLinkScale(const std::string& link_name, double scale) +void CollisionEnv::setLinkScale(const std::string& link_name, double scale) { + validateScale(scale); bool update = getLinkScale(link_name) != scale; link_scale_[link_name] = scale; if (update) @@ -173,7 +193,7 @@ void CollisionRobot::setLinkScale(const std::string& link_name, double scale) } } -double CollisionRobot::getLinkScale(const std::string& link_name) const +double CollisionEnv::getLinkScale(const std::string& link_name) const { auto it = link_scale_.find(link_name); if (it != link_scale_.end()) @@ -182,7 +202,7 @@ double CollisionRobot::getLinkScale(const std::string& link_name) const return 1.0; } -void CollisionRobot::setLinkScale(const std::map& scale) +void CollisionEnv::setLinkScale(const std::map& scale) { std::vector u; for (const auto& link_scale_pair : scale) @@ -196,16 +216,17 @@ void CollisionRobot::setLinkScale(const std::map& scale) updatedPaddingOrScaling(u); } -const std::map& CollisionRobot::getLinkScale() const +const std::map& CollisionEnv::getLinkScale() const { return link_scale_; } -void CollisionRobot::setPadding(const std::vector& padding) +void CollisionEnv::setPadding(const std::vector& padding) { std::vector u; for (const auto& p : padding) { + validatePadding(p.padding); bool update = getLinkPadding(p.link_name) != p.padding; link_padding_[p.link_name] = p.padding; if (update) @@ -215,11 +236,12 @@ void CollisionRobot::setPadding(const std::vector& pad updatedPaddingOrScaling(u); } -void CollisionRobot::setScale(const std::vector& scale) +void CollisionEnv::setScale(const std::vector& scale) { std::vector u; for (const auto& s : scale) { + validateScale(s.scale); bool update = getLinkScale(s.link_name) != s.scale; link_scale_[s.link_name] = s.scale; if (update) @@ -229,7 +251,7 @@ void CollisionRobot::setScale(const std::vector& scale) updatedPaddingOrScaling(u); } -void CollisionRobot::getPadding(std::vector& padding) const +void CollisionEnv::getPadding(std::vector& padding) const { padding.clear(); for (const auto& lp : link_padding_) @@ -241,7 +263,7 @@ void CollisionRobot::getPadding(std::vector& padding) } } -void CollisionRobot::getScale(std::vector& scale) const +void CollisionEnv::getScale(std::vector& scale) const { scale.clear(); for (const auto& ls : link_scale_) @@ -253,8 +275,33 @@ void CollisionRobot::getScale(std::vector& scale) const } } -void CollisionRobot::updatedPaddingOrScaling(const std::vector& links) +void CollisionEnv::updatedPaddingOrScaling(const std::vector& links) +{ +} + +void CollisionEnv::setWorld(const WorldPtr& world) +{ + world_ = world; + if (!world_) + world_.reset(new World()); + + world_const_ = world; +} + +void CollisionEnv::checkCollision(const CollisionRequest& req, CollisionResult& res, + const robot_state::RobotState& state) const +{ + checkSelfCollision(req, res, state); + if (!res.collision || (req.contacts && res.contacts.size() < req.max_contacts)) + checkRobotCollision(req, res, state); +} + +void CollisionEnv::checkCollision(const CollisionRequest& req, CollisionResult& res, + const robot_state::RobotState& state, const AllowedCollisionMatrix& acm) const { + checkSelfCollision(req, res, state, acm); + if (!res.collision || (req.contacts && res.contacts.size() < req.max_contacts)) + checkRobotCollision(req, res, state, acm); } } // end of namespace collision_detection diff --git a/moveit_core/collision_detection/src/collision_octomap_filter.cpp b/moveit_core/collision_detection/src/collision_octomap_filter.cpp index 5305727973..051a7afd25 100644 --- a/moveit_core/collision_detection/src/collision_octomap_filter.cpp +++ b/moveit_core/collision_detection/src/collision_octomap_filter.cpp @@ -36,7 +36,6 @@ #include #include -#include #include #include #include diff --git a/moveit_core/collision_detection/src/collision_world.cpp b/moveit_core/collision_detection/src/collision_world.cpp deleted file mode 100644 index ec2f3abcf9..0000000000 --- a/moveit_core/collision_detection/src/collision_world.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/********************************************************************* - * Software License Agreement (BSD License) - * - * Copyright (c) 2011, Willow Garage, Inc. - * 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 and/or other materials provided - * with the distribution. - * * Neither the name of Willow Garage nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 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 OWNER 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. - *********************************************************************/ - -/* Author: Ioan Sucan */ - -#include -#include - -namespace collision_detection -{ -CollisionWorld::CollisionWorld() : world_(new World()), world_const_(world_) -{ -} - -CollisionWorld::CollisionWorld(const WorldPtr& world) : world_(world), world_const_(world) -{ -} - -CollisionWorld::CollisionWorld(const CollisionWorld& other, const WorldPtr& world) : world_(world), world_const_(world) -{ -} - -void CollisionWorld::checkCollision(const CollisionRequest& req, CollisionResult& res, const CollisionRobot& robot, - const robot_state::RobotState& state) const -{ - robot.checkSelfCollision(req, res, state); - if (!res.collision || (req.contacts && res.contacts.size() < req.max_contacts)) - checkRobotCollision(req, res, robot, state); -} - -void CollisionWorld::checkCollision(const CollisionRequest& req, CollisionResult& res, const CollisionRobot& robot, - const robot_state::RobotState& state, const AllowedCollisionMatrix& acm) const -{ - robot.checkSelfCollision(req, res, state, acm); - if (!res.collision || (req.contacts && res.contacts.size() < req.max_contacts)) - checkRobotCollision(req, res, robot, state, acm); -} - -void CollisionWorld::checkCollision(const CollisionRequest& req, CollisionResult& res, const CollisionRobot& robot, - const robot_state::RobotState& state1, const robot_state::RobotState& state2) const -{ - robot.checkSelfCollision(req, res, state1, state2); - if (!res.collision || (req.contacts && res.contacts.size() < req.max_contacts)) - checkRobotCollision(req, res, robot, state1, state2); -} - -void CollisionWorld::checkCollision(const CollisionRequest& req, CollisionResult& res, const CollisionRobot& robot, - const robot_state::RobotState& state1, const robot_state::RobotState& state2, - const AllowedCollisionMatrix& acm) const -{ - robot.checkSelfCollision(req, res, state1, state2, acm); - if (!res.collision || (req.contacts && res.contacts.size() < req.max_contacts)) - checkRobotCollision(req, res, robot, state1, state2, acm); -} - -void CollisionWorld::setWorld(const WorldPtr& world) -{ - world_ = world; - if (!world_) - world_.reset(new World()); - - world_const_ = world; -} - -} // end of namespace collision_detection \ No newline at end of file diff --git a/moveit_core/collision_detection/src/world.cpp b/moveit_core/collision_detection/src/world.cpp index 4fbf16e76c..f2a404ec8f 100644 --- a/moveit_core/collision_detection/src/world.cpp +++ b/moveit_core/collision_detection/src/world.cpp @@ -168,6 +168,7 @@ const Eigen::Isometry3d& World::getTransform(const std::string& name) const const Eigen::Isometry3d& World::getTransform(const std::string& name, bool& frame_found) const { + frame_found = true; std::map::const_iterator it = objects_.find(name); if (it != objects_.end()) return it->second->shape_poses_[0]; @@ -180,10 +181,7 @@ const Eigen::Isometry3d& World::getTransform(const std::string& name, bool& fram { auto it = object.second->subframe_poses_.find(name.substr(object.first.length() + 1)); if (it != object.second->subframe_poses_.end()) - { - frame_found = true; return it->second; - } } } } diff --git a/moveit_core/collision_detection/test/test_all_valid.cpp b/moveit_core/collision_detection/test/test_all_valid.cpp index 47a33a81cf..435f473980 100644 --- a/moveit_core/collision_detection/test/test_all_valid.cpp +++ b/moveit_core/collision_detection/test/test_all_valid.cpp @@ -36,14 +36,12 @@ #include #include -#include -#include +#include TEST(AllValid, Instantiate) { using namespace collision_detection; CollisionDetectorAllocatorAllValid allocator; - CollisionWorldAllValid world; urdf::ModelInterfaceSharedPtr urdf_model; urdf_model.reset(new urdf::ModelInterface()); @@ -51,11 +49,11 @@ TEST(AllValid, Instantiate) srdf_model.reset(new srdf::Model()); robot_model::RobotModelConstPtr robot_model; robot_model.reset(new robot_model::RobotModel(urdf_model, srdf_model)); - CollisionRobotAllValid robot(robot_model); + CollisionEnvAllValid env(robot_model); } int main(int argc, char** argv) { testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); -} \ No newline at end of file +} diff --git a/moveit_core/collision_detection_fcl/CMakeLists.txt b/moveit_core/collision_detection_fcl/CMakeLists.txt index 8e73a17709..939f958d32 100644 --- a/moveit_core/collision_detection_fcl/CMakeLists.txt +++ b/moveit_core/collision_detection_fcl/CMakeLists.txt @@ -2,8 +2,7 @@ set(MOVEIT_LIB_NAME moveit_collision_detection_fcl) add_library(${MOVEIT_LIB_NAME} src/collision_common.cpp - src/collision_robot_fcl.cpp - src/collision_world_fcl.cpp + src/collision_env_fcl.cpp ) set_target_properties(${MOVEIT_LIB_NAME} PROPERTIES VERSION "${${PROJECT_NAME}_VERSION}") @@ -17,7 +16,8 @@ target_link_libraries(collision_detector_fcl_plugin ${catkin_LIBRARIES} ${MOVEIT install(TARGETS ${MOVEIT_LIB_NAME} collision_detector_fcl_plugin LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} - ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}) + ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}) install(DIRECTORY include/ DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}) @@ -29,4 +29,7 @@ if(CATKIN_ENABLE_TESTING) catkin_add_gtest(test_fcl_collision_detection test/test_fcl_collision_detection.cpp) target_link_libraries(test_fcl_collision_detection moveit_test_utils ${MOVEIT_LIB_NAME} ${Boost_LIBRARIES}) + + catkin_add_gtest(test_fcl_collision_env test/test_fcl_env.cpp) + target_link_libraries(test_fcl_collision_env moveit_test_utils ${MOVEIT_LIB_NAME} ${Boost_LIBRARIES}) endif() diff --git a/moveit_core/collision_detection_fcl/include/moveit/collision_detection_fcl/collision_common.h b/moveit_core/collision_detection_fcl/include/moveit/collision_detection_fcl/collision_common.h index f9fce66b21..c5b89cca28 100644 --- a/moveit_core/collision_detection_fcl/include/moveit/collision_detection_fcl/collision_common.h +++ b/moveit_core/collision_detection_fcl/include/moveit/collision_detection_fcl/collision_common.h @@ -34,11 +34,10 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_COLLISION_DETECTION_FCL_COLLISION_COMMON_ -#define MOVEIT_COLLISION_DETECTION_FCL_COLLISION_COMMON_ +#pragma once #include -#include +#include #include #include @@ -59,24 +58,29 @@ namespace collision_detection { MOVEIT_STRUCT_FORWARD(CollisionGeometryData); +/** \brief Wrapper around world, link and attached objects' geometry data. */ struct CollisionGeometryData { + /** \brief Constructor for a robot link collision geometry object. */ CollisionGeometryData(const robot_model::LinkModel* link, int index) : type(BodyTypes::ROBOT_LINK), shape_index(index) { ptr.link = link; } + /** \brief Constructor for a new collision geometry object which is attached to the robot. */ CollisionGeometryData(const robot_state::AttachedBody* ab, int index) : type(BodyTypes::ROBOT_ATTACHED), shape_index(index) { ptr.ab = ab; } + /** \brief Constructor for a new world collision geometry. */ CollisionGeometryData(const World::Object* obj, int index) : type(BodyTypes::WORLD_OBJECT), shape_index(index) { ptr.obj = obj; } + /** \brief Returns the name which is saved in the member pointed to in \e ptr. */ const std::string& getID() const { switch (type) @@ -91,6 +95,7 @@ struct CollisionGeometryData return ptr.obj->id_; } + /** \brief Returns a string of the corresponding \e type. */ std::string getTypeString() const { switch (type) @@ -105,14 +110,22 @@ struct CollisionGeometryData return "Object"; } - /** \brief Check if two CollisionGeometryData objects point to the same source object */ + /** \brief Check if two CollisionGeometryData objects point to the same source object. */ bool sameObject(const CollisionGeometryData& other) const { return type == other.type && ptr.raw == other.ptr.raw; } + /** \brief Indicates the body type of the object. */ BodyType type; + + /** \brief Multiple \e CollisionGeometryData objects construct a collision object. The collision object refers to an + * array of coordinate transformations at a certain start index. The index of the transformation of a child \e + * CollisionGeometryData object is then given by adding the parent collision object index and the \e shape_index of a + * geometry data object. */ int shape_index; + + /** \brief Points to the type of body which contains the geometry. */ union { const robot_model::LinkModel* link; @@ -122,6 +135,7 @@ struct CollisionGeometryData } ptr; }; +/** \brief Data structure which is passed to the collision callback function of the collision manager. */ struct CollisionData { CollisionData() : req_(NULL), active_components_only_(NULL), res_(NULL), acm_(NULL), done_(false) @@ -137,27 +151,29 @@ struct CollisionData { } - /// Compute \e active_components_only_ based on \e req_ + /** \brief Compute \e active_components_only_ based on the joint group specified in \e req_ */ void enableGroup(const robot_model::RobotModelConstPtr& robot_model); - /// The collision request passed by the user + /** \brief The collision request passed by the user */ const CollisionRequest* req_; - /// If the collision request includes a group name, this set contains the pointers to the link models that are - /// considered for collision; - /// If the pointer is NULL, all collisions are considered. + /** \brief If the collision request includes a group name, this set contains the pointers to the link models that + * are considered for collision. + * + * If the pointer is NULL, all collisions are considered. */ const std::set* active_components_only_; - /// The user specified response location + /** \brief The user-specified response location. */ CollisionResult* res_; - /// The user specified collision matrix (may be NULL) + /** \brief The user-specified collision matrix (may be NULL). */ const AllowedCollisionMatrix* acm_; - /// Flag indicating whether collision checking is complete + /** \brief Flag indicating whether collision checking is complete. */ bool done_; }; +/** \brief Data structure which is passed to the distance callback function of the collision manager. */ struct DistanceData { DistanceData(const DistanceRequest* req, DistanceResult* res) : req(req), res(res), done(false) @@ -167,42 +183,48 @@ struct DistanceData { } - /// Distance query request information + /** \brief Distance query request information. */ const DistanceRequest* req; - /// Distance query results information + /** \brief Distance query results information. */ DistanceResult* res; - /// Indicates if distance query is finished. + /** \brief Indicates if distance query is finished. */ bool done; }; MOVEIT_STRUCT_FORWARD(FCLGeometry); +/** \brief Bundles the \e CollisionGeometryData and FCL collision geometry representation into a single class. */ struct FCLGeometry { FCLGeometry() { } + /** \brief Constructor for a robot link. */ FCLGeometry(fcl::CollisionGeometryd* collision_geometry, const robot_model::LinkModel* link, int shape_index) : collision_geometry_(collision_geometry), collision_geometry_data_(new CollisionGeometryData(link, shape_index)) { collision_geometry_->setUserData(collision_geometry_data_.get()); } + /** \brief Constructor for an attached body. */ FCLGeometry(fcl::CollisionGeometryd* collision_geometry, const robot_state::AttachedBody* ab, int shape_index) : collision_geometry_(collision_geometry), collision_geometry_data_(new CollisionGeometryData(ab, shape_index)) { collision_geometry_->setUserData(collision_geometry_data_.get()); } + /** \brief Constructor for a world object. */ FCLGeometry(fcl::CollisionGeometryd* collision_geometry, const World::Object* obj, int shape_index) : collision_geometry_(collision_geometry), collision_geometry_data_(new CollisionGeometryData(obj, shape_index)) { collision_geometry_->setUserData(collision_geometry_data_.get()); } + /** \brief Updates the \e collision_geometry_data_ with new data while also setting the \e collision_geometry_ to the + * new data. */ template void updateCollisionGeometryData(const T* data, int shape_index, bool newType) { @@ -213,13 +235,18 @@ struct FCLGeometry collision_geometry_->setUserData(collision_geometry_data_.get()); } + /** \brief Pointer to FCL collision geometry. */ std::shared_ptr collision_geometry_; + + /** \brief Pointer to the user-defined geometry data. */ CollisionGeometryDataPtr collision_geometry_data_; }; typedef std::shared_ptr FCLCollisionObjectPtr; typedef std::shared_ptr FCLCollisionObjectConstPtr; +/** \brief A general high-level object which consists of multiple \e FCLCollisionObjects. It is the top level data + * structure which is used in the collision checking process. */ struct FCLObject { void registerTo(fcl::BroadPhaseCollisionManagerd* manager); @@ -227,33 +254,65 @@ struct FCLObject void clear(); std::vector collision_objects_; + + /** \brief Geometry data corresponding to \e collision_objects_. */ std::vector collision_geometry_; }; +/** \brief Bundles an \e FCLObject and a broadphase FCL collision manager. */ struct FCLManager { FCLObject object_; std::shared_ptr manager_; }; +/** \brief Callback function used by the FCLManager used for each pair of collision objects to +* calculate object contact information. +* +* \param o1 First FCL collision object +* \param o2 Second FCL collision object +* \data General pointer to arbitrary data which is used during the callback +* \return True terminates the distance check, false continues it to the next pair of objects */ bool collisionCallback(fcl::CollisionObjectd* o1, fcl::CollisionObjectd* o2, void* data); +/** \brief Callback function used by the FCLManager used for each pair of collision objects to +* calculate collisions and distances. +* +* \param o1 First FCL collision object +* \param o2 Second FCL collision object +* \data General pointer to arbitrary data which is used during the callback +* \return True terminates the collision check, false continues it to the next pair of objects */ bool distanceCallback(fcl::CollisionObjectd* o1, fcl::CollisionObjectd* o2, void* data, double& min_dist); +/** \brief Create new FCLGeometry object out of robot link model. */ FCLGeometryConstPtr createCollisionGeometry(const shapes::ShapeConstPtr& shape, const robot_model::LinkModel* link, int shape_index); + +/** \brief Create new FCLGeometry object out of attached body. */ FCLGeometryConstPtr createCollisionGeometry(const shapes::ShapeConstPtr& shape, const robot_state::AttachedBody* ab, int shape_index); + +/** \brief Create new FCLGeometry object out of a world object. + * + * A world object always consists only of a single shape, therefore we don't need the \e shape_index. */ FCLGeometryConstPtr createCollisionGeometry(const shapes::ShapeConstPtr& shape, const World::Object* obj); +/** \brief Create new scaled and / or padded FCLGeometry object out of robot link model. */ FCLGeometryConstPtr createCollisionGeometry(const shapes::ShapeConstPtr& shape, double scale, double padding, const robot_model::LinkModel* link, int shape_index); + +/** \brief Create new scaled and / or padded FCLGeometry object out of an attached body. */ FCLGeometryConstPtr createCollisionGeometry(const shapes::ShapeConstPtr& shape, double scale, double padding, const robot_state::AttachedBody* ab, int shape_index); + +/** \brief Create new scaled and / or padded FCLGeometry object out of an world object. */ FCLGeometryConstPtr createCollisionGeometry(const shapes::ShapeConstPtr& shape, double scale, double padding, const World::Object* obj); + +/** \brief Increases the counter of the caches which can trigger the cleaning of expired entries from them. */ void cleanCollisionGeometryCache(); +/** \brief Transforms an Eigen Isometry3d to FCL coordinate transformation */ inline void transform2fcl(const Eigen::Isometry3d& b, fcl::Transform3d& f) { #if (MOVEIT_FCL_VERSION >= FCL_VERSION_CHECK(0, 6, 0)) @@ -265,6 +324,7 @@ inline void transform2fcl(const Eigen::Isometry3d& b, fcl::Transform3d& f) #endif } +/** \brief Transforms an Eigen Isometry3d to FCL coordinate transformation */ inline fcl::Transform3d transform2fcl(const Eigen::Isometry3d& b) { fcl::Transform3d t; @@ -272,6 +332,7 @@ inline fcl::Transform3d transform2fcl(const Eigen::Isometry3d& b) return t; } +/** \brief Transforms an FCL contact into a MoveIt contact point. */ inline void fcl2contact(const fcl::Contactd& fc, Contact& c) { c.pos = Eigen::Vector3d(fc.pos[0], fc.pos[1], fc.pos[2]); @@ -285,6 +346,7 @@ inline void fcl2contact(const fcl::Contactd& fc, Contact& c) c.body_type_2 = cgd2->type; } +/** \brief Transforms the FCL internal representation to the MoveIt \e CostSource data structure. */ inline void fcl2costsource(const fcl::CostSourced& fcs, CostSource& cs) { cs.aabb_min[0] = fcs.aabb_min[0]; @@ -298,5 +360,3 @@ inline void fcl2costsource(const fcl::CostSourced& fcs, CostSource& cs) cs.cost = fcs.cost_density; } } - -#endif diff --git a/moveit_core/collision_detection_fcl/include/moveit/collision_detection_fcl/collision_detector_allocator_fcl.h b/moveit_core/collision_detection_fcl/include/moveit/collision_detection_fcl/collision_detector_allocator_fcl.h index 6b7ec1ce52..88bcfcddae 100644 --- a/moveit_core/collision_detection_fcl/include/moveit/collision_detection_fcl/collision_detector_allocator_fcl.h +++ b/moveit_core/collision_detection_fcl/include/moveit/collision_detection_fcl/collision_detector_allocator_fcl.h @@ -34,22 +34,18 @@ /* Author: Acorn Pooley, Ioan Sucan */ -#ifndef MOVEIT_COLLISION_DETECTION_COLLISION_DETECTOR_FCL_H_ -#define MOVEIT_COLLISION_DETECTION_COLLISION_DETECTOR_FCL_H_ +#pragma once #include -#include -#include +#include namespace collision_detection { /** \brief An allocator for FCL collision detectors */ class CollisionDetectorAllocatorFCL - : public CollisionDetectorAllocatorTemplate + : public CollisionDetectorAllocatorTemplate { public: - static const std::string NAME; // defined in collision_world_fcl.cpp + static const std::string NAME; // defined in collision_env_fcl.cpp }; } - -#endif diff --git a/moveit_core/collision_detection_fcl/include/moveit/collision_detection_fcl/collision_detector_fcl_plugin_loader.h b/moveit_core/collision_detection_fcl/include/moveit/collision_detection_fcl/collision_detector_fcl_plugin_loader.h index 18d7e8c40f..e1d749474c 100644 --- a/moveit_core/collision_detection_fcl/include/moveit/collision_detection_fcl/collision_detector_fcl_plugin_loader.h +++ b/moveit_core/collision_detection_fcl/include/moveit/collision_detection_fcl/collision_detector_fcl_plugin_loader.h @@ -2,8 +2,7 @@ * collision_detector_fcl_plugin_loader.h */ -#ifndef MOVEIT_COLLISION_DETECTION_FCL_COLLISION_DETECTOR_FCL_PLUGIN_LOADER_H_ -#define MOVEIT_COLLISION_DETECTION_FCL_COLLISION_DETECTOR_FCL_PLUGIN_LOADER_H_ +#pragma once #include #include @@ -16,4 +15,3 @@ class CollisionDetectorFCLPluginLoader : public CollisionPlugin virtual bool initialize(const planning_scene::PlanningScenePtr& scene, bool exclusive) const; }; } -#endif // MOVEIT_COLLISION_DETECTION_FCL_COLLISION_DETECTOR_FCL_PLUGIN_LOADER_H_ \ No newline at end of file diff --git a/moveit_core/collision_detection_fcl/include/moveit/collision_detection_fcl/collision_env_fcl.h b/moveit_core/collision_detection_fcl/include/moveit/collision_detection_fcl/collision_env_fcl.h new file mode 100644 index 0000000000..8906f8155f --- /dev/null +++ b/moveit_core/collision_detection_fcl/include/moveit/collision_detection_fcl/collision_env_fcl.h @@ -0,0 +1,163 @@ +/********************************************************************* + * Software License Agreement (BSD License) + * + * Copyright (c) 2011, Willow Garage, Inc. + * 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 and/or other materials provided + * with the distribution. + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * 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 OWNER 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. + *********************************************************************/ + +/* Author: Ioan Sucan, Jens Petit */ + +#pragma once + +#include +#include + +#if (MOVEIT_FCL_VERSION >= FCL_VERSION_CHECK(0, 6, 0)) +#include +#else +#include +#endif + +#include + +namespace collision_detection +{ +/** \brief FCL implementation of the CollisionEnv */ +class CollisionEnvFCL : public CollisionEnv +{ +public: + CollisionEnvFCL() = delete; + + CollisionEnvFCL(const robot_model::RobotModelConstPtr& model, double padding = 0.0, double scale = 1.0); + + CollisionEnvFCL(const robot_model::RobotModelConstPtr& model, const WorldPtr& world, double padding = 0.0, + double scale = 1.0); + + CollisionEnvFCL(const CollisionEnvFCL& other, const WorldPtr& world); + + ~CollisionEnvFCL() override; + + virtual void checkSelfCollision(const CollisionRequest& req, CollisionResult& res, + const robot_state::RobotState& state) const override; + + virtual void checkSelfCollision(const CollisionRequest& req, CollisionResult& res, + const robot_state::RobotState& state, + const AllowedCollisionMatrix& acm) const override; + + virtual void checkRobotCollision(const CollisionRequest& req, CollisionResult& res, + const robot_state::RobotState& state) const override; + + virtual void checkRobotCollision(const CollisionRequest& req, CollisionResult& res, + const robot_state::RobotState& state, + const AllowedCollisionMatrix& acm) const override; + + virtual void checkRobotCollision(const CollisionRequest& req, CollisionResult& res, + const robot_state::RobotState& state1, const robot_state::RobotState& state2, + const AllowedCollisionMatrix& acm) const override; + + virtual void checkRobotCollision(const CollisionRequest& req, CollisionResult& res, + const robot_state::RobotState& state1, + const robot_state::RobotState& state2) const override; + + virtual void distanceSelf(const DistanceRequest& req, DistanceResult& res, + const robot_state::RobotState& state) const override; + + virtual void distanceRobot(const DistanceRequest& req, DistanceResult& res, + const robot_state::RobotState& state) const override; + + void setWorld(const WorldPtr& world) override; + +protected: + /** \brief Updates the FCL collision geometry and objects saved in the CollisionRobotFCL members to reflect a new + * padding or scaling of the robot links. + * + * It searches for the link through the pointed-to robot model of the CollisionRobot and then constructs new FCL + * collision objects and geometries depending on the changed robot model. + * + * \param links The names of the links which have been updated in the robot model */ + void updatedPaddingOrScaling(const std::vector& links) override; + + /** \brief Bundles the different checkSelfCollision functions into a single function */ + void checkSelfCollisionHelper(const CollisionRequest& req, CollisionResult& res, const robot_state::RobotState& state, + const AllowedCollisionMatrix* acm) const; + + /** \brief Bundles the different checkRobotCollision functions into a single function */ + void checkRobotCollisionHelper(const CollisionRequest& req, CollisionResult& res, + const robot_state::RobotState& state, const AllowedCollisionMatrix* acm) const; + + /** \brief Construct an FCL collision object from MoveIt's World::Object. */ + void constructFCLObjectWorld(const World::Object* obj, FCLObject& fcl_obj) const; + + /** \brief Updates the specified object in \m fcl_objs_ and in the manager from new data available in the World. + * + * If it does not exist in world, it is deleted. If it's not existing in \m fcl_objs_ yet, it's added there. */ + void updateFCLObject(const std::string& id); + + /** \brief Out of the current robot state and its attached bodies construct an FCLObject which can then be used to + * check for collision. + * + * The current state is used to recalculate the AABB of the FCL collision objects. However they are not computed from + * scratch (which would require call to computeLocalAABB()) but are only transformed according to the joint states. + * + * \param state The current robot state + * \param fcl_obj The newly filled object */ + void constructFCLObjectRobot(const robot_state::RobotState& state, FCLObject& fcl_obj) const; + + /** \brief Prepares for the collision check through constructing an FCL collision object out of the current robot + * state and specifying a broadphase collision manager of FCL where the constructed object is registered to. */ + void allocSelfCollisionBroadPhase(const robot_state::RobotState& state, FCLManager& manager) const; + + /** \brief Converts all shapes which make up an atttached body into a vector of FCLGeometryConstPtr. + * + * When they are converted, they can be added to the FCL representation of the robot for collision checking. + * + * \param ab Pointer to the attached body + * \param geoms Output vector of geometries + */ + void getAttachedBodyObjects(const robot_state::AttachedBody* ab, std::vector& geoms) const; + + /** \brief Vector of shared pointers to the FCL geometry for the objects in fcl_objs_. */ + std::vector robot_geoms_; + + /** \brief Vector of shared pointers to the FCL collision objects which make up the robot */ + std::vector robot_fcl_objs_; + + /// FCL collision manager which handles the collision checking process + std::unique_ptr manager_; + + std::map fcl_objs_; + +private: + /** \brief Callback function executed for each change to the world environment */ + void notifyObjectChange(const ObjectConstPtr& obj, World::Action action); + + World::ObserverHandle observer_handle_; +}; +} diff --git a/moveit_core/collision_detection_fcl/include/moveit/collision_detection_fcl/collision_robot_fcl.h b/moveit_core/collision_detection_fcl/include/moveit/collision_detection_fcl/collision_robot_fcl.h deleted file mode 100644 index a46794e999..0000000000 --- a/moveit_core/collision_detection_fcl/include/moveit/collision_detection_fcl/collision_robot_fcl.h +++ /dev/null @@ -1,100 +0,0 @@ -/********************************************************************* - * Software License Agreement (BSD License) - * - * Copyright (c) 2011, Willow Garage, Inc. - * 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 and/or other materials provided - * with the distribution. - * * Neither the name of Willow Garage nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 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 OWNER 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. - *********************************************************************/ - -/* Author: Ioan Sucan */ - -#ifndef MOVEIT_COLLISION_DETECTION_FCL_COLLISION_ROBOT_ -#define MOVEIT_COLLISION_DETECTION_FCL_COLLISION_ROBOT_ - -#include - -namespace collision_detection -{ -class CollisionRobotFCL : public CollisionRobot -{ - friend class CollisionWorldFCL; - -public: - CollisionRobotFCL(const robot_model::RobotModelConstPtr& robot_model, double padding = 0.0, double scale = 1.0); - - CollisionRobotFCL(const CollisionRobotFCL& other); - - void checkSelfCollision(const CollisionRequest& req, CollisionResult& res, - const robot_state::RobotState& state) const override; - void checkSelfCollision(const CollisionRequest& req, CollisionResult& res, const robot_state::RobotState& state, - const AllowedCollisionMatrix& acm) const override; - void checkSelfCollision(const CollisionRequest& req, CollisionResult& res, const robot_state::RobotState& state1, - const robot_state::RobotState& state2) const override; - void checkSelfCollision(const CollisionRequest& req, CollisionResult& res, const robot_state::RobotState& state1, - const robot_state::RobotState& state2, const AllowedCollisionMatrix& acm) const override; - - void checkOtherCollision(const CollisionRequest& req, CollisionResult& res, const robot_state::RobotState& state, - const CollisionRobot& other_robot, - const robot_state::RobotState& other_state) const override; - void checkOtherCollision(const CollisionRequest& req, CollisionResult& res, const robot_state::RobotState& state, - const CollisionRobot& other_robot, const robot_state::RobotState& other_state, - const AllowedCollisionMatrix& acm) const override; - void checkOtherCollision(const CollisionRequest& req, CollisionResult& res, const robot_state::RobotState& state1, - const robot_state::RobotState& state2, const CollisionRobot& other_robot, - const robot_state::RobotState& other_state1, - const robot_state::RobotState& other_state2) const override; - void checkOtherCollision(const CollisionRequest& req, CollisionResult& res, const robot_state::RobotState& state1, - const robot_state::RobotState& state2, const CollisionRobot& other_robot, - const robot_state::RobotState& other_state1, const robot_state::RobotState& other_state2, - const AllowedCollisionMatrix& acm) const override; - - void distanceSelf(const DistanceRequest& req, DistanceResult& res, - const robot_state::RobotState& state) const override; - - void distanceOther(const DistanceRequest& req, DistanceResult& res, const robot_state::RobotState& state, - const CollisionRobot& other_robot, const robot_state::RobotState& other_state) const override; - -protected: - void updatedPaddingOrScaling(const std::vector& links) override; - void constructFCLObject(const robot_state::RobotState& state, FCLObject& fcl_obj) const; - void allocSelfCollisionBroadPhase(const robot_state::RobotState& state, FCLManager& manager) const; - void getAttachedBodyObjects(const robot_state::AttachedBody* ab, std::vector& geoms) const; - - void checkSelfCollisionHelper(const CollisionRequest& req, CollisionResult& res, const robot_state::RobotState& state, - const AllowedCollisionMatrix* acm) const; - void checkOtherCollisionHelper(const CollisionRequest& req, CollisionResult& res, - const robot_state::RobotState& state, const CollisionRobot& other_robot, - const robot_state::RobotState& other_state, const AllowedCollisionMatrix* acm) const; - - std::vector geoms_; - std::vector fcl_objs_; -}; -} - -#endif diff --git a/moveit_core/collision_detection_fcl/include/moveit/collision_detection_fcl/collision_world_fcl.h b/moveit_core/collision_detection_fcl/include/moveit/collision_detection_fcl/collision_world_fcl.h deleted file mode 100644 index e6d9557630..0000000000 --- a/moveit_core/collision_detection_fcl/include/moveit/collision_detection_fcl/collision_world_fcl.h +++ /dev/null @@ -1,101 +0,0 @@ -/********************************************************************* - * Software License Agreement (BSD License) - * - * Copyright (c) 2011, Willow Garage, Inc. - * 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 and/or other materials provided - * with the distribution. - * * Neither the name of Willow Garage nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 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 OWNER 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. - *********************************************************************/ - -/* Author: Ioan Sucan */ - -#ifndef MOVEIT_COLLISION_DETECTION_FCL_COLLISION_WORLD_FCL_ -#define MOVEIT_COLLISION_DETECTION_FCL_COLLISION_WORLD_FCL_ - -#include -#include - -#if (MOVEIT_FCL_VERSION >= FCL_VERSION_CHECK(0, 6, 0)) -#include -#else -#include -#endif - -#include - -namespace collision_detection -{ -class CollisionWorldFCL : public CollisionWorld -{ -public: - CollisionWorldFCL(); - explicit CollisionWorldFCL(const WorldPtr& world); - CollisionWorldFCL(const CollisionWorldFCL& other, const WorldPtr& world); - ~CollisionWorldFCL() override; - - void checkRobotCollision(const CollisionRequest& req, CollisionResult& res, const CollisionRobot& robot, - const robot_state::RobotState& state) const override; - void checkRobotCollision(const CollisionRequest& req, CollisionResult& res, const CollisionRobot& robot, - const robot_state::RobotState& state, const AllowedCollisionMatrix& acm) const override; - void checkRobotCollision(const CollisionRequest& req, CollisionResult& res, const CollisionRobot& robot, - const robot_state::RobotState& state1, const robot_state::RobotState& state2) const override; - void checkRobotCollision(const CollisionRequest& req, CollisionResult& res, const CollisionRobot& robot, - const robot_state::RobotState& state1, const robot_state::RobotState& state2, - const AllowedCollisionMatrix& acm) const override; - void checkWorldCollision(const CollisionRequest& req, CollisionResult& res, - const CollisionWorld& other_world) const override; - void checkWorldCollision(const CollisionRequest& req, CollisionResult& res, const CollisionWorld& other_world, - const AllowedCollisionMatrix& acm) const override; - - void distanceRobot(const DistanceRequest& req, DistanceResult& res, const CollisionRobot& robot, - const robot_state::RobotState& state) const override; - - void distanceWorld(const DistanceRequest& req, DistanceResult& res, const CollisionWorld& world) const override; - - void setWorld(const WorldPtr& world) override; - -protected: - void checkWorldCollisionHelper(const CollisionRequest& req, CollisionResult& res, const CollisionWorld& other_world, - const AllowedCollisionMatrix* acm) const; - void checkRobotCollisionHelper(const CollisionRequest& req, CollisionResult& res, const CollisionRobot& robot, - const robot_state::RobotState& state, const AllowedCollisionMatrix* acm) const; - - void constructFCLObject(const World::Object* obj, FCLObject& fcl_obj) const; - void updateFCLObject(const std::string& id); - - std::unique_ptr manager_; - std::map fcl_objs_; - -private: - void initialize(); - void notifyObjectChange(const ObjectConstPtr& obj, World::Action action); - World::ObserverHandle observer_handle_; -}; -} - -#endif diff --git a/moveit_core/collision_detection_fcl/include/moveit/collision_detection_fcl/fcl_compat.h b/moveit_core/collision_detection_fcl/include/moveit/collision_detection_fcl/fcl_compat.h index 9eeda077cd..123fac3c08 100644 --- a/moveit_core/collision_detection_fcl/include/moveit/collision_detection_fcl/fcl_compat.h +++ b/moveit_core/collision_detection_fcl/include/moveit/collision_detection_fcl/fcl_compat.h @@ -34,8 +34,7 @@ /* Author: Benjamin Scholz */ -#ifndef MOVEIT_COLLISION_DETECTION_FCL_COMPAT_ -#define MOVEIT_COLLISION_DETECTION_FCL_COMPAT_ +#pragma once #include @@ -98,4 +97,3 @@ class DynamicAABBTreeCollisionManager; using DynamicAABBTreeCollisionManagerd = fcl::DynamicAABBTreeCollisionManager; } #endif -#endif diff --git a/moveit_core/collision_detection_fcl/src/collision_common.cpp b/moveit_core/collision_detection_fcl/src/collision_common.cpp index e977b025a2..0cf3446237 100644 --- a/moveit_core/collision_detection_fcl/src/collision_common.cpp +++ b/moveit_core/collision_detection_fcl/src/collision_common.cpp @@ -356,6 +356,9 @@ bool collisionCallback(fcl::CollisionObjectd* o1, fcl::CollisionObjectd* o2, voi return cdata->done_; } +/** \brief Cache for an arbitrary type of shape. It is assigned during the execution of \e createCollisionGeometry(). + * + * Only a single cache per thread and object type is created as it is a quasi-singleton instance. */ struct FCLShapeCache { using ShapeKey = shapes::ShapeConstWeakPtr; @@ -390,7 +393,10 @@ struct FCLShapeCache static const unsigned int MAX_CLEAN_COUNT = 100; // every this many uses of the cache, a cleaning operation is // executed (this is only removal of expired entries) + /** \brief Map of weak pointers to the FCLGeometry. */ ShapeMap map_; + + /** \brief Counts cache usage and triggers clearing of cache when \m MAX_CLEAN_COUNT is exceeded. */ unsigned int clean_count_; }; @@ -624,7 +630,9 @@ bool distanceCallback(fcl::CollisionObjectd* o1, fcl::CollisionObjectd* o2, void return cdata->done; } -/* We template the function so we get a different cache for each of the template arguments combinations */ +/* Templated function to get a different cache for each of the template arguments combinations. + * + * The returned cache is a quasi-singleton for each thread as it is created \e thread_local. */ template FCLShapeCache& GetShapeCache() { @@ -659,6 +667,11 @@ struct IfSameType }; }; +/** \brief Templated helper function creating new collision geometry out of general object using an arbitrary bounding + * volume (BV). + * + * It assigns a thread-local cache for each type of shape and minimizes memory usage and copying through utilizing the + * cache. */ template FCLGeometryConstPtr createCollisionGeometry(const shapes::ShapeConstPtr& shape, const T* data, int shape_index) { @@ -839,7 +852,6 @@ FCLGeometryConstPtr createCollisionGeometry(const shapes::ShapeConstPtr& shape, return FCLGeometryConstPtr(); } -///////////////////////////////////////////////////// FCLGeometryConstPtr createCollisionGeometry(const shapes::ShapeConstPtr& shape, const robot_model::LinkModel* link, int shape_index) { @@ -857,6 +869,8 @@ FCLGeometryConstPtr createCollisionGeometry(const shapes::ShapeConstPtr& shape, return createCollisionGeometry(shape, obj, 0); } +/** \brief Templated helper function creating new collision geometry out of general object using an arbitrary bounding + * volume (BV). This can include padding and scaling. */ template FCLGeometryConstPtr createCollisionGeometry(const shapes::ShapeConstPtr& shape, double scale, double padding, const T* data, int shape_index) @@ -901,9 +915,8 @@ void cleanCollisionGeometryCache() cache2.bumpUseCount(true); } } -} // namespace collision_detection -void collision_detection::CollisionData::enableGroup(const robot_model::RobotModelConstPtr& robot_model) +void CollisionData::enableGroup(const robot_model::RobotModelConstPtr& robot_model) { if (robot_model->hasJointModelGroup(req_->group_name)) active_components_only_ = &robot_model->getJointModelGroup(req_->group_name)->getUpdatedLinkModelsSet(); @@ -911,7 +924,7 @@ void collision_detection::CollisionData::enableGroup(const robot_model::RobotMod active_components_only_ = nullptr; } -void collision_detection::FCLObject::registerTo(fcl::BroadPhaseCollisionManagerd* manager) +void FCLObject::registerTo(fcl::BroadPhaseCollisionManagerd* manager) { std::vector collision_objects(collision_objects_.size()); for (std::size_t i = 0; i < collision_objects_.size(); ++i) @@ -920,14 +933,15 @@ void collision_detection::FCLObject::registerTo(fcl::BroadPhaseCollisionManagerd manager->registerObjects(collision_objects); } -void collision_detection::FCLObject::unregisterFrom(fcl::BroadPhaseCollisionManagerd* manager) +void FCLObject::unregisterFrom(fcl::BroadPhaseCollisionManagerd* manager) { for (auto& collision_object : collision_objects_) manager->unregisterObject(collision_object.get()); } -void collision_detection::FCLObject::clear() +void FCLObject::clear() { collision_objects_.clear(); collision_geometry_.clear(); } +} // namespace collision_detection diff --git a/moveit_core/collision_detection_fcl/src/collision_env_fcl.cpp b/moveit_core/collision_detection_fcl/src/collision_env_fcl.cpp new file mode 100644 index 0000000000..20ef171fbc --- /dev/null +++ b/moveit_core/collision_detection_fcl/src/collision_env_fcl.cpp @@ -0,0 +1,434 @@ +/********************************************************************* + * Software License Agreement (BSD License) + * + * Copyright (c) 2011, Willow Garage, Inc. + * 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 and/or other materials provided + * with the distribution. + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * 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 OWNER 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. + *********************************************************************/ + +/* Author: Ioan Sucan, Jens Petit */ + +#include +#include +#include + +#include + +#if (MOVEIT_FCL_VERSION >= FCL_VERSION_CHECK(0, 6, 0)) +#include +#endif + +namespace collision_detection +{ +const std::string CollisionDetectorAllocatorFCL::NAME("FCL"); + +CollisionEnvFCL::CollisionEnvFCL(const robot_model::RobotModelConstPtr& model, double padding, double scale) + : CollisionEnv(model, padding, scale) +{ + const std::vector& links = robot_model_->getLinkModelsWithCollisionGeometry(); + std::size_t index; + robot_geoms_.resize(robot_model_->getLinkGeometryCount()); + robot_fcl_objs_.resize(robot_model_->getLinkGeometryCount()); + // we keep the same order of objects as what RobotState *::getLinkState() returns + for (auto link : links) + for (std::size_t j = 0; j < link->getShapes().size(); ++j) + { + FCLGeometryConstPtr link_geometry = createCollisionGeometry(link->getShapes()[j], getLinkScale(link->getName()), + getLinkPadding(link->getName()), link, j); + if (link_geometry) + { + index = link->getFirstCollisionBodyTransformIndex() + j; + robot_geoms_[index] = link_geometry; + + // Need to store the FCL object so the AABB does not get recreated every time. + // Every time this object is created, g->computeLocalAABB() is called which is + // very expensive and should only be calculated once. To update the AABB, use the + // collObj->setTransform and then call collObj->computeAABB() to transform the AABB. + robot_fcl_objs_[index] = + FCLCollisionObjectConstPtr(new fcl::CollisionObjectd(link_geometry->collision_geometry_)); + } + else + ROS_ERROR_NAMED("collision_detection.fcl", "Unable to construct collision geometry for link '%s'", + link->getName().c_str()); + } + + auto m = new fcl::DynamicAABBTreeCollisionManagerd(); + // m->tree_init_level = 2; + manager_.reset(m); + + // request notifications about changes to new world + observer_handle_ = getWorld()->addObserver(boost::bind(&CollisionEnvFCL::notifyObjectChange, this, _1, _2)); +} + +CollisionEnvFCL::CollisionEnvFCL(const robot_model::RobotModelConstPtr& model, const WorldPtr& world, double padding, + double scale) + : CollisionEnv(model, world, padding, scale) +{ + const std::vector& links = robot_model_->getLinkModelsWithCollisionGeometry(); + std::size_t index; + robot_geoms_.resize(robot_model_->getLinkGeometryCount()); + robot_fcl_objs_.resize(robot_model_->getLinkGeometryCount()); + // we keep the same order of objects as what RobotState *::getLinkState() returns + for (auto link : links) + for (std::size_t j = 0; j < link->getShapes().size(); ++j) + { + FCLGeometryConstPtr g = createCollisionGeometry(link->getShapes()[j], getLinkScale(link->getName()), + getLinkPadding(link->getName()), link, j); + if (g) + { + index = link->getFirstCollisionBodyTransformIndex() + j; + robot_geoms_[index] = g; + + // Need to store the FCL object so the AABB does not get recreated every time. + // Every time this object is created, g->computeLocalAABB() is called which is + // very expensive and should only be calculated once. To update the AABB, use the + // collObj->setTransform and then call collObj->computeAABB() to transform the AABB. + robot_fcl_objs_[index] = FCLCollisionObjectConstPtr(new fcl::CollisionObjectd(g->collision_geometry_)); + } + else + ROS_ERROR_NAMED("collision_detection.fcl", "Unable to construct collision geometry for link '%s'", + link->getName().c_str()); + } + + auto m = new fcl::DynamicAABBTreeCollisionManagerd(); + // m->tree_init_level = 2; + manager_.reset(m); + + // request notifications about changes to new world + observer_handle_ = getWorld()->addObserver(boost::bind(&CollisionEnvFCL::notifyObjectChange, this, _1, _2)); + getWorld()->notifyObserverAllObjects(observer_handle_, World::CREATE); +} + +CollisionEnvFCL::~CollisionEnvFCL() +{ + getWorld()->removeObserver(observer_handle_); +} + +CollisionEnvFCL::CollisionEnvFCL(const CollisionEnvFCL& other, const WorldPtr& world) : CollisionEnv(other, world) +{ + robot_geoms_ = other.robot_geoms_; + robot_fcl_objs_ = other.robot_fcl_objs_; + + auto m = new fcl::DynamicAABBTreeCollisionManagerd(); + // m->tree_init_level = 2; + manager_.reset(m); + + fcl_objs_ = other.fcl_objs_; + for (auto& fcl_obj : fcl_objs_) + fcl_obj.second.registerTo(manager_.get()); + // manager_->update(); + + // request notifications about changes to new world + observer_handle_ = getWorld()->addObserver(boost::bind(&CollisionEnvFCL::notifyObjectChange, this, _1, _2)); +} + +void CollisionEnvFCL::getAttachedBodyObjects(const robot_state::AttachedBody* ab, + std::vector& geoms) const +{ + const std::vector& shapes = ab->getShapes(); + for (std::size_t i = 0; i < shapes.size(); ++i) + { + FCLGeometryConstPtr co = createCollisionGeometry(shapes[i], ab, i); + if (co) + geoms.push_back(co); + } +} + +void CollisionEnvFCL::constructFCLObjectWorld(const World::Object* obj, FCLObject& fcl_obj) const +{ + for (std::size_t i = 0; i < obj->shapes_.size(); ++i) + { + FCLGeometryConstPtr g = createCollisionGeometry(obj->shapes_[i], obj); + if (g) + { + auto co = new fcl::CollisionObjectd(g->collision_geometry_, transform2fcl(obj->shape_poses_[i])); + fcl_obj.collision_objects_.push_back(FCLCollisionObjectPtr(co)); + fcl_obj.collision_geometry_.push_back(g); + } + } +} + +void CollisionEnvFCL::constructFCLObjectRobot(const robot_state::RobotState& state, FCLObject& fcl_obj) const +{ + fcl_obj.collision_objects_.reserve(robot_geoms_.size()); + fcl::Transform3d fcl_tf; + + for (std::size_t i = 0; i < robot_geoms_.size(); ++i) + if (robot_geoms_[i] && robot_geoms_[i]->collision_geometry_) + { + transform2fcl(state.getCollisionBodyTransform(robot_geoms_[i]->collision_geometry_data_->ptr.link, + robot_geoms_[i]->collision_geometry_data_->shape_index), + fcl_tf); + auto coll_obj = new fcl::CollisionObjectd(*robot_fcl_objs_[i]); + coll_obj->setTransform(fcl_tf); + coll_obj->computeAABB(); + fcl_obj.collision_objects_.push_back(FCLCollisionObjectPtr(coll_obj)); + } + + // TODO: Implement a method for caching fcl::CollisionObject's for robot_state::AttachedBody's + std::vector ab; + state.getAttachedBodies(ab); + for (auto& body : ab) + { + std::vector objs; + getAttachedBodyObjects(body, objs); + const EigenSTL::vector_Isometry3d& ab_t = body->getGlobalCollisionBodyTransforms(); + for (std::size_t k = 0; k < objs.size(); ++k) + if (objs[k]->collision_geometry_) + { + transform2fcl(ab_t[k], fcl_tf); + fcl_obj.collision_objects_.push_back( + FCLCollisionObjectPtr(new fcl::CollisionObjectd(objs[k]->collision_geometry_, fcl_tf))); + // we copy the shared ptr to the CollisionGeometryData, as this is not stored by the class itself, + // and would be destroyed when objs goes out of scope. + fcl_obj.collision_geometry_.push_back(objs[k]); + } + } +} + +void CollisionEnvFCL::allocSelfCollisionBroadPhase(const robot_state::RobotState& state, FCLManager& manager) const +{ + auto m = new fcl::DynamicAABBTreeCollisionManagerd(); + // m->tree_init_level = 2; + manager.manager_.reset(m); + constructFCLObjectRobot(state, manager.object_); + manager.object_.registerTo(manager.manager_.get()); + // manager.manager_->update(); +} + +void CollisionEnvFCL::checkSelfCollision(const CollisionRequest& req, CollisionResult& res, + const robot_state::RobotState& state) const +{ + checkSelfCollisionHelper(req, res, state, nullptr); +} + +void CollisionEnvFCL::checkSelfCollision(const CollisionRequest& req, CollisionResult& res, + const robot_state::RobotState& state, const AllowedCollisionMatrix& acm) const +{ + checkSelfCollisionHelper(req, res, state, &acm); +} + +void CollisionEnvFCL::checkSelfCollisionHelper(const CollisionRequest& req, CollisionResult& res, + const robot_state::RobotState& state, + const AllowedCollisionMatrix* acm) const +{ + FCLManager manager; + allocSelfCollisionBroadPhase(state, manager); + CollisionData cd(&req, &res, acm); + cd.enableGroup(getRobotModel()); + manager.manager_->collide(&cd, &collisionCallback); + if (req.distance) + { + DistanceRequest dreq; + DistanceResult dres; + + dreq.group_name = req.group_name; + dreq.acm = acm; + dreq.enableGroup(getRobotModel()); + distanceSelf(dreq, dres, state); + res.distance = dres.minimum_distance.distance; + } +} + +void CollisionEnvFCL::checkRobotCollision(const CollisionRequest& req, CollisionResult& res, + const robot_state::RobotState& state) const +{ + checkRobotCollisionHelper(req, res, state, nullptr); +} + +void CollisionEnvFCL::checkRobotCollision(const CollisionRequest& req, CollisionResult& res, + const robot_state::RobotState& state, const AllowedCollisionMatrix& acm) const +{ + checkRobotCollisionHelper(req, res, state, &acm); +} + +void CollisionEnvFCL::checkRobotCollision(const CollisionRequest& req, CollisionResult& res, + const robot_state::RobotState& state1, + const robot_state::RobotState& state2) const +{ + ROS_ERROR_NAMED("collision_detection.bullet", "Continuous collision not implemented"); +} + +void CollisionEnvFCL::checkRobotCollision(const CollisionRequest& req, CollisionResult& res, + const robot_state::RobotState& state1, const robot_state::RobotState& state2, + const AllowedCollisionMatrix& acm) const +{ + ROS_ERROR_NAMED("collision_detection.fcl", "Not implemented"); +} + +void CollisionEnvFCL::checkRobotCollisionHelper(const CollisionRequest& req, CollisionResult& res, + const robot_state::RobotState& state, + const AllowedCollisionMatrix* acm) const +{ + FCLObject fcl_obj; + constructFCLObjectRobot(state, fcl_obj); + + CollisionData cd(&req, &res, acm); + cd.enableGroup(getRobotModel()); + for (std::size_t i = 0; !cd.done_ && i < fcl_obj.collision_objects_.size(); ++i) + manager_->collide(fcl_obj.collision_objects_[i].get(), &cd, &collisionCallback); + + if (req.distance) + { + DistanceRequest dreq; + DistanceResult dres; + + dreq.group_name = req.group_name; + dreq.acm = acm; + dreq.enableGroup(getRobotModel()); + distanceRobot(dreq, dres, state); + res.distance = dres.minimum_distance.distance; + } +} + +void CollisionEnvFCL::distanceSelf(const DistanceRequest& req, DistanceResult& res, + const robot_state::RobotState& state) const +{ + FCLManager manager; + allocSelfCollisionBroadPhase(state, manager); + DistanceData drd(&req, &res); + + manager.manager_->distance(&drd, &distanceCallback); +} + +void CollisionEnvFCL::distanceRobot(const DistanceRequest& req, DistanceResult& res, + const robot_state::RobotState& state) const +{ + FCLObject fcl_obj; + constructFCLObjectRobot(state, fcl_obj); + + DistanceData drd(&req, &res); + for (std::size_t i = 0; !drd.done && i < fcl_obj.collision_objects_.size(); ++i) + manager_->distance(fcl_obj.collision_objects_[i].get(), &drd, &distanceCallback); +} + +void CollisionEnvFCL::updateFCLObject(const std::string& id) +{ + // remove FCL objects that correspond to this object + auto jt = fcl_objs_.find(id); + if (jt != fcl_objs_.end()) + { + jt->second.unregisterFrom(manager_.get()); + jt->second.clear(); + } + + // check to see if we have this object + auto it = getWorld()->find(id); + if (it != getWorld()->end()) + { + // construct FCL objects that correspond to this object + if (jt != fcl_objs_.end()) + { + constructFCLObjectWorld(it->second.get(), jt->second); + jt->second.registerTo(manager_.get()); + } + else + { + constructFCLObjectWorld(it->second.get(), fcl_objs_[id]); + fcl_objs_[id].registerTo(manager_.get()); + } + } + else + { + if (jt != fcl_objs_.end()) + fcl_objs_.erase(jt); + } + + // manager_->update(); +} + +void CollisionEnvFCL::setWorld(const WorldPtr& world) +{ + if (world == getWorld()) + return; + + // turn off notifications about old world + getWorld()->removeObserver(observer_handle_); + + // clear out objects from old world + manager_->clear(); + fcl_objs_.clear(); + cleanCollisionGeometryCache(); + + CollisionEnv::setWorld(world); + + // request notifications about changes to new world + observer_handle_ = getWorld()->addObserver(boost::bind(&CollisionEnvFCL::notifyObjectChange, this, _1, _2)); + + // get notifications any objects already in the new world + getWorld()->notifyObserverAllObjects(observer_handle_, World::CREATE); +} + +void CollisionEnvFCL::notifyObjectChange(const ObjectConstPtr& obj, World::Action action) +{ + if (action == World::DESTROY) + { + auto it = fcl_objs_.find(obj->id_); + if (it != fcl_objs_.end()) + { + it->second.unregisterFrom(manager_.get()); + it->second.clear(); + fcl_objs_.erase(it); + } + cleanCollisionGeometryCache(); + } + else + { + updateFCLObject(obj->id_); + if (action & (World::DESTROY | World::REMOVE_SHAPE)) + cleanCollisionGeometryCache(); + } +} + +void CollisionEnvFCL::updatedPaddingOrScaling(const std::vector& links) +{ + std::size_t index; + for (const auto& link : links) + { + const robot_model::LinkModel* lmodel = robot_model_->getLinkModel(link); + if (lmodel) + { + for (std::size_t j = 0; j < lmodel->getShapes().size(); ++j) + { + FCLGeometryConstPtr g = createCollisionGeometry(lmodel->getShapes()[j], getLinkScale(lmodel->getName()), + getLinkPadding(lmodel->getName()), lmodel, j); + if (g) + { + index = lmodel->getFirstCollisionBodyTransformIndex() + j; + robot_geoms_[index] = g; + robot_fcl_objs_[index] = FCLCollisionObjectConstPtr(new fcl::CollisionObjectd(g->collision_geometry_)); + } + } + } + else + ROS_ERROR_NAMED("collision_detection.fcl", "Updating padding or scaling for unknown link: '%s'", link.c_str()); + } +} + +} // end of namespace collision_detection diff --git a/moveit_core/collision_detection_fcl/src/collision_robot_fcl.cpp b/moveit_core/collision_detection_fcl/src/collision_robot_fcl.cpp deleted file mode 100644 index 9b8a4cea68..0000000000 --- a/moveit_core/collision_detection_fcl/src/collision_robot_fcl.cpp +++ /dev/null @@ -1,307 +0,0 @@ -/********************************************************************* - * Software License Agreement (BSD License) - * - * Copyright (c) 2011, Willow Garage, Inc. - * 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 and/or other materials provided - * with the distribution. - * * Neither the name of Willow Garage nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 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 OWNER 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. - *********************************************************************/ - -/* Author: Ioan Sucan */ - -#include -#include - -#if (MOVEIT_FCL_VERSION >= FCL_VERSION_CHECK(0, 6, 0)) -#include -#endif - -namespace collision_detection -{ -CollisionRobotFCL::CollisionRobotFCL(const robot_model::RobotModelConstPtr& model, double padding, double scale) - : CollisionRobot(model, padding, scale) -{ - const std::vector& links = robot_model_->getLinkModelsWithCollisionGeometry(); - std::size_t index; - geoms_.resize(robot_model_->getLinkGeometryCount()); - fcl_objs_.resize(robot_model_->getLinkGeometryCount()); - // we keep the same order of objects as what RobotState *::getLinkState() returns - for (auto link : links) - for (std::size_t j = 0; j < link->getShapes().size(); ++j) - { - FCLGeometryConstPtr g = createCollisionGeometry(link->getShapes()[j], getLinkScale(link->getName()), - getLinkPadding(link->getName()), link, j); - if (g) - { - index = link->getFirstCollisionBodyTransformIndex() + j; - geoms_[index] = g; - - // Need to store the FCL object so the AABB does not get recreated every time. - // Every time this object is created, g->computeLocalAABB() is called which is - // very expensive and should only be calculated once. To update the AABB, use the - // collObj->setTransform and then call collObj->computeAABB() to transform the AABB. - fcl_objs_[index] = FCLCollisionObjectConstPtr(new fcl::CollisionObjectd(g->collision_geometry_)); - } - else - ROS_ERROR_NAMED("collision_detection.fcl", "Unable to construct collision geometry for link '%s'", - link->getName().c_str()); - } -} - -CollisionRobotFCL::CollisionRobotFCL(const CollisionRobotFCL& other) : CollisionRobot(other) -{ - geoms_ = other.geoms_; - fcl_objs_ = other.fcl_objs_; -} - -void CollisionRobotFCL::getAttachedBodyObjects(const robot_state::AttachedBody* ab, - std::vector& geoms) const -{ - const std::vector& shapes = ab->getShapes(); - for (std::size_t i = 0; i < shapes.size(); ++i) - { - FCLGeometryConstPtr co = createCollisionGeometry(shapes[i], ab, i); - if (co) - geoms.push_back(co); - } -} - -void CollisionRobotFCL::constructFCLObject(const robot_state::RobotState& state, FCLObject& fcl_obj) const -{ - fcl_obj.collision_objects_.reserve(geoms_.size()); - fcl::Transform3d fcl_tf; - - for (std::size_t i = 0; i < geoms_.size(); ++i) - if (geoms_[i] && geoms_[i]->collision_geometry_) - { - transform2fcl(state.getCollisionBodyTransform(geoms_[i]->collision_geometry_data_->ptr.link, - geoms_[i]->collision_geometry_data_->shape_index), - fcl_tf); - auto coll_obj = new fcl::CollisionObjectd(*fcl_objs_[i]); - coll_obj->setTransform(fcl_tf); - coll_obj->computeAABB(); - fcl_obj.collision_objects_.push_back(FCLCollisionObjectPtr(coll_obj)); - } - - // TODO: Implement a method for caching fcl::CollisionObject's for robot_state::AttachedBody's - std::vector ab; - state.getAttachedBodies(ab); - for (auto& body : ab) - { - std::vector objs; - getAttachedBodyObjects(body, objs); - const EigenSTL::vector_Isometry3d& ab_t = body->getGlobalCollisionBodyTransforms(); - for (std::size_t k = 0; k < objs.size(); ++k) - if (objs[k]->collision_geometry_) - { - transform2fcl(ab_t[k], fcl_tf); - fcl_obj.collision_objects_.push_back( - FCLCollisionObjectPtr(new fcl::CollisionObjectd(objs[k]->collision_geometry_, fcl_tf))); - // we copy the shared ptr to the CollisionGeometryData, as this is not stored by the class itself, - // and would be destroyed when objs goes out of scope. - fcl_obj.collision_geometry_.push_back(objs[k]); - } - } -} - -void CollisionRobotFCL::allocSelfCollisionBroadPhase(const robot_state::RobotState& state, FCLManager& manager) const -{ - auto m = new fcl::DynamicAABBTreeCollisionManagerd(); - // m->tree_init_level = 2; - manager.manager_.reset(m); - constructFCLObject(state, manager.object_); - manager.object_.registerTo(manager.manager_.get()); - // manager.manager_->update(); -} - -void CollisionRobotFCL::checkSelfCollision(const CollisionRequest& req, CollisionResult& res, - const robot_state::RobotState& state) const -{ - checkSelfCollisionHelper(req, res, state, nullptr); -} - -void CollisionRobotFCL::checkSelfCollision(const CollisionRequest& req, CollisionResult& res, - const robot_state::RobotState& state, - const AllowedCollisionMatrix& acm) const -{ - checkSelfCollisionHelper(req, res, state, &acm); -} - -void CollisionRobotFCL::checkSelfCollision(const CollisionRequest& req, CollisionResult& res, - const robot_state::RobotState& state1, - const robot_state::RobotState& state2) const -{ - ROS_ERROR_NAMED("collision_detection.fcl", "FCL continuous collision checking not yet implemented"); -} - -void CollisionRobotFCL::checkSelfCollision(const CollisionRequest& req, CollisionResult& res, - const robot_state::RobotState& state1, const robot_state::RobotState& state2, - const AllowedCollisionMatrix& acm) const -{ - ROS_ERROR_NAMED("collision_detection.fcl", "FCL continuous collision checking not yet implemented"); -} - -void CollisionRobotFCL::checkSelfCollisionHelper(const CollisionRequest& req, CollisionResult& res, - const robot_state::RobotState& state, - const AllowedCollisionMatrix* acm) const -{ - FCLManager manager; - allocSelfCollisionBroadPhase(state, manager); - CollisionData cd(&req, &res, acm); - cd.enableGroup(getRobotModel()); - manager.manager_->collide(&cd, &collisionCallback); - if (req.distance) - { - DistanceRequest dreq; - DistanceResult dres; - - dreq.group_name = req.group_name; - dreq.acm = acm; - dreq.enableGroup(getRobotModel()); - distanceSelf(dreq, dres, state); - res.distance = dres.minimum_distance.distance; - } -} - -void CollisionRobotFCL::checkOtherCollision(const CollisionRequest& req, CollisionResult& res, - const robot_state::RobotState& state, const CollisionRobot& other_robot, - const robot_state::RobotState& other_state) const -{ - checkOtherCollisionHelper(req, res, state, other_robot, other_state, nullptr); -} - -void CollisionRobotFCL::checkOtherCollision(const CollisionRequest& req, CollisionResult& res, - const robot_state::RobotState& state, const CollisionRobot& other_robot, - const robot_state::RobotState& other_state, - const AllowedCollisionMatrix& acm) const -{ - checkOtherCollisionHelper(req, res, state, other_robot, other_state, &acm); -} - -void CollisionRobotFCL::checkOtherCollision(const CollisionRequest& req, CollisionResult& res, - const robot_state::RobotState& state1, - const robot_state::RobotState& state2, const CollisionRobot& other_robot, - const robot_state::RobotState& other_state1, - const robot_state::RobotState& other_state2) const -{ - ROS_ERROR_NAMED("collision_detection.fcl", "FCL continuous collision checking not yet implemented"); -} - -void CollisionRobotFCL::checkOtherCollision(const CollisionRequest& req, CollisionResult& res, - const robot_state::RobotState& state1, - const robot_state::RobotState& state2, const CollisionRobot& other_robot, - const robot_state::RobotState& other_state1, - const robot_state::RobotState& other_state2, - const AllowedCollisionMatrix& acm) const -{ - ROS_ERROR_NAMED("collision_detection.fcl", "FCL continuous collision checking not yet implemented"); -} - -void CollisionRobotFCL::checkOtherCollisionHelper(const CollisionRequest& req, CollisionResult& res, - const robot_state::RobotState& state, - const CollisionRobot& other_robot, - const robot_state::RobotState& other_state, - const AllowedCollisionMatrix* acm) const -{ - FCLManager manager; - allocSelfCollisionBroadPhase(state, manager); - - const CollisionRobotFCL& fcl_rob = dynamic_cast(other_robot); - FCLObject other_fcl_obj; - fcl_rob.constructFCLObject(other_state, other_fcl_obj); - - CollisionData cd(&req, &res, acm); - cd.enableGroup(getRobotModel()); - for (std::size_t i = 0; !cd.done_ && i < other_fcl_obj.collision_objects_.size(); ++i) - manager.manager_->collide(other_fcl_obj.collision_objects_[i].get(), &cd, &collisionCallback); - - if (req.distance) - { - DistanceRequest dreq; - DistanceResult dres; - - dreq.group_name = req.group_name; - dreq.acm = acm; - dreq.enableGroup(getRobotModel()); - distanceOther(dreq, dres, state, other_robot, other_state); - res.distance = dres.minimum_distance.distance; - } -} - -void CollisionRobotFCL::updatedPaddingOrScaling(const std::vector& links) -{ - std::size_t index; - for (const auto& link : links) - { - const robot_model::LinkModel* lmodel = robot_model_->getLinkModel(link); - if (lmodel) - { - for (std::size_t j = 0; j < lmodel->getShapes().size(); ++j) - { - FCLGeometryConstPtr g = createCollisionGeometry(lmodel->getShapes()[j], getLinkScale(lmodel->getName()), - getLinkPadding(lmodel->getName()), lmodel, j); - if (g) - { - index = lmodel->getFirstCollisionBodyTransformIndex() + j; - geoms_[index] = g; - fcl_objs_[index] = FCLCollisionObjectConstPtr(new fcl::CollisionObjectd(g->collision_geometry_)); - } - } - } - else - ROS_ERROR_NAMED("collision_detection.fcl", "Updating padding or scaling for unknown link: '%s'", link.c_str()); - } -} - -void CollisionRobotFCL::distanceSelf(const DistanceRequest& req, DistanceResult& res, - const robot_state::RobotState& state) const -{ - FCLManager manager; - allocSelfCollisionBroadPhase(state, manager); - DistanceData drd(&req, &res); - - manager.manager_->distance(&drd, &distanceCallback); -} - -void CollisionRobotFCL::distanceOther(const DistanceRequest& req, DistanceResult& res, - const robot_state::RobotState& state, const CollisionRobot& other_robot, - const robot_state::RobotState& other_state) const -{ - FCLManager manager; - allocSelfCollisionBroadPhase(state, manager); - - const CollisionRobotFCL& fcl_rob = dynamic_cast(other_robot); - FCLObject other_fcl_obj; - fcl_rob.constructFCLObject(other_state, other_fcl_obj); - - DistanceData drd(&req, &res); - for (std::size_t i = 0; !drd.done && i < other_fcl_obj.collision_objects_.size(); ++i) - manager.manager_->distance(other_fcl_obj.collision_objects_[i].get(), &drd, &distanceCallback); -} - -} // end of namespace collision_detection diff --git a/moveit_core/collision_detection_fcl/src/collision_world_fcl.cpp b/moveit_core/collision_detection_fcl/src/collision_world_fcl.cpp deleted file mode 100644 index 8d6eb392f9..0000000000 --- a/moveit_core/collision_detection_fcl/src/collision_world_fcl.cpp +++ /dev/null @@ -1,299 +0,0 @@ -/********************************************************************* - * Software License Agreement (BSD License) - * - * Copyright (c) 2011, Willow Garage, Inc. - * 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 and/or other materials provided - * with the distribution. - * * Neither the name of Willow Garage nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 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 OWNER 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. - *********************************************************************/ - -/* Author: Ioan Sucan */ - -#include -#include -#include - -#if (MOVEIT_FCL_VERSION >= FCL_VERSION_CHECK(0, 6, 0)) -#include -#include -#include -#include -#else -#include -#include -#include -#include -#endif - -#include - -namespace collision_detection -{ -const std::string CollisionDetectorAllocatorFCL::NAME("FCL"); - -CollisionWorldFCL::CollisionWorldFCL() : CollisionWorld() -{ - auto m = new fcl::DynamicAABBTreeCollisionManagerd(); - // m->tree_init_level = 2; - manager_.reset(m); - - // request notifications about changes to new world - observer_handle_ = getWorld()->addObserver(boost::bind(&CollisionWorldFCL::notifyObjectChange, this, _1, _2)); -} - -CollisionWorldFCL::CollisionWorldFCL(const WorldPtr& world) : CollisionWorld(world) -{ - auto m = new fcl::DynamicAABBTreeCollisionManagerd(); - // m->tree_init_level = 2; - manager_.reset(m); - - // request notifications about changes to new world - observer_handle_ = getWorld()->addObserver(boost::bind(&CollisionWorldFCL::notifyObjectChange, this, _1, _2)); - getWorld()->notifyObserverAllObjects(observer_handle_, World::CREATE); -} - -CollisionWorldFCL::CollisionWorldFCL(const CollisionWorldFCL& other, const WorldPtr& world) - : CollisionWorld(other, world) -{ - auto m = new fcl::DynamicAABBTreeCollisionManagerd(); - // m->tree_init_level = 2; - manager_.reset(m); - - fcl_objs_ = other.fcl_objs_; - for (auto& fcl_obj : fcl_objs_) - fcl_obj.second.registerTo(manager_.get()); - // manager_->update(); - - // request notifications about changes to new world - observer_handle_ = getWorld()->addObserver(boost::bind(&CollisionWorldFCL::notifyObjectChange, this, _1, _2)); -} - -CollisionWorldFCL::~CollisionWorldFCL() -{ - getWorld()->removeObserver(observer_handle_); -} - -void CollisionWorldFCL::checkRobotCollision(const CollisionRequest& req, CollisionResult& res, - const CollisionRobot& robot, const robot_state::RobotState& state) const -{ - checkRobotCollisionHelper(req, res, robot, state, nullptr); -} - -void CollisionWorldFCL::checkRobotCollision(const CollisionRequest& req, CollisionResult& res, - const CollisionRobot& robot, const robot_state::RobotState& state, - const AllowedCollisionMatrix& acm) const -{ - checkRobotCollisionHelper(req, res, robot, state, &acm); -} - -void CollisionWorldFCL::checkRobotCollision(const CollisionRequest& req, CollisionResult& res, - const CollisionRobot& robot, const robot_state::RobotState& state1, - const robot_state::RobotState& state2) const -{ - ROS_ERROR_NAMED("collision_detection.fcl", "FCL continuous collision checking not yet implemented"); -} - -void CollisionWorldFCL::checkRobotCollision(const CollisionRequest& req, CollisionResult& res, - const CollisionRobot& robot, const robot_state::RobotState& state1, - const robot_state::RobotState& state2, - const AllowedCollisionMatrix& acm) const -{ - ROS_ERROR_NAMED("collision_detection.fcl", "FCL continuous collision checking not yet implemented"); -} - -void CollisionWorldFCL::checkRobotCollisionHelper(const CollisionRequest& req, CollisionResult& res, - const CollisionRobot& robot, const robot_state::RobotState& state, - const AllowedCollisionMatrix* acm) const -{ - const CollisionRobotFCL& robot_fcl = dynamic_cast(robot); - FCLObject fcl_obj; - robot_fcl.constructFCLObject(state, fcl_obj); - - CollisionData cd(&req, &res, acm); - cd.enableGroup(robot.getRobotModel()); - for (std::size_t i = 0; !cd.done_ && i < fcl_obj.collision_objects_.size(); ++i) - manager_->collide(fcl_obj.collision_objects_[i].get(), &cd, &collisionCallback); - - if (req.distance) - { - DistanceRequest dreq; - DistanceResult dres; - - dreq.group_name = req.group_name; - dreq.acm = acm; - dreq.enableGroup(robot.getRobotModel()); - distanceRobot(dreq, dres, robot, state); - res.distance = dres.minimum_distance.distance; - } -} - -void CollisionWorldFCL::checkWorldCollision(const CollisionRequest& req, CollisionResult& res, - const CollisionWorld& other_world) const -{ - checkWorldCollisionHelper(req, res, other_world, nullptr); -} - -void CollisionWorldFCL::checkWorldCollision(const CollisionRequest& req, CollisionResult& res, - const CollisionWorld& other_world, const AllowedCollisionMatrix& acm) const -{ - checkWorldCollisionHelper(req, res, other_world, &acm); -} - -void CollisionWorldFCL::checkWorldCollisionHelper(const CollisionRequest& req, CollisionResult& res, - const CollisionWorld& other_world, - const AllowedCollisionMatrix* acm) const -{ - const CollisionWorldFCL& other_fcl_world = dynamic_cast(other_world); - CollisionData cd(&req, &res, acm); - manager_->collide(other_fcl_world.manager_.get(), &cd, &collisionCallback); - - if (req.distance) - { - DistanceRequest dreq; - DistanceResult dres; - - dreq.group_name = req.group_name; - dreq.acm = acm; - distanceWorld(dreq, dres, other_world); - res.distance = dres.minimum_distance.distance; - } -} - -void CollisionWorldFCL::constructFCLObject(const World::Object* obj, FCLObject& fcl_obj) const -{ - for (std::size_t i = 0; i < obj->shapes_.size(); ++i) - { - FCLGeometryConstPtr g = createCollisionGeometry(obj->shapes_[i], obj); - if (g) - { - auto co = new fcl::CollisionObjectd(g->collision_geometry_, transform2fcl(obj->shape_poses_[i])); - fcl_obj.collision_objects_.push_back(FCLCollisionObjectPtr(co)); - fcl_obj.collision_geometry_.push_back(g); - } - } -} - -void CollisionWorldFCL::updateFCLObject(const std::string& id) -{ - // remove FCL objects that correspond to this object - auto jt = fcl_objs_.find(id); - if (jt != fcl_objs_.end()) - { - jt->second.unregisterFrom(manager_.get()); - jt->second.clear(); - } - - // check to see if we have this object - auto it = getWorld()->find(id); - if (it != getWorld()->end()) - { - // construct FCL objects that correspond to this object - if (jt != fcl_objs_.end()) - { - constructFCLObject(it->second.get(), jt->second); - jt->second.registerTo(manager_.get()); - } - else - { - constructFCLObject(it->second.get(), fcl_objs_[id]); - fcl_objs_[id].registerTo(manager_.get()); - } - } - else - { - if (jt != fcl_objs_.end()) - fcl_objs_.erase(jt); - } - - // manager_->update(); -} - -void CollisionWorldFCL::setWorld(const WorldPtr& world) -{ - if (world == getWorld()) - return; - - // turn off notifications about old world - getWorld()->removeObserver(observer_handle_); - - // clear out objects from old world - manager_->clear(); - fcl_objs_.clear(); - cleanCollisionGeometryCache(); - - CollisionWorld::setWorld(world); - - // request notifications about changes to new world - observer_handle_ = getWorld()->addObserver(boost::bind(&CollisionWorldFCL::notifyObjectChange, this, _1, _2)); - - // get notifications any objects already in the new world - getWorld()->notifyObserverAllObjects(observer_handle_, World::CREATE); -} - -void CollisionWorldFCL::notifyObjectChange(const ObjectConstPtr& obj, World::Action action) -{ - if (action == World::DESTROY) - { - auto it = fcl_objs_.find(obj->id_); - if (it != fcl_objs_.end()) - { - it->second.unregisterFrom(manager_.get()); - it->second.clear(); - fcl_objs_.erase(it); - } - cleanCollisionGeometryCache(); - } - else - { - updateFCLObject(obj->id_); - if (action & (World::DESTROY | World::REMOVE_SHAPE)) - cleanCollisionGeometryCache(); - } -} - -void CollisionWorldFCL::distanceRobot(const DistanceRequest& req, DistanceResult& res, const CollisionRobot& robot, - const robot_state::RobotState& state) const -{ - const CollisionRobotFCL& robot_fcl = dynamic_cast(robot); - FCLObject fcl_obj; - robot_fcl.constructFCLObject(state, fcl_obj); - - DistanceData drd(&req, &res); - for (std::size_t i = 0; !drd.done && i < fcl_obj.collision_objects_.size(); ++i) - manager_->distance(fcl_obj.collision_objects_[i].get(), &drd, &distanceCallback); -} - -void CollisionWorldFCL::distanceWorld(const DistanceRequest& req, DistanceResult& res, - const CollisionWorld& world) const -{ - const CollisionWorldFCL& other_fcl_world = dynamic_cast(world); - DistanceData drd(&req, &res); - manager_->distance(other_fcl_world.manager_.get(), &drd, &distanceCallback); -} - -} // end of namespace collision_detection diff --git a/moveit_core/collision_detection_fcl/test/test_fcl_collision_detection.cpp b/moveit_core/collision_detection_fcl/test/test_fcl_collision_detection.cpp index e606f632a3..e4ea360a95 100644 --- a/moveit_core/collision_detection_fcl/test/test_fcl_collision_detection.cpp +++ b/moveit_core/collision_detection_fcl/test/test_fcl_collision_detection.cpp @@ -36,8 +36,7 @@ #include #include -#include -#include +#include #include #include @@ -49,8 +48,7 @@ #include #include -typedef collision_detection::CollisionWorldFCL DefaultCWorldType; -typedef collision_detection::CollisionRobotFCL DefaultCRobotType; +typedef collision_detection::CollisionEnvFCL DefaultEnvType; class FclCollisionDetectionTester : public testing::Test { @@ -63,8 +61,7 @@ class FclCollisionDetectionTester : public testing::Test acm_.reset(new collision_detection::AllowedCollisionMatrix(robot_model_->getLinkModelNames(), true)); - crobot_.reset(new DefaultCRobotType(robot_model_)); - cworld_.reset(new DefaultCWorldType()); + c_env_.reset(new DefaultEnvType(robot_model_)); } void TearDown() override @@ -76,8 +73,7 @@ class FclCollisionDetectionTester : public testing::Test robot_model::RobotModelPtr robot_model_; - collision_detection::CollisionRobotPtr crobot_; - collision_detection::CollisionWorldPtr cworld_; + collision_detection::CollisionEnvPtr c_env_; collision_detection::AllowedCollisionMatrixPtr acm_; @@ -97,7 +93,7 @@ TEST_F(FclCollisionDetectionTester, DefaultNotInCollision) collision_detection::CollisionRequest req; collision_detection::CollisionResult res; - crobot_->checkSelfCollision(req, res, robot_state, *acm_); + c_env_->checkSelfCollision(req, res, robot_state, *acm_); ASSERT_FALSE(res.collision); } @@ -124,11 +120,11 @@ TEST_F(FclCollisionDetectionTester, LinksInCollision) robot_state.update(); acm_->setEntry("base_link", "base_bellow_link", false); - crobot_->checkSelfCollision(req, res1, robot_state, *acm_); + c_env_->checkSelfCollision(req, res1, robot_state, *acm_); ASSERT_TRUE(res1.collision); acm_->setEntry("base_link", "base_bellow_link", true); - crobot_->checkSelfCollision(req, res2, robot_state, *acm_); + c_env_->checkSelfCollision(req, res2, robot_state, *acm_); ASSERT_FALSE(res2.collision); // req.verbose = true; @@ -139,7 +135,7 @@ TEST_F(FclCollisionDetectionTester, LinksInCollision) robot_state.update(); acm_->setEntry("r_gripper_palm_link", "l_gripper_palm_link", false); - crobot_->checkSelfCollision(req, res3, robot_state, *acm_); + c_env_->checkSelfCollision(req, res3, robot_state, *acm_); ASSERT_TRUE(res3.collision); } @@ -171,7 +167,7 @@ TEST_F(FclCollisionDetectionTester, ContactReporting) acm_->setEntry("r_gripper_palm_link", "l_gripper_palm_link", false); collision_detection::CollisionResult res; - crobot_->checkSelfCollision(req, res, robot_state, *acm_); + c_env_->checkSelfCollision(req, res, robot_state, *acm_); ASSERT_TRUE(res.collision); EXPECT_EQ(res.contacts.size(), 1u); EXPECT_EQ(res.contacts.begin()->second.size(), 1u); @@ -180,7 +176,7 @@ TEST_F(FclCollisionDetectionTester, ContactReporting) req.max_contacts = 2; req.max_contacts_per_pair = 1; // req.verbose = true; - crobot_->checkSelfCollision(req, res, robot_state, *acm_); + c_env_->checkSelfCollision(req, res, robot_state, *acm_); ASSERT_TRUE(res.collision); EXPECT_EQ(res.contacts.size(), 2u); EXPECT_EQ(res.contacts.begin()->second.size(), 1u); @@ -191,7 +187,7 @@ TEST_F(FclCollisionDetectionTester, ContactReporting) req.max_contacts = 10; req.max_contacts_per_pair = 2; acm_.reset(new collision_detection::AllowedCollisionMatrix(robot_model_->getLinkModelNames(), false)); - crobot_->checkSelfCollision(req, res, robot_state, *acm_); + c_env_->checkSelfCollision(req, res, robot_state, *acm_); ASSERT_TRUE(res.collision); EXPECT_LE(res.contacts.size(), 10u); EXPECT_LE(res.contact_count, 10u); @@ -222,7 +218,7 @@ TEST_F(FclCollisionDetectionTester, ContactPositions) acm_->setEntry("r_gripper_palm_link", "l_gripper_palm_link", false); collision_detection::CollisionResult res; - crobot_->checkSelfCollision(req, res, robot_state, *acm_); + c_env_->checkSelfCollision(req, res, robot_state, *acm_); ASSERT_TRUE(res.collision); ASSERT_EQ(res.contacts.size(), 1u); ASSERT_EQ(res.contacts.begin()->second.size(), 1u); @@ -242,7 +238,7 @@ TEST_F(FclCollisionDetectionTester, ContactPositions) robot_state.update(); collision_detection::CollisionResult res2; - crobot_->checkSelfCollision(req, res2, robot_state, *acm_); + c_env_->checkSelfCollision(req, res2, robot_state, *acm_); ASSERT_TRUE(res2.collision); ASSERT_EQ(res2.contacts.size(), 1u); ASSERT_EQ(res2.contacts.begin()->second.size(), 1u); @@ -262,7 +258,7 @@ TEST_F(FclCollisionDetectionTester, ContactPositions) robot_state.update(); collision_detection::CollisionResult res3; - crobot_->checkSelfCollision(req, res2, robot_state, *acm_); + c_env_->checkSelfCollision(req, res2, robot_state, *acm_); ASSERT_FALSE(res3.collision); } @@ -283,18 +279,18 @@ TEST_F(FclCollisionDetectionTester, AttachedBodyTester) // robot_state.getLinkState("r_gripper_palm_link")->updateGivenGlobalLinkTransform(pos1); robot_state.updateStateWithLinkAt("r_gripper_palm_link", pos1); robot_state.update(); - crobot_->checkSelfCollision(req, res, robot_state, *acm_); + c_env_->checkSelfCollision(req, res, robot_state, *acm_); ASSERT_FALSE(res.collision); shapes::Shape* shape = new shapes::Box(.1, .1, .1); - cworld_->getWorld()->addToObject("box", shapes::ShapeConstPtr(shape), pos1); + c_env_->getWorld()->addToObject("box", shapes::ShapeConstPtr(shape), pos1); res = collision_detection::CollisionResult(); - cworld_->checkRobotCollision(req, res, *crobot_, robot_state, *acm_); + c_env_->checkRobotCollision(req, res, robot_state, *acm_); ASSERT_TRUE(res.collision); // deletes shape - cworld_->getWorld()->removeObject("box"); + c_env_->getWorld()->removeObject("box"); shape = new shapes::Box(.1, .1, .1); std::vector shapes; @@ -305,7 +301,7 @@ TEST_F(FclCollisionDetectionTester, AttachedBodyTester) robot_state.attachBody("box", shapes, poses, touch_links, "r_gripper_palm_link"); res = collision_detection::CollisionResult(); - crobot_->checkSelfCollision(req, res, robot_state, *acm_); + c_env_->checkSelfCollision(req, res, robot_state, *acm_); ASSERT_TRUE(res.collision); // deletes shape @@ -318,19 +314,19 @@ TEST_F(FclCollisionDetectionTester, AttachedBodyTester) robot_state.update(); res = collision_detection::CollisionResult(); - crobot_->checkSelfCollision(req, res, robot_state, *acm_); + c_env_->checkSelfCollision(req, res, robot_state, *acm_); ASSERT_FALSE(res.collision); pos1.translation().x() = 5.01; shapes::Shape* coll = new shapes::Box(.1, .1, .1); - cworld_->getWorld()->addToObject("coll", shapes::ShapeConstPtr(coll), pos1); + c_env_->getWorld()->addToObject("coll", shapes::ShapeConstPtr(coll), pos1); res = collision_detection::CollisionResult(); - cworld_->checkRobotCollision(req, res, *crobot_, robot_state, *acm_); + c_env_->checkRobotCollision(req, res, robot_state, *acm_); ASSERT_TRUE(res.collision); acm_->setEntry("coll", "r_gripper_palm_link", true); res = collision_detection::CollisionResult(); - cworld_->checkRobotCollision(req, res, *crobot_, robot_state, *acm_); + c_env_->checkRobotCollision(req, res, robot_state, *acm_); ASSERT_TRUE(res.collision); } @@ -342,15 +338,15 @@ TEST_F(FclCollisionDetectionTester, DiffSceneTester) collision_detection::CollisionRequest req; collision_detection::CollisionResult res; - - collision_detection::CollisionRobotFCL new_crobot( - *(dynamic_cast(crobot_.get()))); + collision_detection::CollisionEnvFCL* casted_env_pointer = + dynamic_cast(c_env_.get()); + collision_detection::CollisionEnvFCL new_c_env(*casted_env_pointer, c_env_->getWorld()); ros::WallTime before = ros::WallTime::now(); - new_crobot.checkSelfCollision(req, res, robot_state); + new_c_env.checkSelfCollision(req, res, robot_state); double first_check = (ros::WallTime::now() - before).toSec(); before = ros::WallTime::now(); - new_crobot.checkSelfCollision(req, res, robot_state); + new_c_env.checkSelfCollision(req, res, robot_state); double second_check = (ros::WallTime::now() - before).toSec(); EXPECT_LT(fabs(first_check - second_check), .05); @@ -367,22 +363,21 @@ TEST_F(FclCollisionDetectionTester, DiffSceneTester) robot_state.attachBody("kinect", shapes, poses, touch_links, "r_gripper_palm_link"); before = ros::WallTime::now(); - new_crobot.checkSelfCollision(req, res, robot_state); + new_c_env.checkSelfCollision(req, res, robot_state); first_check = (ros::WallTime::now() - before).toSec(); before = ros::WallTime::now(); - new_crobot.checkSelfCollision(req, res, robot_state); + new_c_env.checkSelfCollision(req, res, robot_state); second_check = (ros::WallTime::now() - before).toSec(); // the first check is going to take a while, as data must be constructed EXPECT_LT(second_check, .1); - collision_detection::CollisionRobotFCL other_new_crobot( - *(dynamic_cast(crobot_.get()))); + collision_detection::CollisionEnvFCL other_new_c_env(*casted_env_pointer, c_env_->getWorld()); before = ros::WallTime::now(); - new_crobot.checkSelfCollision(req, res, robot_state); + new_c_env.checkSelfCollision(req, res, robot_state); first_check = (ros::WallTime::now() - before).toSec(); before = ros::WallTime::now(); - new_crobot.checkSelfCollision(req, res, robot_state); + new_c_env.checkSelfCollision(req, res, robot_state); second_check = (ros::WallTime::now() - before).toSec(); EXPECT_LT(fabs(first_check - second_check), .05); @@ -398,23 +393,23 @@ TEST_F(FclCollisionDetectionTester, ConvertObjectToAttached) Eigen::Isometry3d pos2 = Eigen::Isometry3d::Identity(); pos2.translation().x() = 10.0; - cworld_->getWorld()->addToObject("kinect", shape, pos1); + c_env_->getWorld()->addToObject("kinect", shape, pos1); robot_state::RobotState robot_state(robot_model_); robot_state.setToDefaultValues(); robot_state.update(); ros::WallTime before = ros::WallTime::now(); - cworld_->checkRobotCollision(req, res, *crobot_, robot_state); + c_env_->checkRobotCollision(req, res, robot_state); double first_check = (ros::WallTime::now() - before).toSec(); before = ros::WallTime::now(); - cworld_->checkRobotCollision(req, res, *crobot_, robot_state); + c_env_->checkRobotCollision(req, res, robot_state); double second_check = (ros::WallTime::now() - before).toSec(); EXPECT_LT(second_check, .05); - collision_detection::CollisionWorld::ObjectConstPtr object = cworld_->getWorld()->getObject("kinect"); - cworld_->getWorld()->removeObject("kinect"); + collision_detection::CollisionEnv::ObjectConstPtr object = c_env_->getWorld()->getObject("kinect"); + c_env_->getWorld()->removeObject("kinect"); robot_state::RobotState robot_state1(robot_model_); robot_state::RobotState robot_state2(robot_model_); @@ -434,17 +429,17 @@ TEST_F(FclCollisionDetectionTester, ConvertObjectToAttached) // going to take a while, but that's fine res = collision_detection::CollisionResult(); - crobot_->checkSelfCollision(req, res, robot_state1); + c_env_->checkSelfCollision(req, res, robot_state1); EXPECT_TRUE(res.collision); before = ros::WallTime::now(); - crobot_->checkSelfCollision(req, res, robot_state1, *acm_); + c_env_->checkSelfCollision(req, res, robot_state1, *acm_); first_check = (ros::WallTime::now() - before).toSec(); before = ros::WallTime::now(); req.verbose = true; res = collision_detection::CollisionResult(); - crobot_->checkSelfCollision(req, res, robot_state2, *acm_); + c_env_->checkSelfCollision(req, res, robot_state2, *acm_); second_check = (ros::WallTime::now() - before).toSec(); EXPECT_LT(first_check, .05); @@ -461,7 +456,7 @@ TEST_F(FclCollisionDetectionTester, TestCollisionMapAdditionSpeed) shapes.push_back(shapes::ShapeConstPtr(new shapes::Box(.01, .01, .01))); } ros::WallTime start = ros::WallTime::now(); - cworld_->getWorld()->addToObject("map", shapes, poses); + c_env_->getWorld()->addToObject("map", shapes, poses); double t = (ros::WallTime::now() - start).toSec(); EXPECT_GE(1.0, t); // this is not really a failure; it is just that slow; @@ -480,16 +475,16 @@ TEST_F(FclCollisionDetectionTester, MoveMesh) shapes::ShapePtr kinect_shape; kinect_shape.reset(shapes::createMeshFromResource(kinect_dae_resource_)); - cworld_->getWorld()->addToObject("kinect", kinect_shape, kinect_pose); + c_env_->getWorld()->addToObject("kinect", kinect_shape, kinect_pose); Eigen::Isometry3d np; for (unsigned int i = 0; i < 5; i++) { np = Eigen::Translation3d(i * .001, i * .001, i * .001) * Eigen::Quaterniond::Identity(); - cworld_->getWorld()->moveShapeInObject("kinect", kinect_shape, np); + c_env_->getWorld()->moveShapeInObject("kinect", kinect_shape, np); collision_detection::CollisionRequest req; collision_detection::CollisionResult res; - cworld_->checkCollision(req, res, *crobot_, robot_state1, *acm_); + c_env_->checkCollision(req, res, robot_state1, *acm_); } } @@ -508,37 +503,37 @@ TEST_F(FclCollisionDetectionTester, TestChangingShapeSize) std::vector shapes; for (unsigned int i = 0; i < 5; i++) { - cworld_->getWorld()->removeObject("shape"); + c_env_->getWorld()->removeObject("shape"); shapes.clear(); poses.clear(); shapes.push_back(shapes::ShapeConstPtr(new shapes::Box(1 + i * .0001, 1 + i * .0001, 1 + i * .0001))); poses.push_back(Eigen::Isometry3d::Identity()); - cworld_->getWorld()->addToObject("shape", shapes, poses); + c_env_->getWorld()->addToObject("shape", shapes, poses); collision_detection::CollisionRequest req; collision_detection::CollisionResult res; - cworld_->checkCollision(req, res, *crobot_, robot_state1, *acm_); + c_env_->checkCollision(req, res, robot_state1, *acm_); ASSERT_TRUE(res.collision); } Eigen::Isometry3d kinect_pose = Eigen::Isometry3d::Identity(); shapes::ShapePtr kinect_shape; kinect_shape.reset(shapes::createMeshFromResource(kinect_dae_resource_)); - cworld_->getWorld()->addToObject("kinect", kinect_shape, kinect_pose); + c_env_->getWorld()->addToObject("kinect", kinect_shape, kinect_pose); collision_detection::CollisionRequest req2; collision_detection::CollisionResult res2; - cworld_->checkCollision(req2, res2, *crobot_, robot_state1, *acm_); + c_env_->checkCollision(req2, res2, robot_state1, *acm_); ASSERT_TRUE(res2.collision); for (unsigned int i = 0; i < 5; i++) { - cworld_->getWorld()->removeObject("shape"); + c_env_->getWorld()->removeObject("shape"); shapes.clear(); poses.clear(); shapes.push_back(shapes::ShapeConstPtr(new shapes::Box(1 + i * .0001, 1 + i * .0001, 1 + i * .0001))); poses.push_back(Eigen::Isometry3d::Identity()); - cworld_->getWorld()->addToObject("shape", shapes, poses); + c_env_->getWorld()->addToObject("shape", shapes, poses); collision_detection::CollisionRequest req; collision_detection::CollisionResult res; - cworld_->checkCollision(req, res, *crobot_, robot_state1, *acm_); + c_env_->checkCollision(req, res, robot_state1, *acm_); ASSERT_TRUE(res.collision); } } diff --git a/moveit_core/collision_detection_fcl/test/test_fcl_env.cpp b/moveit_core/collision_detection_fcl/test/test_fcl_env.cpp new file mode 100644 index 0000000000..64f65b64c3 --- /dev/null +++ b/moveit_core/collision_detection_fcl/test/test_fcl_env.cpp @@ -0,0 +1,324 @@ +/********************************************************************* + * Software License Agreement (BSD License) + * + * Copyright (c) 2019, Jens Petit + * 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 and/or other materials provided + * with the distribution. + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * 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 OWNER 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. + *********************************************************************/ + +/* Author: Jens Petit */ + +#include +#include + +#include + +#include +#include +#include + +#include +#include + +#include +#include + +/** \brief Brings the panda robot in user defined home position */ +inline void setToHome(robot_state::RobotState& panda_state) +{ + panda_state.setToDefaultValues(); + double joint2 = -0.785; + double joint4 = -2.356; + double joint6 = 1.571; + double joint7 = 0.785; + panda_state.setJointPositions("panda_joint2", &joint2); + panda_state.setJointPositions("panda_joint4", &joint4); + panda_state.setJointPositions("panda_joint6", &joint6); + panda_state.setJointPositions("panda_joint7", &joint7); + panda_state.update(); +} + +class CollisionDetectionEnvTest : public testing::Test +{ +protected: + void SetUp() override + { + robot_model_ = moveit::core::loadTestingRobotModel("panda"); + robot_model_ok_ = static_cast(robot_model_); + + acm_.reset(new collision_detection::AllowedCollisionMatrix(robot_model_->getLinkModelNames(), false)); + + acm_->setEntry("panda_link0", "panda_link1", true); + acm_->setEntry("panda_link1", "panda_link2", true); + acm_->setEntry("panda_link2", "panda_link3", true); + acm_->setEntry("panda_link3", "panda_link4", true); + acm_->setEntry("panda_link4", "panda_link5", true); + acm_->setEntry("panda_link5", "panda_link6", true); + acm_->setEntry("panda_link6", "panda_link7", true); + acm_->setEntry("panda_link7", "panda_hand", true); + acm_->setEntry("panda_hand", "panda_rightfinger", true); + acm_->setEntry("panda_hand", "panda_leftfinger", true); + acm_->setEntry("panda_rightfinger", "panda_leftfinger", true); + acm_->setEntry("panda_link5", "panda_link7", true); + acm_->setEntry("panda_link6", "panda_hand", true); + + c_env_.reset(new collision_detection::CollisionEnvFCL(robot_model_)); + + robot_state_.reset(new robot_state::RobotState(robot_model_)); + + setToHome(*robot_state_); + } + + void TearDown() override + { + } + +protected: + bool robot_model_ok_; + + robot_model::RobotModelPtr robot_model_; + + collision_detection::CollisionEnvPtr c_env_; + + collision_detection::AllowedCollisionMatrixPtr acm_; + + robot_state::RobotStatePtr robot_state_; +}; + +/** \brief Correct setup testing. */ +TEST_F(CollisionDetectionEnvTest, InitOK) +{ + ASSERT_TRUE(robot_model_ok_); +} + +/** \brief Tests the default values specified in the SRDF if they are collision free. */ +TEST_F(CollisionDetectionEnvTest, DefaultNotInCollision) +{ + collision_detection::CollisionRequest req; + collision_detection::CollisionResult res; + c_env_->checkSelfCollision(req, res, *robot_state_, *acm_); + ASSERT_FALSE(res.collision); +} + +/** \brief A configuration where the robot should collide with itself. */ +TEST_F(CollisionDetectionEnvTest, LinksInCollision) +{ + // Sets the joint values to zero which is a colliding configuration + robot_state_->setToDefaultValues(); + robot_state_->update(); + + collision_detection::CollisionRequest req; + collision_detection::CollisionResult res; + c_env_->checkSelfCollision(req, res, *robot_state_, *acm_); + ASSERT_TRUE(res.collision); +} + +/** \brief Adding obstacles to the world which are tested against the robot. Simple cases. */ +TEST_F(CollisionDetectionEnvTest, RobotWorldCollision_1) +{ + collision_detection::CollisionRequest req; + collision_detection::CollisionResult res; + + shapes::Shape* shape = new shapes::Box(.1, .1, .1); + shapes::ShapeConstPtr shape_ptr(shape); + + Eigen::Isometry3d pos1 = Eigen::Isometry3d::Identity(); + pos1.translation().z() = 0.3; + c_env_->getWorld()->addToObject("box", shape_ptr, pos1); + + c_env_->checkSelfCollision(req, res, *robot_state_, *acm_); + ASSERT_FALSE(res.collision); + res.clear(); + + c_env_->checkRobotCollision(req, res, *robot_state_, *acm_); + ASSERT_TRUE(res.collision); + res.clear(); + + c_env_->getWorld()->moveObject("box", pos1); + c_env_->checkRobotCollision(req, res, *robot_state_, *acm_); + ASSERT_TRUE(res.collision); + res.clear(); + + c_env_->getWorld()->moveObject("box", pos1); + ASSERT_FALSE(res.collision); +} + +/** \brief Adding obstacles to the world which are tested against the robot. */ +TEST_F(CollisionDetectionEnvTest, RobotWorldCollision_2) +{ + collision_detection::CollisionRequest req; + collision_detection::CollisionResult res; + req.max_contacts = 10; + req.contacts = true; + req.verbose = true; + + shapes::Shape* shape = new shapes::Box(.4, .4, .4); + shapes::ShapeConstPtr shape_ptr(shape); + + Eigen::Isometry3d pos1 = Eigen::Isometry3d::Identity(); + pos1.translation().z() = 0.3; + c_env_->getWorld()->addToObject("box", shape_ptr, pos1); + c_env_->checkRobotCollision(req, res, *robot_state_, *acm_); + ASSERT_TRUE(res.collision); + ASSERT_GE(res.contact_count, 3u); + res.clear(); +} + +/** \brief Tests the padding through expanding the link geometry in such a way that a collision occurs. */ +TEST_F(CollisionDetectionEnvTest, PaddingTest) +{ + collision_detection::CollisionRequest req; + req.contacts = true; + req.max_contacts = 10; + collision_detection::CollisionResult res; + + c_env_->checkRobotCollision(req, res, *robot_state_, *acm_); + ASSERT_FALSE(res.collision); + res.clear(); + + // Adding the box right in front of the robot hand + shapes::Shape* shape = new shapes::Box(0.1, 0.1, 0.1); + shapes::ShapeConstPtr shape_ptr(shape); + + Eigen::Isometry3d pos{ Eigen::Isometry3d::Identity() }; + pos.translation().x() = 0.43; + pos.translation().y() = 0; + pos.translation().z() = 0.55; + c_env_->getWorld()->addToObject("box", shape_ptr, pos); + + c_env_->setLinkPadding("panda_hand", 0.08); + c_env_->checkRobotCollision(req, res, *robot_state_, *acm_); + ASSERT_TRUE(res.collision); + res.clear(); + + c_env_->setLinkPadding("panda_hand", 0.0); + c_env_->checkRobotCollision(req, res, *robot_state_, *acm_); + ASSERT_FALSE(res.collision); +} + +/** \brief Continuous self collision checks of the robot. + * + * Functionality not supported yet. */ +TEST_F(CollisionDetectionEnvTest, DISABLED_ContinuousCollisionSelf) +{ + collision_detection::CollisionRequest req; + collision_detection::CollisionResult res; + + robot_state::RobotState state1(robot_model_); + robot_state::RobotState state2(robot_model_); + + setToHome(state1); + double joint2 = 0.15; + double joint4 = -3.0; + double joint5 = -0.8; + double joint7 = -0.785; + state1.setJointPositions("panda_joint2", &joint2); + state1.setJointPositions("panda_joint4", &joint4); + state1.setJointPositions("panda_joint5", &joint5); + state1.setJointPositions("panda_joint7", &joint7); + state1.update(); + + c_env_->checkSelfCollision(req, res, state1, *acm_); + ASSERT_FALSE(res.collision); + res.clear(); + + setToHome(state2); + double joint_5_other = 0.8; + state2.setJointPositions("panda_joint2", &joint2); + state2.setJointPositions("panda_joint4", &joint4); + state2.setJointPositions("panda_joint5", &joint_5_other); + state2.setJointPositions("panda_joint7", &joint7); + state2.update(); + + c_env_->checkSelfCollision(req, res, state2, *acm_); + ASSERT_FALSE(res.collision); + res.clear(); + + // c_env_->checkSelfCollision(req, res, state1, state2, *acm_); + ROS_INFO_STREAM("Continous to continous collisions are not supported yet, therefore fail here."); + ASSERT_TRUE(res.collision); + res.clear(); +} + +/** \brief Two similar robot poses are used as start and end pose of a continuous collision check. + * + * Functionality not supported yet. */ +TEST_F(CollisionDetectionEnvTest, DISABLED_ContinuousCollisionWorld) +{ + collision_detection::CollisionRequest req; + req.contacts = true; + req.max_contacts = 10; + collision_detection::CollisionResult res; + + robot_state::RobotState state1(robot_model_); + robot_state::RobotState state2(robot_model_); + + setToHome(state1); + state1.update(); + + setToHome(state2); + double joint_2{ 0.05 }; + double joint_4{ -1.6 }; + state2.setJointPositions("panda_joint2", &joint_2); + state2.setJointPositions("panda_joint4", &joint_4); + state2.update(); + + c_env_->checkRobotCollision(req, res, state1, state2, *acm_); + ASSERT_FALSE(res.collision); + res.clear(); + + // Adding the box which is not in collision with the individual states but sits right between them. + shapes::Shape* shape = new shapes::Box(0.1, 0.1, 0.1); + shapes::ShapeConstPtr shape_ptr(shape); + + Eigen::Isometry3d pos{ Eigen::Isometry3d::Identity() }; + pos.translation().x() = 0.43; + pos.translation().y() = 0; + pos.translation().z() = 0.55; + c_env_->getWorld()->addToObject("box", shape_ptr, pos); + + c_env_->checkRobotCollision(req, res, state1, *acm_); + ASSERT_FALSE(res.collision); + res.clear(); + + c_env_->checkRobotCollision(req, res, state2, *acm_); + ASSERT_FALSE(res.collision); + res.clear(); + + c_env_->checkRobotCollision(req, res, state1, state2, *acm_); + ASSERT_TRUE(res.collision); + ASSERT_EQ(res.contact_count, 4u); + res.clear(); +} + +int main(int argc, char** argv) +{ + testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} diff --git a/moveit_core/collision_distance_field/CMakeLists.txt b/moveit_core/collision_distance_field/CMakeLists.txt index 491b47f0e8..063a1331a3 100644 --- a/moveit_core/collision_distance_field/CMakeLists.txt +++ b/moveit_core/collision_distance_field/CMakeLists.txt @@ -8,10 +8,8 @@ endif() add_library(${MOVEIT_LIB_NAME} src/collision_distance_field_types.cpp src/collision_common_distance_field.cpp - src/collision_robot_distance_field.cpp - src/collision_world_distance_field.cpp - src/collision_robot_hybrid.cpp - src/collision_world_hybrid.cpp + src/collision_env_distance_field.cpp + src/collision_env_hybrid.cpp ) set_target_properties(${MOVEIT_LIB_NAME} PROPERTIES VERSION "${${PROJECT_NAME}_VERSION}") target_link_libraries(${MOVEIT_LIB_NAME} @@ -30,7 +28,7 @@ endif() install(TARGETS ${MOVEIT_LIB_NAME} ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} - RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} + RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION} ) install(DIRECTORY include/ DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}) diff --git a/moveit_core/collision_distance_field/include/moveit/collision_distance_field/collision_common_distance_field.h b/moveit_core/collision_distance_field/include/moveit/collision_distance_field/collision_common_distance_field.h index fa5910a581..cfb6fe750d 100644 --- a/moveit_core/collision_distance_field/include/moveit/collision_distance_field/collision_common_distance_field.h +++ b/moveit_core/collision_distance_field/include/moveit/collision_distance_field/collision_common_distance_field.h @@ -34,13 +34,12 @@ /* Author: E. Gil Jones */ -#ifndef MOVEIT_COLLISION_DETECTION_DISTANCE_FIELD_COLLISION_COMMON_ -#define MOVEIT_COLLISION_DETECTION_DISTANCE_FIELD_COLLISION_COMMON_ +#pragma once #include #include #include -#include +#include #include namespace collision_detection @@ -180,4 +179,3 @@ PosedBodyPointDecompositionVectorPtr getAttachedBodyPointDecomposition(const rob void getBodySphereVisualizationMarkers(const GroupStateRepresentationPtr& gsr, const std::string& reference_frame, visualization_msgs::MarkerArray& body_marker_array); } -#endif diff --git a/moveit_core/collision_distance_field/include/moveit/collision_distance_field/collision_detector_allocator_distance_field.h b/moveit_core/collision_distance_field/include/moveit/collision_distance_field/collision_detector_allocator_distance_field.h index 53c71b9f35..b699170892 100644 --- a/moveit_core/collision_distance_field/include/moveit/collision_distance_field/collision_detector_allocator_distance_field.h +++ b/moveit_core/collision_distance_field/include/moveit/collision_distance_field/collision_detector_allocator_distance_field.h @@ -34,23 +34,18 @@ /* Author: Acorn Pooley, Ioan Sucan */ -#ifndef MOVEIT_COLLISION_DETECTION_COLLISION_DETECTOR_DISTANCE_FIELD_H_ -#define MOVEIT_COLLISION_DETECTION_COLLISION_DETECTOR_DISTANCE_FIELD_H_ +#pragma once #include -#include -#include +#include namespace collision_detection { /** \brief An allocator for Distance Field collision detectors */ class CollisionDetectorAllocatorDistanceField - : public CollisionDetectorAllocatorTemplate + : public CollisionDetectorAllocatorTemplate { public: - static const std::string NAME; // defined in collision_world_distance_field.cpp + static const std::string NAME; // defined in collision_env_distance_field.cpp }; } - -#endif diff --git a/moveit_core/collision_distance_field/include/moveit/collision_distance_field/collision_detector_allocator_hybrid.h b/moveit_core/collision_distance_field/include/moveit/collision_distance_field/collision_detector_allocator_hybrid.h index 6eb3277ee7..efce4d7b11 100644 --- a/moveit_core/collision_distance_field/include/moveit/collision_distance_field/collision_detector_allocator_hybrid.h +++ b/moveit_core/collision_distance_field/include/moveit/collision_distance_field/collision_detector_allocator_hybrid.h @@ -34,23 +34,18 @@ /* Author: Acorn Pooley, Ioan Sucan */ -#ifndef MOVEIT_COLLISION_DETECTION_COLLISION_DETECTOR_HYBRID_H_ -#define MOVEIT_COLLISION_DETECTION_COLLISION_DETECTOR_HYBRID_H_ +#pragma once #include -#include -#include +#include namespace collision_detection { /** \brief An allocator for Hybrid collision detectors */ class CollisionDetectorAllocatorHybrid - : public CollisionDetectorAllocatorTemplate + : public CollisionDetectorAllocatorTemplate { public: - static const std::string NAME; // defined in collision_world_hybrid.cpp + static const std::string NAME; // defined in collision_env_hybrid.cpp }; } - -#endif diff --git a/moveit_core/collision_distance_field/include/moveit/collision_distance_field/collision_distance_field_types.h b/moveit_core/collision_distance_field/include/moveit/collision_distance_field/collision_distance_field_types.h index 364386fb34..9816e4be1e 100644 --- a/moveit_core/collision_distance_field/include/moveit/collision_distance_field/collision_distance_field_types.h +++ b/moveit_core/collision_distance_field/include/moveit/collision_distance_field/collision_distance_field_types.h @@ -34,8 +34,7 @@ /* Author: E. Gil Jones */ -#ifndef MOVEIT_COLLISION_DISTANCE_FIELD_COLLISION_DISTANCE_FIELD_TYPES_ -#define MOVEIT_COLLISION_DISTANCE_FIELD_COLLISION_DISTANCE_FIELD_TYPES_ +#pragma once #include #include @@ -524,5 +523,3 @@ void getCollisionMarkers(const std::string& frame_id, const std::string& ns, con const std::vector& posed_vector_decompositions, const std::vector& gradients, visualization_msgs::MarkerArray& arr); } - -#endif diff --git a/moveit_core/collision_distance_field/include/moveit/collision_distance_field/collision_robot_distance_field.h b/moveit_core/collision_distance_field/include/moveit/collision_distance_field/collision_env_distance_field.h similarity index 57% rename from moveit_core/collision_distance_field/include/moveit/collision_distance_field/collision_robot_distance_field.h rename to moveit_core/collision_distance_field/include/moveit/collision_distance_field/collision_env_distance_field.h index 2c968dac76..93ec59597b 100644 --- a/moveit_core/collision_distance_field/include/moveit/collision_distance_field/collision_robot_distance_field.h +++ b/moveit_core/collision_distance_field/include/moveit/collision_distance_field/collision_env_distance_field.h @@ -34,13 +34,12 @@ /* Author: E. Gil Jones */ -#ifndef MOVEIT_COLLISION_DISTANCE_FIELD_COLLISION_ROBOT_DISTANCE_FIELD_ -#define MOVEIT_COLLISION_DISTANCE_FIELD_COLLISION_ROBOT_DISTANCE_FIELD_ +#pragma once #include -#include #include #include +#include #include #include @@ -54,32 +53,36 @@ static const double DEFAULT_RESOLUTION = .02; static const double DEFAULT_COLLISION_TOLERANCE = 0.0; static const double DEFAULT_MAX_PROPOGATION_DISTANCE = .25; -MOVEIT_CLASS_FORWARD(CollisionRobotDistanceField); +MOVEIT_CLASS_FORWARD(CollisionEnvDistanceField); -class CollisionRobotDistanceField : public CollisionRobot +class CollisionEnvDistanceField : public CollisionEnv { - friend class CollisionWorldDistanceField; - public: EIGEN_MAKE_ALIGNED_OPERATOR_NEW - CollisionRobotDistanceField(const robot_model::RobotModelConstPtr& robot_model); - - CollisionRobotDistanceField(const CollisionRobot& col_robot, const Eigen::Vector3d& size, - const Eigen::Vector3d& origin, bool use_signed_distance_field, double resolution, - double collision_tolerance, double max_propogation_distance, double padding); - - CollisionRobotDistanceField(const robot_model::RobotModelConstPtr& robot_model, - const std::map>& link_body_decompositions, - double size_x = DEFAULT_SIZE_X, double size_y = DEFAULT_SIZE_Y, - double size_z = DEFAULT_SIZE_Z, - bool use_signed_distance_field = DEFAULT_USE_SIGNED_DISTANCE_FIELD, - double resolution = DEFAULT_RESOLUTION, - double collision_tolerance = DEFAULT_COLLISION_TOLERANCE, - double max_propogation_distance = DEFAULT_MAX_PROPOGATION_DISTANCE, double padding = 0.0, - double scale = 1.0); - - CollisionRobotDistanceField(const CollisionRobotDistanceField& other); + CollisionEnvDistanceField(const robot_model::RobotModelConstPtr& robot_model, + const std::map>& link_body_decompositions = + std::map>(), + double size_x = DEFAULT_SIZE_X, double size_y = DEFAULT_SIZE_Y, + double size_z = DEFAULT_SIZE_Z, const Eigen::Vector3d& origin = Eigen::Vector3d(0, 0, 0), + bool use_signed_distance_field = DEFAULT_USE_SIGNED_DISTANCE_FIELD, + double resolution = DEFAULT_RESOLUTION, + double collision_tolerance = DEFAULT_COLLISION_TOLERANCE, + double max_propogation_distance = DEFAULT_MAX_PROPOGATION_DISTANCE, double padding = 0.0, + double scale = 1.0); + + CollisionEnvDistanceField(const robot_model::RobotModelConstPtr& robot_model, const WorldPtr& world, + const std::map>& link_body_decompositions = + std::map>(), + double size_x = DEFAULT_SIZE_X, double size_y = DEFAULT_SIZE_Y, + double size_z = DEFAULT_SIZE_Z, const Eigen::Vector3d& origin = Eigen::Vector3d(0, 0, 0), + bool use_signed_distance_field = DEFAULT_USE_SIGNED_DISTANCE_FIELD, + double resolution = DEFAULT_RESOLUTION, + double collision_tolerance = DEFAULT_COLLISION_TOLERANCE, + double max_propogation_distance = DEFAULT_MAX_PROPOGATION_DISTANCE, double padding = 0.0, + double scale = 1.0); + + CollisionEnvDistanceField(const CollisionEnvDistanceField& other, const WorldPtr& world); void initialize(const std::map>& link_body_decompositions, const Eigen::Vector3d& size, const Eigen::Vector3d& origin, bool use_signed_distance_field, @@ -99,51 +102,6 @@ class CollisionRobotDistanceField : public CollisionRobot const moveit::core::RobotState& state, const collision_detection::AllowedCollisionMatrix& acm, GroupStateRepresentationPtr& gsr) const; - void checkSelfCollision(const collision_detection::CollisionRequest& req, collision_detection::CollisionResult& res, - const moveit::core::RobotState& state1, const moveit::core::RobotState& state2) const override - { - ROS_ERROR_NAMED("collision_distance_field", "Not implemented"); - }; - - void checkSelfCollision(const collision_detection::CollisionRequest& req, collision_detection::CollisionResult& res, - const moveit::core::RobotState& state1, const moveit::core::RobotState& state2, - const collision_detection::AllowedCollisionMatrix& acm) const override - { - ROS_ERROR_NAMED("collision_distance_field", "Not implemented"); - }; - - void checkOtherCollision(const collision_detection::CollisionRequest& req, collision_detection::CollisionResult& res, - const moveit::core::RobotState& state, const CollisionRobot& other_robot, - const moveit::core::RobotState& other_state) const override - { - ROS_ERROR_NAMED("collision_distance_field", "Not implemented"); - }; - - void checkOtherCollision(const collision_detection::CollisionRequest& req, collision_detection::CollisionResult& res, - const moveit::core::RobotState& state, const CollisionRobot& other_robot, - const moveit::core::RobotState& other_state, - const collision_detection::AllowedCollisionMatrix& acm) const override - { - ROS_ERROR_NAMED("collision_distance_field", "Not implemented"); - }; - - void checkOtherCollision(const collision_detection::CollisionRequest& req, collision_detection::CollisionResult& res, - const moveit::core::RobotState& state1, const moveit::core::RobotState& state2, - const CollisionRobot& other_robot, const moveit::core::RobotState& other_state1, - const moveit::core::RobotState& other_state2) const override - { - ROS_ERROR_NAMED("collision_distance_field", "Not implemented"); - }; - - void checkOtherCollision(const collision_detection::CollisionRequest& req, collision_detection::CollisionResult& res, - const moveit::core::RobotState& state1, const moveit::core::RobotState& state2, - const CollisionRobot& other_robot, const moveit::core::RobotState& other_state1, - const moveit::core::RobotState& other_state2, - const collision_detection::AllowedCollisionMatrix& acm) const override - { - ROS_ERROR_NAMED("collision_distance_field", "Not implemented"); - }; - void createCollisionModelMarker(const moveit::core::RobotState& state, visualization_msgs::MarkerArray& model_markers) const; @@ -151,22 +109,12 @@ class CollisionRobotDistanceField : public CollisionRobot { return 0.0; }; + virtual double distanceSelf(const moveit::core::RobotState& state, const collision_detection::AllowedCollisionMatrix& acm) const { return 0.0; }; - virtual double distanceOther(const moveit::core::RobotState& state, const CollisionRobot& other_robot, - const moveit::core::RobotState& other_state) const - { - return 0.0; - }; - virtual double distanceOther(const moveit::core::RobotState& state, const CollisionRobot& other_robot, - const moveit::core::RobotState& other_state, - const collision_detection::AllowedCollisionMatrix& acm) const - { - return 0.0; - }; void distanceSelf(const DistanceRequest& req, DistanceResult& res, const robot_state::RobotState& state) const override @@ -174,12 +122,6 @@ class CollisionRobotDistanceField : public CollisionRobot ROS_ERROR_NAMED("collision_distance_field", "Not implemented"); } - void distanceOther(const DistanceRequest& req, DistanceResult& res, const robot_state::RobotState& state, - const CollisionRobot& other_robot, const robot_state::RobotState& other_state) const override - { - ROS_ERROR_NAMED("collision_distance_field", "Not implemented"); - } - DistanceFieldCacheEntryConstPtr getLastDistanceFieldEntry() const { return distance_field_cache_entry_; @@ -192,6 +134,84 @@ class CollisionRobotDistanceField : public CollisionRobot // const // collision_detection::AllowedCollisionMatrix // &acm) const; + + MOVEIT_STRUCT_FORWARD(DistanceFieldCacheEntryWorld) + struct DistanceFieldCacheEntryWorld + { + std::map> posed_body_point_decompositions_; + distance_field::DistanceFieldPtr distance_field_; + }; + + ~CollisionEnvDistanceField() override; + + void checkCollision(const CollisionRequest& req, CollisionResult& res, + const robot_state::RobotState& state) const override; + + virtual void checkCollision(const CollisionRequest& req, CollisionResult& res, const robot_state::RobotState& state, + GroupStateRepresentationPtr& gsr) const; + + void checkCollision(const CollisionRequest& req, CollisionResult& res, const robot_state::RobotState& state, + const AllowedCollisionMatrix& acm) const override; + + virtual void checkCollision(const CollisionRequest& req, CollisionResult& res, const robot_state::RobotState& state, + const AllowedCollisionMatrix& acm, GroupStateRepresentationPtr& gsr) const; + + void checkRobotCollision(const CollisionRequest& req, CollisionResult& res, + const robot_state::RobotState& state) const override; + + virtual void checkRobotCollision(const CollisionRequest& req, CollisionResult& res, + const robot_state::RobotState& state, GroupStateRepresentationPtr& gsr) const; + + void checkRobotCollision(const CollisionRequest& req, CollisionResult& res, const robot_state::RobotState& state, + const AllowedCollisionMatrix& acm) const override; + + virtual void checkRobotCollision(const CollisionRequest& req, CollisionResult& res, + const robot_state::RobotState& state, const AllowedCollisionMatrix& acm, + GroupStateRepresentationPtr& gsr) const; + + virtual void checkRobotCollision(const CollisionRequest& req, CollisionResult& res, + const robot_state::RobotState& state1, const robot_state::RobotState& state2, + const AllowedCollisionMatrix& acm) const override; + + virtual void checkRobotCollision(const CollisionRequest& req, CollisionResult& res, + const robot_state::RobotState& state1, + const robot_state::RobotState& state2) const override; + + virtual double distanceRobot(const robot_state::RobotState& state, bool verbose = false) const + { + return 0.0; + } + + virtual double distanceRobot(const robot_state::RobotState& state, const AllowedCollisionMatrix& acm, + bool verbose = false) const + { + return 0.0; + } + + void distanceRobot(const DistanceRequest& req, DistanceResult& res, + const robot_state::RobotState& state) const override + { + ROS_ERROR_NAMED("collision_distance_field", "Not implemented"); + } + + void setWorld(const WorldPtr& world) override; + + distance_field::DistanceFieldConstPtr getDistanceField() const + { + return distance_field_cache_entry_->distance_field_; + } + + collision_detection::GroupStateRepresentationConstPtr getLastGroupStateRepresentation() const + { + return last_gsr_; + } + + void getCollisionGradients(const CollisionRequest& req, CollisionResult& res, const robot_state::RobotState& state, + const AllowedCollisionMatrix* acm, GroupStateRepresentationPtr& gsr) const; + + void getAllCollisions(const CollisionRequest& req, CollisionResult& res, const robot_state::RobotState& state, + const AllowedCollisionMatrix* acm, GroupStateRepresentationPtr& gsr) const; + protected: bool getSelfProximityGradients(GroupStateRepresentationPtr& gsr) const; @@ -245,6 +265,20 @@ class CollisionRobotDistanceField : public CollisionRobot void updatedPaddingOrScaling(const std::vector& links) override{}; + DistanceFieldCacheEntryWorldPtr generateDistanceFieldCacheEntryWorld(); + + void updateDistanceObject(const std::string& id, CollisionEnvDistanceField::DistanceFieldCacheEntryWorldPtr& dfce, + EigenSTL::vector_Vector3d& add_points, EigenSTL::vector_Vector3d& subtract_points); + + bool getEnvironmentCollisions(const CollisionRequest& req, CollisionResult& res, + const distance_field::DistanceFieldConstPtr& env_distance_field, + GroupStateRepresentationPtr& gsr) const; + + bool getEnvironmentProximityGradients(const distance_field::DistanceFieldConstPtr& env_distance_field, + GroupStateRepresentationPtr& gsr) const; + + static void notifyObjectChange(CollisionEnvDistanceField* self, const ObjectConstPtr& obj, World::Action action); + Eigen::Vector3d size_; Eigen::Vector3d origin_; bool use_signed_distance_field_; @@ -261,7 +295,10 @@ class CollisionRobotDistanceField : public CollisionRobot std::map pregenerated_group_state_representation_map_; planning_scene::PlanningScenePtr planning_scene_; + + mutable boost::mutex update_cache_lock_world_; + DistanceFieldCacheEntryWorldPtr distance_field_cache_entry_world_; + GroupStateRepresentationPtr last_gsr_; + World::ObserverHandle observer_handle_; }; } - -#endif diff --git a/moveit_core/collision_distance_field/include/moveit/collision_distance_field/collision_env_hybrid.h b/moveit_core/collision_distance_field/include/moveit/collision_distance_field/collision_env_hybrid.h new file mode 100644 index 0000000000..6acf5da2ae --- /dev/null +++ b/moveit_core/collision_distance_field/include/moveit/collision_distance_field/collision_env_hybrid.h @@ -0,0 +1,153 @@ +/********************************************************************* + * Software License Agreement (BSD License) + * + * Copyright (c) 2012, Willow Garage, Inc. + * 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 and/or other materials provided + * with the distribution. + * * Neither the name of the Willow Garage nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * 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 OWNER 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. + *********************************************************************/ + +/* Author: E. Gil Jones, Jens Petit */ + +#pragma once + +#include +#include +#include +#include + +#include + +namespace collision_detection +{ +/** \brief This hybrid collision environment combines FCL and a distance field. Both can be used to calculate + * collisions. */ +class CollisionEnvHybrid : public collision_detection::CollisionEnvFCL +{ +public: + EIGEN_MAKE_ALIGNED_OPERATOR_NEW + + CollisionEnvHybrid(const robot_model::RobotModelConstPtr& robot_model, + const std::map>& link_body_decompositions = + std::map>(), + double size_x = DEFAULT_SIZE_X, double size_y = DEFAULT_SIZE_Y, double size_z = DEFAULT_SIZE_Z, + const Eigen::Vector3d& origin = Eigen::Vector3d(0, 0, 0), + bool use_signed_distance_field = DEFAULT_USE_SIGNED_DISTANCE_FIELD, + double resolution = DEFAULT_RESOLUTION, double collision_tolerance = DEFAULT_COLLISION_TOLERANCE, + double max_propogation_distance = DEFAULT_MAX_PROPOGATION_DISTANCE, double padding = 0.0, + double scale = 1.0); + + CollisionEnvHybrid(const robot_model::RobotModelConstPtr& robot_model, const WorldPtr& world, + const std::map>& link_body_decompositions = + std::map>(), + double size_x = DEFAULT_SIZE_X, double size_y = DEFAULT_SIZE_Y, double size_z = DEFAULT_SIZE_Z, + const Eigen::Vector3d& origin = Eigen::Vector3d(0, 0, 0), + bool use_signed_distance_field = DEFAULT_USE_SIGNED_DISTANCE_FIELD, + double resolution = DEFAULT_RESOLUTION, double collision_tolerance = DEFAULT_COLLISION_TOLERANCE, + double max_propogation_distance = DEFAULT_MAX_PROPOGATION_DISTANCE, double padding = 0.0, + double scale = 1.0); + + CollisionEnvHybrid(const CollisionEnvHybrid& other, const WorldPtr& world); + + ~CollisionEnvHybrid() override + { + } + + void initializeRobotDistanceField(const std::map>& link_body_decompositions, + double size_x, double size_y, double size_z, bool use_signed_distance_field, + double resolution, double collision_tolerance, double max_propogation_distance) + { + cenv_distance_->initialize(link_body_decompositions, Eigen::Vector3d(size_x, size_y, size_z), + Eigen::Vector3d(0, 0, 0), use_signed_distance_field, resolution, collision_tolerance, + max_propogation_distance); + } + + void checkSelfCollisionDistanceField(const collision_detection::CollisionRequest& req, + collision_detection::CollisionResult& res, + const robot_state::RobotState& state) const; + + void checkSelfCollisionDistanceField(const collision_detection::CollisionRequest& req, + collision_detection::CollisionResult& res, const robot_state::RobotState& state, + GroupStateRepresentationPtr& gsr) const; + + void checkSelfCollisionDistanceField(const collision_detection::CollisionRequest& req, + collision_detection::CollisionResult& res, const robot_state::RobotState& state, + const collision_detection::AllowedCollisionMatrix& acm) const; + + void checkSelfCollisionDistanceField(const collision_detection::CollisionRequest& req, + collision_detection::CollisionResult& res, const robot_state::RobotState& state, + const collision_detection::AllowedCollisionMatrix& acm, + GroupStateRepresentationPtr& gsr) const; + const CollisionEnvDistanceFieldConstPtr getCollisionRobotDistanceField() const + { + return cenv_distance_; + } + + void checkCollisionDistanceField(const CollisionRequest& req, CollisionResult& res, + const robot_state::RobotState& state) const; + + void checkCollisionDistanceField(const CollisionRequest& req, CollisionResult& res, + const robot_state::RobotState& state, GroupStateRepresentationPtr& gsr) const; + + void checkCollisionDistanceField(const CollisionRequest& req, CollisionResult& res, + const robot_state::RobotState& state, const AllowedCollisionMatrix& acm) const; + + void checkCollisionDistanceField(const CollisionRequest& req, CollisionResult& res, + const robot_state::RobotState& state, const AllowedCollisionMatrix& acm, + GroupStateRepresentationPtr& gsr) const; + + void checkRobotCollisionDistanceField(const CollisionRequest& req, CollisionResult& res, + const robot_state::RobotState& state) const; + + void checkRobotCollisionDistanceField(const CollisionRequest& req, CollisionResult& res, + const robot_state::RobotState& state, GroupStateRepresentationPtr& gsr) const; + + void checkRobotCollisionDistanceField(const CollisionRequest& req, CollisionResult& res, + const robot_state::RobotState& state, const AllowedCollisionMatrix& acm) const; + + void checkRobotCollisionDistanceField(const CollisionRequest& req, CollisionResult& res, + const robot_state::RobotState& state, const AllowedCollisionMatrix& acm, + GroupStateRepresentationPtr& gsr) const; + + void setWorld(const WorldPtr& world) override; + + void getCollisionGradients(const CollisionRequest& req, CollisionResult& res, const robot_state::RobotState& state, + const AllowedCollisionMatrix* acm, GroupStateRepresentationPtr& gsr) const; + + void getAllCollisions(const CollisionRequest& req, CollisionResult& res, const robot_state::RobotState& state, + const AllowedCollisionMatrix* acm, GroupStateRepresentationPtr& gsr) const; + + const CollisionEnvDistanceFieldConstPtr getCollisionWorldDistanceField() const + { + return cenv_distance_; + } + +protected: + CollisionEnvDistanceFieldPtr cenv_distance_; +}; +}; diff --git a/moveit_core/collision_distance_field/include/moveit/collision_distance_field/collision_robot_hybrid.h b/moveit_core/collision_distance_field/include/moveit/collision_distance_field/collision_robot_hybrid.h deleted file mode 100644 index 528fe3b226..0000000000 --- a/moveit_core/collision_distance_field/include/moveit/collision_distance_field/collision_robot_hybrid.h +++ /dev/null @@ -1,101 +0,0 @@ -/********************************************************************* - * Software License Agreement (BSD License) - * - * Copyright (c) 2012, Willow Garage, Inc. - * 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 and/or other materials provided - * with the distribution. - * * Neither the name of the Willow Garage nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 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 OWNER 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. - *********************************************************************/ - -/* Author: E. Gil Jones */ - -#ifndef MOVEIT_COLLISION_DISTANCE_FIELD_COLLISION_ROBOT_HYBRID_H_ -#define MOVEIT_COLLISION_DISTANCE_FIELD_COLLISION_ROBOT_HYBRID_H_ - -#include -#include -#include -#include - -#include - -namespace collision_detection -{ -class CollisionRobotHybrid : public collision_detection::CollisionRobotFCL -{ -public: - EIGEN_MAKE_ALIGNED_OPERATOR_NEW - - CollisionRobotHybrid(const robot_model::RobotModelConstPtr& robot_model); - - CollisionRobotHybrid(const robot_model::RobotModelConstPtr& robot_model, - const std::map>& link_body_decompositions, - double size_x = DEFAULT_SIZE_X, double size_y = DEFAULT_SIZE_Y, double size_z = DEFAULT_SIZE_Z, - bool use_signed_distance_field = DEFAULT_USE_SIGNED_DISTANCE_FIELD, - double resolution = DEFAULT_RESOLUTION, double collision_tolerance = DEFAULT_COLLISION_TOLERANCE, - double max_propogation_distance = DEFAULT_MAX_PROPOGATION_DISTANCE, double padding = 0.0, - double scale = 1.0); - - CollisionRobotHybrid(const CollisionRobotHybrid& other); - - void initializeRobotDistanceField(const std::map>& link_body_decompositions, - double size_x, double size_y, double size_z, bool use_signed_distance_field, - double resolution, double collision_tolerance, double max_propogation_distance) - { - crobot_distance_->initialize(link_body_decompositions, Eigen::Vector3d(size_x, size_y, size_z), - Eigen::Vector3d(0, 0, 0), use_signed_distance_field, resolution, collision_tolerance, - max_propogation_distance); - } - - void checkSelfCollisionDistanceField(const collision_detection::CollisionRequest& req, - collision_detection::CollisionResult& res, - const robot_state::RobotState& state) const; - - void checkSelfCollisionDistanceField(const collision_detection::CollisionRequest& req, - collision_detection::CollisionResult& res, const robot_state::RobotState& state, - GroupStateRepresentationPtr& gsr) const; - - void checkSelfCollisionDistanceField(const collision_detection::CollisionRequest& req, - collision_detection::CollisionResult& res, const robot_state::RobotState& state, - const collision_detection::AllowedCollisionMatrix& acm) const; - - void checkSelfCollisionDistanceField(const collision_detection::CollisionRequest& req, - collision_detection::CollisionResult& res, const robot_state::RobotState& state, - const collision_detection::AllowedCollisionMatrix& acm, - GroupStateRepresentationPtr& gsr) const; - const CollisionRobotDistanceFieldConstPtr getCollisionRobotDistanceField() const - { - return crobot_distance_; - } - -protected: - CollisionRobotDistanceFieldPtr crobot_distance_; -}; -} - -#endif diff --git a/moveit_core/collision_distance_field/include/moveit/collision_distance_field/collision_world_distance_field.h b/moveit_core/collision_distance_field/include/moveit/collision_distance_field/collision_world_distance_field.h deleted file mode 100644 index d2a5e950fb..0000000000 --- a/moveit_core/collision_distance_field/include/moveit/collision_distance_field/collision_world_distance_field.h +++ /dev/null @@ -1,203 +0,0 @@ -/********************************************************************* - * Software License Agreement (BSD License) - * - * Copyright (c) 2012, Willow Garage, Inc. - * 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 and/or other materials provided - * with the distribution. - * * Neither the name of the Willow Garage nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 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 OWNER 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. - *********************************************************************/ - -/* Author: E. Gil Jones */ - -#ifndef MOVEIT_COLLISION_DISTANCE_FIELD_COLLISION_WORLD_DISTANCE_FIELD_ -#define MOVEIT_COLLISION_DISTANCE_FIELD_COLLISION_WORLD_DISTANCE_FIELD_ - -#include -#include -#include -#include - -namespace collision_detection -{ -MOVEIT_CLASS_FORWARD(CollisionWorldDistanceField) - -class CollisionWorldDistanceField : public CollisionWorld -{ -public: - EIGEN_MAKE_ALIGNED_OPERATOR_NEW - - MOVEIT_STRUCT_FORWARD(DistanceFieldCacheEntry) - struct DistanceFieldCacheEntry - { - std::map> posed_body_point_decompositions_; - distance_field::DistanceFieldPtr distance_field_; - }; - - CollisionWorldDistanceField(Eigen::Vector3d size = Eigen::Vector3d(DEFAULT_SIZE_X, DEFAULT_SIZE_Y, DEFAULT_SIZE_Z), - Eigen::Vector3d origin = Eigen::Vector3d(0, 0, 0), - bool use_signed_distance_field = DEFAULT_USE_SIGNED_DISTANCE_FIELD, - double resolution = DEFAULT_RESOLUTION, - double collision_tolerance = DEFAULT_COLLISION_TOLERANCE, - double max_propogation_distance = DEFAULT_MAX_PROPOGATION_DISTANCE); - - explicit CollisionWorldDistanceField( - const WorldPtr& world, Eigen::Vector3d size = Eigen::Vector3d(DEFAULT_SIZE_X, DEFAULT_SIZE_Y, DEFAULT_SIZE_Z), - Eigen::Vector3d origin = Eigen::Vector3d(0, 0, 0), - bool use_signed_distance_field = DEFAULT_USE_SIGNED_DISTANCE_FIELD, double resolution = DEFAULT_RESOLUTION, - double collision_tolerance = DEFAULT_COLLISION_TOLERANCE, - double max_propogation_distance = DEFAULT_MAX_PROPOGATION_DISTANCE); - - CollisionWorldDistanceField(const CollisionWorldDistanceField& other, const WorldPtr& world); - - ~CollisionWorldDistanceField() override; - - void checkCollision(const CollisionRequest& req, CollisionResult& res, const CollisionRobot& robot, - const robot_state::RobotState& state) const override; - - virtual void checkCollision(const CollisionRequest& req, CollisionResult& res, const CollisionRobot& robot, - const robot_state::RobotState& state, GroupStateRepresentationPtr& gsr) const; - - void checkCollision(const CollisionRequest& req, CollisionResult& res, const CollisionRobot& robot, - const robot_state::RobotState& state, const AllowedCollisionMatrix& acm) const override; - - virtual void checkCollision(const CollisionRequest& req, CollisionResult& res, const CollisionRobot& robot, - const robot_state::RobotState& state, const AllowedCollisionMatrix& acm, - GroupStateRepresentationPtr& gsr) const; - - void checkRobotCollision(const CollisionRequest& req, CollisionResult& res, const CollisionRobot& robot, - const robot_state::RobotState& state) const override; - - virtual void checkRobotCollision(const CollisionRequest& req, CollisionResult& res, const CollisionRobot& robot, - const robot_state::RobotState& state, GroupStateRepresentationPtr& gsr) const; - - void checkRobotCollision(const CollisionRequest& req, CollisionResult& res, const CollisionRobot& robot, - const robot_state::RobotState& state, const AllowedCollisionMatrix& acm) const override; - - virtual void checkRobotCollision(const CollisionRequest& req, CollisionResult& res, const CollisionRobot& robot, - const robot_state::RobotState& state, const AllowedCollisionMatrix& acm, - GroupStateRepresentationPtr& gsr) const; - - void checkRobotCollision(const CollisionRequest& req, CollisionResult& res, const CollisionRobot& robot, - const robot_state::RobotState& state1, const robot_state::RobotState& state2) const override - { - } - void checkRobotCollision(const CollisionRequest& req, CollisionResult& res, const CollisionRobot& robot, - const robot_state::RobotState& state1, const robot_state::RobotState& state2, - const AllowedCollisionMatrix& acm) const override - { - } - void checkWorldCollision(const CollisionRequest& req, CollisionResult& res, - const CollisionWorld& other_world) const override - { - } - void checkWorldCollision(const CollisionRequest& req, CollisionResult& res, const CollisionWorld& other_world, - const AllowedCollisionMatrix& acm) const override - { - } - - virtual double distanceRobot(const CollisionRobot& robot, const robot_state::RobotState& state, - bool verbose = false) const - { - return 0.0; - } - virtual double distanceRobot(const CollisionRobot& robot, const robot_state::RobotState& state, - const AllowedCollisionMatrix& acm, bool verbose = false) const - { - return 0.0; - } - virtual double distanceWorld(const CollisionWorld& world, bool verbose = false) const - { - return 0.0; - } - virtual double distanceWorld(const CollisionWorld& world, const AllowedCollisionMatrix& acm, - bool verbose = false) const - { - return 0.0; - } - - void distanceRobot(const DistanceRequest& req, DistanceResult& res, const CollisionRobot& robot, - const robot_state::RobotState& state) const override - { - ROS_ERROR_NAMED("collision_distance_field", "Not implemented"); - } - - void distanceWorld(const DistanceRequest& req, DistanceResult& res, const CollisionWorld& world) const override - { - ROS_ERROR_NAMED("collision_distance_field", "Not implemented"); - } - - void setWorld(const WorldPtr& world) override; - - distance_field::DistanceFieldConstPtr getDistanceField() const - { - return distance_field_cache_entry_->distance_field_; - } - - collision_detection::GroupStateRepresentationConstPtr getLastGroupStateRepresentation() const - { - return last_gsr_; - } - - void getCollisionGradients(const CollisionRequest& req, CollisionResult& res, const CollisionRobot& robot, - const robot_state::RobotState& state, const AllowedCollisionMatrix* acm, - GroupStateRepresentationPtr& gsr) const; - - void getAllCollisions(const CollisionRequest& req, CollisionResult& res, const CollisionRobot& robot, - const robot_state::RobotState& state, const AllowedCollisionMatrix* acm, - GroupStateRepresentationPtr& gsr) const; - -protected: - DistanceFieldCacheEntryPtr generateDistanceFieldCacheEntry(); - - void updateDistanceObject(const std::string& id, CollisionWorldDistanceField::DistanceFieldCacheEntryPtr& dfce, - EigenSTL::vector_Vector3d& add_points, EigenSTL::vector_Vector3d& subtract_points); - - bool getEnvironmentCollisions(const CollisionRequest& req, CollisionResult& res, - const distance_field::DistanceFieldConstPtr& env_distance_field, - GroupStateRepresentationPtr& gsr) const; - - bool getEnvironmentProximityGradients(const distance_field::DistanceFieldConstPtr& env_distance_field, - GroupStateRepresentationPtr& gsr) const; - - static void notifyObjectChange(CollisionWorldDistanceField* self, const ObjectConstPtr& obj, World::Action action); - - Eigen::Vector3d size_; - Eigen::Vector3d origin_; - bool use_signed_distance_field_; - double resolution_; - double collision_tolerance_; - double max_propogation_distance_; - - mutable boost::mutex update_cache_lock_; - DistanceFieldCacheEntryPtr distance_field_cache_entry_; - GroupStateRepresentationPtr last_gsr_; - World::ObserverHandle observer_handle_; -}; -} - -#endif diff --git a/moveit_core/collision_distance_field/include/moveit/collision_distance_field/collision_world_hybrid.h b/moveit_core/collision_distance_field/include/moveit/collision_distance_field/collision_world_hybrid.h deleted file mode 100644 index 9b70e3c6dc..0000000000 --- a/moveit_core/collision_distance_field/include/moveit/collision_distance_field/collision_world_hybrid.h +++ /dev/null @@ -1,119 +0,0 @@ -/********************************************************************* - * Software License Agreement (BSD License) - * - * Copyright (c) 2012, Willow Garage, Inc. - * 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 and/or other materials provided - * with the distribution. - * * Neither the name of the Willow Garage nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 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 OWNER 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. - *********************************************************************/ - -/* Author: E. Gil Jones */ - -#ifndef MOVEIT_COLLISION_DISTANCE_FIELD_COLLISION_WORLD_HYBRID_H_ -#define MOVEIT_COLLISION_DISTANCE_FIELD_COLLISION_WORLD_HYBRID_H_ - -#include -#include -#include -#include - -namespace collision_detection -{ -class CollisionRobotHybrid; - -class CollisionWorldHybrid : public CollisionWorldFCL -{ -public: - EIGEN_MAKE_ALIGNED_OPERATOR_NEW - CollisionWorldHybrid(Eigen::Vector3d size = Eigen::Vector3d(DEFAULT_SIZE_X, DEFAULT_SIZE_Y, DEFAULT_SIZE_Z), - Eigen::Vector3d origin = Eigen::Vector3d(0, 0, 0), - bool use_signed_distance_field = DEFAULT_USE_SIGNED_DISTANCE_FIELD, - double resolution = DEFAULT_RESOLUTION, double collision_tolerance = DEFAULT_COLLISION_TOLERANCE, - double max_propogation_distance = DEFAULT_MAX_PROPOGATION_DISTANCE); - - explicit CollisionWorldHybrid(const WorldPtr& world, - Eigen::Vector3d size = Eigen::Vector3d(DEFAULT_SIZE_X, DEFAULT_SIZE_Y, DEFAULT_SIZE_Z), - Eigen::Vector3d origin = Eigen::Vector3d(0, 0, 0), - bool use_signed_distance_field = DEFAULT_USE_SIGNED_DISTANCE_FIELD, - double resolution = DEFAULT_RESOLUTION, - double collision_tolerance = DEFAULT_COLLISION_TOLERANCE, - double max_propogation_distance = DEFAULT_MAX_PROPOGATION_DISTANCE); - - CollisionWorldHybrid(const CollisionWorldHybrid& other, const WorldPtr& world); - - ~CollisionWorldHybrid() override - { - } - - void checkCollisionDistanceField(const CollisionRequest& req, CollisionResult& res, const CollisionRobot& robot, - const robot_state::RobotState& state) const; - - void checkCollisionDistanceField(const CollisionRequest& req, CollisionResult& res, const CollisionRobot& robot, - const robot_state::RobotState& state, GroupStateRepresentationPtr& gsr) const; - - void checkCollisionDistanceField(const CollisionRequest& req, CollisionResult& res, const CollisionRobot& robot, - const robot_state::RobotState& state, const AllowedCollisionMatrix& acm) const; - - void checkCollisionDistanceField(const CollisionRequest& req, CollisionResult& res, const CollisionRobot& robot, - const robot_state::RobotState& state, const AllowedCollisionMatrix& acm, - GroupStateRepresentationPtr& gsr) const; - - void checkRobotCollisionDistanceField(const CollisionRequest& req, CollisionResult& res, const CollisionRobot& robot, - const robot_state::RobotState& state) const; - - void checkRobotCollisionDistanceField(const CollisionRequest& req, CollisionResult& res, const CollisionRobot& robot, - const robot_state::RobotState& state, GroupStateRepresentationPtr& gsr) const; - - void checkRobotCollisionDistanceField(const CollisionRequest& req, CollisionResult& res, const CollisionRobot& robot, - const robot_state::RobotState& state, const AllowedCollisionMatrix& acm) const; - - void checkRobotCollisionDistanceField(const CollisionRequest& req, CollisionResult& res, const CollisionRobot& robot, - const robot_state::RobotState& state, const AllowedCollisionMatrix& acm, - GroupStateRepresentationPtr& gsr) const; - - void setWorld(const WorldPtr& world) override; - - void getCollisionGradients(const CollisionRequest& req, CollisionResult& res, const CollisionRobot& robot, - const robot_state::RobotState& state, const AllowedCollisionMatrix* acm, - GroupStateRepresentationPtr& gsr) const; - - void getAllCollisions(const CollisionRequest& req, CollisionResult& res, const CollisionRobot& robot, - const robot_state::RobotState& state, const AllowedCollisionMatrix* acm, - GroupStateRepresentationPtr& gsr) const; - - const CollisionWorldDistanceFieldConstPtr getCollisionWorldDistanceField() const - { - return cworld_distance_; - } - -protected: - CollisionWorldDistanceFieldPtr cworld_distance_; -}; -} - -#endif diff --git a/moveit_core/collision_distance_field/src/collision_robot_distance_field.cpp b/moveit_core/collision_distance_field/src/collision_env_distance_field.cpp similarity index 68% rename from moveit_core/collision_distance_field/src/collision_robot_distance_field.cpp rename to moveit_core/collision_distance_field/src/collision_env_distance_field.cpp index 85cf2246ee..6ddac01a3f 100644 --- a/moveit_core/collision_distance_field/src/collision_robot_distance_field.cpp +++ b/moveit_core/collision_distance_field/src/collision_env_distance_field.cpp @@ -35,54 +35,61 @@ /* Author: E. Gil Jones */ #include -#include -#include -#include #include #include #include +#include +#include +#include +#include +#include +#include +#include namespace collision_detection { const double EPSILON = 0.001f; -CollisionRobotDistanceField::CollisionRobotDistanceField(const robot_model::RobotModelConstPtr& robot_model) - : CollisionRobot(robot_model) +const std::string collision_detection::CollisionDetectorAllocatorDistanceField::NAME("DISTANCE_FIELD"); + +CollisionEnvDistanceField::CollisionEnvDistanceField( + const robot_model::RobotModelConstPtr& robot_model, + const std::map>& link_body_decompositions, double size_x, double size_y, + double size_z, const Eigen::Vector3d& origin, bool use_signed_distance_field, double resolution, + double collision_tolerance, double max_propogation_distance, double padding, double scale) + : CollisionEnv(robot_model) { - // planning_scene_.reset(new planning_scene::PlanningScene(robot_model_)); + initialize(link_body_decompositions, Eigen::Vector3d(size_x, size_y, size_z), origin, use_signed_distance_field, + resolution, collision_tolerance, max_propogation_distance); - std::map> link_body_decompositions; - Eigen::Vector3d size(DEFAULT_SIZE_X, DEFAULT_SIZE_Y, DEFAULT_SIZE_Z); - initialize(link_body_decompositions, size, Eigen::Vector3d(0, 0, 0), DEFAULT_USE_SIGNED_DISTANCE_FIELD, - DEFAULT_RESOLUTION, DEFAULT_COLLISION_TOLERANCE, DEFAULT_MAX_PROPOGATION_DISTANCE); setPadding(0.0); + + distance_field_cache_entry_world_ = generateDistanceFieldCacheEntryWorld(); + + // request notifications about changes to world + observer_handle_ = getWorld()->addObserver(boost::bind(&CollisionEnvDistanceField::notifyObjectChange, this, _1, _2)); } -CollisionRobotDistanceField::CollisionRobotDistanceField( - const robot_model::RobotModelConstPtr& robot_model, +CollisionEnvDistanceField::CollisionEnvDistanceField( + const robot_model::RobotModelConstPtr& robot_model, const WorldPtr& world, const std::map>& link_body_decompositions, double size_x, double size_y, - double size_z, bool use_signed_distance_field, double resolution, double collision_tolerance, - double max_propogation_distance, double padding, double scale) - : CollisionRobot(robot_model, padding, scale) + double size_z, const Eigen::Vector3d& origin, bool use_signed_distance_field, double resolution, + double collision_tolerance, double max_propogation_distance, double padding, double scale) + : CollisionEnv(robot_model, world, padding, scale) { - initialize(link_body_decompositions, Eigen::Vector3d(size_x, size_y, size_z), Eigen::Vector3d(0, 0, 0), - use_signed_distance_field, resolution, collision_tolerance, max_propogation_distance); -} + initialize(link_body_decompositions, Eigen::Vector3d(size_x, size_y, size_z), origin, use_signed_distance_field, + resolution, collision_tolerance, max_propogation_distance); -CollisionRobotDistanceField::CollisionRobotDistanceField(const CollisionRobot& col_robot, const Eigen::Vector3d& size, - const Eigen::Vector3d& origin, bool use_signed_distance_field, - double resolution, double collision_tolerance, - double max_propogation_distance, double padding) - : CollisionRobot(col_robot) -{ - std::map> link_body_decompositions; - initialize(link_body_decompositions, size, origin, use_signed_distance_field, resolution, collision_tolerance, - max_propogation_distance); - setPadding(padding); + distance_field_cache_entry_world_ = generateDistanceFieldCacheEntryWorld(); + + // request notifications about changes to world + observer_handle_ = getWorld()->addObserver(boost::bind(&CollisionEnvDistanceField::notifyObjectChange, this, _1, _2)); + + getWorld()->notifyObserverAllObjects(observer_handle_, World::CREATE); } -CollisionRobotDistanceField::CollisionRobotDistanceField(const CollisionRobotDistanceField& other) - : CollisionRobot(other) +CollisionEnvDistanceField::CollisionEnvDistanceField(const CollisionEnvDistanceField& other, const WorldPtr& world) + : CollisionEnv(other, world) { size_ = other.size_; origin_ = other.origin_; @@ -94,11 +101,21 @@ CollisionRobotDistanceField::CollisionRobotDistanceField(const CollisionRobotDis link_body_decomposition_vector_ = other.link_body_decomposition_vector_; link_body_decomposition_index_map_ = other.link_body_decomposition_index_map_; in_group_update_map_ = other.in_group_update_map_; + distance_field_cache_entry_world_ = generateDistanceFieldCacheEntryWorld(); pregenerated_group_state_representation_map_ = other.pregenerated_group_state_representation_map_; planning_scene_.reset(new planning_scene::PlanningScene(robot_model_)); + + // request notifications about changes to world + observer_handle_ = getWorld()->addObserver(boost::bind(&CollisionEnvDistanceField::notifyObjectChange, this, _1, _2)); + getWorld()->notifyObserverAllObjects(observer_handle_, World::CREATE); +} + +CollisionEnvDistanceField::~CollisionEnvDistanceField() +{ + getWorld()->removeObserver(observer_handle_); } -void CollisionRobotDistanceField::initialize( +void CollisionEnvDistanceField::initialize( const std::map>& link_body_decompositions, const Eigen::Vector3d& size, const Eigen::Vector3d& origin, bool use_signed_distance_field, double resolution, double collision_tolerance, double max_propogation_distance) @@ -130,7 +147,7 @@ void CollisionRobotDistanceField::initialize( } } -void CollisionRobotDistanceField::generateCollisionCheckingStructures( +void CollisionEnvDistanceField::generateCollisionCheckingStructures( const std::string& group_name, const moveit::core::RobotState& state, const collision_detection::AllowedCollisionMatrix* acm, GroupStateRepresentationPtr& gsr, bool generate_distance_field) const @@ -143,17 +160,17 @@ void CollisionRobotDistanceField::generateCollisionCheckingStructures( DistanceFieldCacheEntryPtr new_dfce = generateDistanceFieldCacheEntry(group_name, state, acm, generate_distance_field); boost::mutex::scoped_lock slock(update_cache_lock_); - (const_cast(this))->distance_field_cache_entry_ = new_dfce; + (const_cast(this))->distance_field_cache_entry_ = new_dfce; dfce = new_dfce; } getGroupStateRepresentation(dfce, state, gsr); } -void CollisionRobotDistanceField::checkSelfCollisionHelper(const collision_detection::CollisionRequest& req, - collision_detection::CollisionResult& res, - const moveit::core::RobotState& state, - const collision_detection::AllowedCollisionMatrix* acm, - GroupStateRepresentationPtr& gsr) const +void CollisionEnvDistanceField::checkSelfCollisionHelper(const collision_detection::CollisionRequest& req, + collision_detection::CollisionResult& res, + const moveit::core::RobotState& state, + const collision_detection::AllowedCollisionMatrix* acm, + GroupStateRepresentationPtr& gsr) const { if (!gsr) { @@ -174,9 +191,9 @@ void CollisionRobotDistanceField::checkSelfCollisionHelper(const collision_detec } DistanceFieldCacheEntryConstPtr -CollisionRobotDistanceField::getDistanceFieldCacheEntry(const std::string& group_name, - const moveit::core::RobotState& state, - const collision_detection::AllowedCollisionMatrix* acm) const +CollisionEnvDistanceField::getDistanceFieldCacheEntry(const std::string& group_name, + const moveit::core::RobotState& state, + const collision_detection::AllowedCollisionMatrix* acm) const { DistanceFieldCacheEntryConstPtr ret; if (!distance_field_cache_entry_) @@ -205,36 +222,36 @@ CollisionRobotDistanceField::getDistanceFieldCacheEntry(const std::string& group return cur; } -void CollisionRobotDistanceField::checkSelfCollision(const collision_detection::CollisionRequest& req, - collision_detection::CollisionResult& res, - const moveit::core::RobotState& state) const +void CollisionEnvDistanceField::checkSelfCollision(const collision_detection::CollisionRequest& req, + collision_detection::CollisionResult& res, + const moveit::core::RobotState& state) const { GroupStateRepresentationPtr gsr; checkSelfCollisionHelper(req, res, state, nullptr, gsr); } -void CollisionRobotDistanceField::checkSelfCollision(const collision_detection::CollisionRequest& req, - collision_detection::CollisionResult& res, - const moveit::core::RobotState& state, - GroupStateRepresentationPtr& gsr) const +void CollisionEnvDistanceField::checkSelfCollision(const collision_detection::CollisionRequest& req, + collision_detection::CollisionResult& res, + const moveit::core::RobotState& state, + GroupStateRepresentationPtr& gsr) const { checkSelfCollisionHelper(req, res, state, nullptr, gsr); } -void CollisionRobotDistanceField::checkSelfCollision(const collision_detection::CollisionRequest& req, - collision_detection::CollisionResult& res, - const moveit::core::RobotState& state, - const collision_detection::AllowedCollisionMatrix& acm) const +void CollisionEnvDistanceField::checkSelfCollision(const collision_detection::CollisionRequest& req, + collision_detection::CollisionResult& res, + const moveit::core::RobotState& state, + const collision_detection::AllowedCollisionMatrix& acm) const { GroupStateRepresentationPtr gsr; checkSelfCollisionHelper(req, res, state, &acm, gsr); } -void CollisionRobotDistanceField::checkSelfCollision(const collision_detection::CollisionRequest& req, - collision_detection::CollisionResult& res, - const moveit::core::RobotState& state, - const collision_detection::AllowedCollisionMatrix& acm, - GroupStateRepresentationPtr& gsr) const +void CollisionEnvDistanceField::checkSelfCollision(const collision_detection::CollisionRequest& req, + collision_detection::CollisionResult& res, + const moveit::core::RobotState& state, + const collision_detection::AllowedCollisionMatrix& acm, + GroupStateRepresentationPtr& gsr) const { if (gsr) { @@ -244,9 +261,9 @@ void CollisionRobotDistanceField::checkSelfCollision(const collision_detection:: checkSelfCollisionHelper(req, res, state, &acm, gsr); } -bool CollisionRobotDistanceField::getSelfCollisions(const collision_detection::CollisionRequest& req, - collision_detection::CollisionResult& res, - GroupStateRepresentationPtr& gsr) const +bool CollisionEnvDistanceField::getSelfCollisions(const collision_detection::CollisionRequest& req, + collision_detection::CollisionResult& res, + GroupStateRepresentationPtr& gsr) const { for (unsigned int i = 0; i < gsr->dfce_->link_names_.size() + gsr->dfce_->attached_body_names_.size(); i++) { @@ -324,7 +341,7 @@ bool CollisionRobotDistanceField::getSelfCollisions(const collision_detection::C return (res.contact_count >= req.max_contacts); } -bool CollisionRobotDistanceField::getSelfProximityGradients(GroupStateRepresentationPtr& gsr) const +bool CollisionEnvDistanceField::getSelfProximityGradients(GroupStateRepresentationPtr& gsr) const { bool in_collision = false; @@ -399,9 +416,9 @@ bool CollisionRobotDistanceField::getSelfProximityGradients(GroupStateRepresenta return in_collision; } -bool CollisionRobotDistanceField::getIntraGroupCollisions(const collision_detection::CollisionRequest& req, - collision_detection::CollisionResult& res, - GroupStateRepresentationPtr& gsr) const +bool CollisionEnvDistanceField::getIntraGroupCollisions(const collision_detection::CollisionRequest& req, + collision_detection::CollisionResult& res, + GroupStateRepresentationPtr& gsr) const { unsigned int num_links = gsr->dfce_->link_names_.size(); unsigned int num_attached_bodies = gsr->dfce_->attached_body_names_.size(); @@ -628,7 +645,7 @@ bool CollisionRobotDistanceField::getIntraGroupCollisions(const collision_detect return false; } -bool CollisionRobotDistanceField::getIntraGroupProximityGradients(GroupStateRepresentationPtr& gsr) const +bool CollisionEnvDistanceField::getIntraGroupProximityGradients(GroupStateRepresentationPtr& gsr) const { bool in_collision = false; unsigned int num_links = gsr->dfce_->link_names_.size(); @@ -694,7 +711,7 @@ bool CollisionRobotDistanceField::getIntraGroupProximityGradients(GroupStateRepr } return in_collision; } -DistanceFieldCacheEntryPtr CollisionRobotDistanceField::generateDistanceFieldCacheEntry( +DistanceFieldCacheEntryPtr CollisionEnvDistanceField::generateDistanceFieldCacheEntry( const std::string& group_name, const moveit::core::RobotState& state, const collision_detection::AllowedCollisionMatrix* acm, bool generate_distance_field) const { @@ -947,7 +964,7 @@ DistanceFieldCacheEntryPtr CollisionRobotDistanceField::generateDistanceFieldCac return dfce; } -void CollisionRobotDistanceField::addLinkBodyDecompositions(double resolution) +void CollisionEnvDistanceField::addLinkBodyDecompositions(double resolution) { const std::vector& link_models = robot_model_->getLinkModelsWithCollisionGeometry(); for (const moveit::core::LinkModel* link_model : link_models) @@ -967,8 +984,8 @@ void CollisionRobotDistanceField::addLinkBodyDecompositions(double resolution) } } -void CollisionRobotDistanceField::createCollisionModelMarker(const moveit::core::RobotState& state, - visualization_msgs::MarkerArray& model_markers) const +void CollisionEnvDistanceField::createCollisionModelMarker(const moveit::core::RobotState& state, + visualization_msgs::MarkerArray& model_markers) const { // creating colors std_msgs::ColorRGBA robot_color; @@ -1035,7 +1052,7 @@ void CollisionRobotDistanceField::createCollisionModelMarker(const moveit::core: } } -void CollisionRobotDistanceField::addLinkBodyDecompositions( +void CollisionEnvDistanceField::addLinkBodyDecompositions( double resolution, const std::map>& link_spheres) { ROS_ASSERT_MSG(robot_model_, "RobotModelPtr is invalid"); @@ -1065,7 +1082,7 @@ void CollisionRobotDistanceField::addLinkBodyDecompositions( ROS_DEBUG_STREAM(__FUNCTION__ << " Finished "); } -PosedBodySphereDecompositionPtr CollisionRobotDistanceField::getPosedLinkBodySphereDecomposition( +PosedBodySphereDecompositionPtr CollisionEnvDistanceField::getPosedLinkBodySphereDecomposition( const moveit::core::LinkModel* ls, unsigned int ind) const { PosedBodySphereDecompositionPtr ret; @@ -1074,7 +1091,7 @@ PosedBodySphereDecompositionPtr CollisionRobotDistanceField::getPosedLinkBodySph } PosedBodyPointDecompositionPtr -CollisionRobotDistanceField::getPosedLinkBodyPointDecomposition(const moveit::core::LinkModel* ls) const +CollisionEnvDistanceField::getPosedLinkBodyPointDecomposition(const moveit::core::LinkModel* ls) const { PosedBodyPointDecompositionPtr ret; std::map::const_iterator it = link_body_decomposition_index_map_.find(ls->getName()); @@ -1087,8 +1104,8 @@ CollisionRobotDistanceField::getPosedLinkBodyPointDecomposition(const moveit::co return ret; } -void CollisionRobotDistanceField::updateGroupStateRepresentationState(const moveit::core::RobotState& state, - GroupStateRepresentationPtr& gsr) const +void CollisionEnvDistanceField::updateGroupStateRepresentationState(const moveit::core::RobotState& state, + GroupStateRepresentationPtr& gsr) const { for (unsigned int i = 0; i < gsr->dfce_->link_names_.size(); i++) { @@ -1141,9 +1158,9 @@ void CollisionRobotDistanceField::updateGroupStateRepresentationState(const move } } -void CollisionRobotDistanceField::getGroupStateRepresentation(const DistanceFieldCacheEntryConstPtr& dfce, - const moveit::core::RobotState& state, - GroupStateRepresentationPtr& gsr) const +void CollisionEnvDistanceField::getGroupStateRepresentation(const DistanceFieldCacheEntryConstPtr& dfce, + const moveit::core::RobotState& state, + GroupStateRepresentationPtr& gsr) const { if (!dfce->pregenerated_group_state_representation_) { @@ -1239,8 +1256,8 @@ void CollisionRobotDistanceField::getGroupStateRepresentation(const DistanceFiel } } -bool CollisionRobotDistanceField::compareCacheEntryToState(const DistanceFieldCacheEntryConstPtr& dfce, - const moveit::core::RobotState& state) const +bool CollisionEnvDistanceField::compareCacheEntryToState(const DistanceFieldCacheEntryConstPtr& dfce, + const moveit::core::RobotState& state) const { std::vector new_state_values(state.getVariableCount()); for (unsigned int i = 0; i < new_state_values.size(); i++) @@ -1299,7 +1316,7 @@ bool CollisionRobotDistanceField::compareCacheEntryToState(const DistanceFieldCa return true; } -bool CollisionRobotDistanceField::compareCacheEntryToAllowedCollisionMatrix( +bool CollisionEnvDistanceField::compareCacheEntryToAllowedCollisionMatrix( const DistanceFieldCacheEntryConstPtr& dfce, const collision_detection::AllowedCollisionMatrix& acm) const { if (dfce->acm_.getSize() != acm.getSize()) @@ -1361,7 +1378,7 @@ bool CollisionRobotDistanceField::compareCacheEntryToAllowedCollisionMatrix( } // void -// CollisionRobotDistanceField::generateAllowedCollisionInformation(CollisionRobotDistanceField::DistanceFieldCacheEntryPtr& +// CollisionEnvDistanceField::generateAllowedCollisionInformation(CollisionEnvDistanceField::DistanceFieldCacheEntryPtr& // dfce) // { // for(unsigned int i = 0; i < dfce.link_names_.size(); i++) { @@ -1369,4 +1386,420 @@ bool CollisionRobotDistanceField::compareCacheEntryToAllowedCollisionMatrix( // if(dfce->acm.find // } // } + +void CollisionEnvDistanceField::checkCollision(const CollisionRequest& req, CollisionResult& res, + const robot_state::RobotState& state) const +{ + GroupStateRepresentationPtr gsr; + checkCollision(req, res, state, gsr); +} + +void CollisionEnvDistanceField::checkCollision(const CollisionRequest& req, CollisionResult& res, + const robot_state::RobotState& state, + GroupStateRepresentationPtr& gsr) const +{ + if (!gsr) + { + generateCollisionCheckingStructures(req.group_name, state, nullptr, gsr, true); + } + else + { + updateGroupStateRepresentationState(state, gsr); + } + bool done = getSelfCollisions(req, res, gsr); + if (!done) + { + done = getIntraGroupCollisions(req, res, gsr); + } + if (!done) + { + getEnvironmentCollisions(req, res, distance_field_cache_entry_world_->distance_field_, gsr); + } + + (const_cast(this))->last_gsr_ = gsr; +} + +void CollisionEnvDistanceField::checkCollision(const CollisionRequest& req, CollisionResult& res, + const robot_state::RobotState& state, + const AllowedCollisionMatrix& acm) const +{ + GroupStateRepresentationPtr gsr; + checkCollision(req, res, state, acm, gsr); +} + +void CollisionEnvDistanceField::checkCollision(const CollisionRequest& req, CollisionResult& res, + const robot_state::RobotState& state, const AllowedCollisionMatrix& acm, + GroupStateRepresentationPtr& gsr) const +{ + if (!gsr) + { + generateCollisionCheckingStructures(req.group_name, state, &acm, gsr, true); + } + else + { + updateGroupStateRepresentationState(state, gsr); + } + bool done = getSelfCollisions(req, res, gsr); + if (!done) + { + done = getIntraGroupCollisions(req, res, gsr); + } + if (!done) + { + getEnvironmentCollisions(req, res, distance_field_cache_entry_world_->distance_field_, gsr); + } + + (const_cast(this))->last_gsr_ = gsr; +} + +void CollisionEnvDistanceField::checkRobotCollision(const CollisionRequest& req, CollisionResult& res, + const robot_state::RobotState& state) const +{ + GroupStateRepresentationPtr gsr; + checkRobotCollision(req, res, state, gsr); +} + +void CollisionEnvDistanceField::checkRobotCollision(const CollisionRequest& req, CollisionResult& res, + const robot_state::RobotState& state, + GroupStateRepresentationPtr& gsr) const +{ + distance_field::DistanceFieldConstPtr env_distance_field = distance_field_cache_entry_world_->distance_field_; + if (!gsr) + { + generateCollisionCheckingStructures(req.group_name, state, nullptr, gsr, false); + } + else + { + updateGroupStateRepresentationState(state, gsr); + } + getEnvironmentCollisions(req, res, env_distance_field, gsr); + (const_cast(this))->last_gsr_ = gsr; + + // checkRobotCollisionHelper(req, res, robot, state, &acm); +} + +void CollisionEnvDistanceField::checkRobotCollision(const CollisionRequest& req, CollisionResult& res, + const robot_state::RobotState& state, + const AllowedCollisionMatrix& acm) const +{ + GroupStateRepresentationPtr gsr; + checkRobotCollision(req, res, state, acm, gsr); +} + +void CollisionEnvDistanceField::checkRobotCollision(const CollisionRequest& req, CollisionResult& res, + const robot_state::RobotState& state, + const AllowedCollisionMatrix& acm, + GroupStateRepresentationPtr& gsr) const +{ + distance_field::DistanceFieldConstPtr env_distance_field = distance_field_cache_entry_world_->distance_field_; + + if (!gsr) + { + generateCollisionCheckingStructures(req.group_name, state, &acm, gsr, true); + } + else + { + updateGroupStateRepresentationState(state, gsr); + } + getEnvironmentCollisions(req, res, env_distance_field, gsr); + (const_cast(this))->last_gsr_ = gsr; + + // checkRobotCollisionHelper(req, res, robot, state, &acm); +} + +void CollisionEnvDistanceField::checkRobotCollision(const CollisionRequest& req, CollisionResult& res, + const robot_state::RobotState& state1, + const robot_state::RobotState& state2, + const AllowedCollisionMatrix& acm) const +{ + ROS_ERROR_NAMED("collision_detection.distance", "Continuous collision checking not implemented"); +} + +void CollisionEnvDistanceField::checkRobotCollision(const CollisionRequest& req, CollisionResult& res, + const robot_state::RobotState& state1, + const robot_state::RobotState& state2) const +{ + ROS_ERROR_NAMED("collision_detection.distance", "Continuous collision checking not implemented"); +} + +void CollisionEnvDistanceField::getCollisionGradients(const CollisionRequest& req, CollisionResult& res, + const robot_state::RobotState& state, + const AllowedCollisionMatrix* acm, + GroupStateRepresentationPtr& gsr) const +{ + distance_field::DistanceFieldConstPtr env_distance_field = distance_field_cache_entry_world_->distance_field_; + + if (!gsr) + { + generateCollisionCheckingStructures(req.group_name, state, acm, gsr, true); + } + else + { + updateGroupStateRepresentationState(state, gsr); + } + + getSelfProximityGradients(gsr); + getIntraGroupProximityGradients(gsr); + getEnvironmentProximityGradients(env_distance_field, gsr); + + (const_cast(this))->last_gsr_ = gsr; +} + +void CollisionEnvDistanceField::getAllCollisions(const CollisionRequest& req, CollisionResult& res, + const robot_state::RobotState& state, + const AllowedCollisionMatrix* acm, + GroupStateRepresentationPtr& gsr) const +{ + if (!gsr) + { + generateCollisionCheckingStructures(req.group_name, state, acm, gsr, true); + } + else + { + updateGroupStateRepresentationState(state, gsr); + } + getSelfCollisions(req, res, gsr); + getIntraGroupCollisions(req, res, gsr); + distance_field::DistanceFieldConstPtr env_distance_field = distance_field_cache_entry_world_->distance_field_; + getEnvironmentCollisions(req, res, env_distance_field, gsr); + + (const_cast(this))->last_gsr_ = gsr; +} + +bool CollisionEnvDistanceField::getEnvironmentCollisions( + const CollisionRequest& req, CollisionResult& res, const distance_field::DistanceFieldConstPtr& env_distance_field, + GroupStateRepresentationPtr& gsr) const +{ + for (unsigned int i = 0; i < gsr->dfce_->link_names_.size() + gsr->dfce_->attached_body_names_.size(); i++) + { + bool is_link = i < gsr->dfce_->link_names_.size(); + std::string link_name = i < gsr->dfce_->link_names_.size() ? gsr->dfce_->link_names_[i] : "attached"; + if (is_link && !gsr->dfce_->link_has_geometry_[i]) + { + continue; + } + + const std::vector* collision_spheres_1; + const EigenSTL::vector_Vector3d* sphere_centers_1; + + if (is_link) + { + collision_spheres_1 = &(gsr->link_body_decompositions_[i]->getCollisionSpheres()); + sphere_centers_1 = &(gsr->link_body_decompositions_[i]->getSphereCenters()); + } + else + { + collision_spheres_1 = + &(gsr->attached_body_decompositions_[i - gsr->dfce_->link_names_.size()]->getCollisionSpheres()); + sphere_centers_1 = &(gsr->attached_body_decompositions_[i - gsr->dfce_->link_names_.size()]->getSphereCenters()); + } + + if (req.contacts) + { + std::vector colls; + bool coll = getCollisionSphereCollision( + env_distance_field.get(), *collision_spheres_1, *sphere_centers_1, max_propogation_distance_, + collision_tolerance_, std::min(req.max_contacts_per_pair, req.max_contacts - res.contact_count), colls); + if (coll) + { + res.collision = true; + for (unsigned int col : colls) + { + Contact con; + if (is_link) + { + con.pos = gsr->link_body_decompositions_[i]->getSphereCenters()[col]; + con.body_type_1 = BodyTypes::ROBOT_LINK; + con.body_name_1 = gsr->dfce_->link_names_[i]; + } + else + { + con.pos = gsr->attached_body_decompositions_[i - gsr->dfce_->link_names_.size()]->getSphereCenters()[col]; + con.body_type_1 = BodyTypes::ROBOT_ATTACHED; + con.body_name_1 = gsr->dfce_->attached_body_names_[i - gsr->dfce_->link_names_.size()]; + } + + con.body_type_2 = BodyTypes::WORLD_OBJECT; + con.body_name_2 = "environment"; + res.contact_count++; + res.contacts[std::pair(con.body_name_1, con.body_name_2)].push_back(con); + gsr->gradients_[i].types[col] = ENVIRONMENT; + // ROS_DEBUG_STREAM("Link " << dfce->link_names_[i] << " sphere " << + // colls[j] << " in env collision"); + } + + gsr->gradients_[i].collision = true; + if (res.contact_count >= req.max_contacts) + { + return true; + } + } + } + else + { + bool coll = getCollisionSphereCollision(env_distance_field.get(), *collision_spheres_1, *sphere_centers_1, + max_propogation_distance_, collision_tolerance_); + if (coll) + { + res.collision = true; + return true; + } + } + } + return (res.contact_count >= req.max_contacts); +} + +bool CollisionEnvDistanceField::getEnvironmentProximityGradients( + const distance_field::DistanceFieldConstPtr& env_distance_field, GroupStateRepresentationPtr& gsr) const +{ + bool in_collision = false; + for (unsigned int i = 0; i < gsr->dfce_->link_names_.size(); i++) + { + bool is_link = i < gsr->dfce_->link_names_.size(); + + if (is_link && !gsr->dfce_->link_has_geometry_[i]) + { + continue; + } + + const std::vector* collision_spheres_1; + const EigenSTL::vector_Vector3d* sphere_centers_1; + if (is_link) + { + collision_spheres_1 = &(gsr->link_body_decompositions_[i]->getCollisionSpheres()); + sphere_centers_1 = &(gsr->link_body_decompositions_[i]->getSphereCenters()); + } + else + { + collision_spheres_1 = + &(gsr->attached_body_decompositions_[i - gsr->dfce_->link_names_.size()]->getCollisionSpheres()); + sphere_centers_1 = &(gsr->attached_body_decompositions_[i - gsr->dfce_->link_names_.size()]->getSphereCenters()); + } + + bool coll = getCollisionSphereGradients(env_distance_field.get(), *collision_spheres_1, *sphere_centers_1, + gsr->gradients_[i], ENVIRONMENT, collision_tolerance_, false, + max_propogation_distance_, false); + if (coll) + { + in_collision = true; + } + } + return in_collision; +} + +void CollisionEnvDistanceField::setWorld(const WorldPtr& world) +{ + if (world == getWorld()) + return; + + // turn off notifications about old world + getWorld()->removeObserver(observer_handle_); + + // clear out objects from old world + distance_field_cache_entry_world_->distance_field_->reset(); + + CollisionEnv::setWorld(world); + + // request notifications about changes to new world + observer_handle_ = getWorld()->addObserver(boost::bind(&CollisionEnvDistanceField::notifyObjectChange, this, _1, _2)); + + // get notifications any objects already in the new world + getWorld()->notifyObserverAllObjects(observer_handle_, World::CREATE); +} + +void CollisionEnvDistanceField::notifyObjectChange(CollisionEnvDistanceField* self, const ObjectConstPtr& obj, + World::Action action) +{ + ros::WallTime n = ros::WallTime::now(); + + EigenSTL::vector_Vector3d add_points; + EigenSTL::vector_Vector3d subtract_points; + self->updateDistanceObject(obj->id_, self->distance_field_cache_entry_world_, add_points, subtract_points); + + if (action == World::DESTROY) + { + self->distance_field_cache_entry_world_->distance_field_->removePointsFromField(subtract_points); + } + else if (action & (World::MOVE_SHAPE | World::REMOVE_SHAPE)) + { + self->distance_field_cache_entry_world_->distance_field_->removePointsFromField(subtract_points); + self->distance_field_cache_entry_world_->distance_field_->addPointsToField(add_points); + } + else + { + self->distance_field_cache_entry_world_->distance_field_->addPointsToField(add_points); + } + + ROS_DEBUG_NAMED("collision_distance_field", "Modifying object %s took %lf s", obj->id_.c_str(), + (ros::WallTime::now() - n).toSec()); +} + +void CollisionEnvDistanceField::updateDistanceObject(const std::string& id, DistanceFieldCacheEntryWorldPtr& dfce, + EigenSTL::vector_Vector3d& add_points, + EigenSTL::vector_Vector3d& subtract_points) +{ + std::map>::iterator cur_it = + dfce->posed_body_point_decompositions_.find(id); + if (cur_it != dfce->posed_body_point_decompositions_.end()) + { + for (collision_detection::PosedBodyPointDecompositionPtr& posed_body_point_decomposition : cur_it->second) + { + subtract_points.insert(subtract_points.end(), posed_body_point_decomposition->getCollisionPoints().begin(), + posed_body_point_decomposition->getCollisionPoints().end()); + } + } + + World::ObjectConstPtr object = getWorld()->getObject(id); + if (object) + { + ROS_DEBUG_STREAM("Updating/Adding Object '" << object->id_ << "' with " << object->shapes_.size() + << " shapes to CollisionEnvDistanceField"); + std::vector shape_points; + for (unsigned int i = 0; i < object->shapes_.size(); i++) + { + shapes::ShapeConstPtr shape = object->shapes_[i]; + if (shape->type == shapes::OCTREE) + { + const shapes::OcTree* octree_shape = static_cast(shape.get()); + std::shared_ptr octree = octree_shape->octree; + + shape_points.push_back(std::make_shared(octree)); + } + else + { + BodyDecompositionConstPtr bd = getBodyDecompositionCacheEntry(shape, resolution_); + + shape_points.push_back(std::make_shared(bd, object->shape_poses_[i])); + } + + add_points.insert(add_points.end(), shape_points.back()->getCollisionPoints().begin(), + shape_points.back()->getCollisionPoints().end()); + } + + dfce->posed_body_point_decompositions_[id] = shape_points; + } + else + { + ROS_DEBUG_STREAM("Removing Object '" << id << "' from CollisionEnvDistanceField"); + dfce->posed_body_point_decompositions_.erase(id); + } +} + +CollisionEnvDistanceField::DistanceFieldCacheEntryWorldPtr +CollisionEnvDistanceField::generateDistanceFieldCacheEntryWorld() +{ + DistanceFieldCacheEntryWorldPtr dfce(new DistanceFieldCacheEntryWorld()); + dfce->distance_field_.reset(new distance_field::PropagationDistanceField( + size_.x(), size_.y(), size_.z(), resolution_, origin_.x() - 0.5 * size_.x(), origin_.y() - 0.5 * size_.y(), + origin_.z() - 0.5 * size_.z(), max_propogation_distance_, use_signed_distance_field_)); + + EigenSTL::vector_Vector3d add_points; + EigenSTL::vector_Vector3d subtract_points; + for (const std::pair& object : *getWorld()) + { + updateDistanceObject(object.first, dfce, add_points, subtract_points); + } + dfce->distance_field_->addPointsToField(add_points); + return dfce; +} } // namespace collision_detection diff --git a/moveit_core/collision_distance_field/src/collision_env_hybrid.cpp b/moveit_core/collision_distance_field/src/collision_env_hybrid.cpp new file mode 100644 index 0000000000..7a367c012f --- /dev/null +++ b/moveit_core/collision_distance_field/src/collision_env_hybrid.cpp @@ -0,0 +1,185 @@ +/********************************************************************* + * Software License Agreement (BSD License) + * + * Copyright (c) 2012, Willow Garage, Inc. + * 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 and/or other materials provided + * with the distribution. + * * Neither the name of the Willow Garage nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * 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 OWNER 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. + *********************************************************************/ + +/* Author: E. Gil Jones, Jens Petit */ + +#include +#include +#include + +namespace collision_detection +{ +const std::string collision_detection::CollisionDetectorAllocatorHybrid::NAME("HYBRID"); + +CollisionEnvHybrid::CollisionEnvHybrid( + const robot_model::RobotModelConstPtr& robot_model, + const std::map>& link_body_decompositions, double size_x, double size_y, + double size_z, const Eigen::Vector3d& origin, bool use_signed_distance_field, double resolution, + double collision_tolerance, double max_propogation_distance, double padding, double scale) + : CollisionEnvFCL(robot_model) + , cenv_distance_(new collision_detection::CollisionEnvDistanceField( + robot_model, getWorld(), link_body_decompositions, size_x, size_y, size_z, origin, use_signed_distance_field, + resolution, collision_tolerance, max_propogation_distance, padding, scale)) +{ +} + +CollisionEnvHybrid::CollisionEnvHybrid( + const robot_model::RobotModelConstPtr& robot_model, const WorldPtr& world, + const std::map>& link_body_decompositions, double size_x, double size_y, + double size_z, const Eigen::Vector3d& origin, bool use_signed_distance_field, double resolution, + double collision_tolerance, double max_propogation_distance, double padding, double scale) + : CollisionEnvFCL(robot_model, world, padding, scale) + , cenv_distance_(new collision_detection::CollisionEnvDistanceField( + robot_model, getWorld(), link_body_decompositions, size_x, size_y, size_z, origin, use_signed_distance_field, + resolution, collision_tolerance, max_propogation_distance, padding, scale)) +{ +} + +CollisionEnvHybrid::CollisionEnvHybrid(const CollisionEnvHybrid& other, const WorldPtr& world) + : CollisionEnvFCL(other, world) + , cenv_distance_(new collision_detection::CollisionEnvDistanceField(*other.getCollisionWorldDistanceField(), world)) +{ +} + +void CollisionEnvHybrid::checkSelfCollisionDistanceField(const collision_detection::CollisionRequest& req, + collision_detection::CollisionResult& res, + const robot_state::RobotState& state) const +{ + cenv_distance_->checkSelfCollision(req, res, state); +} + +void CollisionEnvHybrid::checkSelfCollisionDistanceField(const collision_detection::CollisionRequest& req, + collision_detection::CollisionResult& res, + const robot_state::RobotState& state, + GroupStateRepresentationPtr& gsr) const +{ + cenv_distance_->checkSelfCollision(req, res, state, gsr); +} + +void CollisionEnvHybrid::checkSelfCollisionDistanceField(const collision_detection::CollisionRequest& req, + collision_detection::CollisionResult& res, + const robot_state::RobotState& state, + const collision_detection::AllowedCollisionMatrix& acm) const +{ + cenv_distance_->checkSelfCollision(req, res, state, acm); +} + +void CollisionEnvHybrid::checkSelfCollisionDistanceField(const collision_detection::CollisionRequest& req, + collision_detection::CollisionResult& res, + const robot_state::RobotState& state, + const collision_detection::AllowedCollisionMatrix& acm, + GroupStateRepresentationPtr& gsr) const +{ + cenv_distance_->checkSelfCollision(req, res, state, acm, gsr); +} + +void CollisionEnvHybrid::checkCollisionDistanceField(const CollisionRequest& req, CollisionResult& res, + const robot_state::RobotState& state) const +{ + cenv_distance_->checkCollision(req, res, state); +} + +void CollisionEnvHybrid::checkCollisionDistanceField(const CollisionRequest& req, CollisionResult& res, + const robot_state::RobotState& state, + GroupStateRepresentationPtr& gsr) const +{ + cenv_distance_->checkCollision(req, res, state, gsr); +} + +void CollisionEnvHybrid::checkCollisionDistanceField(const CollisionRequest& req, CollisionResult& res, + const robot_state::RobotState& state, + const AllowedCollisionMatrix& acm) const +{ + cenv_distance_->checkCollision(req, res, state, acm); +} + +void CollisionEnvHybrid::checkCollisionDistanceField(const CollisionRequest& req, CollisionResult& res, + const robot_state::RobotState& state, + const AllowedCollisionMatrix& acm, + GroupStateRepresentationPtr& gsr) const +{ + cenv_distance_->checkCollision(req, res, state, acm, gsr); +} + +void CollisionEnvHybrid::checkRobotCollisionDistanceField(const CollisionRequest& req, CollisionResult& res, + const robot_state::RobotState& state) const +{ + cenv_distance_->checkRobotCollision(req, res, state); +} + +void CollisionEnvHybrid::checkRobotCollisionDistanceField(const CollisionRequest& req, CollisionResult& res, + const robot_state::RobotState& state, + GroupStateRepresentationPtr& gsr) const +{ + cenv_distance_->checkRobotCollision(req, res, state, gsr); +} + +void CollisionEnvHybrid::checkRobotCollisionDistanceField(const CollisionRequest& req, CollisionResult& res, + const robot_state::RobotState& state, + const AllowedCollisionMatrix& acm) const +{ + cenv_distance_->checkRobotCollision(req, res, state, acm); +} + +void CollisionEnvHybrid::checkRobotCollisionDistanceField(const CollisionRequest& req, CollisionResult& res, + const robot_state::RobotState& state, + const AllowedCollisionMatrix& acm, + GroupStateRepresentationPtr& gsr) const +{ + cenv_distance_->checkRobotCollision(req, res, state, acm, gsr); +} + +void CollisionEnvHybrid::setWorld(const WorldPtr& world) +{ + if (world == getWorld()) + return; + + cenv_distance_->setWorld(world); + CollisionEnvFCL::setWorld(world); +} + +void CollisionEnvHybrid::getCollisionGradients(const CollisionRequest& req, CollisionResult& res, + const robot_state::RobotState& state, const AllowedCollisionMatrix* acm, + GroupStateRepresentationPtr& gsr) const +{ + cenv_distance_->getCollisionGradients(req, res, state, acm, gsr); +} + +void CollisionEnvHybrid::getAllCollisions(const CollisionRequest& req, CollisionResult& res, + const robot_state::RobotState& state, const AllowedCollisionMatrix* acm, + GroupStateRepresentationPtr& gsr) const +{ + cenv_distance_->getAllCollisions(req, res, state, acm, gsr); +} +} // namespace collision_detection diff --git a/moveit_core/collision_distance_field/src/collision_robot_hybrid.cpp b/moveit_core/collision_distance_field/src/collision_robot_hybrid.cpp deleted file mode 100644 index 45f35aea88..0000000000 --- a/moveit_core/collision_distance_field/src/collision_robot_hybrid.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/********************************************************************* - * Software License Agreement (BSD License) - * - * Copyright (c) 2012, Willow Garage, Inc. - * 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 and/or other materials provided - * with the distribution. - * * Neither the name of the Willow Garage nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 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 OWNER 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. - *********************************************************************/ - -/* Author: E. Gil Jones */ - -#include - -namespace collision_detection -{ -CollisionRobotHybrid::CollisionRobotHybrid(const robot_model::RobotModelConstPtr& robot_model) - : CollisionRobotFCL(robot_model) -{ - crobot_distance_.reset(new collision_detection::CollisionRobotDistanceField(robot_model)); -} - -CollisionRobotHybrid::CollisionRobotHybrid( - const robot_model::RobotModelConstPtr& robot_model, - const std::map>& link_body_decompositions, double size_x, double size_y, - double size_z, bool use_signed_distance_field, double resolution, double collision_tolerance, - double max_propogation_distance, double padding, double scale) - : CollisionRobotFCL(robot_model) -{ - crobot_distance_.reset(new collision_detection::CollisionRobotDistanceField( - robot_model, link_body_decompositions, size_x, size_y, size_z, use_signed_distance_field, resolution, - collision_tolerance, max_propogation_distance, padding, scale)); -} - -CollisionRobotHybrid::CollisionRobotHybrid(const CollisionRobotHybrid& other) : CollisionRobotFCL(other) -{ - crobot_distance_.reset( - new collision_detection::CollisionRobotDistanceField(*other.getCollisionRobotDistanceField().get())); -} - -void CollisionRobotHybrid::checkSelfCollisionDistanceField(const collision_detection::CollisionRequest& req, - collision_detection::CollisionResult& res, - const robot_state::RobotState& state) const -{ - crobot_distance_->checkSelfCollision(req, res, state); -} - -void CollisionRobotHybrid::checkSelfCollisionDistanceField(const collision_detection::CollisionRequest& req, - collision_detection::CollisionResult& res, - const robot_state::RobotState& state, - GroupStateRepresentationPtr& gsr) const -{ - crobot_distance_->checkSelfCollision(req, res, state, gsr); -} - -void CollisionRobotHybrid::checkSelfCollisionDistanceField(const collision_detection::CollisionRequest& req, - collision_detection::CollisionResult& res, - const robot_state::RobotState& state, - const collision_detection::AllowedCollisionMatrix& acm) const -{ - crobot_distance_->checkSelfCollision(req, res, state, acm); -} - -void CollisionRobotHybrid::checkSelfCollisionDistanceField(const collision_detection::CollisionRequest& req, - collision_detection::CollisionResult& res, - const robot_state::RobotState& state, - const collision_detection::AllowedCollisionMatrix& acm, - GroupStateRepresentationPtr& gsr) const -{ - crobot_distance_->checkSelfCollision(req, res, state, acm, gsr); -} -} // namespace collision_detection diff --git a/moveit_core/collision_distance_field/src/collision_world_distance_field.cpp b/moveit_core/collision_distance_field/src/collision_world_distance_field.cpp deleted file mode 100644 index f9d0fb515b..0000000000 --- a/moveit_core/collision_distance_field/src/collision_world_distance_field.cpp +++ /dev/null @@ -1,568 +0,0 @@ -/********************************************************************* - * Software License Agreement (BSD License) - * - * Copyright (c) 2012, Willow Garage, Inc. - * 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 and/or other materials provided - * with the distribution. - * * Neither the name of the Willow Garage nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 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 OWNER 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. - *********************************************************************/ - -/* Author: E. Gil Jones */ - -#include -#include -#include -#include -#include -#include -#include - -namespace collision_detection -{ -CollisionWorldDistanceField::~CollisionWorldDistanceField() -{ - getWorld()->removeObserver(observer_handle_); -} - -CollisionWorldDistanceField::CollisionWorldDistanceField(Eigen::Vector3d size, Eigen::Vector3d origin, - bool use_signed_distance_field, double resolution, - double collision_tolerance, double max_propogation_distance) - : CollisionWorld() - , size_(std::move(size)) - , origin_(std::move(origin)) - , use_signed_distance_field_(use_signed_distance_field) - , resolution_(resolution) - , collision_tolerance_(collision_tolerance) - , max_propogation_distance_(max_propogation_distance) -{ - distance_field_cache_entry_ = generateDistanceFieldCacheEntry(); - - // request notifications about changes to world - observer_handle_ = - getWorld()->addObserver(boost::bind(&CollisionWorldDistanceField::notifyObjectChange, this, _1, _2)); -} - -CollisionWorldDistanceField::CollisionWorldDistanceField(const WorldPtr& world, Eigen::Vector3d size, - Eigen::Vector3d origin, bool use_signed_distance_field, - double resolution, double collision_tolerance, - double max_propogation_distance) - : CollisionWorld(world) - , size_(std::move(size)) - , origin_(std::move(origin)) - , use_signed_distance_field_(use_signed_distance_field) - , resolution_(resolution) - , collision_tolerance_(collision_tolerance) - , max_propogation_distance_(max_propogation_distance) -{ - distance_field_cache_entry_ = generateDistanceFieldCacheEntry(); - - // request notifications about changes to world - observer_handle_ = - getWorld()->addObserver(boost::bind(&CollisionWorldDistanceField::notifyObjectChange, this, _1, _2)); - getWorld()->notifyObserverAllObjects(observer_handle_, World::CREATE); -} - -CollisionWorldDistanceField::CollisionWorldDistanceField(const CollisionWorldDistanceField& other, - const WorldPtr& world) - : CollisionWorld(other, world) -{ - size_ = other.size_; - origin_ = other.origin_; - use_signed_distance_field_ = other.use_signed_distance_field_; - resolution_ = other.resolution_; - collision_tolerance_ = other.collision_tolerance_; - max_propogation_distance_ = other.max_propogation_distance_; - distance_field_cache_entry_ = generateDistanceFieldCacheEntry(); - - // request notifications about changes to world - observer_handle_ = - getWorld()->addObserver(boost::bind(&CollisionWorldDistanceField::notifyObjectChange, this, _1, _2)); - getWorld()->notifyObserverAllObjects(observer_handle_, World::CREATE); -} - -void CollisionWorldDistanceField::checkCollision(const CollisionRequest& req, CollisionResult& res, - const CollisionRobot& robot, - const robot_state::RobotState& state) const -{ - GroupStateRepresentationPtr gsr; - checkCollision(req, res, robot, state, gsr); -} - -void CollisionWorldDistanceField::checkCollision(const CollisionRequest& req, CollisionResult& res, - const CollisionRobot& robot, const robot_state::RobotState& state, - GroupStateRepresentationPtr& gsr) const -{ - try - { - const CollisionRobotDistanceField& cdr = dynamic_cast(robot); - if (!gsr) - { - cdr.generateCollisionCheckingStructures(req.group_name, state, nullptr, gsr, true); - } - else - { - cdr.updateGroupStateRepresentationState(state, gsr); - } - bool done = cdr.getSelfCollisions(req, res, gsr); - if (!done) - { - done = cdr.getIntraGroupCollisions(req, res, gsr); - } - if (!done) - { - getEnvironmentCollisions(req, res, distance_field_cache_entry_->distance_field_, gsr); - } - } - catch (const std::bad_cast& e) - { - ROS_ERROR_STREAM("Could not cast CollisionRobot to CollisionRobotDistanceField, " << e.what()); - return; - } - - (const_cast(this))->last_gsr_ = gsr; -} - -void CollisionWorldDistanceField::checkCollision(const CollisionRequest& req, CollisionResult& res, - const CollisionRobot& robot, const robot_state::RobotState& state, - const AllowedCollisionMatrix& acm) const -{ - GroupStateRepresentationPtr gsr; - checkCollision(req, res, robot, state, acm, gsr); -} - -void CollisionWorldDistanceField::checkCollision(const CollisionRequest& req, CollisionResult& res, - const CollisionRobot& robot, const robot_state::RobotState& state, - const AllowedCollisionMatrix& acm, - GroupStateRepresentationPtr& gsr) const -{ - try - { - const CollisionRobotDistanceField& cdr = dynamic_cast(robot); - if (!gsr) - { - cdr.generateCollisionCheckingStructures(req.group_name, state, &acm, gsr, true); - } - else - { - cdr.updateGroupStateRepresentationState(state, gsr); - } - bool done = cdr.getSelfCollisions(req, res, gsr); - if (!done) - { - done = cdr.getIntraGroupCollisions(req, res, gsr); - } - if (!done) - { - getEnvironmentCollisions(req, res, distance_field_cache_entry_->distance_field_, gsr); - } - } - catch (const std::bad_cast& e) - { - ROS_ERROR_STREAM("Could not cast CollisionRobot to CollisionRobotDistanceField, " << e.what()); - return; - } - - (const_cast(this))->last_gsr_ = gsr; -} - -void CollisionWorldDistanceField::checkRobotCollision(const CollisionRequest& req, CollisionResult& res, - const CollisionRobot& robot, - const robot_state::RobotState& state) const -{ - GroupStateRepresentationPtr gsr; - checkRobotCollision(req, res, robot, state, gsr); -} - -void CollisionWorldDistanceField::checkRobotCollision(const CollisionRequest& req, CollisionResult& res, - const CollisionRobot& robot, const robot_state::RobotState& state, - GroupStateRepresentationPtr& gsr) const -{ - distance_field::DistanceFieldConstPtr env_distance_field = distance_field_cache_entry_->distance_field_; - try - { - const CollisionRobotDistanceField& cdr = dynamic_cast(robot); - DistanceFieldCacheEntryConstPtr dfce; - if (!gsr) - { - cdr.generateCollisionCheckingStructures(req.group_name, state, nullptr, gsr, false); - } - else - { - cdr.updateGroupStateRepresentationState(state, gsr); - } - getEnvironmentCollisions(req, res, env_distance_field, gsr); - (const_cast(this))->last_gsr_ = gsr; - - // checkRobotCollisionHelper(req, res, robot, state, &acm); - } - catch (const std::bad_cast& e) - { - ROS_ERROR_STREAM("Could not cast CollisionRobot to CollisionRobotDistanceField, " << e.what()); - return; - } -} - -void CollisionWorldDistanceField::checkRobotCollision(const CollisionRequest& req, CollisionResult& res, - const CollisionRobot& robot, const robot_state::RobotState& state, - const AllowedCollisionMatrix& acm) const -{ - GroupStateRepresentationPtr gsr; - checkRobotCollision(req, res, robot, state, acm, gsr); -} - -void CollisionWorldDistanceField::checkRobotCollision(const CollisionRequest& req, CollisionResult& res, - const CollisionRobot& robot, const robot_state::RobotState& state, - const AllowedCollisionMatrix& acm, - GroupStateRepresentationPtr& gsr) const -{ - distance_field::DistanceFieldConstPtr env_distance_field = distance_field_cache_entry_->distance_field_; - try - { - const CollisionRobotDistanceField& cdr = dynamic_cast(robot); - DistanceFieldCacheEntryPtr dfce; - if (!gsr) - { - cdr.generateCollisionCheckingStructures(req.group_name, state, &acm, gsr, true); - } - else - { - cdr.updateGroupStateRepresentationState(state, gsr); - } - getEnvironmentCollisions(req, res, env_distance_field, gsr); - (const_cast(this))->last_gsr_ = gsr; - - // checkRobotCollisionHelper(req, res, robot, state, &acm); - } - catch (const std::bad_cast& e) - { - ROS_ERROR_STREAM("Could not cast CollisionRobot to CollisionRobotDistanceField, " << e.what()); - return; - } -} - -void CollisionWorldDistanceField::getCollisionGradients(const CollisionRequest& req, CollisionResult& res, - const CollisionRobot& robot, - const robot_state::RobotState& state, - const AllowedCollisionMatrix* acm, - GroupStateRepresentationPtr& gsr) const -{ - distance_field::DistanceFieldConstPtr env_distance_field = distance_field_cache_entry_->distance_field_; - try - { - const CollisionRobotDistanceField& cdr = dynamic_cast(robot); - if (!gsr) - { - cdr.generateCollisionCheckingStructures(req.group_name, state, acm, gsr, true); - } - else - { - cdr.updateGroupStateRepresentationState(state, gsr); - } - cdr.getSelfProximityGradients(gsr); - cdr.getIntraGroupProximityGradients(gsr); - getEnvironmentProximityGradients(env_distance_field, gsr); - } - catch (const std::bad_cast& e) - { - ROS_ERROR_STREAM("Could not cast CollisionRobot to CollisionRobotDistanceField, " << e.what()); - return; - } - - (const_cast(this))->last_gsr_ = gsr; -} - -void CollisionWorldDistanceField::getAllCollisions(const CollisionRequest& req, CollisionResult& res, - const CollisionRobot& robot, const robot_state::RobotState& state, - const AllowedCollisionMatrix* acm, - GroupStateRepresentationPtr& gsr) const -{ - try - { - const CollisionRobotDistanceField& cdr = dynamic_cast(robot); - if (!gsr) - { - cdr.generateCollisionCheckingStructures(req.group_name, state, acm, gsr, true); - } - else - { - cdr.updateGroupStateRepresentationState(state, gsr); - } - cdr.getSelfCollisions(req, res, gsr); - cdr.getIntraGroupCollisions(req, res, gsr); - distance_field::DistanceFieldConstPtr env_distance_field = distance_field_cache_entry_->distance_field_; - getEnvironmentCollisions(req, res, env_distance_field, gsr); - } - catch (const std::bad_cast& e) - { - ROS_ERROR_STREAM("Could not cast CollisionRobot to CollisionRobotDistanceField, " << e.what()); - return; - } - - (const_cast(this))->last_gsr_ = gsr; -} - -bool CollisionWorldDistanceField::getEnvironmentCollisions( - const CollisionRequest& req, CollisionResult& res, const distance_field::DistanceFieldConstPtr& env_distance_field, - GroupStateRepresentationPtr& gsr) const -{ - for (unsigned int i = 0; i < gsr->dfce_->link_names_.size() + gsr->dfce_->attached_body_names_.size(); i++) - { - bool is_link = i < gsr->dfce_->link_names_.size(); - std::string link_name = i < gsr->dfce_->link_names_.size() ? gsr->dfce_->link_names_[i] : "attached"; - if (is_link && !gsr->dfce_->link_has_geometry_[i]) - { - continue; - } - - const std::vector* collision_spheres_1; - const EigenSTL::vector_Vector3d* sphere_centers_1; - - if (is_link) - { - collision_spheres_1 = &(gsr->link_body_decompositions_[i]->getCollisionSpheres()); - sphere_centers_1 = &(gsr->link_body_decompositions_[i]->getSphereCenters()); - } - else - { - collision_spheres_1 = - &(gsr->attached_body_decompositions_[i - gsr->dfce_->link_names_.size()]->getCollisionSpheres()); - sphere_centers_1 = &(gsr->attached_body_decompositions_[i - gsr->dfce_->link_names_.size()]->getSphereCenters()); - } - - if (req.contacts) - { - std::vector colls; - bool coll = getCollisionSphereCollision( - env_distance_field.get(), *collision_spheres_1, *sphere_centers_1, max_propogation_distance_, - collision_tolerance_, std::min(req.max_contacts_per_pair, req.max_contacts - res.contact_count), colls); - if (coll) - { - res.collision = true; - for (unsigned int col : colls) - { - Contact con; - if (is_link) - { - con.pos = gsr->link_body_decompositions_[i]->getSphereCenters()[col]; - con.body_type_1 = BodyTypes::ROBOT_LINK; - con.body_name_1 = gsr->dfce_->link_names_[i]; - } - else - { - con.pos = gsr->attached_body_decompositions_[i - gsr->dfce_->link_names_.size()]->getSphereCenters()[col]; - con.body_type_1 = BodyTypes::ROBOT_ATTACHED; - con.body_name_1 = gsr->dfce_->attached_body_names_[i - gsr->dfce_->link_names_.size()]; - } - - con.body_type_2 = BodyTypes::WORLD_OBJECT; - con.body_name_2 = "environment"; - res.contact_count++; - res.contacts[std::pair(con.body_name_1, con.body_name_2)].push_back(con); - gsr->gradients_[i].types[col] = ENVIRONMENT; - // ROS_DEBUG_STREAM("Link " << dfce->link_names_[i] << " sphere " << - // colls[j] << " in env collision"); - } - - gsr->gradients_[i].collision = true; - if (res.contact_count >= req.max_contacts) - { - return true; - } - } - } - else - { - bool coll = getCollisionSphereCollision(env_distance_field.get(), *collision_spheres_1, *sphere_centers_1, - max_propogation_distance_, collision_tolerance_); - if (coll) - { - res.collision = true; - return true; - } - } - } - return (res.contact_count >= req.max_contacts); -} - -bool CollisionWorldDistanceField::getEnvironmentProximityGradients( - const distance_field::DistanceFieldConstPtr& env_distance_field, GroupStateRepresentationPtr& gsr) const -{ - bool in_collision = false; - for (unsigned int i = 0; i < gsr->dfce_->link_names_.size(); i++) - { - bool is_link = i < gsr->dfce_->link_names_.size(); - - if (is_link && !gsr->dfce_->link_has_geometry_[i]) - { - continue; - } - - const std::vector* collision_spheres_1; - const EigenSTL::vector_Vector3d* sphere_centers_1; - if (is_link) - { - collision_spheres_1 = &(gsr->link_body_decompositions_[i]->getCollisionSpheres()); - sphere_centers_1 = &(gsr->link_body_decompositions_[i]->getSphereCenters()); - } - else - { - collision_spheres_1 = - &(gsr->attached_body_decompositions_[i - gsr->dfce_->link_names_.size()]->getCollisionSpheres()); - sphere_centers_1 = &(gsr->attached_body_decompositions_[i - gsr->dfce_->link_names_.size()]->getSphereCenters()); - } - - bool coll = getCollisionSphereGradients(env_distance_field.get(), *collision_spheres_1, *sphere_centers_1, - gsr->gradients_[i], ENVIRONMENT, collision_tolerance_, false, - max_propogation_distance_, false); - if (coll) - { - in_collision = true; - } - } - return in_collision; -} - -void CollisionWorldDistanceField::setWorld(const WorldPtr& world) -{ - if (world == getWorld()) - return; - - // turn off notifications about old world - getWorld()->removeObserver(observer_handle_); - - // clear out objects from old world - distance_field_cache_entry_->distance_field_->reset(); - - CollisionWorld::setWorld(world); - - // request notifications about changes to new world - observer_handle_ = - getWorld()->addObserver(boost::bind(&CollisionWorldDistanceField::notifyObjectChange, this, _1, _2)); - - // get notifications any objects already in the new world - getWorld()->notifyObserverAllObjects(observer_handle_, World::CREATE); -} - -void CollisionWorldDistanceField::notifyObjectChange(CollisionWorldDistanceField* self, const ObjectConstPtr& obj, - World::Action action) -{ - ros::WallTime n = ros::WallTime::now(); - - EigenSTL::vector_Vector3d add_points; - EigenSTL::vector_Vector3d subtract_points; - self->updateDistanceObject(obj->id_, self->distance_field_cache_entry_, add_points, subtract_points); - - if (action == World::DESTROY) - { - self->distance_field_cache_entry_->distance_field_->removePointsFromField(subtract_points); - } - else if (action & (World::MOVE_SHAPE | World::REMOVE_SHAPE)) - { - self->distance_field_cache_entry_->distance_field_->removePointsFromField(subtract_points); - self->distance_field_cache_entry_->distance_field_->addPointsToField(add_points); - } - else - { - self->distance_field_cache_entry_->distance_field_->addPointsToField(add_points); - } - - ROS_DEBUG_NAMED("collision_distance_field", "Modifying object %s took %lf s", obj->id_.c_str(), - (ros::WallTime::now() - n).toSec()); -} - -void CollisionWorldDistanceField::updateDistanceObject(const std::string& id, DistanceFieldCacheEntryPtr& dfce, - EigenSTL::vector_Vector3d& add_points, - EigenSTL::vector_Vector3d& subtract_points) -{ - std::map>::iterator cur_it = - dfce->posed_body_point_decompositions_.find(id); - if (cur_it != dfce->posed_body_point_decompositions_.end()) - { - for (collision_detection::PosedBodyPointDecompositionPtr& posed_body_point_decomposition : cur_it->second) - { - subtract_points.insert(subtract_points.end(), posed_body_point_decomposition->getCollisionPoints().begin(), - posed_body_point_decomposition->getCollisionPoints().end()); - } - } - - World::ObjectConstPtr object = getWorld()->getObject(id); - if (object) - { - ROS_DEBUG_STREAM("Updating/Adding Object '" << object->id_ << "' with " << object->shapes_.size() - << " shapes to CollisionWorldDistanceField"); - std::vector shape_points; - for (unsigned int i = 0; i < object->shapes_.size(); i++) - { - shapes::ShapeConstPtr shape = object->shapes_[i]; - if (shape->type == shapes::OCTREE) - { - const shapes::OcTree* octree_shape = static_cast(shape.get()); - std::shared_ptr octree = octree_shape->octree; - - shape_points.push_back(std::make_shared(octree)); - } - else - { - BodyDecompositionConstPtr bd = getBodyDecompositionCacheEntry(shape, resolution_); - - shape_points.push_back(std::make_shared(bd, object->shape_poses_[i])); - } - - add_points.insert(add_points.end(), shape_points.back()->getCollisionPoints().begin(), - shape_points.back()->getCollisionPoints().end()); - } - - dfce->posed_body_point_decompositions_[id] = shape_points; - } - else - { - ROS_DEBUG_STREAM("Removing Object '" << id << "' from CollisionWorldDistanceField"); - dfce->posed_body_point_decompositions_.erase(id); - } -} - -CollisionWorldDistanceField::DistanceFieldCacheEntryPtr CollisionWorldDistanceField::generateDistanceFieldCacheEntry() -{ - DistanceFieldCacheEntryPtr dfce(new DistanceFieldCacheEntry()); - dfce->distance_field_.reset(new distance_field::PropagationDistanceField( - size_.x(), size_.y(), size_.z(), resolution_, origin_.x() - 0.5 * size_.x(), origin_.y() - 0.5 * size_.y(), - origin_.z() - 0.5 * size_.z(), max_propogation_distance_, use_signed_distance_field_)); - - EigenSTL::vector_Vector3d add_points; - EigenSTL::vector_Vector3d subtract_points; - for (const std::pair& object : *getWorld()) - { - updateDistanceObject(object.first, dfce, add_points, subtract_points); - } - dfce->distance_field_->addPointsToField(add_points); - return dfce; -} -} // namespace collision_detection - -#include -const std::string collision_detection::CollisionDetectorAllocatorDistanceField::NAME("DISTANCE_FIELD"); diff --git a/moveit_core/collision_distance_field/src/collision_world_hybrid.cpp b/moveit_core/collision_distance_field/src/collision_world_hybrid.cpp deleted file mode 100644 index 551937cd6a..0000000000 --- a/moveit_core/collision_distance_field/src/collision_world_hybrid.cpp +++ /dev/null @@ -1,160 +0,0 @@ -/********************************************************************* - * Software License Agreement (BSD License) - * - * Copyright (c) 2012, Willow Garage, Inc. - * 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 and/or other materials provided - * with the distribution. - * * Neither the name of the Willow Garage nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * 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 OWNER 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. - *********************************************************************/ - -/* Author: E. Gil Jones */ - -#include -#include - -namespace collision_detection -{ -CollisionWorldHybrid::CollisionWorldHybrid(Eigen::Vector3d size, Eigen::Vector3d origin, bool use_signed_distance_field, - double resolution, double collision_tolerance, - double max_propogation_distance) - : CollisionWorldFCL() - , cworld_distance_(new collision_detection::CollisionWorldDistanceField( - getWorld(), std::move(size), std::move(origin), use_signed_distance_field, resolution, collision_tolerance, - max_propogation_distance)) - -{ -} - -CollisionWorldHybrid::CollisionWorldHybrid(const WorldPtr& world, Eigen::Vector3d size, Eigen::Vector3d origin, - bool use_signed_distance_field, double resolution, - double collision_tolerance, double max_propogation_distance) - : CollisionWorldFCL(world) - , cworld_distance_(new collision_detection::CollisionWorldDistanceField( - getWorld(), std::move(size), std::move(origin), use_signed_distance_field, resolution, collision_tolerance, - max_propogation_distance)) -{ -} - -CollisionWorldHybrid::CollisionWorldHybrid(const CollisionWorldHybrid& other, const WorldPtr& world) - : CollisionWorldFCL(other, world) - , cworld_distance_( - new collision_detection::CollisionWorldDistanceField(*other.getCollisionWorldDistanceField(), world)) -{ -} - -void CollisionWorldHybrid::checkCollisionDistanceField(const CollisionRequest& req, CollisionResult& res, - const CollisionRobot& robot, - const robot_state::RobotState& state) const -{ - cworld_distance_->checkCollision(req, res, robot, state); -} - -void CollisionWorldHybrid::checkCollisionDistanceField(const CollisionRequest& req, CollisionResult& res, - const CollisionRobot& robot, - const robot_state::RobotState& state, - GroupStateRepresentationPtr& gsr) const -{ - cworld_distance_->checkCollision(req, res, robot, state, gsr); -} - -void CollisionWorldHybrid::checkCollisionDistanceField(const CollisionRequest& req, CollisionResult& res, - const CollisionRobot& robot, - const robot_state::RobotState& state, - const AllowedCollisionMatrix& acm) const -{ - cworld_distance_->checkCollision(req, res, robot, state, acm); -} - -void CollisionWorldHybrid::checkCollisionDistanceField(const CollisionRequest& req, CollisionResult& res, - const CollisionRobot& robot, - const robot_state::RobotState& state, - const AllowedCollisionMatrix& acm, - GroupStateRepresentationPtr& gsr) const -{ - cworld_distance_->checkCollision(req, res, robot, state, acm, gsr); -} - -void CollisionWorldHybrid::checkRobotCollisionDistanceField(const CollisionRequest& req, CollisionResult& res, - const CollisionRobot& robot, - const robot_state::RobotState& state) const -{ - cworld_distance_->checkRobotCollision(req, res, robot, state); -} - -void CollisionWorldHybrid::checkRobotCollisionDistanceField(const CollisionRequest& req, CollisionResult& res, - const CollisionRobot& robot, - const robot_state::RobotState& state, - GroupStateRepresentationPtr& gsr) const -{ - cworld_distance_->checkRobotCollision(req, res, robot, state, gsr); -} - -void CollisionWorldHybrid::checkRobotCollisionDistanceField(const CollisionRequest& req, CollisionResult& res, - const CollisionRobot& robot, - const robot_state::RobotState& state, - const AllowedCollisionMatrix& acm) const -{ - cworld_distance_->checkRobotCollision(req, res, robot, state, acm); -} - -void CollisionWorldHybrid::checkRobotCollisionDistanceField(const CollisionRequest& req, CollisionResult& res, - const CollisionRobot& robot, - const robot_state::RobotState& state, - const AllowedCollisionMatrix& acm, - GroupStateRepresentationPtr& gsr) const -{ - cworld_distance_->checkRobotCollision(req, res, robot, state, acm, gsr); -} - -void CollisionWorldHybrid::setWorld(const WorldPtr& world) -{ - if (world == getWorld()) - return; - - cworld_distance_->setWorld(world); - CollisionWorldFCL::setWorld(world); -} - -void CollisionWorldHybrid::getCollisionGradients(const CollisionRequest& req, CollisionResult& res, - const CollisionRobot& robot, const robot_state::RobotState& state, - const AllowedCollisionMatrix* acm, - GroupStateRepresentationPtr& gsr) const -{ - cworld_distance_->getCollisionGradients(req, res, robot, state, acm, gsr); -} - -void CollisionWorldHybrid::getAllCollisions(const CollisionRequest& req, CollisionResult& res, - const CollisionRobot& robot, const robot_state::RobotState& state, - const AllowedCollisionMatrix* acm, GroupStateRepresentationPtr& gsr) const -{ - cworld_distance_->getAllCollisions(req, res, robot, state, acm, gsr); -} -} // namespace collision_detection - -#include -const std::string collision_detection::CollisionDetectorAllocatorHybrid::NAME("HYBRID"); diff --git a/moveit_core/collision_distance_field/test/test_collision_distance_field.cpp b/moveit_core/collision_distance_field/test/test_collision_distance_field.cpp index 19445964db..c744150492 100644 --- a/moveit_core/collision_distance_field/test/test_collision_distance_field.cpp +++ b/moveit_core/collision_distance_field/test/test_collision_distance_field.cpp @@ -38,8 +38,7 @@ #include #include #include -#include -#include +#include #include #include @@ -53,8 +52,7 @@ #include -typedef collision_detection::CollisionWorldDistanceField DefaultCWorldType; -typedef collision_detection::CollisionRobotDistanceField DefaultCRobotType; +typedef collision_detection::CollisionEnvDistanceField DefaultCEnvType; class DistanceFieldCollisionDetectionTester : public testing::Test { @@ -87,8 +85,7 @@ class DistanceFieldCollisionDetectionTester : public testing::Test acm_.reset(new collision_detection::AllowedCollisionMatrix(robot_model_->getLinkModelNames(), true)); std::map> link_body_decompositions; - crobot_.reset(new DefaultCRobotType(robot_model_, link_body_decompositions)); - cworld_.reset(new DefaultCWorldType()); + cenv_.reset(new DefaultCEnvType(robot_model_, link_body_decompositions)); } void TearDown() override @@ -107,8 +104,7 @@ class DistanceFieldCollisionDetectionTester : public testing::Test robot_state::TransformsPtr ftf_; robot_state::TransformsConstPtr ftf_const_; - collision_detection::CollisionRobotPtr crobot_; - collision_detection::CollisionWorldPtr cworld_; + collision_detection::CollisionEnvPtr cenv_; collision_detection::AllowedCollisionMatrixPtr acm_; }; @@ -124,7 +120,7 @@ TEST_F(DistanceFieldCollisionDetectionTester, DefaultNotInCollision) collision_detection::CollisionRequest req; collision_detection::CollisionResult res; req.group_name = "whole_body"; - crobot_->checkSelfCollision(req, res, robot_state, *acm_); + cenv_->checkSelfCollision(req, res, robot_state, *acm_); ASSERT_FALSE(res.collision); } @@ -139,13 +135,13 @@ TEST_F(DistanceFieldCollisionDetectionTester, ChangeTorsoPosition) collision_detection::CollisionResult res2; req.group_name = "right_arm"; - crobot_->checkSelfCollision(req, res1, robot_state, *acm_); + cenv_->checkSelfCollision(req, res1, robot_state, *acm_); std::map torso_val; torso_val["torso_lift_joint"] = .15; robot_state.setVariablePositions(torso_val); robot_state.update(); - crobot_->checkSelfCollision(req, res1, robot_state, *acm_); - crobot_->checkSelfCollision(req, res1, robot_state, *acm_); + cenv_->checkSelfCollision(req, res1, robot_state, *acm_); + cenv_->checkSelfCollision(req, res1, robot_state, *acm_); } TEST_F(DistanceFieldCollisionDetectionTester, LinksInCollision) @@ -168,18 +164,18 @@ TEST_F(DistanceFieldCollisionDetectionTester, LinksInCollision) robot_state.updateStateWithLinkAt("base_bellow_link", offset); acm_->setEntry("base_link", "base_bellow_link", false); - crobot_->checkSelfCollision(req, res1, robot_state, *acm_); + cenv_->checkSelfCollision(req, res1, robot_state, *acm_); ASSERT_TRUE(res1.collision); acm_->setEntry("base_link", "base_bellow_link", true); - crobot_->checkSelfCollision(req, res2, robot_state, *acm_); + cenv_->checkSelfCollision(req, res2, robot_state, *acm_); ASSERT_FALSE(res2.collision); robot_state.updateStateWithLinkAt("r_gripper_palm_link", Eigen::Isometry3d::Identity()); robot_state.updateStateWithLinkAt("l_gripper_palm_link", offset); acm_->setEntry("r_gripper_palm_link", "l_gripper_palm_link", false); - crobot_->checkSelfCollision(req, res3, robot_state, *acm_); + cenv_->checkSelfCollision(req, res3, robot_state, *acm_); ASSERT_TRUE(res3.collision); } @@ -206,7 +202,7 @@ TEST_F(DistanceFieldCollisionDetectionTester, ContactReporting) acm_->setEntry("r_gripper_palm_link", "l_gripper_palm_link", false); collision_detection::CollisionResult res; - crobot_->checkSelfCollision(req, res, robot_state, *acm_); + cenv_->checkSelfCollision(req, res, robot_state, *acm_); ASSERT_TRUE(res.collision); EXPECT_EQ(res.contacts.size(), 1u); EXPECT_EQ(res.contacts.begin()->second.size(), 1u); @@ -215,7 +211,7 @@ TEST_F(DistanceFieldCollisionDetectionTester, ContactReporting) req.max_contacts = 2; req.max_contacts_per_pair = 1; // req.verbose = true; - crobot_->checkSelfCollision(req, res, robot_state, *acm_); + cenv_->checkSelfCollision(req, res, robot_state, *acm_); ASSERT_TRUE(res.collision); EXPECT_EQ(res.contact_count, 2u); EXPECT_EQ(res.contacts.begin()->second.size(), 1u); @@ -226,7 +222,7 @@ TEST_F(DistanceFieldCollisionDetectionTester, ContactReporting) req.max_contacts = 10; req.max_contacts_per_pair = 2; acm_.reset(new collision_detection::AllowedCollisionMatrix(robot_model_->getLinkModelNames(), false)); - crobot_->checkSelfCollision(req, res, robot_state, *acm_); + cenv_->checkSelfCollision(req, res, robot_state, *acm_); ASSERT_TRUE(res.collision); EXPECT_LE(res.contacts.size(), 10u); EXPECT_LE(res.contact_count, 10u); @@ -254,7 +250,7 @@ TEST_F(DistanceFieldCollisionDetectionTester, ContactPositions) acm_->setEntry("r_gripper_palm_link", "l_gripper_palm_link", false); collision_detection::CollisionResult res; - crobot_->checkSelfCollision(req, res, robot_state, *acm_); + cenv_->checkSelfCollision(req, res, robot_state, *acm_); ASSERT_TRUE(res.collision); ASSERT_EQ(res.contacts.size(), 1u); ASSERT_EQ(res.contacts.begin()->second.size(), 1u); @@ -272,7 +268,7 @@ TEST_F(DistanceFieldCollisionDetectionTester, ContactPositions) robot_state.updateStateWithLinkAt("l_gripper_palm_link", pos2); collision_detection::CollisionResult res2; - crobot_->checkSelfCollision(req, res2, robot_state, *acm_); + cenv_->checkSelfCollision(req, res2, robot_state, *acm_); ASSERT_TRUE(res2.collision); ASSERT_EQ(res2.contacts.size(), 1u); ASSERT_EQ(res2.contacts.begin()->second.size(), 1u); @@ -290,7 +286,7 @@ TEST_F(DistanceFieldCollisionDetectionTester, ContactPositions) robot_state.updateStateWithLinkAt("l_gripper_palm_link", pos2); collision_detection::CollisionResult res3; - crobot_->checkSelfCollision(req, res2, robot_state, *acm_); + cenv_->checkSelfCollision(req, res2, robot_state, *acm_); ASSERT_FALSE(res3.collision); } @@ -311,18 +307,18 @@ TEST_F(DistanceFieldCollisionDetectionTester, AttachedBodyTester) pos1.translation().x() = 1.0; robot_state.updateStateWithLinkAt("r_gripper_palm_link", pos1); - crobot_->checkSelfCollision(req, res, robot_state, *acm_); + cenv_->checkSelfCollision(req, res, robot_state, *acm_); ASSERT_FALSE(res.collision); shapes::Shape* shape = new shapes::Box(.25, .25, .25); - cworld_->getWorld()->addToObject("box", shapes::ShapeConstPtr(shape), pos1); + cenv_->getWorld()->addToObject("box", shapes::ShapeConstPtr(shape), pos1); res = collision_detection::CollisionResult(); - cworld_->checkRobotCollision(req, res, *crobot_, robot_state, *acm_); + cenv_->checkRobotCollision(req, res, robot_state, *acm_); ASSERT_TRUE(res.collision); // deletes shape - cworld_->getWorld()->removeObject("box"); + cenv_->getWorld()->removeObject("box"); std::vector shapes; EigenSTL::vector_Isometry3d poses; @@ -336,7 +332,7 @@ TEST_F(DistanceFieldCollisionDetectionTester, AttachedBodyTester) robot_state.attachBody(attached_body); res = collision_detection::CollisionResult(); - crobot_->checkSelfCollision(req, res, robot_state, *acm_); + cenv_->checkSelfCollision(req, res, robot_state, *acm_); ASSERT_TRUE(res.collision); // deletes shape @@ -350,19 +346,19 @@ TEST_F(DistanceFieldCollisionDetectionTester, AttachedBodyTester) robot_state.attachBody(attached_body_1); res = collision_detection::CollisionResult(); - crobot_->checkSelfCollision(req, res, robot_state, *acm_); + cenv_->checkSelfCollision(req, res, robot_state, *acm_); // ASSERT_FALSE(res.collision); pos1.translation().x() = 1.01; shapes::Shape* coll = new shapes::Box(.1, .1, .1); - cworld_->getWorld()->addToObject("coll", shapes::ShapeConstPtr(coll), pos1); + cenv_->getWorld()->addToObject("coll", shapes::ShapeConstPtr(coll), pos1); res = collision_detection::CollisionResult(); - cworld_->checkRobotCollision(req, res, *crobot_, robot_state, *acm_); + cenv_->checkRobotCollision(req, res, robot_state, *acm_); ASSERT_TRUE(res.collision); acm_->setEntry("coll", "r_gripper_palm_link", true); res = collision_detection::CollisionResult(); - cworld_->checkRobotCollision(req, res, *crobot_, robot_state, *acm_); + cenv_->checkRobotCollision(req, res, robot_state, *acm_); ASSERT_TRUE(res.collision); } diff --git a/moveit_core/constraint_samplers/CMakeLists.txt b/moveit_core/constraint_samplers/CMakeLists.txt index e988eb2108..958e37b563 100644 --- a/moveit_core/constraint_samplers/CMakeLists.txt +++ b/moveit_core/constraint_samplers/CMakeLists.txt @@ -19,7 +19,8 @@ add_dependencies(${MOVEIT_LIB_NAME} ${catkin_EXPORTED_TARGETS}) install(TARGETS ${MOVEIT_LIB_NAME} LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} - ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}) + ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}) install(DIRECTORY include/ DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}) diff --git a/moveit_core/constraint_samplers/include/moveit/constraint_samplers/constraint_sampler.h b/moveit_core/constraint_samplers/include/moveit/constraint_samplers/constraint_sampler.h index ce2f2ed073..f86cc069fa 100644 --- a/moveit_core/constraint_samplers/include/moveit/constraint_samplers/constraint_sampler.h +++ b/moveit_core/constraint_samplers/include/moveit/constraint_samplers/constraint_sampler.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_CONSTRAINT_SAMPLERS_CONSTRAINT_SAMPLER_ -#define MOVEIT_CONSTRAINT_SAMPLERS_CONSTRAINT_SAMPLER_ +#pragma once #include #include @@ -296,5 +295,3 @@ class ConstraintSampler bool verbose_; ///< True if verbosity is on }; } - -#endif diff --git a/moveit_core/constraint_samplers/include/moveit/constraint_samplers/constraint_sampler_allocator.h b/moveit_core/constraint_samplers/include/moveit/constraint_samplers/constraint_sampler_allocator.h index abc68a0e28..89db5e830e 100644 --- a/moveit_core/constraint_samplers/include/moveit/constraint_samplers/constraint_sampler_allocator.h +++ b/moveit_core/constraint_samplers/include/moveit/constraint_samplers/constraint_sampler_allocator.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_CONSTRAINT_SAMPLERS_CONSTRAINT_SAMPLER_ALLOCATOR_ -#define MOVEIT_CONSTRAINT_SAMPLERS_CONSTRAINT_SAMPLER_ALLOCATOR_ +#pragma once #include #include @@ -62,5 +61,3 @@ class ConstraintSamplerAllocator const moveit_msgs::Constraints& constr) const = 0; }; } - -#endif diff --git a/moveit_core/constraint_samplers/include/moveit/constraint_samplers/constraint_sampler_manager.h b/moveit_core/constraint_samplers/include/moveit/constraint_samplers/constraint_sampler_manager.h index 05c88548e8..630e307c97 100644 --- a/moveit_core/constraint_samplers/include/moveit/constraint_samplers/constraint_sampler_manager.h +++ b/moveit_core/constraint_samplers/include/moveit/constraint_samplers/constraint_sampler_manager.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_CONSTRAINT_SAMPLERS_CONSTRAINT_SAMPLER_MANAGER_ -#define MOVEIT_CONSTRAINT_SAMPLERS_CONSTRAINT_SAMPLER_MANAGER_ +#pragma once #include #include @@ -144,5 +143,3 @@ class ConstraintSamplerManager sampler_alloc_; /**< \brief Holds the constraint sampler allocators, which will be tested in order */ }; } - -#endif diff --git a/moveit_core/constraint_samplers/include/moveit/constraint_samplers/constraint_sampler_tools.h b/moveit_core/constraint_samplers/include/moveit/constraint_samplers/constraint_sampler_tools.h index ce405b9d51..f222aea111 100644 --- a/moveit_core/constraint_samplers/include/moveit/constraint_samplers/constraint_sampler_tools.h +++ b/moveit_core/constraint_samplers/include/moveit/constraint_samplers/constraint_sampler_tools.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_CONSTRAINT_SAMPLERS_CONSTRAINT_SAMPLER_TOOLS_ -#define MOVEIT_CONSTRAINT_SAMPLERS_CONSTRAINT_SAMPLER_TOOLS_ +#pragma once #include #include @@ -55,5 +54,3 @@ double countSamplesPerSecond(const ConstraintSamplerPtr& sampler, const robot_st double countSamplesPerSecond(const moveit_msgs::Constraints& constr, const planning_scene::PlanningSceneConstPtr& scene, const std::string& group); } - -#endif diff --git a/moveit_core/constraint_samplers/include/moveit/constraint_samplers/default_constraint_samplers.h b/moveit_core/constraint_samplers/include/moveit/constraint_samplers/default_constraint_samplers.h index 77a048bdb8..399e3cc7ef 100644 --- a/moveit_core/constraint_samplers/include/moveit/constraint_samplers/default_constraint_samplers.h +++ b/moveit_core/constraint_samplers/include/moveit/constraint_samplers/default_constraint_samplers.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_CONSTRAINT_SAMPLERS_DEFAULT_CONSTRAINT_SAMPLERS_ -#define MOVEIT_CONSTRAINT_SAMPLERS_DEFAULT_CONSTRAINT_SAMPLERS_ +#pragma once #include #include @@ -526,5 +525,3 @@ class IKConstraintSampler : public ConstraintSampler Eigen::Isometry3d eef_to_ik_tip_transform_; /**< \brief Holds the transformation from end effector to IK tip frame */ }; } - -#endif diff --git a/moveit_core/constraint_samplers/include/moveit/constraint_samplers/union_constraint_sampler.h b/moveit_core/constraint_samplers/include/moveit/constraint_samplers/union_constraint_sampler.h index a50c16298a..7b00590491 100644 --- a/moveit_core/constraint_samplers/include/moveit/constraint_samplers/union_constraint_sampler.h +++ b/moveit_core/constraint_samplers/include/moveit/constraint_samplers/union_constraint_sampler.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_CONSTRAINT_SAMPLERS_DEFAULT_UNION_CONSTRAINT_SAMPLER_ -#define MOVEIT_CONSTRAINT_SAMPLERS_DEFAULT_UNION_CONSTRAINT_SAMPLER_ +#pragma once #include @@ -169,5 +168,3 @@ class UnionConstraintSampler : public ConstraintSampler std::vector samplers_; /**< \brief Holder for sorted internal list of samplers*/ }; } - -#endif diff --git a/moveit_core/constraint_samplers/test/pr2_arm_ik.h b/moveit_core/constraint_samplers/test/pr2_arm_ik.h index 8ba4052ca9..46d4a7ef32 100644 --- a/moveit_core/constraint_samplers/test/pr2_arm_ik.h +++ b/moveit_core/constraint_samplers/test/pr2_arm_ik.h @@ -34,8 +34,7 @@ /* Author: Sachin Chitta */ -#ifndef PR2_ARM_IK_H -#define PR2_ARM_IK_H +#pragma once #include #include @@ -190,4 +189,3 @@ class PR2ArmIK std::vector continuous_joint_; }; } -#endif // PR2_ARM_IK_H diff --git a/moveit_core/constraint_samplers/test/pr2_arm_kinematics_plugin.h b/moveit_core/constraint_samplers/test/pr2_arm_kinematics_plugin.h index 94bd16926e..a3cca94e0c 100644 --- a/moveit_core/constraint_samplers/test/pr2_arm_kinematics_plugin.h +++ b/moveit_core/constraint_samplers/test/pr2_arm_kinematics_plugin.h @@ -34,8 +34,7 @@ /* Author: Sachin Chitta */ -#ifndef PR2_ARM_IK_NODE_H -#define PR2_ARM_IK_NODE_H +#pragma once #include #include @@ -261,5 +260,3 @@ class PR2ArmKinematicsPlugin : public kinematics::KinematicsBase moveit_msgs::MoveItErrorCodes& error_code) const; }; } - -#endif diff --git a/moveit_core/controller_manager/include/moveit/controller_manager/controller_manager.h b/moveit_core/controller_manager/include/moveit/controller_manager/controller_manager.h index da193cb0c2..7af922b3bc 100644 --- a/moveit_core/controller_manager/include/moveit/controller_manager/controller_manager.h +++ b/moveit_core/controller_manager/include/moveit/controller_manager/controller_manager.h @@ -34,15 +34,14 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_MOVEIT_CONTROLLER_MANAGER_ -#define MOVEIT_MOVEIT_CONTROLLER_MANAGER_ +#pragma once #include #include #include #include -/// Namespace for the base class of a MoveIt! controller manager +/// Namespace for the base class of a MoveIt controller manager namespace moveit_controller_manager { /// The reported execution status @@ -101,7 +100,7 @@ struct ExecutionStatus MOVEIT_CLASS_FORWARD(MoveItControllerHandle); -/** \brief MoveIt! sends commands to a controller via a handle that satisfies this interface. */ +/** \brief MoveIt sends commands to a controller via a handle that satisfies this interface. */ class MoveItControllerHandle { public: @@ -149,7 +148,7 @@ class MoveItControllerHandle MOVEIT_CLASS_FORWARD(MoveItControllerManager); -/** @brief MoveIt! does not enforce how controllers are implemented. +/** @brief MoveIt does not enforce how controllers are implemented. To make your controllers usable by MoveIt, this interface needs to be implemented. The main purpose of this interface is to expose the set of known controllers and potentially to allow activating and deactivating them, if multiple controllers are available. @@ -157,7 +156,7 @@ MOVEIT_CLASS_FORWARD(MoveItControllerManager); class MoveItControllerManager { public: - /** \brief Each controller known to MoveIt! has a state. This + /** \brief Each controller known to MoveIt has a state. This structure describes that controller's state. */ struct ControllerState { @@ -165,12 +164,12 @@ class MoveItControllerManager { } - /** \brief A controller can be active or inactive. This means that MoveIt! could activate the controller when + /** \brief A controller can be active or inactive. This means that MoveIt could activate the controller when needed, and de-activate controllers that overlap (control the same set of joints) */ bool active_; /** \brief It is often the case that multiple controllers could be used to execute a motion. Marking a controller as - default makes MoveIt! prefer this controller when multiple options are available. */ + default makes MoveIt prefer this controller when multiple options are available. */ bool default_; }; @@ -209,5 +208,3 @@ class MoveItControllerManager const std::vector& deactivate) = 0; }; } - -#endif diff --git a/moveit_core/distance_field/CMakeLists.txt b/moveit_core/distance_field/CMakeLists.txt index ac60b52783..3955c94fd3 100644 --- a/moveit_core/distance_field/CMakeLists.txt +++ b/moveit_core/distance_field/CMakeLists.txt @@ -12,7 +12,8 @@ add_dependencies(${MOVEIT_LIB_NAME} ${catkin_EXPORTED_TARGETS}) install(TARGETS ${MOVEIT_LIB_NAME} ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} - LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}) + LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}) install(DIRECTORY include/ DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}) diff --git a/moveit_core/distance_field/include/moveit/distance_field/distance_field.h b/moveit_core/distance_field/include/moveit/distance_field/distance_field.h index d1164a4935..b4bfa238d7 100644 --- a/moveit_core/distance_field/include/moveit/distance_field/distance_field.h +++ b/moveit_core/distance_field/include/moveit/distance_field/distance_field.h @@ -34,8 +34,7 @@ /* Author: Mrinal Kalakrishnan, Ken Anderson, E. Gil Jones */ -#ifndef MOVEIT_DISTANCE_FIELD_DISTANCE_FIELD_H -#define MOVEIT_DISTANCE_FIELD_DISTANCE_FIELD_H +#pragma once #include #include @@ -627,5 +626,3 @@ class DistanceField }; } // namespace distance_field - -#endif // MOVEIT_DISTANCE_FIELD_DISTANCE_FIELD_H diff --git a/moveit_core/distance_field/include/moveit/distance_field/find_internal_points.h b/moveit_core/distance_field/include/moveit/distance_field/find_internal_points.h index be419651f9..27363466e1 100644 --- a/moveit_core/distance_field/include/moveit/distance_field/find_internal_points.h +++ b/moveit_core/distance_field/include/moveit/distance_field/find_internal_points.h @@ -34,8 +34,7 @@ /* Author: Acorn Pooley */ -#ifndef MOVEIT_DISTANCE_FIELD__FIND_INTERNAL_POINTS_ -#define MOVEIT_DISTANCE_FIELD__FIND_INTERNAL_POINTS_ +#pragma once #include #include @@ -54,5 +53,3 @@ namespace distance_field */ void findInternalPointsConvex(const bodies::Body& body, double resolution, EigenSTL::vector_Vector3d& points); } - -#endif diff --git a/moveit_core/distance_field/include/moveit/distance_field/propagation_distance_field.h b/moveit_core/distance_field/include/moveit/distance_field/propagation_distance_field.h index 66cbf2daa2..a278a7f6d6 100644 --- a/moveit_core/distance_field/include/moveit/distance_field/propagation_distance_field.h +++ b/moveit_core/distance_field/include/moveit/distance_field/propagation_distance_field.h @@ -34,8 +34,7 @@ /* Author: Mrinal Kalakrishnan, Ken Anderson */ -#ifndef MOVEIT_DISTANCE_FIELD_PROPAGATION_DISTANCE_FIELD_ -#define MOVEIT_DISTANCE_FIELD_PROPAGATION_DISTANCE_FIELD_ +#pragma once #include #include @@ -611,5 +610,3 @@ inline double PropagationDistanceField::getDistance(const PropDistanceFieldVoxel return sqrt_table_[object.distance_square_] - sqrt_table_[object.negative_distance_square_]; } } - -#endif diff --git a/moveit_core/distance_field/include/moveit/distance_field/voxel_grid.h b/moveit_core/distance_field/include/moveit/distance_field/voxel_grid.h index f85cfbdcd7..6cecf4e050 100644 --- a/moveit_core/distance_field/include/moveit/distance_field/voxel_grid.h +++ b/moveit_core/distance_field/include/moveit/distance_field/voxel_grid.h @@ -34,8 +34,7 @@ /* Author: Mrinal Kalakrishnan, Acorn Pooley */ -#ifndef MOVEIT_DISTANCE_FIELD_VOXEL_GRID_ -#define MOVEIT_DISTANCE_FIELD_VOXEL_GRID_ +#pragma once #include #include @@ -579,4 +578,3 @@ inline bool VoxelGrid::worldToGrid(const Eigen::Vector3d& world, Eigen::Vecto } } // namespace distance_field -#endif diff --git a/moveit_core/dynamics_solver/CMakeLists.txt b/moveit_core/dynamics_solver/CMakeLists.txt index 61324a752d..07028fc9e5 100644 --- a/moveit_core/dynamics_solver/CMakeLists.txt +++ b/moveit_core/dynamics_solver/CMakeLists.txt @@ -8,6 +8,7 @@ add_dependencies(${MOVEIT_LIB_NAME} ${catkin_EXPORTED_TARGETS}) install(TARGETS ${MOVEIT_LIB_NAME} ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} - LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}) + LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}) install(DIRECTORY include/ DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}) diff --git a/moveit_core/dynamics_solver/include/moveit/dynamics_solver/dynamics_solver.h b/moveit_core/dynamics_solver/include/moveit/dynamics_solver/dynamics_solver.h index 3e73f8b036..1f579d0c6f 100644 --- a/moveit_core/dynamics_solver/include/moveit/dynamics_solver/dynamics_solver.h +++ b/moveit_core/dynamics_solver/include/moveit/dynamics_solver/dynamics_solver.h @@ -34,8 +34,7 @@ /* Author: Sachin Chitta */ -#ifndef MOVEIT_DYNAMICS_SOLVER_DYNAMICS_SOLVER_ -#define MOVEIT_DYNAMICS_SOLVER_DYNAMICS_SOLVER_ +#pragma once // KDL #include @@ -151,4 +150,3 @@ class DynamicsSolver double gravity_; // Norm of the gravity vector passed in initialize() }; } -#endif diff --git a/moveit_core/exceptions/CMakeLists.txt b/moveit_core/exceptions/CMakeLists.txt index 6b80cf3c28..70ab423d27 100644 --- a/moveit_core/exceptions/CMakeLists.txt +++ b/moveit_core/exceptions/CMakeLists.txt @@ -7,5 +7,6 @@ target_link_libraries(${MOVEIT_LIB_NAME} ${catkin_LIBRARIES} ${urdfdom_LIBRARIES install(TARGETS ${MOVEIT_LIB_NAME} LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} - ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}) + ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}) install(DIRECTORY include/ DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}) diff --git a/moveit_core/exceptions/include/moveit/exceptions/exceptions.h b/moveit_core/exceptions/include/moveit/exceptions/exceptions.h index 2dd4f93464..34394e987c 100644 --- a/moveit_core/exceptions/include/moveit/exceptions/exceptions.h +++ b/moveit_core/exceptions/include/moveit/exceptions/exceptions.h @@ -34,12 +34,11 @@ /* Author: Acorn Pooley, Ioan Sucan */ -#ifndef MOVEIT_EXCEPTIONS_ -#define MOVEIT_EXCEPTIONS_ +#pragma once #include -/** \brief Main namespace for MoveIt! */ +/** \brief Main namespace for MoveIt */ namespace moveit { /** \brief This may be thrown during construction of objects if errors occur */ @@ -56,5 +55,3 @@ class Exception : public std::runtime_error explicit Exception(const std::string& what_arg); }; } - -#endif diff --git a/moveit_core/kinematic_constraints/CMakeLists.txt b/moveit_core/kinematic_constraints/CMakeLists.txt index ea45aa72f0..18ff796f70 100644 --- a/moveit_core/kinematic_constraints/CMakeLists.txt +++ b/moveit_core/kinematic_constraints/CMakeLists.txt @@ -12,7 +12,8 @@ add_dependencies(${MOVEIT_LIB_NAME} ${catkin_EXPORTED_TARGETS}) install(TARGETS ${MOVEIT_LIB_NAME} LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} - ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}) + ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}) install(DIRECTORY include/ DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}) diff --git a/moveit_core/kinematic_constraints/dox/constraint_representation.dox b/moveit_core/kinematic_constraints/dox/constraint_representation.dox index 886a3100e9..d786835f0c 100644 --- a/moveit_core/kinematic_constraints/dox/constraint_representation.dox +++ b/moveit_core/kinematic_constraints/dox/constraint_representation.dox @@ -1,7 +1,7 @@ /** \page constraint_representation Representation and Evaluation of Constraints -Constraints are integral component of MoveIt! and they are used both to constrain robot motion as well as to define planning goals. There following set of constraints are defined in the kinematic_constraints namespace: +Constraints are integral component of MoveIt and they are used both to constrain robot motion as well as to define planning goals. There following set of constraints are defined in the kinematic_constraints namespace: - kinematic_constraints::JointConstraint - kinematic_constraints::OrientationConstraint - kinematic_constraints::PositionConstraint diff --git a/moveit_core/kinematic_constraints/include/moveit/kinematic_constraints/kinematic_constraint.h b/moveit_core/kinematic_constraints/include/moveit/kinematic_constraints/kinematic_constraint.h index 936ebf82fe..a716e8bd86 100644 --- a/moveit_core/kinematic_constraints/include/moveit/kinematic_constraints/kinematic_constraint.h +++ b/moveit_core/kinematic_constraints/include/moveit/kinematic_constraints/kinematic_constraint.h @@ -34,13 +34,12 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_KINEMATIC_CONSTRAINTS_KINEMATIC_CONSTRAINT_ -#define MOVEIT_KINEMATIC_CONSTRAINTS_KINEMATIC_CONSTRAINT_ +#pragma once #include #include #include -#include +#include #include #include @@ -832,7 +831,7 @@ class VisibilityConstraint : public KinematicConstraint */ bool decideContact(const collision_detection::Contact& contact) const; - collision_detection::CollisionRobotPtr collision_robot_; /**< \brief A copy of the collision robot maintained for + collision_detection::CollisionEnvPtr collision_env_; /**< \brief A copy of the collision robot maintained for collision checking the cone against robot links */ bool mobile_sensor_frame_; /**< \brief True if the sensor is a non-fixed frame relative to the transform frame */ bool mobile_target_frame_; /**< \brief True if the target is a non-fixed frame relative to the transform frame */ @@ -1069,5 +1068,3 @@ class KinematicConstraintSet moveit_msgs::Constraints all_constraints_; /**< \brief Messages corresponding to all internal constraints */ }; } - -#endif diff --git a/moveit_core/kinematic_constraints/include/moveit/kinematic_constraints/utils.h b/moveit_core/kinematic_constraints/include/moveit/kinematic_constraints/utils.h index e5e9e5f74f..54080fbacb 100644 --- a/moveit_core/kinematic_constraints/include/moveit/kinematic_constraints/utils.h +++ b/moveit_core/kinematic_constraints/include/moveit/kinematic_constraints/utils.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_KINEMATIC_CONSTRAINTS_UTILS_ -#define MOVEIT_KINEMATIC_CONSTRAINTS_UTILS_ +#pragma once #include #include @@ -68,7 +67,7 @@ moveit_msgs::Constraints mergeConstraints(const moveit_msgs::Constraints& first, const moveit_msgs::Constraints& second); /** \brief Check if any constraints were specified */ -bool isEmpty(const moveit_msgs::Constraints& constr); +[[deprecated("Use moveit/utils/message_checks.h instead")]] bool isEmpty(const moveit_msgs::Constraints& constr); std::size_t countIndividualConstraints(const moveit_msgs::Constraints& constr); @@ -216,4 +215,3 @@ bool constructConstraints(XmlRpc::XmlRpcValue& params, moveit_msgs::Constraints& */ bool resolveConstraintFrames(const robot_state::RobotState& state, moveit_msgs::Constraints& constraints); } -#endif diff --git a/moveit_core/kinematic_constraints/src/kinematic_constraint.cpp b/moveit_core/kinematic_constraints/src/kinematic_constraint.cpp index 526fe4e3d3..884a1dca51 100644 --- a/moveit_core/kinematic_constraints/src/kinematic_constraint.cpp +++ b/moveit_core/kinematic_constraints/src/kinematic_constraint.cpp @@ -38,8 +38,7 @@ #include #include #include -#include -#include +#include #include #include #include @@ -644,7 +643,7 @@ void OrientationConstraint::print(std::ostream& out) const } VisibilityConstraint::VisibilityConstraint(const robot_model::RobotModelConstPtr& model) - : KinematicConstraint(model), collision_robot_(new collision_detection::CollisionRobotFCL(model)) + : KinematicConstraint(model), collision_env_(new collision_detection::CollisionEnvFCL(model)) { type_ = VISIBILITY_CONSTRAINT; } @@ -984,8 +983,7 @@ ConstraintEvaluationResult VisibilityConstraint::decide(const robot_state::Robot return ConstraintEvaluationResult(false, 0.0); // add the visibility cone as an object - collision_detection::CollisionWorldFCL collision_world; - collision_world.getWorld()->addToObject("cone", shapes::ShapeConstPtr(m), Eigen::Isometry3d::Identity()); + collision_env_->getWorld()->addToObject("cone", shapes::ShapeConstPtr(m), Eigen::Isometry3d::Identity()); // check for collisions between the robot and the cone collision_detection::CollisionRequest req; @@ -995,7 +993,7 @@ ConstraintEvaluationResult VisibilityConstraint::decide(const robot_state::Robot req.contacts = true; req.verbose = verbose; req.max_contacts = 1; - collision_world.checkRobotCollision(req, res, *collision_robot_, state, acm); + collision_env_->checkRobotCollision(req, res, state, acm); if (verbose) { @@ -1005,6 +1003,8 @@ ConstraintEvaluationResult VisibilityConstraint::decide(const robot_state::Robot res.collision ? "not " : "", ss.str().c_str()); } + collision_env_->getWorld()->removeObject("cone"); + return ConstraintEvaluationResult(!res.collision, res.collision ? res.contacts.begin()->second.front().depth : 0.0); } diff --git a/moveit_core/kinematic_constraints/src/utils.cpp b/moveit_core/kinematic_constraints/src/utils.cpp index 568efbb95b..59beecec6c 100644 --- a/moveit_core/kinematic_constraints/src/utils.cpp +++ b/moveit_core/kinematic_constraints/src/utils.cpp @@ -38,6 +38,7 @@ #include #include #include +#include using namespace moveit::core; @@ -116,8 +117,7 @@ moveit_msgs::Constraints mergeConstraints(const moveit_msgs::Constraints& first, bool isEmpty(const moveit_msgs::Constraints& constr) { - return constr.position_constraints.empty() && constr.orientation_constraints.empty() && - constr.visibility_constraints.empty() && constr.joint_constraints.empty(); + return moveit::core::isEmpty(constr); } std::size_t countIndividualConstraints(const moveit_msgs::Constraints& constr) diff --git a/moveit_core/kinematics_base/CMakeLists.txt b/moveit_core/kinematics_base/CMakeLists.txt index f4d98357ef..2ec7a736f4 100644 --- a/moveit_core/kinematics_base/CMakeLists.txt +++ b/moveit_core/kinematics_base/CMakeLists.txt @@ -13,6 +13,7 @@ target_link_libraries(${MOVEIT_LIB_NAME} ${catkin_LIBRARIES} ${urdfdom_LIBRARIES install(TARGETS ${MOVEIT_LIB_NAME} LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} - ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}) + ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}) install(DIRECTORY include/ DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}) diff --git a/moveit_core/kinematics_base/include/moveit/kinematics_base/kinematics_base.h b/moveit_core/kinematics_base/include/moveit/kinematics_base/kinematics_base.h index c6536f4805..59fc3ee7c4 100644 --- a/moveit_core/kinematics_base/include/moveit/kinematics_base/kinematics_base.h +++ b/moveit_core/kinematics_base/include/moveit/kinematics_base/kinematics_base.h @@ -34,8 +34,7 @@ /* Author: Sachin Chitta, Dave Coleman */ -#ifndef MOVEIT_KINEMATICS_BASE_KINEMATICS_BASE_ -#define MOVEIT_KINEMATICS_BASE_KINEMATICS_BASE_ +#pragma once #include #include @@ -174,12 +173,18 @@ class KinematicsBase /** * @brief Given the desired poses of all end-effectors, compute joint angles that are able to reach it. * - * This is a default implementation that returns only one solution and so its result is equivalent to calling + * The default implementation returns only one solution and so its result is equivalent to calling * 'getPositionIK(...)' with a zero initialized seed. * + * Some planners (e.g. IKFast) support getting multiple joint solutions for a single pose. + * This can be enabled using the |DiscretizationMethods| enum and choosing an option that is not |NO_DISCRETIZATION|. + * * @param ik_poses The desired pose of each tip link * @param ik_seed_state an initial guess solution for the inverse kinematics - * @param solutions A vector of vectors where each entry is a valid joint solution + * @param solutions A vector of valid joint vectors. This return has two variant behaviors: + * 1) Return a joint solution for every input |ik_poses|, e.g. multi-arm support + * 2) Return multiple joint solutions for a single |ik_poses| input, e.g. underconstrained IK + * TODO(dave): This dual behavior is confusing and should be changed in a future refactor of this API * @param result A struct that reports the results of the query * @param options An option struct which contains the type of redundancy discretization used. This default * implementation only supports the KinematicSearches::NO_DISCRETIZATION method; requesting any @@ -659,5 +664,3 @@ class KinematicsBase std::string removeSlash(const std::string& str) const; }; }; - -#endif diff --git a/moveit_core/kinematics_metrics/CMakeLists.txt b/moveit_core/kinematics_metrics/CMakeLists.txt index 8438c8641d..6a43296df8 100644 --- a/moveit_core/kinematics_metrics/CMakeLists.txt +++ b/moveit_core/kinematics_metrics/CMakeLists.txt @@ -8,6 +8,7 @@ add_dependencies(${MOVEIT_LIB_NAME} ${catkin_EXPORTED_TARGETS}) install(TARGETS ${MOVEIT_LIB_NAME} ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} - LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}) + LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}) install(DIRECTORY include/ DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}) diff --git a/moveit_core/kinematics_metrics/include/moveit/kinematics_metrics/kinematics_metrics.h b/moveit_core/kinematics_metrics/include/moveit/kinematics_metrics/kinematics_metrics.h index c92a7d5063..da5c213e49 100644 --- a/moveit_core/kinematics_metrics/include/moveit/kinematics_metrics/kinematics_metrics.h +++ b/moveit_core/kinematics_metrics/include/moveit/kinematics_metrics/kinematics_metrics.h @@ -34,8 +34,7 @@ /* Author: Sachin Chitta */ -#ifndef MOVEIT_KINEMATICS_METRICS_KINEMATICS_METRICS_ -#define MOVEIT_KINEMATICS_METRICS_KINEMATICS_METRICS_ +#pragma once #include #include @@ -158,5 +157,3 @@ class KinematicsMetrics double penalty_multiplier_; }; } - -#endif diff --git a/moveit_core/macros/include/moveit/macros/class_forward.h b/moveit_core/macros/include/moveit/macros/class_forward.h index 57bb5ce56b..1c5ab03544 100644 --- a/moveit_core/macros/include/moveit/macros/class_forward.h +++ b/moveit_core/macros/include/moveit/macros/class_forward.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_MACROS_CLASS_FORWARD_ -#define MOVEIT_MACROS_CLASS_FORWARD_ +#pragma once #include @@ -58,5 +57,3 @@ #define MOVEIT_STRUCT_FORWARD(C) \ struct C; \ MOVEIT_DECLARE_PTR(C, C); - -#endif diff --git a/moveit_core/macros/include/moveit/macros/console_colors.h b/moveit_core/macros/include/moveit/macros/console_colors.h index 4ea7b65d39..0da6ae80de 100644 --- a/moveit_core/macros/include/moveit/macros/console_colors.h +++ b/moveit_core/macros/include/moveit/macros/console_colors.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_CONSOLE_COLORS_ -#define MOVEIT_CONSOLE_COLORS_ +#pragma once #define MOVEIT_CONSOLE_COLOR_RESET "\033[0m" #define MOVEIT_CONSOLE_COLOR_GRAY "\033[90m" @@ -46,5 +45,3 @@ #define MOVEIT_CONSOLE_COLOR_BLUE "\033[94m" #define MOVEIT_CONSOLE_COLOR_PURPLE "\033[95m" #define MOVEIT_CONSOLE_COLOR_CYAN "\033[96m" - -#endif diff --git a/moveit_core/macros/include/moveit/macros/declare_ptr.h b/moveit_core/macros/include/moveit/macros/declare_ptr.h index 36506e618a..fc3eeb6e39 100644 --- a/moveit_core/macros/include/moveit/macros/declare_ptr.h +++ b/moveit_core/macros/include/moveit/macros/declare_ptr.h @@ -32,8 +32,7 @@ * POSSIBILITY OF SUCH DAMAGE. *********************************************************************/ -#ifndef MOVEIT_MACROS_DECLARE_PTR_ -#define MOVEIT_MACROS_DECLARE_PTR_ +#pragma once #include @@ -70,5 +69,3 @@ typedef std::shared_ptr ConstPtr; \ typedef std::weak_ptr WeakPtr; \ typedef std::weak_ptr ConstWeakPtr; - -#endif diff --git a/moveit_core/macros/include/moveit/macros/deprecation.h b/moveit_core/macros/include/moveit/macros/deprecation.h index 1a69e998f0..20f24b06ac 100644 --- a/moveit_core/macros/include/moveit/macros/deprecation.h +++ b/moveit_core/macros/include/moveit/macros/deprecation.h @@ -32,8 +32,7 @@ * POSSIBILITY OF SUCH DAMAGE. *********************************************************************/ -#ifndef MOVEIT_MACROS_DEPRECATION_ -#define MOVEIT_MACROS_DEPRECATION_ +#pragma once /** \def MOVEIT_DEPRECATED Macro that marks functions as deprecated */ @@ -47,5 +46,3 @@ #else #define MOVEIT_DEPRECATED /* Nothing */ #endif - -#endif diff --git a/moveit_core/package.xml b/moveit_core/package.xml index b12b48f6f3..121f19f3b3 100644 --- a/moveit_core/package.xml +++ b/moveit_core/package.xml @@ -1,7 +1,7 @@ moveit_core 1.0.1 - Core libraries used by MoveIt! + Core libraries used by MoveIt Ioan Sucan Sachin Chitta Acorn Pooley @@ -9,7 +9,7 @@ Dave Coleman Michael Görner Michael Ferguson - MoveIt! Release Team + MoveIt Release Team BSD http://moveit.ros.org diff --git a/moveit_core/planning_interface/CMakeLists.txt b/moveit_core/planning_interface/CMakeLists.txt index 33c0e1a789..8a876192b5 100644 --- a/moveit_core/planning_interface/CMakeLists.txt +++ b/moveit_core/planning_interface/CMakeLists.txt @@ -11,6 +11,7 @@ add_dependencies(${MOVEIT_LIB_NAME} ${catkin_EXPORTED_TARGETS}) install(TARGETS ${MOVEIT_LIB_NAME} ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} - LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}) + LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}) install(DIRECTORY include/ DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}) diff --git a/moveit_core/planning_interface/include/moveit/planning_interface/planning_interface.h b/moveit_core/planning_interface/include/moveit/planning_interface/planning_interface.h index 68214f4a92..9cf2f206f4 100644 --- a/moveit_core/planning_interface/include/moveit/planning_interface/planning_interface.h +++ b/moveit_core/planning_interface/include/moveit/planning_interface/planning_interface.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_PLANNING_INTERFACE_PLANNING_INTERFACE_ -#define MOVEIT_PLANNING_INTERFACE_PLANNING_INTERFACE_ +#pragma once #include #include @@ -48,7 +47,7 @@ namespace planning_scene MOVEIT_CLASS_FORWARD(PlanningScene); } -/** \brief This namespace includes the base class for MoveIt! planners */ +/** \brief This namespace includes the base class for MoveIt planners */ namespace planning_interface { /** @@ -147,7 +146,7 @@ class PlanningContext MOVEIT_CLASS_FORWARD(PlannerManager); -/** \brief Base class for a MoveIt! planner */ +/** \brief Base class for a MoveIt planner */ class PlannerManager { public: @@ -213,5 +212,3 @@ class PlannerManager }; } // planning_interface - -#endif diff --git a/moveit_core/planning_interface/include/moveit/planning_interface/planning_request.h b/moveit_core/planning_interface/include/moveit/planning_interface/planning_request.h index 6138283043..a738f0a0df 100644 --- a/moveit_core/planning_interface/include/moveit/planning_interface/planning_request.h +++ b/moveit_core/planning_interface/include/moveit/planning_interface/planning_request.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_PLANNING_INTERFACE_PLANNING_REQUEST_ -#define MOVEIT_PLANNING_INTERFACE_PLANNING_REQUEST_ +#pragma once #include @@ -46,5 +45,3 @@ namespace planning_interface typedef moveit_msgs::MotionPlanRequest MotionPlanRequest; } // planning_interface - -#endif diff --git a/moveit_core/planning_interface/include/moveit/planning_interface/planning_response.h b/moveit_core/planning_interface/include/moveit/planning_interface/planning_response.h index c902ffd741..e05209921d 100644 --- a/moveit_core/planning_interface/include/moveit/planning_interface/planning_response.h +++ b/moveit_core/planning_interface/include/moveit/planning_interface/planning_response.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_PLANNING_INTERFACE_PLANNING_RESPONSE_ -#define MOVEIT_PLANNING_INTERFACE_PLANNING_RESPONSE_ +#pragma once #include #include @@ -68,5 +67,3 @@ struct MotionPlanDetailedResponse }; } // planning_interface - -#endif diff --git a/moveit_core/planning_request_adapter/CMakeLists.txt b/moveit_core/planning_request_adapter/CMakeLists.txt index 87038c1d31..401e955ded 100644 --- a/moveit_core/planning_request_adapter/CMakeLists.txt +++ b/moveit_core/planning_request_adapter/CMakeLists.txt @@ -8,6 +8,7 @@ add_dependencies(${MOVEIT_LIB_NAME} ${catkin_EXPORTED_TARGETS}) install(TARGETS ${MOVEIT_LIB_NAME} ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} - LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}) + LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}) install(DIRECTORY include/ DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}) diff --git a/moveit_core/planning_request_adapter/include/moveit/planning_request_adapter/planning_request_adapter.h b/moveit_core/planning_request_adapter/include/moveit/planning_request_adapter/planning_request_adapter.h index e950bfba11..daf9426ba0 100644 --- a/moveit_core/planning_request_adapter/include/moveit/planning_request_adapter/planning_request_adapter.h +++ b/moveit_core/planning_request_adapter/include/moveit/planning_request_adapter/planning_request_adapter.h @@ -34,14 +34,12 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_PLANNING_REQUEST_ADAPTER_PLANNING_REQUEST_ADAPTER_ -#define MOVEIT_PLANNING_REQUEST_ADAPTER_PLANNING_REQUEST_ADAPTER_ +#pragma once #include #include #include #include -#include /** \brief Generic interface to adapting motion planning requests */ namespace planning_request_adapter @@ -64,21 +62,9 @@ class PlanningRequestAdapter { } - /// Initialize parameters using the passed NodeHandle - // TODO - Make initialize() a pure virtual function in O-turtle - virtual void initialize(const ros::NodeHandle& node_handle) - { - // Get name of derived adapter - std::string adapter_name = typeid(*this).name(); - // Try to demangle the name - int status; - std::string demangled_name = abi::__cxa_demangle(adapter_name.c_str(), NULL, NULL, &status); - if (status == 0) - adapter_name = demangled_name; - ROS_WARN_NAMED("planning_request_adapter", "Implementation of function initialize() is missing from '%s'." - "Any parameters should be loaded from the passed NodeHandle.", - adapter_name.c_str()); - } + /** \brief Initialize parameters using the passed NodeHandle + if no initialization is needed, simply implement as empty */ + virtual void initialize(const ros::NodeHandle& node_handle) = 0; /// Get a short string that identifies the planning request adapter virtual std::string getDescription() const @@ -134,5 +120,3 @@ class PlanningRequestAdapterChain std::vector adapters_; }; } - -#endif diff --git a/moveit_core/planning_scene/CMakeLists.txt b/moveit_core/planning_scene/CMakeLists.txt index 13174d3f1d..cfa146e3ec 100644 --- a/moveit_core/planning_scene/CMakeLists.txt +++ b/moveit_core/planning_scene/CMakeLists.txt @@ -18,7 +18,8 @@ add_dependencies(${MOVEIT_LIB_NAME} ${catkin_EXPORTED_TARGETS}) install(TARGETS ${MOVEIT_LIB_NAME} LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} - ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}) + ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}) install(DIRECTORY include/ DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}) if(CATKIN_ENABLE_TESTING) diff --git a/moveit_core/planning_scene/dox/planning_scene.dox b/moveit_core/planning_scene/dox/planning_scene.dox index 447b8f52b7..8bd31301b4 100644 --- a/moveit_core/planning_scene/dox/planning_scene.dox +++ b/moveit_core/planning_scene/dox/planning_scene.dox @@ -2,7 +2,7 @@ \page planning_scene_overview Planning Scene -The planning scene (planning_scene::PlanningScene) is the central class for motion planning in MoveIt!. A planning scene represents all the information needed to compute motion plans: The robot's current state, its representation (geometric, kinematic, dynamic) and the world representation. Using this information, things like forward kinematics, inverse kinematics, evaluation of constraints, collision checking, are all possible. +The planning scene (planning_scene::PlanningScene) is the central class for motion planning in MoveIt. A planning scene represents all the information needed to compute motion plans: The robot's current state, its representation (geometric, kinematic, dynamic) and the world representation. Using this information, things like forward kinematics, inverse kinematics, evaluation of constraints, collision checking, are all possible. The planning_scene::PlanningScene class is tightly connected to the planning_scene_monitor::PlannningSceneMonitor class, which maintains a planning scene using information from the ROS Parameter Server and subscription to topics. diff --git a/moveit_core/planning_scene/include/moveit/planning_scene/planning_scene.h b/moveit_core/planning_scene/include/moveit/planning_scene/planning_scene.h index 6503f7793a..6faff3b6aa 100644 --- a/moveit_core/planning_scene/include/moveit/planning_scene/planning_scene.h +++ b/moveit_core/planning_scene/include/moveit/planning_scene/planning_scene.h @@ -34,14 +34,14 @@ /* Author: Ioan Sucan, Acorn Pooley */ -#ifndef MOVEIT_PLANNING_SCENE_PLANNING_SCENE_ -#define MOVEIT_PLANNING_SCENE_PLANNING_SCENE_ +#pragma once #include #include #include #include #include +#include #include #include #include @@ -294,43 +294,31 @@ class PlanningScene : private boost::noncopyable, public std::enable_shared_from return world_; } - /** \brief Get the active collision detector for the world */ - const collision_detection::CollisionWorldConstPtr& getCollisionWorld() const + /** \brief Get the active collision environment */ + const collision_detection::CollisionEnvConstPtr& getCollisionEnv() const { - // we always have a world representation after configure is called. - return active_collision_->cworld_const_; + return active_collision_->getCollisionEnv(); } /** \brief Get the active collision detector for the robot */ - const collision_detection::CollisionRobotConstPtr& getCollisionRobot() const + const collision_detection::CollisionEnvConstPtr& getCollisionEnvUnpadded() const { - return active_collision_->getCollisionRobot(); - } - - /** \brief Get the active collision detector for the robot */ - const collision_detection::CollisionRobotConstPtr& getCollisionRobotUnpadded() const - { - return active_collision_->getCollisionRobotUnpadded(); + return active_collision_->getCollisionEnvUnpadded(); } /** \brief Get a specific collision detector for the world. If not found return active CollisionWorld. */ - const collision_detection::CollisionWorldConstPtr& - getCollisionWorld(const std::string& collision_detector_name) const; - - /** \brief Get a specific collision detector for the padded robot. If no found return active CollisionRobot. */ - const collision_detection::CollisionRobotConstPtr& - getCollisionRobot(const std::string& collision_detector_name) const; + const collision_detection::CollisionEnvConstPtr& getCollisionEnv(const std::string& collision_detector_name) const; /** \brief Get a specific collision detector for the unpadded robot. If no found return active unpadded * CollisionRobot. */ - const collision_detection::CollisionRobotConstPtr& - getCollisionRobotUnpadded(const std::string& collision_detector_name) const; + const collision_detection::CollisionEnvConstPtr& + getCollisionEnvUnpadded(const std::string& collision_detector_name) const; /** \brief Get the representation of the collision robot * This can be used to set padding and link scale on the active collision_robot. * NOTE: After modifying padding and scale on the active robot call * propogateRobotPadding() to copy it to all the other collision detectors. */ - const collision_detection::CollisionRobotPtr& getCollisionRobotNonConst(); + const collision_detection::CollisionEnvPtr& getCollisionEnvNonConst(); /** \brief Copy scale and padding from active CollisionRobot to other CollisionRobots. * This should be called after any changes are made to the scale or padding of the active @@ -502,7 +490,7 @@ class PlanningScene : private boost::noncopyable, public std::enable_shared_from const robot_state::RobotState& robot_state) const { // do self-collision checking with the unpadded version of the robot - getCollisionRobotUnpadded()->checkSelfCollision(req, res, robot_state, getAllowedCollisionMatrix()); + getCollisionEnvUnpadded()->checkSelfCollision(req, res, robot_state, getAllowedCollisionMatrix()); } /** \brief Check whether a specified state (\e robot_state) is in self collision, with respect to a given @@ -522,7 +510,7 @@ class PlanningScene : private boost::noncopyable, public std::enable_shared_from const collision_detection::AllowedCollisionMatrix& acm) const { // do self-collision checking with the unpadded version of the robot - getCollisionRobotUnpadded()->checkSelfCollision(req, res, robot_state, acm); + getCollisionEnvUnpadded()->checkSelfCollision(req, res, robot_state, acm); } /** \brief Get the names of the links that are involved in collisions for the current state */ @@ -625,7 +613,7 @@ class PlanningScene : private boost::noncopyable, public std::enable_shared_from */ double distanceToCollision(const robot_state::RobotState& robot_state) const { - return getCollisionWorld()->distanceRobot(*getCollisionRobot(), robot_state, getAllowedCollisionMatrix()); + return getCollisionEnv()->distanceRobot(robot_state, getAllowedCollisionMatrix()); } /** \brief The distance between the robot model at state \e robot_state to the nearest collision (ignoring @@ -640,7 +628,7 @@ class PlanningScene : private boost::noncopyable, public std::enable_shared_from * self-collisions), if the robot has no padding */ double distanceToCollisionUnpadded(const robot_state::RobotState& robot_state) const { - return getCollisionWorld()->distanceRobot(*getCollisionRobotUnpadded(), robot_state, getAllowedCollisionMatrix()); + return getCollisionEnvUnpadded()->distanceRobot(robot_state, getAllowedCollisionMatrix()); } /** \brief The distance between the robot model at state \e robot_state to the nearest collision, ignoring @@ -659,7 +647,7 @@ class PlanningScene : private boost::noncopyable, public std::enable_shared_from double distanceToCollision(const robot_state::RobotState& robot_state, const collision_detection::AllowedCollisionMatrix& acm) const { - return getCollisionWorld()->distanceRobot(*getCollisionRobot(), robot_state, acm); + return getCollisionEnv()->distanceRobot(robot_state, acm); } /** \brief The distance between the robot model at state \e robot_state to the nearest collision, ignoring @@ -678,7 +666,7 @@ class PlanningScene : private boost::noncopyable, public std::enable_shared_from double distanceToCollisionUnpadded(const robot_state::RobotState& robot_state, const collision_detection::AllowedCollisionMatrix& acm) const { - return getCollisionWorld()->distanceRobot(*getCollisionRobotUnpadded(), robot_state, acm); + return getCollisionEnvUnpadded()->distanceRobot(robot_state, acm); } /**@}*/ @@ -954,14 +942,16 @@ class PlanningScene : private boost::noncopyable, public std::enable_shared_from /** \brief Check if a message includes any information about a planning scene, or it is just a default, empty message. */ - static bool isEmpty(const moveit_msgs::PlanningScene& msg); + [[deprecated("Use moveit/utils/message_checks.h instead")]] static bool + isEmpty(const moveit_msgs::PlanningScene& msg); /** \brief Check if a message includes any information about a planning scene world, or it is just a default, empty * message. */ - static bool isEmpty(const moveit_msgs::PlanningSceneWorld& msg); + [[deprecated("Use moveit/utils/message_checks.h instead")]] static bool + isEmpty(const moveit_msgs::PlanningSceneWorld& msg); /** \brief Check if a message includes any information about a robot state, or it is just a default, empty message. */ - static bool isEmpty(const moveit_msgs::RobotState& msg); + [[deprecated("Use moveit/utils/message_checks.h instead")]] static bool isEmpty(const moveit_msgs::RobotState& msg); /** \brief Clone a planning scene. Even if the scene \e scene depends on a parent, the cloned scene will not. */ static PlanningScenePtr clone(const PlanningSceneConstPtr& scene); @@ -992,23 +982,21 @@ class PlanningScene : private boost::noncopyable, public std::enable_shared_from struct CollisionDetector { collision_detection::CollisionDetectorAllocatorPtr alloc_; - collision_detection::CollisionRobotPtr crobot_unpadded_; // if NULL use parent's - collision_detection::CollisionRobotConstPtr crobot_unpadded_const_; - collision_detection::CollisionRobotPtr crobot_; // if NULL use parent's - collision_detection::CollisionRobotConstPtr crobot_const_; + collision_detection::CollisionEnvPtr cenv_; // never NULL + collision_detection::CollisionEnvConstPtr cenv_const_; - collision_detection::CollisionWorldPtr cworld_; // never NULL - collision_detection::CollisionWorldConstPtr cworld_const_; + collision_detection::CollisionEnvPtr cenv_unpadded_; + collision_detection::CollisionEnvConstPtr cenv_unpadded_const_; CollisionDetectorConstPtr parent_; // may be NULL - const collision_detection::CollisionRobotConstPtr& getCollisionRobot() const + const collision_detection::CollisionEnvConstPtr& getCollisionEnv() const { - return crobot_const_ ? crobot_const_ : parent_->getCollisionRobot(); + return cenv_const_ ? cenv_const_ : parent_->getCollisionEnv(); } - const collision_detection::CollisionRobotConstPtr& getCollisionRobotUnpadded() const + const collision_detection::CollisionEnvConstPtr& getCollisionEnvUnpadded() const { - return crobot_unpadded_const_ ? crobot_unpadded_const_ : parent_->getCollisionRobotUnpadded(); + return cenv_unpadded_const_ ? cenv_unpadded_const_ : parent_->getCollisionEnvUnpadded(); } void findParent(const PlanningScene& scene); void copyPadding(const CollisionDetector& src); @@ -1056,5 +1044,3 @@ class PlanningScene : private boost::noncopyable, public std::enable_shared_from std::unique_ptr object_types_; }; } - -#endif diff --git a/moveit_core/planning_scene/src/planning_scene.cpp b/moveit_core/planning_scene/src/planning_scene.cpp index 37b62f4d85..ed8a94dac9 100644 --- a/moveit_core/planning_scene/src/planning_scene.cpp +++ b/moveit_core/planning_scene/src/planning_scene.cpp @@ -43,6 +43,7 @@ #include #include #include +#include #include #include #include @@ -96,25 +97,17 @@ class SceneTransforms : public robot_state::Transforms bool PlanningScene::isEmpty(const moveit_msgs::PlanningScene& msg) { - return msg.name.empty() && msg.fixed_frame_transforms.empty() && msg.allowed_collision_matrix.entry_names.empty() && - msg.link_padding.empty() && msg.link_scale.empty() && isEmpty(msg.robot_state) && isEmpty(msg.world); + return moveit::core::isEmpty(msg); } bool PlanningScene::isEmpty(const moveit_msgs::RobotState& msg) { - /* a state is empty if it includes no information and it is a diff; if the state is not a diff, then the implicit - information is - that the set of attached bodies is empty, so they must be cleared from the state to be updated */ - return static_cast(msg.is_diff) && msg.multi_dof_joint_state.joint_names.empty() && - msg.joint_state.name.empty() && msg.attached_collision_objects.empty() && msg.joint_state.position.empty() && - msg.joint_state.velocity.empty() && msg.joint_state.effort.empty() && - msg.multi_dof_joint_state.transforms.empty() && msg.multi_dof_joint_state.twist.empty() && - msg.multi_dof_joint_state.wrench.empty(); + return moveit::core::isEmpty(msg); } bool PlanningScene::isEmpty(const moveit_msgs::PlanningSceneWorld& msg) { - return msg.collision_objects.empty() && msg.octomap.octomap.data.empty(); + return moveit::core::isEmpty(msg); } PlanningScene::PlanningScene(const robot_model::RobotModelConstPtr& robot_model, @@ -208,15 +201,13 @@ PlanningScene::PlanningScene(const PlanningSceneConstPtr& parent) : parent_(pare detector->alloc_ = parent_detector->alloc_; detector->parent_ = parent_detector; - detector->cworld_ = detector->alloc_->allocateWorld(parent_detector->cworld_, world_); - detector->cworld_const_ = detector->cworld_; + detector->cenv_ = detector->alloc_->allocateEnv(parent_detector->cenv_, world_); + detector->cenv_const_ = detector->cenv_; - // leave these empty and use parent collision_robot_ unless/until a non-const one + // leave these empty and use parent collision_env_ unless/until a non-const one // is requested (e.g. to modify link padding or scale) - detector->crobot_.reset(); - detector->crobot_const_.reset(); - detector->crobot_unpadded_.reset(); - detector->crobot_unpadded_const_.reset(); + detector->cenv_unpadded_.reset(); + detector->cenv_unpadded_const_.reset(); } setActiveCollisionDetector(parent_->getActiveCollisionDetectorName()); } @@ -243,21 +234,12 @@ PlanningScenePtr PlanningScene::diff(const moveit_msgs::PlanningScene& msg) cons void PlanningScene::CollisionDetector::copyPadding(const PlanningScene::CollisionDetector& src) { - if (!crobot_) - { - alloc_->allocateRobot(parent_->getCollisionRobot()); - crobot_const_ = crobot_; - } - - crobot_->setLinkPadding(src.getCollisionRobot()->getLinkPadding()); - crobot_->setLinkScale(src.getCollisionRobot()->getLinkScale()); + cenv_->setLinkPadding(src.getCollisionEnv()->getLinkPadding()); + cenv_->setLinkScale(src.getCollisionEnv()->getLinkScale()); } void PlanningScene::propogateRobotPadding() { - if (!active_collision_->crobot_) - return; - for (std::pair& it : collision_) { if (it.second != active_collision_) @@ -292,25 +274,23 @@ void PlanningScene::addCollisionDetector(const collision_detection::CollisionDet detector->findParent(*this); - detector->cworld_ = detector->alloc_->allocateWorld(world_); - detector->cworld_const_ = detector->cworld_; + detector->cenv_ = detector->alloc_->allocateEnv(world_, getRobotModel()); + detector->cenv_const_ = detector->cenv_; - // Allocate CollisionRobot unless we can use the parent's crobot_. - // If active_collision_->crobot_ is non-NULL there is local padding and we cannot use the parent's crobot_. - if (!detector->parent_ || active_collision_->crobot_) + // if the current active detector is not the added one, copy its padding to the new one and allocate unpadded + if (detector != active_collision_) { - detector->crobot_ = detector->alloc_->allocateRobot(getRobotModel()); - detector->crobot_const_ = detector->crobot_; + detector->cenv_unpadded_ = detector->alloc_->allocateEnv(world_, getRobotModel()); + detector->cenv_unpadded_const_ = detector->cenv_unpadded_; - if (detector != active_collision_) - detector->copyPadding(*active_collision_); + detector->copyPadding(*active_collision_); } - // Allocate CollisionRobot unless we can use the parent's crobot_unpadded_. + // If we don't have a parent, allocate unpadded versions, otherwise use the parent's cenv_unpadded_. if (!detector->parent_) { - detector->crobot_unpadded_ = detector->alloc_->allocateRobot(getRobotModel()); - detector->crobot_unpadded_const_ = detector->crobot_unpadded_; + detector->cenv_unpadded_ = detector->alloc_->allocateEnv(world_, getRobotModel()); + detector->cenv_unpadded_const_ = detector->cenv_unpadded_; } } @@ -364,36 +344,22 @@ void PlanningScene::getCollisionDetectorNames(std::vector& names) c names.push_back(it.first); } -const collision_detection::CollisionWorldConstPtr& -PlanningScene::getCollisionWorld(const std::string& collision_detector_name) const -{ - CollisionDetectorConstIterator it = collision_.find(collision_detector_name); - if (it == collision_.end()) - { - ROS_ERROR_NAMED(LOGNAME, "Could not get CollisionWorld named '%s'. Returning active CollisionWorld '%s' instead", - collision_detector_name.c_str(), active_collision_->alloc_->getName().c_str()); - return active_collision_->cworld_const_; - } - - return it->second->cworld_const_; -} - -const collision_detection::CollisionRobotConstPtr& -PlanningScene::getCollisionRobot(const std::string& collision_detector_name) const +const collision_detection::CollisionEnvConstPtr& +PlanningScene::getCollisionEnv(const std::string& collision_detector_name) const { CollisionDetectorConstIterator it = collision_.find(collision_detector_name); if (it == collision_.end()) { ROS_ERROR_NAMED(LOGNAME, "Could not get CollisionRobot named '%s'. Returning active CollisionRobot '%s' instead", collision_detector_name.c_str(), active_collision_->alloc_->getName().c_str()); - return active_collision_->getCollisionRobot(); + return active_collision_->getCollisionEnv(); } - return it->second->getCollisionRobot(); + return it->second->getCollisionEnv(); } -const collision_detection::CollisionRobotConstPtr& -PlanningScene::getCollisionRobotUnpadded(const std::string& collision_detector_name) const +const collision_detection::CollisionEnvConstPtr& +PlanningScene::getCollisionEnvUnpadded(const std::string& collision_detector_name) const { CollisionDetectorConstIterator it = collision_.find(collision_detector_name); if (it == collision_.end()) @@ -401,10 +367,10 @@ PlanningScene::getCollisionRobotUnpadded(const std::string& collision_detector_n ROS_ERROR_NAMED(LOGNAME, "Could not get CollisionRobotUnpadded named '%s'. " "Returning active CollisionRobotUnpadded '%s' instead", collision_detector_name.c_str(), active_collision_->alloc_->getName().c_str()); - return active_collision_->getCollisionRobotUnpadded(); + return active_collision_->getCollisionEnvUnpadded(); } - return it->second->getCollisionRobotUnpadded(); + return it->second->getCollisionEnvUnpadded(); } void PlanningScene::clearDiffs() @@ -427,20 +393,18 @@ void PlanningScene::clearDiffs() if (it.second->parent_) { - it.second->crobot_.reset(); - it.second->crobot_const_.reset(); - it.second->crobot_unpadded_.reset(); - it.second->crobot_unpadded_const_.reset(); + it.second->cenv_unpadded_.reset(); + it.second->cenv_unpadded_const_.reset(); - it.second->cworld_ = it.second->alloc_->allocateWorld(it.second->parent_->cworld_, world_); - it.second->cworld_const_ = it.second->cworld_; + it.second->cenv_ = it.second->alloc_->allocateEnv(it.second->parent_->cenv_, world_); + it.second->cenv_const_ = it.second->cenv_; } else { it.second->copyPadding(*parent_->active_collision_); - it.second->cworld_ = it.second->alloc_->allocateWorld(world_); - it.second->cworld_const_ = it.second->cworld_; + it.second->cenv_ = it.second->alloc_->allocateEnv(it.second->parent_->cenv_, world_); + it.second->cenv_const_ = it.second->cenv_; } } @@ -478,13 +442,10 @@ void PlanningScene::pushDiffs(const PlanningScenePtr& scene) if (acm_) scene->getAllowedCollisionMatrixNonConst() = *acm_; - if (active_collision_->crobot_) - { - collision_detection::CollisionRobotPtr active_crobot = scene->getCollisionRobotNonConst(); - active_crobot->setLinkPadding(active_collision_->crobot_->getLinkPadding()); - active_crobot->setLinkScale(active_collision_->crobot_->getLinkScale()); - scene->propogateRobotPadding(); - } + collision_detection::CollisionEnvPtr active_cenv = scene->getCollisionEnvNonConst(); + active_cenv->setLinkPadding(active_collision_->cenv_->getLinkPadding()); + active_cenv->setLinkScale(active_collision_->cenv_->getLinkScale()); + scene->propogateRobotPadding(); if (world_diff_) { @@ -526,12 +487,12 @@ void PlanningScene::checkCollision(const collision_detection::CollisionRequest& const robot_state::RobotState& robot_state) const { // check collision with the world using the padded version - getCollisionWorld()->checkRobotCollision(req, res, *getCollisionRobot(), robot_state, getAllowedCollisionMatrix()); + getCollisionEnv()->checkRobotCollision(req, res, robot_state, getAllowedCollisionMatrix()); if (!res.collision || (req.contacts && res.contacts.size() < req.max_contacts)) { // do self-collision checking with the unpadded version of the robot - getCollisionRobotUnpadded()->checkSelfCollision(req, res, robot_state, getAllowedCollisionMatrix()); + getCollisionEnvUnpadded()->checkSelfCollision(req, res, robot_state, getAllowedCollisionMatrix()); } } @@ -550,11 +511,11 @@ void PlanningScene::checkCollision(const collision_detection::CollisionRequest& const collision_detection::AllowedCollisionMatrix& acm) const { // check collision with the world using the padded version - getCollisionWorld()->checkRobotCollision(req, res, *getCollisionRobot(), robot_state, acm); + getCollisionEnv()->checkRobotCollision(req, res, robot_state, acm); // do self-collision checking with the unpadded version of the robot if (!res.collision || (req.contacts && res.contacts.size() < req.max_contacts)) - getCollisionRobotUnpadded()->checkSelfCollision(req, res, robot_state, acm); + getCollisionEnvUnpadded()->checkSelfCollision(req, res, robot_state, acm); } void PlanningScene::checkCollisionUnpadded(const collision_detection::CollisionRequest& req, @@ -572,12 +533,12 @@ void PlanningScene::checkCollisionUnpadded(const collision_detection::CollisionR const collision_detection::AllowedCollisionMatrix& acm) const { // check collision with the world using the unpadded version - getCollisionWorld()->checkRobotCollision(req, res, *getCollisionRobotUnpadded(), robot_state, acm); + getCollisionEnvUnpadded()->checkRobotCollision(req, res, robot_state, acm); // do self-collision checking with the unpadded version of the robot if (!res.collision || (req.contacts && res.contacts.size() < req.max_contacts)) { - getCollisionRobotUnpadded()->checkSelfCollision(req, res, robot_state, acm); + getCollisionEnvUnpadded()->checkSelfCollision(req, res, robot_state, acm); } } @@ -627,15 +588,9 @@ void PlanningScene::getCollidingLinks(std::vector& links, const rob } } -const collision_detection::CollisionRobotPtr& PlanningScene::getCollisionRobotNonConst() +const collision_detection::CollisionEnvPtr& PlanningScene::getCollisionEnvNonConst() { - if (!active_collision_->crobot_) - { - active_collision_->crobot_ = - active_collision_->alloc_->allocateRobot(active_collision_->parent_->getCollisionRobot()); - active_collision_->crobot_const_ = active_collision_->crobot_; - } - return active_collision_->crobot_; + return active_collision_->cenv_; } robot_state::RobotState& PlanningScene::getCurrentStateNonConst() @@ -724,16 +679,8 @@ void PlanningScene::getPlanningSceneDiffMsg(moveit_msgs::PlanningScene& scene_ms else scene_msg.allowed_collision_matrix = moveit_msgs::AllowedCollisionMatrix(); - if (active_collision_->crobot_) - { - active_collision_->crobot_->getPadding(scene_msg.link_padding); - active_collision_->crobot_->getScale(scene_msg.link_scale); - } - else - { - scene_msg.link_padding.clear(); - scene_msg.link_scale.clear(); - } + active_collision_->cenv_->getPadding(scene_msg.link_padding); + active_collision_->cenv_->getScale(scene_msg.link_scale); scene_msg.object_colors.clear(); if (object_colors_) @@ -819,7 +766,7 @@ bool PlanningScene::getCollisionObjectMsg(moveit_msgs::CollisionObject& collisio collision_obj.header.frame_id = getPlanningFrame(); collision_obj.id = ns; collision_obj.operation = moveit_msgs::CollisionObject::ADD; - collision_detection::CollisionWorld::ObjectConstPtr obj = world_->getObject(ns); + collision_detection::CollisionEnv::ObjectConstPtr obj = world_->getObject(ns); if (!obj) return false; ShapeVisitorAddToCollisionObject sv(&collision_obj); @@ -891,7 +838,7 @@ bool PlanningScene::getOctomapMsg(octomap_msgs::OctomapWithPose& octomap) const octomap.header.frame_id = getPlanningFrame(); octomap.octomap = octomap_msgs::Octomap(); - collision_detection::CollisionWorld::ObjectConstPtr map = world_->getObject(OCTOMAP_NS); + collision_detection::CollisionEnv::ObjectConstPtr map = world_->getObject(OCTOMAP_NS); if (map) { if (map->shapes_.size() == 1) @@ -931,8 +878,8 @@ void PlanningScene::getPlanningSceneMsg(moveit_msgs::PlanningScene& scene_msg) c robot_state::robotStateToRobotStateMsg(getCurrentState(), scene_msg.robot_state); getAllowedCollisionMatrix().getMessage(scene_msg.allowed_collision_matrix); - getCollisionRobot()->getPadding(scene_msg.link_padding); - getCollisionRobot()->getScale(scene_msg.link_scale); + getCollisionEnv()->getPadding(scene_msg.link_padding); + getCollisionEnv()->getScale(scene_msg.link_scale); getObjectColorMsgs(scene_msg.object_colors); @@ -978,8 +925,8 @@ void PlanningScene::getPlanningSceneMsg(moveit_msgs::PlanningScene& scene_msg, if (comp.components & moveit_msgs::PlanningSceneComponents::LINK_PADDING_AND_SCALING) { - getCollisionRobot()->getPadding(scene_msg.link_padding); - getCollisionRobot()->getScale(scene_msg.link_scale); + getCollisionEnv()->getPadding(scene_msg.link_padding); + getCollisionEnv()->getScale(scene_msg.link_scale); } if (comp.components & moveit_msgs::PlanningSceneComponents::OBJECT_COLORS) @@ -1016,7 +963,7 @@ void PlanningScene::saveGeometryToStream(std::ostream& out) const for (const std::string& id : ids) if (id != OCTOMAP_NS) { - collision_detection::CollisionWorld::ObjectConstPtr obj = world_->getObject(id); + collision_detection::CollisionEnv::ObjectConstPtr obj = world_->getObject(id); if (obj) { out << "* " << id << std::endl; @@ -1191,15 +1138,10 @@ void PlanningScene::decoupleParent() for (std::pair& it : collision_) { - if (!it.second->crobot_) - { - it.second->crobot_ = it.second->alloc_->allocateRobot(it.second->parent_->getCollisionRobot()); - it.second->crobot_const_ = it.second->crobot_; - } - if (!it.second->crobot_unpadded_) + if (!it.second->cenv_unpadded_) { - it.second->crobot_unpadded_ = it.second->alloc_->allocateRobot(it.second->parent_->getCollisionRobotUnpadded()); - it.second->crobot_unpadded_const_ = it.second->crobot_unpadded_; + it.second->cenv_unpadded_ = it.second->alloc_->allocateEnv(it.second->parent_->getCollisionEnvUnpadded(), world_); + it.second->cenv_unpadded_const_ = it.second->cenv_unpadded_; } it.second->parent_.reset(); } @@ -1272,13 +1214,8 @@ bool PlanningScene::setPlanningSceneDiffMsg(const moveit_msgs::PlanningScene& sc { for (std::pair& it : collision_) { - if (!it.second->crobot_) - { - it.second->crobot_ = it.second->alloc_->allocateRobot(it.second->parent_->getCollisionRobot()); - it.second->crobot_const_ = it.second->crobot_; - } - it.second->crobot_->setPadding(scene_msg.link_padding); - it.second->crobot_->setScale(scene_msg.link_scale); + it.second->cenv_->setPadding(scene_msg.link_padding); + it.second->cenv_->setScale(scene_msg.link_scale); } } @@ -1315,13 +1252,8 @@ bool PlanningScene::setPlanningSceneMsg(const moveit_msgs::PlanningScene& scene_ acm_.reset(new collision_detection::AllowedCollisionMatrix(scene_msg.allowed_collision_matrix)); for (std::pair& it : collision_) { - if (!it.second->crobot_) - { - it.second->crobot_ = it.second->alloc_->allocateRobot(it.second->parent_->getCollisionRobot()); - it.second->crobot_const_ = it.second->crobot_; - } - it.second->crobot_->setPadding(scene_msg.link_padding); - it.second->crobot_->setScale(scene_msg.link_scale); + it.second->cenv_->setPadding(scene_msg.link_padding); + it.second->cenv_->setScale(scene_msg.link_scale); } object_colors_.reset(new ObjectColorMap()); for (const moveit_msgs::ObjectColor& object_color : scene_msg.object_colors) @@ -1409,7 +1341,7 @@ void PlanningScene::processOctomapMsg(const octomap_msgs::OctomapWithPose& map) void PlanningScene::processOctomapPtr(const std::shared_ptr& octree, const Eigen::Isometry3d& t) { - collision_detection::CollisionWorld::ObjectConstPtr map = world_->getObject(OCTOMAP_NS); + collision_detection::CollisionEnv::ObjectConstPtr map = world_->getObject(OCTOMAP_NS); if (map) { if (map->shapes_.size() == 1) @@ -1510,7 +1442,7 @@ bool PlanningScene::processAttachedCollisionObjectMsg(const moveit_msgs::Attache // TODO(felixvd): This code may be duplicated in robot_state/conversions.cpp // STEP 1.1: Get shapes and poses from existing world object or message. - collision_detection::CollisionWorld::ObjectConstPtr obj_in_world = world_->getObject(object.object.id); + collision_detection::CollisionEnv::ObjectConstPtr obj_in_world = world_->getObject(object.object.id); if (object.object.operation == moveit_msgs::CollisionObject::ADD && object.object.primitives.empty() && object.object.meshes.empty() && object.object.planes.empty()) { diff --git a/moveit_core/planning_scene/test/test_planning_scene.cpp b/moveit_core/planning_scene/test/test_planning_scene.cpp index 73b68186e3..9d93148edb 100644 --- a/moveit_core/planning_scene/test/test_planning_scene.cpp +++ b/moveit_core/planning_scene/test/test_planning_scene.cpp @@ -36,6 +36,7 @@ #include #include +#include #include #include #include @@ -104,10 +105,10 @@ TEST(PlanningScene, LoadRestoreDiff) moveit_msgs::PlanningScene ps_msg; ps_msg.robot_state.is_diff = true; - EXPECT_TRUE(planning_scene::PlanningScene::isEmpty(ps_msg)); + EXPECT_TRUE(moveit::core::isEmpty(ps_msg)); ps->getPlanningSceneMsg(ps_msg); ps->setPlanningSceneMsg(ps_msg); - EXPECT_FALSE(planning_scene::PlanningScene::isEmpty(ps_msg)); + EXPECT_FALSE(moveit::core::isEmpty(ps_msg)); EXPECT_TRUE(world.hasObject("sphere")); planning_scene::PlanningScenePtr next = ps->diff(); diff --git a/moveit_core/profiler/CMakeLists.txt b/moveit_core/profiler/CMakeLists.txt index 92671fd8cd..803b7ebdb8 100644 --- a/moveit_core/profiler/CMakeLists.txt +++ b/moveit_core/profiler/CMakeLists.txt @@ -7,5 +7,6 @@ target_link_libraries(${MOVEIT_LIB_NAME} ${catkin_LIBRARIES} ${urdfdom_LIBRARIES install(TARGETS ${MOVEIT_LIB_NAME} LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} - ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}) + ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}) install(DIRECTORY include/ DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}) diff --git a/moveit_core/profiler/include/moveit/profiler/profiler.h b/moveit_core/profiler/include/moveit/profiler/profiler.h index b996af16f7..554ec2b755 100644 --- a/moveit_core/profiler/include/moveit/profiler/profiler.h +++ b/moveit_core/profiler/include/moveit/profiler/profiler.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_PROFILER_ -#define MOVEIT_PROFILER_ +#pragma once #define MOVEIT_ENABLE_PROFILING 1 @@ -448,5 +447,3 @@ class Profiler } #endif - -#endif diff --git a/moveit_core/robot_model/CMakeLists.txt b/moveit_core/robot_model/CMakeLists.txt index a3383680b3..40a6199da4 100644 --- a/moveit_core/robot_model/CMakeLists.txt +++ b/moveit_core/robot_model/CMakeLists.txt @@ -27,5 +27,6 @@ endif() install(TARGETS ${MOVEIT_LIB_NAME} LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} - ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}) + ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}) install(DIRECTORY include/ DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}) diff --git a/moveit_core/robot_model/include/moveit/robot_model/aabb.h b/moveit_core/robot_model/include/moveit/robot_model/aabb.h index 2ed8ebf382..5c1b84df13 100644 --- a/moveit_core/robot_model/include/moveit/robot_model/aabb.h +++ b/moveit_core/robot_model/include/moveit/robot_model/aabb.h @@ -34,8 +34,7 @@ /* Author: Martin Pecka */ -#ifndef MOVEIT_ROBOT_MODEL_AABB_H -#define MOVEIT_ROBOT_MODEL_AABB_H +#pragma once #include @@ -52,5 +51,3 @@ class AABB : public Eigen::AlignedBox3d }; } } - -#endif // MOVEIT_ROBOT_MODEL_AABB_H diff --git a/moveit_core/robot_model/include/moveit/robot_model/fixed_joint_model.h b/moveit_core/robot_model/include/moveit/robot_model/fixed_joint_model.h index 265b13576c..d10b1622a7 100644 --- a/moveit_core/robot_model/include/moveit/robot_model/fixed_joint_model.h +++ b/moveit_core/robot_model/include/moveit/robot_model/fixed_joint_model.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_CORE_ROBOT_MODEL_FIXED_JOINT_MODEL_ -#define MOVEIT_CORE_ROBOT_MODEL_FIXED_JOINT_MODEL_ +#pragma once #include @@ -68,5 +67,3 @@ class FixedJointModel : public JointModel }; } } - -#endif diff --git a/moveit_core/robot_model/include/moveit/robot_model/floating_joint_model.h b/moveit_core/robot_model/include/moveit/robot_model/floating_joint_model.h index a39a8471e5..6d721d9bf5 100644 --- a/moveit_core/robot_model/include/moveit/robot_model/floating_joint_model.h +++ b/moveit_core/robot_model/include/moveit/robot_model/floating_joint_model.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_CORE_ROBOT_MODEL_FLOATING_JOINT_MODEL_ -#define MOVEIT_CORE_ROBOT_MODEL_FLOATING_JOINT_MODEL_ +#pragma once #include @@ -91,5 +90,3 @@ class FloatingJointModel : public JointModel }; } } - -#endif diff --git a/moveit_core/robot_model/include/moveit/robot_model/joint_model.h b/moveit_core/robot_model/include/moveit/robot_model/joint_model.h index 982ae78bb8..aa07321d73 100644 --- a/moveit_core/robot_model/include/moveit/robot_model/joint_model.h +++ b/moveit_core/robot_model/include/moveit/robot_model/joint_model.h @@ -35,8 +35,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_CORE_ROBOT_MODEL_JOINT_MODEL_ -#define MOVEIT_CORE_ROBOT_MODEL_JOINT_MODEL_ +#pragma once #include #include @@ -521,5 +520,3 @@ class JointModel std::ostream& operator<<(std::ostream& out, const VariableBounds& b); } } - -#endif diff --git a/moveit_core/robot_model/include/moveit/robot_model/joint_model_group.h b/moveit_core/robot_model/include/moveit/robot_model/joint_model_group.h index d46e1fc748..108e1a5ab3 100644 --- a/moveit_core/robot_model/include/moveit/robot_model/joint_model_group.h +++ b/moveit_core/robot_model/include/moveit/robot_model/joint_model_group.h @@ -35,8 +35,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_CORE_ROBOT_MODEL_JOINT_MODEL_GROUP_ -#define MOVEIT_CORE_ROBOT_MODEL_JOINT_MODEL_GROUP_ +#pragma once #include #include @@ -745,5 +744,3 @@ class JointModelGroup }; } } - -#endif diff --git a/moveit_core/robot_model/include/moveit/robot_model/link_model.h b/moveit_core/robot_model/include/moveit/robot_model/link_model.h index decebc2a82..d586dfded0 100644 --- a/moveit_core/robot_model/include/moveit/robot_model/link_model.h +++ b/moveit_core/robot_model/include/moveit/robot_model/link_model.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_CORE_ROBOT_MODEL_LINK_MODEL_ -#define MOVEIT_CORE_ROBOT_MODEL_LINK_MODEL_ +#pragma once #include #include @@ -283,5 +282,3 @@ class LinkModel }; } } - -#endif diff --git a/moveit_core/robot_model/include/moveit/robot_model/planar_joint_model.h b/moveit_core/robot_model/include/moveit/robot_model/planar_joint_model.h index 0900e0b8d9..3524250e41 100644 --- a/moveit_core/robot_model/include/moveit/robot_model/planar_joint_model.h +++ b/moveit_core/robot_model/include/moveit/robot_model/planar_joint_model.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_CORE_ROBOT_MODEL_PLANAR_JOINT_MODEL_ -#define MOVEIT_CORE_ROBOT_MODEL_PLANAR_JOINT_MODEL_ +#pragma once #include @@ -86,5 +85,3 @@ class PlanarJointModel : public JointModel }; } } - -#endif diff --git a/moveit_core/robot_model/include/moveit/robot_model/prismatic_joint_model.h b/moveit_core/robot_model/include/moveit/robot_model/prismatic_joint_model.h index f745947e18..87678c55a5 100644 --- a/moveit_core/robot_model/include/moveit/robot_model/prismatic_joint_model.h +++ b/moveit_core/robot_model/include/moveit/robot_model/prismatic_joint_model.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_CORE_ROBOT_MODEL_PRISMATIC_JOINT_MODEL_ -#define MOVEIT_CORE_ROBOT_MODEL_PRISMATIC_JOINT_MODEL_ +#pragma once #include @@ -86,5 +85,3 @@ class PrismaticJointModel : public JointModel }; } } - -#endif diff --git a/moveit_core/robot_model/include/moveit/robot_model/revolute_joint_model.h b/moveit_core/robot_model/include/moveit/robot_model/revolute_joint_model.h index 33adc02839..76322c2b04 100644 --- a/moveit_core/robot_model/include/moveit/robot_model/revolute_joint_model.h +++ b/moveit_core/robot_model/include/moveit/robot_model/revolute_joint_model.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_CORE_ROBOT_MODEL_REVOLUTE_JOINT_MODEL_ -#define MOVEIT_CORE_ROBOT_MODEL_REVOLUTE_JOINT_MODEL_ +#pragma once #include @@ -97,5 +96,3 @@ class RevoluteJointModel : public JointModel }; } } - -#endif diff --git a/moveit_core/robot_model/include/moveit/robot_model/robot_model.h b/moveit_core/robot_model/include/moveit/robot_model/robot_model.h index 2131a6f1a8..835c675c04 100644 --- a/moveit_core/robot_model/include/moveit/robot_model/robot_model.h +++ b/moveit_core/robot_model/include/moveit/robot_model/robot_model.h @@ -35,8 +35,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_CORE_ROBOT_MODEL_ -#define MOVEIT_CORE_ROBOT_MODEL_ +#pragma once #include #include @@ -54,10 +53,10 @@ #include #include -/** \brief Main namespace for MoveIt! */ +/** \brief Main namespace for MoveIt */ namespace moveit { -/** \brief Core components of MoveIt! */ +/** \brief Core components of MoveIt */ namespace core { MOVEIT_CLASS_FORWARD(RobotModel); @@ -621,5 +620,3 @@ class RobotModel namespace robot_model = moveit::core; namespace robot_state = moveit::core; - -#endif diff --git a/moveit_core/robot_state/CMakeLists.txt b/moveit_core/robot_state/CMakeLists.txt index d2cffe5f6c..90b30c9db7 100644 --- a/moveit_core/robot_state/CMakeLists.txt +++ b/moveit_core/robot_state/CMakeLists.txt @@ -19,7 +19,8 @@ add_dependencies(${MOVEIT_LIB_NAME} ${catkin_EXPORTED_TARGETS}) install(TARGETS ${MOVEIT_LIB_NAME} LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} - ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}) + ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}) install(DIRECTORY include/ DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}) # Unit tests diff --git a/moveit_core/robot_state/include/moveit/robot_state/attached_body.h b/moveit_core/robot_state/include/moveit/robot_state/attached_body.h index 3453d3233d..bf5a4f5ec6 100644 --- a/moveit_core/robot_state/include/moveit/robot_state/attached_body.h +++ b/moveit_core/robot_state/include/moveit/robot_state/attached_body.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_ROBOT_STATE_ATTACHED_BODY_ -#define MOVEIT_ROBOT_STATE_ATTACHED_BODY_ +#pragma once #include #include @@ -184,5 +183,3 @@ class AttachedBody }; } } - -#endif diff --git a/moveit_core/robot_state/include/moveit/robot_state/cartesian_interpolator.h b/moveit_core/robot_state/include/moveit/robot_state/cartesian_interpolator.h index a5447f2f85..ecf843c99a 100644 --- a/moveit_core/robot_state/include/moveit/robot_state/cartesian_interpolator.h +++ b/moveit_core/robot_state/include/moveit/robot_state/cartesian_interpolator.h @@ -36,8 +36,7 @@ /* Author: Ioan Sucan, Mike Lautman */ -#ifndef MOVEIT_CORE_ROBOT_STATE_CARTESIAN_INTERPOLATOR_ -#define MOVEIT_CORE_ROBOT_STATE_CARTESIAN_INTERPOLATOR_ +#pragma once #include @@ -215,5 +214,3 @@ class CartesianInterpolator } // end of namespace core } // end of namespace moveit - -#endif diff --git a/moveit_core/robot_state/include/moveit/robot_state/conversions.h b/moveit_core/robot_state/include/moveit/robot_state/conversions.h index dadd10adbc..e5d1017d33 100644 --- a/moveit_core/robot_state/include/moveit/robot_state/conversions.h +++ b/moveit_core/robot_state/include/moveit/robot_state/conversions.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan, Dave Coleman */ -#ifndef MOVEIT_ROBOT_STATE_CONVERSIONS_ -#define MOVEIT_ROBOT_STATE_CONVERSIONS_ +#pragma once #include #include @@ -47,18 +46,18 @@ namespace moveit namespace core { /** - * @brief Convert a joint state to a MoveIt! robot state + * @brief Convert a joint state to a MoveIt robot state * @param joint_state The input joint state to be converted - * @param state The resultant MoveIt! robot state + * @param state The resultant MoveIt robot state * @return True if successful, false if failed for any reason */ bool jointStateToRobotState(const sensor_msgs::JointState& joint_state, RobotState& state); /** - * @brief Convert a robot state msg (with accompanying extra transforms) to a MoveIt! robot state + * @brief Convert a robot state msg (with accompanying extra transforms) to a MoveIt robot state * @param tf An instance of a transforms object * @param robot_state The input robot state msg - * @param state The resultant MoveIt! robot state + * @param state The resultant MoveIt robot state * @param copy_attached_bodies Flag to include attached objects in robot state copy * @return True if successful, false if failed for any reason */ @@ -66,9 +65,9 @@ bool robotStateMsgToRobotState(const Transforms& tf, const moveit_msgs::RobotSta bool copy_attached_bodies = true); /** - * @brief Convert a robot state msg (with accompanying extra transforms) to a MoveIt! robot state + * @brief Convert a robot state msg (with accompanying extra transforms) to a MoveIt robot state * @param robot_state The input robot state msg - * @param state The resultant MoveIt! robot state + * @param state The resultant MoveIt robot state * @param copy_attached_bodies Flag to include attached objects in robot state copy * @return True if successful, false if failed for any reason */ @@ -76,8 +75,8 @@ bool robotStateMsgToRobotState(const moveit_msgs::RobotState& robot_state, Robot bool copy_attached_bodies = true); /** - * @brief Convert a MoveIt! robot state to a robot state message - * @param state The input MoveIt! robot state object + * @brief Convert a MoveIt robot state to a robot state message + * @param state The input MoveIt robot state object * @param robot_state The resultant RobotState *message * @param copy_attached_bodies Flag to include attached objects in robot state copy */ @@ -86,33 +85,33 @@ void robotStateToRobotStateMsg(const RobotState& state, moveit_msgs::RobotState& /** * @brief Convert AttachedBodies to AttachedCollisionObjects - * @param attached_bodies The input MoveIt! attached body objects + * @param attached_bodies The input MoveIt attached body objects * @param attached_collision_objs The resultant AttachedCollisionObject messages */ void attachedBodiesToAttachedCollisionObjectMsgs( const std::vector& attached_bodies, std::vector& attached_collision_objs); /** - * @brief Convert a MoveIt! robot state to a joint state message - * @param state The input MoveIt! robot state object + * @brief Convert a MoveIt robot state to a joint state message + * @param state The input MoveIt robot state object * @param robot_state The resultant JointState message */ void robotStateToJointStateMsg(const RobotState& state, sensor_msgs::JointState& joint_state); /** - * @brief Convert a joint trajectory point to a MoveIt! robot state + * @brief Convert a joint trajectory point to a MoveIt robot state * @param joint_trajectory The input msg * @param point_id The index of the trajectory point in the joint trajectory. - * @param state The resultant MoveIt! robot state + * @param state The resultant MoveIt robot state * @return True if successful, false if failed for any reason */ bool jointTrajPointToRobotState(const trajectory_msgs::JointTrajectory& trajectory, std::size_t point_id, RobotState& state); /** - * @brief Convert a MoveIt! robot state to common separated values (CSV) on a single line that is + * @brief Convert a MoveIt robot state to common separated values (CSV) on a single line that is * outputted to a stream e.g. for file saving - * @param state - The input MoveIt! robot state object + * @param state - The input MoveIt robot state object * @param out - a file stream, or any other stream * @param include_header - flag to prefix the output with a line of joint names. * @param separator - allows to override the comma seperator with any symbol, such as a white space @@ -121,9 +120,9 @@ void robotStateToStream(const RobotState& state, std::ostream& out, bool include const std::string& separator = ","); /** - * @brief Convert a MoveIt! robot state to common separated values (CSV) on a single line that is + * @brief Convert a MoveIt robot state to common separated values (CSV) on a single line that is * outputted to a stream e.g. for file saving. This version can order by joint model groups - * @param state - The input MoveIt! robot state object + * @param state - The input MoveIt robot state object * @param out - a file stream, or any other stream * @param joint_group_ordering - output joints based on ordering of joint groups * @param include_header - flag to prefix the output with a line of joint names. @@ -135,7 +134,7 @@ void robotStateToStream(const RobotState& state, std::ostream& out, /** * \brief Convert a string of joint values from a file (CSV) or input source into a RobotState - * @param state - the output MoveIt! robot state object + * @param state - the output MoveIt robot state object * @param line - the input string of joint values * @param separator - allows to override the comma seperator with any symbol, such as a white space * \return true on success @@ -143,5 +142,3 @@ void robotStateToStream(const RobotState& state, std::ostream& out, void streamToRobotState(RobotState& state, const std::string& line, const std::string& separator = ","); } } - -#endif diff --git a/moveit_core/robot_state/include/moveit/robot_state/robot_state.h b/moveit_core/robot_state/include/moveit/robot_state/robot_state.h index 62750a6992..126b20baf9 100644 --- a/moveit_core/robot_state/include/moveit/robot_state/robot_state.h +++ b/moveit_core/robot_state/include/moveit/robot_state/robot_state.h @@ -35,8 +35,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_CORE_ROBOT_STATE_ -#define MOVEIT_CORE_ROBOT_STATE_ +#pragma once #include #include @@ -1592,10 +1591,10 @@ as the new values that correspond to the group */ void getAttachedBodies(std::vector& attached_bodies) const; /** \brief Get all bodies attached to a particular group the model corresponding to this state */ - void getAttachedBodies(std::vector& attached_bodies, const JointModelGroup* lm) const; + void getAttachedBodies(std::vector& attached_bodies, const JointModelGroup* group) const; /** \brief Get all bodies attached to a particular link in the model corresponding to this state */ - void getAttachedBodies(std::vector& attached_bodies, const LinkModel* lm) const; + void getAttachedBodies(std::vector& attached_bodies, const LinkModel* link_model) const; /** \brief Remove the attached body named \e id. Return false if the object was not found (and thus not removed). * Return true on success. */ @@ -1837,5 +1836,3 @@ as the new values that correspond to the group */ std::ostream& operator<<(std::ostream& out, const RobotState& s); } } - -#endif diff --git a/moveit_core/robot_state/src/robot_state.cpp b/moveit_core/robot_state/src/robot_state.cpp index cc945513c5..abf7034f98 100644 --- a/moveit_core/robot_state/src/robot_state.cpp +++ b/moveit_core/robot_state/src/robot_state.cpp @@ -912,11 +912,11 @@ void RobotState::getAttachedBodies(std::vector& attached_bo attached_bodies.push_back(it.second); } -void RobotState::getAttachedBodies(std::vector& attached_bodies, const LinkModel* lm) const +void RobotState::getAttachedBodies(std::vector& attached_bodies, const LinkModel* link_model) const { attached_bodies.clear(); for (const std::pair& it : attached_body_map_) - if (it.second->getAttachedLink() == lm) + if (it.second->getAttachedLink() == link_model) attached_bodies.push_back(it.second); } @@ -1109,12 +1109,12 @@ void RobotState::getRobotMarkers(visualization_msgs::MarkerArray& arr, const std for (const std::string& link_name : link_names) { ROS_DEBUG_NAMED(LOGNAME, "Trying to get marker for link '%s'", link_name.c_str()); - const LinkModel* lm = robot_model_->getLinkModel(link_name); - if (!lm) + const LinkModel* link_model = robot_model_->getLinkModel(link_name); + if (!link_model) continue; if (include_attached) for (const std::pair& it : attached_body_map_) - if (it.second->getAttachedLink() == lm) + if (it.second->getAttachedLink() == link_model) { for (std::size_t j = 0; j < it.second->getShapes().size(); ++j) { @@ -1132,37 +1132,38 @@ void RobotState::getRobotMarkers(visualization_msgs::MarkerArray& arr, const std } } - if (lm->getShapes().empty()) + if (link_model->getShapes().empty()) continue; - for (std::size_t j = 0; j < lm->getShapes().size(); ++j) + for (std::size_t j = 0; j < link_model->getShapes().size(); ++j) { visualization_msgs::Marker mark; mark.header.frame_id = robot_model_->getModelFrame(); mark.header.stamp = tm; // we prefer using the visual mesh, if a mesh is available and we have one body to render - const std::string& mesh_resource = lm->getVisualMeshFilename(); - if (mesh_resource.empty() || lm->getShapes().size() > 1) + const std::string& mesh_resource = link_model->getVisualMeshFilename(); + if (mesh_resource.empty() || link_model->getShapes().size() > 1) { - if (!shapes::constructMarkerFromShape(lm->getShapes()[j].get(), mark)) + if (!shapes::constructMarkerFromShape(link_model->getShapes()[j].get(), mark)) continue; // if the object is invisible (0 volume) we skip it if (fabs(mark.scale.x * mark.scale.y * mark.scale.z) < std::numeric_limits::epsilon()) continue; - mark.pose = tf2::toMsg(global_collision_body_transforms_[lm->getFirstCollisionBodyTransformIndex() + j]); + mark.pose = + tf2::toMsg(global_collision_body_transforms_[link_model->getFirstCollisionBodyTransformIndex() + j]); } else { mark.type = mark.MESH_RESOURCE; mark.mesh_use_embedded_materials = false; mark.mesh_resource = mesh_resource; - const Eigen::Vector3d& mesh_scale = lm->getVisualMeshScale(); + const Eigen::Vector3d& mesh_scale = link_model->getVisualMeshScale(); mark.scale.x = mesh_scale[0]; mark.scale.y = mesh_scale[1]; mark.scale.z = mesh_scale[2]; - mark.pose = tf2::toMsg(global_link_transforms_[lm->getLinkIndex()] * lm->getVisualMeshOrigin()); + mark.pose = tf2::toMsg(global_link_transforms_[link_model->getLinkIndex()] * link_model->getVisualMeshOrigin()); } arr.markers.push_back(mark); @@ -1231,7 +1232,7 @@ bool RobotState::getJacobian(const JointModelGroup* group, const LinkModel* link const JointModel* pjm = link->getParentJointModel(); if (pjm->getVariableCount() > 0) { - if (not group->hasJointModel(pjm->getName())) + if (!group->hasJointModel(pjm->getName())) { link = pjm->getParentLinkModel(); continue; @@ -1435,13 +1436,14 @@ bool RobotState::setToIKSolverFrame(Eigen::Isometry3d& pose, const std::string& // Bring the pose to the frame of the IK solver if (!Transforms::sameFrame(ik_frame, robot_model_->getModelFrame())) { - const LinkModel* lm = getLinkModel((!ik_frame.empty() && ik_frame[0] == '/') ? ik_frame.substr(1) : ik_frame); - if (!lm) + const LinkModel* link_model = + getLinkModel((!ik_frame.empty() && ik_frame[0] == '/') ? ik_frame.substr(1) : ik_frame); + if (!link_model) { ROS_ERROR_STREAM_NAMED(LOGNAME, "IK frame '" << ik_frame << "' does not exist."); return false; } - pose = getGlobalLinkTransform(lm).inverse() * pose; + pose = getGlobalLinkTransform(link_model).inverse() * pose; } return true; } @@ -1592,13 +1594,13 @@ bool RobotState::setFromIK(const JointModelGroup* jmg, const EigenSTL::vector_Is } if (pose_frame != solver_tip_frame) { - const robot_model::LinkModel* lm = getLinkModel(pose_frame); - if (!lm) + const robot_model::LinkModel* link_model = getLinkModel(pose_frame); + if (!link_model) { ROS_ERROR_STREAM_NAMED(LOGNAME, "Pose frame '" << pose_frame << "' does not exist."); return false; } - const robot_model::LinkTransformMap& fixed_links = lm->getAssociatedFixedTransforms(); + const robot_model::LinkTransformMap& fixed_links = link_model->getAssociatedFixedTransforms(); for (const std::pair& fixed_link : fixed_links) if (Transforms::sameFrame(fixed_link.first->getName(), solver_tip_frame)) { @@ -1803,10 +1805,10 @@ bool RobotState::setFromIKSubgroups(const JointModelGroup* jmg, const EigenSTL:: } if (pose_frame != solver_tip_frame) { - const robot_model::LinkModel* lm = getLinkModel(pose_frame); - if (!lm) + const robot_model::LinkModel* link_model = getLinkModel(pose_frame); + if (!link_model) return false; - const robot_model::LinkTransformMap& fixed_links = lm->getAssociatedFixedTransforms(); + const robot_model::LinkTransformMap& fixed_links = link_model->getAssociatedFixedTransforms(); for (const std::pair& fixed_link : fixed_links) if (fixed_link.first->getName() == solver_tip_frame) { @@ -2125,8 +2127,8 @@ void RobotState::printTransforms(std::ostream& out) const } out << "Link poses:" << std::endl; - const std::vector& lm = robot_model_->getLinkModels(); - for (const LinkModel* link : lm) + const std::vector& link_model = robot_model_->getLinkModels(); + for (const LinkModel* link : link_model) { out << " " << link->getName() << ": "; printTransform(global_link_transforms_[link->getLinkIndex()], out); @@ -2173,19 +2175,19 @@ void RobotState::getStateTreeJointString(std::ostream& ss, const JointModel* jm, ss << pfx << jm->getVariableNames()[i] << std::setw(12) << position_[jm->getFirstVariableIndex() + i] << std::endl; } - const LinkModel* lm = jm->getChildLinkModel(); + const LinkModel* link_model = jm->getChildLinkModel(); - ss << pfx << "Link: " << lm->getName() << std::endl; - getPoseString(ss, lm->getJointOriginTransform(), pfx + "joint_origin:"); + ss << pfx << "Link: " << link_model->getName() << std::endl; + getPoseString(ss, link_model->getJointOriginTransform(), pfx + "joint_origin:"); if (variable_joint_transforms_) { getPoseString(ss, variable_joint_transforms_[jm->getJointIndex()], pfx + "joint_variable:"); - getPoseString(ss, global_link_transforms_[lm->getLinkIndex()], pfx + "link_global:"); + getPoseString(ss, global_link_transforms_[link_model->getLinkIndex()], pfx + "link_global:"); } - for (std::vector::const_iterator it = lm->getChildJointModels().begin(); - it != lm->getChildJointModels().end(); ++it) - getStateTreeJointString(ss, *it, pfx, it + 1 == lm->getChildJointModels().end()); + for (std::vector::const_iterator it = link_model->getChildJointModels().begin(); + it != link_model->getChildJointModels().end(); ++it) + getStateTreeJointString(ss, *it, pfx, it + 1 == link_model->getChildJointModels().end()); } std::ostream& operator<<(std::ostream& out, const RobotState& s) diff --git a/moveit_core/robot_trajectory/CMakeLists.txt b/moveit_core/robot_trajectory/CMakeLists.txt index 9bcfe4ae86..29b89e5aa2 100644 --- a/moveit_core/robot_trajectory/CMakeLists.txt +++ b/moveit_core/robot_trajectory/CMakeLists.txt @@ -8,6 +8,7 @@ add_dependencies(${MOVEIT_LIB_NAME} ${catkin_EXPORTED_TARGETS}) install(TARGETS ${MOVEIT_LIB_NAME} ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} - LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}) + LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}) install(DIRECTORY include/ DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}) diff --git a/moveit_core/robot_trajectory/include/moveit/robot_trajectory/robot_trajectory.h b/moveit_core/robot_trajectory/include/moveit/robot_trajectory/robot_trajectory.h index 64f4fe309e..1601cd4279 100644 --- a/moveit_core/robot_trajectory/include/moveit/robot_trajectory/robot_trajectory.h +++ b/moveit_core/robot_trajectory/include/moveit/robot_trajectory/robot_trajectory.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan, Adam Leeper */ -#ifndef MOVEIT_ROBOT_TRAJECTORY_KINEMATIC_TRAJECTORY_ -#define MOVEIT_ROBOT_TRAJECTORY_KINEMATIC_TRAJECTORY_ +#pragma once #include #include @@ -202,6 +201,8 @@ class RobotTrajectory void clear(); + double getDuration() const; + double getAverageSegmentDuration() const; void getRobotTrajectoryMsg(moveit_msgs::RobotTrajectory& trajectory) const; @@ -263,5 +264,3 @@ class RobotTrajectory std::deque duration_from_previous_; }; } - -#endif diff --git a/moveit_core/robot_trajectory/src/robot_trajectory.cpp b/moveit_core/robot_trajectory/src/robot_trajectory.cpp index b0d5de749f..0c96f9c8dd 100644 --- a/moveit_core/robot_trajectory/src/robot_trajectory.cpp +++ b/moveit_core/robot_trajectory/src/robot_trajectory.cpp @@ -66,13 +66,17 @@ const std::string& RobotTrajectory::getGroupName() const return EMPTY; } +double RobotTrajectory::getDuration() const +{ + return std::accumulate(duration_from_previous_.begin(), duration_from_previous_.end(), 0.0); +} + double RobotTrajectory::getAverageSegmentDuration() const { if (duration_from_previous_.empty()) return 0.0; else - return std::accumulate(duration_from_previous_.begin(), duration_from_previous_.end(), 0.0) / - (double)duration_from_previous_.size(); + return getDuration() / static_cast(duration_from_previous_.size()); } void RobotTrajectory::swap(RobotTrajectory& other) diff --git a/moveit_core/sensor_manager/include/moveit/sensor_manager/sensor_manager.h b/moveit_core/sensor_manager/include/moveit/sensor_manager/sensor_manager.h index 66c05d4036..222e703504 100644 --- a/moveit_core/sensor_manager/include/moveit/sensor_manager/sensor_manager.h +++ b/moveit_core/sensor_manager/include/moveit/sensor_manager/sensor_manager.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_MOVEIT_SENSOR_MANAGER_ -#define MOVEIT_MOVEIT_SENSOR_MANAGER_ +#pragma once #include #include @@ -43,7 +42,7 @@ #include #include -/// Namespace for the base class of a MoveIt! sensor manager +/// Namespace for the base class of a MoveIt sensor manager namespace moveit_sensor_manager { /** \brief Define the frame of reference and the frustum of a sensor (usually this is a visual sensor) */ @@ -103,5 +102,3 @@ class MoveItSensorManager moveit_msgs::RobotTrajectory& sensor_trajectory) = 0; }; } - -#endif diff --git a/moveit_core/trajectory_processing/CMakeLists.txt b/moveit_core/trajectory_processing/CMakeLists.txt index fdd392a586..7c51bfbec5 100644 --- a/moveit_core/trajectory_processing/CMakeLists.txt +++ b/moveit_core/trajectory_processing/CMakeLists.txt @@ -13,7 +13,8 @@ add_dependencies(${MOVEIT_LIB_NAME} ${catkin_EXPORTED_TARGETS}) install(TARGETS ${MOVEIT_LIB_NAME} ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} - LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}) + LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}) install(DIRECTORY include/ DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}) diff --git a/moveit_core/trajectory_processing/include/moveit/trajectory_processing/iterative_spline_parameterization.h b/moveit_core/trajectory_processing/include/moveit/trajectory_processing/iterative_spline_parameterization.h index c3cb24cb12..67f4683047 100644 --- a/moveit_core/trajectory_processing/include/moveit/trajectory_processing/iterative_spline_parameterization.h +++ b/moveit_core/trajectory_processing/include/moveit/trajectory_processing/iterative_spline_parameterization.h @@ -35,8 +35,7 @@ /* Author: Ken Anderson */ -#ifndef MOVEIT_TRAJECTORY_PROCESSING_ITERATIVE_SPLINE_PARAMETERIZATION__ -#define MOVEIT_TRAJECTORY_PROCESSING_ITERATIVE_SPLINE_PARAMETERIZATION__ +#pragma once #include #include @@ -85,5 +84,3 @@ class IterativeSplineParameterization /// If false, move the 2nd and 2nd-last points. }; } - -#endif diff --git a/moveit_core/trajectory_processing/include/moveit/trajectory_processing/iterative_time_parameterization.h b/moveit_core/trajectory_processing/include/moveit/trajectory_processing/iterative_time_parameterization.h index 59b883f089..64e3d2b5b9 100644 --- a/moveit_core/trajectory_processing/include/moveit/trajectory_processing/iterative_time_parameterization.h +++ b/moveit_core/trajectory_processing/include/moveit/trajectory_processing/iterative_time_parameterization.h @@ -34,8 +34,7 @@ /* Author: Ken Anderson */ -#ifndef MOVEIT_TRAJECTORY_PROCESSING_ITERATIVE_PARABOLIC_SMOOTHER_ -#define MOVEIT_TRAJECTORY_PROCESSING_ITERATIVE_PARABOLIC_SMOOTHER_ +#pragma once #include #include @@ -69,5 +68,3 @@ class IterativeParabolicTimeParameterization double findT2(const double d1, const double d2, const double t1, double t2, const double a_max) const; }; } - -#endif diff --git a/moveit_core/trajectory_processing/include/moveit/trajectory_processing/time_optimal_trajectory_generation.h b/moveit_core/trajectory_processing/include/moveit/trajectory_processing/time_optimal_trajectory_generation.h index 21db426fd1..3e8268a92c 100644 --- a/moveit_core/trajectory_processing/include/moveit/trajectory_processing/time_optimal_trajectory_generation.h +++ b/moveit_core/trajectory_processing/include/moveit/trajectory_processing/time_optimal_trajectory_generation.h @@ -36,8 +36,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#ifndef MOVEIT_TRAJECTORY_PROCESSING_TIME_OPTIMAL_TRAJECTORY_GENERATION_H -#define MOVEIT_TRAJECTORY_PROCESSING_TIME_OPTIMAL_TRAJECTORY_GENERATION_H +#pragma once #include #include @@ -174,5 +173,3 @@ class TimeOptimalTrajectoryGeneration const double resample_dt_; }; } // namespace trajectory_processing - -#endif // MOVEIT_TRAJECTORY_PROCESSING_TIME_OPTIMAL_TRAJECTORY_GENERATION_H diff --git a/moveit_core/trajectory_processing/include/moveit/trajectory_processing/trajectory_tools.h b/moveit_core/trajectory_processing/include/moveit/trajectory_processing/trajectory_tools.h index 0c7658d39f..4c818af3e8 100644 --- a/moveit_core/trajectory_processing/include/moveit/trajectory_processing/trajectory_tools.h +++ b/moveit_core/trajectory_processing/include/moveit/trajectory_processing/trajectory_tools.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_TRAJECTORY_PROCESSING_TRAJECTORY_TOOLS_ -#define MOVEIT_TRAJECTORY_PROCESSING_TRAJECTORY_TOOLS_ +#pragma once #include @@ -44,5 +43,3 @@ namespace trajectory_processing bool isTrajectoryEmpty(const moveit_msgs::RobotTrajectory& trajectory); std::size_t trajectoryWaypointCount(const moveit_msgs::RobotTrajectory& trajectory); } - -#endif diff --git a/moveit_core/transforms/CMakeLists.txt b/moveit_core/transforms/CMakeLists.txt index 411b925a68..ac2bd777b3 100644 --- a/moveit_core/transforms/CMakeLists.txt +++ b/moveit_core/transforms/CMakeLists.txt @@ -8,7 +8,8 @@ add_dependencies(${MOVEIT_LIB_NAME} ${catkin_EXPORTED_TARGETS}) install(TARGETS ${MOVEIT_LIB_NAME} LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} - ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}) + ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}) install(DIRECTORY include/ DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}) # Unit tests diff --git a/moveit_core/transforms/include/moveit/transforms/transforms.h b/moveit_core/transforms/include/moveit/transforms/transforms.h index 949a61341f..6833b606aa 100644 --- a/moveit_core/transforms/include/moveit/transforms/transforms.h +++ b/moveit_core/transforms/include/moveit/transforms/transforms.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_TRANSFORMS_ -#define MOVEIT_TRANSFORMS_ +#pragma once #include #include @@ -200,5 +199,3 @@ class Transforms : private boost::noncopyable }; } } - -#endif diff --git a/moveit_core/transforms/src/transforms.cpp b/moveit_core/transforms/src/transforms.cpp index b853319172..190fb10d0d 100644 --- a/moveit_core/transforms/src/transforms.cpp +++ b/moveit_core/transforms/src/transforms.cpp @@ -47,7 +47,7 @@ Transforms::Transforms(const std::string& target_frame) : target_frame_(target_f { boost::trim(target_frame_); if (target_frame_.empty()) - ROS_ERROR_NAMED("transforms", "The target frame for MoveIt! Transforms cannot be empty."); + ROS_ERROR_NAMED("transforms", "The target frame for MoveIt Transforms cannot be empty."); else { transforms_map_[target_frame_] = Eigen::Isometry3d::Identity(); diff --git a/moveit_core/utils/CMakeLists.txt b/moveit_core/utils/CMakeLists.txt index 05f4bb4878..8a9aaa49bd 100644 --- a/moveit_core/utils/CMakeLists.txt +++ b/moveit_core/utils/CMakeLists.txt @@ -3,6 +3,7 @@ set(MOVEIT_LIB_NAME moveit_utils) add_library(${MOVEIT_LIB_NAME} src/lexical_casts.cpp src/xmlrpc_casts.cpp + src/message_checks.cpp ) target_link_libraries(${MOVEIT_LIB_NAME} ${catkin_LIBRARIES} ${Boost_LIBRARIES}) @@ -22,6 +23,7 @@ install( ${MOVEIT_LIB_NAME} ${MOVEIT_TEST_LIB_NAME} LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} - ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}) + ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}) install(DIRECTORY include/ DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}) diff --git a/moveit_core/utils/include/moveit/utils/lexical_casts.h b/moveit_core/utils/include/moveit/utils/lexical_casts.h index ce0fbcb5b5..3dc0e84ab8 100644 --- a/moveit_core/utils/include/moveit/utils/lexical_casts.h +++ b/moveit_core/utils/include/moveit/utils/lexical_casts.h @@ -34,8 +34,7 @@ /* Author: Simon Schmeisser */ -#ifndef MOVEIT_CORE_UTILS_LEXICAL_CASTS_ -#define MOVEIT_CORE_UTILS_LEXICAL_CASTS_ +#pragma once /** \file lexical_casts.h * \brief locale-agnostic conversion functions from floating point numbers to strings @@ -68,5 +67,3 @@ double toDouble(const std::string& s); float toFloat(const std::string& s); } } - -#endif diff --git a/moveit_core/utils/include/moveit/utils/message_checks.h b/moveit_core/utils/include/moveit/utils/message_checks.h new file mode 100644 index 0000000000..4ac3c0af8d --- /dev/null +++ b/moveit_core/utils/include/moveit/utils/message_checks.h @@ -0,0 +1,65 @@ +/********************************************************************* + * Software License Agreement (BSD License) + * + * Copyright (c) 2019, Universitaet Hamburg. + * 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 and/or other materials provided + * with the distribution. + * * Neither the name of Willow Garage nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * 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 OWNER 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. + *********************************************************************/ + +/* Author: Michael 'v4hn' Goerner */ + +#pragma once + +/** \file empty_msgs.h + * \brief Checks for empty MoveIt-related messages + * + */ + +#include +#include +#include +#include + +namespace moveit +{ +namespace core +{ +/** \brief Check if a message includes any information about a planning scene, or whether it is empty. */ +bool isEmpty(const moveit_msgs::PlanningScene& msg); + +/** \brief Check if a message includes any information about a planning scene world, or whether it is empty. */ +bool isEmpty(const moveit_msgs::PlanningSceneWorld& msg); + +/** \brief Check if a message includes any information about a robot state, or whether it is empty. */ +bool isEmpty(const moveit_msgs::RobotState& msg); + +/** \brief Check if a message specifies constraints */ +bool isEmpty(const moveit_msgs::Constraints& msg); +} +} diff --git a/moveit_core/utils/include/moveit/utils/robot_model_test_utils.h b/moveit_core/utils/include/moveit/utils/robot_model_test_utils.h index fa9bbf989c..652d7111b6 100644 --- a/moveit_core/utils/include/moveit/utils/robot_model_test_utils.h +++ b/moveit_core/utils/include/moveit/utils/robot_model_test_utils.h @@ -14,7 +14,7 @@ * copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials provided * with the distribution. - * * Neither the name of MoveIt! nor the names of its + * * Neither the name of MoveIt nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * @@ -35,8 +35,7 @@ /* Author: Bryce Willey */ /** \brief convenience functions and classes used for making simple robot models for testing. */ -#ifndef MOVEIT_CORE_UTILS_TEST_ -#define MOVEIT_CORE_UTILS_TEST_ +#pragma once #include #include @@ -196,5 +195,3 @@ class RobotModelBuilder }; } } - -#endif diff --git a/moveit_core/utils/src/message_checks.cpp b/moveit_core/utils/src/message_checks.cpp new file mode 100644 index 0000000000..b466e4768b --- /dev/null +++ b/moveit_core/utils/src/message_checks.cpp @@ -0,0 +1,73 @@ +/********************************************************************* + * Software License Agreement (BSD License) + * + * Copyright (c) 2019, Universitaet Hamburg. + * 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 and/or other materials provided + * with the distribution. + * * Neither the name of Hamburg University nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * 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 OWNER 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. + *********************************************************************/ + +/* Author: Michael Goerner */ + +#include + +namespace moveit +{ +namespace core +{ +bool isEmpty(const moveit_msgs::PlanningScene& msg) +{ + return msg.name.empty() && msg.fixed_frame_transforms.empty() && msg.allowed_collision_matrix.entry_names.empty() && + msg.link_padding.empty() && msg.link_scale.empty() && isEmpty(msg.robot_state) && isEmpty(msg.world); +} + +bool isEmpty(const moveit_msgs::PlanningSceneWorld& msg) +{ + return msg.collision_objects.empty() && msg.octomap.octomap.data.empty(); +} + +bool isEmpty(const moveit_msgs::RobotState& msg) +{ + /* a state is empty if it includes no information and it is a diff; if the state is not a diff, then the implicit + information is + that the set of attached bodies is empty, so they must be cleared from the state to be updated */ + return static_cast(msg.is_diff) && msg.multi_dof_joint_state.joint_names.empty() && + msg.joint_state.name.empty() && msg.attached_collision_objects.empty() && msg.joint_state.position.empty() && + msg.joint_state.velocity.empty() && msg.joint_state.effort.empty() && + msg.multi_dof_joint_state.transforms.empty() && msg.multi_dof_joint_state.twist.empty() && + msg.multi_dof_joint_state.wrench.empty(); +} + +bool isEmpty(const moveit_msgs::Constraints& constr) +{ + return constr.position_constraints.empty() && constr.orientation_constraints.empty() && + constr.visibility_constraints.empty() && constr.joint_constraints.empty(); +} + +} // namespace core +} // namespace moveit diff --git a/moveit_core/utils/src/robot_model_test_utils.cpp b/moveit_core/utils/src/robot_model_test_utils.cpp index 9a083176a3..e8bf5d3407 100644 --- a/moveit_core/utils/src/robot_model_test_utils.cpp +++ b/moveit_core/utils/src/robot_model_test_utils.cpp @@ -14,7 +14,7 @@ * copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials provided * with the distribution. - * * Neither the name of MoveIt! nor the names of its + * * Neither the name of MoveIt nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * @@ -120,14 +120,14 @@ void RobotModelBuilder::addChain(const std::string& section, const std::string& return; } // First link should already be added. - if (not urdf_model_->getLink(link_names[0])) + if (!urdf_model_->getLink(link_names[0])) { ROS_ERROR_NAMED(LOGNAME, "Link %s not present in builder yet!", link_names[0].c_str()); is_valid_ = false; return; } - if (not joint_origins.empty() && link_names.size() - 1 != joint_origins.size()) + if (!joint_origins.empty() && link_names.size() - 1 != joint_origins.size()) { ROS_ERROR_NAMED(LOGNAME, "There should be one more link (%zu) than there are joint origins (%zu)", link_names.size(), joint_origins.size()); @@ -152,7 +152,7 @@ void RobotModelBuilder::addChain(const std::string& section, const std::string& joint->name = link_names[i - 1] + "-" + link_names[i] + "-joint"; // Default to Identity transform for origins. joint->parent_to_joint_origin_transform.clear(); - if (not joint_origins.empty()) + if (!joint_origins.empty()) { geometry_msgs::Pose o = joint_origins[i - 1]; joint->parent_to_joint_origin_transform.position = urdf::Vector3(o.position.x, o.position.y, o.position.z); @@ -197,7 +197,7 @@ void RobotModelBuilder::addChain(const std::string& section, const std::string& void RobotModelBuilder::addInertial(const std::string& link_name, double mass, geometry_msgs::Pose origin, double ixx, double ixy, double ixz, double iyy, double iyz, double izz) { - if (not urdf_model_->getLink(link_name)) + if (!urdf_model_->getLink(link_name)) { ROS_ERROR_NAMED(LOGNAME, "Link %s not present in builder yet!", link_name.c_str()); is_valid_ = false; @@ -260,7 +260,7 @@ void RobotModelBuilder::addCollisionMesh(const std::string& link_name, const std void RobotModelBuilder::addLinkCollision(const std::string& link_name, const urdf::CollisionSharedPtr& collision, geometry_msgs::Pose origin) { - if (not urdf_model_->getLink(link_name)) + if (!urdf_model_->getLink(link_name)) { ROS_ERROR_NAMED(LOGNAME, "Link %s not present in builder yet!", link_name.c_str()); is_valid_ = false; @@ -278,7 +278,7 @@ void RobotModelBuilder::addLinkCollision(const std::string& link_name, const urd void RobotModelBuilder::addLinkVisual(const std::string& link_name, const urdf::VisualSharedPtr& vis, geometry_msgs::Pose origin) { - if (not urdf_model_->getLink(link_name)) + if (!urdf_model_->getLink(link_name)) { ROS_ERROR_NAMED(LOGNAME, "Link %s not present in builder yet!", link_name.c_str()); is_valid_ = false; @@ -290,7 +290,7 @@ void RobotModelBuilder::addLinkVisual(const std::string& link_name, const urdf:: urdf::LinkSharedPtr link; urdf_model_->getLink(link_name, link); - if (not link->visual_array.empty()) + if (!link->visual_array.empty()) { link->visual_array.push_back(vis); } diff --git a/moveit_experimental/CMakeLists.txt b/moveit_experimental/CMakeLists.txt deleted file mode 100644 index 085c96e33d..0000000000 --- a/moveit_experimental/CMakeLists.txt +++ /dev/null @@ -1,49 +0,0 @@ -cmake_minimum_required(VERSION 2.8.3) -project(moveit_experimental) - -add_definitions(-std=c++14) - -if(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE Release) -endif() - -find_package(catkin REQUIRED -COMPONENTS - control_msgs - geometry_msgs - joy_teleop - moveit_ros_planning_interface - rosparam_shortcuts - spacenav_node - tf2_ros -) -find_package(Eigen3 REQUIRED) - -set(THIS_PACKAGE_INCLUDE_DIRS - jog_arm/include -) - -catkin_package( - INCLUDE_DIRS - ${THIS_PACKAGE_INCLUDE_DIRS} - ${EIGEN3_INCLUDE_DIR} - LIBRARIES - CATKIN_DEPENDS - control_msgs - geometry_msgs - joy_teleop - moveit_ros_planning_interface - rosparam_shortcuts - spacenav_node - tf2_ros - DEPENDS - EIGEN3 -) - -include_directories( - ${catkin_INCLUDE_DIRS} - ${EIGEN3_INCLUDE_DIRS} - ${THIS_PACKAGE_INCLUDE_DIRS} -) - -add_subdirectory(jog_arm) diff --git a/moveit_experimental/README.md b/moveit_experimental/README.md index 2d250777f5..7ef8ed18c2 100644 --- a/moveit_experimental/README.md +++ b/moveit_experimental/README.md @@ -1,5 +1,5 @@ -# Experimental Packages for MoveIt! +# Experimental Packages for MoveIt -This repository includes possibly broken/unmaintained/unfinished libraries that are being worked on or have been worked on in the past. They are not part of MoveIt! officially. +This repository includes possibly broken/unmaintained/unfinished libraries that are being worked on or have been worked on in the past. They are not part of MoveIt officially. No support is offered for code in this repository, but you are welcome to use it if you see fit. diff --git a/moveit_experimental/collision_distance_field_ros/CATKIN_IGNORE b/moveit_experimental/collision_distance_field_ros/CATKIN_IGNORE new file mode 100644 index 0000000000..e69de29bb2 diff --git a/moveit_experimental/collision_distance_field_ros/CMakeLists.txt b/moveit_experimental/collision_distance_field_ros/CMakeLists.txt index f8f1c9ccad..9094b77a6b 100644 --- a/moveit_experimental/collision_distance_field_ros/CMakeLists.txt +++ b/moveit_experimental/collision_distance_field_ros/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.4.6) +cmake_minimum_required(VERSION 3.1.3) include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake) # Set the build type. Options are: diff --git a/moveit_experimental/collision_distance_field_ros/include/collision_distance_field_ros/collision_distance_field_ros_helpers.h b/moveit_experimental/collision_distance_field_ros/include/collision_distance_field_ros/collision_distance_field_ros_helpers.h index c90f312dc6..0495d74d2a 100644 --- a/moveit_experimental/collision_distance_field_ros/include/collision_distance_field_ros/collision_distance_field_ros_helpers.h +++ b/moveit_experimental/collision_distance_field_ros/include/collision_distance_field_ros/collision_distance_field_ros_helpers.h @@ -34,8 +34,7 @@ /** \author E. Gil Jones */ -#ifndef COLLISION_DISTANCE_FIELD_HELPERS_H_ -#define COLLISION_DISTANCE_FIELD_HELPERS_H_ +#pragma once #include #include @@ -126,4 +125,3 @@ static inline bool loadLinkBodySphereDecompositions( return true; } } -#endif diff --git a/moveit_experimental/collision_distance_field_ros/include/collision_distance_field_ros/collision_robot_distance_field_ros.h b/moveit_experimental/collision_distance_field_ros/include/collision_distance_field_ros/collision_robot_distance_field_ros.h index 8c9861b953..1fb7a58e56 100644 --- a/moveit_experimental/collision_distance_field_ros/include/collision_distance_field_ros/collision_robot_distance_field_ros.h +++ b/moveit_experimental/collision_distance_field_ros/include/collision_distance_field_ros/collision_robot_distance_field_ros.h @@ -34,8 +34,7 @@ /** \author E. Gil Jones */ -#ifndef _COLLISION_ROBOT_DISTANCE_FIELD_ROS_H_ -#define _COLLISION_ROBOT_DISTANCE_FIELD_ROS_H_ +#pragma once #include #include @@ -63,5 +62,3 @@ class CollisionRobotDistanceFieldROS : public CollisionRobotDistanceField } }; } - -#endif diff --git a/moveit_experimental/collision_distance_field_ros/include/collision_distance_field_ros/hybrid_collision_robot_ros.h b/moveit_experimental/collision_distance_field_ros/include/collision_distance_field_ros/hybrid_collision_robot_ros.h index 193d9debd2..8cb1c75f98 100644 --- a/moveit_experimental/collision_distance_field_ros/include/collision_distance_field_ros/hybrid_collision_robot_ros.h +++ b/moveit_experimental/collision_distance_field_ros/include/collision_distance_field_ros/hybrid_collision_robot_ros.h @@ -34,8 +34,7 @@ /** \author E. Gil Jones */ -#ifndef _COLLISION_ROBOT_HYBRID_ROS_H_ -#define _COLLISION_ROBOT_HYBRID_ROS_H_ +#pragma once #include #include @@ -63,5 +62,3 @@ class CollisionRobotHybridROS : public CollisionRobotHybrid } }; } - -#endif diff --git a/moveit_experimental/jog_arm/CMakeLists.txt b/moveit_experimental/jog_arm/CMakeLists.txt deleted file mode 100644 index 329a117dc6..0000000000 --- a/moveit_experimental/jog_arm/CMakeLists.txt +++ /dev/null @@ -1,34 +0,0 @@ -set(JOG_ARM_NAME jog_arm) - -add_executable(${JOG_ARM_NAME}_server - src/jog_arm/collision_check_thread.cpp - src/jog_arm/jog_arm_server.cpp - src/jog_arm/jog_calcs.cpp - src/jog_arm/jog_ros_interface.cpp - src/jog_arm/low_pass_filter.cpp -) -add_dependencies(${JOG_ARM_NAME}_server ${catkin_EXPORTED_TARGETS}) -target_link_libraries(${JOG_ARM_NAME}_server ${catkin_LIBRARIES} ${Eigen_LIBRARIES}) - -add_executable(${JOG_ARM_NAME}_spacenav_to_twist - src/jog_arm/teleop_examples/spacenav_to_twist.cpp -) -add_dependencies(${JOG_ARM_NAME}_spacenav_to_twist ${catkin_EXPORTED_TARGETS}) -target_link_libraries(${JOG_ARM_NAME}_spacenav_to_twist ${catkin_LIBRARIES}) - -install(TARGETS ${JOG_ARM_NAME}_server ${JOG_ARM_NAME}_spacenav_to_twist - RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} -) - -install( - DIRECTORY - include/ - DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION} - FILES_MATCHING PATTERN "*.h" -) - -if(CATKIN_ENABLE_TESTING) - find_package(rostest REQUIRED) - find_package(ros_pytest REQUIRED) - add_rostest(test/launch/jog_arm_integration_test.test) -endif() diff --git a/moveit_experimental/jog_arm/README.md b/moveit_experimental/jog_arm/README.md deleted file mode 100644 index 8dfa5dcd09..0000000000 --- a/moveit_experimental/jog_arm/README.md +++ /dev/null @@ -1,5 +0,0 @@ -## Jog Arm - -See the [tutorial](https://ros-planning.github.io/moveit_tutorials/doc/arm_jogging/arm_jogging_tutorial.html) - -Run tests with `catkin run_tests --no-deps --this` diff --git a/moveit_experimental/jog_arm/config/sia5_simulated_config.yaml b/moveit_experimental/jog_arm/config/sia5_simulated_config.yaml deleted file mode 100644 index 0ce6b2614e..0000000000 --- a/moveit_experimental/jog_arm/config/sia5_simulated_config.yaml +++ /dev/null @@ -1,34 +0,0 @@ -use_gazebo: true # Whether the robot is started in a Gazebo simulation environment -check_collisions: true # Check collisions? -command_in_type: "unitless" # "unitless"> in the range [-1:1], as if from joystick. "speed_units"> cmds are in m/s and rad/s -scale: # Only used if command_in_type=="unitless" - linear: 0.375 # Max linear velocity [m/s] - rotational: 0.750 # Max angular velocity [rad/s] - joint: 1.25 # Max joint angular/linear velocity. [m/s] or [rad/s] -cartesian_command_in_topic: jog_arm_server/delta_jog_cmds # Topic for xyz commands -joint_command_in_topic: jog_arm_server/joint_delta_jog_cmds # Topic for angle commands -command_frame: base_link # If incoming cmds have no frame, this is the default -incoming_command_timeout: 5 # Stop jogging if X seconds elapse without a new cmd -joint_topic: joint_states -move_group_name: arm # Often 'manipulator' or 'arm' -lower_singularity_threshold: 15 # Start decelerating when the condition number hits this (close to singularity). Larger --> closer to singularity -hard_stop_singularity_threshold: 30 # Stop when the condition number hits this. Larger --> closer to singularity -collision_proximity_threshold: 0.03 # Start decelerating when a collision is this far [m] -planning_frame: base_link # The MoveIt! planning frame. Often 'base_link' -low_pass_filter_coeff: 2. # Larger-> more smoothing of jog commands, but more lag. -publish_period: 0.008 # 1/Nominal publish rate [seconds] -publish_delay: 0.005 # delay between calculation and execution start of command -collision_check_rate: 5 # [Hz] Collision-checking can easily bog down a CPU if done too often. -num_halt_msgs_to_publish: 4 # If 0, republish commands forever even if the robot is stationary. Otherwise, specify num. to publish -# Publish boolean warnings to this topic -warning_topic: jog_arm_server/warning -joint_limit_margin: 0.1 # added as a buffer to joint limits [radians]. If moving quickly, make this larger. -command_out_topic: sia5_controller/command # Find this topic by 'rostopic list' or 'rostopic list | grep command' or 'rqt_graph' -# What type of topic does your robot driver expect? -# Currently supported are std_msgs/Float64MultiArray (for ros_control JointGroupVelocityController) -# or trajectory_msgs/JointTrajectory (for Universal Robots and other non-ros_control robots) -command_out_type: trajectory_msgs/JointTrajectory -# Can save some bandwidth as most robots only require positions or velocities -publish_joint_positions: true -publish_joint_velocities: true -publish_joint_accelerations: false diff --git a/moveit_experimental/jog_arm/launch/spacenav_cpp.launch b/moveit_experimental/jog_arm/launch/spacenav_cpp.launch deleted file mode 100644 index 22a577bf85..0000000000 --- a/moveit_experimental/jog_arm/launch/spacenav_cpp.launch +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - diff --git a/moveit_experimental/kinematics_cache/CATKIN_IGNORE b/moveit_experimental/kinematics_cache/CATKIN_IGNORE new file mode 100644 index 0000000000..e69de29bb2 diff --git a/moveit_experimental/kinematics_cache/v1/kinematics_cache/CMakeLists.txt b/moveit_experimental/kinematics_cache/v1/kinematics_cache/CMakeLists.txt index a8109a42b3..6b319e9beb 100644 --- a/moveit_experimental/kinematics_cache/v1/kinematics_cache/CMakeLists.txt +++ b/moveit_experimental/kinematics_cache/v1/kinematics_cache/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.4.6) +cmake_minimum_required(VERSION 3.1.3) include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake) # Set the build type. Options are: diff --git a/moveit_experimental/kinematics_cache/v1/kinematics_cache/include/kinematics_cache/kinematics_cache.h b/moveit_experimental/kinematics_cache/v1/kinematics_cache/include/kinematics_cache/kinematics_cache.h index 1d9f7fd217..952965a57e 100644 --- a/moveit_experimental/kinematics_cache/v1/kinematics_cache/include/kinematics_cache/kinematics_cache.h +++ b/moveit_experimental/kinematics_cache/v1/kinematics_cache/include/kinematics_cache/kinematics_cache.h @@ -35,8 +35,7 @@ * Author: Sachin Chitta *********************************************************************/ -#ifndef KINEMATICS_CACHE_H_ -#define KINEMATICS_CACHE_H_ +#pragma once #include #include @@ -184,5 +183,3 @@ class KinematicsCache typedef std::shared_ptr KinematicsCachePtr; } - -#endif diff --git a/moveit_experimental/kinematics_cache/v1/kinematics_cache_ros/CMakeLists.txt b/moveit_experimental/kinematics_cache/v1/kinematics_cache_ros/CMakeLists.txt index b8b6ee1e04..81aa86cb8c 100644 --- a/moveit_experimental/kinematics_cache/v1/kinematics_cache_ros/CMakeLists.txt +++ b/moveit_experimental/kinematics_cache/v1/kinematics_cache_ros/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.4.6) +cmake_minimum_required(VERSION 3.1.3) include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake) # Set the build type. Options are: diff --git a/moveit_experimental/kinematics_cache/v1/kinematics_cache_ros/include/kinematics_cache_ros/kinematics_cache_ros.h b/moveit_experimental/kinematics_cache/v1/kinematics_cache_ros/include/kinematics_cache_ros/kinematics_cache_ros.h index ceaa9f86e6..187c133f40 100644 --- a/moveit_experimental/kinematics_cache/v1/kinematics_cache_ros/include/kinematics_cache_ros/kinematics_cache_ros.h +++ b/moveit_experimental/kinematics_cache/v1/kinematics_cache_ros/include/kinematics_cache_ros/kinematics_cache_ros.h @@ -35,8 +35,7 @@ * Author: Sachin Chitta *********************************************************************/ -#ifndef KINEMATICS_CACHE_ROS_H_ -#define KINEMATICS_CACHE_ROS_H_ +#pragma once #include #include @@ -70,5 +69,3 @@ class KinematicsCacheROS : public kinematics_cache::KinematicsCache planning_models::RobotModelPtr kinematic_model_; /** A kinematics model */ }; } - -#endif diff --git a/moveit_experimental/kinematics_cache/v1/kinematics_cache_ros/src/kinematics_cache_ros.cpp b/moveit_experimental/kinematics_cache/v1/kinematics_cache_ros/src/kinematics_cache_ros.cpp index 40342b1d31..edc2f0cb64 100644 --- a/moveit_experimental/kinematics_cache/v1/kinematics_cache_ros/src/kinematics_cache_ros.cpp +++ b/moveit_experimental/kinematics_cache/v1/kinematics_cache_ros/src/kinematics_cache_ros.cpp @@ -40,7 +40,7 @@ // ROS #include -// MoveIt! +// MoveIt #include #include #include diff --git a/moveit_experimental/kinematics_cache/v2/kinematics_cache/CMakeLists.txt b/moveit_experimental/kinematics_cache/v2/kinematics_cache/CMakeLists.txt index d22d017782..6dcd3680b0 100644 --- a/moveit_experimental/kinematics_cache/v2/kinematics_cache/CMakeLists.txt +++ b/moveit_experimental/kinematics_cache/v2/kinematics_cache/CMakeLists.txt @@ -9,6 +9,9 @@ add_dependencies(${MOVEIT_LIB_NAME} ${catkin_EXPORTED_TARGETS}) target_link_libraries(${MOVEIT_LIB_NAME} moveit_robot_model ${catkin_LIBRARIES} ${Boost_LIBRARIES}) -install(TARGETS ${MOVEIT_LIB_NAME} LIBRARY DESTINATION ${CATKIN_GLOBAL_LIB_DESTINATION}) +install(TARGETS ${MOVEIT_LIB_NAME} + LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}) install(DIRECTORY include/ DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}) diff --git a/moveit_experimental/kinematics_cache/v2/kinematics_cache/include/moveit/kinematics_cache/kinematics_cache.h b/moveit_experimental/kinematics_cache/v2/kinematics_cache/include/moveit/kinematics_cache/kinematics_cache.h index 0a7c793614..233ad5f27c 100644 --- a/moveit_experimental/kinematics_cache/v2/kinematics_cache/include/moveit/kinematics_cache/kinematics_cache.h +++ b/moveit_experimental/kinematics_cache/v2/kinematics_cache/include/moveit/kinematics_cache/kinematics_cache.h @@ -35,8 +35,7 @@ * Author: Sachin Chitta *********************************************************************/ -#ifndef KINEMATICS_CACHE_H_ -#define KINEMATICS_CACHE_H_ +#pragma once #include #include @@ -182,5 +181,3 @@ class KinematicsCache typedef std::shared_ptr KinematicsCachePtr; } - -#endif diff --git a/moveit_experimental/kinematics_constraint_aware/CATKIN_IGNORE b/moveit_experimental/kinematics_constraint_aware/CATKIN_IGNORE new file mode 100644 index 0000000000..e69de29bb2 diff --git a/moveit_experimental/kinematics_constraint_aware/CMakeLists.txt b/moveit_experimental/kinematics_constraint_aware/CMakeLists.txt index 8aaa5b86dc..12d18cecef 100644 --- a/moveit_experimental/kinematics_constraint_aware/CMakeLists.txt +++ b/moveit_experimental/kinematics_constraint_aware/CMakeLists.txt @@ -7,5 +7,8 @@ add_dependencies(${MOVEIT_LIB_NAME} ${catkin_EXPORTED_TARGETS}) target_link_libraries(${MOVEIT_LIB_NAME} ${catkin_LIBRARIES} ${Boost_LIBRARIES}) -install(TARGETS ${MOVEIT_LIB_NAME} LIBRARY DESTINATION ${CATKIN_GLOBAL_LIB_DESTINATION}) +install(TARGETS ${MOVEIT_LIB_NAME} + LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}) install(DIRECTORY include/ DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}) diff --git a/moveit_experimental/kinematics_constraint_aware/include/moveit/kinematics_constraint_aware/kinematics_constraint_aware.h b/moveit_experimental/kinematics_constraint_aware/include/moveit/kinematics_constraint_aware/kinematics_constraint_aware.h index 4e8ab4348d..4200f2761e 100644 --- a/moveit_experimental/kinematics_constraint_aware/include/moveit/kinematics_constraint_aware/kinematics_constraint_aware.h +++ b/moveit_experimental/kinematics_constraint_aware/include/moveit/kinematics_constraint_aware/kinematics_constraint_aware.h @@ -35,8 +35,7 @@ * Author: Sachin Chitta *********************************************************************/ -#ifndef MOVEIT_KINEMATICS_CONSTRAINT_AWARE_ -#define MOVEIT_KINEMATICS_CONSTRAINT_AWARE_ +#pragma once // System #include @@ -51,7 +50,7 @@ // Plugin #include -// MoveIt! +// MoveIt #include #include #include @@ -141,5 +140,3 @@ class KinematicsConstraintAware unsigned int ik_attempts_; }; } - -#endif diff --git a/moveit_experimental/kinematics_constraint_aware/include/moveit/kinematics_constraint_aware/kinematics_request_response.h b/moveit_experimental/kinematics_constraint_aware/include/moveit/kinematics_constraint_aware/kinematics_request_response.h index b2f62e462b..b54fd335e3 100644 --- a/moveit_experimental/kinematics_constraint_aware/include/moveit/kinematics_constraint_aware/kinematics_request_response.h +++ b/moveit_experimental/kinematics_constraint_aware/include/moveit/kinematics_constraint_aware/kinematics_request_response.h @@ -35,8 +35,7 @@ * Author: Sachin Chitta *********************************************************************/ -#ifndef MOVEIT_KINEMATICS_CONSTRAINT_AWARE_KINEMATICS_REQUEST_RESPONSE_ -#define MOVEIT_KINEMATICS_CONSTRAINT_AWARE_KINEMATICS_REQUEST_RESPONSE_ +#pragma once // System #include @@ -44,7 +43,7 @@ // ROS msgs #include -// MoveIt! +// MoveIt #include #include #include @@ -105,5 +104,3 @@ class KinematicsResponse bool result_; }; } - -#endif diff --git a/moveit_experimental/moveit_jog_arm/CMakeLists.txt b/moveit_experimental/moveit_jog_arm/CMakeLists.txt new file mode 100644 index 0000000000..e95c156c6b --- /dev/null +++ b/moveit_experimental/moveit_jog_arm/CMakeLists.txt @@ -0,0 +1,70 @@ +cmake_minimum_required(VERSION 2.8.3) +project(moveit_jog_arm) + +add_compile_options(-std=c++11) + +if(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Release) +endif() + +find_package(catkin REQUIRED COMPONENTS + control_msgs + geometry_msgs + moveit_ros_planning_interface + rosparam_shortcuts + tf2_ros +) +find_package(Eigen3 REQUIRED) + + +catkin_package( + INCLUDE_DIRS + include + LIBRARIES + CATKIN_DEPENDS + control_msgs + geometry_msgs + moveit_ros_planning_interface + rosparam_shortcuts + tf2_ros + DEPENDS + EIGEN3 +) + +include_directories( + include + ${catkin_INCLUDE_DIRS} + ${EIGEN3_INCLUDE_DIRS} +) + +add_executable(jog_server + src/collision_check_thread.cpp + src/jog_server.cpp + src/jog_calcs.cpp + src/jog_ros_interface.cpp + src/low_pass_filter.cpp +) + +add_dependencies(jog_server ${catkin_EXPORTED_TARGETS}) +target_link_libraries(jog_server ${catkin_LIBRARIES} ${Eigen_LIBRARIES}) + +add_executable(spacenav_to_twist + src/teleop_examples/spacenav_to_twist.cpp +) +add_dependencies(spacenav_to_twist ${catkin_EXPORTED_TARGETS}) +target_link_libraries(spacenav_to_twist ${catkin_LIBRARIES}) + +install( + TARGETS + jog_server + spacenav_to_twist + RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} +) + +install(DIRECTORY include/ DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}) + +if(CATKIN_ENABLE_TESTING) + find_package(rostest REQUIRED) + find_package(ros_pytest REQUIRED) + add_rostest(test/launch/jog_arm_integration_test.test) +endif() diff --git a/moveit_experimental/moveit_jog_arm/README.md b/moveit_experimental/moveit_jog_arm/README.md new file mode 100644 index 0000000000..0543aed922 --- /dev/null +++ b/moveit_experimental/moveit_jog_arm/README.md @@ -0,0 +1,58 @@ +## Jog Arm + +#### Quick Start Guide for UR5 example + +Clone the `universal_robot` repo into your catkin workspace: + + git clone https://github.com/ros-industrial/universal_robot.git + +Run `rosdep install` from the `src` folder to install dependencies. + + rosdep install --from-paths . --ignore-src -y + +Build and subsequently source the catkin workspace. Startup the robot and MoveIt: + + roslaunch ur_gazebo ur5.launch + + roslaunch ur5_moveit_config ur5_moveit_planning_execution.launch sim:=true + + roslaunch ur5_moveit_config moveit_rviz.launch config:=true + +In RViz, "plan and execute" a motion to a non-singular position (not all zero joint angles) that is not close to a joint limit. + +Switch to a compatible type of `ros-control` controller. It should be a `JointGroupVelocityController` or a `JointGroupPositionController`, not a trajectory controller like MoveIt usually requires. + +```sh +rosservice call /controller_manager/switch_controller "start_controllers: +- 'joint_group_position_controller' +stop_controllers: +- 'arm_controller' +strictness: 2" +``` + +Launch the jog node. This example uses commands from a SpaceNavigator joystick-like device: + + roslaunch moveit_jog_arm spacenav_cpp.launch + +If you dont have a SpaceNavigator, send commands like this: + +```sh +rostopic pub -r 100 /jog_server/delta_jog_cmds geometry_msgs/TwistStamped "header: auto +twist: + linear: + x: 0.0 + y: 0.01 + z: -0.01 + angular: + x: 0.0 + y: 0.0 + z: 0.0" +``` + +If you see a warning about "close to singularity", try changing the direction of motion. + +#### Running Tests + +Run tests from the jog\_arm folder: + + catkin run_tests --no-deps --this diff --git a/moveit_experimental/jog_arm/config/spacenav_via_teleop_tools.yaml b/moveit_experimental/moveit_jog_arm/config/spacenav_via_teleop_tools.yaml similarity index 93% rename from moveit_experimental/jog_arm/config/spacenav_via_teleop_tools.yaml rename to moveit_experimental/moveit_jog_arm/config/spacenav_via_teleop_tools.yaml index cd9e53c9df..2308e0c5a0 100644 --- a/moveit_experimental/jog_arm/config/spacenav_via_teleop_tools.yaml +++ b/moveit_experimental/moveit_jog_arm/config/spacenav_via_teleop_tools.yaml @@ -2,7 +2,7 @@ teleop: cartesian_twist_command: type: topic message_type: geometry_msgs/TwistStamped - topic_name: jog_arm_server/delta_jog_cmds + topic_name: jog_server/delta_jog_cmds axis_mappings: - axis: 0 diff --git a/moveit_experimental/moveit_jog_arm/config/ur_simulated_config.yaml b/moveit_experimental/moveit_jog_arm/config/ur_simulated_config.yaml new file mode 100644 index 0000000000..839a4b16a5 --- /dev/null +++ b/moveit_experimental/moveit_jog_arm/config/ur_simulated_config.yaml @@ -0,0 +1,55 @@ +############################################### +# Modify all parameters related to jogging here +############################################### +use_gazebo: true # Whether the robot is started in a Gazebo simulation environment + +## Properties of incoming commands +command_frame: world # TF frame that incoming cmds are given in +command_in_type: "speed_units" # "unitless"> in the range [-1:1], as if from joystick. "speed_units"> cmds are in m/s and rad/s +scale: # Only used if command_in_type=="unitless" + linear: 0.6 # Max linear velocity. Meters per publish_period. Units is [m/s] + rotational: 0.3 # Max angular velocity. Rads per publish_period. Units is [rad/s] + joint: 0.3 # Max joint angular/linear velocity. Rads or Meters per publish period. Units is [rad/s] or [m/s]. +low_pass_filter_coeff: 2. # Larger --> trust the filtered data more, trust the measurements less. + +## Properties of outgoing commands +publish_period: 0.008 # 1/Nominal publish rate [seconds] +publish_delay: 0.005 # delay between calculation and execution start of command + +# What type of topic does your robot driver expect? +# Currently supported are std_msgs/Float64MultiArray (for ros_control JointGroupVelocityController or JointGroupPositionController) +# or trajectory_msgs/JointTrajectory (for Universal Robots and other non-ros_control robots) +command_out_type: std_msgs/Float64MultiArray + +# What to publish? Can save some bandwidth as most robots only require positions or velocities +publish_joint_positions: true +publish_joint_velocities: false +publish_joint_accelerations: false + +## MoveIt properties +move_group_name: manipulator # Often 'manipulator' or 'arm' +planning_frame: world # The MoveIt! planning frame. Often 'base_link' + +## Stopping behaviour +incoming_command_timeout: 2 # Stop jogging if X seconds elapse without a new cmd +# If 0, republish commands forever even if the robot is stationary. Otherwise, specify num. to publish. +# Important because ROS may drop some messages and we need the robot to halt reliably. +num_halt_msgs_to_publish: 4 + +## Configure handling of singularities and joint limits +lower_singularity_threshold: 17 # Start decelerating when the condition number hits this (close to singularity) +hard_stop_singularity_threshold: 30 # Stop when the condition number hits this +joint_limit_margin: 0.1 # added as a buffer to joint limits [radians]. If moving quickly, make this larger. + +## Topic names +cartesian_command_in_topic: jog_server/delta_jog_cmds # Topic for incoming Cartesian twist commands +joint_command_in_topic: jog_server/joint_delta_jog_cmds # Topic for incoming joint angle commands +joint_topic: joint_states +warning_topic: jog_server/halted # Publish boolean warnings to this topic +command_out_topic: joint_group_position_controller/command # Publish outgoing commands here + +## Collision checking +check_collisions: true # Check collisions? +collision_check_rate: 5 # [Hz] Collision-checking can easily bog down a CPU if done too often. +collision_proximity_threshold: 0.01 # Start decelerating when a collision is this far [m] +hard_stop_collision_proximity_threshold: 0.0005 # Stop when a collision is this far [m] diff --git a/moveit_experimental/jog_arm/include/jog_arm/collision_check_thread.h b/moveit_experimental/moveit_jog_arm/include/moveit_jog_arm/collision_check_thread.h similarity index 81% rename from moveit_experimental/jog_arm/include/jog_arm/collision_check_thread.h rename to moveit_experimental/moveit_jog_arm/include/moveit_jog_arm/collision_check_thread.h index 1049f26967..d5c8551576 100644 --- a/moveit_experimental/jog_arm/include/jog_arm/collision_check_thread.h +++ b/moveit_experimental/moveit_jog_arm/include/moveit_jog_arm/collision_check_thread.h @@ -1,6 +1,6 @@ /////////////////////////////////////////////////////////////////////////////// // Title : collision_check_thread.h -// Project : jog_arm +// Project : moveit_jog_arm // Created : 1/11/2019 // Author : Brian O'Neil, Andy Zelenak, Blake Anderson // @@ -37,22 +37,20 @@ // /////////////////////////////////////////////////////////////////////////////// -#ifndef JOG_ARM_COLLISION_CHECK_THREAD_H -#define JOG_ARM_COLLISION_CHECK_THREAD_H +#pragma once -#include -#include +#include "jog_arm_data.h" +#include "low_pass_filter.h" #include #include -namespace jog_arm +namespace moveit_jog_arm { class CollisionCheckThread { public: - CollisionCheckThread(const jog_arm::JogArmParameters parameters, jog_arm::JogArmShared& shared_variables, - pthread_mutex_t& mutex, const robot_model_loader::RobotModelLoaderPtr& model_loader_ptr); + CollisionCheckThread(const moveit_jog_arm::JogArmParameters parameters, + moveit_jog_arm::JogArmShared& shared_variables, pthread_mutex_t& mutex, + const robot_model_loader::RobotModelLoaderPtr& model_loader_ptr); }; } - -#endif // JOG_ARM_COLLISION_CHECK_THREAD_H diff --git a/moveit_experimental/jog_arm/include/jog_arm/jog_arm_data.h b/moveit_experimental/moveit_jog_arm/include/moveit_jog_arm/jog_arm_data.h similarity index 92% rename from moveit_experimental/jog_arm/include/jog_arm/jog_arm_data.h rename to moveit_experimental/moveit_jog_arm/include/moveit_jog_arm/jog_arm_data.h index 119de4adc9..0950d07405 100644 --- a/moveit_experimental/jog_arm/include/jog_arm/jog_arm_data.h +++ b/moveit_experimental/moveit_jog_arm/include/moveit_jog_arm/jog_arm_data.h @@ -1,6 +1,6 @@ /////////////////////////////////////////////////////////////////////////////// // Title : jog_arm_data.h -// Project : jog_arm +// Project : moveit_jog_arm // Created : 1/11/2019 // Author : Brian O'Neil, Andy Zelenak, Blake Anderson // @@ -37,8 +37,7 @@ // /////////////////////////////////////////////////////////////////////////////// -#ifndef JOG_ARM_JOG_ARM_DATA_H -#define JOG_ARM_JOG_ARM_DATA_H +#pragma once #include #include @@ -46,9 +45,9 @@ #include #include -namespace jog_arm +namespace moveit_jog_arm { -static const std::string LOGNAME = "jog_arm_server"; +static const std::string LOGNAME = "jog_server"; static const double WHILE_LOOP_WAIT = 0.001; // Variables to share between threads, and their mutexes @@ -75,7 +74,7 @@ struct JogArmShared trajectory_msgs::JointTrajectory outgoing_command; // Timestamp of incoming commands - ros::Time incoming_cmd_stamp = ros::Time(0.); + ros::Time latest_nonzero_cmd_stamp = ros::Time(0.); // Indicates no collision, etc, so outgoing commands can be sent bool ok_to_publish = false; @@ -87,10 +86,9 @@ struct JogArmParameters std::string move_group_name, joint_topic, cartesian_command_in_topic, command_frame, command_out_topic, planning_frame, warning_topic, joint_command_in_topic, command_in_type, command_out_type; double linear_scale, rotational_scale, joint_scale, lower_singularity_threshold, hard_stop_singularity_threshold, - collision_proximity_threshold, low_pass_filter_coeff, publish_period, publish_delay, incoming_command_timeout, + collision_proximity_threshold, low_pass_filter_coeff, publish_period, incoming_command_timeout, joint_limit_margin, collision_check_rate; int num_halt_msgs_to_publish; bool use_gazebo, check_collisions, publish_joint_positions, publish_joint_velocities, publish_joint_accelerations; }; } -#endif // JOG_ARM_DATA_H diff --git a/moveit_experimental/jog_arm/include/jog_arm/jog_calcs.h b/moveit_experimental/moveit_jog_arm/include/moveit_jog_arm/jog_calcs.h similarity index 87% rename from moveit_experimental/jog_arm/include/jog_arm/jog_calcs.h rename to moveit_experimental/moveit_jog_arm/include/moveit_jog_arm/jog_calcs.h index e610dba2c1..4d01690c7a 100644 --- a/moveit_experimental/jog_arm/include/jog_arm/jog_calcs.h +++ b/moveit_experimental/moveit_jog_arm/include/moveit_jog_arm/jog_calcs.h @@ -1,6 +1,6 @@ /////////////////////////////////////////////////////////////////////////////// // Title : jog_calcs.h -// Project : jog_arm +// Project : moveit_jog_arm // Created : 1/11/2019 // Author : Brian O'Neil, Andy Zelenak, Blake Anderson // @@ -37,31 +37,27 @@ // /////////////////////////////////////////////////////////////////////////////// -#ifndef JOG_ARM_JOG_CALCS_H -#define JOG_ARM_JOG_CALCS_H +#pragma once -#include -#include -#include +#include "jog_arm_data.h" +#include "low_pass_filter.h" #include #include #include #include #include -namespace jog_arm +namespace moveit_jog_arm { class JogCalcs { public: - JogCalcs(const JogArmParameters parameters, JogArmShared& shared_variables, pthread_mutex_t& mutex, + JogCalcs(const JogArmParameters& parameters, JogArmShared& shared_variables, pthread_mutex_t& mutex, const robot_model_loader::RobotModelLoaderPtr& model_loader_ptr); protected: ros::NodeHandle nh_; - moveit::planning_interface::MoveGroupInterface move_group_; - sensor_msgs::JointState incoming_jts_; bool cartesianJogCalcs(geometry_msgs::TwistStamped& cmd, JogArmShared& shared_variables, pthread_mutex_t& mutex); @@ -83,8 +79,9 @@ class JogCalcs // Reset the data stored in low-pass filters so the trajectory won't jump when jogging is resumed. void resetVelocityFilters(); - // Avoid a singularity or other issue. Is handled differently for position vs. velocity control. - void halt(trajectory_msgs::JointTrajectory& jt_traj); + // Suddenly halt for a joint limit or other critical issue. + // Is handled differently for position vs. velocity control. + void suddenHalt(trajectory_msgs::JointTrajectory& jt_traj); void publishWarning(bool active) const; @@ -100,8 +97,7 @@ class JogCalcs trajectory_msgs::JointTrajectory& new_jt_traj, const Eigen::VectorXd& delta_theta, double singularity_scale); - trajectory_msgs::JointTrajectory composeOutgoingMessage(sensor_msgs::JointState& joint_state, - const ros::Time& stamp) const; + trajectory_msgs::JointTrajectory composeOutgoingMessage(sensor_msgs::JointState& joint_state) const; void lowPassFilterVelocities(const Eigen::VectorXd& joint_vel); @@ -136,6 +132,4 @@ class JogCalcs uint num_joints_; }; -} // namespace jog_arm - -#endif // JOG_ARM_JOG_CALCS_H +} // namespace moveit_jog_arm diff --git a/moveit_experimental/jog_arm/include/jog_arm/jog_ros_interface.h b/moveit_experimental/moveit_jog_arm/include/moveit_jog_arm/jog_ros_interface.h similarity index 90% rename from moveit_experimental/jog_arm/include/jog_arm/jog_ros_interface.h rename to moveit_experimental/moveit_jog_arm/include/moveit_jog_arm/jog_ros_interface.h index 636e920afe..8d69686430 100644 --- a/moveit_experimental/jog_arm/include/jog_arm/jog_ros_interface.h +++ b/moveit_experimental/moveit_jog_arm/include/moveit_jog_arm/jog_ros_interface.h @@ -1,6 +1,6 @@ /////////////////////////////////////////////////////////////////////////////// // Title : jog_ros_interface.h -// Project : jog_arm +// Project : moveit_jog_arm // Created : 3/9/2017 // Author : Brian O'Neil, Blake Anderson, Andy Zelenak // @@ -39,20 +39,19 @@ // Server node for arm jogging with MoveIt. -#ifndef JOG_ARM_JOG_ROS_INTERFACE_H -#define JOG_ARM_JOG_ROS_INTERFACE_H +#pragma once +#include "collision_check_thread.h" #include -#include -#include -#include -#include +#include "jog_arm_data.h" +#include "jog_calcs.h" +#include "low_pass_filter.h" #include #include #include #include -namespace jog_arm +namespace moveit_jog_arm { /** * Class JogROSInterface - Instantiated in main(). Handles ROS subs & pubs and creates the worker threads. @@ -86,6 +85,4 @@ class JogROSInterface // Store the parameters that were read from ROS server JogArmParameters ros_parameters_; }; -} // namespace jog_arm - -#endif // JOG_ARM_JOG_ROS_INTERFACE_H +} // namespace moveit_jog_arm diff --git a/moveit_experimental/jog_arm/include/jog_arm/low_pass_filter.h b/moveit_experimental/moveit_jog_arm/include/moveit_jog_arm/low_pass_filter.h similarity index 84% rename from moveit_experimental/jog_arm/include/jog_arm/low_pass_filter.h rename to moveit_experimental/moveit_jog_arm/include/moveit_jog_arm/low_pass_filter.h index e9c9a767c7..424ab6e2f1 100644 --- a/moveit_experimental/jog_arm/include/jog_arm/low_pass_filter.h +++ b/moveit_experimental/moveit_jog_arm/include/moveit_jog_arm/low_pass_filter.h @@ -1,6 +1,6 @@ /////////////////////////////////////////////////////////////////////////////// // Title : low_pass_filter.h -// Project : jog_arm +// Project : moveit_jog_arm // Created : 1/11/2019 // Author : Andy Zelenak // @@ -37,15 +37,15 @@ // /////////////////////////////////////////////////////////////////////////////// -#ifndef JOG_ARM_LOW_PASS_FILTER_H -#define JOG_ARM_LOW_PASS_FILTER_H +#pragma once -namespace jog_arm +namespace moveit_jog_arm { /** * Class LowPassFilter - Filter a signal to soften jerks. - * This is a second-order Butterworth low-pass filter. - * See https://ccrma.stanford.edu/~jos/filters/Example_Second_Order_Butterworth_Lowpass.html + * This is a first-order Butterworth low-pass filter. + * + * TODO: Use ROS filters package (http://wiki.ros.org/filters, https://github.com/ros/filters) */ class LowPassFilter { @@ -55,12 +55,11 @@ class LowPassFilter void reset(double data); private: - double previous_measurements_[3] = { 0., 0., 0. }; - double previous_filtered_measurements_[2] = { 0., 0. }; + double previous_measurements_[2] = { 0., 0. }; + double previous_filtered_measurement_ = 0.; // Larger filter_coeff-> more smoothing of jog commands, but more lag. // Rough plot, with cutoff frequency on the y-axis: // https://www.wolframalpha.com/input/?i=plot+arccot(c) double filter_coeff_ = 10.; }; -} // namespace jog_arm -#endif // JOG_ARM_LOW_PASS_FILTER_H +} // namespace moveit_jog_arm diff --git a/moveit_experimental/moveit_jog_arm/launch/spacenav_cpp.launch b/moveit_experimental/moveit_jog_arm/launch/spacenav_cpp.launch new file mode 100644 index 0000000000..c78dff5b6b --- /dev/null +++ b/moveit_experimental/moveit_jog_arm/launch/spacenav_cpp.launch @@ -0,0 +1,20 @@ + + + + + + + + + + + + + diff --git a/moveit_experimental/jog_arm/launch/spacenav_teleop_tools.launch b/moveit_experimental/moveit_jog_arm/launch/spacenav_teleop_tools.launch similarity index 50% rename from moveit_experimental/jog_arm/launch/spacenav_teleop_tools.launch rename to moveit_experimental/moveit_jog_arm/launch/spacenav_teleop_tools.launch index e49ddbfa54..6b3a97cf92 100644 --- a/moveit_experimental/jog_arm/launch/spacenav_teleop_tools.launch +++ b/moveit_experimental/moveit_jog_arm/launch/spacenav_teleop_tools.launch @@ -1,21 +1,22 @@ + This is the higher-latency, Python-based teleop_tools example. + You can modify it in your own package for your own type of gamepad or joystick. + We do plan to accept pull requests of config files for other controller types using this method. + --> - - - + + + - + diff --git a/moveit_experimental/jog_arm/package.xml b/moveit_experimental/moveit_jog_arm/package.xml similarity index 50% rename from moveit_experimental/jog_arm/package.xml rename to moveit_experimental/moveit_jog_arm/package.xml index 063cf7020e..ed1227fce6 100644 --- a/moveit_experimental/jog_arm/package.xml +++ b/moveit_experimental/moveit_jog_arm/package.xml @@ -1,6 +1,6 @@ - jog_arm + moveit_jog_arm 0.0.3 Provides real-time manipulator Cartesian jogging. @@ -10,10 +10,28 @@ BSD 3-Clause - http://wiki.ros.org/jog_arm + https://ros-planning.github.io/moveit_tutorials Brian O'Neil Andy Zelenak Blake Anderson Alexander Rössler + + catkin + + control_msgs + geometry_msgs + moveit_ros_planning_interface + rosparam_shortcuts + tf2_ros + + joy_teleop + + rostest + ros_pytest + moveit_resources + + + + diff --git a/moveit_experimental/jog_arm/src/jog_arm/collision_check_thread.cpp b/moveit_experimental/moveit_jog_arm/src/collision_check_thread.cpp similarity index 94% rename from moveit_experimental/jog_arm/src/jog_arm/collision_check_thread.cpp rename to moveit_experimental/moveit_jog_arm/src/collision_check_thread.cpp index 47ecd0b10d..56cb82d164 100644 --- a/moveit_experimental/jog_arm/src/jog_arm/collision_check_thread.cpp +++ b/moveit_experimental/moveit_jog_arm/src/collision_check_thread.cpp @@ -1,6 +1,6 @@ /////////////////////////////////////////////////////////////////////////////// // Title : collision_check_thread.cpp -// Project : jog_arm +// Project : moveit_jog_arm // Created : 1/11/2019 // Author : Brian O'Neil, Andy Zelenak, Blake Anderson // @@ -37,19 +37,19 @@ // /////////////////////////////////////////////////////////////////////////////// -#include +#include -namespace jog_arm +namespace moveit_jog_arm { // Constructor for the class that handles collision checking -CollisionCheckThread::CollisionCheckThread(const jog_arm::JogArmParameters parameters, JogArmShared& shared_variables, - pthread_mutex_t& mutex, +CollisionCheckThread::CollisionCheckThread(const moveit_jog_arm::JogArmParameters parameters, + JogArmShared& shared_variables, pthread_mutex_t& mutex, const robot_model_loader::RobotModelLoaderPtr& model_loader_ptr) { // If user specified true in yaml file if (parameters.check_collisions) { - // MoveIt! Setup + // MoveIt Setup while (ros::ok() && !model_loader_ptr) { ROS_WARN_THROTTLE_NAMED(5, LOGNAME, "Waiting for a non-null robot_model_loader pointer"); @@ -134,4 +134,4 @@ CollisionCheckThread::CollisionCheckThread(const jog_arm::JogArmParameters param } } } -} // namespace jog_arm +} // namespace moveit_jog_arm diff --git a/moveit_experimental/jog_arm/src/jog_arm/jog_calcs.cpp b/moveit_experimental/moveit_jog_arm/src/jog_calcs.cpp similarity index 93% rename from moveit_experimental/jog_arm/src/jog_arm/jog_calcs.cpp rename to moveit_experimental/moveit_jog_arm/src/jog_calcs.cpp index 55c76fb190..0ff378a533 100644 --- a/moveit_experimental/jog_arm/src/jog_arm/jog_calcs.cpp +++ b/moveit_experimental/moveit_jog_arm/src/jog_calcs.cpp @@ -1,6 +1,6 @@ /////////////////////////////////////////////////////////////////////////////// // Title : jog_calcs.h -// Project : jog_arm +// Project : moveit_jog_arm // Created : 1/11/2019 // Author : Brian O'Neil, Andy Zelenak, Blake Anderson // @@ -37,19 +37,19 @@ // /////////////////////////////////////////////////////////////////////////////// -#include +#include -namespace jog_arm +namespace moveit_jog_arm { // Constructor for the class that handles jogging calculations -JogCalcs::JogCalcs(const JogArmParameters parameters, JogArmShared& shared_variables, pthread_mutex_t& mutex, +JogCalcs::JogCalcs(const JogArmParameters& parameters, JogArmShared& shared_variables, pthread_mutex_t& mutex, const robot_model_loader::RobotModelLoaderPtr& model_loader_ptr) - : move_group_(parameters.move_group_name), tf_listener_(tf_buffer_), parameters_(parameters) + : tf_listener_(tf_buffer_), parameters_(parameters) { // Publish collision status warning_pub_ = nh_.advertise(parameters_.warning_topic, 1); - // MoveIt! Setup + // MoveIt Setup while (ros::ok() && !model_loader_ptr) { ROS_WARN_THROTTLE_NAMED(5, LOGNAME, "Waiting for a non-null robot_model_loader pointer"); @@ -66,13 +66,9 @@ JogCalcs::JogCalcs(const JogArmParameters parameters, JogArmShared& shared_varia ros::topic::waitForMessage(parameters_.joint_topic); ROS_INFO_NAMED(LOGNAME, "Received first joint msg."); - ROS_INFO_NAMED(LOGNAME, "Waiting for first command msg."); - ros::topic::waitForMessage(parameters_.cartesian_command_in_topic); - ROS_INFO_NAMED(LOGNAME, "Received first command msg."); - resetVelocityFilters(); - jt_state_.name = move_group_.getJointNames(); + jt_state_.name = joint_model_group_->getVariableNames(); num_joints_ = jt_state_.name.size(); jt_state_.position.resize(num_joints_); jt_state_.velocity.resize(num_joints_); @@ -124,7 +120,7 @@ JogCalcs::JogCalcs(const JogArmParameters parameters, JogArmShared& shared_varia // Now do jogging calcs while (ros::ok()) { - // If user commands are all zero, reset the low-pass filters when commands resume + // Flag that incoming commands are all zero. May be used to skip calculations/publication pthread_mutex_lock(&mutex); bool zero_cartesian_cmd_flag = shared_variables.zero_cartesian_cmd_flag; bool zero_joint_cmd_flag = shared_variables.zero_joint_cmd_flag; @@ -148,8 +144,8 @@ JogCalcs::JogCalcs(const JogArmParameters parameters, JogArmShared& shared_varia ros::Duration(WHILE_LOOP_WAIT).sleep(); } - // Assume cartesian jogging command unless the joint command has some nonzero values - if (zero_joint_cmd_flag) + // Prioritize cartesian jogging above joint jogging + if (!zero_cartesian_cmd_flag) { pthread_mutex_lock(&mutex); cartesian_deltas = shared_variables.command_deltas; @@ -158,8 +154,7 @@ JogCalcs::JogCalcs(const JogArmParameters parameters, JogArmShared& shared_varia if (!cartesianJogCalcs(cartesian_deltas, shared_variables, mutex)) continue; } - // If joint jogging command is not all zeros - else + else if (!zero_joint_cmd_flag) { pthread_mutex_lock(&mutex); joint_deltas = shared_variables.joint_command_deltas; @@ -168,6 +163,11 @@ JogCalcs::JogCalcs(const JogArmParameters parameters, JogArmShared& shared_varia if (!jointJogCalcs(joint_deltas, shared_variables)) continue; } + else + { + original_jt_state_ = jt_state_; + outgoing_command_ = composeOutgoingMessage(jt_state_); + } // Halt if the command is stale or inputs are all zero, or commands were zero pthread_mutex_lock(&mutex); @@ -176,12 +176,12 @@ JogCalcs::JogCalcs(const JogArmParameters parameters, JogArmShared& shared_varia if (stale_command || (zero_cartesian_cmd_flag && zero_joint_cmd_flag)) { - halt(outgoing_command_); + suddenHalt(outgoing_command_); zero_cartesian_cmd_flag = true; zero_joint_cmd_flag = true; } - bool valid_nonzero_command = !zero_cartesian_cmd_flag && !zero_joint_cmd_flag; + bool valid_nonzero_command = !zero_cartesian_cmd_flag || !zero_joint_cmd_flag; // Send the newest target joints if (!outgoing_command_.joint_names.empty()) @@ -194,12 +194,15 @@ JogCalcs::JogCalcs(const JogArmParameters parameters, JogArmShared& shared_varia shared_variables.ok_to_publish = true; } // Skip the jogging publication if all inputs have been zero for several cycles in a row. - // num_halt_msgs_to_publish == 0 signifies that we shoud keep republishing forever. + // num_halt_msgs_to_publish == 0 signifies that we should keep republishing forever. else if ((parameters_.num_halt_msgs_to_publish != 0) && (zero_velocity_count > parameters_.num_halt_msgs_to_publish)) { shared_variables.ok_to_publish = false; + // Reset the velocity filters so robot doesn't jump when commands resume + resetVelocityFilters(); } + // The command is invalid but we are publishing num_halt_msgs_to_publish else { shared_variables.outgoing_command = outgoing_command_; @@ -309,8 +312,7 @@ bool JogCalcs::cartesianJogCalcs(geometry_msgs::TwistStamped& cmd, JogArmShared& lowPassFilterVelocities(joint_vel); lowPassFilterPositions(); - const ros::Time next_time = ros::Time::now() + ros::Duration(parameters_.publish_period); - outgoing_command_ = composeOutgoingMessage(jt_state_, next_time); + outgoing_command_ = composeOutgoingMessage(jt_state_); // If close to a collision or a singularity, decelerate applyVelocityScaling(shared_variables, mutex, outgoing_command_, delta_theta_, @@ -318,7 +320,7 @@ bool JogCalcs::cartesianJogCalcs(geometry_msgs::TwistStamped& cmd, JogArmShared& if (!checkIfJointsWithinURDFBounds(outgoing_command_)) { - halt(outgoing_command_); + suddenHalt(outgoing_command_); publishWarning(true); } else @@ -363,13 +365,12 @@ bool JogCalcs::jointJogCalcs(const control_msgs::JointJog& cmd, JogArmShared& sh // update joint state with new values kinematic_state_->setVariableValues(jt_state_); - const ros::Time next_time = ros::Time::now() + ros::Duration(parameters_.publish_delay); - outgoing_command_ = composeOutgoingMessage(jt_state_, next_time); + outgoing_command_ = composeOutgoingMessage(jt_state_); // check if new joint state is valid if (!checkIfJointsWithinURDFBounds(outgoing_command_)) { - halt(outgoing_command_); + suddenHalt(outgoing_command_); publishWarning(true); } else @@ -431,12 +432,11 @@ void JogCalcs::lowPassFilterVelocities(const Eigen::VectorXd& joint_vel) } } -trajectory_msgs::JointTrajectory JogCalcs::composeOutgoingMessage(sensor_msgs::JointState& joint_state, - const ros::Time& stamp) const +trajectory_msgs::JointTrajectory JogCalcs::composeOutgoingMessage(sensor_msgs::JointState& joint_state) const { trajectory_msgs::JointTrajectory new_jt_traj; new_jt_traj.header.frame_id = parameters_.planning_frame; - new_jt_traj.header.stamp = stamp; + new_jt_traj.header.stamp = ros::Time::now(); new_jt_traj.joint_names = joint_state.name; trajectory_msgs::JointTrajectoryPoint point; @@ -465,7 +465,7 @@ bool JogCalcs::applyVelocityScaling(JogArmShared& shared_variables, pthread_mute trajectory_msgs::JointTrajectory& new_jt_traj, const Eigen::VectorXd& delta_theta, double singularity_scale) { - pthread_mutex_unlock(&mutex); + pthread_mutex_lock(&mutex); double collision_scale = shared_variables.collision_velocity_scale; pthread_mutex_unlock(&mutex); @@ -628,8 +628,9 @@ void JogCalcs::publishWarning(bool active) const warning_pub_.publish(status); } -// Avoid a singularity or other issue. Needs to be handled differently for position vs. velocity control -void JogCalcs::halt(trajectory_msgs::JointTrajectory& jt_traj) +// Suddenly halt for a joint limit or other critical issue. +// Is handled differently for position vs. velocity control. +void JogCalcs::suddenHalt(trajectory_msgs::JointTrajectory& jt_traj) { for (std::size_t i = 0; i < num_joints_; ++i) { @@ -761,4 +762,4 @@ bool JogCalcs::addJointIncrements(sensor_msgs::JointState& output, const Eigen:: return true; } -} // namespace jog_arm +} // namespace moveit_jog_arm diff --git a/moveit_experimental/jog_arm/src/jog_arm/jog_ros_interface.cpp b/moveit_experimental/moveit_jog_arm/src/jog_ros_interface.cpp similarity index 94% rename from moveit_experimental/jog_arm/src/jog_arm/jog_ros_interface.cpp rename to moveit_experimental/moveit_jog_arm/src/jog_ros_interface.cpp index 0486a530ef..6eea959af4 100644 --- a/moveit_experimental/jog_arm/src/jog_arm/jog_ros_interface.cpp +++ b/moveit_experimental/moveit_jog_arm/src/jog_ros_interface.cpp @@ -1,6 +1,6 @@ /////////////////////////////////////////////////////////////////////////////// // Title : jog_ros_interface.cpp -// Project : jog_arm +// Project : moveit_jog_arm // Created : 3/9/2017 // Author : Brian O'Neil, Andy Zelenak, Blake Anderson // @@ -39,9 +39,9 @@ // Server node for arm jogging with MoveIt. -#include +#include -namespace jog_arm +namespace moveit_jog_arm { ///////////////////////////////////////////////////////////////////////////////// // JogROSInterface handles ROS subscriptions and instantiates the worker threads. @@ -87,8 +87,6 @@ JogROSInterface::JogROSInterface() // Wait for incoming topics to appear ROS_DEBUG_NAMED(LOGNAME, "Waiting for JointState topic"); ros::topic::waitForMessage(ros_parameters_.joint_topic); - ROS_DEBUG_NAMED(LOGNAME, "Waiting for Cartesian command topic"); - ros::topic::waitForMessage(ros_parameters_.cartesian_command_in_topic); // Wait for low pass filters to stabilize ROS_INFO_STREAM_NAMED(LOGNAME, "Waiting for low-pass filters to stabilize."); @@ -104,7 +102,7 @@ JogROSInterface::JogROSInterface() trajectory_msgs::JointTrajectory outgoing_command = shared_variables_.outgoing_command; // Check for stale cmds - if ((ros::Time::now() - shared_variables_.incoming_cmd_stamp) < + if ((ros::Time::now() - shared_variables_.latest_nonzero_cmd_stamp) < ros::Duration(ros_parameters_.incoming_command_timeout)) { // Mark that incoming commands are not stale @@ -137,12 +135,12 @@ JogROSInterface::JogROSInterface() } else if (shared_variables_.command_is_stale) { - ROS_WARN_STREAM_THROTTLE_NAMED(2, LOGNAME, "Stale command. " - "Try a larger 'incoming_command_timeout' parameter?"); + ROS_WARN_STREAM_THROTTLE_NAMED(10, LOGNAME, "Stale command. " + "Try a larger 'incoming_command_timeout' parameter?"); } else { - ROS_DEBUG_STREAM_THROTTLE_NAMED(2, LOGNAME, "All-zero command. Doing nothing."); + ROS_DEBUG_STREAM_THROTTLE_NAMED(10, LOGNAME, "All-zero command. Doing nothing."); } pthread_mutex_unlock(&shared_variables_mutex_); @@ -189,7 +187,7 @@ void JogROSInterface::deltaCartesianCmdCB(const geometry_msgs::TwistStampedConst shared_variables_.command_deltas.header.frame_id = ros_parameters_.command_frame; } - // Check if input is all zeros. Flag it if so to skip calculations/publication + // Check if input is all zeros. Flag it if so to skip calculations/publication after num_halt_msgs_to_publish shared_variables_.zero_cartesian_cmd_flag = shared_variables_.command_deltas.twist.linear.x == 0.0 && shared_variables_.command_deltas.twist.linear.y == 0.0 && shared_variables_.command_deltas.twist.linear.z == 0.0 && @@ -197,7 +195,10 @@ void JogROSInterface::deltaCartesianCmdCB(const geometry_msgs::TwistStampedConst shared_variables_.command_deltas.twist.angular.y == 0.0 && shared_variables_.command_deltas.twist.angular.z == 0.0; - shared_variables_.incoming_cmd_stamp = msg->header.stamp; + if (!shared_variables_.zero_cartesian_cmd_flag) + { + shared_variables_.latest_nonzero_cmd_stamp = msg->header.stamp; + } pthread_mutex_unlock(&shared_variables_mutex_); } @@ -215,7 +216,10 @@ void JogROSInterface::deltaJointCmdCB(const control_msgs::JointJogConstPtr& msg) }; shared_variables_.zero_joint_cmd_flag = all_zeros; - shared_variables_.incoming_cmd_stamp = msg->header.stamp; + if (!shared_variables_.zero_joint_cmd_flag) + { + shared_variables_.latest_nonzero_cmd_stamp = msg->header.stamp; + } pthread_mutex_unlock(&shared_variables_mutex_); } @@ -240,12 +244,11 @@ bool JogROSInterface::readParameters(ros::NodeHandle& n) ROS_ERROR_STREAM_NAMED(LOGNAME, "A namespace must be specified in the launch file, like:"); ROS_ERROR_STREAM_NAMED(LOGNAME, ""); + "value=\"left_jog_server\" />"); return false; } error += !rosparam_shortcuts::get("", n, parameter_ns + "/publish_period", ros_parameters_.publish_period); - error += !rosparam_shortcuts::get("", n, parameter_ns + "/publish_delay", ros_parameters_.publish_delay); error += !rosparam_shortcuts::get("", n, parameter_ns + "/collision_check_rate", ros_parameters_.collision_check_rate); error += !rosparam_shortcuts::get("", n, parameter_ns + "/num_halt_msgs_to_publish", @@ -364,4 +367,4 @@ bool JogROSInterface::readParameters(ros::NodeHandle& n) return true; } -} // namespace jog_arm +} // namespace moveit_jog_arm diff --git a/moveit_experimental/jog_arm/src/jog_arm/jog_arm_server.cpp b/moveit_experimental/moveit_jog_arm/src/jog_server.cpp similarity index 89% rename from moveit_experimental/jog_arm/src/jog_arm/jog_arm_server.cpp rename to moveit_experimental/moveit_jog_arm/src/jog_server.cpp index 2d2c545a70..ba96f3049f 100644 --- a/moveit_experimental/jog_arm/src/jog_arm/jog_arm_server.cpp +++ b/moveit_experimental/moveit_jog_arm/src/jog_server.cpp @@ -1,6 +1,6 @@ /////////////////////////////////////////////////////////////////////////////// -// Title : jog_arm_server.cpp -// Project : jog_arm +// Title : jog_server.cpp +// Project : moveit_jog_arm // Created : 12/31/2018 // Author : Andy Zelenak // @@ -37,13 +37,13 @@ // /////////////////////////////////////////////////////////////////////////////// -#include +#include int main(int argc, char** argv) { - ros::init(argc, argv, jog_arm::LOGNAME); + ros::init(argc, argv, moveit_jog_arm::LOGNAME); - jog_arm::JogROSInterface ros_interface; + moveit_jog_arm::JogROSInterface ros_interface; return 0; } diff --git a/moveit_experimental/jog_arm/src/jog_arm/low_pass_filter.cpp b/moveit_experimental/moveit_jog_arm/src/low_pass_filter.cpp similarity index 74% rename from moveit_experimental/jog_arm/src/jog_arm/low_pass_filter.cpp rename to moveit_experimental/moveit_jog_arm/src/low_pass_filter.cpp index fcec7bdaa1..8ee2809a5c 100644 --- a/moveit_experimental/jog_arm/src/jog_arm/low_pass_filter.cpp +++ b/moveit_experimental/moveit_jog_arm/src/low_pass_filter.cpp @@ -1,6 +1,6 @@ /////////////////////////////////////////////////////////////////////////////// // Title : low_pass_filter.cpp -// Project : jog_arm +// Project : moveit_jog_arm // Created : 1/11/2019 // Author : Andy Zelenak // @@ -37,9 +37,9 @@ // /////////////////////////////////////////////////////////////////////////////// -#include +#include -namespace jog_arm +namespace moveit_jog_arm { LowPassFilter::LowPassFilter(double low_pass_filter_coeff) { @@ -50,29 +50,22 @@ void LowPassFilter::reset(double data) { previous_measurements_[0] = data; previous_measurements_[1] = data; - previous_measurements_[2] = data; - previous_filtered_measurements_[0] = data; - previous_filtered_measurements_[1] = data; + previous_filtered_measurement_ = data; } double LowPassFilter::filter(double new_measurement) { // Push in the new measurement - previous_measurements_[2] = previous_measurements_[1]; previous_measurements_[1] = previous_measurements_[0]; previous_measurements_[0] = new_measurement; - double new_filtered_msrmt = - (1. / (1. + filter_coeff_ * filter_coeff_ + 1.414 * filter_coeff_)) * - (previous_measurements_[2] + 2. * previous_measurements_[1] + previous_measurements_[0] - - (filter_coeff_ * filter_coeff_ - 1.414 * filter_coeff_ + 1.) * previous_filtered_measurements_[1] - - (-2. * filter_coeff_ * filter_coeff_ + 2.) * previous_filtered_measurements_[0]); + double new_filtered_msrmt = (1. / (1. + filter_coeff_)) * (previous_measurements_[1] + previous_measurements_[0] - + (-filter_coeff_ + 1.) * previous_filtered_measurement_); // Store the new filtered measurement - previous_filtered_measurements_[1] = previous_filtered_measurements_[0]; - previous_filtered_measurements_[0] = new_filtered_msrmt; + previous_filtered_measurement_ = new_filtered_msrmt; return new_filtered_msrmt; } -} // namespace jog_arm +} // namespace moveit_jog_arm diff --git a/moveit_experimental/jog_arm/src/jog_arm/teleop_examples/spacenav_to_twist.cpp b/moveit_experimental/moveit_jog_arm/src/teleop_examples/spacenav_to_twist.cpp similarity index 85% rename from moveit_experimental/jog_arm/src/jog_arm/teleop_examples/spacenav_to_twist.cpp rename to moveit_experimental/moveit_jog_arm/src/teleop_examples/spacenav_to_twist.cpp index 69f4bf0cf3..20ca24a382 100644 --- a/moveit_experimental/jog_arm/src/jog_arm/teleop_examples/spacenav_to_twist.cpp +++ b/moveit_experimental/moveit_jog_arm/src/teleop_examples/spacenav_to_twist.cpp @@ -3,7 +3,7 @@ #include "ros/ros.h" #include "sensor_msgs/Joy.h" -namespace jog_arm +namespace moveit_jog_arm { static const int NUM_SPINNERS = 1; static const int QUEUE_LENGTH = 1; @@ -14,8 +14,8 @@ class SpaceNavToTwist SpaceNavToTwist() : spinner_(NUM_SPINNERS) { joy_sub_ = n_.subscribe("spacenav/joy", QUEUE_LENGTH, &SpaceNavToTwist::joyCallback, this); - twist_pub_ = n_.advertise("jog_arm_server/delta_jog_cmds", QUEUE_LENGTH); - joint_delta_pub_ = n_.advertise("jog_arm_server/joint_delta_jog_cmds", QUEUE_LENGTH); + twist_pub_ = n_.advertise("jog_server/delta_jog_cmds", QUEUE_LENGTH); + joint_delta_pub_ = n_.advertise("jog_server/joint_delta_jog_cmds", QUEUE_LENGTH); spinner_.start(); ros::waitForShutdown(); @@ -40,8 +40,8 @@ class SpaceNavToTwist // Joint jogging with the buttons control_msgs::JointJog joint_deltas; - // This example is for a Motoman SIA5. joint_s is the base joint. - joint_deltas.joint_names.push_back("joint_s"); + // This example is for a UR5. + joint_deltas.joint_names.push_back("shoulder_pan_joint"); // Button 0: positive on the wrist joint // Button 1: negative on the wrist joint @@ -57,13 +57,13 @@ class SpaceNavToTwist ros::Publisher twist_pub_, joint_delta_pub_; ros::AsyncSpinner spinner_; }; -} // namespace jog_arm +} // namespace moveit_jog_arm int main(int argc, char** argv) { ros::init(argc, argv, "spacenav_to_twist"); - jog_arm::SpaceNavToTwist to_twist; + moveit_jog_arm::SpaceNavToTwist to_twist; return 0; } diff --git a/moveit_experimental/jog_arm/test/arm_setup/config/initial_position.yaml b/moveit_experimental/moveit_jog_arm/test/arm_setup/config/initial_position.yaml similarity index 100% rename from moveit_experimental/jog_arm/test/arm_setup/config/initial_position.yaml rename to moveit_experimental/moveit_jog_arm/test/arm_setup/config/initial_position.yaml diff --git a/moveit_experimental/jog_arm/test/arm_setup/config/jog_settings.yaml b/moveit_experimental/moveit_jog_arm/test/arm_setup/config/jog_settings.yaml similarity index 81% rename from moveit_experimental/jog_arm/test/arm_setup/config/jog_settings.yaml rename to moveit_experimental/moveit_jog_arm/test/arm_setup/config/jog_settings.yaml index 15668db878..6fd1119af4 100644 --- a/moveit_experimental/jog_arm/test/arm_setup/config/jog_settings.yaml +++ b/moveit_experimental/moveit_jog_arm/test/arm_setup/config/jog_settings.yaml @@ -5,8 +5,8 @@ scale: # Only used if command_in_type=="unitless" linear: 0.003 # Max linear velocity. Meters per publish_period. rotational: 0.006 # Max angular velocity. Rads per publish_period. joint: 0.01 # Max joint angular/linear velocity. Rads or Meters per publish period. -cartesian_command_in_topic: jog_arm_server/delta_jog_cmds # Topic for xyz commands -joint_command_in_topic: jog_arm_server/joint_delta_jog_cmds # Topic for angle commands +cartesian_command_in_topic: jog_server/delta_jog_cmds # Topic for xyz commands +joint_command_in_topic: jog_server/joint_delta_jog_cmds # Topic for angle commands command_frame: base_link # TF frame that incoming cmds are given in incoming_command_timeout: 1 # Stop jogging if X seconds elapsed without a new cmd joint_topic: joint_states @@ -14,16 +14,15 @@ move_group_name: panda_arm # Often 'manipulator' or 'arm' lower_singularity_threshold: 30 # Start decelerating when the condition number hits this (close to singularity). Larger --> closer to singularity hard_stop_singularity_threshold: 45 # Stop when the condition number hits this. Larger --> closer to singularity collision_proximity_threshold: 0.03 # Start decelerating when a collision is this far [m] -planning_frame: base_link # The MoveIt! planning frame. Often 'base_link' +planning_frame: base_link # The MoveIt planning frame. Often 'base_link' low_pass_filter_coeff: 2. # Larger-> more smoothing to jog commands, but more lag. publish_period: 0.01 # 1/Nominal publish rate [seconds] -publish_delay: 0.005 # delay between calculation and execution start of command collision_check_rate: 5 # [Hz] Collision-checking can easily bog down a CPU if done too often. num_halt_msgs_to_publish: 1 # If 0, republish commands forever even if the robot is stationary. Otherwise, specify num. to publish # Publish boolean warnings to this topic -warning_topic: jog_arm_server/warning +warning_topic: jog_server/warning joint_limit_margin: 0.1 # added as a buffer to joint limits [radians]. If moving quickly, make this larger. -command_out_topic: jog_arm_server/command # Find this topic by 'rostopic list' or 'rostopic list | grep command' or 'rqt_graph' +command_out_topic: jog_server/command # Find this topic by 'rostopic list' or 'rostopic list | grep command' or 'rqt_graph' # What type of topic does your robot driver expect? # Currently supported are std_msgs/Float64MultiArray (for ros_control JointGroupVelocityController) # or trajectory_msgs/JointTrajectory (for Universal Robots and other non-ros_control robots) diff --git a/moveit_experimental/jog_arm/test/arm_setup/launch/panda_move_group.launch b/moveit_experimental/moveit_jog_arm/test/arm_setup/launch/panda_move_group.launch similarity index 100% rename from moveit_experimental/jog_arm/test/arm_setup/launch/panda_move_group.launch rename to moveit_experimental/moveit_jog_arm/test/arm_setup/launch/panda_move_group.launch diff --git a/moveit_experimental/jog_arm/test/integration/test_jog_arm_integration.py b/moveit_experimental/moveit_jog_arm/test/integration/test_jog_arm_integration.py similarity index 93% rename from moveit_experimental/jog_arm/test/integration/test_jog_arm_integration.py rename to moveit_experimental/moveit_jog_arm/test/integration/test_jog_arm_integration.py index 6689c0224a..ca30f5f3ed 100755 --- a/moveit_experimental/jog_arm/test/integration/test_jog_arm_integration.py +++ b/moveit_experimental/moveit_jog_arm/test/integration/test_jog_arm_integration.py @@ -11,10 +11,10 @@ JOG_ARM_SETTLE_TIME_S = 10 ROS_SETTLE_TIME_S = 10 -JOINT_JOG_COMMAND_TOPIC = 'jog_arm_server/joint_delta_jog_cmds' -CARTESIAN_JOG_COMMAND_TOPIC = 'jog_arm_server/delta_jog_cmds' +JOINT_JOG_COMMAND_TOPIC = 'jog_server/joint_delta_jog_cmds' +CARTESIAN_JOG_COMMAND_TOPIC = 'jog_server/delta_jog_cmds' -COMMAND_OUT_TOPIC = 'jog_arm_server/command' +COMMAND_OUT_TOPIC = 'jog_server/command' @pytest.fixture diff --git a/moveit_experimental/jog_arm/test/launch/jog_arm_integration_test.test b/moveit_experimental/moveit_jog_arm/test/launch/jog_arm_integration_test.test similarity index 55% rename from moveit_experimental/jog_arm/test/launch/jog_arm_integration_test.test rename to moveit_experimental/moveit_jog_arm/test/launch/jog_arm_integration_test.test index f9c48abc8c..4cd7ccb4c2 100644 --- a/moveit_experimental/jog_arm/test/launch/jog_arm_integration_test.test +++ b/moveit_experimental/moveit_jog_arm/test/launch/jog_arm_integration_test.test @@ -10,7 +10,7 @@ These aren't suitable for actually jogging a robot in RViz, but they are good enough to test jog node output. --> - + @@ -19,20 +19,20 @@ - + - - + + - - - + + + - + diff --git a/moveit_experimental/package.xml b/moveit_experimental/package.xml deleted file mode 100644 index e34d9ee6dc..0000000000 --- a/moveit_experimental/package.xml +++ /dev/null @@ -1,26 +0,0 @@ - - moveit_experimental - 1.0.1 - Experimental packages for MoveIt! - MoveIt! Release Team - - BSD - http://moveit.ros.org - - catkin - - control_msgs - geometry_msgs - joy_teleop - moveit_ros_planning_interface - rosparam_shortcuts - spacenav_node - tf2_ros - - ros_pytest - rostest - - - - - diff --git a/moveit_kinematics/CMakeLists.txt b/moveit_kinematics/CMakeLists.txt index 2f66a856fb..9383ecfb6c 100644 --- a/moveit_kinematics/CMakeLists.txt +++ b/moveit_kinematics/CMakeLists.txt @@ -1,7 +1,8 @@ -cmake_minimum_required(VERSION 2.8.12) +cmake_minimum_required(VERSION 3.1.3) project(moveit_kinematics) -add_compile_options(-std=c++14) +set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_EXTENSIONS OFF) if(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Release) diff --git a/moveit_kinematics/cached_ik_kinematics_plugin/CMakeLists.txt b/moveit_kinematics/cached_ik_kinematics_plugin/CMakeLists.txt index 05005fa6a5..b295d3eb50 100644 --- a/moveit_kinematics/cached_ik_kinematics_plugin/CMakeLists.txt +++ b/moveit_kinematics/cached_ik_kinematics_plugin/CMakeLists.txt @@ -9,7 +9,10 @@ set_target_properties(${MOVEIT_LIB_NAME} PROPERTIES VERSION "${${PROJECT_NAME}_V target_link_libraries(${MOVEIT_LIB_NAME} ${Boost_FILESYSTEM_LIBRARY} ${catkin_LIBRARIES}) -install(TARGETS ${MOVEIT_LIB_NAME} LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}) +install(TARGETS ${MOVEIT_LIB_NAME} + LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}) if(trac_ik_kinematics_plugin_FOUND) include_directories(${trac_ik_kinematics_plugin_INCLUDE_DIRS}) @@ -27,7 +30,10 @@ if(trac_ik_kinematics_plugin_FOUND) target_link_libraries(${MOVEIT_LIB_NAME} ${trac_ik_kinematics_plugin_LIBRARIES}) set_target_properties(${MOVEIT_LIB_NAME} PROPERTIES COMPILE_DEFINITIONS "CACHED_IK_KINEMATICS_TRAC_IK") endif() -install(TARGETS ${MOVEIT_LIB_NAME} LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}) +install(TARGETS ${MOVEIT_LIB_NAME} + LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}) # This is just for testing purposes; the arms from Universal Robots have # analytic solvers, so caching just adds extra overhead. @@ -42,7 +48,10 @@ if(ur_kinematics_FOUND) moveit_cached_ik_kinematics_base ${ur${UR}_pluginlib} ${catkin_LIBRARIES}) - install(TARGETS ${MOVEIT_LIB_NAME} LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}) + install(TARGETS ${MOVEIT_LIB_NAME} + LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}) endforeach() endif() diff --git a/moveit_kinematics/cached_ik_kinematics_plugin/README.md b/moveit_kinematics/cached_ik_kinematics_plugin/README.md index 571d53ab2c..77aa5697cd 100644 --- a/moveit_kinematics/cached_ik_kinematics_plugin/README.md +++ b/moveit_kinematics/cached_ik_kinematics_plugin/README.md @@ -46,7 +46,7 @@ This illustrates two points: (1) if the IK solver is slow, significant improveme Below is a complete list of all arguments: -- `robot`: the name of the corresponding MoveIt! config package +- `robot`: the name of the corresponding MoveIt config package - `group`: the joint group to measure (by default performance is reported for all joint groups) - `tip`: the name of the end effector (by default the default end effectors are used) - `num`: the number of IK calls per joint group diff --git a/moveit_kinematics/cached_ik_kinematics_plugin/include/moveit/cached_ik_kinematics_plugin/cached_ik_kinematics_plugin.h b/moveit_kinematics/cached_ik_kinematics_plugin/include/moveit/cached_ik_kinematics_plugin/cached_ik_kinematics_plugin.h index 649d89f7df..1d4a76286f 100644 --- a/moveit_kinematics/cached_ik_kinematics_plugin/include/moveit/cached_ik_kinematics_plugin/cached_ik_kinematics_plugin.h +++ b/moveit_kinematics/cached_ik_kinematics_plugin/include/moveit/cached_ik_kinematics_plugin/cached_ik_kinematics_plugin.h @@ -34,8 +34,7 @@ /* Author: Mark Moll */ -#ifndef MOVEIT_ROS_PLANNING_CACHED_IK_KINEMATICS_PLUGIN_ -#define MOVEIT_ROS_PLANNING_CACHED_IK_KINEMATICS_PLUGIN_ +#pragma once #include #include @@ -348,4 +347,3 @@ class CachedMultiTipIKKinematicsPlugin : public CachedIKKinematicsPlugin -#ifndef MOVEIT_ROS_PLANNING_CACHED_IK_KINEMATICS_GREEDY_K_CENTERS_ -#define MOVEIT_ROS_PLANNING_CACHED_IK_KINEMATICS_GREEDY_K_CENTERS_ +#pragma once #include #include @@ -129,5 +128,3 @@ class GreedyKCenters std::mt19937 generator_{ std::random_device{}() }; }; } - -#endif diff --git a/moveit_kinematics/cached_ik_kinematics_plugin/include/moveit/cached_ik_kinematics_plugin/detail/NearestNeighbors.h b/moveit_kinematics/cached_ik_kinematics_plugin/include/moveit/cached_ik_kinematics_plugin/detail/NearestNeighbors.h index dc026872fe..e3fc410078 100644 --- a/moveit_kinematics/cached_ik_kinematics_plugin/include/moveit/cached_ik_kinematics_plugin/detail/NearestNeighbors.h +++ b/moveit_kinematics/cached_ik_kinematics_plugin/include/moveit/cached_ik_kinematics_plugin/detail/NearestNeighbors.h @@ -36,8 +36,7 @@ // This file is a slightly modified version of -#ifndef MOVEIT_ROS_PLANNING_CACHED_IK_KINEMATICS_NEAREST_NEIGHBORS_ -#define MOVEIT_ROS_PLANNING_CACHED_IK_KINEMATICS_NEAREST_NEIGHBORS_ +#pragma once #include #include @@ -116,5 +115,3 @@ class NearestNeighbors DistanceFunction distFun_; }; } - -#endif diff --git a/moveit_kinematics/cached_ik_kinematics_plugin/include/moveit/cached_ik_kinematics_plugin/detail/NearestNeighborsGNAT.h b/moveit_kinematics/cached_ik_kinematics_plugin/include/moveit/cached_ik_kinematics_plugin/detail/NearestNeighborsGNAT.h index 6d3b72f55e..dc21099fc6 100644 --- a/moveit_kinematics/cached_ik_kinematics_plugin/include/moveit/cached_ik_kinematics_plugin/detail/NearestNeighborsGNAT.h +++ b/moveit_kinematics/cached_ik_kinematics_plugin/include/moveit/cached_ik_kinematics_plugin/detail/NearestNeighborsGNAT.h @@ -36,8 +36,7 @@ // This file is a slightly modified version of -#ifndef MOVEIT_ROS_PLANNING_CACHED_IK_KINEMATICS_NEAREST_NEIGHBORS_GNAT_ -#define MOVEIT_ROS_PLANNING_CACHED_IK_KINEMATICS_NEAREST_NEIGHBORS_GNAT_ +#pragma once #include "NearestNeighbors.h" #include "GreedyKCenters.h" @@ -720,5 +719,3 @@ class NearestNeighborsGNAT : public NearestNeighbors<_T> std::unordered_set removed_; }; } - -#endif diff --git a/moveit_kinematics/ikfast_kinematics_plugin/README.md b/moveit_kinematics/ikfast_kinematics_plugin/README.md index 2f90c02007..c29d897011 100644 --- a/moveit_kinematics/ikfast_kinematics_plugin/README.md +++ b/moveit_kinematics/ikfast_kinematics_plugin/README.md @@ -1,9 +1,9 @@ -MoveIt! IKFast +MoveIt IKFast ========== * Authors: Dave Coleman, CU Boulder; Jeremy Zoss, SwRI; David Butterworth, KAIST, Mathias Lüdtke, Fraunhofer IPA * Date: 5/24/2013 -Generates a IKFast kinematics plugin for MoveIt! using [OpenRave](http://openrave.org/) generated cpp files. +Generates a IKFast kinematics plugin for MoveIt using [OpenRave](http://openrave.org/) generated cpp files. Tested on ROS Hydro and greater with Catkin using OpenRave 0.8 with a 6dof and 7dof robot arm manipulator. Does not work with greater than 7dof. diff --git a/moveit_kinematics/ikfast_kinematics_plugin/scripts/create_ikfast_moveit_plugin.py b/moveit_kinematics/ikfast_kinematics_plugin/scripts/create_ikfast_moveit_plugin.py index ab5abaaead..e9ce8770d7 100755 --- a/moveit_kinematics/ikfast_kinematics_plugin/scripts/create_ikfast_moveit_plugin.py +++ b/moveit_kinematics/ikfast_kinematics_plugin/scripts/create_ikfast_moveit_plugin.py @@ -1,7 +1,7 @@ #! /usr/bin/env python from __future__ import print_function ''' -IKFast Plugin Generator for MoveIt! +IKFast Plugin Generator for MoveIt Creates a kinematics plugin using the output of IKFast from OpenRAVE. This plugin and the move_group node can be used as a general @@ -71,13 +71,13 @@ def get_pkg_dir(pkg_name): def create_parser(): parser = argparse.ArgumentParser( - description="Generate an IKFast MoveIt! kinematic plugin") + description="Generate an IKFast MoveIt kinematic plugin") parser.add_argument("robot_name", help="The name of your robot") parser.add_argument("planning_group_name", help="The name of the planning group for which your IKFast solution was generated") parser.add_argument("ikfast_plugin_pkg", - help="The name of the MoveIt! IKFast Kinematics Plugin to be created/updated") + help="The name of the MoveIt IKFast Kinematics Plugin to be created/updated") parser.add_argument("base_link_name", help="The name of the base link that was used when generating your IKFast solution") parser.add_argument("eef_link_name", diff --git a/moveit_kinematics/ikfast_kinematics_plugin/templates/CMakeLists.txt b/moveit_kinematics/ikfast_kinematics_plugin/templates/CMakeLists.txt index 5706256fb2..e4020ed280 100644 --- a/moveit_kinematics/ikfast_kinematics_plugin/templates/CMakeLists.txt +++ b/moveit_kinematics/ikfast_kinematics_plugin/templates/CMakeLists.txt @@ -1,7 +1,8 @@ -cmake_minimum_required(VERSION 2.8.12) +cmake_minimum_required(VERSION 3.1.3) project(_PACKAGE_NAME_) -add_compile_options(-std=c++14) +set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_EXTENSIONS OFF) find_package(catkin REQUIRED COMPONENTS moveit_core @@ -25,7 +26,9 @@ target_compile_options(${IKFAST_LIBRARY_NAME} PRIVATE -Wno-unused-variable) install(TARGETS ${IKFAST_LIBRARY_NAME} - LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}) + LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}) install( FILES diff --git a/moveit_kinematics/ikfast_kinematics_plugin/templates/ikfast61_moveit_plugin_template.cpp b/moveit_kinematics/ikfast_kinematics_plugin/templates/ikfast61_moveit_plugin_template.cpp index c76082e880..b2fd03982a 100644 --- a/moveit_kinematics/ikfast_kinematics_plugin/templates/ikfast61_moveit_plugin_template.cpp +++ b/moveit_kinematics/ikfast_kinematics_plugin/templates/ikfast61_moveit_plugin_template.cpp @@ -34,11 +34,11 @@ *********************************************************************/ /* - * IKFast Kinematics Solver Plugin for MoveIt! wrapping an ikfast solver from OpenRAVE. + * IKFast Kinematics Solver Plugin for MoveIt wrapping an ikfast solver from OpenRAVE. * * AUTO-GENERATED by create_ikfast_moveit_plugin.py in moveit_kinematics package. * - * This file, including the ikfast cpp from OpenRAVE below, forms a MoveIt! kinematics plugin. + * This file, including the ikfast cpp from OpenRAVE below, forms a MoveIt kinematics plugin. */ #include @@ -940,7 +940,7 @@ bool IKFastKinematicsPlugin::searchPositionIK(const geometry_msgs::Pose& ik_pose if (!consistency_limits.empty()) { - // MoveIt! replaced consistency_limit (scalar) w/ consistency_limits (vector) + // MoveIt replaced consistency_limit (scalar) w/ consistency_limits (vector) // Assume [0]th free_params element for now. Probably wrong. double max_limit = fmin(joint_max_vector_[free_params_[0]], initial_guess + consistency_limits[free_params_[0]]); double min_limit = fmax(joint_min_vector_[free_params_[0]], initial_guess - consistency_limits[free_params_[0]]); diff --git a/moveit_kinematics/kdl_kinematics_plugin/CMakeLists.txt b/moveit_kinematics/kdl_kinematics_plugin/CMakeLists.txt index 9388ae6f26..cd3ffc0891 100644 --- a/moveit_kinematics/kdl_kinematics_plugin/CMakeLists.txt +++ b/moveit_kinematics/kdl_kinematics_plugin/CMakeLists.txt @@ -7,5 +7,8 @@ set_target_properties(${MOVEIT_LIB_NAME} PROPERTIES VERSION "${${PROJECT_NAME}_V target_link_libraries(${MOVEIT_LIB_NAME} ${catkin_LIBRARIES}) -install(TARGETS ${MOVEIT_LIB_NAME} LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}) +install(TARGETS ${MOVEIT_LIB_NAME} + LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}) install(DIRECTORY include/ DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}) diff --git a/moveit_kinematics/kdl_kinematics_plugin/include/moveit/kdl_kinematics_plugin/chainiksolver_vel_mimic_svd.hpp b/moveit_kinematics/kdl_kinematics_plugin/include/moveit/kdl_kinematics_plugin/chainiksolver_vel_mimic_svd.hpp index 9cff711601..afefc41f3c 100644 --- a/moveit_kinematics/kdl_kinematics_plugin/include/moveit/kdl_kinematics_plugin/chainiksolver_vel_mimic_svd.hpp +++ b/moveit_kinematics/kdl_kinematics_plugin/include/moveit/kdl_kinematics_plugin/chainiksolver_vel_mimic_svd.hpp @@ -23,8 +23,7 @@ // linear relationship to that of another joint. // Copyright (C) 2013 Sachin Chitta, Willow Garage -#ifndef KDL_CHAIN_IKSOLVERVEL_PINV_Mimic_HPP -#define KDL_CHAIN_IKSOLVERVEL_PINV_Mimic_HPP +#pragma once #include #include @@ -116,4 +115,3 @@ class ChainIkSolverVelMimicSVD : public ChainIkSolverVel Jacobian jac_reduced_; // reduced Jacobian with contributions of mimic joints mapped onto active DoFs }; } -#endif diff --git a/moveit_kinematics/kdl_kinematics_plugin/include/moveit/kdl_kinematics_plugin/joint_mimic.hpp b/moveit_kinematics/kdl_kinematics_plugin/include/moveit/kdl_kinematics_plugin/joint_mimic.hpp index 6814441850..45ad0a0c47 100644 --- a/moveit_kinematics/kdl_kinematics_plugin/include/moveit/kdl_kinematics_plugin/joint_mimic.hpp +++ b/moveit_kinematics/kdl_kinematics_plugin/include/moveit/kdl_kinematics_plugin/joint_mimic.hpp @@ -34,8 +34,7 @@ /* Author: Sachin Chitta */ -#ifndef MOVEIT_KDL_KINEMATICS_PLUGIN_JOINT_MIMIC -#define MOVEIT_KDL_KINEMATICS_PLUGIN_JOINT_MIMIC +#pragma once namespace kdl_kinematics_plugin { @@ -71,5 +70,3 @@ class JointMimic } }; } - -#endif diff --git a/moveit_kinematics/kdl_kinematics_plugin/include/moveit/kdl_kinematics_plugin/kdl_kinematics_plugin.h b/moveit_kinematics/kdl_kinematics_plugin/include/moveit/kdl_kinematics_plugin/kdl_kinematics_plugin.h index 6f094a50e0..6e13e834f4 100644 --- a/moveit_kinematics/kdl_kinematics_plugin/include/moveit/kdl_kinematics_plugin/kdl_kinematics_plugin.h +++ b/moveit_kinematics/kdl_kinematics_plugin/include/moveit/kdl_kinematics_plugin/kdl_kinematics_plugin.h @@ -34,8 +34,7 @@ /* Author: Sachin Chitta, David Lu!!, Ugo Cupcic */ -#ifndef MOVEIT_ROS_PLANNING_KDL_KINEMATICS_PLUGIN_ -#define MOVEIT_ROS_PLANNING_KDL_KINEMATICS_PLUGIN_ +#pragma once // ROS #include @@ -53,7 +52,7 @@ #include #include -// MoveIt! +// MoveIt #include #include #include @@ -196,5 +195,3 @@ class KDLKinematicsPlugin : public kinematics::KinematicsBase double orientation_vs_position_weight_; }; } - -#endif diff --git a/moveit_kinematics/lma_kinematics_plugin/CMakeLists.txt b/moveit_kinematics/lma_kinematics_plugin/CMakeLists.txt index 0397388312..1dadddcd56 100644 --- a/moveit_kinematics/lma_kinematics_plugin/CMakeLists.txt +++ b/moveit_kinematics/lma_kinematics_plugin/CMakeLists.txt @@ -5,5 +5,8 @@ set_target_properties(${MOVEIT_LIB_NAME} PROPERTIES VERSION "${${PROJECT_NAME}_V target_link_libraries(${MOVEIT_LIB_NAME} ${catkin_LIBRARIES}) -install(TARGETS ${MOVEIT_LIB_NAME} LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}) +install(TARGETS ${MOVEIT_LIB_NAME} + LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}) install(DIRECTORY include/ DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}) diff --git a/moveit_kinematics/lma_kinematics_plugin/include/moveit/lma_kinematics_plugin/lma_kinematics_plugin.h b/moveit_kinematics/lma_kinematics_plugin/include/moveit/lma_kinematics_plugin/lma_kinematics_plugin.h index 996080593a..79c1155d67 100644 --- a/moveit_kinematics/lma_kinematics_plugin/include/moveit/lma_kinematics_plugin/lma_kinematics_plugin.h +++ b/moveit_kinematics/lma_kinematics_plugin/include/moveit/lma_kinematics_plugin/lma_kinematics_plugin.h @@ -34,8 +34,7 @@ /* Author: Francisco Suarez-Ruiz */ -#ifndef MOVEIT_ROS_PLANNING_LMA_KINEMATICS_PLUGIN_H -#define MOVEIT_ROS_PLANNING_LMA_KINEMATICS_PLUGIN_H +#pragma once // ROS #include @@ -53,7 +52,7 @@ #include #include -// MoveIt! +// MoveIt #include #include #include @@ -182,5 +181,3 @@ class LMAKinematicsPlugin : public kinematics::KinematicsBase double orientation_vs_position_weight_; }; } - -#endif diff --git a/moveit_kinematics/package.xml b/moveit_kinematics/package.xml index 649b3ef22a..64ddccb0b9 100644 --- a/moveit_kinematics/package.xml +++ b/moveit_kinematics/package.xml @@ -2,7 +2,7 @@ moveit_kinematics 1.0.1 - Package for all inverse kinematics solvers in MoveIt! + Package for all inverse kinematics solvers in MoveIt Dave Coleman Ioan Sucan @@ -11,7 +11,7 @@ Dave Coleman G.A. vd. Hoorn Jorge Nicho - MoveIt! Release Team + MoveIt Release Team BSD diff --git a/moveit_kinematics/srv_kinematics_plugin/CMakeLists.txt b/moveit_kinematics/srv_kinematics_plugin/CMakeLists.txt index b7829f2412..2cf14dd877 100644 --- a/moveit_kinematics/srv_kinematics_plugin/CMakeLists.txt +++ b/moveit_kinematics/srv_kinematics_plugin/CMakeLists.txt @@ -5,5 +5,8 @@ set_target_properties(${MOVEIT_LIB_NAME} PROPERTIES VERSION "${${PROJECT_NAME}_V target_link_libraries(${MOVEIT_LIB_NAME} ${catkin_LIBRARIES}) -install(TARGETS ${MOVEIT_LIB_NAME} LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}) +install(TARGETS ${MOVEIT_LIB_NAME} + LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}) install(DIRECTORY include/ DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}) diff --git a/moveit_kinematics/srv_kinematics_plugin/include/moveit/srv_kinematics_plugin/srv_kinematics_plugin.h b/moveit_kinematics/srv_kinematics_plugin/include/moveit/srv_kinematics_plugin/srv_kinematics_plugin.h index b19d1e880a..f0a1494648 100644 --- a/moveit_kinematics/srv_kinematics_plugin/include/moveit/srv_kinematics_plugin/srv_kinematics_plugin.h +++ b/moveit_kinematics/srv_kinematics_plugin/include/moveit/srv_kinematics_plugin/srv_kinematics_plugin.h @@ -33,14 +33,13 @@ *********************************************************************/ /* Author: Dave Coleman, Masaki Murooka - Desc: Connects MoveIt! to any inverse kinematics solver via a ROS service call + Desc: Connects MoveIt to any inverse kinematics solver via a ROS service call Supports planning groups with multiple tip frames \todo: better support for mimic joints \todo: better support for redundant joints */ -#ifndef MOVEIT_ROS_PLANNING_SRV_KINEMATICS_PLUGIN_ -#define MOVEIT_ROS_PLANNING_SRV_KINEMATICS_PLUGIN_ +#pragma once // ROS #include @@ -55,7 +54,7 @@ #include #include -// MoveIt! +// MoveIt #include #include @@ -159,5 +158,3 @@ class SrvKinematicsPlugin : public kinematics::KinematicsBase std::shared_ptr ik_service_client_; }; } - -#endif diff --git a/moveit_kinematics/test/CMakeLists.txt b/moveit_kinematics/test/CMakeLists.txt index b7dee1f18d..be739327c6 100644 --- a/moveit_kinematics/test/CMakeLists.txt +++ b/moveit_kinematics/test/CMakeLists.txt @@ -36,5 +36,6 @@ if(CATKIN_ENABLE_TESTING) target_link_libraries(benchmark_ik ${catkin_LIBRARIES} ${moveit_ros_planning_LIBRARIES} ${Boost_PROGRAM_OPTIONS_LIBRARY}) - install(TARGETS benchmark_ik DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}) + install(TARGETS benchmark_ik + RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}) endif() diff --git a/moveit_kinematics/test/test_kinematics_plugin.cpp b/moveit_kinematics/test/test_kinematics_plugin.cpp index 682a519909..1235bfd9f9 100644 --- a/moveit_kinematics/test/test_kinematics_plugin.cpp +++ b/moveit_kinematics/test/test_kinematics_plugin.cpp @@ -43,7 +43,7 @@ #include #include -// MoveIt! +// MoveIt #include #include #include diff --git a/moveit_planners/README.md b/moveit_planners/README.md index 0f0f685d07..5d35579eac 100644 --- a/moveit_planners/README.md +++ b/moveit_planners/README.md @@ -1,3 +1,3 @@ -# MoveIt! Planners +# MoveIt Planners Interfaces for the motion planning libraries used in MoveIt diff --git a/moveit_planners/chomp/chomp_interface/CHANGELOG.rst b/moveit_planners/chomp/chomp_interface/CHANGELOG.rst index 3b2e6e9912..7184007695 100644 --- a/moveit_planners/chomp/chomp_interface/CHANGELOG.rst +++ b/moveit_planners/chomp/chomp_interface/CHANGELOG.rst @@ -48,7 +48,7 @@ Changelog for package chomp_interface 0.10.1 (2018-05-25) ------------------- * [fix] dependencies for chomp interface test (`#778 `_) -* [maintenance] MoveIt! tf2 migration (`#830 `_) +* [maintenance] MoveIt tf2 migration (`#830 `_) * Contributors: Bence Magyar, Dave Coleman, Ian McMahon, Mikael Arguedas, Robert Haschke, Stephan, Will Baker 0.9.11 (2017-12-25) diff --git a/moveit_planners/chomp/chomp_interface/CMakeLists.txt b/moveit_planners/chomp/chomp_interface/CMakeLists.txt index 2cddd07a5b..a811145448 100644 --- a/moveit_planners/chomp/chomp_interface/CMakeLists.txt +++ b/moveit_planners/chomp/chomp_interface/CMakeLists.txt @@ -1,7 +1,8 @@ -cmake_minimum_required(VERSION 2.8.3) +cmake_minimum_required(VERSION 3.1.3) project(moveit_planners_chomp) -add_definitions(-std=c++14) +set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_EXTENSIONS OFF) # find catkin in isolation so that CATKIN_ENABLE_TESTING is defined find_package(catkin REQUIRED) @@ -53,7 +54,7 @@ install(DIRECTORY include/chomp_interface/ install(TARGETS ${PROJECT_NAME} chomp_planner_plugin ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} - RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} + RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION} ) if(CATKIN_ENABLE_TESTING) diff --git a/moveit_planners/chomp/chomp_interface/include/chomp_interface/chomp_interface.h b/moveit_planners/chomp/chomp_interface/include/chomp_interface/chomp_interface.h index 1272a130cc..464da4ab92 100644 --- a/moveit_planners/chomp/chomp_interface/include/chomp_interface/chomp_interface.h +++ b/moveit_planners/chomp/chomp_interface/include/chomp_interface/chomp_interface.h @@ -34,8 +34,7 @@ /* Author: E. Gil Jones */ -#ifndef CHOMP_INTERFACE_CHOMP_INTERFACE_H -#define CHOMP_INTERFACE_CHOMP_INTERFACE_H +#pragma once #include #include @@ -64,5 +63,3 @@ class CHOMPInterface : public chomp::ChompPlanner chomp::ChompParameters params_; }; } - -#endif diff --git a/moveit_planners/chomp/chomp_interface/include/chomp_interface/chomp_planning_context.h b/moveit_planners/chomp/chomp_interface/include/chomp_interface/chomp_planning_context.h index 69169f8a66..2dee290b9b 100644 --- a/moveit_planners/chomp/chomp_interface/include/chomp_interface/chomp_planning_context.h +++ b/moveit_planners/chomp/chomp_interface/include/chomp_interface/chomp_planning_context.h @@ -34,8 +34,7 @@ /* Author: Chittaranjan Srinivas Swaminathan */ -#ifndef CHOMP_INTERFACE_CHOMP_PLANNING_CONTEXT_H -#define CHOMP_INTERFACE_CHOMP_PLANNING_CONTEXT_H +#pragma once #include #include @@ -65,5 +64,3 @@ class CHOMPPlanningContext : public planning_interface::PlanningContext }; } /* namespace chomp_interface */ - -#endif /* CHOMP_PLANNING_CONTEXT_H_ */ diff --git a/moveit_planners/chomp/chomp_interface/package.xml b/moveit_planners/chomp/chomp_interface/package.xml index e7f232010e..bc27808754 100644 --- a/moveit_planners/chomp/chomp_interface/package.xml +++ b/moveit_planners/chomp/chomp_interface/package.xml @@ -1,13 +1,13 @@ moveit_planners_chomp - The interface for using CHOMP within MoveIt! + The interface for using CHOMP within MoveIt 1.0.1 Gil Jones Chittaranjan Srinivas Swaminathan Dave Coleman - MoveIt! Release Team + MoveIt Release Team BSD diff --git a/moveit_planners/chomp/chomp_interface/test/rrbot_chomp_planning_pipeline.launch.xml b/moveit_planners/chomp/chomp_interface/test/rrbot_chomp_planning_pipeline.launch.xml index b3146c917b..4b3a1f6f54 100644 --- a/moveit_planners/chomp/chomp_interface/test/rrbot_chomp_planning_pipeline.launch.xml +++ b/moveit_planners/chomp/chomp_interface/test/rrbot_chomp_planning_pipeline.launch.xml @@ -1,5 +1,5 @@ - + diff --git a/moveit_planners/chomp/chomp_motion_planner/CHANGELOG.rst b/moveit_planners/chomp/chomp_motion_planner/CHANGELOG.rst index 0dc05a2151..d32082addf 100644 --- a/moveit_planners/chomp/chomp_motion_planner/CHANGELOG.rst +++ b/moveit_planners/chomp/chomp_motion_planner/CHANGELOG.rst @@ -50,7 +50,7 @@ Changelog for package chomp_motion_planner 0.10.1 (2018-05-25) ------------------- * [fix] for chomp fixed base joint bug (`#870 `_) -* [maintenance] MoveIt! tf2 migration (`#830 `_) +* [maintenance] MoveIt tf2 migration (`#830 `_) * [maintenance] switch to ROS_LOGGER from CONSOLE_BRIDGE (`#874 `_) * Contributors: Bence Magyar, Dave Coleman, Ian McMahon, Mike Lautman, Xiaojian Ma diff --git a/moveit_planners/chomp/chomp_motion_planner/CMakeLists.txt b/moveit_planners/chomp/chomp_motion_planner/CMakeLists.txt index 2ec61daeb2..d02a10255a 100644 --- a/moveit_planners/chomp/chomp_motion_planner/CMakeLists.txt +++ b/moveit_planners/chomp/chomp_motion_planner/CMakeLists.txt @@ -1,7 +1,8 @@ -cmake_minimum_required(VERSION 2.8.3) +cmake_minimum_required(VERSION 3.1.3) project(chomp_motion_planner) -add_definitions(-std=c++14) +set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_EXTENSIONS OFF) find_package(catkin REQUIRED COMPONENTS roscpp @@ -33,5 +34,5 @@ install(DIRECTORY include/${PROJECT_NAME}/ install(TARGETS ${PROJECT_NAME} ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} - RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} + RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION} ) diff --git a/moveit_planners/chomp/chomp_motion_planner/include/chomp_motion_planner/chomp_cost.h b/moveit_planners/chomp/chomp_motion_planner/include/chomp_motion_planner/chomp_cost.h index bda7cbd3f9..a60b1e1c71 100644 --- a/moveit_planners/chomp/chomp_motion_planner/include/chomp_motion_planner/chomp_cost.h +++ b/moveit_planners/chomp/chomp_motion_planner/include/chomp_motion_planner/chomp_cost.h @@ -34,8 +34,7 @@ /* Author: Mrinal Kalakrishnan */ -#ifndef CHOMP_COST_H_ -#define CHOMP_COST_H_ +#pragma once #include #include @@ -97,5 +96,3 @@ inline double ChompCost::getCost(Eigen::MatrixXd::ColXpr joint_trajectory) const } } // namespace chomp - -#endif /* CHOMP_COST_H_ */ diff --git a/moveit_planners/chomp/chomp_motion_planner/include/chomp_motion_planner/chomp_optimizer.h b/moveit_planners/chomp/chomp_motion_planner/include/chomp_motion_planner/chomp_optimizer.h index fba516334b..dafda7f0b2 100644 --- a/moveit_planners/chomp/chomp_motion_planner/include/chomp_motion_planner/chomp_optimizer.h +++ b/moveit_planners/chomp/chomp_motion_planner/include/chomp_motion_planner/chomp_optimizer.h @@ -34,8 +34,7 @@ /* Author: Mrinal Kalakrishnan */ -#ifndef CHOMP_OPTIMIZER_H_ -#define CHOMP_OPTIMIZER_H_ +#pragma once #include #include @@ -43,8 +42,7 @@ #include #include #include -#include -#include +#include #include #include @@ -86,25 +84,21 @@ class ChompOptimizer inline double getPotential(double field_distance, double radius, double clearence) { double d = field_distance - radius; - double potential = 0.0; - // three cases below: - if (d >= clearence) + if (d >= clearence) // everything is fine { - potential = 0.0; + return 0.0; } - else if (d >= 0.0) + else if (d >= 0.0) // transition phase, no collision yet { - double diff = (d - clearence); - double gradient_magnitude = diff * clearence; // (diff / clearance) - potential = 0.5 * gradient_magnitude * diff; + const double diff = (d - clearence); + const double gradient_magnitude = diff / clearence; + return 0.5 * gradient_magnitude * diff; // 0.5 * (d - clearance)^2 / clearance } - else // if d < 0.0 + else // d < 0.0: collision { - potential = -d + 0.5 * clearence; + return -d + 0.5 * clearence; // linearly increase, starting from 0.5 * clearance } - - return potential; } template void getJacobian(int trajectoryPoint, Eigen::Vector3d& collision_point_pos, std::string& jointName, @@ -136,8 +130,7 @@ class ChompOptimizer moveit::core::RobotState state_; moveit::core::RobotState start_state_; const moveit::core::JointModelGroup* joint_model_group_; - const collision_detection::CollisionWorldHybrid* hy_world_; - const collision_detection::CollisionRobotHybrid* hy_robot_; + const collision_detection::CollisionEnvHybrid* hy_env_; std::vector joint_costs_; collision_detection::GroupStateRepresentationPtr gsr_; @@ -224,5 +217,3 @@ class ChompOptimizer bool isCurrentTrajectoryMeshToMeshCollisionFree() const; }; } - -#endif /* CHOMP_OPTIMIZER_H_ */ diff --git a/moveit_planners/chomp/chomp_motion_planner/include/chomp_motion_planner/chomp_parameters.h b/moveit_planners/chomp/chomp_motion_planner/include/chomp_motion_planner/chomp_parameters.h index f1446c9d8a..ab78f274ca 100644 --- a/moveit_planners/chomp/chomp_motion_planner/include/chomp_motion_planner/chomp_parameters.h +++ b/moveit_planners/chomp/chomp_motion_planner/include/chomp_motion_planner/chomp_parameters.h @@ -34,8 +34,7 @@ /* Author: Mrinal Kalakrishnan */ -#ifndef CHOMP_PARAMETERS_H_ -#define CHOMP_PARAMETERS_H_ +#pragma once #include @@ -98,5 +97,3 @@ class ChompParameters }; } // namespace chomp - -#endif /* CHOMP_PARAMETERS_H_ */ diff --git a/moveit_planners/chomp/chomp_motion_planner/include/chomp_motion_planner/chomp_planner.h b/moveit_planners/chomp/chomp_motion_planner/include/chomp_motion_planner/chomp_planner.h index 30d77fa7a0..a4d85fb673 100644 --- a/moveit_planners/chomp/chomp_motion_planner/include/chomp_motion_planner/chomp_planner.h +++ b/moveit_planners/chomp/chomp_motion_planner/include/chomp_motion_planner/chomp_planner.h @@ -34,8 +34,7 @@ /* Author: E. Gil Jones */ -#ifndef _CHOMP_PLANNER_H_ -#define _CHOMP_PLANNER_H_ +#pragma once #include #include @@ -55,5 +54,3 @@ class ChompPlanner planning_interface::MotionPlanDetailedResponse& res) const; }; } - -#endif diff --git a/moveit_planners/chomp/chomp_motion_planner/include/chomp_motion_planner/chomp_trajectory.h b/moveit_planners/chomp/chomp_motion_planner/include/chomp_motion_planner/chomp_trajectory.h index 359ce88b24..559237aa12 100644 --- a/moveit_planners/chomp/chomp_motion_planner/include/chomp_motion_planner/chomp_trajectory.h +++ b/moveit_planners/chomp/chomp_motion_planner/include/chomp_motion_planner/chomp_trajectory.h @@ -34,8 +34,7 @@ /* Author: Mrinal Kalakrishnan */ -#ifndef CHOMP_TRAJECTORY_H_ -#define CHOMP_TRAJECTORY_H_ +#pragma once #include #include @@ -308,5 +307,3 @@ inline double ChompTrajectory::getDuration() const return duration_; } } - -#endif /* CHOMP_TRAJECTORY_H_ */ diff --git a/moveit_planners/chomp/chomp_motion_planner/include/chomp_motion_planner/chomp_utils.h b/moveit_planners/chomp/chomp_motion_planner/include/chomp_motion_planner/chomp_utils.h index 0b9a5214ae..b5fb5b7a66 100644 --- a/moveit_planners/chomp/chomp_motion_planner/include/chomp_motion_planner/chomp_utils.h +++ b/moveit_planners/chomp/chomp_motion_planner/include/chomp_motion_planner/chomp_utils.h @@ -34,8 +34,7 @@ /* Author: Mrinal Kalakrishnan */ -#ifndef CHOMP_UTILS_H_ -#define CHOMP_UTILS_H_ +#pragma once #include #include @@ -86,5 +85,3 @@ static inline double shortestAngularDistance(double start, double end) } } // namespace chomp - -#endif /* CHOMP_UTILS_H_ */ diff --git a/moveit_planners/chomp/chomp_motion_planner/include/chomp_motion_planner/multivariate_gaussian.h b/moveit_planners/chomp/chomp_motion_planner/include/chomp_motion_planner/multivariate_gaussian.h index d906439cef..a1935d640e 100644 --- a/moveit_planners/chomp/chomp_motion_planner/include/chomp_motion_planner/multivariate_gaussian.h +++ b/moveit_planners/chomp/chomp_motion_planner/include/chomp_motion_planner/multivariate_gaussian.h @@ -34,8 +34,7 @@ /* Author: Mrinal Kalakrishnan */ -#ifndef MULTIVARIATE_GAUSSIAN_H_ -#define MULTIVARIATE_GAUSSIAN_H_ +#pragma once #include #include @@ -93,5 +92,3 @@ void MultivariateGaussian::sample(Eigen::MatrixBase& output) output = mean_ + covariance_cholesky_ * output; } } - -#endif /* MULTIVARIATE_GAUSSIAN_H_ */ diff --git a/moveit_planners/chomp/chomp_motion_planner/package.xml b/moveit_planners/chomp/chomp_motion_planner/package.xml index 8abb126185..81c05a1bf6 100644 --- a/moveit_planners/chomp/chomp_motion_planner/package.xml +++ b/moveit_planners/chomp/chomp_motion_planner/package.xml @@ -7,7 +7,7 @@ Mrinal Kalakrishnan Chittaranjan Srinivas Swaminathan - MoveIt! Release Team + MoveIt Release Team BSD http://ros.org/wiki/chomp_motion_planner diff --git a/moveit_planners/chomp/chomp_motion_planner/src/chomp_optimizer.cpp b/moveit_planners/chomp/chomp_motion_planner/src/chomp_optimizer.cpp index 6158d6f3e5..bd8b655928 100644 --- a/moveit_planners/chomp/chomp_motion_planner/src/chomp_optimizer.cpp +++ b/moveit_planners/chomp/chomp_motion_planner/src/chomp_optimizer.cpp @@ -43,12 +43,15 @@ #include #include #include +#include namespace chomp { double getRandomDouble() { - return ((double)random() / (double)RAND_MAX); + std::default_random_engine seed; + std::uniform_real_distribution<> uniform(0.0, 1.0); + return uniform(seed); } ChompOptimizer::ChompOptimizer(ChompTrajectory* trajectory, const planning_scene::PlanningSceneConstPtr& planning_scene, @@ -75,21 +78,14 @@ ChompOptimizer::ChompOptimizer(ChompTrajectory* trajectory, const planning_scene ROS_INFO_STREAM("Active collision detector is: " + planning_scene->getActiveCollisionDetectorName()); - hy_world_ = dynamic_cast( - planning_scene->getCollisionWorld(planning_scene->getActiveCollisionDetectorName()).get()); - if (!hy_world_) + hy_env_ = dynamic_cast( + planning_scene->getCollisionEnv(planning_scene->getActiveCollisionDetectorName()).get()); + if (!hy_env_) { ROS_WARN_STREAM("Could not initialize hybrid collision world from planning scene"); return; } - hy_robot_ = dynamic_cast( - planning_scene->getCollisionRobot(planning_scene->getActiveCollisionDetectorName()).get()); - if (!hy_robot_) - { - ROS_WARN_STREAM("Could not initialize hybrid collision robot from planning scene"); - return; - } initialize(); } @@ -107,8 +103,7 @@ void ChompOptimizer::initialize() collision_detection::CollisionResult res; req.group_name = planning_group_; ros::WallTime wt = ros::WallTime::now(); - hy_world_->getCollisionGradients(req, res, *hy_robot_->getCollisionRobotDistanceField().get(), state_, - &planning_scene_->getAllowedCollisionMatrix(), gsr_); + hy_env_->getCollisionGradients(req, res, state_, &planning_scene_->getAllowedCollisionMatrix(), gsr_); ROS_INFO_STREAM("First coll check took " << (ros::WallTime::now() - wt)); num_collision_points_ = 0; for (const collision_detection::GradientInfo& gradient : gsr_->gradients_) @@ -615,7 +610,7 @@ void ChompOptimizer::calculateCollisionIncrements() // This is faster and guaranteed to converge, but it may take more iterations in the worst case. if (parameters_->use_stochastic_descent_) { - start_point = (int)(((double)random() / (double)RAND_MAX) * (free_vars_end_ - free_vars_start_) + free_vars_start_); + start_point = (int)(getRandomDouble() * (free_vars_end_ - free_vars_start_) + free_vars_start_); if (start_point < free_vars_start_) start_point = free_vars_start_; if (start_point > free_vars_end_) @@ -937,8 +932,7 @@ void ChompOptimizer::performForwardKinematics() setRobotStateFromPoint(group_trajectory_, i); ros::WallTime grad = ros::WallTime::now(); - hy_world_->getCollisionGradients(req, res, *hy_robot_->getCollisionRobotDistanceField().get(), state_, nullptr, - gsr_); + hy_env_->getCollisionGradients(req, res, state_, nullptr, gsr_); total_dur += (ros::WallTime::now() - grad); computeJointProperties(i); state_is_in_collision_[i] = false; diff --git a/moveit_planners/chomp/chomp_motion_planner/src/chomp_trajectory.cpp b/moveit_planners/chomp/chomp_motion_planner/src/chomp_trajectory.cpp index 8580682a20..e1f56aa0e7 100644 --- a/moveit_planners/chomp/chomp_motion_planner/src/chomp_trajectory.cpp +++ b/moveit_planners/chomp/chomp_motion_planner/src/chomp_trajectory.cpp @@ -155,7 +155,7 @@ void ChompTrajectory::fillInMinJerk() // calculate the spline coefficients for each joint: // (these are for the special case of zero start and end vel and acc) - double coeff[num_joints_][6]; + std::vector coeff(num_joints_); for (size_t i = 0; i < num_joints_; i++) { double x0 = (*this)(start_index, i); diff --git a/moveit_planners/chomp/chomp_optimizer_adapter/CMakeLists.txt b/moveit_planners/chomp/chomp_optimizer_adapter/CMakeLists.txt index f5a743686c..0e69e70585 100644 --- a/moveit_planners/chomp/chomp_optimizer_adapter/CMakeLists.txt +++ b/moveit_planners/chomp/chomp_optimizer_adapter/CMakeLists.txt @@ -1,7 +1,8 @@ -cmake_minimum_required(VERSION 2.8.3) +cmake_minimum_required(VERSION 3.1.3) project(moveit_chomp_optimizer_adapter) -add_compile_options(-std=c++14) +set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_EXTENSIONS OFF) find_package(catkin REQUIRED COMPONENTS moveit_core @@ -23,5 +24,5 @@ install(FILES chomp_optimizer_adapter_plugin_description.xml install(TARGETS ${PROJECT_NAME} ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} - RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} + RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION} ) diff --git a/moveit_planners/chomp/chomp_optimizer_adapter/package.xml b/moveit_planners/chomp/chomp_optimizer_adapter/package.xml index f5a6d016a7..4861c4e43c 100644 --- a/moveit_planners/chomp/chomp_optimizer_adapter/package.xml +++ b/moveit_planners/chomp/chomp_optimizer_adapter/package.xml @@ -6,7 +6,7 @@ 1.0.1 Raghavender Sahdev Raghavender Sahdev - MoveIt! Release Team + MoveIt Release Team BSD diff --git a/moveit_planners/moveit_planners/package.xml b/moveit_planners/moveit_planners/package.xml index 77d65918bf..a3ef9a50aa 100644 --- a/moveit_planners/moveit_planners/package.xml +++ b/moveit_planners/moveit_planners/package.xml @@ -6,7 +6,7 @@ Sachin Chitta Dave Coleman - MoveIt! Release Team + MoveIt Release Team BSD diff --git a/moveit_planners/ompl/CHANGELOG.rst b/moveit_planners/ompl/CHANGELOG.rst index 06a4259f1c..37a663ac0b 100644 --- a/moveit_planners/ompl/CHANGELOG.rst +++ b/moveit_planners/ompl/CHANGELOG.rst @@ -117,7 +117,7 @@ Changelog for package moveit_planners_ompl * renamed newGoal to new_goal for keeping with formatting * setting GroupStateValidityCallbackFn member for constraint_sampler member and implementing callbacks for state validity checking * added functions to check validit of state, and also to act as callback for constraint sampler -* Added copy function from MoveIt! robot_state joint values to ompl state +* Added copy function from MoveIt robot_state joint values to ompl state * fix for demo constraints database linking error * Namespaced less useful debug output to allow to be easily silenced using ros console * Contributors: Dave Coleman, Dave Hershberger, Sachin Chitta, arjungm diff --git a/moveit_planners/ompl/CMakeLists.txt b/moveit_planners/ompl/CMakeLists.txt index e68728812f..677f51f1d4 100644 --- a/moveit_planners/ompl/CMakeLists.txt +++ b/moveit_planners/ompl/CMakeLists.txt @@ -1,8 +1,9 @@ -cmake_minimum_required(VERSION 2.8.12) +cmake_minimum_required(VERSION 3.1.3) project(moveit_planners_ompl) # At least C++11 required for OMPL -add_compile_options(-std=c++14) +set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_EXTENSIONS OFF) if(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Release) diff --git a/moveit_planners/ompl/ompl_interface/CMakeLists.txt b/moveit_planners/ompl/ompl_interface/CMakeLists.txt index cc9181efee..0f7c18bbb9 100644 --- a/moveit_planners/ompl/ompl_interface/CMakeLists.txt +++ b/moveit_planners/ompl/ompl_interface/CMakeLists.txt @@ -40,8 +40,11 @@ add_library(moveit_ompl_planner_plugin src/ompl_planner_manager.cpp) set_target_properties(moveit_ompl_planner_plugin PROPERTIES VERSION "${${PROJECT_NAME}_VERSION}") target_link_libraries(moveit_ompl_planner_plugin ${MOVEIT_LIB_NAME} ${catkin_LIBRARIES} ${Boost_LIBRARIES}) -install(TARGETS ${MOVEIT_LIB_NAME} moveit_ompl_planner moveit_ompl_planner_plugin moveit_generate_state_database +install(TARGETS ${MOVEIT_LIB_NAME} moveit_ompl_planner_plugin LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}) +install(TARGETS moveit_ompl_planner moveit_generate_state_database RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}) install(DIRECTORY include/ DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}) diff --git a/moveit_planners/ompl/ompl_interface/cfg/OMPLDynamicReconfigure.cfg b/moveit_planners/ompl/ompl_interface/cfg/OMPLDynamicReconfigure.cfg index 50757b73df..e9db604e9d 100755 --- a/moveit_planners/ompl/ompl_interface/cfg/OMPLDynamicReconfigure.cfg +++ b/moveit_planners/ompl/ompl_interface/cfg/OMPLDynamicReconfigure.cfg @@ -4,10 +4,10 @@ PACKAGE = "moveit_planners_ompl" from dynamic_reconfigure.parameter_generator_catkin import * gen = ParameterGenerator() -gen.add("simplify_solutions", bool_t, 1, "Flag indicating whether computed motion plans are also simplified", True) -gen.add("minimum_waypoint_count", int_t, 2, "Set the minimum number of waypoints to include in a motion plan", 10, 2, 10000) -gen.add("maximum_waypoint_distance", double_t, 3, "The maximum distance between consecutive waypoints along the solution path (0.0 means 'ignore')", 0.0, 0.0, 50.0) -gen.add("link_for_exploration_tree", str_t, 4, "Show the exploration tree for a particular link", "") -gen.add("display_random_valid_states", bool_t, 5, "Flag indicating whether random valid states are to be published", False) +gen.add("simplify_solutions", bool_t, 0, "Flag indicating whether computed motion plans are also simplified", True) +gen.add("minimum_waypoint_count", int_t, 0, "Set the minimum number of waypoints to include in a motion plan", 2, 2, 10000) +gen.add("maximum_waypoint_distance", double_t, 0, "The maximum distance between consecutive waypoints along the solution path (0.0 means 'ignore')", 0.0, 0.0, 50.0) +gen.add("link_for_exploration_tree", str_t, 0, "Show the exploration tree for a particular link", "") +gen.add("display_random_valid_states", bool_t, 0, "Flag indicating whether random valid states are to be published", False) exit(gen.generate(PACKAGE, PACKAGE, "OMPLDynamicReconfigure")) diff --git a/moveit_planners/ompl/ompl_interface/cfg/cpp/ompl_interface_ros/OMPLDynamicReconfigureConfig.h b/moveit_planners/ompl/ompl_interface/cfg/cpp/ompl_interface_ros/OMPLDynamicReconfigureConfig.h index fba9e700d3..4e85adddb2 100644 --- a/moveit_planners/ompl/ompl_interface/cfg/cpp/ompl_interface_ros/OMPLDynamicReconfigureConfig.h +++ b/moveit_planners/ompl/ompl_interface/cfg/cpp/ompl_interface_ros/OMPLDynamicReconfigureConfig.h @@ -43,8 +43,7 @@ // Author: Blaise Gassend -#ifndef __ompl_interface_ros__OMPLDYNAMICRECONFIGURECONFIG_H__ -#define __ompl_interface_ros__OMPLDYNAMICRECONFIGURECONFIG_H__ +#pragma once #include #include @@ -532,5 +531,3 @@ inline const OMPLDynamicReconfigureConfigStatics* OMPLDynamicReconfigureConfig:: return statics; } } - -#endif // __OMPLDYNAMICRECONFIGURERECONFIGURATOR_H__ diff --git a/moveit_planners/ompl/ompl_interface/include/moveit/ompl_interface/constraints_library.h b/moveit_planners/ompl/ompl_interface/include/moveit/ompl_interface/constraints_library.h index 7615ad1561..18c3888fc4 100644 --- a/moveit_planners/ompl/ompl_interface/include/moveit/ompl_interface/constraints_library.h +++ b/moveit_planners/ompl/ompl_interface/include/moveit/ompl_interface/constraints_library.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_OMPL_INTERFACE_CONSTRAINTS_LIBRARY_ -#define MOVEIT_OMPL_INTERFACE_CONSTRAINTS_LIBRARY_ +#pragma once #include #include @@ -200,5 +199,3 @@ class ConstraintsLibrary std::map constraint_approximations_; }; } - -#endif diff --git a/moveit_planners/ompl/ompl_interface/include/moveit/ompl_interface/detail/constrained_goal_sampler.h b/moveit_planners/ompl/ompl_interface/include/moveit/ompl_interface/detail/constrained_goal_sampler.h index 4eb0b16ec2..d054ab8e15 100644 --- a/moveit_planners/ompl/ompl_interface/include/moveit/ompl_interface/detail/constrained_goal_sampler.h +++ b/moveit_planners/ompl/ompl_interface/include/moveit/ompl_interface/detail/constrained_goal_sampler.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_OMPL_INTERFACE_DETAIL_CONSTRAINED_GOAL_SAMPLER_ -#define MOVEIT_OMPL_INTERFACE_DETAIL_CONSTRAINED_GOAL_SAMPLER_ +#pragma once #include #include @@ -73,5 +72,3 @@ class ConstrainedGoalSampler : public ompl::base::GoalLazySamples unsigned int verbose_display_; }; } - -#endif diff --git a/moveit_planners/ompl/ompl_interface/include/moveit/ompl_interface/detail/constrained_sampler.h b/moveit_planners/ompl/ompl_interface/include/moveit/ompl_interface/detail/constrained_sampler.h index a0554bfbf7..cb72a22811 100644 --- a/moveit_planners/ompl/ompl_interface/include/moveit/ompl_interface/detail/constrained_sampler.h +++ b/moveit_planners/ompl/ompl_interface/include/moveit/ompl_interface/detail/constrained_sampler.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_OMPL_INTERFACE_DETAIL_CONSTRAINED_SAMPLER_ -#define MOVEIT_OMPL_INTERFACE_DETAIL_CONSTRAINED_SAMPLER_ +#pragma once #include #include @@ -78,5 +77,3 @@ class ConstrainedSampler : public ompl::base::StateSampler double inv_dim_; }; } - -#endif diff --git a/moveit_planners/ompl/ompl_interface/include/moveit/ompl_interface/detail/constrained_valid_state_sampler.h b/moveit_planners/ompl/ompl_interface/include/moveit/ompl_interface/detail/constrained_valid_state_sampler.h index 7a504f7fbe..61e9b0d15d 100644 --- a/moveit_planners/ompl/ompl_interface/include/moveit/ompl_interface/detail/constrained_valid_state_sampler.h +++ b/moveit_planners/ompl/ompl_interface/include/moveit/ompl_interface/detail/constrained_valid_state_sampler.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_OMPL_INTERFACE_DETAIL_CONSTRAINED_VALID_STATE_SAMPLER_ -#define MOVEIT_OMPL_INTERFACE_DETAIL_CONSTRAINED_VALID_STATE_SAMPLER_ +#pragma once #include #include @@ -70,5 +69,3 @@ class ValidConstrainedSampler : public ompl::base::ValidStateSampler ompl::RNG rng_; }; } - -#endif diff --git a/moveit_planners/ompl/ompl_interface/include/moveit/ompl_interface/detail/constraint_approximations.h b/moveit_planners/ompl/ompl_interface/include/moveit/ompl_interface/detail/constraint_approximations.h index 5636257e46..ccf47358ae 100644 --- a/moveit_planners/ompl/ompl_interface/include/moveit/ompl_interface/detail/constraint_approximations.h +++ b/moveit_planners/ompl/ompl_interface/include/moveit/ompl_interface/detail/constraint_approximations.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_OMPL_INTERFACE_DETAIL_CONSTRAINT_APPROXIMATION_ -#define MOVEIT_OMPL_INTERFACE_DETAIL_CONSTRAINT_APPROXIMATION_ +#pragma once #include #include @@ -75,5 +74,3 @@ struct ConstraintApproximation MOVEIT_DECLARE_PTR(ConstraintApproximations, std::vector) } - -#endif diff --git a/moveit_planners/ompl/ompl_interface/include/moveit/ompl_interface/detail/projection_evaluators.h b/moveit_planners/ompl/ompl_interface/include/moveit/ompl_interface/detail/projection_evaluators.h index 8fd837ad9d..63c0b0917f 100644 --- a/moveit_planners/ompl/ompl_interface/include/moveit/ompl_interface/detail/projection_evaluators.h +++ b/moveit_planners/ompl/ompl_interface/include/moveit/ompl_interface/detail/projection_evaluators.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_OMPL_INTERFACE_DETAIL_PROJECTION_EVALUATORS_ -#define MOVEIT_OMPL_INTERFACE_DETAIL_PROJECTION_EVALUATORS_ +#pragma once #include #include @@ -83,5 +82,3 @@ class ProjectionEvaluatorJointValue : public ompl::base::ProjectionEvaluator std::vector variables_; }; } - -#endif diff --git a/moveit_planners/ompl/ompl_interface/include/moveit/ompl_interface/detail/state_validity_checker.h b/moveit_planners/ompl/ompl_interface/include/moveit/ompl_interface/detail/state_validity_checker.h index c485879007..23e02f87fb 100644 --- a/moveit_planners/ompl/ompl_interface/include/moveit/ompl_interface/detail/state_validity_checker.h +++ b/moveit_planners/ompl/ompl_interface/include/moveit/ompl_interface/detail/state_validity_checker.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_OMPL_INTERFACE_DETAIL_STATE_VALIDITY_CHECKER_ -#define MOVEIT_OMPL_INTERFACE_DETAIL_STATE_VALIDITY_CHECKER_ +#pragma once #include #include @@ -89,5 +88,3 @@ class StateValidityChecker : public ompl::base::StateValidityChecker bool verbose_; }; } - -#endif diff --git a/moveit_planners/ompl/ompl_interface/include/moveit/ompl_interface/detail/threadsafe_state_storage.h b/moveit_planners/ompl/ompl_interface/include/moveit/ompl_interface/detail/threadsafe_state_storage.h index a19b69bfda..a276ede06e 100644 --- a/moveit_planners/ompl/ompl_interface/include/moveit/ompl_interface/detail/threadsafe_state_storage.h +++ b/moveit_planners/ompl/ompl_interface/include/moveit/ompl_interface/detail/threadsafe_state_storage.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_OMPL_INTERFACE_DEATIL_THREADSAFE_STATE_STORAGE_ -#define MOVEIT_OMPL_INTERFACE_DEATIL_THREADSAFE_STATE_STORAGE_ +#pragma once #include #include @@ -58,4 +57,3 @@ class TSStateStorage mutable std::mutex lock_; }; } -#endif diff --git a/moveit_planners/ompl/ompl_interface/include/moveit/ompl_interface/model_based_planning_context.h b/moveit_planners/ompl/ompl_interface/include/moveit/ompl_interface/model_based_planning_context.h index 90f5034502..022aa4ab29 100644 --- a/moveit_planners/ompl/ompl_interface/include/moveit/ompl_interface/model_based_planning_context.h +++ b/moveit_planners/ompl/ompl_interface/include/moveit/ompl_interface/model_based_planning_context.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_OMPL_INTERFACE_MODEL_BASED_PLANNING_CONTEXT_ -#define MOVEIT_OMPL_INTERFACE_MODEL_BASED_PLANNING_CONTEXT_ +#pragma once #include #include @@ -377,5 +376,3 @@ class ModelBasedPlanningContext : public planning_interface::PlanningContext bool simplify_solutions_; }; } // namespace ompl_interface - -#endif diff --git a/moveit_planners/ompl/ompl_interface/include/moveit/ompl_interface/ompl_interface.h b/moveit_planners/ompl/ompl_interface/include/moveit/ompl_interface/ompl_interface.h index ef25ce8452..5dc11716ee 100644 --- a/moveit_planners/ompl/ompl_interface/include/moveit/ompl_interface/ompl_interface.h +++ b/moveit_planners/ompl/ompl_interface/include/moveit/ompl_interface/ompl_interface.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_OMPL_INTERFACE_OMPL_INTERFACE_ -#define MOVEIT_OMPL_INTERFACE_OMPL_INTERFACE_ +#pragma once #include #include @@ -48,7 +47,7 @@ #include #include -/** \brief The MoveIt! interface to OMPL */ +/** \brief The MoveIt interface to OMPL */ namespace ompl_interface { /** @class OMPLInterface @@ -193,5 +192,3 @@ class OMPLInterface constraint_sampler_manager_loader::ConstraintSamplerManagerLoaderPtr constraint_sampler_manager_loader_; }; } - -#endif diff --git a/moveit_planners/ompl/ompl_interface/include/moveit/ompl_interface/parameterization/joint_space/joint_model_state_space.h b/moveit_planners/ompl/ompl_interface/include/moveit/ompl_interface/parameterization/joint_space/joint_model_state_space.h index 6b4dbb5229..4a8c9073fa 100644 --- a/moveit_planners/ompl/ompl_interface/include/moveit/ompl_interface/parameterization/joint_space/joint_model_state_space.h +++ b/moveit_planners/ompl/ompl_interface/include/moveit/ompl_interface/parameterization/joint_space/joint_model_state_space.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_OMPL_INTERFACE_PARAMETERIZATION_JOINT_SPACE_JOINT_MODEL_STATE_SPACE_ -#define MOVEIT_OMPL_INTERFACE_PARAMETERIZATION_JOINT_SPACE_JOINT_MODEL_STATE_SPACE_ +#pragma once #include @@ -49,5 +48,3 @@ class JointModelStateSpace : public ModelBasedStateSpace JointModelStateSpace(const ModelBasedStateSpaceSpecification& spec); }; } - -#endif diff --git a/moveit_planners/ompl/ompl_interface/include/moveit/ompl_interface/parameterization/joint_space/joint_model_state_space_factory.h b/moveit_planners/ompl/ompl_interface/include/moveit/ompl_interface/parameterization/joint_space/joint_model_state_space_factory.h index 5ff8e4dab2..246f8a48e1 100644 --- a/moveit_planners/ompl/ompl_interface/include/moveit/ompl_interface/parameterization/joint_space/joint_model_state_space_factory.h +++ b/moveit_planners/ompl/ompl_interface/include/moveit/ompl_interface/parameterization/joint_space/joint_model_state_space_factory.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_OMPL_INTERFACE_PARAMETERIZATION_JOINT_SPACE_JOINT_MODEL_STATE_SPACE_FACTORY_ -#define MOVEIT_OMPL_INTERFACE_PARAMETERIZATION_JOINT_SPACE_JOINT_MODEL_STATE_SPACE_FACTORY_ +#pragma once #include @@ -53,5 +52,3 @@ class JointModelStateSpaceFactory : public ModelBasedStateSpaceFactory ModelBasedStateSpacePtr allocStateSpace(const ModelBasedStateSpaceSpecification& space_spec) const override; }; } - -#endif diff --git a/moveit_planners/ompl/ompl_interface/include/moveit/ompl_interface/parameterization/model_based_state_space.h b/moveit_planners/ompl/ompl_interface/include/moveit/ompl_interface/parameterization/model_based_state_space.h index 3ef5246888..106a4a2c41 100644 --- a/moveit_planners/ompl/ompl_interface/include/moveit/ompl_interface/parameterization/model_based_state_space.h +++ b/moveit_planners/ompl/ompl_interface/include/moveit/ompl_interface/parameterization/model_based_state_space.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_OMPL_INTERFACE_PARAMETERIZATION_MODEL_BASED_STATE_SPACE_ -#define MOVEIT_OMPL_INTERFACE_PARAMETERIZATION_MODEL_BASED_STATE_SPACE_ +#pragma once #include #include @@ -241,10 +240,10 @@ class ModelBasedStateSpace : public ompl::base::StateSpace virtual void copyToOMPLState(ompl::base::State* state, const robot_state::RobotState& rstate) const; /** - * \brief Copy a single joint's values (which might have multiple variables) from a MoveIt! robot_state to an OMPL + * \brief Copy a single joint's values (which might have multiple variables) from a MoveIt robot_state to an OMPL * state. * \param state - output OMPL state with single joint modified - * \param robot_state - input MoveIt! state to get the joint value from + * \param robot_state - input MoveIt state to get the joint value from * \param joint_model - the joint to copy values of * \param ompl_state_joint_index - the index of the joint in the ompl state (passed in for efficiency, you should * cache this index) @@ -270,5 +269,3 @@ class ModelBasedStateSpace : public ompl::base::StateSpace double tag_snap_to_segment_complement_; }; } // namespace ompl_interface - -#endif diff --git a/moveit_planners/ompl/ompl_interface/include/moveit/ompl_interface/parameterization/model_based_state_space_factory.h b/moveit_planners/ompl/ompl_interface/include/moveit/ompl_interface/parameterization/model_based_state_space_factory.h index f369b52588..0bd363d9b2 100644 --- a/moveit_planners/ompl/ompl_interface/include/moveit/ompl_interface/parameterization/model_based_state_space_factory.h +++ b/moveit_planners/ompl/ompl_interface/include/moveit/ompl_interface/parameterization/model_based_state_space_factory.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_OMPL_INTERFACE_PARAMETERIZATION_MODEL_BASED_STATE_SPACE_FACTORY_ -#define MOVEIT_OMPL_INTERFACE_PARAMETERIZATION_MODEL_BASED_STATE_SPACE_FACTORY_ +#pragma once #include #include @@ -75,5 +74,3 @@ class ModelBasedStateSpaceFactory std::string type_; }; } - -#endif diff --git a/moveit_planners/ompl/ompl_interface/include/moveit/ompl_interface/parameterization/work_space/pose_model_state_space.h b/moveit_planners/ompl/ompl_interface/include/moveit/ompl_interface/parameterization/work_space/pose_model_state_space.h index 9f6fbaf9ee..a0d632c527 100644 --- a/moveit_planners/ompl/ompl_interface/include/moveit/ompl_interface/parameterization/work_space/pose_model_state_space.h +++ b/moveit_planners/ompl/ompl_interface/include/moveit/ompl_interface/parameterization/work_space/pose_model_state_space.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_OMPL_INTERFACE_PARAMETERIZATION_WORK_SPACE_POSE_MODEL_STATE_SPACE_ -#define MOVEIT_OMPL_INTERFACE_PARAMETERIZATION_WORK_SPACE_POSE_MODEL_STATE_SPACE_ +#pragma once #include #include @@ -136,5 +135,3 @@ class PoseModelStateSpace : public ModelBasedStateSpace double jump_factor_; }; } - -#endif diff --git a/moveit_planners/ompl/ompl_interface/include/moveit/ompl_interface/parameterization/work_space/pose_model_state_space_factory.h b/moveit_planners/ompl/ompl_interface/include/moveit/ompl_interface/parameterization/work_space/pose_model_state_space_factory.h index fc6d616d11..11f45ad066 100644 --- a/moveit_planners/ompl/ompl_interface/include/moveit/ompl_interface/parameterization/work_space/pose_model_state_space_factory.h +++ b/moveit_planners/ompl/ompl_interface/include/moveit/ompl_interface/parameterization/work_space/pose_model_state_space_factory.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_OMPL_INTERFACE_PARAMETERIZATION_WORK_SPACE_POSE_MODEL_STATE_SPACE_FACTORY_ -#define MOVEIT_OMPL_INTERFACE_PARAMETERIZATION_WORK_SPACE_POSE_MODEL_STATE_SPACE_FACTORY_ +#pragma once #include @@ -53,5 +52,3 @@ class PoseModelStateSpaceFactory : public ModelBasedStateSpaceFactory ModelBasedStateSpacePtr allocStateSpace(const ModelBasedStateSpaceSpecification& space_spec) const override; }; } - -#endif diff --git a/moveit_planners/ompl/ompl_interface/include/moveit/ompl_interface/planning_context_manager.h b/moveit_planners/ompl/ompl_interface/include/moveit/ompl_interface/planning_context_manager.h index 4d08768b4b..c8d2f9fcb7 100644 --- a/moveit_planners/ompl/ompl_interface/include/moveit/ompl_interface/planning_context_manager.h +++ b/moveit_planners/ompl/ompl_interface/include/moveit/ompl_interface/planning_context_manager.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_OMPL_INTERFACE_PLANNING_CONTEXT_MANAGER_ -#define MOVEIT_OMPL_INTERFACE_PLANNING_CONTEXT_MANAGER_ +#pragma once #include #include @@ -229,5 +228,3 @@ class PlanningContextManager CachedContextsPtr cached_contexts_; }; } - -#endif diff --git a/moveit_planners/ompl/ompl_interface/src/detail/state_validity_checker.cpp b/moveit_planners/ompl/ompl_interface/src/detail/state_validity_checker.cpp index 5d47880ea6..5deb25fce8 100644 --- a/moveit_planners/ompl/ompl_interface/src/detail/state_validity_checker.cpp +++ b/moveit_planners/ompl/ompl_interface/src/detail/state_validity_checker.cpp @@ -119,7 +119,7 @@ bool ompl_interface::StateValidityChecker::isValidWithoutCache(const ompl::base: return false; } - // convert ompl state to MoveIt! robot state + // convert ompl state to MoveIt robot state robot_state::RobotState* robot_state = tss_.getStateStorage(); planning_context_->getOMPLStateSpace()->copyToRobotState(*robot_state, state); diff --git a/moveit_planners/ompl/ompl_interface/src/generate_state_database.cpp b/moveit_planners/ompl/ompl_interface/src/generate_state_database.cpp index f1cd7d56c6..e2cbf39c25 100644 --- a/moveit_planners/ompl/ompl_interface/src/generate_state_database.cpp +++ b/moveit_planners/ompl/ompl_interface/src/generate_state_database.cpp @@ -42,6 +42,7 @@ #include #include +#include #include #include @@ -165,7 +166,7 @@ int main(int argc, char** argv) } } - if (kinematic_constraints::isEmpty(params.constraints)) + if (moveit::core::isEmpty(params.constraints)) { ROS_FATAL_NAMED(LOGNAME, "Abort. Constraint description is an empty set of constraints."); return 1; diff --git a/moveit_planners/ompl/package.xml b/moveit_planners/ompl/package.xml index 1f2f7e6fc0..f7c87e00f2 100644 --- a/moveit_planners/ompl/package.xml +++ b/moveit_planners/ompl/package.xml @@ -1,12 +1,12 @@ moveit_planners_ompl 1.0.1 - MoveIt! interface to OMPL + MoveIt interface to OMPL Ioan Sucan Dave Coleman - MoveIt! Release Team + MoveIt Release Team BSD diff --git a/moveit_planners/sbpl/core/sbpl_interface/CMakeLists.txt b/moveit_planners/sbpl/core/sbpl_interface/CMakeLists.txt index 2b0568a402..b93b07f3fc 100644 --- a/moveit_planners/sbpl/core/sbpl_interface/CMakeLists.txt +++ b/moveit_planners/sbpl/core/sbpl_interface/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.4.6) +cmake_minimum_required(VERSION 3.1.3) include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake) # Set the build type. Options are: diff --git a/moveit_planners/sbpl/core/sbpl_interface/include/sbpl_interface/bfs3d/BFS_3D.h b/moveit_planners/sbpl/core/sbpl_interface/include/sbpl_interface/bfs3d/BFS_3D.h index 8b60176b72..cf5700adf4 100644 --- a/moveit_planners/sbpl/core/sbpl_interface/include/sbpl_interface/bfs3d/BFS_3D.h +++ b/moveit_planners/sbpl/core/sbpl_interface/include/sbpl_interface/bfs3d/BFS_3D.h @@ -34,8 +34,7 @@ /** \Author: Benjamin Cohen /bcohen@willowgarage.com, E. Gil Jones **/ -#ifndef _SBPL_BFS_3D_H_ -#define _SBPL_BFS_3D_H_ +#pragma once #include @@ -77,5 +76,3 @@ class BFS_3D int getDistance(int, int, int); }; } - -#endif diff --git a/moveit_planners/sbpl/core/sbpl_interface/include/sbpl_interface/bresenham.h b/moveit_planners/sbpl/core/sbpl_interface/include/sbpl_interface/bresenham.h index 748bddf830..4f8f7847b9 100644 --- a/moveit_planners/sbpl/core/sbpl_interface/include/sbpl_interface/bresenham.h +++ b/moveit_planners/sbpl/core/sbpl_interface/include/sbpl_interface/bresenham.h @@ -32,8 +32,7 @@ * POSSIBILITY OF SUCH DAMAGE. *********************************************************************/ -#ifndef _BRESENHAM3D_ -#define _BRESENHAM3D_ +#pragma once #include #include @@ -56,5 +55,3 @@ void get_bresenham3d_parameters(int p1x, int p1y, int p1z, int p2x, int p2y, int void get_current_point3d(bresenham3d_param_t* params, int* x, int* y, int* z); int get_next_point3d(bresenham3d_param_t* params); - -#endif diff --git a/moveit_planners/sbpl/core/sbpl_interface/include/sbpl_interface/dummy_environment.h b/moveit_planners/sbpl/core/sbpl_interface/include/sbpl_interface/dummy_environment.h index 3f9c43ba34..8dda73802e 100644 --- a/moveit_planners/sbpl/core/sbpl_interface/include/sbpl_interface/dummy_environment.h +++ b/moveit_planners/sbpl/core/sbpl_interface/include/sbpl_interface/dummy_environment.h @@ -32,8 +32,7 @@ * POSSIBILITY OF SUCH DAMAGE. *********************************************************************/ -#ifndef _DUMMY_ENVIRONMENT_H_ -#define _DUMMY_ENVIRONMENT_H_ +#pragma once class DummyEnvironment : public DiscreteSpaceInformation { @@ -100,5 +99,3 @@ class DummyEnvironment : public DiscreteSpaceInformation { } }; - -#endif diff --git a/moveit_planners/sbpl/core/sbpl_interface/include/sbpl_interface/environment_chain3d.h b/moveit_planners/sbpl/core/sbpl_interface/include/sbpl_interface/environment_chain3d.h index e33fdec39e..53b258ced3 100644 --- a/moveit_planners/sbpl/core/sbpl_interface/include/sbpl_interface/environment_chain3d.h +++ b/moveit_planners/sbpl/core/sbpl_interface/include/sbpl_interface/environment_chain3d.h @@ -34,8 +34,7 @@ /** \Author: Benjamin Cohen /bcohen@willowgarage.com, E. Gil Jones **/ -#ifndef _ENVIRONMENT_CHAIN3D_H_ -#define _ENVIRONMENT_CHAIN3D_H_ +#pragma once #include #include @@ -51,8 +50,7 @@ #include #include #include -#include -#include +#include #include #include @@ -249,8 +247,7 @@ class EnvironmentChain3D : public DiscreteSpaceInformation std::vector > joint_motion_wrappers_; std::vector > possible_actions_; planning_models::RobotState* state_; - const collision_detection::CollisionWorldHybrid* hy_world_; - const collision_detection::CollisionRobotHybrid* hy_robot_; + const collision_detection::CollisionEnvHybrid* hy_env_; planning_models::RobotState* ::JointStateGroup* joint_state_group_; boost::shared_ptr gsr_; // boost::shared_ptr kinematics_solver_; @@ -334,5 +331,3 @@ inline void EnvironmentChain3D::convertJointAnglesToCoord(const std::vector #include @@ -318,5 +317,3 @@ class SingleJointMotionPrimitive : public JointMotionPrimitive double delta_; }; } - -#endif diff --git a/moveit_planners/sbpl/core/sbpl_interface/include/sbpl_interface/sbpl_interface.h b/moveit_planners/sbpl/core/sbpl_interface/include/sbpl_interface/sbpl_interface.h index 753211ccdb..61f5c91d80 100644 --- a/moveit_planners/sbpl/core/sbpl_interface/include/sbpl_interface/sbpl_interface.h +++ b/moveit_planners/sbpl/core/sbpl_interface/include/sbpl_interface/sbpl_interface.h @@ -32,8 +32,7 @@ * POSSIBILITY OF SUCH DAMAGE. *********************************************************************/ -#ifndef MOVEIT_SBPL_INTERFACE_H_ -#define MOVEIT_SBPL_INTERFACE_H_ +#pragma once #include #include @@ -68,5 +67,3 @@ class SBPLInterface // SBPLPlanner *planner_; }; } - -#endif diff --git a/moveit_planners/sbpl/core/sbpl_interface/include/sbpl_interface/sbpl_meta_interface.h b/moveit_planners/sbpl/core/sbpl_interface/include/sbpl_interface/sbpl_meta_interface.h index 654d41b11d..dc41e7037f 100644 --- a/moveit_planners/sbpl/core/sbpl_interface/include/sbpl_interface/sbpl_meta_interface.h +++ b/moveit_planners/sbpl/core/sbpl_interface/include/sbpl_interface/sbpl_meta_interface.h @@ -32,8 +32,7 @@ * POSSIBILITY OF SUCH DAMAGE. *********************************************************************/ -#ifndef MOVEIT_SBPL_META_INTERFACE_H_ -#define MOVEIT_SBPL_META_INTERFACE_H_ +#pragma once #include #include @@ -77,5 +76,3 @@ class SBPLMetaInterface PlanningStatistics last_planning_statistics_; }; } - -#endif diff --git a/moveit_planners/sbpl/core/sbpl_interface/include/sbpl_interface/sbpl_params.h b/moveit_planners/sbpl/core/sbpl_interface/include/sbpl_interface/sbpl_params.h index 17e309740f..56c5a53f51 100644 --- a/moveit_planners/sbpl/core/sbpl_interface/include/sbpl_interface/sbpl_params.h +++ b/moveit_planners/sbpl/core/sbpl_interface/include/sbpl_interface/sbpl_params.h @@ -32,8 +32,7 @@ * POSSIBILITY OF SUCH DAMAGE. *********************************************************************/ -#ifndef _SBPL_PARAMS_H_ -#define _SBPL_PARAMS_H_ +#pragma once #include #include @@ -204,5 +203,3 @@ class SBPLParams std::vector motion_primitive_type_names_; }; } - -#endif diff --git a/moveit_planners/sbpl/core/sbpl_interface/src/environment_chain3d.cpp b/moveit_planners/sbpl/core/sbpl_interface/src/environment_chain3d.cpp index 6e84c9ac11..5ff2829e1f 100644 --- a/moveit_planners/sbpl/core/sbpl_interface/src/environment_chain3d.cpp +++ b/moveit_planners/sbpl/core/sbpl_interface/src/environment_chain3d.cpp @@ -247,8 +247,7 @@ void EnvironmentChain3D::GetSuccs(int source_state_ID, std::vector* succ_id req.group_name = planning_group_; if (!planning_parameters_.use_standard_collision_checking_) { - hy_world_->checkCollisionDistanceField(req, res, *hy_robot_->getCollisionRobotDistanceField().get(), state_, - gsr_); + hy_env_->checkCollisionDistanceField(req, res, *hy_env_->getCollisionRobotDistanceField().get(), state_, gsr_); } else { @@ -436,18 +435,16 @@ bool EnvironmentChain3D::setupForMotionPlan(const planning_scene::PlanningSceneC if (!planning_parameters_.use_standard_collision_checking_) { - hy_world_ = - dynamic_cast(planning_scene->getCollisionWorld().get()); - if (!hy_world_) + hy_env_ = dynamic_cast(planning_scene->getCollisionEnv().get()); + if (!hy_env_) { ROS_WARN_STREAM("Could not initialize hybrid collision world from planning scene"); mres.error_code.val = moveit_msgs::MoveItErrorCodes::COLLISION_CHECKING_UNAVAILABLE; return false; } - hy_robot_ = - dynamic_cast(planning_scene->getCollisionRobot().get()); - if (!hy_robot_) + hy_env_ = dynamic_cast(planning_scene->getCollisionEnv().get()); + if (!hy_env_) { ROS_WARN_STREAM("Could not initialize hybrid collision robot from planning scene"); mres.error_code.val = moveit_msgs::MoveItErrorCodes::COLLISION_CHECKING_UNAVAILABLE; @@ -473,8 +470,8 @@ bool EnvironmentChain3D::setupForMotionPlan(const planning_scene::PlanningSceneC req.group_name = planning_group_; if (!planning_parameters_.use_standard_collision_checking_) { - hy_world_->checkCollisionDistanceField(req, res, *hy_robot_->getCollisionRobotDistanceField().get(), state_, - planning_scene_->getAllowedCollisionMatrix(), gsr_); + hy_env_->checkCollisionDistanceField(req, res, *hy_env_->getCollisionRobotDistanceField().get(), state_, + planning_scene_->getAllowedCollisionMatrix(), gsr_); } else { @@ -507,7 +504,7 @@ bool EnvironmentChain3D::setupForMotionPlan(const planning_scene::PlanningSceneC gsr_->dfce_->distance_field_->getZNumCells()); boost::shared_ptr world_distance_field = - hy_world_->getCollisionWorldDistanceField()->getDistanceField(); + hy_env_->getCollisionWorldDistanceField()->getDistanceField(); if (world_distance_field->getXNumCells() != gsr_->dfce_->distance_field_->getXNumCells() || world_distance_field->getYNumCells() != gsr_->dfce_->distance_field_->getYNumCells() || world_distance_field->getZNumCells() != gsr_->dfce_->distance_field_->getZNumCells()) @@ -579,8 +576,8 @@ bool EnvironmentChain3D::setupForMotionPlan(const planning_scene::PlanningSceneC goal_state.setStateValues(goal_vals); if (!planning_parameters_.use_standard_collision_checking_) { - hy_world_->checkCollisionDistanceField(req, res, *hy_robot_->getCollisionRobotDistanceField().get(), goal_state, - planning_scene_->getAllowedCollisionMatrix(), gsr_); + hy_env_->checkCollisionDistanceField(req, res, *hy_env_->getCollisionRobotDistanceField().get(), goal_state, + planning_scene_->getAllowedCollisionMatrix(), gsr_); } else { @@ -1101,8 +1098,8 @@ bool EnvironmentChain3D::interpolateAndCollisionCheck(const std::vector collision_detection::CollisionResult res; if (!planning_parameters_.use_standard_collision_checking_) { - hy_world_->checkCollisionDistanceField(req, res, *hy_robot_->getCollisionRobotDistanceField().get(), - interpolation_state_temp_, gsr_); + hy_env_->checkCollisionDistanceField(req, res, *hy_env_->getCollisionRobotDistanceField().get(), + interpolation_state_temp_, gsr_); } else { diff --git a/moveit_planners/sbpl/ros/sbpl_interface_ros/CMakeLists.txt b/moveit_planners/sbpl/ros/sbpl_interface_ros/CMakeLists.txt index 36c26c49b3..557e38a8fd 100644 --- a/moveit_planners/sbpl/ros/sbpl_interface_ros/CMakeLists.txt +++ b/moveit_planners/sbpl/ros/sbpl_interface_ros/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.4.6) +cmake_minimum_required(VERSION 3.1.3) include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake) # Set the build type. Options are: diff --git a/moveit_planners/trajopt/trajopt/CMakeLists.txt b/moveit_planners/trajopt/trajopt/CMakeLists.txt new file mode 100644 index 0000000000..3536268e5a --- /dev/null +++ b/moveit_planners/trajopt/trajopt/CMakeLists.txt @@ -0,0 +1,62 @@ +cmake_minimum_required(VERSION 2.8.3) +project(trajopt) + +add_compile_options(-std=c++11 -Wall -Wextra) + +find_package(catkin REQUIRED COMPONENTS + trajopt_sco + trajopt_utils + roscpp +) + +find_package(Eigen3 REQUIRED) +find_package(Boost COMPONENTS system python thread program_options REQUIRED) + +find_package(PkgConfig REQUIRED) +pkg_check_modules(JSONCPP jsoncpp) + +catkin_package( + INCLUDE_DIRS + include + LIBRARIES + ${PROJECT_NAME} + CATKIN_DEPENDS + trajopt_sco + trajopt_utils + roscpp + DEPENDS + EIGEN3 + Boost +) + +include_directories( + include + ${catkin_INCLUDE_DIRS} + SYSTEM ${EIGEN3_INCLUDE_DIRS} + SYSTEM ${Boost_INCLUDE_DIRS} + SYSTEM ${JSONCPP_INCLUDE_DIRS} +) + +set(TRAJOPT_SOURCE_FILES + src/trajectory_costs.cpp + src/kinematic_terms.cpp + src/problem_description.cpp + src/utils.cpp +) + +add_library(${PROJECT_NAME} ${TRAJOPT_SOURCE_FILES}) +target_link_libraries(${PROJECT_NAME} ${Boost_SYSTEM_LIBRARY} ${JSONCPP_LIBRARIES} ${catkin_LIBRARIES}) +target_compile_options(${PROJECT_NAME} PRIVATE -Wsuggest-override -Wconversion -Wsign-conversion) + +# Mark executables and/or libraries for installation +install(TARGETS ${PROJECT_NAME} + ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} +) + +# Mark cpp header files for installation +install(DIRECTORY include/${PROJECT_NAME}/ + DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION} + FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp" PATTERN "*.hxx" + ) diff --git a/moveit_planners/trajopt/trajopt/LICENSE b/moveit_planners/trajopt/trajopt/LICENSE new file mode 100644 index 0000000000..9103917b0f --- /dev/null +++ b/moveit_planners/trajopt/trajopt/LICENSE @@ -0,0 +1,11 @@ +Copyright (c) 2013, John Schulman +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 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. + +http://opensource.org/licenses/BSD-2-Clause \ No newline at end of file diff --git a/moveit_planners/trajopt/trajopt/README.md b/moveit_planners/trajopt/trajopt/README.md new file mode 100644 index 0000000000..1c18708b1f --- /dev/null +++ b/moveit_planners/trajopt/trajopt/README.md @@ -0,0 +1,3 @@ +TODO(ommmid): Remove code duplication. +This package temporarily copied into moveit until the repo trajopt_ros does not depend on Tesseract +See ros-industrial-consortium/trajopt_ros#122 \ No newline at end of file diff --git a/moveit_planners/trajopt/trajopt/include/trajopt/cache.hxx b/moveit_planners/trajopt/trajopt/include/trajopt/cache.hxx new file mode 100644 index 0000000000..7fc8edaa1c --- /dev/null +++ b/moveit_planners/trajopt/trajopt/include/trajopt/cache.hxx @@ -0,0 +1,26 @@ +#pragma once + +template +class Cache +{ +public: + EIGEN_MAKE_ALIGNED_OPERATOR_NEW + + KeyT keybuf[bufsize]; // circular buffer + ValueT valbuf[bufsize]; // circular buffer + int m_i; + Cache() : m_i(0) { memset(keybuf, 666, sizeof(keybuf)); } + void put(const KeyT& key, const ValueT& value) + { + keybuf[m_i] = key; + valbuf[m_i] = value; + ++m_i; + if (m_i == bufsize) + m_i = 0; + } + ValueT* get(const KeyT& key) + { + KeyT* it = std::find(&keybuf[0], &keybuf[0] + bufsize, key); + return (it == &keybuf[0] + bufsize) ? nullptr : &valbuf[it - &keybuf[0]]; + } +}; diff --git a/moveit_planners/trajopt/trajopt/include/trajopt/common.hpp b/moveit_planners/trajopt/trajopt/include/trajopt/common.hpp new file mode 100644 index 0000000000..41b82a6046 --- /dev/null +++ b/moveit_planners/trajopt/trajopt/include/trajopt/common.hpp @@ -0,0 +1,3 @@ +#pragma once +#include +#include diff --git a/moveit_planners/trajopt/trajopt/include/trajopt/kinematic_terms.h b/moveit_planners/trajopt/trajopt/include/trajopt/kinematic_terms.h new file mode 100644 index 0000000000..b8daa7515e --- /dev/null +++ b/moveit_planners/trajopt/trajopt/include/trajopt/kinematic_terms.h @@ -0,0 +1,93 @@ +#pragma once + +#include + +#include + +namespace trajopt +{ +/** + * @brief Extracts the vector part of quaternion + */ +inline Eigen::Vector3d quaternionRotationVector(const Eigen::Matrix3d& matrix) +{ + Eigen::Quaterniond quaternion; + quaternion = matrix; + return Eigen::Vector3d(quaternion.x(), quaternion.y(), quaternion.z()); +} + +/** + * @brief Appends b to a of type VectorXd + */ +inline Eigen::VectorXd concatVector(const Eigen::VectorXd& vector_a, const Eigen::VectorXd& vector_b) +{ + Eigen::VectorXd out(vector_a.size() + vector_b.size()); + out.topRows(vector_a.size()) = vector_a; + out.middleRows(vector_a.size(), vector_b.size()) = vector_b; + return out; +} + +/** + * @brief Appends b to a of type T + */ +template +inline std::vector concatVector(const std::vector& vector_a, const std::vector& vector_b) +{ + std::vector out; + out.insert(out.end(), vector_a.begin(), vector_a.end()); + out.insert(out.end(), vector_b.begin(), vector_b.end()); + return out; +} + +/** + * @brief Used to calculate the error for StaticCartPoseTermInfo + * This is converted to a cost or constraint using TrajOptCostFromErrFunc or TrajOptConstraintFromErrFunc + */ +struct CartPoseErrCalculator : public sco::VectorOfVector +{ + EIGEN_MAKE_ALIGNED_OPERATOR_NEW + Eigen::Isometry3d target_pose_inv_; + planning_scene::PlanningSceneConstPtr planning_scene_; + std::string link_; + Eigen::Isometry3d tcp_; + + CartPoseErrCalculator(const Eigen::Isometry3d& pose, const planning_scene::PlanningSceneConstPtr planning_scene, + const std::string& link, Eigen::Isometry3d tcp = Eigen::Isometry3d::Identity()) + : target_pose_inv_(pose.inverse()), planning_scene_(planning_scene), link_(link), tcp_(tcp) + { + } + + Eigen::VectorXd operator()(const Eigen::VectorXd& dof_vals) const override; +}; + +// TODO(omid): The following should be added and adjusted from trajopt +// JointPosEqCost +// JointPosIneqCost +// JointPosEqConstraint +// JointPosIneqConstraint + +struct JointVelErrCalculator : sco::VectorOfVector +{ + /** @brief Velocity target */ + double target_; + /** @brief Upper tolerance */ + double upper_tol_; + /** @brief Lower tolerance */ + double lower_tol_; + JointVelErrCalculator() : target_(0.0), upper_tol_(0.0), lower_tol_(0.0) + { + } + JointVelErrCalculator(double target, double upper_tol, double lower_tol) + : target_(target), upper_tol_(upper_tol), lower_tol_(lower_tol) + { + } + + Eigen::VectorXd operator()(const Eigen::VectorXd& var_vals) const override; +}; + +struct JointVelJacobianCalculator : sco::MatrixOfVector +{ + Eigen::MatrixXd operator()(const Eigen::VectorXd& var_vals) const override; +}; + +} // namespace trajopt diff --git a/moveit_planners/trajopt/trajopt/include/trajopt/problem_description.h b/moveit_planners/trajopt/trajopt/include/trajopt/problem_description.h new file mode 100644 index 0000000000..6d6ff865f8 --- /dev/null +++ b/moveit_planners/trajopt/trajopt/include/trajopt/problem_description.h @@ -0,0 +1,367 @@ +#pragma once + +#include +#include + +#include +#include + +#include + +namespace trajopt +{ +/** +@brief Used to apply cost/constraint to joint-space velocity + +Term is applied to every step between first_step and last_step. It applies two limits, upper_limits/lower_limits, +to the joint velocity subject to the following cases. + +* term_type = TT_COST +** upper_limit = lower_limit = 0 - Cost is applied with a SQUARED error scaled for each joint by coeffs +** upper_limit != lower_limit - 2 hinge costs are applied scaled for each joint by coeffs. If velocity < upper_limit and +velocity > lower_limit, no penalty. + +* term_type = TT_CNT +** upper_limit = lower_limit = 0 - Equality constraint is applied +** upper_limit != lower_limit - 2 Inequality constraints are applied. These are both satisfied when velocity < +upper_limit and velocity > lower_limit + +Note: coeffs, upper_limits, and lower_limits are optional. If a term is not given it will default to 0 for all joints. +If one value is given, this will be broadcast to all joints. + +Note: Velocity is calculated numerically using forward finite difference + +\f{align*}{ + cost = \sum_{t=0}^{T-2} \sum_j c_j (x_{t+1,j} - x_{t,j})^2 +\f} +where j indexes over DOF, and \f$c_j\f$ are the coeffs. +*/ + +struct TermInfo; +MOVEIT_CLASS_FORWARD(TermInfo); + +class TrajOptProblem; +MOVEIT_CLASS_FORWARD(TrajOptProblem); + +struct JointPoseTermInfo; +MOVEIT_CLASS_FORWARD(JointPoseTermInfo); + +struct CartPoseTermInfo; +MOVEIT_CLASS_FORWARD(CartPoseTermInfo); + +struct JointVelTermInfo; +MOVEIT_CLASS_FORWARD(JointVelTermInfo); + +struct ProblemInfo; +TrajOptProblemPtr ConstructProblem(const ProblemInfo&); + +enum TermType +{ + TT_COST = 0x1, // 0000 0001 + TT_CNT = 0x2, // 0000 0010 + TT_USE_TIME = 0x4, // 0000 0100 +}; + +struct BasicInfo +{ + /** @brief If true, first time step is fixed with a joint level constraint + If this is false, the starting point of the trajectory will + not be the current position of the robot. The use case example is: if we are trying to execute a process like + sanding the critical part which is the actual process path not how we get to the start of the process path. So we + plan the + process path first leaving the start free to hopefully get the most optimal and then we plan from the current + location with + start fixed to the start of the process path. It depends on what we want the default behavior to be + */ + bool start_fixed; + /** @brief Number of time steps (rows) in the optimization matrix */ + int n_steps; + sco::IntVec dofs_fixed; // optional + sco::ModelType convex_solver; // which convex solver to use + + /** @brief If true, the last column in the optimization matrix will be 1/dt */ + bool use_time = false; + /** @brief The upper limit of 1/dt values allowed in the optimization*/ + double dt_upper_lim = 1.0; + /** @brief The lower limit of 1/dt values allowed in the optimization*/ + double dt_lower_lim = 1.0; +}; + +/** +Initialization info read from json +*/ +struct InitInfo +{ + /** @brief Methods of initializing the optimization matrix. This defines how robot moves from the current + state to the start state + + STATIONARY: Initializes all joint values to the initial value (the current value in the env) + JOINT_INTERPOLATED: Linearly interpolates between initial value and the joint position specified in InitInfo.data + GIVEN_TRAJ: Initializes the matrix to a given trajectory + + In all cases the dt column (if present) is appended the selected method is defined. + */ + enum Type + { + STATIONARY, + JOINT_INTERPOLATED, + GIVEN_TRAJ, + }; + /** @brief Specifies the type of initialization to use */ + Type type; + + /** @brief Data used during initialization. Use depends on the initialization selected. This data will be used + to create initialization matrix. We need to give the goal information to this init info + */ + trajopt::TrajArray data; + + /** @brief Default value the final column of the optimization is initialized too if time is being used */ + double dt = 1.0; +}; + +/** +When cost or constraint element of JSON doc is read, one of these guys gets +constructed to hold the parameters. +Then it later gets converted to a Cost object by the addObjectiveTerms method +*/ +struct TermInfo +{ + std::string name; + int term_type; + int getSupportedTypes() + { + return supported_term_types_; + } + // virtual void fromJson(ProblemConstructionInfo& pci, const Json::Value& v) = 0; + virtual void addObjectiveTerms(TrajOptProblem& prob) = 0; + + static TermInfoPtr fromName(const std::string& type); + + /** + * Registers a user-defined TermInfo so you can use your own cost + * see function RegisterMakers.cpp + */ + using MakerFunc = TermInfoPtr (*)(void); + static void RegisterMaker(const std::string& type, MakerFunc); + + virtual ~TermInfo() = default; + +protected: + TermInfo(int supported_term_types) : supported_term_types_(supported_term_types) + { + } + +private: + static std::map name_to_maker_; + int supported_term_types_; +}; + +struct ProblemInfo +{ +public: + BasicInfo basic_info; + sco::BasicTrustRegionSQPParameters opt_info; + std::vector cost_infos; + std::vector cnt_infos; + InitInfo init_info; + + planning_scene::PlanningSceneConstPtr planning_scene; + std::string planning_group_name; + + ProblemInfo(planning_scene::PlanningSceneConstPtr ps, const std::string& pg) + : planning_scene(ps), planning_group_name(pg) + { + } +}; + +/** + * Holds all the data for a trajectory optimization problem + * so you can modify it programmatically, e.g. add your own costs + */ +class TrajOptProblem : public sco::OptProb +{ +public: + TrajOptProblem(); + TrajOptProblem(const ProblemInfo& problem_info); + virtual ~TrajOptProblem() = default; + /** @brief Returns the values of the specified joints (start_col to num_col) for the specified timestep i.*/ + sco::VarVector GetVarRow(int i, int start_col, int num_col) + { + return matrix_traj_vars.rblock(i, start_col, num_col); + } + /** @brief Returns the values of all joints for the specified timestep i.*/ + sco::VarVector GetVarRow(int i) + { + return matrix_traj_vars.row(i); + } + /** @brief Returns the value of the specified joint j for the specified timestep i.*/ + sco::Var& GetVar(int i, int j) + { + return matrix_traj_vars.at(i, j); + } + trajopt::VarArray& GetVars() + { + return matrix_traj_vars; + } + /** @brief Returns the number of steps in the problem. This is the number of rows in the optimization matrix.*/ + int GetNumSteps() + { + return matrix_traj_vars.rows(); + } + /** @brief Returns the problem DOF. This is the number of columns in the optization matrix. + * Note that this is not necessarily the same as the kinematic DOF.*/ + int GetNumDOF() + { + return matrix_traj_vars.cols(); + } + /** @brief Returns the kinematic DOF of the active joint model group + */ + int GetActiveGroupNumDOF() + { + return dof_; + } + planning_scene::PlanningSceneConstPtr GetPlanningScene() + { + return planning_scene_; + } + void SetInitTraj(const trajopt::TrajArray& x) + { + matrix_init_traj = x; + } + trajopt::TrajArray GetInitTraj() + { + return matrix_init_traj; + } + // friend TrajOptProbPtr ConstructProblem(const ProblemConstructionInfo&); + /** @brief Returns TrajOptProb.has_time */ + bool GetHasTime() + { + return has_time; + } + /** @brief Sets TrajOptProb.has_time */ + void SetHasTime(bool tmp) + { + has_time = tmp; + } + +private: + /** @brief If true, the last column in the optimization matrix will be 1/dt */ + bool has_time; + /** @brief is the matrix holding the joint values of the trajectory for all timesteps */ + trajopt::VarArray matrix_traj_vars; + planning_scene::PlanningSceneConstPtr planning_scene_; + std::string planning_group_; + /** @brief Kinematic DOF of the active joint model group */ + int dof_; + trajopt::TrajArray matrix_init_traj; +}; + +/** @brief This term is used when the goal frame is fixed in cartesian space + + Set term_type == TT_COST or TT_CNT for cost or constraint. +*/ +struct CartPoseTermInfo : public TermInfo +{ + // EIGEN_MAKE_ALIGNED_OPERATOR_NEW + + /** @brief Timestep at which to apply term */ + int timestep; + /** @brief Cartesian position */ + Eigen::Vector3d xyz; + /** @brief Rotation quaternion */ + Eigen::Vector4d wxyz; + /** @brief coefficients for position and rotation */ + Eigen::Vector3d pos_coeffs, rot_coeffs; + /** @brief Link which should reach desired pose */ + std::string link; + /** @brief Static transform applied to the link */ + Eigen::Isometry3d tcp; + + CartPoseTermInfo(); + + /** @brief Used to add term to pci from json */ + // void fromJson(ProblemConstructionInfo& pci, const Json::Value& v) override; + /** @brief Converts term info into cost/constraint and adds it to trajopt problem */ + void addObjectiveTerms(TrajOptProblem& prob) override; + + static TermInfoPtr create() + { + TermInfoPtr out(new CartPoseTermInfo()); + return out; + } +}; + +/** + \brief Joint space position cost + Position operates on a single point (unlike velocity, etc). This is b/c the primary usecase is joint-space + position waypoints + + \f{align*}{ + \sum_i c_i (x_i - xtarg_i)^2 + \f} + where \f$i\f$ indexes over dof and \f$c_i\f$ are coeffs + */ +struct JointPoseTermInfo : public TermInfo +{ + /** @brief Vector of coefficients that scale the cost. Size should be the DOF of the system. Default: vector of 0's*/ + trajopt::DblVec coeffs; + /** @brief Vector of position targets. This is a required value. Size should be the DOF of the system */ + trajopt::DblVec targets; + /** @brief Vector of position upper limits. Size should be the DOF of the system. Default: vector of 0's*/ + trajopt::DblVec upper_tols; + /** @brief Vector of position lower limits. Size should be the DOF of the system. Default: vector of 0's*/ + trajopt::DblVec lower_tols; + /** @brief First time step to which the term is applied. Default: 0 */ + int first_step = 0; + /** @brief Last time step to which the term is applied. Default: prob.GetNumSteps() - 1*/ + int last_step = -1; + + /** @brief Initialize term with it's supported types */ + JointPoseTermInfo() : TermInfo(TT_COST | TT_CNT | TT_USE_TIME) + { + } + + /** @brief Converts term info into cost/constraint and adds it to trajopt problem */ + void addObjectiveTerms(TrajOptProblem& prob) override; + + static TermInfoPtr create() + { + TermInfoPtr out(new JointPoseTermInfo()); + return out; + } +}; + +struct JointVelTermInfo : public TermInfo +{ + /** @brief Vector of coefficients that scale the cost. Size should be the DOF of the system. Default: vector of 0's*/ + trajopt::DblVec coeffs; + /** @brief Vector of velocity targets. This is a required value. Size should be the DOF of the system */ + trajopt::DblVec targets; + /** @brief Vector of velocity upper limits. Size should be the DOF of the system. Default: vector of 0's*/ + trajopt::DblVec upper_tols; + /** @brief Vector of velocity lower limits. Size should be the DOF of the system. Default: vector of 0's*/ + trajopt::DblVec lower_tols; + /** @brief First time step to which the term is applied. Default: 0*/ + int first_step = 0; + /** @brief Last time step to which the term is applied. Default: prob.GetNumSteps() - 1*/ + int last_step = -1; + + /** @brief Initialize term with it's supported types */ + JointVelTermInfo() : TermInfo(TT_COST | TT_CNT | TT_USE_TIME) + { + } + + /** @brief Converts term info into cost/constraint and adds it to trajopt problem */ + void addObjectiveTerms(TrajOptProblem& prob) override; + + static TermInfoPtr create() + { + TermInfoPtr out(new JointVelTermInfo()); + return out; + } +}; + +void generateInitialTrajectory(const ProblemInfo& pci, const std::vector& current_joint_values, + trajopt::TrajArray& init_traj); + +} // namespace trajopt_interface diff --git a/moveit_planners/trajopt/trajopt/include/trajopt/trajectory_costs.hpp b/moveit_planners/trajopt/trajopt/include/trajopt/trajectory_costs.hpp new file mode 100644 index 0000000000..c96b150bd2 --- /dev/null +++ b/moveit_planners/trajopt/trajopt/include/trajopt/trajectory_costs.hpp @@ -0,0 +1,541 @@ +#pragma once + +/** +Simple quadratic costs on trajectory +*/ + +#include +#include + +#include "trajopt/common.hpp" + +namespace trajopt +{ +class TRAJOPT_API JointPosEqCost : public sco::Cost +{ +public: + /** @brief Forms error in QuadExpr - independent of penalty type */ + JointPosEqCost(const VarArray& traj, const Eigen::VectorXd& coeffs, const Eigen::VectorXd& targets, int& first_step, + int& last_step); + /** @brief Convexifies cost expression - In this case, it is already quadratic so there's nothing to do */ + sco::ConvexObjectivePtr convex(const DblVec& x, sco::Model* model) override; + /** @brief Numerically evaluate cost given the vector of values */ + double value(const DblVec&) override; + sco::VarVector getVars() override + { + return vars_.flatten(); + } + +private: + /** @brief The variables being optimized. Used to properly index the vector being optimized */ + VarArray vars_; + /** @brief The coefficients used to weight the cost */ + Eigen::VectorXd coeffs_; + /** @brief Stores the cost as an expression */ + sco::QuadExpr expr_; + /** @brief Vector of velocity targets */ + Eigen::VectorXd targets_; + /** @brief First time step to which the term is applied */ + int first_step_; + /** @brief Last time step to which the term is applied */ + int last_step_; +}; + +/** + * @brief The JointVelIneqCost class + * Assumes that the target is ... + */ +class TRAJOPT_API JointPosIneqCost : public sco::Cost +{ +public: + /** @brief Forms error in QuadExpr - independent of penalty type */ + JointPosIneqCost(const VarArray& traj, const Eigen::VectorXd& coeffs, const Eigen::VectorXd& targets, + const Eigen::VectorXd& upper_limits, const Eigen::VectorXd& lower_limits, int& first_step, + int& last_step); + /** @brief Convexifies cost expression - In this case, it is already quadratic so there's nothing to do */ + sco::ConvexObjectivePtr convex(const DblVec& x, sco::Model* model) override; + /** @brief Numerically evaluate cost given the vector of values */ + double value(const DblVec&) override; + sco::VarVector getVars() override + { + return vars_.flatten(); + } + +private: + /** @brief The variables being optimized. Used to properly index the vector being optimized */ + VarArray vars_; + /** @brief The coefficients used to weight the cost */ + Eigen::VectorXd coeffs_; + /** @brief Vector of upper tolerances */ + Eigen::VectorXd upper_tols_; + /** @brief Vector of lower tolerances */ + Eigen::VectorXd lower_tols_; + /** @brief Vector of velocity targets */ + Eigen::VectorXd targets_; + /** @brief First time step to which the term is applied */ + int first_step_; + /** @brief Last time step to which the term is applied */ + int last_step_; + /** @brief Stores the costs as an expression. Will be length num_jnts*num_timesteps*2 */ + std::vector expr_vec_; +}; + +class TRAJOPT_API JointPosEqConstraint : public sco::EqConstraint +{ +public: + /** @brief Forms error in QuadExpr - independent of penalty type */ + JointPosEqConstraint(const VarArray& traj, const Eigen::VectorXd& coeffs, const Eigen::VectorXd& targetss, + int& first_step, int& last_step); + /** @brief Convexifies cost expression - In this case, it is already quadratic so there's nothing to do */ + sco::ConvexConstraintsPtr convex(const DblVec& x, sco::Model* model) override; + /** @brief Numerically evaluate cost given the vector of values */ + DblVec value(const DblVec&) override; + + sco::VarVector getVars() override + { + return vars_.flatten(); + } + +private: + /** @brief The variables being optimized. Used to properly index the vector being optimized */ + VarArray vars_; + /** @brief The coefficients used to weight the cost */ + Eigen::VectorXd coeffs_; + /** @brief Stores the costs as an expression. Will be length num_jnts*num_timesteps */ + std::vector expr_vec_; + /** @brief Vector of velocity targets */ + Eigen::VectorXd targets_; + /** @brief First time step to which the term is applied */ + int first_step_; + /** @brief Last time step to which the term is applied */ + int last_step_; +}; + +class TRAJOPT_API JointPosIneqConstraint : public sco::IneqConstraint +{ +public: + /** @brief Forms error in QuadExpr - independent of penalty type */ + JointPosIneqConstraint(const VarArray& traj, const Eigen::VectorXd& coeffs, const Eigen::VectorXd& targets, + const Eigen::VectorXd& upper_limits, const Eigen::VectorXd& lower_limits, int& first_step, + int& last_step); + /** @brief Convexifies cost expression - In this case, it is already quadratic so there's nothing to do */ + sco::ConvexConstraintsPtr convex(const DblVec& x, sco::Model* model) override; + /** @brief Numerically evaluate cost given the vector of values */ + DblVec value(const DblVec&) override; + sco::VarVector getVars() override + { + return vars_.flatten(); + } + +private: + /** @brief The variables being optimized. Used to properly index the vector being optimized */ + VarArray vars_; + /** @brief The coefficients used to weight the cost */ + Eigen::VectorXd coeffs_; + /** @brief Vector of upper tolerances */ + Eigen::VectorXd upper_tols_; + /** @brief Vector of lower tolerances */ + Eigen::VectorXd lower_tols_; + /** @brief Vector of targets */ + Eigen::VectorXd targets_; + /** @brief First time step to which the term is applied */ + int first_step_; + /** @brief Last time step to which the term is applied */ + int last_step_; + /** @brief Stores the costs as an expression. Will be length num_jnts*num_timesteps*2 */ + std::vector expr_vec_; +}; + +class TRAJOPT_API JointVelEqCost : public sco::Cost +{ +public: + /** @brief Forms error in QuadExpr - independent of penalty type */ + JointVelEqCost(const VarArray& traj, const Eigen::VectorXd& coeffs, const Eigen::VectorXd& targets, int& first_step, + int& last_step); + /** @brief Convexifies cost expression - In this case, it is already quadratic so there's nothing to do */ + sco::ConvexObjectivePtr convex(const DblVec& x, sco::Model* model) override; + /** @brief Numerically evaluate cost given the vector of values using Eigen*/ + double value(const DblVec&) override; + sco::VarVector getVars() override + { + return vars_.flatten(); + } + +private: + /** @brief The variables being optimized. Used to properly index the vector being optimized */ + VarArray vars_; + /** @brief The coefficients used to weight the cost */ + Eigen::VectorXd coeffs_; + /** @brief Stores the cost as an expression */ + sco::QuadExpr expr_; + /** @brief Vector of velocity targets */ + Eigen::VectorXd targets_; + /** @brief First time step to which the term is applied */ + int first_step_; + /** @brief Last time step to which the term is applied */ + int last_step_; +}; + +class TRAJOPT_API JointVelIneqCost : public sco::Cost +{ +public: + /** @brief Forms error in QuadExpr - independent of penalty type */ + JointVelIneqCost(const VarArray& traj, const Eigen::VectorXd& coeffs, const Eigen::VectorXd& targets, + const Eigen::VectorXd& upper_limits, const Eigen::VectorXd& lower_limits, int& first_step, + int& last_step); + /** @brief Convexifies cost expression - In this case, it is already quadratic so there's nothing to do */ + sco::ConvexObjectivePtr convex(const DblVec& x, sco::Model* model) override; + /** @brief Numerically evaluate cost given the vector of values */ + double value(const DblVec&) override; + sco::VarVector getVars() override + { + return vars_.flatten(); + } + +private: + /** @brief The variables being optimized. Used to properly index the vector being optimized */ + VarArray vars_; + /** @brief The coefficients used to weight the cost */ + Eigen::VectorXd coeffs_; + /** @brief Vector of upper tolerances */ + Eigen::VectorXd upper_tols_; + /** @brief Vector of lower tolerances */ + Eigen::VectorXd lower_tols_; + /** @brief Vector of velocity targets */ + Eigen::VectorXd targets_; + /** @brief First time step to which the term is applied */ + int first_step_; + /** @brief Last time step to which the term is applied */ + int last_step_; + /** @brief Stores the costs as an expression. Will be length num_jnts*num_timesteps*2 */ + std::vector expr_vec_; +}; + +class TRAJOPT_API JointVelEqConstraint : public sco::EqConstraint +{ +public: + /** @brief Forms error in QuadExpr - independent of penalty type */ + JointVelEqConstraint(const VarArray& traj, const Eigen::VectorXd& coeffs, const Eigen::VectorXd& targets, + int& first_step, int& last_step); + /** @brief Convexifies cost expression - In this case, it is already quadratic so there's nothing to do */ + sco::ConvexConstraintsPtr convex(const DblVec& x, sco::Model* model) override; + /** @brief Numerically evaluate cost given the vector of values */ + DblVec value(const DblVec&) override; + + sco::VarVector getVars() override + { + return vars_.flatten(); + } + +private: + /** @brief The variables being optimized. Used to properly index the vector being optimized */ + VarArray vars_; + /** @brief The coefficients used to weight the cost */ + Eigen::VectorXd coeffs_; + /** @brief Stores the costs as an expression. Will be length num_jnts*(num_timesteps-1) */ + std::vector expr_vec_; + /** @brief Vector of velocity targets */ + Eigen::VectorXd targets_; + /** @brief First time step to which the term is applied */ + int first_step_; + /** @brief Last time step to which the term is applied */ + int last_step_; +}; + +class TRAJOPT_API JointVelIneqConstraint : public sco::IneqConstraint +{ +public: + /** @brief Forms error in QuadExpr - independent of penalty type */ + JointVelIneqConstraint(const VarArray& traj, const Eigen::VectorXd& coeffs, const Eigen::VectorXd& targets, + const Eigen::VectorXd& upper_limits, const Eigen::VectorXd& lower_limits, int& first_step, + int& last_step); + /** @brief Convexifies cost expression - In this case, it is already quadratic so there's nothing to do */ + sco::ConvexConstraintsPtr convex(const DblVec& x, sco::Model* model) override; + /** @brief Numerically evaluate cost given the vector of values */ + DblVec value(const DblVec&) override; + sco::VarVector getVars() override + { + return vars_.flatten(); + } + +private: + /** @brief The variables being optimized. Used to properly index the vector being optimized */ + VarArray vars_; + /** @brief The coefficients used to weight the cost */ + Eigen::VectorXd coeffs_; + /** @brief Vector of upper tolerances */ + Eigen::VectorXd upper_tols_; + /** @brief Vector of lower tolerances */ + Eigen::VectorXd lower_tols_; + /** @brief Vector of velocity targets */ + Eigen::VectorXd targets_; + /** @brief First time step to which the term is applied */ + int first_step_; + /** @brief Last time step to which the term is applied */ + int last_step_; + /** @brief Stores the costs as an expression. Will be length num_jnts*(num_timesteps-1)*2 */ + std::vector expr_vec_; +}; + +class TRAJOPT_API JointAccEqCost : public sco::Cost +{ +public: + /** @brief Forms error in QuadExpr - independent of penalty type */ + JointAccEqCost(const VarArray& traj, const Eigen::VectorXd& coeffs, const Eigen::VectorXd& targets, int& first_step, + int& last_step); + /** @brief Convexifies cost expression - In this case, it is already quadratic so there's nothing to do */ + sco::ConvexObjectivePtr convex(const DblVec& x, sco::Model* model) override; + /** @brief Numerically evaluate cost given the vector of values */ + double value(const DblVec&) override; + sco::VarVector getVars() override + { + return vars_.flatten(); + } + +private: + /** @brief The variables being optimized. Used to properly index the vector being optimized */ + VarArray vars_; + /** @brief The coefficients used to weight the cost */ + Eigen::VectorXd coeffs_; + /** @brief Stores the cost as an expression */ + sco::QuadExpr expr_; + /** @brief Vector of velocity targets */ + Eigen::VectorXd targets_; + /** @brief First time step to which the term is applied */ + int first_step_; + /** @brief Last time step to which the term is applied */ + int last_step_; +}; + +class TRAJOPT_API JointAccIneqCost : public sco::Cost +{ +public: + /** @brief Forms error in a vector of AffExpr - independent of penalty type */ + JointAccIneqCost(const VarArray& traj, const Eigen::VectorXd& coeffs, const Eigen::VectorXd& targets, + const Eigen::VectorXd& upper_limits, const Eigen::VectorXd& lower_limits, int& first_step, + int& last_step); + /** @brief Convexifies cost expression - In this case, it is already quadratic so there's nothing to do */ + sco::ConvexObjectivePtr convex(const DblVec& x, sco::Model* model) override; + /** @brief Numerically evaluate cost given the vector of values */ + double value(const DblVec&) override; + sco::VarVector getVars() override + { + return vars_.flatten(); + } + +private: + /** @brief The variables being optimized. Used to properly index the vector being optimized */ + VarArray vars_; + /** @brief The coefficients used to weight the cost */ + Eigen::VectorXd coeffs_; + /** @brief Vector of upper tolerances */ + Eigen::VectorXd upper_tols_; + /** @brief Vector of lower tolerances */ + Eigen::VectorXd lower_tols_; + /** @brief Vector of acceleration targets */ + Eigen::VectorXd targets_; + /** @brief First time step to which the term is applied */ + int first_step_; + /** @brief Last time step to which the term is applied */ + int last_step_; + /** @brief Stores the costs as an expression. Will be length num_jnts*(num_timesteps-2)*2 */ + std::vector expr_vec_; +}; + +class TRAJOPT_API JointAccEqConstraint : public sco::EqConstraint +{ +public: + /** @brief Forms error in a vector of AffExpr - independent of penalty type */ + JointAccEqConstraint(const VarArray& traj, const Eigen::VectorXd& coeffs, const Eigen::VectorXd& targets, + int& first_step, int& last_step); + /** @brief Convexifies cost expression - In this case, it is already quadratic so there's nothing to do */ + sco::ConvexConstraintsPtr convex(const DblVec& x, sco::Model* model) override; + /** @brief Numerically evaluate cost given the vector of values */ + DblVec value(const DblVec&) override; + + sco::VarVector getVars() override + { + return vars_.flatten(); + } + +private: + /** @brief The variables being optimized. Used to properly index the vector being optimized */ + VarArray vars_; + /** @brief The coefficients used to weight the cost */ + Eigen::VectorXd coeffs_; + /** @brief Stores the costs as an expression. Will be length num_jnts*(num_timesteps-2) */ + std::vector expr_vec_; + /** @brief Vector of acceleration targets */ + Eigen::VectorXd targets_; + /** @brief First time step to which the term is applied */ + int first_step_; + /** @brief Last time step to which the term is applied */ + int last_step_; +}; + +class TRAJOPT_API JointAccIneqConstraint : public sco::IneqConstraint +{ +public: + /** @brief Forms error in a vector of AffExpr - independent of penalty type */ + JointAccIneqConstraint(const VarArray& traj, const Eigen::VectorXd& coeffs, const Eigen::VectorXd& targets, + const Eigen::VectorXd& upper_limits, const Eigen::VectorXd& lower_limits, int& first_step, + int& last_step); + /** @brief Convexifies cost expression - In this case, it is already quadratic so there's nothing to do */ + sco::ConvexConstraintsPtr convex(const DblVec& x, sco::Model* model) override; + /** @brief Numerically evaluate cost given the vector of values */ + DblVec value(const DblVec&) override; + sco::VarVector getVars() override + { + return vars_.flatten(); + } + +private: + /** @brief The variables being optimized. Used to properly index the vector being optimized */ + VarArray vars_; + /** @brief The coefficients used to weight the cost */ + Eigen::VectorXd coeffs_; + /** @brief Vector of upper tolerances */ + Eigen::VectorXd upper_tols_; + /** @brief Vector of lower tolerances */ + Eigen::VectorXd lower_tols_; + /** @brief Vector of acceleration targets */ + Eigen::VectorXd targets_; + /** @brief First time step to which the term is applied */ + int first_step_; + /** @brief Last time step to which the term is applied */ + int last_step_; + /** @brief Stores the costs as an expression. Will be length num_jnts*(num_timesteps-2)*2 */ + std::vector expr_vec_; +}; + +class TRAJOPT_API JointJerkEqCost : public sco::Cost +{ +public: + /** @brief Forms error in QuadExpr - independent of penalty type */ + JointJerkEqCost(const VarArray& traj, const Eigen::VectorXd& coeffs, const Eigen::VectorXd& targets, int& first_step, + int& last_step); + /** @brief Convexifies cost expression - In this case, it is already quadratic so there's nothing to do */ + sco::ConvexObjectivePtr convex(const DblVec& x, sco::Model* model) override; + /** @brief Numerically evaluate cost given the vector of values */ + double value(const DblVec&) override; + sco::VarVector getVars() override + { + return vars_.flatten(); + } + +private: + /** @brief The variables being optimized. Used to properly index the vector being optimized */ + VarArray vars_; + /** @brief The coefficients used to weight the cost */ + Eigen::VectorXd coeffs_; + /** @brief Stores the cost as an expression */ + sco::QuadExpr expr_; + /** @brief Vector of jerk targets */ + Eigen::VectorXd targets_; + /** @brief First time step to which the term is applied */ + int first_step_; + /** @brief Last time step to which the term is applied */ + int last_step_; +}; + +class TRAJOPT_API JointJerkIneqCost : public sco::Cost +{ +public: + /** @brief Forms error in a vector of AffExpr - independent of penalty type */ + JointJerkIneqCost(const VarArray& traj, const Eigen::VectorXd& coeffs, const Eigen::VectorXd& targets, + const Eigen::VectorXd& upper_limits, const Eigen::VectorXd& lower_limits, int& first_step, + int& last_step); + /** @brief Convexifies cost expression - In this case, it is already quadratic so there's nothing to do */ + sco::ConvexObjectivePtr convex(const DblVec& x, sco::Model* model) override; + /** @brief Numerically evaluate cost given the vector of values */ + double value(const DblVec&) override; + sco::VarVector getVars() override + { + return vars_.flatten(); + } + +private: + /** @brief The variables being optimized. Used to properly index the vector being optimized */ + VarArray vars_; + /** @brief The coefficients used to weight the cost */ + Eigen::VectorXd coeffs_; + /** @brief Vector of upper tolerances */ + Eigen::VectorXd upper_tols_; + /** @brief Vector of lower tolerances */ + Eigen::VectorXd lower_tols_; + /** @brief Vector of jerk targets */ + Eigen::VectorXd targets_; + /** @brief First time step to which the term is applied */ + int first_step_; + /** @brief Last time step to which the term is applied */ + int last_step_; + /** @brief Stores the costs as an expression. Will be length num_jnts*(num_timesteps-4)*2 */ + std::vector expr_vec_; +}; + +class TRAJOPT_API JointJerkEqConstraint : public sco::EqConstraint +{ +public: + /** @brief Forms error in a vector of AffExpr - independent of penalty type */ + JointJerkEqConstraint(const VarArray& traj, const Eigen::VectorXd& coeffs, const Eigen::VectorXd& targets, + int& first_step, int& last_step); + /** @brief Convexifies cost expression - In this case, it is already quadratic so there's nothing to do */ + sco::ConvexConstraintsPtr convex(const DblVec& x, sco::Model* model) override; + /** @brief Numerically evaluate cost given the vector of values */ + DblVec value(const DblVec&) override; + + sco::VarVector getVars() override + { + return vars_.flatten(); + } + +private: + /** @brief The variables being optimized. Used to properly index the vector being optimized */ + VarArray vars_; + /** @brief The coefficients used to weight the cost */ + Eigen::VectorXd coeffs_; + /** @brief Stores the costs as an expression. Will be length num_jnts*(num_timesteps-4) */ + std::vector expr_vec_; + /** @brief Vector of velocity targets */ + Eigen::VectorXd targets_; + /** @brief First time step to which the term is applied */ + int first_step_; + /** @brief Last time step to which the term is applied */ + int last_step_; +}; + +class TRAJOPT_API JointJerkIneqConstraint : public sco::IneqConstraint +{ +public: + /** @brief Forms error in a vector of AffExpr - independent of penalty type */ + JointJerkIneqConstraint(const VarArray& traj, const Eigen::VectorXd& coeffs, const Eigen::VectorXd& targets, + const Eigen::VectorXd& upper_limits, const Eigen::VectorXd& lower_limits, int& first_step, + int& last_step); + /** @brief Convexifies cost expression - In this case, it is already quadratic so there's nothing to do */ + sco::ConvexConstraintsPtr convex(const DblVec& x, sco::Model* model) override; + /** @brief Numerically evaluate cost given the vector of values */ + DblVec value(const DblVec&) override; + sco::VarVector getVars() override + { + return vars_.flatten(); + } + +private: + /** @brief The variables being optimized. Used to properly index the vector being optimized */ + VarArray vars_; + /** @brief The coefficients used to weight the cost */ + Eigen::VectorXd coeffs_; + /** @brief Vector of upper tolerances */ + Eigen::VectorXd upper_tols_; + /** @brief Vector of lower tolerances */ + Eigen::VectorXd lower_tols_; + /** @brief Vector of velocity targets */ + Eigen::VectorXd targets_; + /** @brief First time step to which the term is applied */ + int first_step_; + /** @brief Last time step to which the term is applied */ + int last_step_; + /** @brief Stores the costs as an expression. Will be length num_jnts*(num_timesteps-4)*2 */ + std::vector expr_vec_; +}; +} // namespace trajopt diff --git a/moveit_planners/trajopt/trajopt/include/trajopt/typedefs.hpp b/moveit_planners/trajopt/trajopt/include/trajopt/typedefs.hpp new file mode 100644 index 0000000000..d6ae14e9a9 --- /dev/null +++ b/moveit_planners/trajopt/trajopt/include/trajopt/typedefs.hpp @@ -0,0 +1,60 @@ +#pragma once +#include +#include +TRAJOPT_IGNORE_WARNINGS_PUSH +#include +#include +#include +TRAJOPT_IGNORE_WARNINGS_POP + +#include +#include + +namespace trajopt +{ +typedef util::BasicArray VarArray; +typedef util::BasicArray AffArray; +typedef util::BasicArray CntArray; +typedef Eigen::Matrix DblMatrix; +typedef Eigen::Matrix TrajArray; +typedef sco::DblVec DblVec; +typedef sco::IntVec IntVec; + +/** @brief Adds plotting to the CostFromErrFunc class in trajopt_sco */ +class TrajOptCostFromErrFunc : public sco::CostFromErrFunc +{ +public: + /// supply error function, obtain derivative numerically + TrajOptCostFromErrFunc(sco::VectorOfVectorPtr f, const sco::VarVector& vars, const Eigen::VectorXd& coeffs, + sco::PenaltyType pen_type, const std::string& name) + : CostFromErrFunc(f, vars, coeffs, pen_type, name) + { + } + + /// supply error function and gradient + TrajOptCostFromErrFunc(sco::VectorOfVectorPtr f, sco::MatrixOfVectorPtr dfdx, const sco::VarVector& vars, + const Eigen::VectorXd& coeffs, sco::PenaltyType pen_type, const std::string& name) + : CostFromErrFunc(f, dfdx, vars, coeffs, pen_type, name) + { + } +}; + +/** @brief Adds plotting to the ConstraintFromFunc class in trajopt_sco */ +class TrajOptConstraintFromErrFunc : public sco::ConstraintFromErrFunc +{ +public: + /// supply error function, obtain derivative numerically + TrajOptConstraintFromErrFunc(sco::VectorOfVectorPtr f, const sco::VarVector& vars, const Eigen::VectorXd& coeffs, + sco::ConstraintType type, const std::string& name) + : ConstraintFromErrFunc(f, vars, coeffs, type, name) + { + } + + /// supply error function and gradient + TrajOptConstraintFromErrFunc(sco::VectorOfVectorPtr f, sco::MatrixOfVectorPtr dfdx, const sco::VarVector& vars, + const Eigen::VectorXd& coeffs, sco::ConstraintType type, const std::string& name) + : ConstraintFromErrFunc(f, dfdx, vars, coeffs, type, name) + { + } +}; +} diff --git a/moveit_planners/trajopt/trajopt/include/trajopt/utils.hpp b/moveit_planners/trajopt/trajopt/include/trajopt/utils.hpp new file mode 100644 index 0000000000..710f21d42b --- /dev/null +++ b/moveit_planners/trajopt/trajopt/include/trajopt/utils.hpp @@ -0,0 +1,152 @@ +#pragma once +#include +TRAJOPT_IGNORE_WARNINGS_PUSH +#include +TRAJOPT_IGNORE_WARNINGS_POP + +#include + +namespace trajopt +{ +template +using AlignedUnorderedMap = std::unordered_map, std::equal_to, + Eigen::aligned_allocator>>; + +/** +Extract trajectory array from solution vector x using indices in array vars +*/ +TrajArray TRAJOPT_API getTraj(const DblVec& x, const VarArray& vars); +TrajArray TRAJOPT_API getTraj(const DblVec& x, const AffArray& arr); + +inline DblVec trajToDblVec(const TrajArray& x) +{ + return DblVec(x.data(), x.data() + x.rows() * x.cols()); +} + +/** + * @brief Appends b to a of type VectorXd + */ +inline Eigen::VectorXd concat(const Eigen::VectorXd& a, const Eigen::VectorXd& b) +{ + Eigen::VectorXd out(a.size() + b.size()); + out.topRows(a.size()) = a; + out.middleRows(a.size(), b.size()) = b; + return out; +} + +/** + * @brief Appends b to a of type T + */ +template +std::vector concat(const std::vector& a, const std::vector& b) +{ + std::vector out; + std::vector x(a.size() + b.size()); + out.insert(out.end(), a.begin(), a.end()); + out.insert(out.end(), b.begin(), b.end()); + return out; +} + +template +std::vector singleton(const T& x) +{ + return std::vector(1, x); +} + +void TRAJOPT_API AddVarArrays(sco::OptProb& prob, int rows, const std::vector& cols, + const std::vector& name_prefix, const std::vector& newvars); + +void TRAJOPT_API AddVarArray(sco::OptProb& prob, int rows, int cols, const std::string& name_prefix, VarArray& newvars); + +/** @brief Store Safety Margin Data for a given timestep */ +struct SafetyMarginData +{ + EIGEN_MAKE_ALIGNED_OPERATOR_NEW + SafetyMarginData(const double& default_safety_margin, const double& default_safety_margin_coeff) + : default_safety_margin_data_(default_safety_margin, default_safety_margin_coeff) + , max_safety_margin_(default_safety_margin) + { + } + + /** + * @brief Set the safety margin for a given contact pair + * + * The order of the object names does not matter, that is handled internal to + * the class. + * + * @param obj1 The first object name + * @param obj2 The Second object name + * @param safety_margins contacts with distance < safety_margin are penalized + * @param safety_margin_coeffs A safety margin coefficient vector where each + * element corresponds to a given timestep. + */ + void SetPairSafetyMarginData(const std::string& obj1, const std::string& obj2, const double& safety_margin, + const double& safety_margin_coeff) + { + Eigen::Vector2d data(safety_margin, safety_margin_coeff); + + pair_lookup_table_[obj1 + obj2] = data; + pair_lookup_table_[obj2 + obj1] = data; + + if (safety_margin > max_safety_margin_) + { + max_safety_margin_ = safety_margin; + } + } + + const Eigen::Vector2d& getPairSafetyMarginData(const std::string& obj1, const std::string& obj2) const + { + const std::string& key = obj1 + obj2; + auto it = pair_lookup_table_.find(key); + + if (it != pair_lookup_table_.end()) + { + return it->second; + } + else + { + return default_safety_margin_data_; + } + } + + const double& getMaxSafetyMargin() const + { + return max_safety_margin_; + } + +private: + /// The coeff used during optimization + /// safety margin: contacts with distance < dist_pen are penalized + /// Stores [dist_pen, coeff] + Eigen::Vector2d default_safety_margin_data_; + + /// This use when requesting collision data because you can only provide a + /// single contact distance threshold. + double max_safety_margin_; + + /// A map of link pair to contact distance setting [dist_pen, coeff] + AlignedUnorderedMap pair_lookup_table_; +}; +typedef std::shared_ptr SafetyMarginDataPtr; +typedef std::shared_ptr SafetyMarginDataConstPtr; + +/** + * @brief This is a utility function for creating the Safety Margin data vector + * @param num_elements The number of objects to create + * @param default_safety_margin Default safety margin + * @param default_safety_margin_coeff Default safety margin coeff + * @return A vector of Safety Margin Data + */ +inline std::vector createSafetyMarginDataVector(int num_elements, + const double& default_safety_margin, + const double& default_safety_margin_coeff) +{ + std::vector info; + info.reserve(static_cast(num_elements)); + for (auto i = 0; i < num_elements; ++i) + { + info.push_back(SafetyMarginDataPtr(new SafetyMarginData(default_safety_margin, default_safety_margin_coeff))); + } + return info; +} +} diff --git a/moveit_planners/trajopt/trajopt/package.xml b/moveit_planners/trajopt/trajopt/package.xml new file mode 100644 index 0000000000..ce1731dff7 --- /dev/null +++ b/moveit_planners/trajopt/trajopt/package.xml @@ -0,0 +1,27 @@ + + + trajopt + 0.1.0 + The trajopt package + Levi Armstrong + BSD + Apache 2.0 + Levi Armstrong + John Schulman + + catkin + trajopt_sco + trajopt_utils + roscpp + + gtest + rostest + roslib + libpcl-all-dev + pcl_conversions + pr2_description + + + + + diff --git a/moveit_planners/trajopt/trajopt/src/kinematic_terms.cpp b/moveit_planners/trajopt/trajopt/src/kinematic_terms.cpp new file mode 100644 index 0000000000..4559e5b8a1 --- /dev/null +++ b/moveit_planners/trajopt/trajopt/src/kinematic_terms.cpp @@ -0,0 +1,64 @@ +#include +#include + +#include +#include + +#include "trajopt/kinematic_terms.h" + +using namespace std; +using namespace sco; +using namespace Eigen; + +namespace trajopt +{ +VectorXd CartPoseErrCalculator::operator()(const VectorXd& dof_vals) const +{ + // TODO: create the actual error function from information in planning scene + VectorXd err; + return err; +} + +VectorXd JointVelErrCalculator::operator()(const VectorXd& var_vals) const +{ + assert(var_vals.rows() % 2 == 0); + // var_vals = (theta_t1, theta_t2, theta_t3 ... 1/dt_1, 1/dt_2, 1/dt_3 ...) + int half = static_cast(var_vals.rows() / 2); + int num_vels = half - 1; + // (x1-x0)*(1/dt) + VectorXd vel = (var_vals.segment(1, num_vels) - var_vals.segment(0, num_vels)).array() * + var_vals.segment(half + 1, num_vels).array(); + + // Note that for equality terms tols are 0, so error is effectively doubled + VectorXd result(vel.rows() * 2); + result.topRows(vel.rows()) = -(upper_tol_ - (vel.array() - target_)); + result.bottomRows(vel.rows()) = lower_tol_ - (vel.array() - target_); + return result; +} + +MatrixXd JointVelJacobianCalculator::operator()(const VectorXd& var_vals) const +{ + // var_vals = (theta_t1, theta_t2, theta_t3 ... 1/dt_1, 1/dt_2, 1/dt_3 ...) + int num_vals = static_cast(var_vals.rows()); + int half = num_vals / 2; + int num_vels = half - 1; + MatrixXd jac = MatrixXd::Zero(num_vels * 2, num_vals); + + for (int i = 0; i < num_vels; i++) + { + // v = (j_i+1 - j_i)*(1/dt) + // We calculate v with the dt from the second pt + int time_index = i + half + 1; + jac(i, i) = -1.0 * var_vals(time_index); + jac(i, i + 1) = 1.0 * var_vals(time_index); + jac(i, time_index) = var_vals(i + 1) - var_vals(i); + // All others are 0 + } + + // bottom half is negative velocities + jac.bottomRows(num_vels) = -jac.topRows(num_vels); + + return jac; +} + +} // namespace trajopt diff --git a/moveit_planners/trajopt/trajopt/src/problem_description.cpp b/moveit_planners/trajopt/trajopt/src/problem_description.cpp new file mode 100644 index 0000000000..3fa093c399 --- /dev/null +++ b/moveit_planners/trajopt/trajopt/src/problem_description.cpp @@ -0,0 +1,600 @@ +/********************************************************************* + * Software License Agreement (BSD License) + * + * Copyright (c) 2013, John Schulman + * 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 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. + * + * http://opensource.org/licenses/BSD-2-Clause + *********************************************************************/ + +#include +#include + +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include "trajopt/problem_description.h" + +/** + * @brief Checks the size of the parameter given and throws if incorrect + * @param parameter The vector whose size is getting checked + * @param expected_size The expected size of the vector + * @param name The name to use when printing an error or warning + * @param apply_first If true and only one value is given, broadcast value to length of expected_size + */ +void checkParameterSize(trajopt::DblVec& parameter, const unsigned int& expected_size, const std::string& name, + const bool& apply_first = true) +{ + if (apply_first == true && parameter.size() == 1) + { + parameter = trajopt::DblVec(expected_size, parameter[0]); + ROS_INFO("1 %s given. Applying to all %i joints", name.c_str(), expected_size); + } + else if (parameter.size() != expected_size) + { + PRINT_AND_THROW(boost::format("wrong number of %s. expected %i got %i") % name % expected_size % parameter.size()); + } +} + +namespace trajopt +{ +TrajOptProblem::TrajOptProblem() +{ +} + +TrajOptProblem::TrajOptProblem(const ProblemInfo& problem_info) + : OptProb(problem_info.basic_info.convex_solver) + , planning_scene_(problem_info.planning_scene) + , planning_group_(problem_info.planning_group_name) +{ + robot_model::RobotModelConstPtr robot_model = planning_scene_->getRobotModel(); + robot_state::RobotState current_state = planning_scene_->getCurrentState(); + const robot_state::JointModelGroup* joint_model_group = current_state.getJointModelGroup(planning_group_); + + moveit::core::JointBoundsVector bounds = joint_model_group->getActiveJointModelsBounds(); + dof_ = static_cast(joint_model_group->getActiveJointModelNames().size()); // or bounds.size(); + + int n_steps = problem_info.basic_info.n_steps; + + ROS_INFO(" ======================================= problem_description: limits"); + Eigen::MatrixX2d limits(dof_, 2); + for (int k = 0; k < limits.size() / 2; ++k) + { + moveit::core::JointModel::Bounds bound = *bounds[k]; + // In MoveIt, joints are considered to have multiple dofs but we only have single dof joints: + moveit::core::VariableBounds joint_bound = bound.front(); + + limits(k, 0) = joint_bound.min_position_; + limits(k, 1) = joint_bound.max_position_; + + ROS_INFO("joint %i with lower bound: %f, upper bound: %f", k, joint_bound.min_position_, joint_bound.max_position_); + } + + Eigen::VectorXd lower, upper; + lower = limits.col(0); + upper = limits.col(1); + + trajopt::DblVec vlower, vupper; + std::vector names; + for (int i = 0; i < n_steps; ++i) + { + for (int j = 0; j < dof_; ++j) + { + names.push_back((boost::format("j_%i_%i") % i % j).str()); + } + vlower.insert(vlower.end(), lower.data(), lower.data() + lower.size()); + vupper.insert(vupper.end(), upper.data(), upper.data() + upper.size()); + + if (problem_info.basic_info.use_time == true) + { + vlower.insert(vlower.end(), problem_info.basic_info.dt_lower_lim); + vupper.insert(vupper.end(), problem_info.basic_info.dt_upper_lim); + names.push_back((boost::format("dt_%i") % i).str()); + } + } + + sco::VarVector trajvarvec = createVariables(names, vlower, vupper); + matrix_traj_vars = trajopt::VarArray(n_steps, dof_ + (problem_info.basic_info.use_time ? 1 : 0), trajvarvec.data()); + // matrix_traj_vars is essentialy a matrix of elements like: + // j_0_0, j_0_1 ... + // j_1_0, j_1_1 ... + // its size is n_steps by n_dof +} + +TrajOptProblemPtr ConstructProblem(const ProblemInfo& pci) +{ + const BasicInfo& bi = pci.basic_info; + int n_steps = bi.n_steps; + + bool use_time = false; + // Check that all costs and constraints support the types that are specified in pci + for (TermInfoPtr cost : pci.cost_infos) + { + if (cost->term_type & TT_CNT) + ROS_WARN("%s is listed as a type TT_CNT but was added to cost_infos", (cost->name).c_str()); + if (!(cost->getSupportedTypes() & TT_COST)) + PRINT_AND_THROW(boost::format("%s is only a constraint, but you listed it as a cost") % cost->name); + if (cost->term_type & TT_USE_TIME) + { + use_time = true; + if (!(cost->getSupportedTypes() & TT_USE_TIME)) + PRINT_AND_THROW(boost::format("%s does not support time, but you listed it as a using time") % cost->name); + } + } + for (TermInfoPtr cnt : pci.cnt_infos) + { + if (cnt->term_type & TT_COST) + ROS_WARN("%s is listed as a type TT_COST but was added to cnt_infos", (cnt->name).c_str()); + if (!(cnt->getSupportedTypes() & TT_CNT)) + PRINT_AND_THROW(boost::format("%s is only a cost, but you listed it as a constraint") % cnt->name); + if (cnt->term_type & TT_USE_TIME) + { + use_time = true; + if (!(cnt->getSupportedTypes() & TT_USE_TIME)) + PRINT_AND_THROW(boost::format("%s does not support time, but you listed it as a using time") % cnt->name); + } + } + + // Check that if a cost or constraint uses time, basic_info is set accordingly + if ((use_time == true) && (pci.basic_info.use_time == false)) + PRINT_AND_THROW("A term is using time and basic_info is not set correctly. Try basic_info.use_time = true"); + + // This could be removed in the future once we are sure that all costs are + if ((use_time == false) && (pci.basic_info.use_time == true)) + PRINT_AND_THROW("No terms use time and basic_info is not set correctly. Try basic_info.use_time = false"); + + TrajOptProblemPtr prob(new TrajOptProblem(pci)); + + // Generate initial trajectory and check its size + robot_model::RobotModelConstPtr robot_model = pci.planning_scene->getRobotModel(); + robot_state::RobotState current_state = pci.planning_scene->getCurrentState(); + + const robot_state::JointModelGroup* joint_model_group = current_state.getJointModelGroup(pci.planning_group_name); + int n_dof = prob->GetNumDOF(); + + std::vector current_joint_values; + current_state.copyJointGroupPositions(joint_model_group, current_joint_values); + + trajopt::TrajArray init_traj; + generateInitialTrajectory(pci, current_joint_values, init_traj); + + if (pci.basic_info.use_time == true) + { + prob->SetHasTime(true); + if (init_traj.rows() != n_steps || init_traj.cols() != n_dof + 1) + { + PRINT_AND_THROW(boost::format("Initial trajectory is not the right size matrix\n" + "Expected %i rows (time steps) x %i columns (%i dof + 1 time column)\n" + "Got %i rows and %i columns") % + n_steps % (n_dof + 1) % n_dof % init_traj.rows() % init_traj.cols()); + } + } + else + { + prob->SetHasTime(false); + if (init_traj.rows() != n_steps || init_traj.cols() != n_dof) + { + PRINT_AND_THROW(boost::format("Initial trajectory is not the right size matrix\n" + "Expected %i rows (time steps) x %i columns\n" + "Got %i rows and %i columns") % + n_steps % n_dof % init_traj.rows() % init_traj.cols()); + } + } + prob->SetInitTraj(init_traj); + + trajopt::VarArray matrix_traj_vars_temp; + // If start_fixed, constrain the joint values for the first time step to be their initialized values + if (bi.start_fixed) + { + if (init_traj.rows() < 1) + { + PRINT_AND_THROW("Initial trajectory must contain at least the start state."); + } + + if (init_traj.cols() != (n_dof + (use_time ? 1 : 0))) + { + PRINT_AND_THROW("robot dof values don't match initialization. I don't " + "know what you want me to use for the dof values"); + } + + for (int j = 0; j < static_cast(n_dof); ++j) + { + matrix_traj_vars_temp = prob->GetVars(); + prob->addLinearConstraint(sco::exprSub(sco::AffExpr(matrix_traj_vars_temp(0, j)), init_traj(0, j)), sco::EQ); + } + } + + // Apply constraint to each fixed dof to its initial value for all timesteps (freeze that column) + if (!bi.dofs_fixed.empty()) + { + for (const int& dof_ind : bi.dofs_fixed) + { + for (int i = 1; i < prob->GetNumSteps(); ++i) + { + matrix_traj_vars_temp = prob->GetVars(); + prob->addLinearConstraint( + sco::exprSub(sco::AffExpr(matrix_traj_vars_temp(i, dof_ind)), sco::AffExpr(init_traj(0, dof_ind))), + sco::EQ); + } + } + } + + for (const TermInfoPtr& ci : pci.cost_infos) + { + ci->addObjectiveTerms(*prob); + } + + for (const TermInfoPtr& ci : pci.cnt_infos) + { + ci->addObjectiveTerms(*prob); + } + return prob; +} + +CartPoseTermInfo::CartPoseTermInfo() : TermInfo(TT_COST | TT_CNT) +{ + pos_coeffs = Eigen::Vector3d::Ones(); + rot_coeffs = Eigen::Vector3d::Ones(); + tcp.setIdentity(); +} + +void CartPoseTermInfo::addObjectiveTerms(TrajOptProblem& prob) +{ + unsigned int n_dof = prob.GetActiveGroupNumDOF(); + + Eigen::Isometry3d input_pose; + Eigen::Quaterniond q(wxyz(0), wxyz(1), wxyz(2), wxyz(3)); + input_pose.linear() = q.matrix(); + input_pose.translation() = xyz; + + if (term_type == (TT_COST | TT_USE_TIME)) + { + ROS_ERROR("Use time version of this term has not been defined."); + } + else if (term_type == (TT_CNT | TT_USE_TIME)) + { + ROS_ERROR("Use time version of this term has not been defined."); + } + else if ((term_type & TT_COST) && ~(term_type | ~TT_USE_TIME)) + { + sco::VectorOfVectorPtr f(new CartPoseErrCalculator(input_pose, prob.GetPlanningScene(), link, tcp)); + prob.addCost(sco::CostPtr(new sco::CostFromErrFunc(f, prob.GetVarRow(timestep, 0, n_dof), + concatVector(rot_coeffs, pos_coeffs), sco::ABS, name))); + } + else if ((term_type & TT_CNT) && ~(term_type | ~TT_USE_TIME)) + { + sco::VectorOfVectorPtr f(new CartPoseErrCalculator(input_pose, prob.GetPlanningScene(), link, tcp)); + prob.addConstraint(sco::ConstraintPtr(new sco::ConstraintFromErrFunc( + f, prob.GetVarRow(timestep, 0, n_dof), concatVector(rot_coeffs, pos_coeffs), sco::EQ, name))); + } + else + { + ROS_WARN("CartPoseTermInfo does not have a valid term_type defined. No cost/constraint applied"); + } +} + +void JointPoseTermInfo::addObjectiveTerms(TrajOptProblem& prob) +{ + unsigned int n_dof = prob.GetActiveGroupNumDOF(); + + // If optional parameter not given, set to default + if (coeffs.empty()) + coeffs = trajopt::DblVec(n_dof, 1); + if (upper_tols.empty()) + upper_tols = trajopt::DblVec(n_dof, 0); + if (lower_tols.empty()) + lower_tols = trajopt::DblVec(n_dof, 0); + if (last_step <= -1) + last_step = prob.GetNumSteps() - 1; + + // Check time step is valid + if ((prob.GetNumSteps() - 1) <= first_step) + first_step = prob.GetNumSteps() - 1; + if ((prob.GetNumSteps() - 1) <= last_step) + last_step = prob.GetNumSteps() - 1; + // if (last_step == first_step) + // last_step += 1; + if (last_step < first_step) + { + int tmp = first_step; + first_step = last_step; + last_step = tmp; + ROS_WARN("Last time step for JointPosTerm comes before first step. Reversing them."); + } + if (last_step == -1) // last_step not set + last_step = first_step; + + // Check if parameters are the correct size. + checkParameterSize(coeffs, n_dof, "JointPoseTermInfo coeffs", true); + checkParameterSize(targets, n_dof, "JointPoseTermInfo targets", true); + checkParameterSize(upper_tols, n_dof, "JointPoseTermInfo upper_tols", true); + checkParameterSize(lower_tols, n_dof, "JointPoseTermInfo lower_tols", true); + + // Check if tolerances are all zeros + bool is_upper_zeros = + std::all_of(upper_tols.begin(), upper_tols.end(), [](double i) { return util::doubleEquals(i, 0.); }); + bool is_lower_zeros = + std::all_of(lower_tols.begin(), lower_tols.end(), [](double i) { return util::doubleEquals(i, 0.); }); + + // Get vars associated with joints + trajopt::VarArray vars = prob.GetVars(); + trajopt::VarArray joint_vars = vars.block(0, 0, vars.rows(), static_cast(n_dof)); + if (prob.GetHasTime()) + ROS_INFO("JointPoseTermInfo does not differ based on setting of TT_USE_TIME"); + + if (term_type & TT_COST) + { + // If the tolerances are 0, an equality cost is set. Otherwise it's a hinged "inequality" cost + if (is_upper_zeros && is_lower_zeros) + { + prob.addCost(sco::CostPtr(new trajopt::JointPosEqCost(joint_vars, util::toVectorXd(coeffs), + util::toVectorXd(targets), first_step, last_step))); + prob.getCosts().back()->setName(name); + } + else + { + prob.addCost(sco::CostPtr(new trajopt::JointPosIneqCost(joint_vars, util::toVectorXd(coeffs), + util::toVectorXd(targets), util::toVectorXd(upper_tols), + util::toVectorXd(lower_tols), first_step, last_step))); + prob.getCosts().back()->setName(name); + } + } + else if (term_type & TT_CNT) + { + // If the tolerances are 0, an equality cnt is set. Otherwise it's an inequality constraint + if (is_upper_zeros && is_lower_zeros) + { + prob.addConstraint(sco::ConstraintPtr(new trajopt::JointPosEqConstraint( + joint_vars, util::toVectorXd(coeffs), util::toVectorXd(targets), first_step, last_step))); + prob.getConstraints().back()->setName(name); + } + else + { + prob.addConstraint(sco::ConstraintPtr(new trajopt::JointPosIneqConstraint( + joint_vars, util::toVectorXd(coeffs), util::toVectorXd(targets), util::toVectorXd(upper_tols), + util::toVectorXd(lower_tols), first_step, last_step))); + prob.getConstraints().back()->setName(name); + } + } + else + { + ROS_WARN("JointPosTermInfo does not have a valid term_type defined. No cost/constraint applied"); + } +} + +void JointVelTermInfo::addObjectiveTerms(TrajOptProblem& prob) +{ + unsigned int n_dof = prob.GetNumDOF(); + + // If optional parameter not given, set to default + if (coeffs.empty()) + coeffs = trajopt::DblVec(n_dof, 1); + if (upper_tols.empty()) + upper_tols = trajopt::DblVec(n_dof, 0); + if (lower_tols.empty()) + lower_tols = trajopt::DblVec(n_dof, 0); + if (last_step <= -1) + last_step = prob.GetNumSteps() - 1; + + // If only one time step is desired, calculate velocity with next step (2 steps are needed for 1 velocity calculation) + if ((prob.GetNumSteps() - 2) <= first_step) + first_step = prob.GetNumSteps() - 2; + if ((prob.GetNumSteps() - 1) <= last_step) + last_step = prob.GetNumSteps() - 1; + if (last_step == first_step) + last_step += 1; + if (last_step < first_step) + { + int tmp = first_step; + first_step = last_step; + last_step = tmp; + ROS_WARN("Last time step for JointVelTerm comes before first step. Reversing them."); + } + + // Check if parameters are the correct size. + checkParameterSize(coeffs, n_dof, "JointVelTermInfo coeffs", true); + checkParameterSize(targets, n_dof, "JointVelTermInfo targets", true); + checkParameterSize(upper_tols, n_dof, "JointVelTermInfo upper_tols", true); + checkParameterSize(lower_tols, n_dof, "JointVelTermInfo lower_tols", true); + assert(last_step > first_step); + assert(first_step >= 0); + + // Check if tolerances are all zeros + bool is_upper_zeros = + std::all_of(upper_tols.begin(), upper_tols.end(), [](double i) { return util::doubleEquals(i, 0.); }); + bool is_lower_zeros = + std::all_of(lower_tols.begin(), lower_tols.end(), [](double i) { return util::doubleEquals(i, 0.); }); + + // Get vars associated with joints + trajopt::VarArray vars = prob.GetVars(); + trajopt::VarArray joint_vars = vars.block(0, 0, vars.rows(), static_cast(n_dof)); + + if (term_type == (TT_COST | TT_USE_TIME)) + { + unsigned num_vels = last_step - first_step; + + // Apply seperate cost to each joint b/c that is how the error function is currently written + for (size_t j = 0; j < n_dof; j++) + { + // Get a vector of a single column of vars + sco::VarVector joint_vars_vec = joint_vars.cblock(first_step, j, last_step - first_step + 1); + sco::VarVector time_vars_vec = vars.cblock(first_step, vars.cols() - 1, last_step - first_step + 1); + + // If the tolerances are 0, an equality cost is set + if (is_upper_zeros && is_lower_zeros) + { + trajopt::DblVec single_jnt_coeffs = trajopt::DblVec(num_vels * 2, coeffs[j]); + prob.addCost(sco::CostPtr(new sco::CostFromErrFunc( + sco::VectorOfVectorPtr(new JointVelErrCalculator(targets[j], upper_tols[j], lower_tols[j])), + sco::MatrixOfVectorPtr(new JointVelJacobianCalculator()), concatVector(joint_vars_vec, time_vars_vec), + util::toVectorXd(single_jnt_coeffs), sco::SQUARED, name + "_j" + std::to_string(j)))); + } + // Otherwise it's a hinged "inequality" cost + else + { + trajopt::DblVec single_jnt_coeffs = trajopt::DblVec(num_vels * 2, coeffs[j]); + prob.addCost(sco::CostPtr(new sco::CostFromErrFunc( + sco::VectorOfVectorPtr(new JointVelErrCalculator(targets[j], upper_tols[j], lower_tols[j])), + sco::MatrixOfVectorPtr(new JointVelJacobianCalculator()), concatVector(joint_vars_vec, time_vars_vec), + util::toVectorXd(single_jnt_coeffs), sco::HINGE, name + "_j" + std::to_string(j)))); + } + } + } + else if (term_type == (TT_CNT | TT_USE_TIME)) + { + unsigned num_vels = last_step - first_step; + + // Apply seperate cnt to each joint b/c that is how the error function is currently written + for (size_t j = 0; j < n_dof; j++) + { + // Get a vector of a single column of vars + sco::VarVector joint_vars_vec = joint_vars.cblock(first_step, j, last_step - first_step + 1); + sco::VarVector time_vars_vec = vars.cblock(first_step, vars.cols() - 1, last_step - first_step + 1); + + // If the tolerances are 0, an equality cnt is set + if (is_upper_zeros && is_lower_zeros) + { + trajopt::DblVec single_jnt_coeffs = trajopt::DblVec(num_vels * 2, coeffs[j]); + prob.addConstraint(sco::ConstraintPtr(new sco::ConstraintFromErrFunc( + sco::VectorOfVectorPtr(new JointVelErrCalculator(targets[j], upper_tols[j], lower_tols[j])), + sco::MatrixOfVectorPtr(new JointVelJacobianCalculator()), concatVector(joint_vars_vec, time_vars_vec), + util::toVectorXd(single_jnt_coeffs), sco::EQ, name + "_j" + std::to_string(j)))); + } + // Otherwise it's a hinged "inequality" constraint + else + { + trajopt::DblVec single_jnt_coeffs = trajopt::DblVec(num_vels * 2, coeffs[j]); + prob.addConstraint(sco::ConstraintPtr(new sco::ConstraintFromErrFunc( + sco::VectorOfVectorPtr(new JointVelErrCalculator(targets[j], upper_tols[j], lower_tols[j])), + sco::MatrixOfVectorPtr(new JointVelJacobianCalculator()), concatVector(joint_vars_vec, time_vars_vec), + util::toVectorXd(single_jnt_coeffs), sco::INEQ, name + "_j" + std::to_string(j)))); + } + } + } + else if ((term_type & TT_COST) && ~(term_type | ~TT_USE_TIME)) + { + // If the tolerances are 0, an equality cost is set. Otherwise it's a hinged "inequality" cost + if (is_upper_zeros && is_lower_zeros) + { + prob.addCost(sco::CostPtr(new trajopt::JointVelEqCost(joint_vars, util::toVectorXd(coeffs), + util::toVectorXd(targets), first_step, last_step))); + prob.getCosts().back()->setName(name); + } + else + { + prob.addCost(sco::CostPtr(new trajopt::JointVelIneqCost(joint_vars, util::toVectorXd(coeffs), + util::toVectorXd(targets), util::toVectorXd(upper_tols), + util::toVectorXd(lower_tols), first_step, last_step))); + prob.getCosts().back()->setName(name); + } + } + else if ((term_type & TT_CNT) && ~(term_type | ~TT_USE_TIME)) + { + // If the tolerances are 0, an equality cnt is set. Otherwise it's an inequality constraint + if (is_upper_zeros && is_lower_zeros) + { + prob.addConstraint(sco::ConstraintPtr(new trajopt::JointVelEqConstraint( + joint_vars, util::toVectorXd(coeffs), util::toVectorXd(targets), first_step, last_step))); + prob.getConstraints().back()->setName(name); + } + else + { + prob.addConstraint(sco::ConstraintPtr(new trajopt::JointVelIneqConstraint( + joint_vars, util::toVectorXd(coeffs), util::toVectorXd(targets), util::toVectorXd(upper_tols), + util::toVectorXd(lower_tols), first_step, last_step))); + prob.getConstraints().back()->setName(name); + } + } + else + { + ROS_WARN("JointVelTermInfo does not have a valid term_type defined. No cost/constraint applied"); + } +} + +void generateInitialTrajectory(const ProblemInfo& pci, const std::vector& current_joint_values, + trajopt::TrajArray& init_traj) +{ + Eigen::VectorXd current_pos(current_joint_values.size()); + for (std::size_t joint_index = 0; joint_index < current_joint_values.size(); ++joint_index) + { + current_pos(joint_index) = current_joint_values[joint_index]; + } + + InitInfo init_info = pci.init_info; + + // initialize based on type specified + if (init_info.type == InitInfo::STATIONARY) + { + // Initializes all joint values to the initial value (the current value in scene) + init_traj = current_pos.transpose().replicate(pci.basic_info.n_steps, 1); + } + else if (init_info.type == InitInfo::JOINT_INTERPOLATED) + { + // Linearly interpolates between initial value (current values in the scene) and the joint position specified in + // InitInfo.data + Eigen::VectorXd end_pos = init_info.data; + init_traj.resize(pci.basic_info.n_steps, end_pos.rows()); + for (int dof_index = 0; dof_index < current_pos.rows(); ++dof_index) + { + init_traj.col(dof_index) = + Eigen::VectorXd::LinSpaced(pci.basic_info.n_steps, current_pos(dof_index), end_pos(dof_index)); + } + } + else if (init_info.type == InitInfo::GIVEN_TRAJ) + { + // Initializes the matrix to a given trajectory + init_traj = init_info.data; + } + else + { + PRINT_AND_THROW("Init Info did not have a valid type. Valid types are " + "STATIONARY, JOINT_INTERPOLATED, or GIVEN_TRAJ"); + } + + // Currently all trajectories are generated without time then appended here + if (pci.basic_info.use_time) + { + // add on time (default to 1 sec) + init_traj.conservativeResize(Eigen::NoChange_t(), init_traj.cols() + 1); + + init_traj.block(0, init_traj.cols() - 1, init_traj.rows(), 1) = + Eigen::VectorXd::Constant(init_traj.rows(), init_info.dt); + } +} +} diff --git a/moveit_planners/trajopt/trajopt/src/trajectory_costs.cpp b/moveit_planners/trajopt/trajopt/src/trajectory_costs.cpp new file mode 100644 index 0000000000..b12fcf925b --- /dev/null +++ b/moveit_planners/trajopt/trajopt/src/trajectory_costs.cpp @@ -0,0 +1,899 @@ +#include +TRAJOPT_IGNORE_WARNINGS_PUSH +#include +TRAJOPT_IGNORE_WARNINGS_POP + +#include +#include +#include + +#include "trajopt/trajectory_costs.hpp" + +namespace +{ +/** @brief Returns the difference between each row of a matrixXd and the row before */ +static Eigen::MatrixXd diffAxis0(const Eigen::MatrixXd& in) +{ + return in.middleRows(1, in.rows() - 1) - in.middleRows(0, in.rows() - 1); +} +} // namespace + +namespace trajopt +{ +//////////// Joint cost functions ///////////////// + +//////////////////// Position ///////////////////// +JointPosEqCost::JointPosEqCost(const VarArray& vars, const Eigen::VectorXd& coeffs, const Eigen::VectorXd& targets, + int& first_step, int& last_step) + : Cost("JointPosEq"), vars_(vars), coeffs_(coeffs), targets_(targets), first_step_(first_step), last_step_(last_step) +{ + for (int i = first_step_; i <= last_step_; ++i) + { + for (int j = 0; j < vars.cols(); ++j) + { + // pos = x1 - targ + sco::AffExpr pos; + sco::exprInc(pos, sco::exprMult(vars(i, j), 1)); + sco::exprDec(pos, targets_[j]); + // expr_ = coeff * vel^2 + sco::exprInc(expr_, sco::exprMult(sco::exprSquare(pos), coeffs_[j])); + } + } +} +double JointPosEqCost::value(const DblVec& xvec) +{ + // Convert vector from optimization to trajectory + Eigen::MatrixXd traj = (getTraj(xvec, vars_)); + // Takes diff b/n the subsequent rows and subtract each row by the targets_ vector + Eigen::MatrixXd diff = + (traj.block(first_step_, 0, last_step_ - first_step_ + 1, traj.cols())).rowwise() - targets_.transpose(); + // Element-wise square it, multiply it by a diagonal matrix of coefficients, and sums output + return (diff.array().square().matrix() * coeffs_.asDiagonal()).sum(); +} +sco::ConvexObjectivePtr JointPosEqCost::convex(const DblVec& /*x*/, sco::Model* model) +{ + sco::ConvexObjectivePtr out(new sco::ConvexObjective(model)); + out->addQuadExpr(expr_); + return out; +} + +JointPosIneqCost::JointPosIneqCost(const VarArray& vars, const Eigen::VectorXd& coeffs, const Eigen::VectorXd& targets, + const Eigen::VectorXd& upper_tols, const Eigen::VectorXd& lower_tols, + int& first_step, int& last_step) + : Cost("JointPosIneq") + , vars_(vars) + , coeffs_(coeffs) + , upper_tols_(upper_tols) + , lower_tols_(lower_tols) + , targets_(targets) + , first_step_(first_step) + , last_step_(last_step) +{ + for (int i = first_step_; i <= last_step_; ++i) + { + for (int j = 0; j < vars.cols(); ++j) + { + sco::AffExpr expr; + sco::AffExpr expr_neg; + // pos = x1 - targ + sco::AffExpr pos; + sco::exprInc(pos, sco::exprMult(vars(i, j), 1)); + sco::exprDec(pos, targets_[j]); + sco::exprInc(expr, upper_tols_[j]); // expr_ = upper_tol + + // Form upper limit expr = - (upper_tol-(vel-targ)) + sco::exprDec(expr, pos); // expr = upper_tol_- (vel - targets_) + sco::exprScale(expr, -coeffs[j]); // expr = - (upper_tol_- (vel - targets_)) * coeffs_ + expr_vec_.push_back(expr); + + // Form upper limit expr = - (upper_tol-(vel-targ)) + sco::exprDec(expr_neg, pos); // expr = lower_tol_- (vel - targets_) + sco::exprScale(expr_neg, coeffs[j]); // expr = (lower_tol_- (vel - targets_)) * coeffs_ + expr_vec_.push_back(expr_neg); + } + } +} + +double JointPosIneqCost::value(const DblVec& xvec) +{ + // Convert vector from optimization to trajectory + Eigen::MatrixXd traj = getTraj(xvec, vars_); + // Takes diff b/n the subsequent rows to get velocity + Eigen::MatrixXd pos = traj.block(first_step_, 0, last_step_ - first_step_ + 1, traj.cols()); + // Subtract targets to center about 0 and then subtract from tolerance + Eigen::MatrixXd diff0 = (pos.rowwise() - targets_.transpose()); + Eigen::MatrixXd diff1 = (diff0.rowwise() - upper_tols_.transpose()) * coeffs_.asDiagonal(); + Eigen::MatrixXd diff2 = ((diff0 * -1).rowwise() + lower_tols_.transpose()) * coeffs_.asDiagonal(); + // Applies hinge, multiplies it by a diagonal matrix of coefficients, sums each corresponding value, and converts to + // vector + return diff1.cwiseMax(0).sum() + diff2.cwiseMax(0).sum(); +} + +sco::ConvexObjectivePtr JointPosIneqCost::convex(const DblVec& /*x*/, sco::Model* model) +{ + sco::ConvexObjectivePtr out(new sco::ConvexObjective(model)); + // Add hinge cost. Set the coefficient to 1 here since we include it in the AffExpr already + // This is necessary since we want a seperate coefficient per joint + for (sco::AffExpr& expr : expr_vec_) + { + out->addHinge(expr, 1); + } + return out; +} + +JointPosEqConstraint::JointPosEqConstraint(const VarArray& vars, const Eigen::VectorXd& coeffs, + const Eigen::VectorXd& targets, int& first_step, int& last_step) + : EqConstraint("JointPosEq") + , vars_(vars) + , coeffs_(coeffs) + , targets_(targets) + , first_step_(first_step) + , last_step_(last_step) +{ + for (int i = first_step_; i <= last_step_; ++i) + { + for (int j = 0; j < vars.cols(); ++j) + { + // pos = x1 - targ + sco::AffExpr pos; + sco::exprInc(pos, sco::exprMult(vars(i, j), 1)); + sco::exprDec(pos, targets_[j]); + // expr_ = coeff * vel - Not squared b/c QuadExpr cnt not yet supported (TODO) + expr_vec_.push_back(sco::exprMult(pos, coeffs_[j])); + } + } +} + +DblVec JointPosEqConstraint::value(const DblVec& xvec) +{ + // Convert vector from optimization to trajectory + Eigen::MatrixXd traj = getTraj(xvec, vars_); + // Takes diff b/n the subsequent rows and subtract each row by the targets_ vector + Eigen::MatrixXd diff = + (traj.block(first_step_, 0, last_step_ - first_step_ + 1, traj.cols())).rowwise() - targets_.transpose(); + // Squares it, multiplies it by a diagonal matrix of coefficients, and converts to vector + return util::toDblVec((diff.array().square()).matrix() * coeffs_.asDiagonal()); +} +sco::ConvexConstraintsPtr JointPosEqConstraint::convex(const DblVec& /*x*/, sco::Model* model) +{ + sco::ConvexConstraintsPtr out(new sco::ConvexConstraints(model)); + for (sco::AffExpr& expr : expr_vec_) + { + out->addEqCnt(expr); + } + return out; +} + +JointPosIneqConstraint::JointPosIneqConstraint(const VarArray& vars, const Eigen::VectorXd& coeffs, + const Eigen::VectorXd& targets, const Eigen::VectorXd& upper_tols, + const Eigen::VectorXd& lower_tols, int& first_step, int& last_step) + : IneqConstraint("JointPosIneq") + , vars_(vars) + , coeffs_(coeffs) + , upper_tols_(upper_tols) + , lower_tols_(lower_tols) + , targets_(targets) + , first_step_(first_step) + , last_step_(last_step) +{ + for (int i = first_step_; i <= last_step_; ++i) + { + for (int j = 0; j < vars.cols(); ++j) + { + sco::AffExpr expr; + sco::AffExpr expr_neg; + // pos = x1 - targ + sco::AffExpr pos; + sco::exprInc(pos, sco::exprMult(vars(i, j), 1)); + sco::exprDec(pos, targets_[j]); + sco::exprInc(expr, upper_tols_[j]); // expr_ = upper_tol + + // Form upper limit expr = - (upper_tol-(vel-targ)) + sco::exprDec(expr, pos); // expr = upper_tol_- (vel - targets_) + sco::exprScale(expr, -coeffs[j]); // expr = - (upper_tol_- (vel - targets_)) * coeffs_ + expr_vec_.push_back(expr); + + // Form lower limit expr = (upper_tol-(vel-targ)) + sco::exprDec(expr_neg, pos); // expr = lower_tol_- (vel - targets_) + sco::exprScale(expr_neg, coeffs[j]); // expr = (lower_tol_- (vel - targets_)) * coeffs_ + expr_vec_.push_back(expr_neg); + } + } +} + +DblVec JointPosIneqConstraint::value(const DblVec& xvec) +{ + // Convert vector from optimization to trajectory + Eigen::MatrixXd traj = getTraj(xvec, vars_); + // Takes diff b/n the subsequent rows to get velocity + Eigen::MatrixXd pos = diffAxis0(traj.block(first_step_, 0, last_step_ - first_step_ + 1, traj.cols())); + // Subtract targets to center about 0 and then subtract from tolerance + Eigen::MatrixXd diff0 = (pos.rowwise() - targets_.transpose()); + Eigen::MatrixXd diff1 = (diff0.rowwise() - upper_tols_.transpose()) * coeffs_.asDiagonal(); + Eigen::MatrixXd diff2 = ((diff0 * -1).rowwise() + lower_tols_.transpose()) * coeffs_.asDiagonal(); + // Applies hinge, multiplies it by a diagonal matrix of coefficients, sums each corresponding value, and converts to + // vector + Eigen::MatrixXd out(diff1.rows(), diff1.cols() + diff2.cols()); + out << diff1, diff2; + return util::toDblVec(out); +} + +sco::ConvexConstraintsPtr JointPosIneqConstraint::convex(const DblVec& /*x*/, sco::Model* model) +{ + sco::ConvexConstraintsPtr out(new sco::ConvexConstraints(model)); + // Add hinge cost. Set the coefficient to 1 here since we include it in the AffExpr already + // This is necessary since we want a seperate coefficient per joint + for (sco::AffExpr& expr : expr_vec_) + { + out->addIneqCnt(expr); + } + return out; +} + +//////////////////// Velocity ///////////////////// +JointVelEqCost::JointVelEqCost(const VarArray& vars, const Eigen::VectorXd& coeffs, const Eigen::VectorXd& targets, + int& first_step, int& last_step) + : Cost("JointVelEq"), vars_(vars), coeffs_(coeffs), targets_(targets), first_step_(first_step), last_step_(last_step) +{ + for (int i = first_step_; i <= last_step_ - 1; ++i) + { + for (int j = 0; j < vars.cols(); ++j) + { + // vel = (x2 - x1) - targ + sco::AffExpr vel; + sco::exprInc(vel, sco::exprMult(vars(i, j), -1)); + sco::exprInc(vel, sco::exprMult(vars(i + 1, j), 1)); + exprDec(vel, targets_[j]); + // expr_ = coeff * vel^2 + exprInc(expr_, exprMult(exprSquare(vel), coeffs_[j])); + } + } +} +double JointVelEqCost::value(const DblVec& xvec) +{ + // Convert vector from optimization to trajectory + Eigen::MatrixXd traj = (getTraj(xvec, vars_)); + // Takes diff b/n the subsequent rows and subtract each row by the targets_ vector + Eigen::MatrixXd diff = (diffAxis0(traj.block(first_step_, 0, last_step_ - first_step_ + 1, traj.cols()))).rowwise() - + targets_.transpose(); + // Element-wise square it, multiply it by a diagonal matrix of coefficients, and sums output + return (diff.array().square().matrix() * coeffs_.asDiagonal()).sum(); +} +sco::ConvexObjectivePtr JointVelEqCost::convex(const DblVec& /*x*/, sco::Model* model) +{ + sco::ConvexObjectivePtr out(new sco::ConvexObjective(model)); + out->addQuadExpr(expr_); + return out; +} + +JointVelIneqCost::JointVelIneqCost(const VarArray& vars, const Eigen::VectorXd& coeffs, const Eigen::VectorXd& targets, + const Eigen::VectorXd& upper_tols, const Eigen::VectorXd& lower_tols, + int& first_step, int& last_step) + : Cost("JointVelIneq") + , vars_(vars) + , coeffs_(coeffs) + , upper_tols_(upper_tols) + , lower_tols_(lower_tols) + , targets_(targets) + , first_step_(first_step) + , last_step_(last_step) +{ + for (int i = first_step_; i <= last_step_ - 1; ++i) + { + for (int j = 0; j < vars.cols(); ++j) + { + // vel = (x2 - x1) - targ + sco::AffExpr vel; + sco::AffExpr expr; + sco::AffExpr expr_neg; + sco::exprInc(vel, sco::exprMult(vars(i, j), -1)); + sco::exprInc(vel, sco::exprMult(vars(i + 1, j), 1)); + sco::exprDec(vel, targets_[j]); // offset to center about 0 + + // Form upper limit expr = - (upper_tol-(vel-targ)) + sco::exprInc(expr, upper_tols_[j]); // expr_ = upper_tol + sco::exprDec(expr, vel); // expr = upper_tol_- (vel - targets_) + sco::exprScale(expr, -coeffs[j]); // expr = - (upper_tol_- (vel - targets_)) * coeffs_ + expr_vec_.push_back(expr); + + // Form lower limit expr = (upper_tol-(vel-targ)) + sco::exprInc(expr_neg, lower_tols_[j]); // expr_ = lower_tol_ + sco::exprDec(expr_neg, vel); // expr = lower_tol_- (vel - targets_) + sco::exprScale(expr_neg, coeffs[j]); // expr = (lower_tol_- (vel - targets_)) * coeffs_ + expr_vec_.push_back(expr_neg); + } + } +} + +double JointVelIneqCost::value(const DblVec& xvec) +{ + // Convert vector from optimization to trajectory + Eigen::MatrixXd traj = getTraj(xvec, vars_); + // Takes diff b/n the subsequent rows to get velocity + Eigen::MatrixXd vel = diffAxis0(traj.block(first_step_, 0, last_step_ - first_step_ + 1, traj.cols())); + // Subtract targets_ to center about 0 and then subtract from tolerance + Eigen::MatrixXd diff0 = (vel.rowwise() - targets_.transpose()); + Eigen::MatrixXd diff1 = (diff0.rowwise() - upper_tols_.transpose()) * coeffs_.asDiagonal(); + Eigen::MatrixXd diff2 = ((diff0 * -1).rowwise() + lower_tols_.transpose()) * coeffs_.asDiagonal(); + // Applies hinge, multiplies it by a diagonal matrix of coefficients, sums each corresponding value, and converts to + // vector + return diff1.cwiseMax(0).sum() + diff2.cwiseMax(0).sum(); +} + +sco::ConvexObjectivePtr JointVelIneqCost::convex(const DblVec& /*x*/, sco::Model* model) +{ + sco::ConvexObjectivePtr out(new sco::ConvexObjective(model)); + // Add hinge cost. Set the coefficient to 1 here since we include it in the AffExpr already + // This is necessary since we want a seperate coefficient per joint + for (sco::AffExpr& expr : expr_vec_) + { + out->addHinge(expr, 1); + } + return out; +} + +JointVelEqConstraint::JointVelEqConstraint(const VarArray& vars, const Eigen::VectorXd& coeffs, + const Eigen::VectorXd& targets, int& first_step, int& last_step) + : EqConstraint("JointVelEq") + , vars_(vars) + , coeffs_(coeffs) + , targets_(targets) + , first_step_(first_step) + , last_step_(last_step) +{ + for (int i = first_step_; i <= last_step_ - 1; ++i) + { + for (int j = 0; j < vars.cols(); ++j) + { + // vel = (x2 - x1) - targ + sco::AffExpr vel; + sco::exprInc(vel, sco::exprMult(vars(i, j), -1)); + sco::exprInc(vel, sco::exprMult(vars(i + 1, j), 1)); + sco::exprDec(vel, targets_[j]); + // expr_ = coeff * vel - Not squared b/c QuadExpr cnt not yet supported (TODO) + expr_vec_.push_back(sco::exprMult(vel, coeffs_[j])); + } + } +} + +DblVec JointVelEqConstraint::value(const DblVec& xvec) +{ + // Convert vector from optimization to trajectory + Eigen::MatrixXd traj = getTraj(xvec, vars_); + // Takes diff b/n the subsequent rows and subtract each row by the targets_ vector + Eigen::MatrixXd diff = (diffAxis0(traj.block(first_step_, 0, last_step_ - first_step_ + 1, traj.cols()))).rowwise() - + targets_.transpose(); + // Squares it, multiplies it by a diagonal matrix of coefficients, and converts to vector + return util::toDblVec((diff.array().square()).matrix() * coeffs_.asDiagonal()); +} +sco::ConvexConstraintsPtr JointVelEqConstraint::convex(const DblVec& /*x*/, sco::Model* model) +{ + sco::ConvexConstraintsPtr out(new sco::ConvexConstraints(model)); + for (sco::AffExpr& expr : expr_vec_) + { + out->addEqCnt(expr); + } + return out; +} + +JointVelIneqConstraint::JointVelIneqConstraint(const VarArray& vars, const Eigen::VectorXd& coeffs, + const Eigen::VectorXd& targets, const Eigen::VectorXd& upper_tols, + const Eigen::VectorXd& lower_tols, int& first_step, int& last_step) + : IneqConstraint("JointVelIneq") + , vars_(vars) + , coeffs_(coeffs) + , upper_tols_(upper_tols) + , lower_tols_(lower_tols) + , targets_(targets) + , first_step_(first_step) + , last_step_(last_step) +{ + for (int i = first_step_; i <= last_step_ - 1; ++i) + { + for (int j = 0; j < vars.cols(); ++j) + { + // vel = (x2 - x1) - targ + sco::AffExpr vel; + sco::AffExpr expr; + sco::AffExpr expr_neg; + sco::exprInc(vel, sco::exprMult(vars(i, j), -1)); + sco::exprInc(vel, sco::exprMult(vars(i + 1, j), 1)); + sco::exprDec(vel, targets_[j]); // offset to center about 0 + + // Form upper limit expr = - (upper_tol-(vel-targ)) + sco::exprInc(expr, upper_tols_[j]); // expr_ = upper_tol + sco::exprDec(expr, vel); // expr = upper_tol_- (vel - targets_) + sco::exprScale(expr, -coeffs[j]); // expr = - (upper_tol_- (vel - targets_)) * coeffs_ + expr_vec_.push_back(expr); + + // Form lower limit expr = (lower_tol-(vel-targ)) + sco::exprInc(expr_neg, lower_tols_[j]); // expr_ = lower_tol_ + sco::exprDec(expr_neg, vel); // expr = lower_tol_- (vel - targets_) + sco::exprScale(expr_neg, coeffs[j]); // expr = (lower_tol_- (vel - targets_)) * coeffs_ + expr_vec_.push_back(expr_neg); + } + } +} + +DblVec JointVelIneqConstraint::value(const DblVec& xvec) +{ + // Convert vector from optimization to trajectory + Eigen::MatrixXd traj = getTraj(xvec, vars_); + // Takes diff b/n the subsequent rows to get velocity + Eigen::MatrixXd vel = diffAxis0(traj.block(first_step_, 0, last_step_ - first_step_ + 1, traj.cols())); + // Subtract targets_ to center about 0 and then subtract from tolerance + Eigen::MatrixXd diff0 = (vel.rowwise() - targets_.transpose()); + Eigen::MatrixXd diff1 = (diff0.rowwise() - upper_tols_.transpose()) * coeffs_.asDiagonal(); + Eigen::MatrixXd diff2 = ((diff0 * -1).rowwise() + lower_tols_.transpose()) * coeffs_.asDiagonal(); + // Applies hinge, multiplies it by a diagonal matrix of coefficients, sums each corresponding value, and converts to + // vector + Eigen::MatrixXd out(diff1.rows(), diff1.cols() + diff2.cols()); + out << diff1, diff2; + return util::toDblVec(out.cwiseMax(0)); +} + +sco::ConvexConstraintsPtr JointVelIneqConstraint::convex(const DblVec& /*x*/, sco::Model* model) +{ + sco::ConvexConstraintsPtr out(new sco::ConvexConstraints(model)); + // Add hinge cost. Set the coefficient to 1 here since we include it in the AffExpr already + // This is necessary since we want a seperate coefficient per joint + for (sco::AffExpr& expr : expr_vec_) + { + out->addIneqCnt(expr); + } + return out; +} + +//////////////////// Acceleration ///////////////////// +JointAccEqCost::JointAccEqCost(const VarArray& vars, const Eigen::VectorXd& coeffs, const Eigen::VectorXd& targets, + int& first_step, int& last_step) + : Cost("JointAccEq"), vars_(vars), coeffs_(coeffs), targets_(targets), first_step_(first_step), last_step_(last_step) +{ + for (int i = first_step_; i <= last_step_ - 2; ++i) + { + for (int j = 0; j < vars.cols(); ++j) + { + // acc = (x3 - 2*x2 + x1) - targ + sco::AffExpr acc; + sco::exprInc(acc, sco::exprMult(vars(i, j), 1.0)); + sco::exprInc(acc, sco::exprMult(vars(i + 1, j), -2.0)); + sco::exprInc(acc, sco::exprMult(vars(i + 2, j), 1.0)); + + sco::exprDec(acc, targets_[j]); + // expr_ = coeff * acc^2 + sco::exprInc(expr_, sco::exprMult(sco::exprSquare(acc), coeffs_[j])); + } + } +} +double JointAccEqCost::value(const DblVec& xvec) +{ + // Convert vector from optimization to trajectory + Eigen::MatrixXd traj = (getTraj(xvec, vars_)); + // Takes diff b/n the subsequent rows and subtract each row by the targets_ vector + Eigen::MatrixXd diff = + (diffAxis0(diffAxis0(traj.block(first_step_, 0, last_step_ - first_step_ + 1, traj.cols())))).rowwise() - + targets_.transpose(); + // Element-wise square it, multiply it by a diagonal matrix of coefficients, and sums output + return (diff.array().square().matrix() * coeffs_.asDiagonal()).sum(); +} +sco::ConvexObjectivePtr JointAccEqCost::convex(const DblVec& /*x*/, sco::Model* model) +{ + sco::ConvexObjectivePtr out(new sco::ConvexObjective(model)); + out->addQuadExpr(expr_); + return out; +} + +JointAccIneqCost::JointAccIneqCost(const VarArray& vars, const Eigen::VectorXd& coeffs, const Eigen::VectorXd& targets, + const Eigen::VectorXd& upper_tols, const Eigen::VectorXd& lower_tols, + int& first_step, int& last_step) + : Cost("JointAccIneq") + , vars_(vars) + , coeffs_(coeffs) + , upper_tols_(upper_tols) + , lower_tols_(lower_tols) + , targets_(targets) + , first_step_(first_step) + , last_step_(last_step) +{ + for (int i = first_step_; i <= last_step_ - 2; ++i) + { + for (int j = 0; j < vars.cols(); ++j) + { + // acc = (x3 - 2*x2 + x1) - targ + sco::AffExpr acc; + sco::AffExpr expr; + sco::AffExpr expr_neg; + sco::exprInc(acc, sco::exprMult(vars(i, j), 1.0)); + sco::exprInc(acc, sco::exprMult(vars(i + 1, j), -2.0)); + sco::exprInc(acc, sco::exprMult(vars(i + 2, j), 1.0)); + sco::exprDec(acc, targets_[j]); // offset to center about 0 + + // Form upper limit expr = - (upper_tol-(acc-targ)) + sco::exprInc(expr, upper_tols_[j]); // expr_ = upper_tol + sco::exprDec(expr, acc); // expr = upper_tol_- (vel - targets_) + sco::exprScale(expr, -coeffs[j]); // expr = - (upper_tol_- (vel - targets_)) * coeffs_ + expr_vec_.push_back(expr); + + // Form lower limit expr = (lower_tol-(acc-targ)) + sco::exprInc(expr_neg, lower_tols_[j]); // expr_ = lower_tol_ + sco::exprDec(expr_neg, acc); // expr = lower_tol_- (vel - targets_) + sco::exprScale(expr_neg, coeffs[j]); // expr = (lower_tol_- (vel - targets_)) * coeffs_ + expr_vec_.push_back(expr_neg); + } + } +} + +double JointAccIneqCost::value(const DblVec& xvec) +{ + // Convert vector from optimization to trajectory + Eigen::MatrixXd traj = getTraj(xvec, vars_); + // Takes diff b/n the subsequent rows to get velocity + Eigen::MatrixXd acc = diffAxis0(diffAxis0(traj.block(first_step_, 0, last_step_ - first_step_ + 1, traj.cols()))); + // Subtract targets_ to center about 0 and then subtract from tolerance + Eigen::MatrixXd diff0 = (acc.rowwise() - targets_.transpose()); + Eigen::MatrixXd diff1 = (diff0.rowwise() - upper_tols_.transpose()) * coeffs_.asDiagonal(); + Eigen::MatrixXd diff2 = ((diff0 * -1).rowwise() + lower_tols_.transpose()) * coeffs_.asDiagonal(); + // Applies hinge, multiplies it by a diagonal matrix of coefficients, sums each corresponding value, and converts to + // vector + return diff1.cwiseMax(0).sum() + diff2.cwiseMax(0).sum(); +} + +sco::ConvexObjectivePtr JointAccIneqCost::convex(const DblVec& /*x*/, sco::Model* model) +{ + sco::ConvexObjectivePtr out(new sco::ConvexObjective(model)); + // Add hinge cost. Set the coefficient to 1 here since we include it in the AffExpr already + // This is necessary since we want a seperate coefficient per joint + for (sco::AffExpr& expr : expr_vec_) + { + out->addHinge(expr, 1); + } + return out; +} + +JointAccEqConstraint::JointAccEqConstraint(const VarArray& vars, const Eigen::VectorXd& coeffs, + const Eigen::VectorXd& targets, int& first_step, int& last_step) + : EqConstraint("JointAccEq") + , vars_(vars) + , coeffs_(coeffs) + , targets_(targets) + , first_step_(first_step) + , last_step_(last_step) +{ + for (int i = first_step_; i <= last_step_ - 2; ++i) + { + for (int j = 0; j < vars.cols(); ++j) + { + // acc = (x3 - 2*x2 + x1) - targ + sco::AffExpr acc; + sco::exprInc(acc, sco::exprMult(vars(i, j), 1.0)); + sco::exprInc(acc, sco::exprMult(vars(i + 1, j), -2.0)); + sco::exprInc(acc, sco::exprMult(vars(i + 2, j), 1.0)); + + sco::exprDec(acc, targets_[j]); // offset to center about 0 + // expr_ = coeff * vel - Not squared b/c QuadExpr cnt not yet supported (TODO) + expr_vec_.push_back(sco::exprMult(acc, coeffs_[j])); + } + } +} + +DblVec JointAccEqConstraint::value(const DblVec& xvec) +{ + // Convert vector from optimization to trajectory + Eigen::MatrixXd traj = getTraj(xvec, vars_); + // Takes diff b/n the subsequent rows and subtract each row by the targets_ vector + Eigen::MatrixXd diff = + (diffAxis0(diffAxis0(traj.block(first_step_, 0, last_step_ - first_step_ + 1, traj.cols())))).rowwise() - + targets_.transpose(); + // Squares it, multiplies it by a diagonal matrix of coefficients, and converts to vector + return util::toDblVec((diff.array().square()).matrix() * coeffs_.asDiagonal()); +} +sco::ConvexConstraintsPtr JointAccEqConstraint::convex(const DblVec& /*x*/, sco::Model* model) +{ + sco::ConvexConstraintsPtr out(new sco::ConvexConstraints(model)); + for (sco::AffExpr& expr : expr_vec_) + { + out->addEqCnt(expr); + } + return out; +} + +JointAccIneqConstraint::JointAccIneqConstraint(const VarArray& vars, const Eigen::VectorXd& coeffs, + const Eigen::VectorXd& targets, const Eigen::VectorXd& upper_tols, + const Eigen::VectorXd& lower_tols, int& first_step, int& last_step) + : IneqConstraint("JointAccIneq") + , vars_(vars) + , coeffs_(coeffs) + , upper_tols_(upper_tols) + , lower_tols_(lower_tols) + , targets_(targets) + , first_step_(first_step) + , last_step_(last_step) +{ + // Form upper limit expr = - (upper_tol-(vel-targ)) + for (int i = first_step_; i <= last_step_ - 2; ++i) + { + for (int j = 0; j < vars.cols(); ++j) + { + // acc = (x3 - 2*x2 + x1) - targ + sco::AffExpr acc; + sco::AffExpr expr; + sco::AffExpr expr_neg; + sco::exprInc(acc, sco::exprMult(vars(i, j), 1.0)); + sco::exprInc(acc, sco::exprMult(vars(i + 1, j), -2.0)); + sco::exprInc(acc, sco::exprMult(vars(i + 2, j), 1.0)); + sco::exprDec(acc, targets_[j]); // offset to center about 0 + + // Form upper limit expr = - (upper_tol-(vel-targ)) + sco::exprInc(expr, upper_tols_[j]); // expr_ = upper_tol + sco::exprDec(expr, acc); // expr = upper_tol_- (vel - targets_) + sco::exprScale(expr, -coeffs[j]); // expr = - (upper_tol_- (vel - targets_)) * coeffs_ + expr_vec_.push_back(expr); + + // Form upper limit expr = - (upper_tol-(vel-targ)) + sco::exprInc(expr_neg, lower_tols_[j]); // expr_ = lower_tol_ + sco::exprDec(expr_neg, acc); // expr = lower_tol_- (vel - targets_) + sco::exprScale(expr_neg, coeffs[j]); // expr = (lower_tol_- (vel - targets_)) * coeffs_ + expr_vec_.push_back(expr_neg); + } + } +} + +DblVec JointAccIneqConstraint::value(const DblVec& xvec) +{ + // Convert vector from optimization to trajectory + Eigen::MatrixXd traj = getTraj(xvec, vars_); + // Takes diff b/n the subsequent rows to get velocity + Eigen::MatrixXd acc = diffAxis0(diffAxis0(traj.block(first_step_, 0, last_step_ - first_step_ + 1, traj.cols()))); + // Subtract targets_ to center about 0 and then subtract from tolerance + Eigen::MatrixXd diff0 = (acc.rowwise() - targets_.transpose()); + Eigen::MatrixXd diff1 = (diff0.rowwise() - upper_tols_.transpose()) * coeffs_.asDiagonal(); + Eigen::MatrixXd diff2 = ((diff0 * -1).rowwise() + lower_tols_.transpose()) * coeffs_.asDiagonal(); + // Applies hinge, multiplies it by a diagonal matrix of coefficients, sums each corresponding value, and converts to + // vector + Eigen::MatrixXd out(diff1.rows(), diff1.cols() + diff2.cols()); + out << diff1, diff2; + return util::toDblVec(out.cwiseMax(0)); +} + +sco::ConvexConstraintsPtr JointAccIneqConstraint::convex(const DblVec& /*x*/, sco::Model* model) +{ + sco::ConvexConstraintsPtr out(new sco::ConvexConstraints(model)); + // Add hinge cost. Set the coefficient to 1 here since we include it in the AffExpr already + // This is necessary since we want a seperate coefficient per joint + for (sco::AffExpr& expr : expr_vec_) + { + out->addIneqCnt(expr); + } + return out; +} + +//////////////////// Jerk ///////////////////// +JointJerkEqCost::JointJerkEqCost(const VarArray& vars, const Eigen::VectorXd& coeffs, const Eigen::VectorXd& targets, + int& first_step, int& last_step) + : Cost("JointJerkEq"), vars_(vars), coeffs_(coeffs), targets_(targets), first_step_(first_step), last_step_(last_step) +{ + for (int i = first_step_; i <= last_step_ - 4; ++i) + { + for (int j = 0; j < vars.cols(); ++j) + { + sco::AffExpr jerk; + sco::exprInc(jerk, sco::exprMult(vars(i, j), -1.0 / 2.0)); + sco::exprInc(jerk, sco::exprMult(vars(i + 1, j), 1.0)); + sco::exprInc(jerk, sco::exprMult(vars(i + 2, j), 0.0)); + sco::exprInc(jerk, sco::exprMult(vars(i + 3, j), -1.0)); + sco::exprInc(jerk, sco::exprMult(vars(i + 4, j), 1.0 / 2.0)); + + sco::exprDec(jerk, targets_[j]); + // expr_ = coeff * jerk^2 + sco::exprInc(expr_, sco::exprMult(sco::exprSquare(jerk), coeffs_[j])); + } + } +} +double JointJerkEqCost::value(const DblVec& xvec) +{ + // Convert vector from optimization to trajectory + Eigen::MatrixXd traj = (getTraj(xvec, vars_)); + // Takes diff b/n the subsequent rows and subtract each row by the targets_ vector + Eigen::MatrixXd diff = + (diffAxis0(diffAxis0(diffAxis0(traj.block(first_step_, 0, last_step_ - first_step_ + 1, traj.cols()))))) + .rowwise() - + targets_.transpose(); + // Element-wise square it, multiply it by a diagonal matrix of coefficients, and sums output + return (diff.array().square().matrix() * coeffs_.asDiagonal()).sum(); +} +sco::ConvexObjectivePtr JointJerkEqCost::convex(const DblVec& /*x*/, sco::Model* model) +{ + sco::ConvexObjectivePtr out(new sco::ConvexObjective(model)); + out->addQuadExpr(expr_); + return out; +} + +JointJerkIneqCost::JointJerkIneqCost(const VarArray& vars, const Eigen::VectorXd& coeffs, + const Eigen::VectorXd& targets, const Eigen::VectorXd& upper_tols, + const Eigen::VectorXd& lower_tols, int& first_step, int& last_step) + : Cost("JointJerkIneq") + , vars_(vars) + , coeffs_(coeffs) + , upper_tols_(upper_tols) + , lower_tols_(lower_tols) + , targets_(targets) + , first_step_(first_step) + , last_step_(last_step) +{ + for (int i = first_step_; i <= last_step_ - 4; ++i) + { + for (int j = 0; j < vars.cols(); ++j) + { + sco::AffExpr jerk; + sco::AffExpr expr; + sco::AffExpr expr_neg; + sco::exprInc(jerk, sco::exprMult(vars(i, j), -1.0 / 2.0)); + sco::exprInc(jerk, sco::exprMult(vars(i + 1, j), 1.0)); + sco::exprInc(jerk, sco::exprMult(vars(i + 2, j), 0.0)); + sco::exprInc(jerk, sco::exprMult(vars(i + 3, j), -1.0)); + sco::exprInc(jerk, sco::exprMult(vars(i + 4, j), 1.0 / 2.0)); + sco::exprDec(jerk, targets_[j]); + + // Form upper limit expr = - (upper_tol-(jerk-targ)) + sco::exprInc(expr, upper_tols_[j]); // expr_ = upper_tol + sco::exprDec(expr, jerk); // expr = upper_tol_- (vel - targets_) + sco::exprScale(expr, -coeffs[j]); // expr = - (upper_tol_- (vel - targets_)) * coeffs_ + expr_vec_.push_back(expr); + + // Form lower limit expr = (lower_tol-(acc-targ)) + sco::exprInc(expr_neg, lower_tols_[j]); // expr_ = lower_tol_ + sco::exprDec(expr_neg, jerk); // expr = lower_tol_- (vel - targets_) + sco::exprScale(expr_neg, coeffs[j]); // expr = (lower_tol_- (vel - targets_)) * coeffs_ + expr_vec_.push_back(expr_neg); + } + } +} + +double JointJerkIneqCost::value(const DblVec& xvec) +{ + // Convert vector from optimization to trajectory + Eigen::MatrixXd traj = getTraj(xvec, vars_); + // Takes diff b/n the subsequent rows to get velocity + Eigen::MatrixXd jerk = + diffAxis0(diffAxis0(diffAxis0(traj.block(first_step_, 0, last_step_ - first_step_ + 1, traj.cols())))); + // Subtract targets_ to center about 0 and then subtract from tolerance + Eigen::MatrixXd diff0 = (jerk.rowwise() - targets_.transpose()); + Eigen::MatrixXd diff1 = (diff0.rowwise() - upper_tols_.transpose()) * coeffs_.asDiagonal(); + Eigen::MatrixXd diff2 = ((diff0 * -1).rowwise() + lower_tols_.transpose()) * coeffs_.asDiagonal(); + // Applies hinge, multiplies it by a diagonal matrix of coefficients, sums each corresponding value, and converts to + // vector + return diff1.cwiseMax(0).sum() + diff2.cwiseMax(0).sum(); +} + +sco::ConvexObjectivePtr JointJerkIneqCost::convex(const DblVec& /*x*/, sco::Model* model) +{ + sco::ConvexObjectivePtr out(new sco::ConvexObjective(model)); + // Add hinge cost. Set the coefficient to 1 here since we include it in the AffExpr already + // This is necessary since we want a seperate coefficient per joint + for (sco::AffExpr& expr : expr_vec_) + { + out->addHinge(expr, 1); + } + return out; +} + +JointJerkEqConstraint::JointJerkEqConstraint(const VarArray& vars, const Eigen::VectorXd& coeffs, + const Eigen::VectorXd& targets, int& first_step, int& last_step) + : EqConstraint("JointJerkEq") + , vars_(vars) + , coeffs_(coeffs) + , targets_(targets) + , first_step_(first_step) + , last_step_(last_step) +{ + for (int i = first_step_; i <= last_step_ - 4; ++i) + { + for (int j = 0; j < vars.cols(); ++j) + { + sco::AffExpr jerk; + sco::exprInc(jerk, sco::exprMult(vars(i, j), -1.0 / 2.0)); + sco::exprInc(jerk, sco::exprMult(vars(i + 1, j), 1.0)); + sco::exprInc(jerk, sco::exprMult(vars(i + 2, j), 0.0)); + sco::exprInc(jerk, sco::exprMult(vars(i + 3, j), -1.0)); + sco::exprInc(jerk, sco::exprMult(vars(i + 4, j), 1.0 / 2.0)); + + sco::exprDec(jerk, targets_[j]); // offset to center about 0 + // expr_ = coeff * jerk - Not squared b/c QuadExpr cnt not yet supported (TODO) + expr_vec_.push_back(sco::exprMult(jerk, coeffs_[j])); + } + } +} + +DblVec JointJerkEqConstraint::value(const DblVec& xvec) +{ + // Convert vector from optimization to trajectory + Eigen::MatrixXd traj = getTraj(xvec, vars_); + // Takes diff b/n the subsequent rows and subtract each row by the targets_ vector + Eigen::MatrixXd diff = + (diffAxis0(diffAxis0(diffAxis0(traj.block(first_step_, 0, last_step_ - first_step_ + 1, traj.cols()))))) + .rowwise() - + targets_.transpose(); + // Squares it, multiplies it by a diagonal matrix of coefficients, and converts to vector + return util::toDblVec((diff.array().square()).matrix() * coeffs_.asDiagonal()); +} +sco::ConvexConstraintsPtr JointJerkEqConstraint::convex(const DblVec& /*x*/, sco::Model* model) +{ + sco::ConvexConstraintsPtr out(new sco::ConvexConstraints(model)); + for (sco::AffExpr& expr : expr_vec_) + { + out->addEqCnt(expr); + } + return out; +} + +JointJerkIneqConstraint::JointJerkIneqConstraint(const VarArray& vars, const Eigen::VectorXd& coeffs, + const Eigen::VectorXd& targets, const Eigen::VectorXd& upper_tols, + const Eigen::VectorXd& lower_tols, int& first_step, int& last_step) + : IneqConstraint("JointJerkIneq") + , vars_(vars) + , coeffs_(coeffs) + , upper_tols_(upper_tols) + , lower_tols_(lower_tols) + , targets_(targets) + , first_step_(first_step) + , last_step_(last_step) +{ + for (int i = first_step_; i <= last_step_ - 4; ++i) + { + for (int j = 0; j < vars.cols(); ++j) + { + sco::AffExpr jerk; + sco::AffExpr expr; + sco::AffExpr expr_neg; + sco::exprInc(jerk, sco::exprMult(vars(i, j), -1.0 / 2.0)); + sco::exprInc(jerk, sco::exprMult(vars(i + 1, j), 1.0)); + sco::exprInc(jerk, sco::exprMult(vars(i + 2, j), 0.0)); + sco::exprInc(jerk, sco::exprMult(vars(i + 3, j), -1.0)); + sco::exprInc(jerk, sco::exprMult(vars(i + 4, j), 1.0 / 2.0)); + sco::exprDec(jerk, targets_[j]); // offset to center about 0 + + // Form upper limit expr = - (upper_tol-(vel-targ)) + sco::exprInc(expr, upper_tols_[j]); // expr_ = upper_tol + sco::exprDec(expr, jerk); // expr = upper_tol_- (vel - targets_) + sco::exprScale(expr, -coeffs[j]); // expr = - (upper_tol_- (vel - targets_)) * coeffs_ + expr_vec_.push_back(expr); + + // Form upper limit expr = - (upper_tol-(vel-targ)) + sco::exprInc(expr_neg, lower_tols_[j]); // expr_ = lower_tol_ + sco::exprDec(expr_neg, jerk); // expr = lower_tol_- (vel - targets_) + sco::exprScale(expr_neg, coeffs[j]); // expr = (lower_tol_- (vel - targets_)) * coeffs_ + expr_vec_.push_back(expr_neg); + } + } +} + +DblVec JointJerkIneqConstraint::value(const DblVec& xvec) +{ + // Convert vector from optimization to trajectory + Eigen::MatrixXd traj = getTraj(xvec, vars_); + // Takes diff b/n the subsequent rows to get velocity + Eigen::MatrixXd acc = diffAxis0(diffAxis0(traj.block(first_step_, 0, last_step_ - first_step_ + 1, traj.cols()))); + // Subtract targets_ to center about 0 and then subtract from tolerance + Eigen::MatrixXd diff0 = (acc.rowwise() - targets_.transpose()); + Eigen::MatrixXd diff1 = (diff0.rowwise() - upper_tols_.transpose()) * coeffs_.asDiagonal(); + Eigen::MatrixXd diff2 = ((diff0 * -1).rowwise() + lower_tols_.transpose()) * coeffs_.asDiagonal(); + // Applies hinge, multiplies it by a diagonal matrix of coefficients, sums each corresponding value, and converts to + // vector + Eigen::MatrixXd out(diff1.rows(), diff1.cols() + diff2.cols()); + out << diff1, diff2; + return util::toDblVec(out.cwiseMax(0)); +} + +sco::ConvexConstraintsPtr JointJerkIneqConstraint::convex(const DblVec& /*x*/, sco::Model* model) +{ + sco::ConvexConstraintsPtr out(new sco::ConvexConstraints(model)); + // Add hinge cost. Set the coefficient to 1 here since we include it in the AffExpr already + // This is necessary since we want a seperate coefficient per joint + for (sco::AffExpr& expr : expr_vec_) + { + out->addIneqCnt(expr); + } + return out; +} + +} // namespace trajopt diff --git a/moveit_planners/trajopt/trajopt/src/utils.cpp b/moveit_planners/trajopt/trajopt/src/utils.cpp new file mode 100644 index 0000000000..dbd87f4fb6 --- /dev/null +++ b/moveit_planners/trajopt/trajopt/src/utils.cpp @@ -0,0 +1,87 @@ +#include +TRAJOPT_IGNORE_WARNINGS_PUSH +#include +#include +TRAJOPT_IGNORE_WARNINGS_POP + +#include +#include + +namespace trajopt +{ +TrajArray getTraj(const DblVec& x, const VarArray& vars) +{ + TrajArray out(vars.rows(), vars.cols()); + for (int i = 0; i < vars.rows(); ++i) + { + for (int j = 0; j < vars.cols(); ++j) + { + out(i, j) = vars(i, j).value(x); + } + } + return out; +} + +TrajArray getTraj(const DblVec& x, const AffArray& arr) +{ + Eigen::MatrixXd out(arr.rows(), arr.cols()); + for (int i = 0; i < arr.rows(); ++i) + { + for (int j = 0; j < arr.cols(); ++j) + { + out(i, j) = arr(i, j).value(x); + } + } + return out; +} + +void AddVarArrays(sco::OptProb& prob, int rows, const IntVec& cols, const std::vector& name_prefix, + const std::vector& newvars) +{ + size_t n_arr = name_prefix.size(); + assert(static_cast(n_arr) == newvars.size()); + + std::vector index(n_arr); + for (size_t i = 0; i < n_arr; ++i) + { + newvars[i]->resize(rows, cols[i]); + index[i].resize(rows, cols[i]); + } + + std::vector names; + int var_idx = prob.getNumVars(); + for (int i = 0; i < rows; ++i) + { + for (size_t k = 0; k < n_arr; ++k) + { + for (int j = 0; j < cols[k]; ++j) + { + index[k](i, j) = var_idx; + names.push_back((boost::format("%s_%i_%i") % name_prefix[k] % i % j).str()); + ++var_idx; + } + } + } + prob.createVariables(names); // note that w,r, are both unbounded + + const std::vector& vars = prob.getVars(); + for (size_t k = 0; k < n_arr; ++k) + { + for (int i = 0; i < rows; ++i) + { + for (int j = 0; j < cols[k]; ++j) + { + (*newvars[k])(i, j) = vars[static_cast(index[k](i, j))]; + } + } + } +} + +void AddVarArray(sco::OptProb& prob, int rows, int cols, const std::string& name_prefix, VarArray& newvars) +{ + std::vector arrs(1, &newvars); + std::vector prefixes(1, name_prefix); + std::vector colss(1, cols); + AddVarArrays(prob, rows, colss, prefixes, arrs); +} +} diff --git a/moveit_planners/trajopt/trajopt_interface/CMakeLists.txt b/moveit_planners/trajopt/trajopt_interface/CMakeLists.txt new file mode 100644 index 0000000000..8f564a302a --- /dev/null +++ b/moveit_planners/trajopt/trajopt_interface/CMakeLists.txt @@ -0,0 +1,108 @@ +cmake_minimum_required(VERSION 2.8.12) +project(moveit_planners_trajopt) + +add_compile_options(-std=c++14) + +if(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Release) +endif() + +find_package(catkin REQUIRED + COMPONENTS + moveit_core + moveit_visual_tools + moveit_ros_planning + moveit_ros_planning_interface + pluginlib + roscpp + trajopt + trajopt_sco + trajopt_utils +) + +catkin_package( + INCLUDE_DIRS include + LIBRARIES + ${PROJECT_NAME} + INCLUDE_DIRS + CATKIN_DEPENDS + roscpp + pluginlib + moveit_core + moveit_visual_tools + moveit_ros_planning_interface +) + +# The following include_directory should have include folder of the new planner. +include_directories( + include + ${catkin_INCLUDE_DIRS} + SYSTEM + ${Boost_INCLUDE_DIRS} + ${catkin_INCLUDE_DIRS} +) + +add_library( + ${PROJECT_NAME} + src/trajopt_interface.cpp + src/trajopt_planning_context.cpp +) + +target_link_libraries( + ${PROJECT_NAME} + ${catkin_LIBRARIES} + ${Boost_LIBRARIES} +) + +set_target_properties( + ${PROJECT_NAME} + PROPERTIES + VERSION + "${${PROJECT_NAME}_VERSION}" +) + +# TrajOpt planning plugin +add_library(moveit_trajopt_planner_plugin src/trajopt_planner_manager.cpp) +set_target_properties(moveit_trajopt_planner_plugin PROPERTIES VERSION "${${PROJECT_NAME}_VERSION}") + +target_link_libraries(moveit_trajopt_planner_plugin ${PROJECT_NAME} ${catkin_LIBRARIES}) + +############# +## Install ## +############# + +# Mark executables and/or libraries for installation +install( + TARGETS ${PROJECT_NAME} moveit_trajopt_planner_plugin + ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} +) + +# Mark cpp header files for installation +install( + DIRECTORY + include/trajopt_interface/ + DESTINATION + ${CATKIN_PACKAGE_INCLUDE_DESTINATION} +) + +install(FILES trajopt_interface_plugin_description.xml + DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}) + +############# +## Testing ## +############# + +if(CATKIN_ENABLE_TESTING) + find_package(rostest REQUIRED) + + add_rostest_gtest(trajectory_test test/trajectory_test.test test/trajectory_test.cpp) + target_link_libraries( + trajectory_test + ${LIBRARY_NAME} + ${catkin_LIBRARIES} + ${PROJECT_NAME} + ) + +endif() diff --git a/moveit_planners/trajopt/trajopt_interface/README.md b/moveit_planners/trajopt/trajopt_interface/README.md new file mode 100644 index 0000000000..84e0ce1d44 --- /dev/null +++ b/moveit_planners/trajopt/trajopt_interface/README.md @@ -0,0 +1 @@ +As of August 2019, this is a work in progress towards adding trajopt motion planning algorithm to MoveIt as a planner plugin. diff --git a/moveit_planners/trajopt/trajopt_interface/include/trajopt_interface/trajopt_interface.h b/moveit_planners/trajopt/trajopt_interface/include/trajopt_interface/trajopt_interface.h new file mode 100644 index 0000000000..ba1a2dd5c3 --- /dev/null +++ b/moveit_planners/trajopt/trajopt_interface/include/trajopt_interface/trajopt_interface.h @@ -0,0 +1,79 @@ +/********************************************************************* + * Software License Agreement (BSD License) + * + * Copyright (c) 2019, PickNik, LLC. + * 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 and/or other materials provided + * with the distribution. + * * Neither the name of PickNik nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * 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 OWNER 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. + *********************************************************************/ + +/* Author: Omid Heidari */ +#pragma once + +#include + +#include + +#include +#include + +namespace trajopt_interface +{ +MOVEIT_CLASS_FORWARD(TrajOptInterface); + +class TrajOptInterface +{ +public: + TrajOptInterface(const ros::NodeHandle& nh = ros::NodeHandle("~")); + + const sco::BasicTrustRegionSQPParameters& getParams() const + { + return params_; + } + + bool solve(const planning_scene::PlanningSceneConstPtr& planning_scene, + const planning_interface::MotionPlanRequest& req, moveit_msgs::MotionPlanDetailedResponse& res); + +protected: + /** @brief Configure everything using the param server */ + void setTrajOptParams(sco::BasicTrustRegionSQPParameters& param); + void setDefaultTrajOPtParams(); + void setProblemInfoParam(trajopt::ProblemInfo& problem_info); + void setJointPoseTermInfoParams(trajopt::JointPoseTermInfoPtr& jp, std::string name); + trajopt::DblVec extractStartJointValues(const planning_interface::MotionPlanRequest& req, + const std::vector& group_joint_names); + + ros::NodeHandle nh_; /// The ROS node handle + sco::BasicTrustRegionSQPParameters params_; + std::vector optimizer_callbacks_; + trajopt::TrajOptProblemPtr trajopt_problem_; + std::string name_; +}; + +void callBackFunc(sco::OptProb* opt_prob, sco::OptResults& opt_res); +} diff --git a/moveit_planners/trajopt/trajopt_interface/include/trajopt_interface/trajopt_planning_context.h b/moveit_planners/trajopt/trajopt_interface/include/trajopt_interface/trajopt_planning_context.h new file mode 100644 index 0000000000..9c3d6601e4 --- /dev/null +++ b/moveit_planners/trajopt/trajopt_interface/include/trajopt_interface/trajopt_planning_context.h @@ -0,0 +1,32 @@ +#pragma once + +#include + +#include +#include + +namespace trajopt_interface +{ +MOVEIT_CLASS_FORWARD(TrajOptPlanningContext); + +class TrajOptPlanningContext : public planning_interface::PlanningContext +{ +public: + TrajOptPlanningContext(const std::string& name, const std::string& group, + const robot_model::RobotModelConstPtr& model); + ~TrajOptPlanningContext() override + { + } + + bool solve(planning_interface::MotionPlanResponse& res) override; + bool solve(planning_interface::MotionPlanDetailedResponse& res) override; + + bool terminate() override; + void clear() override; + +private: + moveit::core::RobotModelConstPtr robot_model_; + + TrajOptInterfacePtr trajopt_interface_; +}; +} // namespace trajopt_interface diff --git a/moveit_planners/trajopt/trajopt_interface/package.xml b/moveit_planners/trajopt/trajopt_interface/package.xml new file mode 100644 index 0000000000..9bba70b4ee --- /dev/null +++ b/moveit_planners/trajopt/trajopt_interface/package.xml @@ -0,0 +1,37 @@ + + moveit_planners_trajopt + 1.0.1 + + TrajOpt planning plugin, an optimization based motion planner + + Omid Heidari + + Omid Heidari + MoveIt! Release Team + + BSD + + http://moveit.ros.org + https://github.com/ros-planning/moveit/issues + https://github.com/ros-planning/moveit + + catkin + + pluginlib + moveit_core + moveit_ros_planning + moveit_ros_planning_interface + moveit_visual_tools + roscpp + trajopt + trajopt_sco + trajopt_utils + + rosunit + rostest + + + + + + diff --git a/moveit_planners/trajopt/trajopt_interface/src/trajopt_interface.cpp b/moveit_planners/trajopt/trajopt_interface/src/trajopt_interface.cpp new file mode 100644 index 0000000000..de9832e800 --- /dev/null +++ b/moveit_planners/trajopt/trajopt_interface/src/trajopt_interface.cpp @@ -0,0 +1,473 @@ +/********************************************************************* + * Software License Agreement (BSD License) + * + * Copyright (c) 2019, PickNik, Inc. + * 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 and/or other materials provided + * with the distribution. + * * Neither the name of PickNik nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * 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 OWNER 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. + *********************************************************************/ + +/* Author: Omid Heidari */ + +#include +#include + +#include + +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include + +#include "trajopt_interface/trajopt_interface.h" + +namespace trajopt_interface +{ +TrajOptInterface::TrajOptInterface(const ros::NodeHandle& nh) : nh_(nh), name_("TrajOptInterface") +{ + trajopt_problem_ = trajopt::TrajOptProblemPtr(new trajopt::TrajOptProblem); + setDefaultTrajOPtParams(); + + // TODO: callbacks should be defined by the user + optimizer_callbacks_.push_back(callBackFunc); +} + +bool TrajOptInterface::solve(const planning_scene::PlanningSceneConstPtr& planning_scene, + const planning_interface::MotionPlanRequest& req, + moveit_msgs::MotionPlanDetailedResponse& res) +{ + ROS_INFO(" ======================================= From trajopt_interface, solve is called"); + setTrajOptParams(params_); + + if (!planning_scene) + { + ROS_ERROR_STREAM_NAMED(name_, "No planning scene initialized."); + res.error_code.val = moveit_msgs::MoveItErrorCodes::FAILURE; + return false; + } + + ROS_INFO(" ======================================= Extract current state information"); + ros::WallTime start_time = ros::WallTime::now(); + robot_model::RobotModelConstPtr robot_model = planning_scene->getRobotModel(); + bool robot_model_ok = static_cast(robot_model); + if (!robot_model_ok) + ROS_ERROR_STREAM_NAMED(name_, "robot model is not loaded properly"); + + robot_state::RobotStatePtr current_state(new robot_state::RobotState(robot_model)); + *current_state = planning_scene->getCurrentState(); + const robot_state::JointModelGroup* joint_model_group = current_state->getJointModelGroup(req.group_name); + if (joint_model_group == nullptr) + ROS_ERROR_STREAM_NAMED(name_, "joint model group is empty"); + + std::vector group_joint_names = joint_model_group->getActiveJointModelNames(); + int dof = group_joint_names.size(); + std::vector current_joint_values; + current_state->copyJointGroupPositions(joint_model_group, current_joint_values); + + // Current state is different from star state in general + ROS_INFO(" ======================================= Extract start state infromation"); + trajopt::DblVec start_joint_values = extractStartJointValues(req, group_joint_names); + + // check the start state for being empty or joint limit violiation + if (start_joint_values.empty()) + { + ROS_ERROR_STREAM_NAMED(name_, "Start_state is empty"); + res.error_code.val = moveit_msgs::MoveItErrorCodes::INVALID_ROBOT_STATE; + return false; + } + + if (not joint_model_group->satisfiesPositionBounds(start_joint_values.data())) + { + ROS_ERROR_STREAM_NAMED(name_, "Start state violates joint limits"); + res.error_code.val = moveit_msgs::MoveItErrorCodes::INVALID_ROBOT_STATE; + return false; + } + + ROS_INFO(" ======================================= Create ProblemInfo"); + trajopt::ProblemInfo problem_info(planning_scene, req.group_name); + setProblemInfoParam(problem_info); + + ROS_INFO(" ======================================= Populate init info"); + // For type JOINT_INTERPOLATED, we need the configuration of the robot at one state (which should be the goal), we do + // not need the robot configuration along the whole trajectory. That is why we need one index which is 0 for "points[]" + if (problem_info.init_info.type == trajopt::InitInfo::JOINT_INTERPOLATED) + { + Eigen::VectorXd initial_joint_values_eigen(dof); + for (int joint_index = 0; joint_index < dof; ++joint_index) + { + initial_joint_values_eigen(joint_index) = req.reference_trajectories[0].joint_trajectory[0].points[0].positions[joint_index]; + } + + problem_info.init_info.data = initial_joint_values_eigen; + } + else if (problem_info.init_info.type == trajopt::InitInfo::GIVEN_TRAJ) + { + int num_steps = problem_info.basic_info.n_steps; + trajopt::TrajArray init_traj; + init_traj.resize(num_steps, dof); + for (std::size_t step = 0; step < num_steps; ++num_steps) + { + for (std::size_t joint_index = 0; joint_index < dof; ++joint_index ) + { + init_traj(step, joint_index) = req.reference_trajectories[0].joint_trajectory[0].points[step].positions[joint_index]; + } + } + + problem_info.init_info.data = init_traj; + } + + ROS_INFO(" ======================================= Create Constraints"); + if (req.goal_constraints.empty()) + { + ROS_ERROR_STREAM_NAMED("trajopt_planner", "No goal constraints specified!"); + res.error_code.val = moveit_msgs::MoveItErrorCodes::INVALID_GOAL_CONSTRAINTS; + return false; + } + + ROS_INFO(" ======================================= Cartesian Constraints"); + if (!req.goal_constraints[0].position_constraints.empty() && !req.goal_constraints[0].orientation_constraints.empty()) + { + trajopt::CartPoseTermInfoPtr cart_goal_pos(new trajopt::CartPoseTermInfo); + + // TODO: Feed cart_goal_pos with request information and the needed param to the setup.yaml file + // TODO: Multiple Cartesian constraints + + // Add the constraint to problem_info + problem_info.cnt_infos.push_back(cart_goal_pos); + } + else if (req.goal_constraints[0].position_constraints.empty() && + !req.goal_constraints[0].orientation_constraints.empty()) + { + ROS_ERROR_STREAM_NAMED("trajopt_planner", "position constraint is not defined"); + res.error_code.val = moveit_msgs::MoveItErrorCodes::INVALID_GOAL_CONSTRAINTS; + return false; + } + else if (!req.goal_constraints[0].orientation_constraints.empty() && + req.goal_constraints[0].orientation_constraints.empty()) + { + ROS_ERROR_STREAM_NAMED("trajopt_planner", "orientation constraint is not defined"); + res.error_code.val = moveit_msgs::MoveItErrorCodes::INVALID_GOAL_CONSTRAINTS; + return false; + } + + ROS_INFO(" ======================================= Constraints from request goal_constraints"); + for (auto goal_cnt : req.goal_constraints) + { + trajopt::JointPoseTermInfoPtr joint_pos_term(new trajopt::JointPoseTermInfo); + // When using MotionPlanning Display in RViz, the created request has no name for the constriant + setJointPoseTermInfoParams(joint_pos_term, (goal_cnt.name != "") ? goal_cnt.name : "goal_tmp"); + + trajopt::DblVec joint_goal_constraints; + for (const moveit_msgs::JointConstraint& joint_goal_constraint : goal_cnt.joint_constraints) + { + joint_goal_constraints.push_back(joint_goal_constraint.position); + } + joint_pos_term->targets = joint_goal_constraints; + problem_info.cnt_infos.push_back(joint_pos_term); + } + + ROS_INFO(" ======================================= Constraints from request start_state"); + // add the start pos from request as a constraint + trajopt::JointPoseTermInfoPtr joint_start_pos(new trajopt::JointPoseTermInfo); + + joint_start_pos->targets = start_joint_values; + setJointPoseTermInfoParams(joint_start_pos, "start_pos"); + problem_info.cnt_infos.push_back(joint_start_pos); + + ROS_INFO(" ======================================= Velocity Constraints, hard-coded"); + // TODO: should be defined by user, its parametes should be added to setup.yaml + trajopt::JointVelTermInfoPtr joint_vel(new trajopt::JointVelTermInfo); + + joint_vel->coeffs = std::vector(dof, 5.0); + joint_vel->targets = std::vector(dof, 0.0); + joint_vel->first_step = 0; + joint_vel->last_step = problem_info.basic_info.n_steps - 1; + joint_vel->name = "joint_vel"; + joint_vel->term_type = trajopt::TT_COST; + problem_info.cost_infos.push_back(joint_vel); + + ROS_INFO(" ======================================= Visibility Constraints"); + if (!req.goal_constraints[0].visibility_constraints.empty()) + { + // TODO: Add visibility constraint + } + + ROS_DEBUG_STREAM_NAMED(name_, "trajopt_param.improve_ratio_threshold: " << params_.improve_ratio_threshold); + ROS_DEBUG_STREAM_NAMED(name_, "trajopt_param.min_trust_box_size: " << params_.min_trust_box_size); + ROS_DEBUG_STREAM_NAMED(name_, "trajopt_param.min_approx_improve: " << params_.min_approx_improve); + ROS_DEBUG_STREAM_NAMED(name_, "trajopt_param.params_.min_approx_improve_frac: " << params_.min_approx_improve_frac); + ROS_DEBUG_STREAM_NAMED(name_, "trajopt_param.max_iter: " << params_.max_iter); + ROS_DEBUG_STREAM_NAMED(name_, "trajopt_param.trust_shrink_ratio: " << params_.trust_shrink_ratio); + ROS_DEBUG_STREAM_NAMED(name_, "trajopt_param.trust_expand_ratio: " << params_.trust_expand_ratio); + ROS_DEBUG_STREAM_NAMED(name_, "trajopt_param.cnt_tolerance: " << params_.cnt_tolerance); + ROS_DEBUG_STREAM_NAMED(name_, "trajopt_param.max_merit_coeff_increases: " << params_.max_merit_coeff_increases); + ROS_DEBUG_STREAM_NAMED(name_, "trajopt_param.merit_coeff_increase_ratio: " << params_.merit_coeff_increase_ratio); + ROS_DEBUG_STREAM_NAMED(name_, "trajopt_param.max_time: " << params_.max_time); + ROS_DEBUG_STREAM_NAMED(name_, "trajopt_param.merit_error_coeff: " << params_.merit_error_coeff); + ROS_DEBUG_STREAM_NAMED(name_, "trajopt_param.trust_box_size: " << params_.trust_box_size); + ROS_DEBUG_STREAM_NAMED(name_, "problem_info.basic_info.n_steps: " << problem_info.basic_info.n_steps); + ROS_DEBUG_STREAM_NAMED(name_, "problem_info.basic_info.dt_upper_lim: " << problem_info.basic_info.dt_upper_lim); + ROS_DEBUG_STREAM_NAMED(name_, "problem_info.basic_info.dt_lower_lim: " << problem_info.basic_info.dt_lower_lim); + ROS_DEBUG_STREAM_NAMED(name_, "problem_info.basic_info.start_fixed: " << problem_info.basic_info.start_fixed); + ROS_DEBUG_STREAM_NAMED(name_, "problem_info.basic_info.use_time: " << problem_info.basic_info.use_time); + ROS_DEBUG_STREAM_NAMED(name_, "problem_info.basic_info.convex_solver: " << problem_info.basic_info.convex_solver); + + std::string problem_info_type; + switch (problem_info.init_info.type) + { + case trajopt::InitInfo::STATIONARY: + problem_info_type = "STATIONARY"; + break; + case trajopt::InitInfo::JOINT_INTERPOLATED: + problem_info_type = "JOINT_INTERPOLATED"; + break; + case trajopt::InitInfo::GIVEN_TRAJ: + problem_info_type = "GIVEN_TRAJ"; + break; + } + ROS_DEBUG_STREAM_NAMED(name_, "problem_info.basic_info.type: " << problem_info_type); + ROS_DEBUG_STREAM_NAMED(name_, "problem_info.basic_info.dt: " << problem_info.init_info.dt); + + ROS_INFO(" ======================================= Construct problem"); + trajopt_problem_ = ConstructProblem(problem_info); + + ROS_INFO_STREAM_NAMED("num_cost", trajopt_problem_->getNumCosts()); + ROS_INFO_STREAM_NAMED("num_constraints", trajopt_problem_->getNumConstraints()); + + ROS_INFO(" ======================================= TrajOpt Optimization"); + sco::BasicTrustRegionSQP opt(trajopt_problem_); + + opt.setParameters(params_); + opt.initialize(trajopt::trajToDblVec(trajopt_problem_->GetInitTraj())); + + // Add all callbacks + for (const sco::Optimizer::Callback& callback : optimizer_callbacks_) + + { + opt.addCallback(callback); + } + + // Optimize + ros::WallTime create_time = ros::WallTime::now(); + opt.optimize(); + + ROS_INFO(" ======================================= TrajOpt Solution"); + trajopt::TrajArray opt_solution = trajopt::getTraj(opt.x(), trajopt_problem_->GetVars()); + + // assume that the trajectory is now optimized, fill in the output structure: + ROS_INFO_STREAM_NAMED("num_rows", opt_solution.rows()); + ROS_INFO_STREAM_NAMED("num_cols", opt_solution.cols()); + + res.trajectory.resize(1); + res.trajectory[0].joint_trajectory.joint_names = group_joint_names; + res.trajectory[0].joint_trajectory.header = req.start_state.joint_state.header; + + // fill in the entire trajectory + res.trajectory[0].joint_trajectory.points.resize(opt_solution.rows()); + for (int i = 0; i < opt_solution.rows(); i++) + { + res.trajectory[0].joint_trajectory.points[i].positions.resize(opt_solution.cols()); + for (size_t j = 0; j < opt_solution.cols(); j++) + { + res.trajectory[0].joint_trajectory.points[i].positions[j] = opt_solution(i, j); + } + // Further filtering is required to set valid timestamps accounting for velocity and acceleration constraints. + res.trajectory[0].joint_trajectory.points[i].time_from_start = ros::Duration(0.0); + } + + res.error_code.val = moveit_msgs::MoveItErrorCodes::SUCCESS; + res.processing_time.push_back((ros::WallTime::now() - start_time).toSec()); + + ROS_INFO(" ======================================= check if final state is within goal tolerances"); + kinematic_constraints::JointConstraint joint_cnt(planning_scene->getRobotModel()); + robot_state::RobotState last_state(*current_state); + last_state.setJointGroupPositions(req.group_name, res.trajectory[0].joint_trajectory.points.back().positions); + + for (int jn = 0; jn < res.trajectory[0].joint_trajectory.points.back().positions.size(); ++jn) + { + ROS_INFO_STREAM_NAMED("joint_value", res.trajectory[0].joint_trajectory.points.back().positions[jn] + << " " << req.goal_constraints.back().joint_constraints[jn].position); + } + + bool constraints_are_ok = true; + int joint_cnt_index = 0; + for (const moveit_msgs::JointConstraint& constraint : req.goal_constraints.back().joint_constraints) + { + ROS_INFO("index %i: jc.configure(constraint)=> %d, jc.decide(last_state).satisfied=> %d, tolerance %f", + joint_cnt_index, joint_cnt.configure(constraint), joint_cnt.decide(last_state).satisfied, + constraint.tolerance_above); + constraints_are_ok = constraints_are_ok and joint_cnt.configure(constraint); + constraints_are_ok = constraints_are_ok and joint_cnt.decide(last_state).satisfied; + if (not constraints_are_ok) + { + ROS_ERROR_STREAM_NAMED("trajopt_planner", "Goal constraints are violated: " << constraint.joint_name); + res.error_code.val = moveit_msgs::MoveItErrorCodes::GOAL_CONSTRAINTS_VIOLATED; + return false; + } + joint_cnt_index = joint_cnt_index + 1; + } + + ROS_INFO(" ==================================== Response"); + res.trajectory_start = req.start_state; + + ROS_INFO(" ==================================== Debug Response"); + ROS_INFO_STREAM_NAMED("group_name", res.group_name); + ROS_INFO_STREAM_NAMED("start_traj_name_size", res.trajectory_start.joint_state.name.size()); + ROS_INFO_STREAM_NAMED("start_traj_position_size", res.trajectory_start.joint_state.position.size()); + ROS_INFO_STREAM_NAMED("traj_name_size", res.trajectory[0].joint_trajectory.joint_names.size()); + ROS_INFO_STREAM_NAMED("traj_point_size", res.trajectory[0].joint_trajectory.points.size()); + return true; +} + +void TrajOptInterface::setDefaultTrajOPtParams() +{ + sco::BasicTrustRegionSQPParameters params; + params_ = params; +} + +void TrajOptInterface::setTrajOptParams(sco::BasicTrustRegionSQPParameters& params) +{ + nh_.param("trajopt_param/improve_ratio_threshold", params.improve_ratio_threshold, 0.25); + nh_.param("trajopt_param/min_trust_box_size", params.min_trust_box_size, 1e-4); + nh_.param("trajopt_param/min_approx_improve", params.min_approx_improve, 1e-4); + nh_.param("trajopt_param/min_approx_improve_frac", params.min_approx_improve_frac, -static_cast(INFINITY)); + nh_.param("trajopt_param/max_iter", params.max_iter, 100.0); + nh_.param("trajopt_param/trust_shrink_ratio", params.trust_shrink_ratio, 0.1); + + nh_.param("trajopt_param/trust_expand_ratio", params.trust_expand_ratio, 1.5); + nh_.param("trajopt_param/cnt_tolerance", params.cnt_tolerance, 1e-4); + nh_.param("trajopt_param/max_merit_coeff_increases", params.max_merit_coeff_increases, 5.0); + nh_.param("trajopt_param/merit_coeff_increase_ratio", params.merit_coeff_increase_ratio, 10.0); + nh_.param("trajopt_param/max_time", params.max_time, static_cast(INFINITY)); + nh_.param("trajopt_param/merit_error_coeff", params.merit_error_coeff, 10.0); + nh_.param("trajopt_param/trust_box_size", params.trust_box_size, 1e-1); +} + +void TrajOptInterface::setProblemInfoParam(trajopt::ProblemInfo& problem_info) +{ + nh_.param("problem_info/basic_info/n_steps", problem_info.basic_info.n_steps, 20); + nh_.param("problem_info/basic_info/dt_upper_lim", problem_info.basic_info.dt_upper_lim, 2.0); + nh_.param("problem_info/basic_info/dt_lower_lim", problem_info.basic_info.dt_lower_lim, 100.0); + nh_.param("problem_info/basic_info/start_fixed", problem_info.basic_info.start_fixed, true); + nh_.param("problem_info/basic_info/use_time", problem_info.basic_info.use_time, false); + int convex_solver_index; + nh_.param("problem_info/basic_info/convex_solver", convex_solver_index, 1); + switch (convex_solver_index) + { + case 1: + problem_info.basic_info.convex_solver = sco::ModelType::AUTO_SOLVER; + break; + case 2: + problem_info.basic_info.convex_solver = sco::ModelType::BPMPD; + break; + case 3: + problem_info.basic_info.convex_solver = sco::ModelType::OSQP; + break; + case 4: + problem_info.basic_info.convex_solver = sco::ModelType::QPOASES; + break; + case 5: + problem_info.basic_info.convex_solver = sco::ModelType::GUROBI; + break; + } + + nh_.param("problem_info/init_info/dt", problem_info.init_info.dt, 0.5); + int type_index; + nh_.param("problem_info/init_info/type", type_index, 1); + switch (type_index) + { + case 1: + problem_info.init_info.type = trajopt::InitInfo::STATIONARY; + break; + case 2: + problem_info.init_info.type = trajopt::InitInfo::JOINT_INTERPOLATED; + break; + case 3: + problem_info.init_info.type = trajopt::InitInfo::GIVEN_TRAJ; + break; + } +} + +void TrajOptInterface::setJointPoseTermInfoParams(trajopt::JointPoseTermInfoPtr& jp, std::string name) +{ + int term_type_index; + std::string term_type_address = "joint_pos_term_info/" + name + "/term_type"; + nh_.param(term_type_address, term_type_index, 1); + + switch (term_type_index) + { + case 1: + jp->term_type = trajopt::TT_COST; + break; + case 2: + jp->term_type = trajopt::TT_CNT; + break; + case 3: + jp->term_type = trajopt::TT_USE_TIME; + break; + } + + nh_.getParam("joint_pos_term_info/" + name + "/first_timestep", jp->first_step); + nh_.getParam("joint_pos_term_info/" + name + "/last_timestep", jp->last_step); + nh_.getParam("joint_pos_term_info/" + name + "/name", jp->name); +} + +trajopt::DblVec TrajOptInterface::extractStartJointValues(const planning_interface::MotionPlanRequest& req, + const std::vector& group_joint_names) +{ + std::unordered_map all_joints; + trajopt::DblVec start_joint_vals; + + for (int joint_index = 0; joint_index < req.start_state.joint_state.position.size(); ++joint_index) + { + all_joints[req.start_state.joint_state.name[joint_index]] = req.start_state.joint_state.position[joint_index]; + } + + for (auto joint_name : group_joint_names) + { + ROS_INFO(" joint position from start state, name: %s, value: %f", joint_name.c_str(), all_joints[joint_name]); + start_joint_vals.push_back(all_joints[joint_name]); + } + + return start_joint_vals; +} + +void callBackFunc(sco::OptProb* opt_prob, sco::OptResults& opt_res) +{ + // TODO: Create the actuall implementation +} + +} // namespace trajopt_interface diff --git a/moveit_planners/trajopt/trajopt_interface/src/trajopt_planner_manager.cpp b/moveit_planners/trajopt/trajopt_interface/src/trajopt_planner_manager.cpp new file mode 100644 index 0000000000..760c58f823 --- /dev/null +++ b/moveit_planners/trajopt/trajopt_interface/src/trajopt_planner_manager.cpp @@ -0,0 +1,141 @@ +/********************************************************************* + * Software License Agreement (BSD License) + * + * Copyright (c) 2019, PickNik LLC + * 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 and/or other materials provided + * with the distribution. + * * Neither the name of PickNik LLC nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * 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 OWNER 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. + *********************************************************************/ + +/* Author: Omid Heidari + Desc: TrajOpt planning plugin +*/ + +#include + +#include "moveit/collision_detection_fcl/collision_detector_allocator_fcl.h" + +#include + +#include "trajopt_interface/trajopt_planning_context.h" + +namespace trajopt_interface +{ +class TrajOptPlannerManager : public planning_interface::PlannerManager +{ +public: + TrajOptPlannerManager() : planning_interface::PlannerManager() + { + } + + bool initialize(const robot_model::RobotModelConstPtr& model, const std::string& ns) override + { + ROS_INFO(" ======================================= initialize gets called"); + + if (!ns.empty()) + nh_ = ros::NodeHandle(ns); + std::string trajopt_ns = ns.empty() ? "trajopt" : ns + "/trajopt"; + + for (const std::string& gpName : model->getJointModelGroupNames()) + { + ROS_INFO(" ======================================= group name: %s, robot model: %s", gpName.c_str(), + model->getName().c_str()); + planning_contexts_[gpName] = + TrajOptPlanningContextPtr(new TrajOptPlanningContext("trajopt_planning_context", gpName, model)); + } + + return true; + } + + bool canServiceRequest(const moveit_msgs::MotionPlanRequest& req) const override + { + return req.trajectory_constraints.constraints.empty(); + } + + std::string getDescription() const override + { + return "TrajOpt"; + } + + void getPlanningAlgorithms(std::vector& algs) const override + { + algs.clear(); + algs.push_back("trajopt"); + } + + planning_interface::PlanningContextPtr getPlanningContext(const planning_scene::PlanningSceneConstPtr& planning_scene, + const planning_interface::MotionPlanRequest& req, + moveit_msgs::MoveItErrorCodes& error_code) const override + { + ROS_INFO(" ======================================= getPlanningContext() is called "); + error_code.val = moveit_msgs::MoveItErrorCodes::SUCCESS; + + if (req.group_name.empty()) + { + ROS_ERROR("No group specified to plan for"); + error_code.val = moveit_msgs::MoveItErrorCodes::INVALID_GROUP_NAME; + return planning_interface::PlanningContextPtr(); + } + + if (!planning_scene) + { + ROS_ERROR("No planning scene supplied as input"); + error_code.val = moveit_msgs::MoveItErrorCodes::FAILURE; + return planning_interface::PlanningContextPtr(); + } + + // create PlanningScene using hybrid collision detector + planning_scene::PlanningScenePtr ps = planning_scene->diff(); + + // set FCL for the collision + ps->setActiveCollisionDetector(collision_detection::CollisionDetectorAllocatorFCL::create(), true); + + // retrieve and configure existing context + const TrajOptPlanningContextPtr& context = planning_contexts_.at(req.group_name); + + ROS_INFO(" ======================================= context is made "); + + context->setPlanningScene(ps); + context->setMotionPlanRequest(req); + + error_code.val = moveit_msgs::MoveItErrorCodes::SUCCESS; + + return context; + } + +private: + ros::NodeHandle nh_; + +protected: + std::map planning_contexts_; +}; + +} // namespace trajopt_interface + +// register the TrajOptPlannerManager class as a plugin +CLASS_LOADER_REGISTER_CLASS(trajopt_interface::TrajOptPlannerManager, planning_interface::PlannerManager); diff --git a/moveit_planners/trajopt/trajopt_interface/src/trajopt_planning_context.cpp b/moveit_planners/trajopt/trajopt_interface/src/trajopt_planning_context.cpp new file mode 100644 index 0000000000..34b1e4c307 --- /dev/null +++ b/moveit_planners/trajopt/trajopt_interface/src/trajopt_planning_context.cpp @@ -0,0 +1,76 @@ +#include +#include +#include +#include + +#include + +#include + +#include "trajopt_interface/trajopt_planning_context.h" +#include "trajopt_interface/trajopt_interface.h" + +namespace trajopt_interface +{ +TrajOptPlanningContext::TrajOptPlanningContext(const std::string& context_name, const std::string& group_name, + const robot_model::RobotModelConstPtr& model) + : planning_interface::PlanningContext(context_name, group_name), robot_model_(model) +{ + ROS_INFO(" ======================================= TrajOptPlanningContext is constructed"); + trajopt_interface_ = TrajOptInterfacePtr(new TrajOptInterface()); +} + +bool TrajOptPlanningContext::solve(planning_interface::MotionPlanDetailedResponse& res) +{ + moveit_msgs::MotionPlanDetailedResponse res_msg; + bool trajopt_solved = trajopt_interface_->solve(planning_scene_, request_, res_msg); + + if (trajopt_solved) + { + res.trajectory_.resize(1); + res.trajectory_[0] = + robot_trajectory::RobotTrajectoryPtr(new robot_trajectory::RobotTrajectory(robot_model_, getGroupName())); + + moveit::core::RobotState start_state(robot_model_); + robot_state::robotStateMsgToRobotState(res_msg.trajectory_start, start_state); + res.trajectory_[0]->setRobotTrajectoryMsg(start_state, res_msg.trajectory[0]); + + res.description_.push_back("plan"); + // TODO: Add the initial trajectory to res (MotionPlanDetailedResponse) + res.processing_time_ = res_msg.processing_time; + res.error_code_ = res_msg.error_code; + return true; + } + else + { + res.error_code_ = res_msg.error_code; + return false; + } +} + +bool TrajOptPlanningContext::solve(planning_interface::MotionPlanResponse& res) +{ + planning_interface::MotionPlanDetailedResponse res_detailed; + bool planning_success = solve(res_detailed); + + res.error_code_ = res_detailed.error_code_; + + if (planning_success) + { + res.trajectory_ = res_detailed.trajectory_[0]; + res.planning_time_ = res_detailed.processing_time_[0]; + } + + return planning_success; +} + +bool TrajOptPlanningContext::terminate() +{ + ROS_ERROR_STREAM_NAMED("trajopt_planning_context", "TrajOpt is not interruptable yet"); + return false; +} +void TrajOptPlanningContext::clear() +{ +} + +} // namespace trajopt_interface diff --git a/moveit_planners/trajopt/trajopt_interface/test/trajectory_test.cpp b/moveit_planners/trajopt/trajopt_interface/test/trajectory_test.cpp new file mode 100644 index 0000000000..d8763a30de --- /dev/null +++ b/moveit_planners/trajopt/trajopt_interface/test/trajectory_test.cpp @@ -0,0 +1,212 @@ +/********************************************************************* + * Software License Agreement + * + * Copyright (c) 2019, PickNik Consulting + * All rights reserved. + * + *********************************************************************/ + +/* Author: Omid Heidari + Desc: Test the trajectory planned by trajopt + */ + +// C++ +#include +#include +#include + +// ROS +#include + +// Testing +#include + +#include + +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include + +class TrajectoryTest : public ::testing::Test +{ +public: + TrajectoryTest() + { + } + +protected: + void SetUp() override + { + node_handle_ = ros::NodeHandle("~"); + robot_model_ = moveit::core::loadTestingRobotModel("panda"); + bool robot_model_ok_ = static_cast(robot_model_); + if (!robot_model_ok_) + ROS_ERROR_STREAM_NAMED("trajectory_test", "robot model is not loaded correctly"); + } + +protected: + robot_model::RobotModelPtr robot_model_; + std::vector group_joint_names_; + const std::string PLANNING_GROUP = "panda_arm"; + const double GOAL_TOLERANCE = 0.1; + ros::NodeHandle node_handle_; +}; // class TrajectoryTest + +TEST_F(TrajectoryTest, concatVectorValidation) +{ + std::vector vec_a = { 1, 2, 3, 4, 5 }; + std::vector vec_b = { 6, 7, 8, 9, 10 }; + std::vector vec_c = trajopt::concatVector(vec_a, vec_b); + EXPECT_EQ(vec_c.size(), vec_a.size() + vec_b.size()); + + // Check if the output of concatVector is correct. + // Loop over the output and the input vectors to see if they match + std::size_t length_ab = vec_a.size() + vec_b.size(); + for (std::size_t index = 0; index < length_ab; ++index) + { + if (index < vec_a.size()) + { + EXPECT_EQ(vec_c[index], vec_a[index]); + } + else + { + EXPECT_EQ(vec_c[index], vec_b[index - vec_a.size()]); + } + } +} + +TEST_F(TrajectoryTest, goalTolerance) +{ + const std::string NODE_NAME = "trajectory_test"; + + // Create a RobotState and JointModelGroup to keep track of the current robot pose and planning group + robot_state::RobotStatePtr current_state(new robot_state::RobotState(robot_model_)); + current_state->setToDefaultValues(); + + const robot_state::JointModelGroup* joint_model_group = current_state->getJointModelGroup(PLANNING_GROUP); + EXPECT_NE(joint_model_group, nullptr); + const std::vector& joint_names = joint_model_group->getActiveJointModelNames(); + EXPECT_EQ(joint_names.size(), 7); + + planning_scene::PlanningScenePtr planning_scene(new planning_scene::PlanningScene(robot_model_)); + + // Create response and request + planning_interface::MotionPlanRequest req; + planning_interface::MotionPlanResponse res; + + // Set start state + // ====================================================================================== + std::vector start_joint_values = { 0.4, 0.3, 0.5, -0.55, 0.88, 1.0, -0.075 }; + robot_state::RobotStatePtr start_state(new robot_state::RobotState(robot_model_)); + start_state->setJointGroupPositions(joint_model_group, start_joint_values); + start_state->update(); + + req.start_state.joint_state.name = joint_names; + req.start_state.joint_state.position = start_joint_values; + req.goal_constraints.clear(); + req.group_name = PLANNING_GROUP; + + // Set the goal state and joints tolerance + // ======================================================================================== + robot_state::RobotStatePtr goal_state(new robot_state::RobotState(robot_model_)); + std::vector goal_joint_values = { 0.8, 0.7, 1, -1.3, 1.9, 2.2, -0.1 }; + goal_state->setJointGroupPositions(joint_model_group, goal_joint_values); + goal_state->update(); + moveit_msgs::Constraints joint_goal = kinematic_constraints::constructGoalConstraints(*goal_state, joint_model_group); + req.goal_constraints.push_back(joint_goal); + req.goal_constraints[0].name = "goal_pos"; + // Set joint tolerance + std::vector goal_joint_constraint = req.goal_constraints[0].joint_constraints; + for (std::size_t x = 0; x < goal_joint_constraint.size(); ++x) + { + req.goal_constraints[0].joint_constraints[x].tolerance_above = 0.001; + req.goal_constraints[0].joint_constraints[x].tolerance_below = 0.001; + } + + // Load planner + // ====================================================================================== + // We will now construct a loader to load a planner, by name. + // Note that we are using the ROS pluginlib library here. + boost::scoped_ptr> planner_plugin_loader; + planning_interface::PlannerManagerPtr planner_instance; + + std::string planner_plugin_name = "trajopt_interface/TrajOptPlanner"; + node_handle_.setParam("planning_plugin", planner_plugin_name); + + // Make sure the planner plugin is loaded + EXPECT_TRUE(node_handle_.getParam("planning_plugin", planner_plugin_name)); + try + { + planner_plugin_loader.reset(new pluginlib::ClassLoader( + "moveit_core", "planning_interface::PlannerManager")); + } + catch (pluginlib::PluginlibException& ex) + { + ROS_FATAL_STREAM_NAMED(NODE_NAME, "Exception while creating planning plugin loader " << ex.what()); + } + try + { + planner_instance.reset(planner_plugin_loader->createUnmanagedInstance(planner_plugin_name)); + if (!planner_instance->initialize(robot_model_, node_handle_.getNamespace())) + ROS_FATAL_STREAM_NAMED(NODE_NAME, "Could not initialize planner instance"); + ROS_INFO_STREAM_NAMED(NODE_NAME, "Using planning interface '" << planner_instance->getDescription() << "'"); + } + catch (pluginlib::PluginlibException& ex) + { + const std::vector& classes = planner_plugin_loader->getDeclaredClasses(); + std::stringstream ss; + for (std::size_t i = 0; i < classes.size(); ++i) + ss << classes[i] << " "; + ROS_ERROR_STREAM_NAMED(NODE_NAME, "Exception while loading planner '" << planner_plugin_name << "': " << ex.what() + << std::endl + << "Available plugins: " << ss.str()); + } + + // Creat planning context + // ======================================================================================== + planning_interface::PlanningContextPtr context = + planner_instance->getPlanningContext(planning_scene, req, res.error_code_); + + context->solve(res); + EXPECT_EQ(res.error_code_.val, res.error_code_.SUCCESS); + + moveit_msgs::MotionPlanResponse response; + res.getMessage(response); + + // Check the difference between the last step in the solution and the goal + // ======================================================================================== + std::vector joints_values_last_step = response.trajectory.joint_trajectory.points.back().positions; + + for (std::size_t joint_index = 0; joint_index < joints_values_last_step.size(); ++joint_index) + { + double goal_error = + abs(joints_values_last_step[joint_index] - req.goal_constraints[0].joint_constraints[joint_index].position); + std::cerr << "goal_error: " << goal_error << std::endl; + EXPECT_LT(goal_error, GOAL_TOLERANCE); + } +} + +int main(int argc, char** argv) +{ + testing::InitGoogleTest(&argc, argv); + ros::init(argc, argv, "trajectory_test"); + + ros::AsyncSpinner spinner(1); + spinner.start(); + + int result = RUN_ALL_TESTS(); + ros::shutdown(); + + return result; +} diff --git a/moveit_planners/trajopt/trajopt_interface/test/trajectory_test.test b/moveit_planners/trajopt/trajopt_interface/test/trajectory_test.test new file mode 100644 index 0000000000..36314b49b5 --- /dev/null +++ b/moveit_planners/trajopt/trajopt_interface/test/trajectory_test.test @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/moveit_planners/trajopt/trajopt_interface/trajopt_interface_plugin_description.xml b/moveit_planners/trajopt/trajopt_interface/trajopt_interface_plugin_description.xml new file mode 100644 index 0000000000..051864285a --- /dev/null +++ b/moveit_planners/trajopt/trajopt_interface/trajopt_interface_plugin_description.xml @@ -0,0 +1,7 @@ + + + + The trajopt motion planner plugin which implements sequential convex optimization to solve motion planning problem. + + + diff --git a/moveit_planners/trajopt/trajopt_sco/3rdpartylib/bpmpd_linux32.a b/moveit_planners/trajopt/trajopt_sco/3rdpartylib/bpmpd_linux32.a new file mode 100644 index 0000000000..52720f64e7 Binary files /dev/null and b/moveit_planners/trajopt/trajopt_sco/3rdpartylib/bpmpd_linux32.a differ diff --git a/moveit_planners/trajopt/trajopt_sco/3rdpartylib/bpmpd_linux64.a b/moveit_planners/trajopt/trajopt_sco/3rdpartylib/bpmpd_linux64.a new file mode 100644 index 0000000000..8c39248887 Binary files /dev/null and b/moveit_planners/trajopt/trajopt_sco/3rdpartylib/bpmpd_linux64.a differ diff --git a/moveit_planners/trajopt/trajopt_sco/CMakeLists.txt b/moveit_planners/trajopt/trajopt_sco/CMakeLists.txt new file mode 100644 index 0000000000..14826bab2b --- /dev/null +++ b/moveit_planners/trajopt/trajopt_sco/CMakeLists.txt @@ -0,0 +1,139 @@ +cmake_minimum_required(VERSION 2.8.3) +project(trajopt_sco) + +add_compile_options(-std=c++11 -Wall -Wextra) + +set(osqp_DIR "/home/omid/osqp/build") +message(WARNING "osqp_dir ---------------> ${osqp_DIR}") + +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/") +find_package(catkin REQUIRED COMPONENTS trajopt_utils) +find_package(GUROBI QUIET) +find_package(osqp) +find_package(qpOASES QUIET) +find_package(Eigen3 REQUIRED) + + +find_package(PkgConfig REQUIRED) +pkg_check_modules(JSONCPP jsoncpp) + +set(SCO_SOURCE_FILES + src/solver_interface.cpp + src/solver_utils.cpp + src/modeling.cpp + src/expr_ops.cpp + src/expr_vec_ops.cpp + src/optimizers.cpp + src/modeling_utils.cpp + src/num_diff.cpp +) + +if (NOT APPLE) + set (HAVE_BPMPD TRUE) +endif() + +catkin_package( + INCLUDE_DIRS + include + LIBRARIES + ${PROJECT_NAME} + CATKIN_DEPENDS trajopt_utils + DEPENDS + EIGEN3 +) + +include_directories( + include + ${catkin_INCLUDE_DIRS} + SYSTEM ${EIGEN3_INCLUDE_DIRS} + SYSTEM ${JSONCPP_INCLUDE_DIRS} +) + +if (HAVE_BPMPD) + add_executable(bpmpd_caller src/bpmpd_caller.cpp) + + if( CMAKE_SIZEOF_VOID_P EQUAL 8 ) # 64 bits + set(BPMPD_LIBRARY "${CMAKE_CURRENT_SOURCE_DIR}/3rdpartylib/bpmpd_linux64.a") + else() + set(BPMPD_LIBRARY "${CMAKE_CURRENT_SOURCE_DIR}/3rdpartylib/bpmpd_linux32.a") + endif() + + target_link_libraries(bpmpd_caller ${BPMPD_LIBRARY} -static) + target_compile_options(bpmpd_caller PRIVATE -Wsuggest-override -Wconversion -Wsign-conversion) + + list(APPEND SCO_SOURCE_FILES src/bpmpd_interface.cpp) + set_property(SOURCE src/bpmpd_interface.cpp APPEND PROPERTY COMPILE_DEFINITIONS BPMPD_CALLER="\\\"${CATKIN_DEVEL_PREFIX}/lib/${PROJECT_NAME}/bpmpd_caller\\\"") + + #TODO: Levi check if this is correct. + set(BPMPD_WORKING_DIR "${CATKIN_DEVEL_PREFIX}/lib/${PROJECT_NAME}/") + set_property(SOURCE src/bpmpd_caller.cpp APPEND PROPERTY COMPILE_DEFINITIONS BPMPD_WORKING_DIR="${BPMPD_WORKING_DIR}") + file(COPY src/bpmpd.par DESTINATION ${BPMPD_WORKING_DIR}) + + set_property(SOURCE src/solver_interface.cpp APPEND PROPERTY COMPILE_DEFINITIONS HAVE_BPMPD) +endif() + +if (GUROBI_FOUND) + include_directories(${GUROBI_INCLUDE_DIR}) + set_property(SOURCE src/solver_interface.cpp APPEND PROPERTY COMPILE_DEFINITIONS HAVE_GUROBI) + list(APPEND SCO_SOURCE_FILES src/gurobi_interface.cpp) +endif(GUROBI_FOUND) + +if (osqp_FOUND) + set_property(SOURCE src/solver_interface.cpp APPEND PROPERTY COMPILE_DEFINITIONS HAVE_OSQP) + list(APPEND SCO_SOURCE_FILES src/osqp_interface.cpp) +endif() + +if (qpOASES_FOUND) + include_directories(${qpOASES_INCLUDE_DIRS}) + set_property(SOURCE src/solver_interface.cpp APPEND PROPERTY COMPILE_DEFINITIONS HAVE_QPOASES) + list(APPEND SCO_SOURCE_FILES src/qpoases_interface.cpp) +endif() + +add_library(${PROJECT_NAME} ${SCO_SOURCE_FILES}) + +set (SCO_LINK_LIBS ${catkin_LIBRARIES} ${CMAKE_DL_LIBS}) +if (GUROBI_FOUND) + list(APPEND SCO_LINK_LIBS ${GUROBI_LIBRARIES}) +endif() +if (HAVE_BPMPD) + list(APPEND SCO_LINK_LIBS ${BPMPD_LIBRARY}) +endif() +if (osqp_FOUND) + target_link_libraries(${PROJECT_NAME} PRIVATE osqp::osqpstatic) +endif() +if (qpOASES_FOUND) + target_link_libraries(${PROJECT_NAME} PRIVATE ${qpOASES_LIBRARIES}) +endif() + +target_link_libraries(${PROJECT_NAME} PRIVATE ${JSONCPP_LIBRARIES}) +target_link_libraries(${PROJECT_NAME} PUBLIC ${SCO_LINK_LIBS}) +target_compile_options(${PROJECT_NAME} PRIVATE -Wsuggest-override -Wconversion -Wsign-conversion) + +# Mark executables and/or libraries for installation +install( + TARGETS ${PROJECT_NAME} + ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} +) + +# Mark cpp header files for installation +install(DIRECTORY include/${PROJECT_NAME}/ + DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION} + FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp" + ) + +if (CATKIN_ENABLE_TESTING) + set(SCO_TEST_SOURCE + test/unit.cpp + test/small-problems-unit.cpp + test/solver-interface-unit.cpp + test/solver-utils-unit.cpp + ) + + catkin_add_gtest(${PROJECT_NAME}-test ${SCO_TEST_SOURCE}) + target_link_libraries(${PROJECT_NAME}-test ${PROJECT_NAME}) + if (osqp_FOUND) + target_link_libraries(${PROJECT_NAME}-test osqp::osqpstatic) + endif() +endif() diff --git a/moveit_planners/trajopt/trajopt_sco/LICENSE b/moveit_planners/trajopt/trajopt_sco/LICENSE new file mode 100644 index 0000000000..9103917b0f --- /dev/null +++ b/moveit_planners/trajopt/trajopt_sco/LICENSE @@ -0,0 +1,11 @@ +Copyright (c) 2013, John Schulman +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 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. + +http://opensource.org/licenses/BSD-2-Clause \ No newline at end of file diff --git a/moveit_planners/trajopt/trajopt_sco/README.md b/moveit_planners/trajopt/trajopt_sco/README.md new file mode 100644 index 0000000000..1c18708b1f --- /dev/null +++ b/moveit_planners/trajopt/trajopt_sco/README.md @@ -0,0 +1,3 @@ +TODO(ommmid): Remove code duplication. +This package temporarily copied into moveit until the repo trajopt_ros does not depend on Tesseract +See ros-industrial-consortium/trajopt_ros#122 \ No newline at end of file diff --git a/moveit_planners/trajopt/trajopt_sco/cmake/Modules/FindGUROBI.cmake b/moveit_planners/trajopt/trajopt_sco/cmake/Modules/FindGUROBI.cmake new file mode 100644 index 0000000000..5a0b849f15 --- /dev/null +++ b/moveit_planners/trajopt/trajopt_sco/cmake/Modules/FindGUROBI.cmake @@ -0,0 +1,43 @@ +# - Try to find GUROBI +# +# This modules reads hints about search locations from the following +# environment variables: +# GUROBI_HOME +# +# e.g. GUROBI_HOME=/opt/gurobobi810/linux64 +# +# The module will define: +# GUROBI_FOUND - If we found Gurobi in the system +# GUROBI_INCLUDE_DIR - Gurobi include directories +# GUROBI_LIBRARIES - libraries needed to use Gurobi +# +# This module will NOT enforce a specific GUROBI version, rather it will +# only work with latest GUROBI version (8.1.0) + +find_path(GUROBI_INCLUDE_DIR NAMES gurobi_c++.h + HINTS + ENV GUROBI_HOME + PATH_SUFFIXES include + ) + +find_library(GUROBI_LIBRARY NAMES gurobi81 + HINTS + ENV GUROBI_HOME + PATH_SUFFIXES lib + ) + +find_library(GUROBI_CXX_LIBRARY NAMES gurobi_c++ + HINTS + ENV GUROBI_HOME + PATH_SUFFIXES lib + ) + +set(GUROBI_LIBRARIES ${GUROBI_LIBRARY} ${GUROBI_CXX_LIBRARY}) + +include(FindPackageHandleStandardArgs) +# handle the QUIETLY and REQUIRED arguments and set GUROBI_FOUND to TRUE +# if all listed variables are TRUE +find_package_handle_standard_args(GUROBI DEFAULT_MSG + GUROBI_LIBRARY GUROBI_CXX_LIBRARY GUROBI_INCLUDE_DIR) + +mark_as_advanced(GUROBI_INCLUDE_DIR GUROBI_LIBRARY GUROBI_CXX_LIBRARY GUROBI_LIBRARIES) diff --git a/moveit_planners/trajopt/trajopt_sco/cmake/Modules/FindqpOASES.cmake b/moveit_planners/trajopt/trajopt_sco/cmake/Modules/FindqpOASES.cmake new file mode 100644 index 0000000000..457824faf3 --- /dev/null +++ b/moveit_planners/trajopt/trajopt_sco/cmake/Modules/FindqpOASES.cmake @@ -0,0 +1,51 @@ +#.rst: +# FindqpOASES +# ----------- +# +# Try to find the qpOASES library. +# Once done this will define the following variables:: +# +# qpOASES_FOUND - System has qpOASES +# qpOASES_INCLUDE_DIRS - qpOASES include directory +# qpOASES_LIBRARIES - qpOASES libraries +# +# qpOASES does not have an "install" step, and the includes are in the source +# tree, while the libraries are in the build tree. +# Therefore the environment and cmake variables `qpOASES_SOURCE_DIR` and +# `qpOASES_BINARY_DIR` will be used to locate the includes and libraries. + +#============================================================================= +# Copyright 2014 iCub Facility, Istituto Italiano di Tecnologia +# Authors: Daniele E. Domenichelli +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of YCM, substitute the full +# License text for the above reference.) + + +include(FindPackageHandleStandardArgs) + +find_path(qpOASES_INCLUDEDIR + NAMES qpOASES.hpp + HINTS "${qpOASES_SOURCE_DIR}" + ENV qpOASES_SOURCE_DIR + PATH_SUFFIXES include) +find_library(qpOASES_LIB + NAMES qpOASES + HINTS "${qpOASES_BINARY_DIR}" + ENV qpOASES_BINARY_DIR + PATH_SUFFIXES lib + libs) + +set(qpOASES_INCLUDE_DIRS ${qpOASES_INCLUDEDIR}) +set(qpOASES_LIBRARIES ${qpOASES_LIB}) + +find_package_handle_standard_args(qpOASES DEFAULT_MSG qpOASES_LIBRARIES + qpOASES_INCLUDE_DIRS) +set(qpOASES_FOUND ${QPOASES_FOUND}) diff --git a/moveit_planners/trajopt/trajopt_sco/include/trajopt_sco/bpmpd_interface.hpp b/moveit_planners/trajopt/trajopt_sco/include/trajopt_sco/bpmpd_interface.hpp new file mode 100644 index 0000000000..e0516e880d --- /dev/null +++ b/moveit_planners/trajopt/trajopt_sco/include/trajopt_sco/bpmpd_interface.hpp @@ -0,0 +1,40 @@ +#pragma once +#include +#include + +namespace sco +{ +class BPMPDModel : public Model +{ +public: + VarVector m_vars; + CntVector m_cnts; + AffExprVector m_cntExprs; + ConstraintTypeVector m_cntTypes; + DblVec m_soln; + DblVec m_lbs, m_ubs; + + QuadExpr m_objective; + + int m_pipeIn, m_pipeOut, m_pid; + + BPMPDModel(); + ~BPMPDModel() override; + + Var addVar(const std::string& name) override; + Cnt addEqCnt(const AffExpr&, const std::string& name) override; + Cnt addIneqCnt(const AffExpr&, const std::string& name) override; + Cnt addIneqCnt(const QuadExpr&, const std::string& name) override; + void removeVars(const VarVector& vars) override; + void removeCnts(const CntVector& cnts) override; + + void update() override; + void setVarBounds(const VarVector& vars, const DblVec& lower, const DblVec& upper) override; + DblVec getVarValues(const VarVector& vars) const override; + virtual CvxOptStatus optimize() override; + virtual void setObjective(const AffExpr&) override; + virtual void setObjective(const QuadExpr&) override; + virtual void writeToFile(const std::string& fname) override; + virtual VarVector getVars() const override; +}; +} diff --git a/moveit_planners/trajopt/trajopt_sco/include/trajopt_sco/bpmpd_io.hpp b/moveit_planners/trajopt/trajopt_sco/include/trajopt_sco/bpmpd_io.hpp new file mode 100644 index 0000000000..a9c296970a --- /dev/null +++ b/moveit_planners/trajopt/trajopt_sco/include/trajopt_sco/bpmpd_io.hpp @@ -0,0 +1,158 @@ +#pragma once +#include +TRAJOPT_IGNORE_WARNINGS_PUSH +#include +#include +#include +#include +#include +#include +TRAJOPT_IGNORE_WARNINGS_POP + +namespace bpmpd_io +{ +enum SerMode +{ + DESER, + SER +}; + +template +void ser(int fp, T& x, SerMode mode) +{ + switch (mode) + { + case SER: + { + T xcopy = x; + long n = write(fp, &xcopy, sizeof(T)); + assert(n == sizeof(T)); + break; + } + case DESER: + { + long n = read(fp, &x, sizeof(T)); + assert(n == sizeof(T)); + break; + } + } +} + +template +void ser(int fp, std::vector& x, SerMode mode) +{ + unsigned long size = x.size(); + ser(fp, size, mode); + switch (mode) + { + case SER: + { + long n = write(fp, x.data(), sizeof(T) * size); + assert(static_cast(n) == sizeof(T) * size); + break; + } + case DESER: + { + x.resize(size); + long n = read(fp, x.data(), sizeof(T) * size); + assert(static_cast(n) == sizeof(T) * size); + break; + } + } +} + +struct bpmpd_input +{ + int m, n, nz, qn, qnz; + std::vector acolcnt, acolidx; + std::vector acolnzs; + std::vector qcolcnt, qcolidx; + std::vector qcolnzs; + std::vector rhs, obj, lbound, ubound; + + bpmpd_input() + { + } + bpmpd_input(int m, int n, int nz, int qn, int qnz, const std::vector& acolcnt, const std::vector& acolidx, + const std::vector& acolnzs, const std::vector& qcolcnt, const std::vector& qcolidx, + const std::vector& qcolnzs, const std::vector& rhs, const std::vector& obj, + const std::vector& lbound, const std::vector& ubound) + : m(m) + , n(n) + , nz(nz) + , qn(qn) + , qnz(qnz) + , acolcnt(acolcnt) + , acolidx(acolidx) + , acolnzs(acolnzs) + , qcolcnt(qcolcnt) + , qcolidx(qcolidx) + , qcolnzs(qcolnzs) + , rhs(rhs) + , obj(obj) + , lbound(lbound) + , ubound(ubound) + { + } +}; + +const char EXIT_CHAR = 123; +const char CHECK_CHAR = 111; + +void ser(int fp, bpmpd_input& bi, SerMode mode) +{ + char scorrect = 'z', s = (mode == SER) ? scorrect : 0; + ser(fp, s, mode); + if (s == EXIT_CHAR) + { + exit(0); + } + + ser(fp, bi.m, mode); + ser(fp, bi.n, mode); + ser(fp, bi.nz, mode); + ser(fp, bi.qn, mode); + ser(fp, bi.qnz, mode); + ser(fp, bi.acolcnt, mode); + ser(fp, bi.acolidx, mode); + ser(fp, bi.acolnzs, mode); + ser(fp, bi.qcolcnt, mode); + ser(fp, bi.qcolidx, mode); + ser(fp, bi.qcolnzs, mode); + ser(fp, bi.rhs, mode); + ser(fp, bi.obj, mode); + ser(fp, bi.lbound, mode); + ser(fp, bi.ubound, mode); +} + +struct bpmpd_output +{ + std::vector primal, dual; + std::vector status; + int code; + double opt; + bpmpd_output() + { + } + bpmpd_output(const std::vector& primal, const std::vector& dual, const std::vector& status, + int code, double opt) + : primal(primal), dual(dual), status(status), code(code), opt(opt) + { + } +}; + +void ser(int fp, bpmpd_output& bo, SerMode mode) +{ + char scorrect = CHECK_CHAR, s = (mode == SER) ? scorrect : 0; + ser(fp, s, mode); + if (s == EXIT_CHAR) + { + exit(0); + } + ser(fp, bo.primal, mode); + ser(fp, bo.dual, mode); + ser(fp, bo.status, mode); + ser(fp, bo.code, mode); + ser(fp, bo.opt, mode); +} +} diff --git a/moveit_planners/trajopt/trajopt_sco/include/trajopt_sco/expr_op_overloads.hpp b/moveit_planners/trajopt/trajopt_sco/include/trajopt_sco/expr_op_overloads.hpp new file mode 100644 index 0000000000..70e89ad02e --- /dev/null +++ b/moveit_planners/trajopt/trajopt_sco/include/trajopt_sco/expr_op_overloads.hpp @@ -0,0 +1,136 @@ +#pragma once +#include + +namespace sco +{ +inline AffExpr operator+(const Var& x, double y) +{ + return exprAdd(AffExpr(x), y); +} +inline AffExpr operator+(const AffExpr& x, double y) +{ + return exprAdd(x, y); +} +inline QuadExpr operator+(const QuadExpr& x, double y) +{ + return exprAdd(x, y); +} +inline AffExpr operator+(const Var& x, const Var& y) +{ + return exprAdd(AffExpr(x), y); +} +inline AffExpr operator+(const AffExpr& x, const Var& y) +{ + return exprAdd(x, y); +} +inline QuadExpr operator+(const QuadExpr& x, const Var& y) +{ + return exprAdd(x, y); +} +inline AffExpr operator+(const Var& x, const AffExpr& y) +{ + return exprAdd(AffExpr(x), y); +} +inline AffExpr operator+(const AffExpr& x, const AffExpr& y) +{ + return exprAdd(x, y); +} +inline QuadExpr operator+(const QuadExpr& x, const AffExpr& y) +{ + return exprAdd(x, y); +} +inline QuadExpr operator+(const Var& x, const QuadExpr& y) +{ + return exprAdd(QuadExpr(x), y); +} +inline QuadExpr operator+(const AffExpr& x, const QuadExpr& y) +{ + return exprAdd(QuadExpr(x), y); +} +inline QuadExpr operator+(const QuadExpr& x, const QuadExpr& y) +{ + return exprAdd(x, y); +} +inline AffExpr operator-(const Var& x, double y) +{ + return exprSub(AffExpr(x), y); +} +inline AffExpr operator-(const AffExpr& x, double y) +{ + return exprSub(x, y); +} +inline QuadExpr operator-(const QuadExpr& x, double y) +{ + return exprSub(x, y); +} +inline AffExpr operator-(const Var& x, const Var& y) +{ + return exprSub(AffExpr(x), y); +} +inline AffExpr operator-(const AffExpr& x, const Var& y) +{ + return exprSub(x, y); +} +inline QuadExpr operator-(const QuadExpr& x, const Var& y) +{ + return exprSub(x, y); +} +inline AffExpr operator-(const Var& x, const AffExpr& y) +{ + return exprSub(AffExpr(x), y); +} +inline AffExpr operator-(const AffExpr& x, const AffExpr& y) +{ + return exprSub(x, y); +} +inline QuadExpr operator-(const QuadExpr& x, const AffExpr& y) +{ + return exprSub(x, y); +} +inline QuadExpr operator-(const Var& x, const QuadExpr& y) +{ + return exprSub(QuadExpr(x), y); +} +inline QuadExpr operator-(const AffExpr& x, const QuadExpr& y) +{ + return exprSub(QuadExpr(x), y); +} +inline QuadExpr operator-(const QuadExpr& x, const QuadExpr& y) +{ + return exprSub(x, y); +} +/////////////// + +inline AffExpr operator*(double a, const Var& b) +{ + return exprMult(b, a); +} +inline AffExpr operator*(double a, const AffExpr& b) +{ + return exprMult(b, a); +} +inline QuadExpr operator*(double a, const QuadExpr& b) +{ + return exprMult(b, a); +} +inline AffExpr operator*(const Var& a, double b) +{ + return exprMult(a, b); +} +inline AffExpr operator*(const AffExpr& a, double b) +{ + return exprMult(a, b); +} +inline QuadExpr operator*(const QuadExpr& a, double b) +{ + return exprMult(a, b); +} +inline AffExpr operator-(const Var& a) +{ + return exprMult(a, -1); +} +inline AffExpr operator-(const AffExpr& a) +{ + return exprMult(a, -1); +} +} diff --git a/moveit_planners/trajopt/trajopt_sco/include/trajopt_sco/expr_ops.hpp b/moveit_planners/trajopt/trajopt_sco/include/trajopt_sco/expr_ops.hpp new file mode 100644 index 0000000000..bb934c6131 --- /dev/null +++ b/moveit_planners/trajopt/trajopt_sco/include/trajopt_sco/expr_ops.hpp @@ -0,0 +1,193 @@ +#pragma once +#include +#include + +namespace sco +{ +////// In-place operations /////// + +// multiplication +inline void exprScale(AffExpr& v, double a) +{ + v.constant *= a; + for (unsigned i = 0; i < v.coeffs.size(); ++i) + v.coeffs[i] *= a; +} +inline void exprScale(QuadExpr& q, double a) +{ + exprScale(q.affexpr, a); + for (unsigned i = 0; i < q.coeffs.size(); ++i) + q.coeffs[i] *= a; +} + +// addition +inline void exprInc(AffExpr& a, double b) +{ + a.constant += b; +} +inline void exprInc(AffExpr& a, const AffExpr& b) +{ + a.constant += b.constant; + a.coeffs.insert(a.coeffs.end(), b.coeffs.begin(), b.coeffs.end()); + a.vars.insert(a.vars.end(), b.vars.begin(), b.vars.end()); +} +inline void exprInc(AffExpr& a, const Var& b) +{ + exprInc(a, AffExpr(b)); +} +inline void exprInc(QuadExpr& a, double b) +{ + exprInc(a.affexpr, b); +} +inline void exprInc(QuadExpr& a, const Var& b) +{ + exprInc(a.affexpr, AffExpr(b)); +} +inline void exprInc(QuadExpr& a, const AffExpr& b) +{ + exprInc(a.affexpr, b); +} +inline void exprInc(QuadExpr& a, const QuadExpr& b) +{ + exprInc(a.affexpr, b.affexpr); + a.coeffs.insert(a.coeffs.end(), b.coeffs.begin(), b.coeffs.end()); + a.vars1.insert(a.vars1.end(), b.vars1.begin(), b.vars1.end()); + a.vars2.insert(a.vars2.end(), b.vars2.begin(), b.vars2.end()); +} + +// subtraction +inline void exprDec(AffExpr& a, double b) +{ + a.constant -= b; +} +inline void exprDec(AffExpr& a, AffExpr b) +{ + exprScale(b, -1); + exprInc(a, b); +} +inline void exprDec(AffExpr& a, const Var& b) +{ + exprDec(a, AffExpr(b)); +} +inline void exprDec(QuadExpr& a, double b) +{ + exprDec(a.affexpr, b); +} +inline void exprDec(QuadExpr& a, const Var& b) +{ + exprDec(a.affexpr, b); +} +inline void exprDec(QuadExpr& a, const AffExpr& b) +{ + exprDec(a.affexpr, b); +} +inline void exprDec(QuadExpr& a, QuadExpr b) +{ + exprScale(b, -1); + exprInc(a, b); +} + +///////////////////// + +inline AffExpr exprMult(const Var& a, double b) +{ + AffExpr c(a); + exprScale(c, b); + return c; +} +// multiplication +inline AffExpr exprMult(AffExpr a, double b) +{ + exprScale(a, b); + return a; +} +inline QuadExpr exprMult(QuadExpr a, double b) +{ + exprScale(a, b); + return a; +} + +inline AffExpr exprAdd(AffExpr a, double b) +{ + exprInc(a, b); + return a; +} +inline AffExpr exprAdd(AffExpr a, const Var& b) +{ + exprInc(a, b); + return a; +} +inline AffExpr exprAdd(AffExpr a, const AffExpr& b) +{ + exprInc(a, b); + return a; +} +inline QuadExpr exprAdd(QuadExpr a, double b) +{ + exprInc(a, b); + return a; +} +inline QuadExpr exprAdd(QuadExpr a, const Var& b) +{ + exprInc(a, b); + return a; +} +inline QuadExpr exprAdd(QuadExpr a, const AffExpr& b) +{ + exprInc(a, b); + return a; +} +inline QuadExpr exprAdd(QuadExpr a, const QuadExpr& b) +{ + exprInc(a, b); + return a; +} + +inline AffExpr exprSub(AffExpr a, double b) +{ + exprDec(a, b); + return a; +} +inline AffExpr exprSub(AffExpr a, const Var& b) +{ + exprDec(a, b); + return a; +} +inline AffExpr exprSub(AffExpr a, const AffExpr& b) +{ + exprDec(a, b); + return a; +} +inline QuadExpr exprSub(QuadExpr a, double b) +{ + exprDec(a, b); + return a; +} +inline QuadExpr exprSub(QuadExpr a, const Var& b) +{ + exprDec(a, b); + return a; +} +inline QuadExpr exprSub(QuadExpr a, const AffExpr& b) +{ + exprDec(a, b); + return a; +} +inline QuadExpr exprSub(QuadExpr a, const QuadExpr& b) +{ + exprDec(a, b); + return a; +} + +////////////////////// +/** + * @brief Multiplies two AffExpr. Does not consider any optimizations for shared variables + * @return The QuadExpr result of the multiplication + */ +QuadExpr exprMult(const AffExpr&, const AffExpr&); + +QuadExpr exprSquare(const Var&); +QuadExpr exprSquare(const AffExpr&); + +AffExpr cleanupAff(const AffExpr&); +} diff --git a/moveit_planners/trajopt/trajopt_sco/include/trajopt_sco/expr_vec_ops.hpp b/moveit_planners/trajopt/trajopt_sco/include/trajopt_sco/expr_vec_ops.hpp new file mode 100644 index 0000000000..050cea9a95 --- /dev/null +++ b/moveit_planners/trajopt/trajopt_sco/include/trajopt_sco/expr_vec_ops.hpp @@ -0,0 +1,30 @@ +#pragma once +#include +TRAJOPT_IGNORE_WARNINGS_PUSH +#include +TRAJOPT_IGNORE_WARNINGS_POP + +#include + +namespace sco +{ +#if 0 +Matrix3d leftCrossProdMat(const Vector3d& x); +Matrix3d rightCrossProdMat(const Vector3d& x); + +ExprVector exprMatMult(const MatrixXd& A, const VarVector& x); +ExprVector exprMatMult(const MatrixXd& A, const ExprVector& x); + +ExprVector exprCross(const VectorXd& x, const VarVector& y); +ExprVector exprCross(const VarVector& x, const VectorXd& y); +ExprVector exprCross(const VectorXd& x, const ExprVector& y); +ExprVector exprCross(const ExprVector& x, const VectorXd& y); + +#endif +AffExpr varDot(const Eigen::VectorXd& x, const VarVector& v); +AffExpr exprDot(const Eigen::VectorXd& x, const AffExprVector& v); +#if 0 +QuadExpr varNorm2(const VarVector& v); +QuadExpr exprNorm2(const ExprVector& v); +#endif +} diff --git a/moveit_planners/trajopt/trajopt_sco/include/trajopt_sco/gurobi_interface.hpp b/moveit_planners/trajopt/trajopt_sco/include/trajopt_sco/gurobi_interface.hpp new file mode 100644 index 0000000000..39809169ca --- /dev/null +++ b/moveit_planners/trajopt/trajopt_sco/include/trajopt_sco/gurobi_interface.hpp @@ -0,0 +1,53 @@ +#pragma once +#include + +/** + +@file gurobi_interface.hpp + +Gurobi backend + +*/ + +struct _GRBmodel; +typedef struct _GRBmodel GRBmodel; + +namespace sco +{ +class GurobiModel : public Model +{ +public: + GRBmodel* m_model; + VarVector m_vars; + CntVector m_cnts; + + GurobiModel(); + + Var addVar(const std::string& name) override; + Var addVar(const std::string& name, double lower, double upper) override; + + Cnt addEqCnt(const AffExpr&, const std::string& name) override; + Cnt addIneqCnt(const AffExpr&, const std::string& name) override; + Cnt addIneqCnt(const QuadExpr&, const std::string& name) override; + + void removeVars(const VarVector&) override; + void removeCnts(const CntVector&) override; + + void update() override; + void setVarBounds(const VarVector&, const DblVec& lower, const DblVec& upper) override; + DblVec getVarValues(const VarVector&) const override; + + CvxOptStatus optimize() override; + /** Don't use this function, because it adds constraints that aren't tracked + */ + CvxOptStatus optimizeFeasRelax(); + + void setObjective(const AffExpr&) override; + void setObjective(const QuadExpr&) override; + void writeToFile(const std::string& fname) override; + + VarVector getVars() const override; + + ~GurobiModel(); +}; +} diff --git a/moveit_planners/trajopt/trajopt_sco/include/trajopt_sco/modeling.hpp b/moveit_planners/trajopt/trajopt_sco/include/trajopt_sco/modeling.hpp new file mode 100644 index 0000000000..0db00f76f4 --- /dev/null +++ b/moveit_planners/trajopt/trajopt_sco/include/trajopt_sco/modeling.hpp @@ -0,0 +1,325 @@ +#pragma once + +/* + * Model a non-convex optimization problem by defining Cost and Constraint + * objects + * which know how to generate a convex approximation + * + * + */ +#include +TRAJOPT_IGNORE_WARNINGS_PUSH +#include +TRAJOPT_IGNORE_WARNINGS_POP + +#include +#include + +namespace sco +{ +/** +Stores convex terms in a objective +For non-quadratic terms like hinge(x) and abs(x), it needs to add auxilliary +variables and linear constraints to the model +Note: When this object is deleted, the constraints and variables it added to the +model are removed + */ +class ConvexObjective +{ +public: + ConvexObjective(Model* model) : model_(model) + { + } + void addAffExpr(const AffExpr&); + void addQuadExpr(const QuadExpr&); + void addHinge(const AffExpr&, double coeff); + void addAbs(const AffExpr&, double coeff); + void addHinges(const AffExprVector&); + void addL1Norm(const AffExprVector&); + void addL2Norm(const AffExprVector&); + void addMax(const AffExprVector&); + + bool inModel() + { + return model_ != nullptr; + } + void addConstraintsToModel(); + void removeFromModel(); + double value(const DblVec& x); + + ~ConvexObjective(); + + Model* model_; + QuadExpr quad_; + VarVector vars_; + AffExprVector eqs_; + AffExprVector ineqs_; + CntVector cnts_; + +private: + ConvexObjective() + { + } + ConvexObjective(ConvexObjective&) + { + } +}; + +/** +Stores convex inequality constraints and affine equality constraints. +Actually only affine inequality constraints are currently implemented. +*/ +class ConvexConstraints +{ +public: + ConvexConstraints(Model* model) : model_(model) + { + } + /** Expression that should == 0 */ + void addEqCnt(const AffExpr&); + /** Expression that should <= 0 */ + void addIneqCnt(const AffExpr&); + void setModel(Model* model) + { + assert(!inModel()); + model_ = model; + } + bool inModel() + { + return model_ != nullptr; + } + void addConstraintsToModel(); + void removeFromModel(); + + DblVec violations(const DblVec& x); + double violation(const DblVec& x); + + ~ConvexConstraints(); + AffExprVector eqs_; + AffExprVector ineqs_; + +private: + Model* model_; + CntVector cnts_; + ConvexConstraints() : model_(nullptr) + { + } + ConvexConstraints(ConvexConstraints&) + { + } +}; + +/** +Non-convex cost function, which knows how to calculate its convex approximation +(convexify() method) +*/ +class Cost +{ +public: + /** Evaluate at solution vector x*/ + virtual double value(const DblVec&) = 0; + /** Convexify at solution vector x*/ + virtual ConvexObjectivePtr convex(const DblVec& x, Model* model) = 0; + /** Get problem variables associated with this cost */ + virtual VarVector getVars() = 0; + std::string name() + { + return name_; + } + void setName(const std::string& name) + { + name_ = name; + } + Cost() : name_("unnamed") + { + } + Cost(const std::string& name) : name_(name) + { + } + virtual ~Cost() = default; + +protected: + std::string name_; +}; + +/** +Non-convex vector-valued constraint function, which knows how to calculate its +convex approximation +*/ +class Constraint +{ +public: + /** inequality vs equality */ + virtual ConstraintType type() = 0; + /** Evaluate at solution vector x*/ + virtual DblVec value(const DblVec& x) = 0; + /** Convexify at solution vector x*/ + virtual ConvexConstraintsPtr convex(const DblVec& x, Model* model) = 0; + /** Calculate constraint violations (positive part for inequality constraint, + * absolute value for inequality constraint)*/ + DblVec violations(const DblVec& x); + /** Sum of violations */ + double violation(const DblVec& x); + /** Get problem variables associated with this constraint */ + virtual VarVector getVars() = 0; + std::string name() + { + return name_; + } + void setName(const std::string& name) + { + name_ = name; + } + Constraint() : name_("unnamed") + { + } + Constraint(const std::string& name) : name_(name) + { + } + virtual ~Constraint() + { + } + +protected: + std::string name_; +}; + +class EqConstraint : public Constraint +{ +public: + ConstraintType type() override + { + return EQ; + } + EqConstraint() : Constraint() + { + } + EqConstraint(const std::string& name) : Constraint(name) + { + } +}; + +class IneqConstraint : public Constraint +{ +public: + ConstraintType type() override + { + return INEQ; + } + IneqConstraint() : Constraint() + { + } + IneqConstraint(const std::string& name) : Constraint(name) + { + } +}; + +/** +Non-convex optimization problem +*/ +class OptProb +{ +public: + OptProb(ModelType convex_solver = ModelType::AUTO_SOLVER); + virtual ~OptProb() = default; + + /** create variables with bounds [-INFINITY, INFINITY] */ + VarVector createVariables(const std::vector& names); + /** create variables with bounds [lb[i], ub[i] */ + VarVector createVariables(const std::vector& names, const DblVec& lb, const DblVec& ub); + /** set the lower bounds of all the variables */ + void setLowerBounds(const DblVec& lb); + /** set the upper bounds of all the variables */ + void setUpperBounds(const DblVec& ub); + /** set lower bounds of some of the variables */ + void setLowerBounds(const DblVec& lb, const VarVector& vars); + /** set upper bounds of some of the variables */ + void setUpperBounds(const DblVec& ub, const VarVector& vars); + /** Note: in the current implementation, this function just adds the + * constraint to the + * model. So if you're not careful, you might end up with an infeasible + * problem. */ + void addLinearConstraint(const AffExpr&, ConstraintType type); + /** Add nonlinear cost function */ + void addCost(CostPtr); + /** Add nonlinear constraint function */ + void addConstraint(ConstraintPtr); + void addEqConstraint(ConstraintPtr); + void addIneqConstraint(ConstraintPtr); + /** Find closest point to solution vector x that satisfies linear inequality + * constraints */ + DblVec getCentralFeasiblePoint(const DblVec& x); + DblVec getClosestFeasiblePoint(const DblVec& x); + + std::vector getConstraints() const; + const std::vector& getCosts() + { + return costs_; + } + const std::vector& getIneqConstraints() + { + return ineqcnts_; + } + const std::vector& getEqConstraints() + { + return eqcnts_; + } + const DblVec& getLowerBounds() + { + return lower_bounds_; + } + const DblVec& getUpperBounds() + { + return upper_bounds_; + } + ModelPtr getModel() + { + return model_; + } + const VarVector& getVars() + { + return vars_; + } + int getNumCosts() + { + return static_cast(costs_.size()); + } + int getNumConstraints() + { + return static_cast(eqcnts_.size() + ineqcnts_.size()); + } + int getNumVars() + { + return static_cast(vars_.size()); + } + +protected: + ModelPtr model_; + VarVector vars_; + DblVec lower_bounds_; + DblVec upper_bounds_; + std::vector costs_; + std::vector eqcnts_; + std::vector ineqcnts_; + + OptProb(OptProb&); +}; + +template +inline void setVec(DblVec& x, const VarVector& vars, const VecType& vals) +{ + assert(vars.size() == vals.size()); + for (size_t i = 0; i < vars.size(); ++i) + { + x[static_cast(vars[i].var_rep->index)] = vals[i]; + } +} +template +inline OutVecType getVec1(const DblVec& x, const VarVector& vars) +{ + OutVecType out(vars.size()); + for (unsigned i = 0; i < vars.size(); ++i) + out[i] = x[vars[i].var_rep->index]; + return out; +} +} diff --git a/moveit_planners/trajopt/trajopt_sco/include/trajopt_sco/modeling_utils.hpp b/moveit_planners/trajopt/trajopt_sco/include/trajopt_sco/modeling_utils.hpp new file mode 100644 index 0000000000..c8f19e5b69 --- /dev/null +++ b/moveit_planners/trajopt/trajopt_sco/include/trajopt_sco/modeling_utils.hpp @@ -0,0 +1,109 @@ +#pragma once +#include +#include +#include +/** +@file modeling_utils.hpp +@brief Build problem from user-defined functions +Utilities for creating Cost and Constraint objects from functions +using numerical derivatives or user-defined analytic derivatives. + */ + +namespace sco +{ +enum PenaltyType +{ + SQUARED, + ABS, + HINGE +}; + +/** +x is the big solution vector of the whole problem. vars are variables that +index into the vector x +this function extracts (from x) the values of the variables in vars + */ +Eigen::VectorXd getVec(const DblVec& x, const VarVector& vars); +/** +Same idea as above, but different output type + */ +DblVec getDblVec(const DblVec& x, const VarVector& vars); + +AffExpr affFromValGrad(double y, const Eigen::VectorXd& x, const Eigen::VectorXd& dydx, const VarVector& vars); + +class CostFromFunc : public Cost +{ +public: + /// supply function, obtain derivative and hessian numerically + CostFromFunc(ScalarOfVectorPtr f, const VarVector& vars, const std::string& name, bool full_hessian = false); + double value(const DblVec& x) override; + ConvexObjectivePtr convex(const DblVec& x, Model* model) override; + VarVector getVars() override + { + return vars_; + } + +protected: + ScalarOfVectorPtr f_; + VarVector vars_; + bool full_hessian_; + double epsilon_; +}; + +class CostFromErrFunc : public Cost +{ +public: + /// supply error function, obtain derivative numerically + CostFromErrFunc(VectorOfVectorPtr f, const VarVector& vars, const Eigen::VectorXd& coeffs, PenaltyType pen_type, + const std::string& name); + /// supply error function and gradient + CostFromErrFunc(VectorOfVectorPtr f, MatrixOfVectorPtr dfdx, const VarVector& vars, const Eigen::VectorXd& coeffs, + PenaltyType pen_type, const std::string& name); + double value(const DblVec& x) override; + ConvexObjectivePtr convex(const DblVec& x, Model* model) override; + VarVector getVars() override + { + return vars_; + } + +protected: + VectorOfVectorPtr f_; + MatrixOfVectorPtr dfdx_; + VarVector vars_; + Eigen::VectorXd coeffs_; + PenaltyType pen_type_; + double epsilon_; +}; + +class ConstraintFromErrFunc : public Constraint +{ +public: + /// supply error function, obtain derivative numerically + ConstraintFromErrFunc(VectorOfVectorPtr f, const VarVector& vars, const Eigen::VectorXd& coeffs, ConstraintType type, + const std::string& name); + /// supply error function and gradient + ConstraintFromErrFunc(VectorOfVectorPtr f, MatrixOfVectorPtr dfdx, const VarVector& vars, + const Eigen::VectorXd& coeffs, ConstraintType type, const std::string& name); + DblVec value(const DblVec& x) override; + ConvexConstraintsPtr convex(const DblVec& x, Model* model) override; + ConstraintType type() override + { + return type_; + } + VarVector getVars() override + { + return vars_; + } + +protected: + VectorOfVectorPtr f_; + MatrixOfVectorPtr dfdx_; + VarVector vars_; + Eigen::VectorXd coeffs_; + ConstraintType type_; + double epsilon_; + Eigen::VectorXd scaling_; +}; + +std::string AffExprToString(const AffExpr& aff); +} diff --git a/moveit_planners/trajopt/trajopt_sco/include/trajopt_sco/num_diff.hpp b/moveit_planners/trajopt/trajopt_sco/include/trajopt_sco/num_diff.hpp new file mode 100644 index 0000000000..388d30562f --- /dev/null +++ b/moveit_planners/trajopt/trajopt_sco/include/trajopt_sco/num_diff.hpp @@ -0,0 +1,79 @@ +#pragma once +#include +TRAJOPT_IGNORE_WARNINGS_PUSH +#include +#include +#include +TRAJOPT_IGNORE_WARNINGS_POP + +/* + * Numerical derivatives + */ + +namespace sco +{ +class ScalarOfVector; +class VectorOfVector; +class MatrixOfVector; +typedef std::shared_ptr ScalarOfVectorPtr; +typedef std::shared_ptr VectorOfVectorPtr; +typedef std::shared_ptr MatrixOfVectorPtr; + +class ScalarOfVector +{ +public: + virtual double operator()(const Eigen::VectorXd& x) const = 0; + double call(const Eigen::VectorXd& x) const + { + return operator()(x); + } + virtual ~ScalarOfVector() + { + } + typedef std::function func; + static ScalarOfVectorPtr construct(const func&); + // typedef VectorXd (*c_func)(const VectorXd&); + // static ScalarOfVectorPtr construct(const c_func&); +}; +class VectorOfVector +{ +public: + virtual Eigen::VectorXd operator()(const Eigen::VectorXd& x) const = 0; + Eigen::VectorXd call(const Eigen::VectorXd& x) const + { + return operator()(x); + } + virtual ~VectorOfVector() + { + } + typedef std::function func; + static VectorOfVectorPtr construct(const func&); + // typedef VectorXd (*c_func)(const VectorXd&); + // static VectorOfVectorPtr construct(const c_func&); +}; +class MatrixOfVector +{ +public: + virtual Eigen::MatrixXd operator()(const Eigen::VectorXd& x) const = 0; + Eigen::MatrixXd call(const Eigen::VectorXd& x) const + { + return operator()(x); + } + virtual ~MatrixOfVector() + { + } + typedef std::function func; + static MatrixOfVectorPtr construct(const func&); + // typedef VectorMatrixXd (*c_func)(const VectorXd&); + // static MatrixOfVectorPtr construct(const c_func&); +}; + +Eigen::VectorXd calcForwardNumGrad(const ScalarOfVector& f, const Eigen::VectorXd& x, double epsilon); +Eigen::MatrixXd calcForwardNumJac(const VectorOfVector& f, const Eigen::VectorXd& x, double epsilon); +void calcGradAndDiagHess(const ScalarOfVector& f, const Eigen::VectorXd& x, double epsilon, double& y, + Eigen::VectorXd& grad, Eigen::VectorXd& hess); +void calcGradHess(ScalarOfVectorPtr f, const Eigen::VectorXd& x, double epsilon, double& y, Eigen::VectorXd& grad, + Eigen::MatrixXd& hess); +VectorOfVectorPtr forwardNumGrad(ScalarOfVectorPtr f, double epsilon); +MatrixOfVectorPtr forwardNumJac(VectorOfVectorPtr f, double epsilon); +} diff --git a/moveit_planners/trajopt/trajopt_sco/include/trajopt_sco/optimizers.hpp b/moveit_planners/trajopt/trajopt_sco/include/trajopt_sco/optimizers.hpp new file mode 100644 index 0000000000..6d4d9a3915 --- /dev/null +++ b/moveit_planners/trajopt/trajopt_sco/include/trajopt_sco/optimizers.hpp @@ -0,0 +1,149 @@ +#pragma once +#include +TRAJOPT_IGNORE_WARNINGS_PUSH +#include +#include +TRAJOPT_IGNORE_WARNINGS_POP + +#include +/* + * Algorithms for non-convex, constrained optimization + */ + +namespace sco +{ +enum OptStatus +{ + OPT_CONVERGED, + OPT_SCO_ITERATION_LIMIT, // hit iteration limit before convergence + OPT_PENALTY_ITERATION_LIMIT, + OPT_FAILED, + INVALID +}; +static const char* OptStatus_strings[] = { "CONVERGED", "SCO_ITERATION_LIMIT", "PENALTY_ITERATION_LIMIT", "FAILED", + "INVALID" }; +inline std::string statusToString(OptStatus status) +{ + return OptStatus_strings[status]; +} +struct OptResults +{ + DblVec x; // solution estimate + OptStatus status; + double total_cost; + DblVec cost_vals; + DblVec cnt_viols; + int n_func_evals, n_qp_solves; + void clear() + { + x.clear(); + status = INVALID; + cost_vals.clear(); + cnt_viols.clear(); + n_func_evals = 0; + n_qp_solves = 0; + } + OptResults() + { + clear(); + } +}; +std::ostream& operator<<(std::ostream& o, const OptResults& r); + +class Optimizer +{ + /* + * Solves an optimization problem + */ +public: + virtual ~Optimizer() = default; + virtual OptStatus optimize() = 0; + virtual void setProblem(OptProbPtr prob) + { + prob_ = prob; + } + void initialize(const DblVec& x); + DblVec& x() + { + return results_.x; + } + OptResults& results() + { + return results_; + } + typedef std::function Callback; + void addCallback(const Callback& f); // called before each iteration +protected: + std::vector callbacks_; + void callCallbacks(); + OptProbPtr prob_; + OptResults results_; +}; + +struct BasicTrustRegionSQPParameters +{ + double improve_ratio_threshold; // minimum ratio true_improve/approx_improve + // to accept step + double min_trust_box_size; // if trust region gets any smaller, exit and + // report convergence + double min_approx_improve; // if model improves less than this, exit and + // report convergence + double min_approx_improve_frac; // if model improves less than this, exit and + // report convergence + double max_iter; // The max number of iterations + double trust_shrink_ratio; // if improvement is less than + // improve_ratio_threshold, shrink trust region by + // this ratio + double trust_expand_ratio; // if improvement is less than + // improve_ratio_threshold, shrink trust region by + // this ratio + double cnt_tolerance; // after convergence of penalty subproblem, if + // constraint violation is less than this, we're done + double max_merit_coeff_increases; // number of times that we jack up penalty + // coefficient + double merit_coeff_increase_ratio; // ratio that we increate coeff each time + double max_time; // not yet implemented + double merit_error_coeff; // initial penalty coefficient + double trust_box_size; // current size of trust region (component-wise) + + BasicTrustRegionSQPParameters(); +}; + +class BasicTrustRegionSQP : public Optimizer +{ + /* + * Alternates between convexifying objectives and constraints and then solving + * convex subproblem + * Uses a merit function to decide whether or not to accept the step + * merit function = objective + merit_err_coeff * | constraint_error | + * Note: sometimes the convexified objectives and constraints lead to an + * infeasible subproblem + * In that case, you should turn them into penalties and solve that problem + * (todo: implement penalty-based sqp that gracefully handles infeasible + * constraints) + */ +public: + BasicTrustRegionSQP(); + BasicTrustRegionSQP(OptProbPtr prob); + void setProblem(OptProbPtr prob) override; + void setParameters(const BasicTrustRegionSQPParameters& param) + { + param_ = param; + } + const BasicTrustRegionSQPParameters& getParameters() const + { + return param_; + } + BasicTrustRegionSQPParameters& getParameters() + { + return param_; + } + OptStatus optimize() override; + +protected: + void adjustTrustRegion(double ratio); + void setTrustBoxConstraints(const DblVec& x); + ModelPtr model_; + BasicTrustRegionSQPParameters param_; +}; +} diff --git a/moveit_planners/trajopt/trajopt_sco/include/trajopt_sco/osqp_interface.hpp b/moveit_planners/trajopt/trajopt_sco/include/trajopt_sco/osqp_interface.hpp new file mode 100644 index 0000000000..b17f7256a7 --- /dev/null +++ b/moveit_planners/trajopt/trajopt_sco/include/trajopt_sco/osqp_interface.hpp @@ -0,0 +1,84 @@ +#pragma once +#include +TRAJOPT_IGNORE_WARNINGS_PUSH +#include +#include +TRAJOPT_IGNORE_WARNINGS_POP + +#include +#include + +namespace sco +{ +/** + * OSQPModel uses the BSD solver OSQP to solve a linearly constrained QP. + * OSQP solves a problem in the form: + * ``` + * min 1/2*x'Px + q'x + * s.t. l <= Ax <= u + * ``` + * + * More informations about the solver are available at: + * https://osqp.org/docs/ + */ +class OSQPModel : public Model +{ + OSQPSettings osqp_settings_; /**< OSQP Settings */ + /** OSQPData. Some fields here (`osp_data_.A` and `osp_data_.P`) are + * automatically allocated by OSQP, but deallocated by us. */ + OSQPData osqp_data_; + /** OSQP Workspace. Memory here is managed by OSQP */ + OSQPWorkspace* osqp_workspace_; + + /** Updates OSQP quadratic cost matrix from QuadExpr expression. + * Transforms QuadExpr objective_ into the OSQP CSC matrix P_ */ + void updateObjective(); + + /** Updates qpOASES constraints from AffExpr expression. + * Transforms AffExpr cntr_exprs_ and box bounds lbs_ and ubs_ into the + * OSQP CSC matrix A_, and vectors lbA_ and ubA_ */ + void updateConstraints(); + + /** Creates or updates the solver and its workspace */ + void createOrUpdateSolver(); + + VarVector vars_; /**< model variables */ + CntVector cnts_; /**< model's constraints sizes */ + DblVec lbs_, ubs_; /**< variables bounds */ + AffExprVector cnt_exprs_; /**< constraints expressions */ + ConstraintTypeVector cnt_types_; /**< constraints types */ + DblVec solution_; /**< optimizizer's solution for current model */ + + std::vector P_row_indices_; /**< row indices for P, CSC format */ + std::vector P_column_pointers_; /**< column pointers for P, CSC format */ + DblVec P_csc_data_; /**< P values in CSC format */ + Eigen::VectorXd q_; /**< linear part of the objective */ + + std::vector A_row_indices_; /**< row indices for constraint matrix, CSC format */ + std::vector A_column_pointers_; /**< column pointers for constraint matrix, CSC format */ + DblVec A_csc_data_; /**< constraint matrix values in CSC format */ + DblVec l_, u_; /**< linear constraints upper and lower limits */ + + QuadExpr objective_; /**< objective QuadExpr expression */ + +public: + OSQPModel(); + virtual ~OSQPModel(); + + Var addVar(const std::string& name) override; + Cnt addEqCnt(const AffExpr&, const std::string& name) override; + Cnt addIneqCnt(const AffExpr&, const std::string& name) override; + Cnt addIneqCnt(const QuadExpr&, const std::string& name) override; + void removeVars(const VarVector& vars) override; + void removeCnts(const CntVector& cnts) override; + + void update() override; + void setVarBounds(const VarVector& vars, const DblVec& lower, const DblVec& upper) override; + DblVec getVarValues(const VarVector& vars) const override; + virtual CvxOptStatus optimize() override; + virtual void setObjective(const AffExpr&) override; + virtual void setObjective(const QuadExpr&) override; + virtual void writeToFile(const std::string& fname) override; + virtual VarVector getVars() const override; +}; +} diff --git a/moveit_planners/trajopt/trajopt_sco/include/trajopt_sco/qpoases_interface.hpp b/moveit_planners/trajopt/trajopt_sco/include/trajopt_sco/qpoases_interface.hpp new file mode 100644 index 0000000000..ddf1ce9153 --- /dev/null +++ b/moveit_planners/trajopt/trajopt_sco/include/trajopt_sco/qpoases_interface.hpp @@ -0,0 +1,95 @@ +#pragma once +#include +TRAJOPT_IGNORE_WARNINGS_PUSH +#include +#include +TRAJOPT_IGNORE_WARNINGS_POP + +#include +#include + +namespace sco +{ +/** + * qpOASESModel uses the LGPL solver qpOASES to solve a linearly constrained QP. + * qpOASES solves a problem in the form: + * ``` + * min 1/2*x'Hx + x'g + * s.t. lb <= x <= ub + * lbA <= Ax <= ubA + * ``` + * + * More informations about the solver are available at: + * https://projects.coin-or.org/qpOASES + */ +class qpOASESModel : public Model +{ + /** pointer to a qpOASES Sequential Quadratic Problem*/ + std::shared_ptr qpoases_problem_; + qpOASES::Options qpoases_options_; /**< qpOASES solver options */ + + qpOASES::SymSparseMat H_; /**< Quadratic cost matrix */ + qpOASES::SparseMatrix A_; /**< Constraints matrix */ + + /** Updates qpOASES Hessian matrix from QuadExpr expression. + * Transforms QuadExpr objective_ into the qpOASES sparse matrix H_*/ + void updateObjective(); + + /** Updates qpOASES constraints from AffExpr expression. + * Transforms AffExpr cntr_exprs_ into the qpOASES sparse matrix A_, and + * vectors lbA_ and ubA_ */ + void updateConstraints(); + + /** + * Instantiates a new qpOASES problem if it has not been instantiated yet + * or if the size of the problem has changed. + * + * @returns true if a new qpOASES problem has been instantiated + */ + bool updateSolver(); + + /** + * Instantiates a new qpOASES problem + */ + void createSolver(); + + VarVector vars_; /**< model variables */ + CntVector cnts_; /**< model's constraints sizes */ + DblVec lb_, ub_; /**< variables bounds */ + AffExprVector cnt_exprs_; /**< constraints expressions */ + ConstraintTypeVector cnt_types_; /**< constraints types */ + DblVec solution_; /**< optimizizer's solution for current model */ + + IntVec H_row_indices_; /**< row indices for Hessian, CSC format */ + IntVec H_column_pointers_; /**< column pointers for Hessian, CSC format */ + DblVec H_csc_data_; /**< Hessian values in CSC format */ + Eigen::VectorXd g_; /**< gradient of the optimization problem */ + + IntVec A_row_indices_; /**< row indices for constraint matrix, CSC format */ + IntVec A_column_pointers_; /**< column pointers for constraint matrix, CSC format */ + DblVec A_csc_data_; /**< constraint matrix values in CSC format */ + DblVec lbA_, ubA_; /**< linear constraints upper and lower limits */ + + QuadExpr objective_; /**< objective QuadExpr expression */ + +public: + qpOASESModel(); + virtual ~qpOASESModel(); + + Var addVar(const std::string& name) override; + Cnt addEqCnt(const AffExpr&, const std::string& name) override; + Cnt addIneqCnt(const AffExpr&, const std::string& name) override; + Cnt addIneqCnt(const QuadExpr&, const std::string& name) override; + void removeVars(const VarVector& vars) override; + void removeCnts(const CntVector& cnts) override; + + void update() override; + void setVarBounds(const VarVector& vars, const DblVec& lower, const DblVec& upper) override; + DblVec getVarValues(const VarVector& vars) const override; + virtual CvxOptStatus optimize() override; + virtual void setObjective(const AffExpr&) override; + virtual void setObjective(const QuadExpr&) override; + virtual void writeToFile(const std::string& fname) override; + virtual VarVector getVars() const override; +}; +} diff --git a/moveit_planners/trajopt/trajopt_sco/include/trajopt_sco/sco_common.hpp b/moveit_planners/trajopt/trajopt_sco/include/trajopt_sco/sco_common.hpp new file mode 100644 index 0000000000..3769654ff7 --- /dev/null +++ b/moveit_planners/trajopt/trajopt_sco/include/trajopt_sco/sco_common.hpp @@ -0,0 +1,61 @@ +#pragma once +#include +TRAJOPT_IGNORE_WARNINGS_PUSH +#include +#include +#include +TRAJOPT_IGNORE_WARNINGS_POP + +#include + +namespace sco +{ +typedef std::vector DblVec; +typedef std::vector IntVec; +typedef std::vector VarVector; +typedef std::vector AffExprVector; +typedef std::vector QuadExprVector; +typedef std::vector CntVector; + +inline double vecSum(const DblVec& v) +{ + double out = 0; + for (unsigned i = 0; i < v.size(); ++i) + out += v[i]; + return out; +} +inline double vecAbsSum(const DblVec& v) +{ + double out = 0; + for (unsigned i = 0; i < v.size(); ++i) + out += fabs(v[i]); + return out; +} +inline double pospart(double x) +{ + return (x > 0) ? x : 0; +} +inline double sq(double x) +{ + return x * x; +} +inline double vecHingeSum(const DblVec& v) +{ + double out = 0; + for (unsigned i = 0; i < v.size(); ++i) + out += pospart(v[i]); + return out; +} +inline double vecMax(const DblVec& v) +{ + return *std::max_element(v.begin(), v.end()); +} +inline double vecDot(const DblVec& a, const DblVec& b) +{ + assert(a.size() == b.size()); + double out = 0; + for (unsigned i = 0; i < a.size(); ++i) + out += a[i] * b[i]; + return out; +} +} diff --git a/moveit_planners/trajopt/trajopt_sco/include/trajopt_sco/sco_fwd.hpp b/moveit_planners/trajopt/trajopt_sco/include/trajopt_sco/sco_fwd.hpp new file mode 100644 index 0000000000..982c8a9ee0 --- /dev/null +++ b/moveit_planners/trajopt/trajopt_sco/include/trajopt_sco/sco_fwd.hpp @@ -0,0 +1,48 @@ +// autogenerated forward declaration header +#pragma once +#include +TRAJOPT_IGNORE_WARNINGS_PUSH +#include +TRAJOPT_IGNORE_WARNINGS_POP + +namespace sco +{ +class GurobiModel; +typedef std::shared_ptr GurobiModelPtr; +class ConvexObjective; +typedef std::shared_ptr ConvexObjectivePtr; +class ConvexConstraints; +typedef std::shared_ptr ConvexConstraintsPtr; +class Cost; +typedef std::shared_ptr CostPtr; +class Constraint; +typedef std::shared_ptr ConstraintPtr; +class EqConstraint; +typedef std::shared_ptr EqConstraintPtr; +class IneqConstraint; +typedef std::shared_ptr IneqConstraintPtr; +class OptProb; +typedef std::shared_ptr OptProbPtr; +class CostFromFunc; +typedef std::shared_ptr CostFromFuncPtr; +class ConstraintFromErrFunc; +typedef std::shared_ptr ConstraintFromFuncPtr; +class Optimizer; +typedef std::shared_ptr OptimizerPtr; +class BasicTrustRegionSQP; +typedef std::shared_ptr BasicTrustRegionSQPPtr; +class Model; +typedef std::shared_ptr ModelPtr; +struct VarRep; +typedef std::shared_ptr VarRepPtr; +struct Var; +typedef std::shared_ptr VarPtr; +struct CntRep; +typedef std::shared_ptr CntRepPtr; +struct Cnt; +typedef std::shared_ptr CntPtr; +struct AffExpr; +typedef std::shared_ptr AffExprPtr; +struct QuadExpr; +typedef std::shared_ptr QuadExprPtr; +} diff --git a/moveit_planners/trajopt/trajopt_sco/include/trajopt_sco/solver_interface.hpp b/moveit_planners/trajopt/trajopt_sco/include/trajopt_sco/solver_interface.hpp new file mode 100644 index 0000000000..6e7ae0b8cc --- /dev/null +++ b/moveit_planners/trajopt/trajopt_sco/include/trajopt_sco/solver_interface.hpp @@ -0,0 +1,247 @@ +#pragma once +#include +TRAJOPT_IGNORE_WARNINGS_PUSH +#include +#include +#include +#include +#include +#include +TRAJOPT_IGNORE_WARNINGS_POP +#include + +/** +@file solver_interface.hpp +@brief Interface to convex solvers + + This is based on Gurobi's nice c++ API (though the SCO Gurobi backend uses the +Gurobi c api). + However, our intention is to allow for different solvers to be used as +backends. + */ + +namespace sco +{ +enum ConstraintType +{ + EQ, + INEQ +}; + +typedef std::vector ConstraintTypeVector; + +enum CvxOptStatus +{ + CVX_SOLVED, + CVX_INFEASIBLE, + CVX_FAILED +}; + +/** @brief Convex optimization problem + +Gotchas: +- after adding a variable, need to call update() before doing anything else with +that variable + + */ +class Model +{ +public: + virtual Var addVar(const std::string& name) = 0; + virtual Var addVar(const std::string& name, double lb, double ub); + + virtual Cnt addEqCnt(const AffExpr&, const std::string& name) = 0; // expr == 0 + virtual Cnt addIneqCnt(const AffExpr&, const std::string& name) = 0; // expr <= 0 + virtual Cnt addIneqCnt(const QuadExpr&, const std::string& name) = 0; // expr <= 0 + + virtual void removeVar(const Var& var); + virtual void removeCnt(const Cnt& cnt); + virtual void removeVars(const VarVector& vars) = 0; + virtual void removeCnts(const CntVector& cnts) = 0; + + virtual void update() = 0; // call after adding/deleting stuff + virtual void setVarBounds(const Var& var, double lower, double upper); + virtual void setVarBounds(const VarVector& vars, const DblVec& lower, const DblVec& upper) = 0; + virtual double getVarValue(const Var& var) const; + virtual DblVec getVarValues(const VarVector& vars) const = 0; + virtual CvxOptStatus optimize() = 0; + + virtual void setObjective(const AffExpr&) = 0; + virtual void setObjective(const QuadExpr&) = 0; + virtual void writeToFile(const std::string& fname) = 0; + + virtual VarVector getVars() const = 0; + + virtual ~Model() + { + } +}; + +struct VarRep +{ + VarRep(int _index, const std::string& _name, void* _creator) + : index(_index), name(_name), removed(false), creator(_creator) + { + } + int index; + std::string name; + bool removed; + void* creator; +}; + +struct Var +{ + VarRep* var_rep; + Var() : var_rep(nullptr) + { + } + Var(VarRep* var_rep) : var_rep(var_rep) + { + } + Var(const Var& other) : var_rep(other.var_rep) + { + } + double value(const double* x) const + { + return x[var_rep->index]; + } + double value(const DblVec& x) const + { + assert(var_rep->index < static_cast(x.size())); + return x[static_cast(var_rep->index)]; + } +}; + +struct CntRep +{ + CntRep(int _index, void* _creator) : index(_index), removed(false), creator(_creator) + { + } + int index; + bool removed; + void* creator; + ConstraintType type; + std::string expr; // todo placeholder +}; + +struct Cnt +{ + CntRep* cnt_rep; + Cnt() : cnt_rep(nullptr) + { + } + Cnt(CntRep* cnt_rep) : cnt_rep(cnt_rep) + { + } + Cnt(const Cnt& other) : cnt_rep(other.cnt_rep) + { + } +}; + +struct AffExpr +{ // affine expression + double constant; + DblVec coeffs; + VarVector vars; + AffExpr() : constant(0) + { + } + explicit AffExpr(double a) : constant(a) + { + } + explicit AffExpr(const Var& v) : constant(0), coeffs(1, 1), vars(1, v) + { + } + AffExpr(const AffExpr& other) : constant(other.constant), coeffs(other.coeffs), vars(other.vars) + { + } + size_t size() const + { + return coeffs.size(); + } + double value(const double* x) const; + double value(const DblVec& x) const; +}; + +struct QuadExpr +{ + AffExpr affexpr; + DblVec coeffs; + VarVector vars1; + VarVector vars2; + QuadExpr() + { + } + explicit QuadExpr(double a) : affexpr(a) + { + } + explicit QuadExpr(const Var& v) : affexpr(v) + { + } + explicit QuadExpr(const AffExpr& aff) : affexpr(aff) + { + } + size_t size() const + { + return coeffs.size(); + } + double value(const double* x) const; + double value(const DblVec& x) const; +}; + +std::ostream& operator<<(std::ostream&, const Var&); +std::ostream& operator<<(std::ostream&, const Cnt&); +std::ostream& operator<<(std::ostream&, const AffExpr&); +std::ostream& operator<<(std::ostream&, const QuadExpr&); + +class ModelType +{ +public: + enum Value + { + GUROBI, + BPMPD, + OSQP, + QPOASES, + AUTO_SOLVER + }; + + static const std::vector MODEL_NAMES_; + + ModelType(); + ModelType(const ModelType::Value& v); + ModelType(const int& v); + ModelType(const std::string& s); + operator int() const; + bool operator==(const ModelType::Value& a) const; + bool operator==(const ModelType& a) const; + bool operator!=(const ModelType& a) const; + void fromJson(const Json::Value& v); + friend std::ostream& operator<<(std::ostream& os, const ModelType& cs); + +private: + Value value_; +}; + +std::vector availableSolvers(); + +std::ostream& operator<<(std::ostream& os, const ModelType& cs); + +ModelPtr createModel(ModelType model_type = ModelType::AUTO_SOLVER); + +IntVec vars2inds(const VarVector& vars); + +IntVec cnts2inds(const CntVector& cnts); + +/** + * @brief simplify2 gets as input a list of indices, corresponding to non-zero + * values in vals, checks that all indexed values are actually non-zero, + * and if they are not, removes them from vals and inds, so that + * inds_out.size() <= inds.size(). Also, it will compact vals so that + * vals_out.size() == inds_out.size() + * + * @param[in,out] inds indices of non-vero variables in vals + * @param[in,out] val values + */ +void simplify2(IntVec& inds, DblVec& vals); +} diff --git a/moveit_planners/trajopt/trajopt_sco/include/trajopt_sco/solver_utils.hpp b/moveit_planners/trajopt/trajopt_sco/include/trajopt_sco/solver_utils.hpp new file mode 100644 index 0000000000..42fcd3e34e --- /dev/null +++ b/moveit_planners/trajopt/trajopt_sco/include/trajopt_sco/solver_utils.hpp @@ -0,0 +1,142 @@ +#pragma once +#include +TRAJOPT_IGNORE_WARNINGS_PUSH +#include +#include +#include +TRAJOPT_IGNORE_WARNINGS_POP + +#include + +namespace sco +{ +/** + * @brief transform an `AffExpr` to an `Eigen::SparseVector` + * + * @param [in] expr an `AffExpr` expression + * @param [out] sparse_vector vector where to store results. It will be resized + * to the correct size. + * @param [in] n_vars the number of variables in expr. It is usually equal + * to `expr.size()`, but it might be larger. + */ +void exprToEigen(const AffExpr& expr, Eigen::SparseVector& sparse_vector, const int& n_vars); + +/** + * @brief transform a `QuadExpr` to an `Eigen::SparseMatrix` plus + * `Eigen::VectorXd` + * + * @param [in] expr a `QuadExpr` expression + * @param [out] sparse_matrix matrix where to store results. It will be resized + * to the correct size. + * @param [out] vector vector where to store the affine part of the + * `QuadExpr`. It will be resized to the correct size. + * @param [in] n_vars the number of variables in expr. It is usually equal + * to `expr.size()`, but it might be larger. + * @param [in] matrix_is_halved if `true`, sparse_matrix will be premultiplied + * by the coefficient `2`. + * @param [in] force_diagonal if true, we will forcibly add elements to the + * diagonal of the sparse matrix, adding `0.` if needed + */ +void exprToEigen(const QuadExpr& expr, Eigen::SparseMatrix& sparse_matrix, Eigen::VectorXd& vector, + const int& n_vars, const bool& matrix_is_halved = false, const bool& force_diagonal = false); + +/** + * @brief transform a vector of `AffExpr` to an `Eigen::SparseMatrix` plus an + * `Eigen::VectorXd`. + * Notice that the underlying transformation is so that the the affine + * expressions of the type `ax + b` will be stacked in matrix form into + * `Ax + b` and then transformed into the expression `Ax <= -b` so that + * `vector[i] = -expr_vec[i].constant` + * @param [in] expr_vec a an `AffExprVector` + * @param [out] sparse_matrix matrix where to store results. It will be resized + * to the correct size. + * @param [out] vector vector where to store all the constants of each `AffExpr`, + * ordered by their appearance order in `expr_vec`. + * It will be resized to the correct size. + * @param [in] n_vars the larger number of variables in expr. + * It is usually the same for each `expr` in `expr_vec`, + * and equal to `expr.size()`, but it might be larger. + */ +void exprToEigen(const AffExprVector& expr_vec, Eigen::SparseMatrix& sparse_matrix, Eigen::VectorXd& vector, + const int& n_vars = -1); +/** + * @brief Converts triplets to an `Eigen::SparseMatrix`. + * @param [in] rows_i a vector of row indices + * @param [in] cols_j a vector of columns indices + * @param [in] values_ij a vector of values, so that: + * `M[rows_i[k], cols_j[k]] = values_ij[k]` + * @param [in,out] sparse_matrix must be of the right size, as we should not + * be guessing the right size of sparse_matrix from + * a sparse triplet representation. + */ +void tripletsToEigen(const IntVec& rows_i, const IntVec& cols_j, const DblVec& values_ij, + Eigen::SparseMatrix& sparse_matrix); + +/** + * @brief Converts an `Eigen::SparseMatrix` into triplets format + * @param [in] sparse_matrix an `Eigen::SparseMatrix` + * @param [out] rows_i a vector of row indices + * @param [out] cols_j a vector of columns indices + * @param [out] values_ij a vector of values, so that: + * `M[rows_i[k], cols_j[k]] = values_ij[k]` + */ +void eigenToTriplets(const Eigen::SparseMatrix& sparse_matrix, IntVec& rows_i, IntVec& cols_j, + DblVec& values_ij); + +/** + * @brief converts a sparse matrix into compressed + * sparse column representation (CSC). + * + * @param [out] row_indices row indices for a CSC matrix + * @param [out] column_pointers column pointer for a CSC matrix + * @param [out] values pointer to non-zero elements in CSC representation + * @param [in,out] sparse_matrix input matrix: will be compressed + */ +template +void eigenToCSC(Eigen::SparseMatrix& sparse_matrix, std::vector& row_indices, + std::vector& column_pointers, DblVec& values) +{ + Eigen::SparseMatrix sm_t; + auto sm_ref = std::ref(sparse_matrix); + + if (eigenUpLoType > 0) + { + sm_t = sparse_matrix.triangularView(); + sm_ref = std::ref(sm_t); + } + sm_ref.get().makeCompressed(); + + if (sizeof(T) != sizeof(int)) + { + IntVec row_indices_int, column_pointers_int; + auto si_p = sm_ref.get().innerIndexPtr(); + row_indices_int.assign(si_p, si_p + sm_ref.get().nonZeros()); + row_indices.clear(); + row_indices.reserve(row_indices_int.size()); + for (const auto& v : row_indices_int) + row_indices.push_back(static_cast(v)); + + si_p = sm_ref.get().outerIndexPtr(); + column_pointers_int.assign(si_p, si_p + sm_ref.get().outerSize()); + column_pointers.clear(); + column_pointers.reserve(column_pointers_int.size()); + for (const auto& v : column_pointers_int) + column_pointers.push_back(static_cast(v)); + } + else + { + auto si_p = sm_ref.get().innerIndexPtr(); + row_indices.assign(si_p, si_p + sm_ref.get().nonZeros()); + + si_p = sm_ref.get().outerIndexPtr(); + column_pointers.assign(si_p, si_p + sm_ref.get().outerSize()); + } + + // while Eigen does not enforce this, CSC format requires that column + // pointers ends with the number of non-zero elements + column_pointers.push_back(sm_ref.get().nonZeros()); + + auto csc_v = sm_ref.get().valuePtr(); + values.assign(csc_v, csc_v + sm_ref.get().nonZeros()); +} +} diff --git a/moveit_planners/trajopt/trajopt_sco/package.xml b/moveit_planners/trajopt/trajopt_sco/package.xml new file mode 100644 index 0000000000..eaba8862f4 --- /dev/null +++ b/moveit_planners/trajopt/trajopt_sco/package.xml @@ -0,0 +1,19 @@ + + + trajopt_sco + 0.1.0 + The trajopt_sco package + Levi Armstrong + BSD + + catkin + trajopt_utils + + rosunit + + + + + + + diff --git a/moveit_planners/trajopt/trajopt_sco/src/bpmpd.par b/moveit_planners/trajopt/trajopt_sco/src/bpmpd.par new file mode 100644 index 0000000000..342c55aee8 --- /dev/null +++ b/moveit_planners/trajopt/trajopt_sco/src/bpmpd.par @@ -0,0 +1,189 @@ +! Parameter file for multiply predictor - corrector method + +MPS and Input/Output definitions + +BEGIN_PROB ! Begin marker +NAME = default ! Problem name, max. 36 characters +STARTSOL = ! Warm start solution file name +MAXMN = 250000. ! Upper bound for M+N +MINMAX = 1. ! =1. (mininmize) =-1. (maximize) +OUTPUT = 1. ! Output level 0 :only statistic, 1 :solution +OBJNAM = ! Objective function name (first N type row) +RHSNAM = ! RHS name (first) +BNDNAM = ! BOUND name (first) +RNGNAM = ! RANGE name (first) +EXPLSLACK = 1. ! Include slack as variables +BIGBOUND = 1.0d+15 ! Skip bounds and ranges exceeding this limit +SMALLVAL = 1.0d-12 ! Skip matrix (and bound) values under this limit +ITERLOG = 3. ! 0:no report, 1: stdout, 2: logfile, 3:both + ! 4:advanced debug info 8: debug on steplengths + ! 256: generating bpmpd.qps at start +END_PROB + + +Optimization parameter section + + +BEGIN_OPT + +! Supernode parameters + +PSUPNODE = 4. ! Primer supernode length +SSUPNODE = 4. ! Secunder supernode length +CACHESIZ = 256. ! Size of the cache in kilobytes +PUSHFACT = 2. ! 0: pull Cholesky + ! 1: single-pass push Cholesky + ! 2: multi-pass push Cholesky + +! Density handling and factorization type parameters + +MAXDENSE = 0.20 ! maximal dense columns rate +DENSGAP = 3.50 ! density gap parameter +DENSLEN = 10. ! Value for the possibily dense columns +SUPDENS = 350. ! 'Super' dense column length +SETLAM = 0. ! 0 : density gap heuristic, ( AAT ) + ! -1 : use LAM, ( AAT ) + +! Pivot and factorization parameters + +TPIV1 = 1.0D-03 ! First threshold pivot tolerance +TPIV2 = 1.0D-08 ! Second threshold pivot tolerance +TABS = 1.0D-12 ! Abs. pivot tolerance for the first factorization +TRABS = 1.0D-15 ! Abs. pivot tolerance during the algorithm +LAM = 1.0D-05 ! Minimum value of lambda +TFIND = 25. ! Pivot search loop count +ORDERING = 0. ! 0 : Selected automatically + ! 1 : Minimum degree + ! 2 : Minimum local fill-in + ! 3 : Nested dissection (METIS at the moment) + ! -1 : No ordering + +! Stopping criterion parameters + +TOPT1 = 1.0D-08 ! Relative duality gap tolerance +TOPT2 = 1.0D-25 ! Average complementary gap tolerance +TFEAS1 = 1.0D-07 ! Relative primal feasibility tolerance +TFEAS2 = 1.0D-07 ! Relative dual feasibility tolerance +INFTOL = 1.0D+04 ! Infeasibility check tolerance +TSDIR = 1.0D-16 ! Search direction maximum norm tolerance +MAXITER = 99. ! Iteration limit + +! Numerical tolerances + +TPLUS = 1.0D-10 ! Relative addition tolerance +TZER = 1.0D-35 ! Relative zero tolerance + +! Iterative refinement tolerances + +TRESX = 1.0D-10 ! Acceptable residual in the primal space +TRESY = 1.0D-10 ! Acceptable residual in the dual space +MAXREF = 5. ! Maximal number of refinement +REFMET = 3. ! Refinement method: 1: Iterative improvement + ! 2: Preconditioned QMR + ! 4: Preconditioned CGM + +! Scaling parameters ! Scaling methods: + ! 0. : No scaling + ! 1. : Simple scaling to rowmax=1, colmax=1 + ! 2. : Geometric mean scaling + simple scaling + ! 3. : Curtis-Reid's algorithm + simple scaling + ! 4. : Geometric mean scaling only + ! 5. : Curtis-Reid's algorithm only +OBJNORM = 1.0D+02 ! Scaling the objective to this max. norm +RHSNORM = 0.0D+00 ! Scaling the rhs to this max. norm +SIGNORE = 1.0D-12 ! Ignore values during scaling under this parameter + ! BEFORE AGGREGATOR +SPASSES1 = 5. ! Maximum number of passes ( <128 ) +SMETHOD1 = 2. ! Scaling method + ! AFTER AGGREGATOR +SPASSES2 = 0. ! Maximum number of passes ( <128 ) +SMETHOD2 = 0. ! Scaling method + +! Complementary gap ballancing + +MINSTEP = 5.0d-01 ! Minimum stepsize +COMPLMIN = 1.0d-03 ! Min/Max complementarity component threshold + +! Predictor-corrector and barrier parameters + +STOPCOR = 1.00D-03 ! Correction stop parameter +BARSET = 2.00D-01 ! Barrier set-up limit +BARGROW = 1.00D+03 ! Barrier grow controll +BARMIN = 1.00D-15 ! Minimum barrier threshold +MINCORR = -1. ! Number of the minimum corrections +MAXCORR = 1. ! Number of the maximum corrections +INIBARR = 0.0d+0 ! Use initial barrier parameter + +! Centrality corrections parameters + +TARGET = 9.00D-02 ! Trial steplength improvement +TSMALL = 2.00D-01 ! Small complementarity bound +TLARGE = 2.00D+01 ! Large compelmentarity bound +CENTER = 5.00D+00 ! Centrality force +CORSTOP = 1.01D+00 ! Correction stop parameter +MINCCORR = 0. ! Number of the minimum corrections +MAXCCORR = 9. ! Number of the maximum corrections + +! Steplenth parameters + +PRDARE = 0.999D+00 ! Maximal primal steplength +DUDARE = 0.999D+00 ! Maximal dual steplength + +! Variable fixing tolerances + +TFIXVAR = 1.0D-20 ! Variable reset parameter +TFIXSLACK = 1.0D-20 ! Slack reset parameter +DSLACKLIM = 1.0D-20 ! Dual slack variable limit + +! Starting point paramerers + +PRMIN = 150.00 ! Minimum initial variable value +UPMAX = 50000.00 ! Maximum initial variable value +DUMIN = 150.00 ! Minimum initial slack value +LSQWEIGHT = 10.00 ! LSQ weight over quadratic objective +SMETHOD = 2. ! Starting method (1. or 2.) +SAFEMET = -3. ! Safe method (1. 2. or 3.) + +! +! Presolv parameters +! + +PRESOLV = 2047. ! 1 : singleton row check (895) + ! 2 : singleton column check + ! 4 : min/max row value check + ! 8 : cheap dual tests + ! 16 : dual check + ! 32 : primal bound check and relaxation + ! 64 : search identical variables + ! 128 : setting vars free in row doubletons + ! 256 : elimination of free variables + ! 512 : linear dependency check + ! 1024 : sparser + ! 2048 : Restore original bounds after elimination + ! 4096 : extended dual tests + +BNDLOOP = 5. ! Maximum loops in bound check +DULOOP = 10. ! Maximum loops in dual check +PRIMALBND = 1000. ! Maximal upper bound allowed during bndcheck +DUALBND = 10000. ! Maximal upper bound allowed during ducheck +PRESFEAS = 1.0d-8 ! Feasibility tolerance during presolve +PIVRTOL = 1.0D-2 ! Relative pivot tolerance in aggragation +PIVATOL = 1.0D-4 ! Absolute pivot tolerance in aggregation +PIVXTOL = 1.0D-8 ! Absolute pivot tolerance in linear dep. check +FILLTOL = 4. ! Fill-in controll during aggregation + +! +! Regularization parameters +! + +SOFTREG = 1.0D-12 ! Soft regularization parameter +HARDREG = 1.0D-16 ! Hard regularization parameter +SCFREE = 1.0D-06 ! Regularization for free variables +REGULARIZE= 27. ! Regularization method + ! 1. Pre-regularize free variables + ! 2. Pre-regularize equalities, AS + ! 4. Pre-regularize equalities, NE + ! 8. Post-regularize free variables + ! 16. Post-regularize equalities, AS + ! 32. Post-regularize equalities, NE +END_OPT diff --git a/moveit_planners/trajopt/trajopt_sco/src/bpmpd_caller.cpp b/moveit_planners/trajopt/trajopt_sco/src/bpmpd_caller.cpp new file mode 100644 index 0000000000..235f359b53 --- /dev/null +++ b/moveit_planners/trajopt/trajopt_sco/src/bpmpd_caller.cpp @@ -0,0 +1,63 @@ +#include +TRAJOPT_IGNORE_WARNINGS_PUSH +#include +#include +#include +#include +TRAJOPT_IGNORE_WARNINGS_POP + +#include +#include + +extern "C" { +extern void bpmpd(int*, int*, int*, int*, int*, int*, int*, double*, int*, int*, double*, double*, double*, double*, + double*, double*, double*, int*, double*, int*, double*, int*); +} + +int main(int /*argc*/, char** /*argv*/) +{ + std::string working_dir = BPMPD_WORKING_DIR; + int err = chdir(working_dir.c_str()); + if (err != 0) + { + std::cerr << "error going to BPMPD working dir\n"; + std::cerr << strerror(err) << std::endl; + abort(); + } + // int counter=0; + while (true) + { + bpmpd_io::bpmpd_input bi; + bpmpd_io::ser(STDIN_FILENO, bi, bpmpd_io::DESER); + + int memsiz = 0; + double BIG = 1e30; + bpmpd_io::bpmpd_output bo; + bo.primal.resize(static_cast(bi.m + bi.n)); + bo.dual.resize(static_cast(bi.m + bi.n)); + bo.status.resize(static_cast(bi.m + bi.n)); + +#define DBG(expr) // cerr << #expr << ": " << CSTR(expr) << std::endl + DBG(bi.m); + DBG(bi.n); + DBG(bi.nz); + DBG(bi.qn); + DBG(bi.qnz); + DBG(bi.acolcnt); + DBG(bi.acolidx); + DBG(bi.acolnzs); + DBG(bi.qcolcnt); + DBG(bi.qcolidx); + DBG(bi.qcolnzs); + DBG(bi.rhs); + DBG(bi.obj); + DBG(bi.lbound); + DBG(bi.ubound); + + bpmpd(&bi.m, &bi.n, &bi.nz, &bi.qn, &bi.qnz, bi.acolcnt.data(), bi.acolidx.data(), bi.acolnzs.data(), + bi.qcolcnt.data(), bi.qcolidx.data(), bi.qcolnzs.data(), bi.rhs.data(), bi.obj.data(), bi.lbound.data(), + bi.ubound.data(), bo.primal.data(), bo.dual.data(), bo.status.data(), &BIG, &bo.code, &bo.opt, &memsiz); + + bpmpd_io::ser(STDOUT_FILENO, bo, bpmpd_io::SER); + } +} diff --git a/moveit_planners/trajopt/trajopt_sco/src/bpmpd_interface.cpp b/moveit_planners/trajopt/trajopt_sco/src/bpmpd_interface.cpp new file mode 100644 index 0000000000..b17bb6ff2f --- /dev/null +++ b/moveit_planners/trajopt/trajopt_sco/src/bpmpd_interface.cpp @@ -0,0 +1,517 @@ +#include +TRAJOPT_IGNORE_WARNINGS_PUSH +#include +#include +#include +TRAJOPT_IGNORE_WARNINGS_POP + +#include +#include +#include +#include + +/** +This is a readme file for the linux DLL version of BPMPD version 2.21 +The DLL solves linear and convex quadratic problems. + + +The objective function is assumed to be in the form: + + 1 + min c'x + - x'Qx + 2 + + +The interface (Fortran-like) for BPMPD: + + subroutine bpmpd(m,n,nz,qn,qnz, + acolcnt,acolidx,acolnzs, + qcolcnt,qcolidx,qcolnzs, + rhs,obj,lbound,ubound,primal,dual,status, + big,code,opt,memsiz) + +integer*4 m,n,nz,qn,qnz,acolcnt(n),acolidx(nz),qcolcnt(n),qcolidx(qnz), + status(n+m),code, +real*8 acolnzs(nz),qcolnzs(qnz),rhs(m),obj(n),lbound(n+m),ubound(n+m), + primal(n+m),dual(n+m),big,opt + + +or C-like: + +void bpmpd(int *m, int *n, int *nz, int *qn, int *qnz, int *acolcnt, + int *acolidx, double *acolnzs, int *qcolcnt, int *qcolidx, + double *qcolnzs, double *rhs, double *obj, double *lbound, + double *ubound, double *primal, double *dual, int *status, + double *big, int *code, double *opt, int *memsiz) + +where + + memsiz : Number of bytes to be allocated by bpmpd. If memsiz <= 0 + bpmpd determines the allocatable memory itself. As output + memsiz contains the memory in bytes which was used during + the process. + + m : number of rows in the constraint matrix + n : number of columns in the constraint matrix + nz : number of nonzeros in the constraint matrix + qn : number of quadratic variables + qnz : number of nonzeros in the lower triangular of Q (with diagonals) + + acolcnt : number of nonzeros in each column of A + acolidx : A matrix index values + acolnzs : A matrix nonzero values + It is supposed that the columns are placed continuousely from + the first positions of the parallel arrays acolidx-acolnzs. + + qcolcnt : number of nonzeros in each column of the lower triangular part of Q + qcolidx : Q matrix index values + qcolnzs : Q matrix nonzero values + It is supposed that the the lower triangular part (with diagonal) + of Q is provided and its columns are placed continuousely from + the first positions of the parallel arrays qcolidx-qcolnzs. + + rhs : right hand side + obj : objective function + lbound : 1 .. n lower bounds of the variables + n+1 .. n+m lower bounds on rows (slacks) + ubound : upper bounds (like lbound) + + primal : optimal primal values + dual : optimal dual values + status : basic/nonbasic status estimation of variables (1/0) + + big : Represents infinity (recommended big = 1.0d+30 ) + code : return code + if code < 0 --> not enought memory + if code = 1 --> solver stopped at feasible point (suboptimal +solution) + if code = 2 --> optimal solution found + if code = 3 --> problem dual infeasible + if code = 4 --> problem primal infeasible + + opt : final primal objective value + +The DLL will read the parameter file called bpmpd.par (if presented) and +write a log file called bpmpd.log. + + + As example the LP problem : + + min x1 + x1*x1 + 2*x1*x2 + 2*x2*x2 + x4*x4 + + 1x1 + 2x2 + 0x3 -4x4 >= 0 + 3x1 + 0x2 - 2x3 -1x4 <= 100 + 30 >= 1x1 + 3x2 + 3x3 -2x4 >= 10 + + x1,x2,x3 >=0 + x1 <= 20 + + Then the input parameters: + + m=3, n=4, nz=10, qn=3, qnz=4 + + ubound : (20, big, big, big, big, 0, 20) + lbound : ( 0, 0, 0, -big, 0, -big, 0) + rhs : ( 0, 100, 10) + obj : ( 1, 0, 0, 0) + +acolcnt : ( 3, 2, 2, 3) +acolidx : ( 1, 2, 3, 1, 3, 2, 3, 1, 2, 3) +acolnzs : ( 1, 3, 1, 2, 3, -2, 3, -4,-1,-2) + +qcolcnt : ( 2, 1, 0, 1) +qcolidx : ( 1,2, 2, 4) +qcolnzs : ( 2,2, 4, 2) + + 1 1 1 0 2 2 0 +(Note : 2*x1*x2 = x1*x2+x2*x1 thus - * Q = 1 2 0 and Q = 2 4 0 ) + 2 0 0 1 0 0 2 + +NOTE: +The subroutine solves minimization problems, therefore you +have to change the sign of the objective, if you have a maximization +problem. + +NOTE: +The DLL routine will create a log file called "bpmpd.log" at every call. +The old bpmpd.log file will be overwritten. + +NOTE: +A sample driver solving the above problem is included as well as the +logfile it generates. + **/ + +// extern "C" { +// extern void bpmpd(int *, int *, int *, int *, int *, int *, int *, +// double *, int *, int *, double *, double *, double *, double *, +// double *, double *, double *, int *, double *, int *, double *, int +// *); +// } + +namespace sco +{ +static double BPMPD_BIG = 1e+30; + +ModelPtr createBPMPDModel() +{ + ModelPtr out(new BPMPDModel()); + return out; +} + +#define READ 0 +#define WRITE 1 + +pid_t popen2(const char* command, int* infp, int* outfp) +{ + int p_stdin[2], p_stdout[2]; + pid_t pid; + + if (pipe(p_stdin) != 0 || pipe(p_stdout) != 0) + return -1; + + pid = fork(); + + if (pid < 0) + { + assert(0); + return pid; + } + else if (pid == 0) + { + close(p_stdin[WRITE]); + dup2(p_stdin[READ], READ); + close(p_stdout[READ]); + dup2(p_stdout[WRITE], WRITE); + + execl("/bin/sh", "sh", "-c", command, nullptr); + perror("execl"); + exit(1); + } + + if (infp == nullptr) + close(p_stdin[WRITE]); + else + *infp = p_stdin[WRITE]; + + if (outfp == nullptr) + close(p_stdout[READ]); + else + *outfp = p_stdout[READ]; + + return pid; +} + +static pid_t gPID = 0; +static int gPipeIn = 0; +static int gPipeOut = 0; + +void fexit() +{ + char text[1] = { bpmpd_io::EXIT_CHAR }; + long n = write(gPipeIn, text, 1); + ALWAYS_ASSERT(n == 1); +} + +BPMPDModel::BPMPDModel() : m_pipeIn(0), m_pipeOut(0) +{ + if (gPID == 0) + { + atexit(fexit); + gPID = popen2(BPMPD_CALLER, &gPipeIn, &gPipeOut); + } +} + +BPMPDModel::~BPMPDModel() +{ + // char text[1] = {123}; + // write(gPipeIn, text, 1); + // // kill(m_pid, SIGKILL); // TODO: WHY DOES THIS KILL THE PARENT PROCESS?! + // close(m_pipeIn); + // close(m_pipeOut); + // m_pipeIn=0; + // m_pipeOut=0; +} + +Var BPMPDModel::addVar(const std::string& name) +{ + m_vars.push_back(new VarRep(static_cast(m_vars.size()), name, this)); + m_lbs.push_back(-BPMPD_BIG); + m_ubs.push_back(BPMPD_BIG); + return m_vars.back(); +} +Cnt BPMPDModel::addEqCnt(const AffExpr& expr, const std::string& /*name*/) +{ + m_cnts.push_back(new CntRep(static_cast(m_cnts.size()), this)); + m_cntExprs.push_back(expr); + m_cntTypes.push_back(EQ); + return m_cnts.back(); +} +Cnt BPMPDModel::addIneqCnt(const AffExpr& expr, const std::string& /*name*/) +{ + m_cnts.push_back(new CntRep(static_cast(m_cnts.size()), this)); + m_cntExprs.push_back(expr); + m_cntTypes.push_back(INEQ); + return m_cnts.back(); +} +Cnt BPMPDModel::addIneqCnt(const QuadExpr&, const std::string& /*name*/) +{ + assert(0 && "NOT IMPLEMENTED"); + return nullptr; +} +void BPMPDModel::removeVars(const VarVector& vars) +{ + IntVec inds = vars2inds(vars); + for (unsigned i = 0; i < vars.size(); ++i) + vars[i].var_rep->removed = true; +} + +void BPMPDModel::removeCnts(const CntVector& cnts) +{ + IntVec inds = cnts2inds(cnts); + for (unsigned i = 0; i < cnts.size(); ++i) + cnts[i].cnt_rep->removed = true; +} + +void BPMPDModel::update() +{ + { + size_t inew = 0; + for (unsigned iold = 0; iold < m_vars.size(); ++iold) + { + const Var& var = m_vars[iold]; + if (!var.var_rep->removed) + { + m_vars[inew] = var; + m_lbs[inew] = m_lbs[iold]; + m_ubs[inew] = m_ubs[iold]; + var.var_rep->index = static_cast(inew); + ++inew; + } + else + delete var.var_rep; + } + m_vars.resize(inew); + m_lbs.resize(inew); + m_ubs.resize(inew); + } + { + size_t inew = 0; + for (unsigned iold = 0; iold < m_cnts.size(); ++iold) + { + const Cnt& cnt = m_cnts[iold]; + if (!cnt.cnt_rep->removed) + { + m_cnts[inew] = cnt; + m_cntExprs[inew] = m_cntExprs[iold]; + m_cntTypes[inew] = m_cntTypes[iold]; + cnt.cnt_rep->index = static_cast(inew); + ++inew; + } + else + delete cnt.cnt_rep; + } + m_cnts.resize(inew); + m_cntExprs.resize(inew); + m_cntTypes.resize(inew); + } +} + +void BPMPDModel::setVarBounds(const VarVector& vars, const DblVec& lower, const DblVec& upper) +{ + for (unsigned i = 0; i < vars.size(); ++i) + { + size_t varind = static_cast(vars[i].var_rep->index); + m_lbs[varind] = lower[i]; + m_ubs[varind] = upper[i]; + } +} +DblVec BPMPDModel::getVarValues(const VarVector& vars) const +{ + DblVec out(vars.size()); + for (unsigned i = 0; i < vars.size(); ++i) + { + size_t varind = static_cast(vars[i].var_rep->index); + out[i] = m_soln[varind]; + } + return out; +} + +#define DBG(expr) // cout << #expr << ": " << CSTR(expr) << std::endl + +CvxOptStatus BPMPDModel::optimize() +{ + update(); + // + // + // int m, n, nz, qn, qnz, acolcnt[maxn+1], acolidx[maxnz], qcolcnt[maxn+1], + // qcolidx[maxqnz], + // status[maxn+maxm], code, memsiz; + // double acolnzs[maxnz], qcolnzs[maxqnz], rhs[maxm], obj[maxn], + // lbound[maxn+maxm], + // ubound[maxn+maxm], primal[maxn+maxm], dual[maxn+maxm], big, opt; + + size_t n = m_vars.size(); + size_t m = m_cnts.size(); + + IntVec acolcnt(n), acolidx, qcolcnt(n), qcolidx, status(m + n); + DblVec acolnzs, qcolnzs, rhs(m), obj(n, 0), lbound(m + n), ubound(m + n), primal(m + n), dual(m + n); + + DBG(m_lbs); + DBG(m_ubs); + for (size_t iVar = 0; iVar < n; ++iVar) + { + lbound[iVar] = fmax(m_lbs[iVar], -BPMPD_BIG); + ubound[iVar] = fmin(m_ubs[iVar], BPMPD_BIG); + } + + std::vector var2cntinds(n); + std::vector var2cntvals(n); + for (size_t iCnt = 0; iCnt < m; ++iCnt) + { + const AffExpr& aff = m_cntExprs[iCnt]; + // cout << "adding constraint " << aff << endl; + IntVec inds = vars2inds(aff.vars); + + for (size_t i = 0; i < aff.vars.size(); ++i) + { + var2cntinds[static_cast(inds[i])].push_back(static_cast(iCnt)); + var2cntvals[static_cast(inds[i])].push_back(aff.coeffs[i]); // xxx maybe repeated/ + } + + lbound[n + iCnt] = (m_cntTypes[iCnt] == INEQ) ? -BPMPD_BIG : 0; + ubound[n + iCnt] = 0; + rhs[iCnt] = -aff.constant; + } + + for (size_t iVar = 0; iVar < n; ++iVar) + { + simplify2(var2cntinds[iVar], var2cntvals[iVar]); + acolcnt[iVar] = static_cast(var2cntinds[iVar].size()); + acolidx.insert(acolidx.end(), var2cntinds[iVar].begin(), var2cntinds[iVar].end()); + acolnzs.insert(acolnzs.end(), var2cntvals[iVar].begin(), var2cntvals[iVar].end()); + } + // cout << CSTR(acolidx) << endl; + // cout << CSTR(acolnzs) << endl; + + std::vector var2qcoeffs(n); + std::vector var2qinds(n); + for (size_t i = 0; i < m_objective.size(); ++i) + { + size_t idx1 = static_cast(m_objective.vars1[i].var_rep->index); + size_t idx2 = static_cast(m_objective.vars2[i].var_rep->index); + if (idx1 < idx2) + { + var2qinds[idx1].push_back(static_cast(idx2)); + var2qcoeffs[idx1].push_back(m_objective.coeffs[i]); + } + else if (idx1 == idx2) + { + var2qinds[idx1].push_back(static_cast(idx2)); + var2qcoeffs[idx1].push_back(m_objective.coeffs[i] * 2); + } + else + { + var2qinds[idx2].push_back(static_cast(idx1)); + var2qcoeffs[idx2].push_back(m_objective.coeffs[i]); + } + } + + for (size_t iVar = 0; iVar < n; ++iVar) + { + simplify2(var2qinds[iVar], var2qcoeffs[iVar]); + qcolidx.insert(qcolidx.end(), var2qinds[iVar].begin(), var2qinds[iVar].end()); + qcolnzs.insert(qcolnzs.end(), var2qcoeffs[iVar].begin(), var2qcoeffs[iVar].end()); + qcolcnt[iVar] = static_cast(var2qinds[iVar].size()); + } + + for (size_t i = 0; i < m_objective.affexpr.size(); ++i) + { + obj[static_cast(m_objective.affexpr.vars[i].var_rep->index)] += m_objective.affexpr.coeffs[i]; + } + +#define VECINC(vec) \ + for (unsigned i = 0; i < vec.size(); ++i) \ + ++vec[i]; + VECINC(acolidx); + VECINC(qcolidx); +#undef VECINC + + // cout << "objective: " << m_objective << endl; + + int nz = static_cast(acolnzs.size()), qn = static_cast(n), qnz = static_cast(qcolnzs.size()); + + DBG(m); + DBG(n); + DBG(nz); + DBG(qn); + DBG(qnz); + DBG(acolcnt); + DBG(acolidx); + DBG(acolnzs); + DBG(qcolcnt); + DBG(qcolidx); + DBG(qcolnzs); + DBG(rhs); + DBG(obj); + DBG(lbound); + DBG(ubound); + +#if 0 + bpmpd(&m, &n, &nz, &qn, &qnz, acolcnt.data(), acolidx.data(), acolnzs.data(), qcolcnt.data(), qcolidx.data(), qcolnzs.data(), + rhs.data(), obj.data(), lbound.data(), ubound.data(), + primal.data(), dual.data(), status.data(), &BIG, &code, &opt, &memsiz); + + // opt += m_objective.affexpr.constant; + m_soln = DblVec(primal.begin(), primal.begin()+n); + + + if (1) { + DBG(primal); + DBG(dual); + DBG(status); + DBG(code); + DBG(opt); +#undef DBG + +#else + + bpmpd_io::bpmpd_input bi(static_cast(m), static_cast(n), nz, qn, qnz, acolcnt, acolidx, acolnzs, qcolcnt, + qcolidx, qcolnzs, rhs, obj, lbound, ubound); + bpmpd_io::ser(gPipeIn, bi, bpmpd_io::SER); + + // std::cout << "serialization time:" << end-start << std::endl; + + bpmpd_io::bpmpd_output bo; + bpmpd_io::ser(gPipeOut, bo, bpmpd_io::DESER); + + m_soln = DblVec(bo.primal.begin(), bo.primal.begin() + static_cast(n)); + int retcode = bo.code; + + if (retcode == 2) + return CVX_SOLVED; + else if (retcode == 3 || retcode == 4) + return CVX_INFEASIBLE; + else + return CVX_FAILED; + +#endif + + // exit(0); +} +void BPMPDModel::setObjective(const AffExpr& expr) +{ + m_objective.affexpr = expr; +} +void BPMPDModel::setObjective(const QuadExpr& expr) +{ + m_objective = expr; +} +void BPMPDModel::writeToFile(const std::string& /*fname*/) +{ + // assert(0 && "NOT IMPLEMENTED"); +} +VarVector BPMPDModel::getVars() const +{ + return m_vars; +} +} diff --git a/moveit_planners/trajopt/trajopt_sco/src/expr_ops.cpp b/moveit_planners/trajopt/trajopt_sco/src/expr_ops.cpp new file mode 100644 index 0000000000..eeab09ba62 --- /dev/null +++ b/moveit_planners/trajopt/trajopt_sco/src/expr_ops.cpp @@ -0,0 +1,106 @@ +#include +TRAJOPT_IGNORE_WARNINGS_PUSH +#include +TRAJOPT_IGNORE_WARNINGS_POP + +#include + +static inline double sq(double x) +{ + return x * x; +} +namespace sco +{ +QuadExpr exprMult(const AffExpr& affexpr1, const AffExpr& affexpr2) +{ + QuadExpr out; + size_t naff1 = affexpr1.coeffs.size(); + size_t naff2 = affexpr2.coeffs.size(); + size_t nquad = naff1 * naff2; + + // Multiply the constants of the two expr + out.affexpr.constant = affexpr1.constant * affexpr2.constant; + + // Account for vars in each expr multiplied by the constant in the other expr + out.affexpr.vars.reserve(naff1 + naff2); + out.affexpr.vars.insert(out.affexpr.vars.end(), affexpr1.vars.begin(), affexpr1.vars.end()); + out.affexpr.vars.insert(out.affexpr.vars.end(), affexpr2.vars.begin(), affexpr2.vars.end()); + out.affexpr.coeffs.resize(naff1 + naff2); + for (size_t i = 0; i < naff1; ++i) + out.affexpr.coeffs[i] = affexpr2.constant * affexpr1.coeffs[i]; + for (size_t i = 0; i < naff2; ++i) + out.affexpr.coeffs[i + naff1] = affexpr1.constant * affexpr2.coeffs[i]; + + // Account for the vars in each expr that are multipled by another var in the other expr + out.coeffs.reserve(nquad); + out.vars1.reserve(nquad); + out.vars2.reserve(nquad); + for (size_t i = 0; i < naff1; ++i) + { + for (size_t j = 0; j < naff2; ++j) + { + out.vars1.push_back(affexpr1.vars[i]); + out.vars2.push_back(affexpr2.vars[j]); + out.coeffs.push_back(affexpr1.coeffs[i] * affexpr2.coeffs[j]); + } + } + return out; +} + +QuadExpr exprSquare(const Var& a) +{ + QuadExpr out; + out.coeffs.push_back(1); + out.vars1.push_back(a); + out.vars2.push_back(a); + return out; +} + +QuadExpr exprSquare(const AffExpr& affexpr) +{ + QuadExpr out; + size_t naff = affexpr.coeffs.size(); + size_t nquad = (naff * (naff + 1)) / 2; + + out.affexpr.constant = sq(affexpr.constant); + + out.affexpr.vars = affexpr.vars; + out.affexpr.coeffs.resize(naff); + for (size_t i = 0; i < naff; ++i) + out.affexpr.coeffs[i] = 2 * affexpr.constant * affexpr.coeffs[i]; + + out.coeffs.reserve(nquad); + out.vars1.reserve(nquad); + out.vars2.reserve(nquad); + for (size_t i = 0; i < naff; ++i) + { + out.vars1.push_back(affexpr.vars[i]); + out.vars2.push_back(affexpr.vars[i]); + out.coeffs.push_back(sq(affexpr.coeffs[i])); + for (size_t j = i + 1; j < naff; ++j) + { + out.vars1.push_back(affexpr.vars[i]); + out.vars2.push_back(affexpr.vars[j]); + out.coeffs.push_back(2 * affexpr.coeffs[i] * affexpr.coeffs[j]); + } + } + return out; +} + +AffExpr cleanupAff(const AffExpr& a) +{ + AffExpr out; + for (size_t i = 0; i < a.size(); ++i) + { + if (fabs(a.coeffs[i]) > 1e-7) + { + out.coeffs.push_back(a.coeffs[i]); + out.vars.push_back(a.vars[i]); + } + } + out.constant = a.constant; + return out; +} + +/////////////////////////////////////////////////////////////// +} // namespace sco diff --git a/moveit_planners/trajopt/trajopt_sco/src/expr_vec_ops.cpp b/moveit_planners/trajopt/trajopt_sco/src/expr_vec_ops.cpp new file mode 100644 index 0000000000..07ff89a0b8 --- /dev/null +++ b/moveit_planners/trajopt/trajopt_sco/src/expr_vec_ops.cpp @@ -0,0 +1,12 @@ +#include +namespace sco +{ +AffExpr varDot(const Eigen::VectorXd& x, const VarVector& v) +{ + AffExpr out; + out.constant = 0; + out.vars = v; + out.coeffs = DblVec(x.data(), x.data() + x.size()); + return out; +} +} diff --git a/moveit_planners/trajopt/trajopt_sco/src/gurobi_interface.cpp b/moveit_planners/trajopt/trajopt_sco/src/gurobi_interface.cpp new file mode 100644 index 0000000000..c86dd714d0 --- /dev/null +++ b/moveit_planners/trajopt/trajopt_sco/src/gurobi_interface.cpp @@ -0,0 +1,299 @@ +#include +TRAJOPT_IGNORE_WARNINGS_PUSH +extern "C" { +#include "gurobi_c.h" +} +#include +#include +#include +#include +#include +TRAJOPT_IGNORE_WARNINGS_POP + +#include +#include +#include + +namespace sco +{ +GRBenv* gEnv; + +#if 0 +void simplify(IntVec& inds, DblVec& vals) { + // first find the largest element of inds + // make an array of that size + // + + assert(inds.size() == vals.size()); + int min_ind = *std::min_element(inds.begin(), inds.end()); + int max_ind = *std::max_element(inds.begin(), inds.end()); + int orig_size = inds.size(); + int work_size = max_ind - min_ind + 1; + DblVec work_vals(work_size, 0); + + for (int i=0; i < orig_size; ++i) { + work_vals[inds[i] - min_ind] += vals[i]; + } + + + int i_new = 0; + for (int i=0; i < work_size; ++i) { + if (work_vals[i] != 0) { + vals[i_new] = work_vals[i]; + inds[i_new] = i + min_ind; + ++i_new; + } + } + + inds.resize(i_new); + vals.resize(i_new); + +} +#endif + +#define ENSURE_SUCCESS(expr) \ + do \ + { \ + bool error = expr; \ + if (error) \ + { \ + printf("GRB error: %s while evaluating %s at %s:%i\n", GRBgeterrormsg(gEnv), #expr, __FILE__, __LINE__); \ + abort(); \ + } \ + } while (0) + +ModelPtr createGurobiModel() +{ + ModelPtr out(new GurobiModel()); + return out; +} + +GurobiModel::GurobiModel() +{ + if (!gEnv) + { + GRBloadenv(&gEnv, nullptr); + if (util::GetLogLevel() < util::LevelDebug) + { + ENSURE_SUCCESS(GRBsetintparam(gEnv, "OutputFlag", 0)); + } + } + GRBnewmodel(gEnv, &m_model, "problem", 0, nullptr, nullptr, nullptr, nullptr, nullptr); +} + +Var GurobiModel::addVar(const std::string& name) +{ + ENSURE_SUCCESS(GRBaddvar(m_model, 0, nullptr, nullptr, 0, -GRB_INFINITY, GRB_INFINITY, GRB_CONTINUOUS, + const_cast(name.c_str()))); + m_vars.push_back(new VarRep(static_cast(m_vars.size()), name, this)); + return m_vars.back(); +} + +Var GurobiModel::addVar(const std::string& name, double lb, double ub) +{ + ENSURE_SUCCESS(GRBaddvar(m_model, 0, nullptr, nullptr, 0, lb, ub, GRB_CONTINUOUS, const_cast(name.c_str()))); + m_vars.push_back(new VarRep(static_cast(m_vars.size()), name, this)); + return m_vars.back(); +} + +Cnt GurobiModel::addEqCnt(const AffExpr& expr, const std::string& name) +{ + LOG_TRACE("adding eq constraint: %s = 0", CSTR(expr)); + IntVec inds = vars2inds(expr.vars); + DblVec vals = expr.coeffs; + simplify2(inds, vals); + ENSURE_SUCCESS(GRBaddconstr(m_model, inds.size(), const_cast(inds.data()), const_cast(vals.data()), + GRB_EQUAL, -expr.constant, const_cast(name.c_str()))); + m_cnts.push_back(new CntRep(static_cast(m_cnts.size()), this)); + return m_cnts.back(); +} +Cnt GurobiModel::addIneqCnt(const AffExpr& expr, const std::string& name) +{ + LOG_TRACE("adding ineq: %s <= 0", CSTR(expr)); + IntVec inds = vars2inds(expr.vars); + DblVec vals = expr.coeffs; + simplify2(inds, vals); + ENSURE_SUCCESS(GRBaddconstr(m_model, inds.size(), inds.data(), vals.data(), GRB_LESS_EQUAL, -expr.constant, + const_cast(name.c_str()))); + m_cnts.push_back(new CntRep(static_cast(m_cnts.size()), this)); + return m_cnts.back(); +} +Cnt GurobiModel::addIneqCnt(const QuadExpr& qexpr, const std::string& name) +{ + int numlnz = qexpr.affexpr.size(); + IntVec linds = vars2inds(qexpr.affexpr.vars); + DblVec lvals = qexpr.affexpr.coeffs; + IntVec inds1 = vars2inds(qexpr.vars1); + IntVec inds2 = vars2inds(qexpr.vars2); + ENSURE_SUCCESS(GRBaddqconstr(m_model, numlnz, linds.data(), lvals.data(), qexpr.size(), inds1.data(), inds2.data(), + const_cast(qexpr.coeffs.data()), GRB_LESS_EQUAL, -qexpr.affexpr.constant, + const_cast(name.c_str()))); + return Cnt(); +} + +void resetIndices(VarVector& vars) +{ + for (size_t i = 0; i < vars.size(); ++i) + vars[i].var_rep[i].index = i; +} +void resetIndices(CntVector& cnts) +{ + for (size_t i = 0; i < cnts.size(); ++i) + cnts[i].cnt_rep[i].index = i; +} + +void GurobiModel::removeVars(const VarVector& vars) +{ + IntVec inds = vars2inds(vars); + ENSURE_SUCCESS(GRBdelvars(m_model, inds.size(), inds.data())); + for (int i = 0; i < vars.size(); ++i) + vars[i].var_rep->removed = true; +} + +void GurobiModel::removeCnts(const CntVector& cnts) +{ + IntVec inds = cnts2inds(cnts); + ENSURE_SUCCESS(GRBdelconstrs(m_model, inds.size(), inds.data())); + for (int i = 0; i < cnts.size(); ++i) + cnts[i].cnt_rep->removed = true; +} + +#if 0 +void GurobiModel::setVarBounds(const Var& var, double lower, double upper) { + assert(var.var_rep->creator == this); + ENSURE_SUCCESS(GRBsetdblattrelement(m_model, GRB_DBL_ATTR_LB, var.var_rep->index, lower)); + ENSURE_SUCCESS(GRBsetdblattrelement(m_model, GRB_DBL_ATTR_UB, var.var_rep->index, upper)); +} +#endif + +void GurobiModel::setVarBounds(const VarVector& vars, const DblVec& lower, const DblVec& upper) +{ + assert(vars.size() == lower.size() && vars.size() == upper.size()); + IntVec inds = vars2inds(vars); + ENSURE_SUCCESS( + GRBsetdblattrlist(m_model, GRB_DBL_ATTR_LB, inds.size(), inds.data(), const_cast(lower.data()))); + ENSURE_SUCCESS( + GRBsetdblattrlist(m_model, GRB_DBL_ATTR_UB, inds.size(), inds.data(), const_cast(upper.data()))); +} + +#if 0 +double GurobiModel::getVarValue(const Var& var) const { + assert(var.var_rep->creator == this); + double out; + ENSURE_SUCCESS(GRBgetdblattrelement(m_model, GRB_DBL_ATTR_X, var.var_rep->index, &out)); + return out; +} +#endif + +DblVec GurobiModel::getVarValues(const VarVector& vars) const +{ + assert((vars.size() == 0) || (vars[0].var_rep->creator == this)); + IntVec inds = vars2inds(vars); + DblVec out(inds.size()); + ENSURE_SUCCESS(GRBgetdblattrlist(m_model, GRB_DBL_ATTR_X, inds.size(), inds.data(), out.data())); + return out; +} + +CvxOptStatus GurobiModel::optimize() +{ + ENSURE_SUCCESS(GRBoptimize(m_model)); + int status; + GRBgetintattr(m_model, GRB_INT_ATTR_STATUS, &status); + if (status == GRB_OPTIMAL) + { + double objval; + GRBgetdblattr(m_model, GRB_DBL_ATTR_OBJVAL, &objval); + LOG_DEBUG("solver objective value: %.3e", objval); + return CVX_SOLVED; + } + else if (status == GRB_INFEASIBLE) + { + GRBcomputeIIS(m_model); + return CVX_INFEASIBLE; + } + else + return CVX_FAILED; +} +CvxOptStatus GurobiModel::optimizeFeasRelax() +{ + double lbpen = GRB_INFINITY, ubpen = GRB_INFINITY, rhspen = 1; + ENSURE_SUCCESS( + GRBfeasrelax(m_model, 0 /*sum of viol*/, 0 /*just minimize cost of viol*/, &lbpen, &ubpen, &rhspen, nullptr)); + return optimize(); +} + +void GurobiModel::setObjective(const AffExpr& expr) +{ + GRBdelq(m_model); + + int nvars; + GRBgetintattr(m_model, GRB_INT_ATTR_NUMVARS, &nvars); + assert(nvars == m_vars.size()); + + DblVec obj(nvars, 0); + for (size_t i = 0; i < expr.size(); ++i) + { + obj[expr.vars[i].var_rep->index] += expr.coeffs[i]; + } + ENSURE_SUCCESS(GRBsetdblattrarray(m_model, "Obj", 0, nvars, obj.data())); + GRBsetdblattr(m_model, "ObjCon", expr.constant); +} + +void GurobiModel::setObjective(const QuadExpr& quad_expr) +{ + setObjective(quad_expr.affexpr); + IntVec inds1 = vars2inds(quad_expr.vars1); + IntVec inds2 = vars2inds(quad_expr.vars2); + GRBaddqpterms(m_model, quad_expr.coeffs.size(), const_cast(inds1.data()), const_cast(inds2.data()), + const_cast(quad_expr.coeffs.data())); +} + +void GurobiModel::writeToFile(const std::string& fname) +{ + ENSURE_SUCCESS(GRBwrite(m_model, fname.c_str())); +} +void GurobiModel::update() +{ + ENSURE_SUCCESS(GRBupdatemodel(m_model)); + + { + int inew = 0; + for (const Var& var : m_vars) + { + if (!var.var_rep->removed) + { + m_vars[inew] = var; + var.var_rep->index = inew; + ++inew; + } + else + delete var.var_rep; + } + m_vars.resize(inew); + } + { + int inew = 0; + for (const Cnt& cnt : m_cnts) + { + if (!cnt.cnt_rep->removed) + { + m_cnts[inew] = cnt; + cnt.cnt_rep->index = inew; + ++inew; + } + else + delete cnt.cnt_rep; + } + m_cnts.resize(inew); + } +} + +VarVector GurobiModel::getVars() const +{ + return m_vars; +} +GurobiModel::~GurobiModel() +{ + ENSURE_SUCCESS(GRBfreemodel(m_model)); +} +} diff --git a/moveit_planners/trajopt/trajopt_sco/src/modeling.cpp b/moveit_planners/trajopt/trajopt_sco/src/modeling.cpp new file mode 100644 index 0000000000..81a2140b5e --- /dev/null +++ b/moveit_planners/trajopt/trajopt_sco/src/modeling.cpp @@ -0,0 +1,298 @@ +#include +TRAJOPT_IGNORE_WARNINGS_PUSH +#include +#include +#include +#include +TRAJOPT_IGNORE_WARNINGS_POP + +#include +#include +#include +#include +#include + +namespace sco +{ +void ConvexObjective::addAffExpr(const AffExpr& affexpr) +{ + exprInc(quad_, affexpr); +} +void ConvexObjective::addQuadExpr(const QuadExpr& quadexpr) +{ + exprInc(quad_, quadexpr); +} +void ConvexObjective::addHinge(const AffExpr& affexpr, double coeff) +{ + Var hinge = model_->addVar("hinge", 0, INFINITY); + vars_.push_back(hinge); + ineqs_.push_back(affexpr); + exprDec(ineqs_.back(), hinge); + AffExpr hinge_cost = exprMult(AffExpr(hinge), coeff); + exprInc(quad_, hinge_cost); +} + +void ConvexObjective::addAbs(const AffExpr& affexpr, double coeff) +{ + Var neg = model_->addVar("neg", 0, INFINITY); + Var pos = model_->addVar("pos", 0, INFINITY); + vars_.push_back(neg); + vars_.push_back(pos); + AffExpr neg_plus_pos; + neg_plus_pos.coeffs = DblVec(2, coeff); + neg_plus_pos.vars.push_back(neg); + neg_plus_pos.vars.push_back(pos); + exprInc(quad_, neg_plus_pos); + AffExpr affeq = affexpr; + affeq.vars.push_back(neg); + affeq.vars.push_back(pos); + affeq.coeffs.push_back(1); + affeq.coeffs.push_back(-1); + eqs_.push_back(affeq); +} + +void ConvexObjective::addHinges(const AffExprVector& ev) +{ + for (size_t i = 0; i < ev.size(); ++i) + addHinge(ev[i], 1); +} + +void ConvexObjective::addL1Norm(const AffExprVector& ev) +{ + for (size_t i = 0; i < ev.size(); ++i) + addAbs(ev[i], 1); +} + +void ConvexObjective::addL2Norm(const AffExprVector& ev) +{ + for (size_t i = 0; i < ev.size(); ++i) + exprInc(quad_, exprSquare(ev[i])); +} + +void ConvexObjective::addMax(const AffExprVector& ev) +{ + Var m = model_->addVar("max", -INFINITY, INFINITY); + for (size_t i = 0; i < ev.size(); ++i) + { + ineqs_.push_back(ev[i]); + exprDec(ineqs_.back(), m); + } +} + +void ConvexObjective::addConstraintsToModel() +{ + cnts_.reserve(eqs_.size() + ineqs_.size()); + for (const AffExpr& aff : eqs_) + { + cnts_.push_back(model_->addEqCnt(aff, "")); + } + for (const AffExpr& aff : ineqs_) + { + cnts_.push_back(model_->addIneqCnt(aff, "")); + } +} + +void ConvexObjective::removeFromModel() +{ + model_->removeCnts(cnts_); + model_->removeVars(vars_); + model_ = nullptr; +} +ConvexObjective::~ConvexObjective() +{ + if (inModel()) + removeFromModel(); +} + +void ConvexConstraints::addEqCnt(const AffExpr& aff) +{ + eqs_.push_back(aff); +} +void ConvexConstraints::addIneqCnt(const AffExpr& aff) +{ + ineqs_.push_back(aff); +} +void ConvexConstraints::addConstraintsToModel() +{ + cnts_.reserve(eqs_.size() + ineqs_.size()); + for (const AffExpr& aff : eqs_) + { + cnts_.push_back(model_->addEqCnt(aff, "")); + } + for (const AffExpr& aff : ineqs_) + { + cnts_.push_back(model_->addIneqCnt(aff, "")); + } +} + +void ConvexConstraints::removeFromModel() +{ + model_->removeCnts(cnts_); + model_ = nullptr; +} + +DblVec ConvexConstraints::violations(const DblVec& x) +{ + DblVec out; + out.reserve(eqs_.size() + ineqs_.size()); + for (const AffExpr& aff : eqs_) + out.push_back(fabs(aff.value(x.data()))); + for (const AffExpr& aff : ineqs_) + out.push_back(pospart(aff.value(x.data()))); + return out; +} +double ConvexConstraints::violation(const DblVec& x) +{ + return vecSum(violations(x)); +} +ConvexConstraints::~ConvexConstraints() +{ + if (inModel()) + removeFromModel(); +} + +double ConvexObjective::value(const DblVec& x) +{ + return quad_.value(x); +} +DblVec Constraint::violations(const DblVec& x) +{ + DblVec val = value(x); + DblVec out(val.size()); + + if (type() == EQ) + { + for (size_t i = 0; i < val.size(); ++i) + out[i] = fabs(val[i]); + } + else + { // type() == INEQ + for (size_t i = 0; i < val.size(); ++i) + out[i] = pospart(val[i]); + } + + return out; +} + +double Constraint::violation(const DblVec& x) +{ + return vecSum(violations(x)); +} +OptProb::OptProb(ModelType convex_solver) : model_(createModel(convex_solver)) +{ +} +VarVector OptProb::createVariables(const std::vector& var_names) +{ + return createVariables(var_names, DblVec(var_names.size(), -INFINITY), DblVec(var_names.size(), INFINITY)); +} + +VarVector OptProb::createVariables(const std::vector& var_names, const DblVec& lb, const DblVec& ub) +{ + size_t n_add = var_names.size(), n_cur = vars_.size(); + assert(lb.size() == n_add); + assert(ub.size() == n_add); + vars_.reserve(n_cur + n_add); + lower_bounds_.reserve(n_cur + n_add); + upper_bounds_.reserve(n_cur + n_add); + for (size_t i = 0; i < var_names.size(); ++i) + { + vars_.push_back(model_->addVar(var_names[i], lb[i], ub[i])); + lower_bounds_.push_back(lb[i]); + upper_bounds_.push_back(ub[i]); + } + model_->update(); + return VarVector(vars_.end() - static_cast(n_add), vars_.end()); +} + +void OptProb::setLowerBounds(const DblVec& lb) +{ + assert(lb.size() == vars_.size()); + lower_bounds_ = lb; +} + +void OptProb::setUpperBounds(const DblVec& ub) +{ + assert(ub.size() == vars_.size()); + upper_bounds_ = ub; +} + +void OptProb::setLowerBounds(const DblVec& lb, const VarVector& vars) +{ + setVec(lower_bounds_, vars, lb); +} +void OptProb::setUpperBounds(const DblVec& ub, const VarVector& vars) +{ + setVec(upper_bounds_, vars, ub); +} +void OptProb::addCost(CostPtr cost) +{ + costs_.push_back(cost); +} +void OptProb::addConstraint(ConstraintPtr cnt) +{ + if (cnt->type() == EQ) + addEqConstraint(cnt); + else + addIneqConstraint(cnt); +} + +void OptProb::addEqConstraint(ConstraintPtr cnt) +{ + assert(cnt->type() == EQ); + eqcnts_.push_back(cnt); +} + +void OptProb::addIneqConstraint(ConstraintPtr cnt) +{ + assert(cnt->type() == INEQ); + ineqcnts_.push_back(cnt); +} + +std::vector OptProb::getConstraints() const +{ + std::vector out; + out.reserve(eqcnts_.size() + ineqcnts_.size()); + out.insert(out.end(), eqcnts_.begin(), eqcnts_.end()); + out.insert(out.end(), ineqcnts_.begin(), ineqcnts_.end()); + return out; +} + +void OptProb::addLinearConstraint(const AffExpr& expr, ConstraintType type) +{ + if (type == EQ) + model_->addEqCnt(expr, ""); + else + model_->addIneqCnt(expr, ""); +} + +DblVec OptProb::getCentralFeasiblePoint(const DblVec& x) +{ + assert(x.size() == lower_bounds_.size()); + DblVec center(x.size()); + for (unsigned i = 0; i < x.size(); ++i) + center[i] = (lower_bounds_[i] + upper_bounds_[i]) / 2; + return getClosestFeasiblePoint(center); +} + +DblVec OptProb::getClosestFeasiblePoint(const DblVec& x) +{ + LOG_DEBUG("getClosestFeasiblePoint"); + assert(vars_.size() == x.size()); + QuadExpr obj; + for (unsigned i = 0; i < x.size(); ++i) + { + exprInc(obj, exprSquare(exprSub(AffExpr(vars_[i]), x[i]))); + } + model_->setVarBounds(vars_, lower_bounds_, upper_bounds_); + model_->setObjective(obj); + CvxOptStatus status = model_->optimize(); + if (status != CVX_SOLVED) + { + model_->writeToFile("/tmp/fail.lp"); + PRINT_AND_THROW("couldn't find a feasible point. there's probably a " + "problem with variable bounds (e.g. joint limits). wrote " + "to /tmp/fail.lp"); + } + return model_->getVarValues(vars_); +} +} // namespace sco diff --git a/moveit_planners/trajopt/trajopt_sco/src/modeling_utils.cpp b/moveit_planners/trajopt/trajopt_sco/src/modeling_utils.cpp new file mode 100644 index 0000000000..760677f0d3 --- /dev/null +++ b/moveit_planners/trajopt/trajopt_sco/src/modeling_utils.cpp @@ -0,0 +1,253 @@ +#include +TRAJOPT_IGNORE_WARNINGS_PUSH +#include +#include +TRAJOPT_IGNORE_WARNINGS_POP + +#include +#include +#include +#include + +namespace sco +{ +const double DEFAULT_EPSILON = 1e-5; + +Eigen::VectorXd getVec(const DblVec& x, const VarVector& vars) +{ + Eigen::VectorXd out(vars.size()); + for (unsigned i = 0; i < vars.size(); ++i) + out[i] = x[static_cast(vars[i].var_rep->index)]; + return out; +} + +DblVec getDblVec(const DblVec& x, const VarVector& vars) +{ + DblVec out(vars.size()); + for (unsigned i = 0; i < vars.size(); ++i) + out[i] = x[static_cast(vars[i].var_rep->index)]; + return out; +} + +AffExpr affFromValGrad(double y, const Eigen::VectorXd& x, const Eigen::VectorXd& dydx, const VarVector& vars) +{ + AffExpr aff; + aff.constant = y - dydx.dot(x); + aff.coeffs = util::toDblVec(dydx); + aff.vars = vars; + aff = cleanupAff(aff); + return aff; +} + +CostFromFunc::CostFromFunc(ScalarOfVectorPtr f, const VarVector& vars, const std::string& name, bool full_hessian) + : Cost(name), f_(f), vars_(vars), full_hessian_(full_hessian), epsilon_(DEFAULT_EPSILON) +{ +} + +double CostFromFunc::value(const DblVec& xin) +{ + Eigen::VectorXd x = getVec(xin, vars_); + return f_->call(x); +} + +ConvexObjectivePtr CostFromFunc::convex(const DblVec& xin, Model* model) +{ + Eigen::VectorXd x = getVec(xin, vars_); + + ConvexObjectivePtr out(new ConvexObjective(model)); + if (!full_hessian_) + { + double val; + Eigen::VectorXd grad, hess; + calcGradAndDiagHess(*f_, x, epsilon_, val, grad, hess); + hess = hess.cwiseMax(Eigen::VectorXd::Zero(hess.size())); + QuadExpr& quad = out->quad_; + quad.affexpr.constant = val - grad.dot(x) + .5 * x.dot(hess.cwiseProduct(x)); + quad.affexpr.vars = vars_; + quad.affexpr.coeffs = util::toDblVec(grad - hess.cwiseProduct(x)); + quad.vars1 = vars_; + quad.vars2 = vars_; + quad.coeffs = util::toDblVec(hess * .5); + } + else + { + double val; + Eigen::VectorXd grad; + Eigen::MatrixXd hess; + calcGradHess(f_, x, epsilon_, val, grad, hess); + + Eigen::MatrixXd pos_hess = Eigen::MatrixXd::Zero(x.size(), x.size()); + Eigen::SelfAdjointEigenSolver es(hess); + Eigen::VectorXd eigvals = es.eigenvalues(); + Eigen::MatrixXd eigvecs = es.eigenvectors(); + for (long int i = 0, end = x.size(); i != end; ++i) + { // tricky --- eigen size() is signed + if (eigvals(i) > 0) + pos_hess += eigvals(i) * eigvecs.col(i) * eigvecs.col(i).transpose(); + } + + QuadExpr& quad = out->quad_; + quad.affexpr.constant = val - grad.dot(x) + .5 * x.dot(pos_hess * x); + quad.affexpr.vars = vars_; + quad.affexpr.coeffs = util::toDblVec(grad - pos_hess * x); + + size_t nquadterms = static_cast((x.size() * (x.size() - 1)) / 2); + quad.coeffs.reserve(nquadterms); + quad.vars1.reserve(nquadterms); + quad.vars2.reserve(nquadterms); + for (long int i = 0, end = x.size(); i != end; ++i) + { // tricky --- eigen size() is signed + quad.vars1.push_back(vars_[static_cast(i)]); + quad.vars2.push_back(vars_[static_cast(i)]); + quad.coeffs.push_back(pos_hess(i, i) / 2); + for (long int j = i + 1; j != end; ++j) + { // tricky --- eigen size() is signed + quad.vars1.push_back(vars_[static_cast(i)]); + quad.vars2.push_back(vars_[static_cast(j)]); + quad.coeffs.push_back(pos_hess(i, j)); + } + } + } + + return out; +} + +CostFromErrFunc::CostFromErrFunc(VectorOfVectorPtr f, const VarVector& vars, const Eigen::VectorXd& coeffs, + PenaltyType pen_type, const std::string& name) + : Cost(name), f_(f), vars_(vars), coeffs_(coeffs), pen_type_(pen_type), epsilon_(DEFAULT_EPSILON) +{ +} +CostFromErrFunc::CostFromErrFunc(VectorOfVectorPtr f, MatrixOfVectorPtr dfdx, const VarVector& vars, + const Eigen::VectorXd& coeffs, PenaltyType pen_type, const std::string& name) + : Cost(name), f_(f), dfdx_(dfdx), vars_(vars), coeffs_(coeffs), pen_type_(pen_type), epsilon_(DEFAULT_EPSILON) +{ +} +double CostFromErrFunc::value(const DblVec& xin) +{ + Eigen::VectorXd x = getVec(xin, vars_); + Eigen::VectorXd err = f_->call(x); + + switch (pen_type_) + { + case SQUARED: + err = err.array().square(); + break; + case ABS: + err = err.array().abs(); + break; + case HINGE: + err = err.cwiseMax(Eigen::VectorXd::Zero(err.size())); + break; + default: + assert(0 && "unreachable"); + } + + if (coeffs_.size() > 0) + err.array() *= coeffs_.array(); + + return err.array().sum(); +} +ConvexObjectivePtr CostFromErrFunc::convex(const DblVec& xin, Model* model) +{ + Eigen::VectorXd x = getVec(xin, vars_); + Eigen::MatrixXd jac = (dfdx_) ? dfdx_->call(x) : calcForwardNumJac(*f_, x, epsilon_); + ConvexObjectivePtr out(new ConvexObjective(model)); + Eigen::VectorXd y = f_->call(x); + for (int i = 0; i < jac.rows(); ++i) + { + AffExpr aff = affFromValGrad(y[i], x, jac.row(i), vars_); + double weight = 1; + if (coeffs_.size() > 0) + { + if (coeffs_[i] == 0) + continue; + + weight = coeffs_[i]; + } + switch (pen_type_) + { + case SQUARED: + { + QuadExpr quad = exprSquare(aff); + exprScale(quad, weight); + out->addQuadExpr(quad); + break; + } + case ABS: + { + exprScale(aff, weight); + out->addAbs(aff, 1); + break; + } + case HINGE: + { + exprScale(aff, weight); + out->addHinge(aff, 1); + break; + } + default: + assert(0 && "unreachable"); + } + } + return out; +} + +ConstraintFromErrFunc::ConstraintFromErrFunc(VectorOfVectorPtr f, const VarVector& vars, const Eigen::VectorXd& coeffs, + ConstraintType type, const std::string& name) + : Constraint(name), f_(f), vars_(vars), coeffs_(coeffs), type_(type), epsilon_(DEFAULT_EPSILON) +{ +} + +ConstraintFromErrFunc::ConstraintFromErrFunc(VectorOfVectorPtr f, MatrixOfVectorPtr dfdx, const VarVector& vars, + const Eigen::VectorXd& coeffs, ConstraintType type, + const std::string& name) + : Constraint(name), f_(f), dfdx_(dfdx), vars_(vars), coeffs_(coeffs), type_(type), epsilon_(DEFAULT_EPSILON) +{ +} + +DblVec ConstraintFromErrFunc::value(const DblVec& xin) +{ + Eigen::VectorXd x = getVec(xin, vars_); + Eigen::VectorXd err = f_->call(x); + if (coeffs_.size() > 0) + err.array() *= coeffs_.array(); + return util::toDblVec(err); +} + +ConvexConstraintsPtr ConstraintFromErrFunc::convex(const DblVec& xin, Model* model) +{ + Eigen::VectorXd x = getVec(xin, vars_); + Eigen::MatrixXd jac = (dfdx_) ? dfdx_->call(x) : calcForwardNumJac(*f_, x, epsilon_); + ConvexConstraintsPtr out(new ConvexConstraints(model)); + Eigen::VectorXd y = f_->call(x); + for (int i = 0; i < jac.rows(); ++i) + { + AffExpr aff = affFromValGrad(y[i], x, jac.row(i), vars_); + if (coeffs_.size() > 0) + { + if (coeffs_[i] == 0) + continue; + exprScale(aff, coeffs_[i]); + } + if (type() == INEQ) + out->addIneqCnt(aff); + else + out->addEqCnt(aff); + } + return out; +} + +std::string AffExprToString(const AffExpr& aff) +{ + std::string out; + for (size_t i = 0; i < aff.vars.size(); i++) + { + if (i != 0) + out.append(" + "); + std::string term = std::to_string(aff.coeffs[i]) + "*" + aff.vars[i].var_rep->name; + out.append(term); + } + out.append(" + " + std::to_string(aff.constant)); + return out; +} +} diff --git a/moveit_planners/trajopt/trajopt_sco/src/num_diff.cpp b/moveit_planners/trajopt/trajopt_sco/src/num_diff.cpp new file mode 100644 index 0000000000..4277cf5035 --- /dev/null +++ b/moveit_planners/trajopt/trajopt_sco/src/num_diff.cpp @@ -0,0 +1,130 @@ +#include + +namespace sco +{ +ScalarOfVectorPtr ScalarOfVector::construct(const func& f) +{ + struct F : public ScalarOfVector + { + func f; + F(const func& _f) : f(_f) + { + } + double operator()(const Eigen::VectorXd& x) const override + { + return f(x); + } + }; + ScalarOfVector* sov = new F(f); // to avoid erroneous clang warning + return ScalarOfVectorPtr(sov); +} +VectorOfVectorPtr VectorOfVector::construct(const func& f) +{ + struct F : public VectorOfVector + { + func f; + F(const func& _f) : f(_f) + { + } + Eigen::VectorXd operator()(const Eigen::VectorXd& x) const override + { + return f(x); + } + }; + VectorOfVector* vov = new F(f); // to avoid erroneous clang warning + return VectorOfVectorPtr(vov); +} + +Eigen::VectorXd calcForwardNumGrad(const ScalarOfVector& f, const Eigen::VectorXd& x, double epsilon) +{ + Eigen::VectorXd out(x.size()); + Eigen::VectorXd xpert = x; + double y = f(x); + for (int i = 0; i < x.size(); ++i) + { + xpert(i) = x(i) + epsilon; + double ypert = f(xpert); + out(i) = (ypert - y) / epsilon; + xpert(i) = x(i); + } + return out; +} +Eigen::MatrixXd calcForwardNumJac(const VectorOfVector& f, const Eigen::VectorXd& x, double epsilon) +{ + Eigen::VectorXd y = f(x); + Eigen::MatrixXd out(y.size(), x.size()); + Eigen::VectorXd xpert = x; + for (int i = 0; i < x.size(); ++i) + { + xpert(i) = x(i) + epsilon; + Eigen::VectorXd ypert = f(xpert); + out.col(i) = (ypert - y) / epsilon; + xpert(i) = x(i); + } + return out; +} + +void calcGradAndDiagHess(const ScalarOfVector& f, const Eigen::VectorXd& x, double epsilon, double& y, + Eigen::VectorXd& grad, Eigen::VectorXd& hess) +{ + y = f(x); + grad.resize(x.size()); + hess.resize(x.size()); + Eigen::VectorXd xpert = x; + for (int i = 0; i < x.size(); ++i) + { + xpert(i) = x(i) + epsilon / 2; + double yplus = f(xpert); + xpert(i) = x(i) - epsilon / 2; + double yminus = f(xpert); + grad(i) = (yplus - yminus) / epsilon; + hess(i) = (yplus + yminus - 2 * y) / (epsilon * epsilon / 4); + xpert(i) = x(i); + } +} + +void calcGradHess(ScalarOfVectorPtr f, const Eigen::VectorXd& x, double epsilon, double& y, Eigen::VectorXd& grad, + Eigen::MatrixXd& hess) +{ + y = f->call(x); + VectorOfVectorPtr grad_func = forwardNumGrad(f, epsilon); + grad = grad_func->call(x); + hess = calcForwardNumJac(*grad_func, x, epsilon); + hess = (hess + hess.transpose()) / 2; +} + +struct ForwardNumGrad : public VectorOfVector +{ + ScalarOfVectorPtr f_; + double epsilon_; + ForwardNumGrad(ScalarOfVectorPtr f, double epsilon) : f_(f), epsilon_(epsilon) + { + } + Eigen::VectorXd operator()(const Eigen::VectorXd& x) const override + { + return calcForwardNumGrad(*f_, x, epsilon_); + } +}; + +struct ForwardNumJac : public MatrixOfVector +{ + VectorOfVectorPtr f_; + double epsilon_; + ForwardNumJac(VectorOfVectorPtr f, double epsilon) : f_(f), epsilon_(epsilon) + { + } + Eigen::MatrixXd operator()(const Eigen::VectorXd& x) const override + { + return calcForwardNumJac(*f_, x, epsilon_); + } +}; + +VectorOfVectorPtr forwardNumGrad(ScalarOfVectorPtr f, double epsilon) +{ + return VectorOfVectorPtr(new ForwardNumGrad(f, epsilon)); +} +MatrixOfVectorPtr forwardNumJac(VectorOfVectorPtr f, double epsilon) +{ + return MatrixOfVectorPtr(new ForwardNumJac(f, epsilon)); +} +} diff --git a/moveit_planners/trajopt/trajopt_sco/src/optimizers.cpp b/moveit_planners/trajopt/trajopt_sco/src/optimizers.cpp new file mode 100644 index 0000000000..d541106c20 --- /dev/null +++ b/moveit_planners/trajopt/trajopt_sco/src/optimizers.cpp @@ -0,0 +1,462 @@ +#include +TRAJOPT_IGNORE_WARNINGS_PUSH +#include +#include +#include +TRAJOPT_IGNORE_WARNINGS_POP + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace sco +{ +std::ostream& operator<<(std::ostream& o, const OptResults& r) +{ + o << "Optimization results:" << std::endl + << "status: " << statusToString(r.status) << std::endl + << "cost values: " << util::Str(r.cost_vals) << std::endl + << "constraint violations: " << util::Str(r.cnt_viols) << std::endl + << "n func evals: " << r.n_func_evals << std::endl + << "n qp solves: " << r.n_qp_solves << std::endl; + return o; +} + +////////////////////////////////////////////////// +////////// private utility functions for sqp ///////// +////////////////////////////////////////////////// + +static DblVec evaluateCosts(const std::vector& costs, const DblVec& x) +{ + DblVec out(costs.size()); + for (size_t i = 0; i < costs.size(); ++i) + { + out[i] = costs[i]->value(x); + } + return out; +} +static DblVec evaluateConstraintViols(const std::vector& constraints, const DblVec& x) +{ + DblVec out(constraints.size()); + for (size_t i = 0; i < constraints.size(); ++i) + { + out[i] = constraints[i]->violation(x); + } + return out; +} +static std::vector convexifyCosts(const std::vector& costs, const DblVec& x, Model* model) +{ + std::vector out(costs.size()); + for (size_t i = 0; i < costs.size(); ++i) + { + out[i] = costs[i]->convex(x, model); + } + return out; +} +static std::vector convexifyConstraints(const std::vector& cnts, const DblVec& x, + Model* model) +{ + std::vector out(cnts.size()); + for (size_t i = 0; i < cnts.size(); ++i) + { + out[i] = cnts[i]->convex(x, model); + } + return out; +} + +DblVec evaluateModelCosts(const std::vector& costs, const DblVec& x) +{ + DblVec out(costs.size()); + for (size_t i = 0; i < costs.size(); ++i) + { + out[i] = costs[i]->value(x); + } + return out; +} +DblVec evaluateModelCntViols(const std::vector& cnts, const DblVec& x) +{ + DblVec out(cnts.size()); + for (size_t i = 0; i < cnts.size(); ++i) + { + out[i] = cnts[i]->violation(x); + } + return out; +} + +static std::vector getCostNames(const std::vector& costs) +{ + std::vector out(costs.size()); + for (size_t i = 0; i < costs.size(); ++i) + out[i] = costs[i]->name(); + return out; +} +static std::vector getCntNames(const std::vector& cnts) +{ + std::vector out(cnts.size()); + for (size_t i = 0; i < cnts.size(); ++i) + out[i] = cnts[i]->name(); + return out; +} + +void printCostInfo(const DblVec& old_cost_vals, const DblVec& model_cost_vals, const DblVec& new_cost_vals, + const DblVec& old_cnt_vals, const DblVec& model_cnt_vals, const DblVec& new_cnt_vals, + const std::vector& cost_names, const std::vector& cnt_names, + double merit_coeff) +{ + std::printf("%15s | %10s | %10s | %10s | %10s\n", "", "oldexact", "dapprox", "dexact", "ratio"); + std::printf("%15s | %10s---%10s---%10s---%10s\n", "COSTS", "----------", "----------", "----------", "----------"); + for (size_t i = 0; i < old_cost_vals.size(); ++i) + { + double approx_improve = old_cost_vals[i] - model_cost_vals[i]; + double exact_improve = old_cost_vals[i] - new_cost_vals[i]; + if (fabs(approx_improve) > 1e-8) + std::printf("%15s | %10.3e | %10.3e | %10.3e | %10.3e\n", cost_names[i].c_str(), old_cost_vals[i], approx_improve, + exact_improve, exact_improve / approx_improve); + else + std::printf("%15s | %10.3e | %10.3e | %10.3e | %10s\n", cost_names[i].c_str(), old_cost_vals[i], approx_improve, + exact_improve, " ------ "); + } + if (cnt_names.size() == 0) + return; + std::printf("%15s | %10s---%10s---%10s---%10s\n", "CONSTRAINTS", "----------", "----------", "----------", "---------" + "-"); + for (size_t i = 0; i < old_cnt_vals.size(); ++i) + { + double approx_improve = old_cnt_vals[i] - model_cnt_vals[i]; + double exact_improve = old_cnt_vals[i] - new_cnt_vals[i]; + if (fabs(approx_improve) > 1e-8) + std::printf("%15s | %10.3e | %10.3e | %10.3e | %10.3e\n", cnt_names[i].c_str(), merit_coeff * old_cnt_vals[i], + merit_coeff * approx_improve, merit_coeff * exact_improve, exact_improve / approx_improve); + else + std::printf("%15s | %10.3e | %10.3e | %10.3e | %10s\n", cnt_names[i].c_str(), merit_coeff * old_cnt_vals[i], + merit_coeff * approx_improve, merit_coeff * exact_improve, " ------ "); + } +} + +// todo: use different coeffs for each constraint +std::vector cntsToCosts(const std::vector& cnts, double err_coeff, + Model* model) +{ + std::vector out; + for (const ConvexConstraintsPtr& cnt : cnts) + { + ConvexObjectivePtr obj(new ConvexObjective(model)); + for (const AffExpr& aff : cnt->eqs_) + { + obj->addAbs(aff, err_coeff); + } + for (const AffExpr& aff : cnt->ineqs_) + { + obj->addHinge(aff, err_coeff); + } + out.push_back(obj); + } + return out; +} + +void Optimizer::addCallback(const Callback& cb) +{ + callbacks_.push_back(cb); +} +void Optimizer::callCallbacks() +{ + for (unsigned i = 0; i < callbacks_.size(); ++i) + { + callbacks_[i](prob_.get(), results_); + } +} + +void Optimizer::initialize(const DblVec& x) +{ + if (!prob_) + PRINT_AND_THROW("need to set the problem before initializing"); + if (prob_->getVars().size() != x.size()) + PRINT_AND_THROW(boost::format("initialization vector has wrong length. expected %i got %i") % + prob_->getVars().size() % x.size()); + results_.clear(); + results_.x = x; +} + +BasicTrustRegionSQPParameters::BasicTrustRegionSQPParameters() +{ + improve_ratio_threshold = 0.25; + min_trust_box_size = 1e-4; + min_approx_improve = 1e-4; + min_approx_improve_frac = -INFINITY; + max_iter = 50; + trust_shrink_ratio = 0.1; + trust_expand_ratio = 1.5; + cnt_tolerance = 1e-4; + max_merit_coeff_increases = 5; + merit_coeff_increase_ratio = 10; + max_time = INFINITY; + merit_error_coeff = 10; + trust_box_size = 1e-1; +} + +BasicTrustRegionSQP::BasicTrustRegionSQP() +{ +} +BasicTrustRegionSQP::BasicTrustRegionSQP(OptProbPtr prob) +{ + setProblem(prob); +} +void BasicTrustRegionSQP::setProblem(OptProbPtr prob) +{ + Optimizer::setProblem(prob); + model_ = prob->getModel(); +} + +void BasicTrustRegionSQP::adjustTrustRegion(double ratio) +{ + param_.trust_box_size *= ratio; +} +void BasicTrustRegionSQP::setTrustBoxConstraints(const DblVec& x) +{ + const VarVector& vars = prob_->getVars(); + assert(vars.size() == x.size()); + const DblVec &lb = prob_->getLowerBounds(), ub = prob_->getUpperBounds(); + DblVec lbtrust(x.size()), ubtrust(x.size()); + for (size_t i = 0; i < x.size(); ++i) + { + lbtrust[i] = fmax(x[i] - param_.trust_box_size, lb[i]); + ubtrust[i] = fmin(x[i] + param_.trust_box_size, ub[i]); + } + model_->setVarBounds(vars, lbtrust, ubtrust); +} + +#if 0 +struct MultiCritFilter { + /** + * Checks if you're making an improvement on a multidimensional objective + * Given a set of past error vectors, the improvement is defined as + * min_{olderrvec in past_err_vecs} | olderrvec - errvec |^+ + */ + vector errvecs; + double improvement(const DblVec& errvec) { + double leastImprovement=INFINITY; + for (const DblVec& olderrvec : errvecs) { + double improvement=0; + for (int i=0; i < errvec.size(); ++i) improvement += pospart(olderrvec[i] - errvec[i]); + leastImprovement = fmin(leastImprovement, improvement); + } + return leastImprovement; + } + void insert(const DblVec& x) {errvecs.push_back(x);} + bool empty() {return errvecs.size() > 0;} +}; +#endif + +OptStatus BasicTrustRegionSQP::optimize() +{ + std::vector cost_names = getCostNames(prob_->getCosts()); + std::vector constraints = prob_->getConstraints(); + std::vector cnt_names = getCntNames(constraints); + + if (results_.x.size() == 0) + PRINT_AND_THROW("you forgot to initialize!"); + if (!prob_) + PRINT_AND_THROW("you forgot to set the optimization problem"); + + results_.x = prob_->getClosestFeasiblePoint(results_.x); + + assert(results_.x.size() == prob_->getVars().size()); + assert(prob_->getCosts().size() > 0 || constraints.size() > 0); + + OptStatus retval = INVALID; + + for (int merit_increases = 0; merit_increases < param_.max_merit_coeff_increases; ++merit_increases) + { /* merit adjustment loop */ + for (int iter = 1;; ++iter) + { /* sqp loop */ + callCallbacks(); + + LOG_DEBUG("current iterate: %s", CSTR(results_.x)); + LOG_INFO("iteration %i", iter); + + // speedup: if you just evaluated the cost when doing the line search, use + // that + if (results_.cost_vals.empty() && results_.cnt_viols.empty()) + { // only happens on the first iteration + results_.cnt_viols = evaluateConstraintViols(constraints, results_.x); + results_.cost_vals = evaluateCosts(prob_->getCosts(), results_.x); + assert(results_.n_func_evals == 0); + ++results_.n_func_evals; + } + + // DblVec new_cnt_viols = evaluateConstraintViols(constraints, results_.x); + // DblVec new_cost_vals = evaluateCosts(prob_->getCosts(), results_.x); + // cout << "costs" << endl; + // for (int i=0; i < new_cnt_viols.size(); ++i) { + // cout << cnt_names[i] << " " << new_cnt_viols[i] - + // results_.cnt_viols[i] << endl; + // } + // for (int i=0; i < new_cost_vals.size(); ++i) { + // cout << cost_names[i] << " " << new_cost_vals[i] - + // results_.cost_vals[i] << endl; + // } + + std::vector cost_models = convexifyCosts(prob_->getCosts(), results_.x, model_.get()); + std::vector cnt_models = convexifyConstraints(constraints, results_.x, model_.get()); + std::vector cnt_cost_models = cntsToCosts(cnt_models, param_.merit_error_coeff, model_.get()); + model_->update(); + for (ConvexObjectivePtr& cost : cost_models) + cost->addConstraintsToModel(); + for (ConvexObjectivePtr& cost : cnt_cost_models) + cost->addConstraintsToModel(); + model_->update(); + QuadExpr objective; + for (ConvexObjectivePtr& co : cost_models) + exprInc(objective, co->quad_); + for (ConvexObjectivePtr& co : cnt_cost_models) + exprInc(objective, co->quad_); + + // objective = cleanupExpr(objective); + model_->setObjective(objective); + + // if (logging::filter() >= IPI_LEVEL_DEBUG) { + // DblVec model_cost_vals; + // for (ConvexObjectivePtr& cost : cost_models) { + // model_cost_vals.push_back(cost->value(x)); + // } + // LOG_DEBUG("model costs %s should equalcosts %s", + // printer(model_cost_vals), printer(cost_vals)); + // } + + while (param_.trust_box_size >= param_.min_trust_box_size) + { + setTrustBoxConstraints(results_.x); + CvxOptStatus status = model_->optimize(); + ++results_.n_qp_solves; + if (status != CVX_SOLVED) + { + LOG_ERROR("convex solver failed! set TRAJOPT_LOG_THRESH=DEBUG to see " + "solver output. saving model to /tmp/fail.lp and IIS to " + "/tmp/fail.ilp"); + model_->writeToFile("/tmp/fail.lp"); + model_->writeToFile("/tmp/fail.ilp"); + retval = OPT_FAILED; + goto cleanup; + } + DblVec model_var_vals = model_->getVarValues(model_->getVars()); + + DblVec model_cost_vals = evaluateModelCosts(cost_models, model_var_vals); + DblVec model_cnt_viols = evaluateModelCntViols(cnt_models, model_var_vals); + + // the n variables of the OptProb happen to be the first n variables in + // the Model + DblVec new_x(model_var_vals.begin(), model_var_vals.begin() + static_cast(results_.x.size())); + + if (util::GetLogLevel() >= util::LevelDebug) + { + DblVec cnt_costs1 = evaluateModelCosts(cnt_cost_models, model_var_vals); + DblVec cnt_costs2 = model_cnt_viols; + for (unsigned i = 0; i < cnt_costs2.size(); ++i) + cnt_costs2[i] *= param_.merit_error_coeff; + LOG_DEBUG("SHOULD BE ALMOST THE SAME: %s ?= %s", CSTR(cnt_costs1), CSTR(cnt_costs2)); + // not exactly the same because cnt_costs1 is based on aux variables, + // but they might not be at EXACTLY the right value + } + + DblVec new_cost_vals = evaluateCosts(prob_->getCosts(), new_x); + DblVec new_cnt_viols = evaluateConstraintViols(constraints, new_x); + ++results_.n_func_evals; + + double old_merit = vecSum(results_.cost_vals) + param_.merit_error_coeff * vecSum(results_.cnt_viols); + double model_merit = vecSum(model_cost_vals) + param_.merit_error_coeff * vecSum(model_cnt_viols); + double new_merit = vecSum(new_cost_vals) + param_.merit_error_coeff * vecSum(new_cnt_viols); + double approx_merit_improve = old_merit - model_merit; + double exact_merit_improve = old_merit - new_merit; + double merit_improve_ratio = exact_merit_improve / approx_merit_improve; + + if (util::GetLogLevel() >= util::LevelInfo) + { + LOG_INFO(" "); + printCostInfo(results_.cost_vals, model_cost_vals, new_cost_vals, results_.cnt_viols, model_cnt_viols, + new_cnt_viols, cost_names, cnt_names, param_.merit_error_coeff); + std::printf("%15s | %10.3e | %10.3e | %10.3e | %10.3e\n", "TOTAL", old_merit, approx_merit_improve, + exact_merit_improve, merit_improve_ratio); + } + + if (approx_merit_improve < -1e-5) + { + LOG_ERROR("approximate merit function got worse (%.3e). " + "(convexification is probably wrong to zeroth order)", + approx_merit_improve); + } + if (approx_merit_improve < param_.min_approx_improve) + { + LOG_INFO("converged because improvement was small (%.3e < %.3e)", approx_merit_improve, + param_.min_approx_improve); + retval = OPT_CONVERGED; + goto penaltyadjustment; + } + if (approx_merit_improve / old_merit < param_.min_approx_improve_frac) + { + LOG_INFO("converged because improvement ratio was small (%.3e < %.3e)", approx_merit_improve / old_merit, + param_.min_approx_improve_frac); + retval = OPT_CONVERGED; + goto penaltyadjustment; + } + else if (exact_merit_improve < 0 || merit_improve_ratio < param_.improve_ratio_threshold) + { + adjustTrustRegion(param_.trust_shrink_ratio); + LOG_INFO("shrunk trust region. new box size: %.4f", param_.trust_box_size); + } + else + { + results_.x = new_x; + results_.cost_vals = new_cost_vals; + results_.cnt_viols = new_cnt_viols; + adjustTrustRegion(param_.trust_expand_ratio); + LOG_INFO("expanded trust region. new box size: %.4f", param_.trust_box_size); + break; + } + } + + if (param_.trust_box_size < param_.min_trust_box_size) + { + LOG_INFO("converged because trust region is tiny"); + retval = OPT_CONVERGED; + goto penaltyadjustment; + } + else if (iter >= param_.max_iter) + { + LOG_INFO("iteration limit"); + retval = OPT_SCO_ITERATION_LIMIT; + goto cleanup; + } + } + + penaltyadjustment: + if (results_.cnt_viols.empty() || vecMax(results_.cnt_viols) < param_.cnt_tolerance) + { + if (results_.cnt_viols.size() > 0) + LOG_INFO("woo-hoo! constraints are satisfied (to tolerance %.2e)", param_.cnt_tolerance); + goto cleanup; + } + else + { + LOG_INFO("not all constraints are satisfied. increasing penalties"); + param_.merit_error_coeff *= param_.merit_coeff_increase_ratio; + param_.trust_box_size = fmax(param_.trust_box_size, param_.min_trust_box_size / param_.trust_shrink_ratio * 1.5); + } + } + retval = OPT_PENALTY_ITERATION_LIMIT; + LOG_INFO("optimization couldn't satisfy all constraints"); + +cleanup: + assert(retval != INVALID && "should never happen"); + results_.status = retval; + results_.total_cost = vecSum(results_.cost_vals); + LOG_INFO("\n==================\n%s==================", CSTR(results_)); + callCallbacks(); + + return retval; +} +} // namespace sco diff --git a/moveit_planners/trajopt/trajopt_sco/src/osqp_interface.cpp b/moveit_planners/trajopt/trajopt_sco/src/osqp_interface.cpp new file mode 100644 index 0000000000..a3dffa4c7b --- /dev/null +++ b/moveit_planners/trajopt/trajopt_sco/src/osqp_interface.cpp @@ -0,0 +1,271 @@ +#include +TRAJOPT_IGNORE_WARNINGS_PUSH +#include +#include +#include +#include +#include +TRAJOPT_IGNORE_WARNINGS_POP + +#include +#include +#include +#include + +namespace sco +{ +double OSQP_INFINITY = std::numeric_limits::infinity(); + +ModelPtr createOSQPModel() +{ + ModelPtr out(new OSQPModel()); + return out; +} + +OSQPModel::OSQPModel() +{ + // Define Solver settings as default + // see https://osqp.org/docs/interfaces/solver_settings.html#solver-settings + osqp_set_default_settings(&osqp_settings_); + // tuning parameters to be less accurate, but add a polishing step + osqp_settings_.eps_abs = 1e-4; + osqp_settings_.eps_rel = 1e-6; + osqp_settings_.max_iter = 8192; + osqp_settings_.polish = 1; + osqp_settings_.verbose = false; + + // Initialize data + osqp_data_.A = nullptr; + osqp_data_.P = nullptr; + osqp_workspace_ = nullptr; +} + +OSQPModel::~OSQPModel() +{ + // Cleanup + if (osqp_workspace_ != nullptr) + osqp_cleanup(osqp_workspace_); + if (osqp_data_.A != nullptr) + c_free(osqp_data_.A); + if (osqp_data_.P != nullptr) + c_free(osqp_data_.P); +} + +Var OSQPModel::addVar(const std::string& name) +{ + vars_.push_back(new VarRep(vars_.size(), name, this)); + lbs_.push_back(-OSQP_INFINITY); + ubs_.push_back(OSQP_INFINITY); + return vars_.back(); +} + +Cnt OSQPModel::addEqCnt(const AffExpr& expr, const std::string& /*name*/) +{ + cnts_.push_back(new CntRep(cnts_.size(), this)); + cnt_exprs_.push_back(expr); + cnt_types_.push_back(EQ); + return cnts_.back(); +} + +Cnt OSQPModel::addIneqCnt(const AffExpr& expr, const std::string& /*name*/) +{ + cnts_.push_back(new CntRep(cnts_.size(), this)); + cnt_exprs_.push_back(expr); + cnt_types_.push_back(INEQ); + return cnts_.back(); +} + +Cnt OSQPModel::addIneqCnt(const QuadExpr&, const std::string& /*name*/) +{ + throw std::runtime_error("NOT IMPLEMENTED"); + return Cnt(); +} + +void OSQPModel::removeVars(const VarVector& vars) +{ + IntVec inds = vars2inds(vars); + for (unsigned i = 0; i < vars.size(); ++i) + vars[i].var_rep->removed = true; +} + +void OSQPModel::removeCnts(const CntVector& cnts) +{ + IntVec inds = cnts2inds(cnts); + for (unsigned i = 0; i < cnts.size(); ++i) + cnts[i].cnt_rep->removed = true; +} + +void OSQPModel::updateObjective() +{ + const size_t n = vars_.size(); + osqp_data_.n = n; + + Eigen::SparseMatrix sm; + exprToEigen(objective_, sm, q_, n, true); + eigenToCSC(sm, P_row_indices_, P_column_pointers_, P_csc_data_); + + if (osqp_data_.P != nullptr) + c_free(osqp_data_.P); + osqp_data_.P = csc_matrix(osqp_data_.n, osqp_data_.n, P_csc_data_.size(), P_csc_data_.data(), P_row_indices_.data(), + P_column_pointers_.data()); + + osqp_data_.q = q_.data(); +} + +void OSQPModel::updateConstraints() +{ + const size_t n = vars_.size(); + const size_t m = cnts_.size(); + osqp_data_.m = m + n; + + Eigen::SparseMatrix sm; + Eigen::VectorXd v; + exprToEigen(cnt_exprs_, sm, v, n); + Eigen::SparseMatrix sm_e(m + n, n); + Eigen::SparseMatrix sm_e2 = sm; + sm.conservativeResize(m + n, Eigen::NoChange_t(n)); + + l_.clear(); + l_.resize(m + n, -OSQP_INFINITY); + u_.clear(); + u_.resize(m + n, OSQP_INFINITY); + + for (int i_cnt = 0; i_cnt < m; ++i_cnt) + { + l_[i_cnt] = (cnt_types_[i_cnt] == INEQ) ? -OSQP_INFINITY : v[i_cnt]; + u_[i_cnt] = v[i_cnt]; + } + + for (int i_bnd = 0; i_bnd < n; ++i_bnd) + { + l_[i_bnd + m] = fmax(lbs_[i_bnd], -OSQP_INFINITY); + u_[i_bnd + m] = fmin(ubs_[i_bnd], OSQP_INFINITY); + sm.insert(i_bnd + m, i_bnd) = 1.; + } + + eigenToCSC(sm, A_row_indices_, A_column_pointers_, A_csc_data_); + + if (osqp_data_.A != nullptr) + c_free(osqp_data_.A); + osqp_data_.A = csc_matrix(osqp_data_.m, osqp_data_.n, A_csc_data_.size(), A_csc_data_.data(), A_row_indices_.data(), + A_column_pointers_.data()); + + osqp_data_.l = l_.data(); + osqp_data_.u = u_.data(); +} + +void OSQPModel::createOrUpdateSolver() +{ + updateObjective(); + updateConstraints(); + + // TODO atm we are not updating the workspace, but recreating it each time. + // In the future, we will checking sparsity did not change and update instead + if (osqp_workspace_ != nullptr) + osqp_cleanup(osqp_workspace_); + // Setup workspace - this should be called only once + osqp_workspace_ = osqp_setup(&osqp_data_, &osqp_settings_); +} + +void OSQPModel::update() +{ + { + int inew = 0; + for (unsigned iold = 0; iold < vars_.size(); ++iold) + { + const Var& var = vars_[iold]; + if (!var.var_rep->removed) + { + vars_[inew] = var; + lbs_[inew] = lbs_[iold]; + ubs_[inew] = ubs_[iold]; + var.var_rep->index = inew; + ++inew; + } + else + delete var.var_rep; + } + vars_.resize(inew); + lbs_.resize(inew); + ubs_.resize(inew); + } + { + int inew = 0; + for (unsigned iold = 0; iold < cnts_.size(); ++iold) + { + const Cnt& cnt = cnts_[iold]; + if (!cnt.cnt_rep->removed) + { + cnts_[inew] = cnt; + cnt_exprs_[inew] = cnt_exprs_[iold]; + cnt_types_[inew] = cnt_types_[iold]; + cnt.cnt_rep->index = inew; + ++inew; + } + else + delete cnt.cnt_rep; + } + cnts_.resize(inew); + cnt_exprs_.resize(inew); + cnt_types_.resize(inew); + } +} + +void OSQPModel::setVarBounds(const VarVector& vars, const DblVec& lower, const DblVec& upper) +{ + for (unsigned i = 0; i < vars.size(); ++i) + { + const int varind = vars[i].var_rep->index; + lbs_[varind] = lower[i]; + ubs_[varind] = upper[i]; + } +} +DblVec OSQPModel::getVarValues(const VarVector& vars) const +{ + DblVec out(vars.size()); + for (unsigned i = 0; i < vars.size(); ++i) + { + const int varind = vars[i].var_rep->index; + out[i] = solution_[varind]; + } + return out; +} + +CvxOptStatus OSQPModel::optimize() +{ + update(); + createOrUpdateSolver(); + + // Solve Problem + const int retcode = osqp_solve(osqp_workspace_); + + if (retcode == 0) + { + // opt += m_objective.affexpr.constant; + solution_ = DblVec(osqp_workspace_->solution->x, osqp_workspace_->solution->x + vars_.size()); + int status = osqp_workspace_->info->status_val; + if (status == OSQP_SOLVED || status == OSQP_SOLVED_INACCURATE) + return CVX_SOLVED; + else if (status == OSQP_PRIMAL_INFEASIBLE || status == OSQP_PRIMAL_INFEASIBLE_INACCURATE || + status == OSQP_DUAL_INFEASIBLE || status == OSQP_DUAL_INFEASIBLE_INACCURATE) + return CVX_INFEASIBLE; + } + return CVX_FAILED; +} +void OSQPModel::setObjective(const AffExpr& expr) +{ + objective_.affexpr = expr; +} +void OSQPModel::setObjective(const QuadExpr& expr) +{ + objective_ = expr; +} +void OSQPModel::writeToFile(const std::string& /*fname*/) +{ + return; // NOT IMPLEMENTED +} +VarVector OSQPModel::getVars() const +{ + return vars_; +} +} diff --git a/moveit_planners/trajopt/trajopt_sco/src/qpoases_interface.cpp b/moveit_planners/trajopt/trajopt_sco/src/qpoases_interface.cpp new file mode 100644 index 0000000000..d3140cf0ee --- /dev/null +++ b/moveit_planners/trajopt/trajopt_sco/src/qpoases_interface.cpp @@ -0,0 +1,262 @@ +#include +TRAJOPT_IGNORE_WARNINGS_PUSH +#include +#include +#include +#include +TRAJOPT_IGNORE_WARNINGS_POP + +#include +#include +#include +#include + +using namespace qpOASES; + +namespace sco +{ +double QPOASES_INFTY = qpOASES::INFTY; + +ModelPtr createqpOASESModel() +{ + ModelPtr out(new qpOASESModel()); + return out; +} + +qpOASESModel::qpOASESModel() +{ + // set to be fast. More details at: + // https://www.coin-or.org/qpOASES/doc/3.2/doxygen/classOptions.html + // https://projects.coin-or.org/qpOASES/browser/stable/3.2/src/Options.cpp#L191 + qpoases_options_.setToMPC(); + qpoases_options_.printLevel = qpOASES::PL_NONE; + // enable regularisation to deal with degenerate Hessians + qpoases_options_.enableRegularisation = qpOASES::BT_TRUE; + qpoases_options_.ensureConsistency(); +} + +qpOASESModel::~qpOASESModel() +{ +} +Var qpOASESModel::addVar(const std::string& name) +{ + vars_.push_back(new VarRep(vars_.size(), name, this)); + lb_.push_back(-QPOASES_INFTY); + ub_.push_back(QPOASES_INFTY); + return vars_.back(); +} + +Cnt qpOASESModel::addEqCnt(const AffExpr& expr, const std::string& /*name*/) +{ + cnts_.push_back(new CntRep(cnts_.size(), this)); + cnt_exprs_.push_back(expr); + cnt_types_.push_back(EQ); + return cnts_.back(); +} + +Cnt qpOASESModel::addIneqCnt(const AffExpr& expr, const std::string& /*name*/) +{ + cnts_.push_back(new CntRep(cnts_.size(), this)); + cnt_exprs_.push_back(expr); + cnt_types_.push_back(INEQ); + return cnts_.back(); +} + +Cnt qpOASESModel::addIneqCnt(const QuadExpr&, const std::string& /*name*/) +{ + assert(0 && "NOT IMPLEMENTED"); + return 0; +} + +void qpOASESModel::removeVars(const VarVector& vars) +{ + IntVec inds = vars2inds(vars); + for (unsigned i = 0; i < vars.size(); ++i) + vars[i].var_rep->removed = true; +} + +void qpOASESModel::removeCnts(const CntVector& cnts) +{ + IntVec inds = cnts2inds(cnts); + for (unsigned i = 0; i < cnts.size(); ++i) + cnts[i].cnt_rep->removed = true; +} + +void qpOASESModel::updateObjective() +{ + const size_t n = vars_.size(); + + Eigen::SparseMatrix sm; + exprToEigen(objective_, sm, g_, n, true, true); + eigenToCSC(sm, H_row_indices_, H_column_pointers_, H_csc_data_); + + H_ = SymSparseMat(vars_.size(), vars_.size(), H_row_indices_.data(), H_column_pointers_.data(), H_csc_data_.data()); + H_.createDiagInfo(); +} + +void qpOASESModel::updateConstraints() +{ + const size_t n = vars_.size(); + const size_t m = cnts_.size(); + + lbA_.clear(); + lbA_.resize(m, -QPOASES_INFTY); + ubA_.clear(); + ubA_.resize(m, QPOASES_INFTY); + + Eigen::SparseMatrix sm; + Eigen::VectorXd v; + exprToEigen(cnt_exprs_, sm, v, n); + + for (int i_cnt = 0; i_cnt < m; ++i_cnt) + { + lbA_[i_cnt] = (cnt_types_[i_cnt] == INEQ) ? -QPOASES_INFTY : v[i_cnt]; + ubA_[i_cnt] = v[i_cnt]; + } + + eigenToCSC(sm, A_row_indices_, A_column_pointers_, A_csc_data_); + A_ = SparseMatrix(cnts_.size(), vars_.size(), A_row_indices_.data(), A_column_pointers_.data(), A_csc_data_.data()); +} + +bool qpOASESModel::updateSolver() +{ + bool solver_updated = false; + if (!qpoases_problem_ || vars_.size() != qpoases_problem_->getNV() || cnts_.size() != qpoases_problem_->getNC()) + { + // Create Problem - this should be called only once + qpoases_problem_.reset(new SQProblem(vars_.size(), cnts_.size())); + qpoases_problem_->setOptions(qpoases_options_); + solver_updated = true; + } + return solver_updated; +} + +void qpOASESModel::createSolver() +{ + qpoases_problem_.reset(); + updateSolver(); +} + +void qpOASESModel::update() +{ + { + int inew = 0; + for (unsigned iold = 0; iold < vars_.size(); ++iold) + { + const Var& var = vars_[iold]; + if (!var.var_rep->removed) + { + vars_[inew] = var; + lb_[inew] = lb_[iold]; + ub_[inew] = ub_[iold]; + var.var_rep->index = inew; + ++inew; + } + else + delete var.var_rep; + } + vars_.resize(inew); + lb_.resize(inew, QPOASES_INFTY); + ub_.resize(inew, -QPOASES_INFTY); + } + { + int inew = 0; + for (unsigned iold = 0; iold < cnts_.size(); ++iold) + { + const Cnt& cnt = cnts_[iold]; + if (!cnt.cnt_rep->removed) + { + cnts_[inew] = cnt; + cnt_exprs_[inew] = cnt_exprs_[iold]; + cnt_types_[inew] = cnt_types_[iold]; + cnt.cnt_rep->index = inew; + ++inew; + } + else + delete cnt.cnt_rep; + } + cnts_.resize(inew); + cnt_exprs_.resize(inew); + cnt_types_.resize(inew); + } +} + +void qpOASESModel::setVarBounds(const VarVector& vars, const DblVec& lower, const DblVec& upper) +{ + for (unsigned i = 0; i < vars.size(); ++i) + { + const int varind = vars[i].var_rep->index; + lb_[varind] = lower[i]; + ub_[varind] = upper[i]; + } +} +DblVec qpOASESModel::getVarValues(const VarVector& vars) const +{ + DblVec out(vars.size()); + for (unsigned i = 0; i < vars.size(); ++i) + { + const int varind = vars[i].var_rep->index; + out[i] = solution_[varind]; + } + return out; +} + +CvxOptStatus qpOASESModel::optimize() +{ + update(); + updateObjective(); + updateConstraints(); + updateSolver(); + qpOASES::returnValue val = qpOASES::RET_QP_SOLUTION_STARTED; + + // Solve Problem + int nWSR = 255; + if (qpoases_problem_->isInitialised()) + { + val = qpoases_problem_->hotstart(&H_, g_.data(), &A_, lb_.data(), ub_.data(), lbA_.data(), ubA_.data(), nWSR, + nullptr); + } + + if (val != qpOASES::SUCCESSFUL_RETURN) + { + // TODO ATM this means we are creating a new solver even if updateSolver + // returned true and the problem is not initialized. Still, it makes + // tests pass. + createSolver(); + + val = qpoases_problem_->init(&H_, g_.data(), &A_, lb_.data(), ub_.data(), lbA_.data(), ubA_.data(), nWSR, nullptr); + } + + if (val == qpOASES::SUCCESSFUL_RETURN) + { + // opt += m_objective.affexpr.constant; + solution_.resize(vars_.size(), 0.); + val = qpoases_problem_->getPrimalSolution(solution_.data()); + return CVX_SOLVED; + } + else if (val == qpOASES::RET_INIT_FAILED_INFEASIBILITY) + { + return CVX_INFEASIBLE; + } + else + { + return CVX_FAILED; + } +} +void qpOASESModel::setObjective(const AffExpr& expr) +{ + objective_.affexpr = expr; +} +void qpOASESModel::setObjective(const QuadExpr& expr) +{ + objective_ = expr; +} +void qpOASESModel::writeToFile(const std::string& /*fname*/) +{ + return; // NOT IMPLEMENTED +} +VarVector qpOASESModel::getVars() const +{ + return vars_; +} +} diff --git a/moveit_planners/trajopt/trajopt_sco/src/solver_interface.cpp b/moveit_planners/trajopt/trajopt_sco/src/solver_interface.cpp new file mode 100644 index 0000000000..0162da16bf --- /dev/null +++ b/moveit_planners/trajopt/trajopt_sco/src/solver_interface.cpp @@ -0,0 +1,326 @@ +#include +TRAJOPT_IGNORE_WARNINGS_PUSH +#include +#include +#include +#include +TRAJOPT_IGNORE_WARNINGS_POP + +#include +#include + +namespace sco +{ +const std::vector ModelType::MODEL_NAMES_ = { "GUROBI", "BPMPD", "OSQP", "QPOASES", "AUTO_SOLVER" }; + +IntVec vars2inds(const VarVector& vars) +{ + IntVec inds(vars.size()); + for (size_t i = 0; i < inds.size(); ++i) + inds[i] = vars[i].var_rep->index; + return inds; +} +IntVec cnts2inds(const CntVector& cnts) +{ + IntVec inds(cnts.size()); + for (size_t i = 0; i < inds.size(); ++i) + inds[i] = cnts[i].cnt_rep->index; + return inds; +} + +void simplify2(IntVec& inds, DblVec& vals) +{ + typedef std::map Int2Double; + Int2Double ind2val; + for (unsigned i = 0; i < inds.size(); ++i) + { + if (vals[i] != 0.0) + ind2val[inds[i]] += vals[i]; + } + inds.resize(ind2val.size()); + vals.resize(ind2val.size()); + long unsigned int i_new = 0; + for (Int2Double::value_type& iv : ind2val) + { + inds[i_new] = iv.first; + vals[i_new] = iv.second; + ++i_new; + } +} + +double AffExpr::value(const double* x) const +{ + double out = constant; + for (size_t i = 0; i < size(); ++i) + { + out += coeffs[i] * vars[i].value(x); + } + return out; +} +double AffExpr::value(const DblVec& x) const +{ + double out = constant; + for (size_t i = 0; i < size(); ++i) + { + out += coeffs[i] * vars[i].value(x); + } + return out; +} +double QuadExpr::value(const DblVec& x) const +{ + double out = affexpr.value(x); + for (size_t i = 0; i < size(); ++i) + { + out += coeffs[i] * vars1[i].value(x) * vars2[i].value(x); + } + return out; +} +double QuadExpr::value(const double* x) const +{ + double out = affexpr.value(x); + for (size_t i = 0; i < size(); ++i) + { + out += coeffs[i] * vars1[i].value(x) * vars2[i].value(x); + } + return out; +} + +Var Model::addVar(const std::string& name, double lb, double ub) +{ + Var v = addVar(name); + setVarBounds(v, lb, ub); + return v; +} +void Model::removeVar(const Var& var) +{ + VarVector vars(1, var); + removeVars(vars); +} +void Model::removeCnt(const Cnt& cnt) +{ + CntVector cnts(1, cnt); + removeCnts(cnts); +} + +double Model::getVarValue(const Var& var) const +{ + VarVector vars(1, var); + return getVarValues(vars)[0]; +} + +void Model::setVarBounds(const Var& var, double lower, double upper) +{ + DblVec lowers(1, lower), uppers(1, upper); + VarVector vars(1, var); + setVarBounds(vars, lowers, uppers); +} + +std::ostream& operator<<(std::ostream& o, const Var& v) +{ + if (v.var_rep != nullptr) + o << v.var_rep->name; + else + o << "nullvar"; + return o; +} + +std::ostream& operator<<(std::ostream& o, const Cnt& c) +{ + o << c.cnt_rep->expr << ((c.cnt_rep->type == EQ) ? " == 0" : " <= 0"); + return o; +} + +std::ostream& operator<<(std::ostream& o, const AffExpr& e) +{ + o << e.constant; + for (size_t i = 0; i < e.size(); ++i) + { + o << " + " << e.coeffs[i] << "*" << e.vars[i]; + } + return o; +} + +std::ostream& operator<<(std::ostream& o, const QuadExpr& e) +{ + o << e.affexpr; + for (size_t i = 0; i < e.size(); ++i) + { + o << " + " << e.coeffs[i] << "*" << e.vars1[i] << "*" << e.vars2[i]; + } + return o; +} + +std::ostream& operator<<(std::ostream& o, const ModelType& cs) +{ + size_t cs_ivalue_ = static_cast(cs.value_); + if (cs_ivalue_ > cs.MODEL_NAMES_.size()) + { + std::stringstream conversion_error; + conversion_error << "Error converting ModelType to string - " + << "enum value is " << cs_ivalue_ << std::endl; + throw std::runtime_error(conversion_error.str()); + } + o << ModelType::MODEL_NAMES_[cs_ivalue_]; + return o; +} + +ModelType::ModelType() +{ + value_ = ModelType::AUTO_SOLVER; +} +ModelType::ModelType(const ModelType::Value& v) +{ + value_ = v; +} +ModelType::ModelType(const int& v) +{ + value_ = static_cast(v); +} +ModelType::ModelType(const std::string& s) +{ + for (unsigned int i = 0; i < ModelType::MODEL_NAMES_.size(); ++i) + { + if (s == ModelType::MODEL_NAMES_[i]) + { + value_ = static_cast(i); + return; + } + } + PRINT_AND_THROW(boost::format("invalid solver name:\"%s\"") % s); +} + +ModelType::operator int() const +{ + return static_cast(value_); +} +bool ModelType::operator==(const ModelType::Value& a) const +{ + return value_ == a; +} +bool ModelType::operator==(const ModelType& a) const +{ + return value_ == a.value_; +} +bool ModelType::operator!=(const ModelType& a) const +{ + return value_ != a.value_; +} +void ModelType::fromJson(const Json::Value& v) +{ + try + { + std::string ref = v.asString(); + ModelType cs(ref); + value_ = cs.value_; + } + catch (const std::runtime_error&) + { + PRINT_AND_THROW(boost::format("expected: %s, got %s") % ("string") % (v)); + } +} + +std::vector availableSolvers() +{ + std::vector has_solver(ModelType::AUTO_SOLVER, false); +#ifdef HAVE_GUROBI + has_solver[ModelType::GUROBI] = true; +#endif +#ifdef HAVE_BPMPD + has_solver[ModelType::BPMPD] = true; +#endif +#ifdef HAVE_OSQP + has_solver[ModelType::OSQP] = true; +#endif +#ifdef HAVE_QPOASES + has_solver[ModelType::QPOASES] = true; +#endif + size_t n_available_solvers = 0; + for (auto i = 0; i < ModelType::AUTO_SOLVER; ++i) + if (has_solver[static_cast(i)]) + ++n_available_solvers; + std::vector available_solvers(n_available_solvers, ModelType::AUTO_SOLVER); + + size_t j = 0; + for (int i = 0; i < static_cast(ModelType::AUTO_SOLVER); ++i) + if (has_solver[static_cast(i)]) + available_solvers[j++] = static_cast(i); + return available_solvers; +} + +ModelPtr createModel(ModelType model_type) +{ +#ifdef HAVE_GUROBI + extern ModelPtr createGurobiModel(); +#endif +#ifdef HAVE_BPMPD + extern ModelPtr createBPMPDModel(); +#endif +#ifdef HAVE_OSQP + extern ModelPtr createOSQPModel(); +#endif +#ifdef HAVE_QPOASES + extern ModelPtr createqpOASESModel(); +#endif + + char* solver_env = getenv("TRAJOPT_CONVEX_SOLVER"); + + ModelType solver = model_type; + + if (solver == ModelType::AUTO_SOLVER) + { + if (solver_env and std::string(solver_env) != "AUTO_SOLVER") + { + try + { + solver = ModelType(std::string(solver_env)); + } + catch (std::runtime_error&) + { + PRINT_AND_THROW(boost::format("invalid solver \"%s\"specified by TRAJOPT_CONVEX_SOLVER") % solver_env); + } + } + else + { + solver = availableSolvers()[0]; + } + } + +#ifndef HAVE_GUROBI + if (solver == ModelType::GUROBI) + PRINT_AND_THROW("you didn't build with GUROBI support"); +#endif +#ifndef HAVE_BPMPD + if (solver == ModelType::BPMPD) + PRINT_AND_THROW("you don't have BPMPD support on this platform"); +#endif +#ifndef HAVE_OSQP + if (solver == ModelType::OSQP) + PRINT_AND_THROW("you don't have OSQP support on this platform"); +#endif +#ifndef HAVE_QPOASES + if (solver == ModelType::QPOASES) + PRINT_AND_THROW("you don't have qpOASES support on this platform"); +#endif + +#ifdef HAVE_GUROBI + if (solver == ModelType::GUROBI) + return createGurobiModel(); +#endif +#ifdef HAVE_BPMPD + if (solver == ModelType::BPMPD) + return createBPMPDModel(); +#endif +#ifdef HAVE_OSQP + if (solver == ModelType::OSQP) + return createOSQPModel(); +#endif +#ifdef HAVE_QPOASES + if (solver == ModelType::QPOASES) + return createqpOASESModel(); +#endif + std::stringstream solver_instatiation_error; + solver_instatiation_error << "Failed to create solver: unknown solver " << solver << std::endl; + PRINT_AND_THROW(solver_instatiation_error.str()); + return ModelPtr(); +} +} diff --git a/moveit_planners/trajopt/trajopt_sco/src/solver_utils.cpp b/moveit_planners/trajopt/trajopt_sco/src/solver_utils.cpp new file mode 100644 index 0000000000..4fbdea121a --- /dev/null +++ b/moveit_planners/trajopt/trajopt_sco/src/solver_utils.cpp @@ -0,0 +1,124 @@ +#include +TRAJOPT_IGNORE_WARNINGS_PUSH +#include +#include +#include +TRAJOPT_IGNORE_WARNINGS_POP + +#include +#include + +namespace sco +{ +void exprToEigen(const AffExpr& expr, Eigen::SparseVector& sparse_vector, const int& n_vars) +{ + sparse_vector.resize(n_vars); + sparse_vector.reserve(static_cast(expr.size())); + for (size_t i = 0; i < expr.size(); ++i) + { + int i_var_index = expr.vars[i].var_rep->index; + if (i_var_index >= n_vars) + { + std::stringstream msg; + msg << "Coefficient " << i << "has index " << i_var_index << " but n_vars is " << n_vars; + throw std::runtime_error(msg.str()); + } + if (expr.coeffs[i] != 0.) + sparse_vector.coeffRef(i_var_index) += expr.coeffs[i]; + } +} + +void exprToEigen(const QuadExpr& expr, Eigen::SparseMatrix& sparse_matrix, Eigen::VectorXd& vector, + const int& n_vars, const bool& matrix_is_halved, const bool& force_diagonal) +{ + IntVec ind1 = vars2inds(expr.vars1); + IntVec ind2 = vars2inds(expr.vars2); + sparse_matrix.resize(n_vars, n_vars); + sparse_matrix.reserve(static_cast(2 * expr.size())); + + Eigen::SparseVector vector_sparse; + exprToEigen(expr.affexpr, vector_sparse, n_vars); + vector = vector_sparse; + + for (size_t i = 0; i < expr.coeffs.size(); ++i) + { + if (expr.coeffs[i] != 0.0) + { + if (ind1[i] == ind2[i]) + sparse_matrix.coeffRef(ind1[i], ind2[i]) += expr.coeffs[i]; + else + { + int c, r; + if (ind1[i] < ind2[i]) + { + r = ind1[i]; + c = ind2[i]; + } + else + { + r = ind2[i]; + c = ind1[i]; + } + sparse_matrix.coeffRef(r, c) += expr.coeffs[i]; + } + } + } + + auto sparse_matrix_T = Eigen::SparseMatrix(sparse_matrix.transpose()); + sparse_matrix = sparse_matrix + sparse_matrix_T; + + if (!matrix_is_halved) + sparse_matrix = 0.5 * sparse_matrix; + + if (force_diagonal) + for (int k = 0; k < n_vars; ++k) + sparse_matrix.coeffRef(k, k) += 0.0; +} + +void exprToEigen(const AffExprVector& expr_vec, Eigen::SparseMatrix& sparse_matrix, Eigen::VectorXd& vector, + const int& n_vars) +{ + vector.resize(static_cast(expr_vec.size())); + vector.setZero(); + sparse_matrix.resize(static_cast(expr_vec.size()), n_vars); + sparse_matrix.reserve(static_cast(expr_vec.size()) * n_vars); + + for (long int i = 0; i < static_cast(expr_vec.size()); ++i) + { + const AffExpr& expr = expr_vec[static_cast(i)]; + Eigen::SparseVector expr_vector; + exprToEigen(expr, expr_vector, n_vars); + for (Eigen::SparseVector::InnerIterator it(expr_vector); it; ++it) + sparse_matrix.coeffRef(i, it.index()) = it.value(); + vector[i] = -expr.constant; + } +} + +void tripletsToEigen(const IntVec& rows_i, const IntVec& cols_j, const DblVec& values_ij, + Eigen::SparseMatrix& sparse_matrix) +{ + typedef Eigen::Triplet T; + std::vector> triplets; + for (unsigned int i = 0; i < values_ij.size(); ++i) + triplets.push_back(T(rows_i[i], cols_j[i], values_ij[i])); + sparse_matrix.setFromTriplets(triplets.begin(), triplets.end()); +} + +void eigenToTriplets(const Eigen::SparseMatrix& sparse_matrix, IntVec& rows_i, IntVec& cols_j, + DblVec& values_ij) +{ + auto& sm = sparse_matrix; + rows_i.reserve(rows_i.size() + static_cast(sm.nonZeros())); + cols_j.reserve(cols_j.size() + static_cast(sm.nonZeros())); + values_ij.reserve(values_ij.size() + static_cast(sm.nonZeros())); + for (int k = 0; k < sm.outerSize(); ++k) + { + for (Eigen::SparseMatrix::InnerIterator it(sm, k); it; ++it) + { + rows_i.push_back(static_cast(it.row())); + cols_j.push_back(static_cast(it.col())); + values_ij.push_back(it.value()); + } + } +} +} diff --git a/moveit_planners/trajopt/trajopt_sco/test/small-problems-unit.cpp b/moveit_planners/trajopt/trajopt_sco/test/small-problems-unit.cpp new file mode 100644 index 0000000000..7e7356a99e --- /dev/null +++ b/moveit_planners/trajopt/trajopt_sco/test/small-problems-unit.cpp @@ -0,0 +1,190 @@ +#include +TRAJOPT_IGNORE_WARNINGS_PUSH +#include +#include +#include +#include +#include +#include +TRAJOPT_IGNORE_WARNINGS_POP + +#include +#include +#include +#include +#include +#include +#include + +using namespace util; +using namespace std; +using namespace sco; +using namespace Eigen; + +class SQP : public testing::TestWithParam +{ +protected: + SQP() + { + } +}; + +void setupProblem(OptProbPtr& probptr, size_t nvars, ModelType convex_solver) +{ + probptr.reset(new OptProb(convex_solver)); + vector var_names; + for (size_t i = 0; i < nvars; ++i) + { + var_names.push_back((boost::format("x_%i") % i).str()); + } + probptr->createVariables(var_names); +} + +void expectAllNear(const DblVec& x, const DblVec& y, double abstol) +{ + EXPECT_EQ(x.size(), y.size()); + stringstream ss; + LOG_INFO("checking %s ?= %s", CSTR(x), CSTR(y)); + for (size_t i = 0; i < x.size(); ++i) + EXPECT_NEAR(x[i], y[i], abstol); +} + +double f_QuadraticSeparable(const VectorXd& x) +{ + return x(0) * x(0) + sq(x(1) - 1) + sq(x(2) - 2); +} +TEST_P(SQP, QuadraticSeparable) +{ + // if the problem is exactly a QP, it should be solved in one iteration + OptProbPtr prob; + setupProblem(prob, 3, GetParam()); + prob->addCost(CostPtr(new CostFromFunc(ScalarOfVector::construct(&f_QuadraticSeparable), prob->getVars(), "f"))); + BasicTrustRegionSQP solver(prob); + BasicTrustRegionSQPParameters& params = solver.getParameters(); + params.trust_box_size = 100; + DblVec x = { 3, 4, 5 }; + solver.initialize(x); + OptStatus status = solver.optimize(); + ASSERT_EQ(status, OPT_CONVERGED); + expectAllNear(solver.x(), { 0, 1, 2 }, 1e-3); + // todo: checks on number of iterations and function evaluates +} +double f_QuadraticNonseparable(const VectorXd& x) +{ + return sq(x(0) - x(1) + 3 * x(2)) + sq(x(0) - 1) + sq(x(2) - 2); +} +TEST_P(SQP, QuadraticNonseparable) +{ + OptProbPtr prob; + setupProblem(prob, 3, GetParam()); + prob->addCost( + CostPtr(new CostFromFunc(ScalarOfVector::construct(&f_QuadraticNonseparable), prob->getVars(), "f", true))); + BasicTrustRegionSQP solver(prob); + BasicTrustRegionSQPParameters& params = solver.getParameters(); + params.trust_box_size = 100; + params.min_trust_box_size = 1e-5; + params.min_approx_improve = 1e-6; + DblVec x = { 3, 4, 5 }; + solver.initialize(x); + OptStatus status = solver.optimize(); + ASSERT_EQ(status, OPT_CONVERGED); + expectAllNear(solver.x(), { 1, 7, 2 }, .01); + // todo: checks on number of iterations and function evaluates +} + +void testProblem(ScalarOfVectorPtr f, VectorOfVectorPtr g, ConstraintType cnt_type, const DblVec& init, + const DblVec& sol, ModelType convex_solver) +{ + OptProbPtr prob; + size_t n = init.size(); + assert(sol.size() == n); + setupProblem(prob, n, convex_solver); + prob->addCost(CostPtr(new CostFromFunc(f, prob->getVars(), "f", true))); + prob->addConstraint(ConstraintPtr(new ConstraintFromErrFunc(g, prob->getVars(), VectorXd(), cnt_type, "g"))); + BasicTrustRegionSQP solver(prob); + BasicTrustRegionSQPParameters& params = solver.getParameters(); + params.max_iter = 1000; + params.min_trust_box_size = 1e-5; + params.min_approx_improve = 1e-10; + params.merit_error_coeff = 1; + + solver.initialize(init); + OptStatus status = solver.optimize(); + EXPECT_EQ(status, OPT_CONVERGED); + expectAllNear(solver.x(), sol, .01); +} +// http://www.ai7.uni-bayreuth.de/test_problem_coll.pdf + +double f_TP1(const VectorXd& x) +{ + return 1 * sq(x(1) - sq(x(0))) + sq(1 - x(0)); +} +VectorXd g_TP1(const VectorXd& x) +{ + VectorXd out(1); + out(0) = -1.5 - x(1); + return out; +} +double f_TP2(const VectorXd& x) +{ + return 100 * sq(x(1) - sq(x(0))) + sq(1 - x(0)); +} +VectorXd g_TP2(const VectorXd& x) +{ + VectorXd out(1); + out(0) = -1.5 - x(1); + return out; +} +double f_TP3(const VectorXd& x) +{ + return (x(1) + 1e-5 * sq(x(1) - x(0))); +} +VectorXd g_TP3(const VectorXd& x) +{ + VectorXd out(1); + out(0) = 0 - x(1); + return out; +} +double f_TP6(const VectorXd& x) +{ + return sq(1 - x(0)); +} +VectorXd g_TP6(const VectorXd& x) +{ + VectorXd out(1); + out(0) = 10 * (x(1) - sq(x(0))); + return out; +} +double f_TP7(const VectorXd& x) +{ + return log(1 + sq(x(0))) - x(1); +} +VectorXd g_TP7(const VectorXd& x) +{ + VectorXd out(1); + out(0) = sq(1 + sq(x(0))) + sq(x(1)) - 4; + return out; +} + +TEST_P(SQP, TP1) +{ + testProblem(ScalarOfVector::construct(&f_TP1), VectorOfVector::construct(&g_TP1), INEQ, { -2, 1 }, { 1, 1 }, + GetParam()); +} +TEST_P(SQP, TP3) +{ + testProblem(ScalarOfVector::construct(&f_TP3), VectorOfVector::construct(&g_TP3), INEQ, { 10, 1 }, { 0, 0 }, + GetParam()); +} +TEST_P(SQP, TP6) +{ + testProblem(ScalarOfVector::construct(&f_TP6), VectorOfVector::construct(&g_TP6), EQ, { 10, 1 }, { 1, 1 }, + GetParam()); +} +TEST_P(SQP, TP7) +{ + testProblem(ScalarOfVector::construct(&f_TP7), VectorOfVector::construct(&g_TP7), EQ, { 2, 2 }, { 0., sqrtf(3.) }, + GetParam()); +} + +INSTANTIATE_TEST_CASE_P(AllSolvers, SQP, testing::ValuesIn(availableSolvers())); diff --git a/moveit_planners/trajopt/trajopt_sco/test/solver-interface-unit.cpp b/moveit_planners/trajopt/trajopt_sco/test/solver-interface-unit.cpp new file mode 100644 index 0000000000..6f118b1e3c --- /dev/null +++ b/moveit_planners/trajopt/trajopt_sco/test/solver-interface-unit.cpp @@ -0,0 +1,246 @@ +#include +TRAJOPT_IGNORE_WARNINGS_PUSH +#include +#include +#include +TRAJOPT_IGNORE_WARNINGS_POP + +#include +#include +#include +#include + +namespace sco +{ +extern void simplify2(IntVec& inds, DblVec& vals); +} + +using namespace sco; + +class SolverInterface : public testing::TestWithParam +{ +protected: + SolverInterface() + { + } +}; + +TEST(SolverInterface, simplify2) +{ + IntVec indices = { 0, 1, 3 }; + DblVec values = { 1e-7, 1e3, 0., 0., 0. }; + simplify2(indices, values); + + EXPECT_EQ(indices.size(), 2); + EXPECT_EQ(values.size(), 2); + EXPECT_TRUE((indices == IntVec{ 0, 1 })); + EXPECT_TRUE((values == DblVec{ 1e-7, 1e3 })); +} + +TEST_P(SolverInterface, setup_problem) +{ + ModelPtr solver = createModel(GetParam()); + VarVector vars; + for (int i = 0; i < 3; ++i) + { + char namebuf[5]; + sprintf(namebuf, "v%i", i); + vars.push_back(solver->addVar(namebuf)); + } + solver->update(); + + AffExpr aff; + std::cout << aff << std::endl; + for (int i = 0; i < 3; ++i) + { + exprInc(aff, vars[i]); + solver->setVarBounds(vars[i], 0, 10); + } + aff.constant -= 3; + std::cout << aff << std::endl; + QuadExpr affsquared = exprSquare(aff); + solver->setObjective(affsquared); + solver->update(); + LOG_INFO("objective: %s", CSTR(affsquared)); + LOG_INFO("please manually check that /tmp/solver-interface-test.lp matches this"); + solver->writeToFile("/tmp/solver-interface-test.lp"); + + solver->optimize(); + + DblVec soln(3); + for (int i = 0; i < 3; ++i) + { + soln[i] = solver->getVarValue(vars[i]); + } + EXPECT_NEAR(aff.value(soln), 0, 1e-6); + + solver->removeVar(vars[2]); + solver->update(); + EXPECT_EQ(solver->getVars().size(), 2); +} + +// Tests multiplying larger terms +TEST_P(SolverInterface, DISABLED_ExprMult_test1) // QuadExpr not PSD +{ + ModelPtr solver = createModel(GetParam()); + VarVector vars; + for (int i = 0; i < 3; ++i) + { + char namebuf[5]; + sprintf(namebuf, "v%i", i); + vars.push_back(solver->addVar(namebuf)); + } + for (int i = 3; i < 6; ++i) + { + char namebuf[5]; + sprintf(namebuf, "v%i", i); + vars.push_back(solver->addVar(namebuf)); + } + solver->update(); + + AffExpr aff1; + std::cout << aff1 << std::endl; + for (int i = 0; i < 3; ++i) + { + exprInc(aff1, vars[i]); + solver->setVarBounds(vars[i], 0, 10); + } + aff1.constant -= 3; + std::cout << aff1 << std::endl; + + AffExpr aff2; + std::cout << aff2 << std::endl; + for (int i = 3; i < 6; ++i) + { + exprInc(aff2, vars[i]); + solver->setVarBounds(vars[i], 0, 10); + } + aff2.constant -= 5; + + std::cout << aff2 << std::endl; + QuadExpr aff12 = exprMult(aff1, aff2); + solver->setObjective(aff12); + solver->update(); + LOG_INFO("objective: %s", CSTR(aff12)); + LOG_INFO("please manually check that /tmp/solver-interface-test.lp matches this"); + solver->writeToFile("/tmp/solver-interface-test.lp"); + + solver->optimize(); + + DblVec soln(3); + for (int i = 0; i < 3; ++i) + { + soln[i] = solver->getVarValue(vars[i]); + } + EXPECT_NEAR(aff1.value(soln), 0, 1e-6); + + solver->removeVar(vars[2]); + solver->update(); + EXPECT_EQ(solver->getVars().size(), 5); +} + +// Tests multiplication with 2 variables: v1=10, v2=20 => (2*v1)(v2) = 400 +TEST_P(SolverInterface, ExprMult_test2) +{ + const double v1_val = 10; + const double v2_val = 20; + const double v1_coeff = 2; + const double v2_coeff = 1; + const double aff1_const = 0; + const double aff2_const = 0; + + ModelPtr solver = createModel(GetParam()); + VarVector vars; + vars.push_back(solver->addVar("v1")); + vars.push_back(solver->addVar("v2")); + + solver->update(); + + AffExpr aff1; + AffExpr aff2; + + exprInc(aff1, vars[0]); + solver->setVarBounds(vars[0], v1_val, v1_val); + aff1.constant = aff1_const; + aff1.coeffs[0] = v1_coeff; + + exprInc(aff2, vars[1]); + solver->setVarBounds(vars[1], v2_val, v2_val); + aff2.constant = aff2_const; + aff2.coeffs[0] = v2_coeff; + + std::cout << "aff1: " << aff1 << std::endl; + std::cout << "aff2: " << aff2 << std::endl; + QuadExpr aff12 = exprMult(aff1, aff2); + solver->setObjective(aff12); + solver->update(); + LOG_INFO("objective: %s", CSTR(aff12)); + LOG_INFO("please manually check that /tmp/solver-interface-test.lp matches this"); + solver->writeToFile("/tmp/solver-interface-test.lp"); + + solver->optimize(); + + DblVec soln(2); + for (int i = 0; i < 2; ++i) + { + soln[i] = solver->getVarValue(vars[i]); + std::cout << soln[i] << std::endl; + } + std::cout << "Result: " << aff12.value(soln) << std::endl; + double answer = (v1_coeff * v1_val + aff1_const) * (v2_coeff * v2_val + aff2_const); + EXPECT_NEAR(aff12.value(soln), answer, 1e-6); +} + +// Tests multiplication with a constant: v1=10, v2=20 => (3*v1-3)(2*v2-5) = 945 +TEST_P(SolverInterface, ExprMult_test3) +{ + const double v1_val = 10; + const double v2_val = 20; + const double v1_coeff = 3; + const double v2_coeff = 2; + const double aff1_const = -3; + const double aff2_const = -5; + + ModelPtr solver = createModel(GetParam()); + VarVector vars; + vars.push_back(solver->addVar("v1")); + vars.push_back(solver->addVar("v2")); + + solver->update(); + + AffExpr aff1; + AffExpr aff2; + + exprInc(aff1, vars[0]); + solver->setVarBounds(vars[0], v1_val, v1_val); + aff1.constant = aff1_const; + aff1.coeffs[0] = v1_coeff; + + exprInc(aff2, vars[1]); + solver->setVarBounds(vars[1], v2_val, v2_val); + aff2.constant = aff2_const; + aff2.coeffs[0] = v2_coeff; + + std::cout << "aff1: " << aff1 << std::endl; + std::cout << "aff2: " << aff2 << std::endl; + QuadExpr aff12 = exprMult(aff1, aff2); + solver->setObjective(aff12); + solver->update(); + LOG_INFO("objective: %s", CSTR(aff12)); + LOG_INFO("please manually check that /tmp/solver-interface-test.lp matches this"); + solver->writeToFile("/tmp/solver-interface-test.lp"); + + solver->optimize(); + + DblVec soln(2); + for (int i = 0; i < 2; ++i) + { + soln[i] = solver->getVarValue(vars[i]); + std::cout << soln[i] << std::endl; + } + std::cout << "Result: " << aff12.value(soln) << std::endl; + double answer = (v1_coeff * v1_val + aff1_const) * (v2_coeff * v2_val + aff2_const); + EXPECT_NEAR(aff12.value(soln), answer, 1e-6); +} + +INSTANTIATE_TEST_CASE_P(AllSolvers, SolverInterface, testing::ValuesIn(availableSolvers())); diff --git a/moveit_planners/trajopt/trajopt_sco/test/solver-utils-unit.cpp b/moveit_planners/trajopt/trajopt_sco/test/solver-utils-unit.cpp new file mode 100644 index 0000000000..084648dd37 --- /dev/null +++ b/moveit_planners/trajopt/trajopt_sco/test/solver-utils-unit.cpp @@ -0,0 +1,261 @@ +#include +TRAJOPT_IGNORE_WARNINGS_PUSH +#include +#include +#include +#include +#include +#include +TRAJOPT_IGNORE_WARNINGS_POP + +#include +#include +#include +#include +#include + +using namespace sco; + +TEST(solver_utils, exprToEigen) +{ + int n_vars = 2; + std::vector x_info; + VarVector x; + for (int i = 0; i < n_vars; ++i) + { + std::stringstream var_name; + var_name << "x_" << i; + VarRepPtr x_el(new VarRep(i, var_name.str(), nullptr)); + x_info.push_back(x_el); + x.push_back(Var(x_el.get())); + } + + // x_affine = [3, 2]*x + 1 + AffExpr x_affine; + x_affine.vars = x; + x_affine.coeffs = DblVec{ 3, 2 }; + x_affine.constant = 1; + + std::cout << "x_affine= " << x_affine << std::endl; + std::cout << "expecting A = [3, 2];" << std::endl << " u = [1]" << std::endl; + Eigen::MatrixXd m_A_expected(1, n_vars); + m_A_expected << 3, 2; + Eigen::VectorXd v_u_expected(1); + v_u_expected << -1; + + Eigen::SparseVector v_A; + exprToEigen(x_affine, v_A, n_vars); + ASSERT_EQ(v_A.size(), m_A_expected.cols()); + Eigen::VectorXd v_A_d = v_A; + Eigen::VectorXd m_A_r = m_A_expected.row(0); + EXPECT_TRUE(v_A_d.isApprox(m_A_r)) << "error converting x_affine" + << " to Eigen::SparseVector. " + << "v_A :" << std::endl + << v_A << std::endl; + + Eigen::SparseMatrix m_A; + Eigen::VectorXd v_u; + AffExprVector x_affine_vector(1, x_affine); + exprToEigen(x_affine_vector, m_A, v_u, n_vars); + ASSERT_EQ(v_u_expected.size(), v_u.size()); + EXPECT_TRUE(v_u_expected == v_u) << "v_u_expected != v_u" << std::endl << "v_u:" << std::endl << v_u << std::endl; + EXPECT_EQ(m_A.nonZeros(), 2) << "m_A.nonZeros() != 2" << std::endl; + ASSERT_EQ(m_A.rows(), m_A_expected.rows()); + ASSERT_EQ(m_A.cols(), m_A_expected.cols()); + EXPECT_TRUE(m_A.isApprox(m_A_expected)) << "error converting x_affine to " + << "Eigen::SparseMatrix. m_A :" << std::endl + << m_A << std::endl; + + QuadExpr x_squared = exprSquare(x_affine); + std::cout << "x_squared= " << x_squared << std::endl; + std::cout << "expecting Q = [9, 6;" << std::endl + << " 6, 4]" << std::endl + << " q = [6, 4]" << std::endl; + Eigen::MatrixXd m_Q_expected(2, 2); + m_Q_expected << 9, 6, 6, 4; + DblVec v_q_expected{ 6, 4 }; + + Eigen::SparseMatrix m_Q; + Eigen::VectorXd v_q; + exprToEigen(x_squared, m_Q, v_q, n_vars); + { + Eigen::Map v_q_e_eig(v_q_expected.data(), v_q_expected.size()); + ASSERT_EQ(v_q.size(), v_q_e_eig.size()); + EXPECT_TRUE(v_q_e_eig.isApprox(v_q)) << "v_q_expected != v_q" << std::endl + << "v_q:" << std::endl + << v_q << std::endl; + } + EXPECT_TRUE(m_Q.isApprox(m_Q_expected)) << "error converting x_squared to " + << "Eigen::SparseMatrix. m_Q :" << std::endl + << m_Q << std::endl; + EXPECT_EQ(m_Q.nonZeros(), 4) << "m_Q.nonZeros() != 4" << std::endl; + + exprToEigen(x_squared, m_Q, v_q, n_vars, true); + { + Eigen::Map v_q_e_eig(v_q_expected.data(), v_q_expected.size()); + EXPECT_TRUE(v_q_e_eig.isApprox(v_q)) << "v_q_expected != v_q" << std::endl + << "v_q:" << std::endl + << v_q << std::endl; + } + EXPECT_TRUE(m_Q.isApprox(2 * m_Q_expected)) << "error converting x_squared to" + << " Eigen::SparseMatrix. m_Q :" << std::endl + << m_Q << std::endl; + EXPECT_EQ(m_Q.nonZeros(), 4) << "m_Q.nonZeros() != 4" << std::endl; + + x_affine.coeffs = DblVec{ 0, 2 }; + std::cout << "x_affine= " << x_affine << std::endl; + std::cout << "expecting A = [0, 2];" << std::endl; + x_squared = exprSquare(x_affine); + std::cout << "x_squared= " << x_squared << std::endl; + std::cout << "expecting Q = [0, 0;" << std::endl << " 0, 4]" << std::endl; + m_Q_expected.setZero(); + m_Q_expected << 0, 0, 0, 4; + exprToEigen(x_squared, m_Q, v_q, n_vars, false, false); + EXPECT_TRUE(m_Q.isApprox(m_Q_expected)) << "error converting x_squared to " + << "Eigen::SparseMatrix. m_Q :" << std::endl + << m_Q << std::endl; + EXPECT_EQ(m_Q.nonZeros(), 1) << "m_Q.nonZeros() != 1" << std::endl; + + exprToEigen(x_squared, m_Q, v_q, n_vars, true, false); + EXPECT_TRUE(m_Q.isApprox(2 * m_Q_expected)) << "error converting x_squared to" + << " Eigen::SparseMatrix. m_Q :" << std::endl + << m_Q << std::endl; + EXPECT_EQ(m_Q.nonZeros(), 1) << "m_Q.nonZeros() != 1" << std::endl; + + exprToEigen(x_squared, m_Q, v_q, n_vars, false, true); + EXPECT_TRUE(m_Q.isApprox(m_Q_expected)) << "error converting x_squared to " + << "Eigen::SparseMatrix. m_Q :" << std::endl + << m_Q << std::endl; + EXPECT_EQ(m_Q.nonZeros(), 2) << "m_Q.nonZeros() != 2" << std::endl; + + exprToEigen(x_squared, m_Q, v_q, n_vars, true, true); + EXPECT_TRUE(m_Q.isApprox(2 * m_Q_expected)) << "error converting x_squared to" + << "Eigen::SparseMatrix. m_Q :" << std::endl + << m_Q << std::endl; + EXPECT_EQ(m_Q.nonZeros(), 2) << "m_Q.nonZeros() != 2" << std::endl; +} + +TEST(solver_utils, eigenToTriplets) +{ + Eigen::MatrixXd m_Q(2, 2); + m_Q << 9, 0, 6, 4; + Eigen::SparseMatrix m_Q_sparse_expected = m_Q.sparseView(); + IntVec m_Q_i, m_Q_j; + DblVec m_Q_ij; + eigenToTriplets(m_Q_sparse_expected, m_Q_i, m_Q_j, m_Q_ij); + Eigen::SparseMatrix m_Q_sparse(2, 2); + tripletsToEigen(m_Q_i, m_Q_j, m_Q_ij, m_Q_sparse); + EXPECT_TRUE(m_Q_sparse.isApprox(m_Q)) << "m_Q != m_Q_sparse when converting " + << "m_Q -> triplets -> m_Q_sparse. m_Q:" << std::endl + << m_Q << std::endl; + EXPECT_EQ(m_Q_sparse.nonZeros(), 3) << "m_Q.nonZeros() != 3" << std::endl; +} + +TEST(solver_utils, eigenToCSC) +{ + DblVec P; + IntVec rows_i; + IntVec cols_p; + { + /* + * M = [ 1, 2, 3, + * 1, 0, 9, + * 1, 8, 0] + */ + Eigen::MatrixXd M(3, 3); + M << 1, 2, 3, 1, 0, 9, 1, 8, 0; + Eigen::SparseMatrix Ms = M.sparseView(); + + eigenToCSC(Ms, rows_i, cols_p, P); + + EXPECT_TRUE(rows_i.size() == P.size()) << "rows_i.size() != P.size()"; + EXPECT_TRUE((P == DblVec{ 1, 1, 1, 2, 8, 3, 9 })) << "bad P:\n" << CSTR(P); + EXPECT_TRUE((rows_i == IntVec{ 0, 1, 2, 0, 2, 0, 1 })) << "bad rows_i:\n" << CSTR(rows_i); + EXPECT_TRUE((cols_p == IntVec{ 0, 3, 5, 7 })) << "cols_p not in " + << "CRC form:\n" + << CSTR(cols_p); + } + { + /* + * M = [ 0, 2, 0, + * 7, 0, 0, + * 0, 0, 0] + */ + Eigen::SparseMatrix M(3, 3); + M.coeffRef(0, 1) = 2; + M.coeffRef(1, 0) = 7; + + eigenToCSC(M, rows_i, cols_p, P); + + EXPECT_TRUE(rows_i.size() == P.size()) << "rows_i.size() != P.size()"; + EXPECT_TRUE((P == DblVec{ 7, 2 })) << "bad P:\n" << CSTR(P); + EXPECT_TRUE((rows_i == IntVec{ 1, 0 })) << "rows_i != data_j:\n" + << CSTR(rows_i) << " vs\n" + << CSTR((IntVec{ 1, 0 })); + EXPECT_TRUE((cols_p == IntVec{ 0, 1, 2, 2 })) << "cols_p not in " + << "CRC form:\n" + << CSTR(cols_p); + + std::vector rows_i_ll, cols_p_ll; + std::vector rows_i_ll_exp{ 1, 0 }; + std::vector cols_p_ll_exp{ 0, 1, 2, 2 }; + + eigenToCSC(M, rows_i_ll, cols_p_ll, P); + EXPECT_TRUE(rows_i_ll.size() == P.size()) << "rows_i_ll.size() != P.size()"; + EXPECT_TRUE((rows_i_ll == rows_i_ll_exp)); + EXPECT_TRUE((cols_p_ll == cols_p_ll_exp)); + + std::vector rows_i_ull, cols_p_ull; + std::vector rows_i_ull_exp{ 1, 0 }; + std::vector cols_p_ull_exp{ 0, 1, 2, 2 }; + eigenToCSC(M, rows_i_ull, cols_p_ull, P); + EXPECT_TRUE(rows_i_ull.size() == P.size()) << "rows_i_ll.size() != P.size()"; + EXPECT_TRUE((rows_i_ull == rows_i_ull_exp)); + EXPECT_TRUE((cols_p_ull == cols_p_ull_exp)); + } + { + /* + * M = [ 0, 0, 0, + * 0, 0, 0, + * 0, 6, 0] + */ + Eigen::SparseMatrix M(3, 3); + M.coeffRef(2, 1) = 6; + + eigenToCSC(M, rows_i, cols_p, P); + + EXPECT_TRUE(rows_i.size() == P.size()) << "rows_i.size() != P.size()"; + EXPECT_TRUE((P == DblVec{ 6 })) << "bad P:\n" << CSTR(P); + EXPECT_TRUE((rows_i == IntVec{ 2 })) << "rows_i != data_j:\n" << CSTR(rows_i) << " vs\n" << CSTR((IntVec{ 1, 0 })); + EXPECT_TRUE((cols_p == IntVec{ 0, 0, 1, 1 })) << "cols_p not in " + << "CRC form:\n" + << CSTR(cols_p); + } +} + +TEST(solver_utils, eigenToCSC_upper_triangular) +{ + /* + * M = [ 1, 2, 0, + * 2, 4, 0, + * 0, 0, 9] + */ + Eigen::MatrixXd M(3, 3); + M << 1, 2, 0, 2, 4, 0, 0, 0, 9; + Eigen::SparseMatrix Ms = M.sparseView(); + + DblVec P; + IntVec rows_i; + IntVec cols_p; + eigenToCSC(Ms, rows_i, cols_p, P); + + EXPECT_TRUE(rows_i.size() == P.size()) << "rows_i.size() != P.size()"; + EXPECT_TRUE((P == DblVec{ 1, 2, 4, 9 })) << "bad P:\n" << CSTR(P); + EXPECT_TRUE((rows_i == IntVec{ 0, 0, 1, 2 })) << "rows_i != expected" + << ":\n" + << CSTR(rows_i) << " vs\n" + << CSTR((IntVec{ 0, 0, 1, 2 })); + EXPECT_TRUE((cols_p == IntVec{ 0, 1, 3, 4 })) << "cols_p not in " + << "CRC form:\n" + << CSTR(cols_p); +} diff --git a/moveit_planners/trajopt/trajopt_sco/test/unit.cpp b/moveit_planners/trajopt/trajopt_sco/test/unit.cpp new file mode 100644 index 0000000000..539179562b --- /dev/null +++ b/moveit_planners/trajopt/trajopt_sco/test/unit.cpp @@ -0,0 +1,10 @@ +#include +TRAJOPT_IGNORE_WARNINGS_PUSH +#include +TRAJOPT_IGNORE_WARNINGS_POP + +int main(int argc, char** argv) +{ + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} diff --git a/moveit_planners/trajopt/trajopt_utils/CMakeLists.txt b/moveit_planners/trajopt/trajopt_utils/CMakeLists.txt new file mode 100644 index 0000000000..478b1ca414 --- /dev/null +++ b/moveit_planners/trajopt/trajopt_utils/CMakeLists.txt @@ -0,0 +1,48 @@ +cmake_minimum_required(VERSION 2.8.3) +project(trajopt_utils) + +add_compile_options(-std=c++11 -Wall -Wextra) + +find_package(catkin REQUIRED COMPONENTS) + +find_package(Eigen3 REQUIRED) +find_package(Boost COMPONENTS system python thread program_options REQUIRED) + +set(UTILS_SOURCE_FILES + src/stl_to_string.cpp + src/clock.cpp + src/config.cpp + src/logging.cpp +) + +catkin_package( + INCLUDE_DIRS include + LIBRARIES ${PROJECT_NAME} +# CATKIN_DEPENDS roscpp + DEPENDS + EIGEN3 +) + +include_directories( + include + ${catkin_INCLUDE_DIRS} + SYSTEM ${EIGEN3_INCLUDE_DIRS} + SYSTEM ${Boost_INCLUDE_DIRS} +) + +add_library(${PROJECT_NAME} ${UTILS_SOURCE_FILES}) +target_link_libraries(${PROJECT_NAME} ${Boost_PROGRAM_OPTIONS_LIBRARY}) +target_compile_options(${PROJECT_NAME} PRIVATE -Wsuggest-override -Wconversion -Wsign-conversion) + +# Mark executables and/or libraries for installation +install(TARGETS ${PROJECT_NAME} + ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} +) + +# Mark cpp header files for installation +install(DIRECTORY include/${PROJECT_NAME}/ + DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION} + FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp" + ) diff --git a/moveit_planners/trajopt/trajopt_utils/LICENSE b/moveit_planners/trajopt/trajopt_utils/LICENSE new file mode 100644 index 0000000000..9103917b0f --- /dev/null +++ b/moveit_planners/trajopt/trajopt_utils/LICENSE @@ -0,0 +1,11 @@ +Copyright (c) 2013, John Schulman +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 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. + +http://opensource.org/licenses/BSD-2-Clause \ No newline at end of file diff --git a/moveit_planners/trajopt/trajopt_utils/README.md b/moveit_planners/trajopt/trajopt_utils/README.md new file mode 100644 index 0000000000..1c18708b1f --- /dev/null +++ b/moveit_planners/trajopt/trajopt_utils/README.md @@ -0,0 +1,3 @@ +TODO(ommmid): Remove code duplication. +This package temporarily copied into moveit until the repo trajopt_ros does not depend on Tesseract +See ros-industrial-consortium/trajopt_ros#122 \ No newline at end of file diff --git a/moveit_planners/trajopt/trajopt_utils/include/trajopt_utils/basic_array.hpp b/moveit_planners/trajopt/trajopt_utils/include/trajopt_utils/basic_array.hpp new file mode 100644 index 0000000000..e9e6413e62 --- /dev/null +++ b/moveit_planners/trajopt/trajopt_utils/include/trajopt_utils/basic_array.hpp @@ -0,0 +1,147 @@ +#pragma once +#include +TRAJOPT_IGNORE_WARNINGS_PUSH +#include +TRAJOPT_IGNORE_WARNINGS_POP + +namespace util +{ +template +struct BasicArray +{ + int m_nRow; + int m_nCol; + std::vector m_data; + + BasicArray() : m_nRow(0), m_nCol(0) + { + } + BasicArray(int nRow, int nCol) : m_nRow(nRow), m_nCol(nCol) + { + m_data.resize(m_nRow * m_nCol); + } + BasicArray(int nRow, int nCol, const T* data) : m_nRow(nRow), m_nCol(nCol), m_data(data, data + nRow * nCol) + { + } + BasicArray(const BasicArray& x) : m_nRow(x.m_nRow), m_nCol(x.m_nCol), m_data(x.m_data) + { + } + void resize(int nRow, int nCol) + { + m_nRow = nRow; + m_nCol = nCol; + m_data.resize(static_cast(m_nRow * m_nCol)); + } + + int rows() const + { + return m_nRow; + } + int cols() const + { + return m_nCol; + } + int size() const + { + return m_data.size(); + } + BasicArray block(int startRow, int startCol, int nRow, int nCol) const + { + BasicArray out; + out.resize(nRow, nCol); + for (int iRow = 0; iRow < nRow; ++iRow) + { + for (int iCol = 0; iCol < nCol; ++iCol) + { + out(iRow, iCol) = at(iRow + startRow, iCol + startCol); + } + } + return out; + } + std::vector rblock(int startRow, int startCol, int nCol) const + { + std::vector out(static_cast(nCol)); + for (int iCol = 0; iCol < nCol; ++iCol) + { + out[static_cast(iCol)] = at(static_cast(startRow), static_cast(iCol + startCol)); + } + return out; + } + std::vector cblock(int startRow, int startCol, int nRow) const + { + std::vector out(nRow); + for (int iRow = 0; iRow < nRow; ++iRow) + { + out[iRow] = at(iRow + startRow, startCol); + } + return out; + } + BasicArray middleRows(int start, int n) + { + BasicArray out; + out.resize(n, m_nCol); + for (int i = start; i < start + n; ++i) + { + for (int j = 0; j < m_nCol; ++j) + { + out(i, j) = at(i, j); + } + } + return out; + } + BasicArray topRows(int n) + { + return middleRows(0, n); + } + BasicArray bottomRows(int n) + { + return middleRows(m_nRow - n, n); + } + const T& at(int row, int col) const + { + return m_data.at(static_cast(row * m_nCol + col)); + } + T& at(int row, int col) + { + return m_data.at(static_cast(row * m_nCol + col)); + } + const T& operator()(int row, int col) const + { + return m_data.at(static_cast(row * m_nCol + col)); + } + T& operator()(int row, int col) + { + return m_data.at(static_cast(row * m_nCol + col)); + } + std::vector col(int col) + { + std::vector out; + out.reserve(m_nRow); + for (int row = 0; row < m_nRow; row++) + out.push_back(at(row, col)); + return out; + } + + std::vector row(int row) + { + std::vector out; + out.reserve(static_cast(m_nCol)); + for (int col = 0; col < m_nCol; col++) + out.push_back(at(row, col)); + return out; + } + + std::vector flatten() + { + return m_data; + } + T* data() + { + return m_data.data(); + } + T* data() const + { + return m_data.data(); + } +}; +} // namespace util diff --git a/moveit_planners/trajopt/trajopt_utils/include/trajopt_utils/clock.hpp b/moveit_planners/trajopt/trajopt_utils/include/trajopt_utils/clock.hpp new file mode 100644 index 0000000000..1fcf7c201f --- /dev/null +++ b/moveit_planners/trajopt/trajopt_utils/include/trajopt_utils/clock.hpp @@ -0,0 +1,7 @@ +#pragma once + +namespace util +{ +void StartClock(); +double GetClock(); +} diff --git a/moveit_planners/trajopt/trajopt_utils/include/trajopt_utils/config.hpp b/moveit_planners/trajopt/trajopt_utils/include/trajopt_utils/config.hpp new file mode 100644 index 0000000000..54b5a4a598 --- /dev/null +++ b/moveit_planners/trajopt/trajopt_utils/include/trajopt_utils/config.hpp @@ -0,0 +1,80 @@ +#pragma once +#include +TRAJOPT_IGNORE_WARNINGS_PUSH +#include +#include +#include +#include +#include +TRAJOPT_IGNORE_WARNINGS_POP + +#include + +namespace util +{ +namespace po = boost::program_options; + +struct ParameterBase +{ + std::string m_name; + std::string m_desc; + ParameterBase(const std::string& name, const std::string& desc) : m_name(name), m_desc(desc) + { + } + virtual void addToBoost(po::options_description&) = 0; + virtual ~ParameterBase() + { + } +}; +typedef std::shared_ptr ParameterBasePtr; + +template +struct ParameterVec : ParameterBase +{ + std::vector* m_value; + ParameterVec(std::string name, std::vector* value, std::string desc) : ParameterBase(name, desc), m_value(value) + { + } + void addToBoost(po::options_description& od) + { + od.add_options()(m_name.c_str(), po::value(m_value)->default_value(*m_value, Str(*m_value))->multitoken(), + m_desc.c_str()); + } +}; + +template +struct Parameter : ParameterBase +{ + T* m_value; + Parameter(std::string name, T* value, std::string desc) : ParameterBase(name, desc), m_value(value) + { + } + void addToBoost(po::options_description& od) + { + od.add_options()(m_name.c_str(), po::value(m_value)->default_value(*m_value, Str(*m_value)), m_desc.c_str()); + } +}; + +struct Config +{ + std::vector params; + void add(ParameterBase* param) + { + params.push_back(ParameterBasePtr(param)); + } +}; + +struct CommandParser +{ + std::vector configs; + void addGroup(const Config& config) + { + configs.push_back(config); + } + CommandParser(const Config& config) + { + addGroup(config); + } + void read(int argc, char* argv[]); +}; +} diff --git a/moveit_planners/trajopt/trajopt_utils/include/trajopt_utils/eigen_conversions.hpp b/moveit_planners/trajopt/trajopt_utils/include/trajopt_utils/eigen_conversions.hpp new file mode 100644 index 0000000000..c8b89ceb92 --- /dev/null +++ b/moveit_planners/trajopt/trajopt_utils/include/trajopt_utils/eigen_conversions.hpp @@ -0,0 +1,18 @@ +#pragma once +#include +TRAJOPT_IGNORE_WARNINGS_PUSH +#include +#include +TRAJOPT_IGNORE_WARNINGS_POP + +namespace util +{ +inline std::vector toDblVec(const Eigen::Matrix& x) +{ + return std::vector(x.data(), x.data() + x.size()); +} +inline Eigen::VectorXd toVectorXd(const std::vector& x) +{ + return Eigen::Map(x.data(), static_cast(x.size())); +} +} diff --git a/moveit_planners/trajopt/trajopt_utils/include/trajopt_utils/eigen_slicing.hpp b/moveit_planners/trajopt/trajopt_utils/include/trajopt_utils/eigen_slicing.hpp new file mode 100644 index 0000000000..ac1e4fccdb --- /dev/null +++ b/moveit_planners/trajopt/trajopt_utils/include/trajopt_utils/eigen_slicing.hpp @@ -0,0 +1,27 @@ +#include +TRAJOPT_IGNORE_WARNINGS_PUSH +#include +#include +TRAJOPT_IGNORE_WARNINGS_POP + +namespace util +{ +template +VectorT fancySlice(const VectorT& x, const std::vector& inds) +{ + VectorT out(inds.size()); + for (int i = 0; i < inds.size(); ++i) + out[i] = x[inds[i]]; + return out; +} + +template +std::vector flatnonzero(const VectorT& x) +{ + std::vector out; + for (int i = 0; i < x.size(); ++i) + if (x[i] != 0) + out.push_back(i); + return out; +} +} diff --git a/moveit_planners/trajopt/trajopt_utils/include/trajopt_utils/interpolation.hpp b/moveit_planners/trajopt/trajopt_utils/include/trajopt_utils/interpolation.hpp new file mode 100644 index 0000000000..79d7f7550e --- /dev/null +++ b/moveit_planners/trajopt/trajopt_utils/include/trajopt_utils/interpolation.hpp @@ -0,0 +1,48 @@ +#include +TRAJOPT_IGNORE_WARNINGS_PUSH +#include +TRAJOPT_IGNORE_WARNINGS_POP + +namespace util +{ +template +Eigen::VectorXi searchsorted(const VectorT& x, const VectorT& y) +{ + // y(i-1) <= x(out(i)) < y(i) + int nX = x.size(); + int nY = y.size(); + + Eigen::VectorXi out(nX); + int iY = 0; + for (int iX = 0; iX < nX; iX++) + { + while (iY < nY && x[iX] > y[iY]) + iY++; + out(iX) = iY; + } + return out; +} + +template +MatrixT interp2d(const VectorT& xNew, const VectorT& xOld, const MatrixT& yOld) +{ + int nNew = xNew.size(); + int nOld = xOld.size(); + MatrixT yNew(nNew, yOld.cols()); + Eigen::VectorXi new2old = searchsorted(xNew, xOld); + for (int iNew = 0; iNew < nNew; iNew++) + { + int iOldAbove = new2old(iNew); + if (iOldAbove == 0) + yNew.row(iNew) = yOld.row(0); + else if (iOldAbove == nOld) + yNew.row(iNew) = yOld.row(nOld - 1); + else + { + double t = (xNew(iNew) - xOld(iOldAbove - 1)) / (xOld(iOldAbove) - xOld(iOldAbove - 1)); + yNew.row(iNew) = yOld.row(iOldAbove - 1) * (1 - t) + yOld.row(iOldAbove) * t; + } + } + return yNew; +} +} diff --git a/moveit_planners/trajopt/trajopt_utils/include/trajopt_utils/logging.hpp b/moveit_planners/trajopt/trajopt_utils/include/trajopt_utils/logging.hpp new file mode 100644 index 0000000000..482c193d1a --- /dev/null +++ b/moveit_planners/trajopt/trajopt_utils/include/trajopt_utils/logging.hpp @@ -0,0 +1,74 @@ +#pragma once +#include +TRAJOPT_IGNORE_WARNINGS_PUSH +#include +TRAJOPT_IGNORE_WARNINGS_POP + +namespace util +{ +enum LogLevel +{ + LevelFatal = 0, + LevelError = 1, + LevelWarn = 2, + LevelInfo = 3, + LevelDebug = 4, + LevelTrace = 5 +}; + +extern LogLevel gLogLevel; +inline LogLevel GetLogLevel() +{ + return gLogLevel; +} +#define FATAL_PREFIX "\x1b[31m[FATAL] " +#define ERROR_PREFIX "\x1b[31m[ERROR] " +#define WARN_PREFIX "\x1b[33m[WARN] " +#define INFO_PREFIX "[INFO] " +#define DEBUG_PREFIX "\x1b[32m[DEBUG] " +#define TRACE_PREFIX "\x1b[34m[TRACE] " +#define LOG_SUFFIX "\x1b[0m\n" + +#define LOG_FATAL(msg, ...) \ + if (util::GetLogLevel() >= util::LevelFatal) \ + { \ + printf(FATAL_PREFIX); \ + printf(msg, ##__VA_ARGS__); \ + printf(LOG_SUFFIX); \ + } +#define LOG_ERROR(msg, ...) \ + if (util::GetLogLevel() >= util::LevelError) \ + { \ + printf(ERROR_PREFIX); \ + printf(msg, ##__VA_ARGS__); \ + printf(LOG_SUFFIX); \ + } +#define LOG_WARN(msg, ...) \ + if (util::GetLogLevel() >= util::LevelWarn) \ + { \ + printf(WARN_PREFIX); \ + printf(msg, ##__VA_ARGS__); \ + printf(LOG_SUFFIX); \ + } +#define LOG_INFO(msg, ...) \ + if (util::GetLogLevel() >= util::LevelInfo) \ + { \ + printf(INFO_PREFIX); \ + printf(msg, ##__VA_ARGS__); \ + printf(LOG_SUFFIX); \ + } +#define LOG_DEBUG(msg, ...) \ + if (util::GetLogLevel() >= util::LevelDebug) \ + { \ + printf(DEBUG_PREFIX); \ + printf(msg, ##__VA_ARGS__); \ + printf(LOG_SUFFIX); \ + } +#define LOG_TRACE(msg, ...) \ + if (util::GetLogLevel() >= util::LevelTrace) \ + { \ + printf(TRACE_PREFIX); \ + printf(msg, ##__VA_ARGS__); \ + printf(LOG_SUFFIX); \ + } +} diff --git a/moveit_planners/trajopt/trajopt_utils/include/trajopt_utils/macros.h b/moveit_planners/trajopt/trajopt_utils/include/trajopt_utils/macros.h new file mode 100644 index 0000000000..47332a1735 --- /dev/null +++ b/moveit_planners/trajopt/trajopt_utils/include/trajopt_utils/macros.h @@ -0,0 +1,71 @@ +#pragma once +#include + +#define TRAJOPT_IGNORE_WARNINGS_PUSH \ + _Pragma("GCC diagnostic push") _Pragma("GCC diagnostic ignored \"-Wall\"") \ + _Pragma("GCC diagnostic ignored \"-Wint-to-pointer-cast\"") \ + _Pragma("GCC diagnostic ignored \"-Wunused-parameter\"") \ + _Pragma("GCC diagnostic ignored \"-Wsuggest-override\"") \ + _Pragma("GCC diagnostic ignored \"-Wconversion\"") \ + _Pragma("GCC diagnostic ignored \"-Wfloat-conversion\"") \ + _Pragma("GCC diagnostic ignored \"-Wsign-conversion\"") + +#define TRAJOPT_IGNORE_WARNINGS_POP _Pragma("GCC diagnostic pop") + +// Generic helper definitions for shared library support +#if defined _WIN32 || defined __CYGWIN__ +#define TRAJOPT_HELPER_DLL_IMPORT __declspec(dllimport) +#define TRAJOPT_HELPER_DLL_EXPORT __declspec(dllexport) +#define TRAJOPT_HELPER_DLL_LOCAL +#else +#if __GNUC__ >= 4 +#define TRAJOPT_HELPER_DLL_IMPORT __attribute__((visibility("default"))) +#define TRAJOPT_HELPER_DLL_EXPORT __attribute__((visibility("default"))) +#define TRAJOPT_HELPER_DLL_LOCAL __attribute__((visibility("hidden"))) +#else +#define TRAJOPT_HELPER_DLL_IMPORT +#define TRAJOPT_HELPER_DLL_EXPORT +#define TRAJOPT_HELPER_DLL_LOCAL +#endif +#endif + +// Now we use the generic helper definitions above to define TRAJOPT_API and TRAJOPT_LOCAL. +// TRAJOPT_API is used for the public API symbols. It either DLL imports or DLL exports (or does nothing for static +// build) +// TRAJOPT_LOCAL is used for non-api symbols. + +#define TRAJOPT_DLL + +#ifdef TRAJOPT_DLL // defined if TRAJOPT is compiled as a DLL +#ifdef TRAJOPT_DLL_EXPORTS // defined if we are building the TRAJOPT DLL (instead of using it) +#define TRAJOPT_API TRAJOPT_HELPER_DLL_EXPORT +#else +#define TRAJOPT_API TRAJOPT_HELPER_DLL_IMPORT +#endif // TRAJOPT_DLL_EXPORTS +#define TRAJOPT_LOCAL TRAJOPT_HELPER_DLL_LOCAL +#else // TRAJOPT_DLL is not defined: this means TRAJOPT is a static lib. +#define TRAJOPT_API +#define TRAJOPT_LOCAL +#endif // TRAJOPT_DLL + +#define PRINT_AND_THROW(s) \ + do \ + { \ + std::cerr << "\033[1;31mERROR " << s << "\033[0m\n"; \ + std::cerr << "at " << __FILE__ << ":" << __LINE__ << std::endl; \ + std::stringstream ss; \ + ss << s; \ + throw std::runtime_error(ss.str()); \ + } while (0) +#define FAIL_IF_FALSE(expr) \ + if (!(expr)) \ + { \ + PRINT_AND_THROW("expected true: " #expr); \ + } + +#define ALWAYS_ASSERT(exp) \ + if (!(exp)) \ + { \ + printf("%s failed in file %s at line %i\n", #exp, __FILE__, __LINE__); \ + abort(); \ + } diff --git a/moveit_planners/trajopt/trajopt_utils/include/trajopt_utils/math.hpp b/moveit_planners/trajopt/trajopt_utils/include/trajopt_utils/math.hpp new file mode 100644 index 0000000000..1c71ef8f1c --- /dev/null +++ b/moveit_planners/trajopt/trajopt_utils/include/trajopt_utils/math.hpp @@ -0,0 +1,13 @@ +#pragma once +#include +TRAJOPT_IGNORE_WARNINGS_PUSH +#include +TRAJOPT_IGNORE_WARNINGS_POP + +namespace util +{ +float randf() +{ + return (float)rand() / (float)RAND_MAX; +} +} diff --git a/moveit_planners/trajopt/trajopt_utils/include/trajopt_utils/stl_to_string.hpp b/moveit_planners/trajopt/trajopt_utils/include/trajopt_utils/stl_to_string.hpp new file mode 100644 index 0000000000..e6bbe304fa --- /dev/null +++ b/moveit_planners/trajopt/trajopt_utils/include/trajopt_utils/stl_to_string.hpp @@ -0,0 +1,73 @@ +#pragma once +#include +TRAJOPT_IGNORE_WARNINGS_PUSH +#include +#include +#include +#include +#include +#include +TRAJOPT_IGNORE_WARNINGS_POP + +namespace util +{ +// std::string Str(const vector& x); +// std::string Str(const vector& x); +// std::string Str(const vector& x); + +template +std::string Str(const std::vector& x) +{ + std::stringstream ss; + ss << "("; + if (x.size() > 0) + ss << x[0]; + for (size_t i = 1; i < x.size(); ++i) + ss << ", " << x[i]; + ss << ")"; + return ss.str(); +} + +template +std::string Str(const std::set& x) +{ + std::stringstream ss; + ss << "{"; + typename std::set::const_iterator it = x.begin(); + if (x.size() > 0) + { + ss << *it; + ++it; + for (; it != x.end(); ++it) + ss << ", " << *it; + } + ss << "}"; + return ss.str(); +} + +template +std::string Str(const T& x) +{ + std::stringstream ss; + ss << x; + return ss.str(); +} +#define CSTR(x) util::Str(x).c_str() + +template +std::string Str(const typename std::map& x) +{ + std::stringstream ss; + ss << "{"; + typename std::map::const_iterator it = x.begin(); + if (x.size() > 0) + { + ss << Str(it->first) << " : " << Str(it->second); + ++it; + for (; it != x.end(); ++it) + ss << ", " << Str(it->first) << " : " << Str(it->second); + } + ss << "}"; + return ss.str(); +} +} diff --git a/moveit_planners/trajopt/trajopt_utils/include/trajopt_utils/vector_ops.hpp b/moveit_planners/trajopt/trajopt_utils/include/trajopt_utils/vector_ops.hpp new file mode 100644 index 0000000000..5a17476b3b --- /dev/null +++ b/moveit_planners/trajopt/trajopt_utils/include/trajopt_utils/vector_ops.hpp @@ -0,0 +1,20 @@ +#include +TRAJOPT_IGNORE_WARNINGS_PUSH +#include +TRAJOPT_IGNORE_WARNINGS_POP + +namespace util +{ +std::vector arange(int n) +{ + std::vector out(static_cast(n)); + for (int i = 0; i < n; ++i) + out[static_cast(i)] = i; + return out; +} + +inline bool doubleEquals(double x, double y, double eps = 1E-5) +{ + return std::abs(x - y) < eps; +} +} diff --git a/moveit_planners/trajopt/trajopt_utils/package.xml b/moveit_planners/trajopt/trajopt_utils/package.xml new file mode 100644 index 0000000000..0c38901c12 --- /dev/null +++ b/moveit_planners/trajopt/trajopt_utils/package.xml @@ -0,0 +1,16 @@ + + + trajopt_utils + 0.1.0 + The trajopt_utils package + Levi Armstrong + BSD + + catkin + + + + + + + diff --git a/moveit_planners/trajopt/trajopt_utils/src/clock.cpp b/moveit_planners/trajopt/trajopt_utils/src/clock.cpp new file mode 100644 index 0000000000..0ef0f05fc1 --- /dev/null +++ b/moveit_planners/trajopt/trajopt_utils/src/clock.cpp @@ -0,0 +1,40 @@ +#include +TRAJOPT_IGNORE_WARNINGS_PUSH +#include +#include +TRAJOPT_IGNORE_WARNINGS_POP + +#include + +namespace util +{ +static long unsigned int startTime = 0; + +/* + * Starts the clock! Call this once at the beginning of the program. + * Calling again will reset the clock to 0; but doing so is not + * thread-safe if other threads may be calling GetClock(); (which + * is thread-safe since it only reads values and calls thread-safe + * functions in the kernel). + */ +// time in units of seconds since some time in the past +void StartClock() +{ + // determine start time + struct timeval startTimeStruct; + gettimeofday(&startTimeStruct, nullptr); + startTime = static_cast(startTimeStruct.tv_sec * 1e6l + startTimeStruct.tv_usec); +} + +/* + * Returns the current time since the call to StartClock(); + */ +double GetClock() +{ + struct timeval startTimeStruct; + unsigned long int curTime; + gettimeofday(&startTimeStruct, nullptr); + curTime = static_cast(startTimeStruct.tv_sec * 1e6l + startTimeStruct.tv_usec); + return (1e-6) * static_cast(curTime - startTime); +} +} diff --git a/moveit_planners/trajopt/trajopt_utils/src/config.cpp b/moveit_planners/trajopt/trajopt_utils/src/config.cpp new file mode 100644 index 0000000000..07b687ff97 --- /dev/null +++ b/moveit_planners/trajopt/trajopt_utils/src/config.cpp @@ -0,0 +1,27 @@ +#include + +namespace util +{ +void CommandParser::read(int argc, char* argv[]) +{ + // create boost options_description based on variables, parser + po::options_description od; + od.add_options()("help,h", "produce help message"); + for (std::size_t i = 0; i < configs.size(); ++i) + { + for (std::size_t j = 0; j < configs[i].params.size(); ++j) + { + configs[i].params[j]->addToBoost(od); + } + } + po::variables_map vm; + po::store(po::command_line_parser(argc, argv).options(od).run(), vm); + if (vm.count("help")) + { + std::cout << "usage: " << argv[0] << " [options]" << std::endl; + std::cout << od << std::endl; + exit(0); + } + po::notify(vm); +} +} diff --git a/moveit_planners/trajopt/trajopt_utils/src/logging.cpp b/moveit_planners/trajopt/trajopt_utils/src/logging.cpp new file mode 100644 index 0000000000..f8510478ac --- /dev/null +++ b/moveit_planners/trajopt/trajopt_utils/src/logging.cpp @@ -0,0 +1,54 @@ +#include +TRAJOPT_IGNORE_WARNINGS_PUSH +#include +#include +#include +TRAJOPT_IGNORE_WARNINGS_POP + +#include + +namespace util +{ +LogLevel gLogLevel; + +int LoggingInit() +{ + const char* VALID_THRESH_VALUES = "FATAL ERROR WARN INFO DEBUG TRACE"; + + char* lvlc = getenv("TRAJOPT_LOG_THRESH"); + std::string lvlstr; + if (lvlc == nullptr) + { + std::printf("You can set logging level with TRAJOPT_LOG_THRESH. Valid values: " + "%s. Defaulting to ERROR\n", + VALID_THRESH_VALUES); +#ifdef NDEBUG + lvlstr = "ERROR"; +#else + lvlstr = "DEBUG"; +#endif + } + else + lvlstr = std::string(lvlc); + if (lvlstr == "FATAL") + gLogLevel = LevelFatal; + else if (lvlstr == "ERROR") + gLogLevel = LevelError; + else if (lvlstr == "WARN") + gLogLevel = LevelWarn; + else if (lvlstr == "INFO") + gLogLevel = LevelInfo; + else if (lvlstr == "DEBUG") + gLogLevel = LevelDebug; + else if (lvlstr == "TRACE") + gLogLevel = LevelTrace; + else + { + std::printf("Invalid value for environment variable TRAJOPT_LOG_THRESH: %s\n", lvlstr.c_str()); + std::printf("Valid values: %s\n", VALID_THRESH_VALUES); + abort(); + } + return 1; +} +int this_is_a_hack_but_rhs_executes_on_library_load = LoggingInit(); +} diff --git a/moveit_planners/trajopt/trajopt_utils/src/stl_to_string.cpp b/moveit_planners/trajopt/trajopt_utils/src/stl_to_string.cpp new file mode 100644 index 0000000000..ab8e0b9c2e --- /dev/null +++ b/moveit_planners/trajopt/trajopt_utils/src/stl_to_string.cpp @@ -0,0 +1,33 @@ +#include + +namespace +{ +template +std::string Str_impl(const std::vector& x) +{ + std::stringstream ss; + ss << "("; + if (x.size() > 0) + ss << x[0]; + for (size_t i = 1; i < x.size(); ++i) + ss << ", " << x[i]; + ss << ")"; + return ss.str(); +} +} + +namespace util +{ +std::string Str(const std::vector& x) +{ + return Str_impl(x); +} +std::string Str(const std::vector& x) +{ + return Str_impl(x); +} +std::string Str(const std::vector& x) +{ + return Str_impl(x); +} +} diff --git a/moveit_planners/trajopt/trajopt_utils/src/test_logging.cpp b/moveit_planners/trajopt/trajopt_utils/src/test_logging.cpp new file mode 100644 index 0000000000..a991c81bf0 --- /dev/null +++ b/moveit_planners/trajopt/trajopt_utils/src/test_logging.cpp @@ -0,0 +1,12 @@ +#include + +int main() +{ + LOG_FATAL("fatal"); + LOG_ERROR("error"); + LOG_WARN("warn"); + LOG_INFO("info"); + LOG_DEBUG("debug"); + LOG_TRACE("trace"); + printf("hi\n"); +} diff --git a/moveit_plugins/README.md b/moveit_plugins/README.md index 62065de1f1..b6400b3a55 100644 --- a/moveit_plugins/README.md +++ b/moveit_plugins/README.md @@ -1,4 +1,4 @@ -# MoveIt! Plugins +# MoveIt Plugins This is a collection of plugins for MoveIt: - moveit_simple_controller_manager - A very basic controller manager plugin. Can connect to FollowJointTrajectoryAction and GripperCommandAction servers. diff --git a/moveit_plugins/moveit_fake_controller_manager/CMakeLists.txt b/moveit_plugins/moveit_fake_controller_manager/CMakeLists.txt index 6408e9062b..7a24177c77 100644 --- a/moveit_plugins/moveit_fake_controller_manager/CMakeLists.txt +++ b/moveit_plugins/moveit_fake_controller_manager/CMakeLists.txt @@ -1,7 +1,8 @@ -cmake_minimum_required(VERSION 2.8.3) +cmake_minimum_required(VERSION 3.1.3) project(moveit_fake_controller_manager) -add_compile_options(-std=c++14) +set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_EXTENSIONS OFF) if(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Release) @@ -31,7 +32,10 @@ add_library(${PROJECT_NAME} set_target_properties(${PROJECT_NAME} PROPERTIES VERSION "${${PROJECT_NAME}_VERSION}") target_link_libraries(${PROJECT_NAME} ${catkin_LIBRARIES} ${Boost_LIBRARIES}) -install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}) +install(TARGETS ${PROJECT_NAME} + LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}) install(FILES moveit_fake_controller_manager_plugin_description.xml DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION} diff --git a/moveit_plugins/moveit_fake_controller_manager/README.md b/moveit_plugins/moveit_fake_controller_manager/README.md index 102a296a23..cacbba6f9a 100644 --- a/moveit_plugins/moveit_fake_controller_manager/README.md +++ b/moveit_plugins/moveit_fake_controller_manager/README.md @@ -1,6 +1,6 @@ -# MoveIt! Fake Controller Manager +# MoveIt Fake Controller Manager -This package implements a series of fake trajectory controllers for MoveIt! -- to be used in simulation. +This package implements a series of fake trajectory controllers for MoveIt -- to be used in simulation. For example, the `demo.launch` generated by MoveIt's `setup_assistant`, employs fake controllers for nice visualization in `rviz`. For configuration, edit the file `config/fake_controllers.yaml`, and adjust the desired controller type. diff --git a/moveit_plugins/moveit_fake_controller_manager/package.xml b/moveit_plugins/moveit_fake_controller_manager/package.xml index 05c2662a48..d87a4a53bb 100644 --- a/moveit_plugins/moveit_fake_controller_manager/package.xml +++ b/moveit_plugins/moveit_fake_controller_manager/package.xml @@ -6,7 +6,7 @@ Ioan Sucan Michael Görner - MoveIt! Release Team + MoveIt Release Team BSD diff --git a/moveit_plugins/moveit_plugins/package.xml b/moveit_plugins/moveit_plugins/package.xml index 265fa36725..c64dc69235 100644 --- a/moveit_plugins/moveit_plugins/package.xml +++ b/moveit_plugins/moveit_plugins/package.xml @@ -1,13 +1,13 @@ moveit_plugins 1.0.1 - Metapackage for MoveIt! plugins. + Metapackage for MoveIt plugins. Michael Ferguson Ioan Sucan Michael Görner - MoveIt! Release Team + MoveIt Release Team BSD diff --git a/moveit_plugins/moveit_ros_control_interface/CMakeLists.txt b/moveit_plugins/moveit_ros_control_interface/CMakeLists.txt index e460655d1c..c590d3de6d 100644 --- a/moveit_plugins/moveit_ros_control_interface/CMakeLists.txt +++ b/moveit_plugins/moveit_ros_control_interface/CMakeLists.txt @@ -1,7 +1,8 @@ -cmake_minimum_required(VERSION 2.8.3) +cmake_minimum_required(VERSION 3.1.3) project(moveit_ros_control_interface) -add_compile_options(-std=c++14) +set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_EXTENSIONS OFF) find_package(catkin REQUIRED COMPONENTS actionlib @@ -68,7 +69,7 @@ target_link_libraries(${PROJECT_NAME}_trajectory_plugin install(TARGETS ${PROJECT_NAME}_plugin ${PROJECT_NAME}_trajectory_plugin ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} -RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} +RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION} ) ## Mark cpp header files for installation diff --git a/moveit_plugins/moveit_ros_control_interface/README.md b/moveit_plugins/moveit_ros_control_interface/README.md index d13be1b5a2..355006d366 100644 --- a/moveit_plugins/moveit_ros_control_interface/README.md +++ b/moveit_plugins/moveit_ros_control_interface/README.md @@ -1,4 +1,4 @@ -# MoveIt! ROS Control Plugin +# MoveIt ROS Control Plugin This package provides plugins of base class `moveit_controller_manager::MoveItControllerManager` and a new plugin base class for `moveit_controller_manager::MoveItControllerHandle` allocators. The allocator class is necessary because `moveit_controller_manager::MoveItControllerHandle` needs a name passed to the constructor. @@ -7,7 +7,7 @@ Two variantes are provided, `moveit_ros_control_interface::MoveItControllerManag ## moveit_ros_control_interface::MoveItControllerManager This plugin interfaces a single ros_control-driven node in the namespace given in the `~ros_control_namespace` ROS parameter. -It polls all controllers via the `list_controllers` service and passes their properties to MoveIt!. +It polls all controllers via the `list_controllers` service and passes their properties to MoveIt. The polling is throttled to 1 Hertz. ### Handle plugins @@ -17,7 +17,7 @@ These plugins should be registered with lookup names that match the correspondin Currently plugins for `position_controllers/JointTrajectoryController`, `velocity_controllers/JointTrajectoryController` and `effort_controllers/JointTrajectoryController` are available, which simply wrap `moveit_simple_controller_manager::FollowJointTrajectoryControllerHandle` instances. ### Setup -In your MoveIt! launch file (e.g. `ROBOT_moveit_config/launch/ROBOT_moveit_controller_manager.launch.xml`) set the `moveit_controller_manager` parameter: +In your MoveIt launch file (e.g. `ROBOT_moveit_config/launch/ROBOT_moveit_controller_manager.launch.xml`) set the `moveit_controller_manager` parameter: ``` ``` @@ -42,8 +42,8 @@ controller_list: ``` ### Controller switching -MoveIt! can decide which controllers have to be started and stopped. -Since only controller names with registered allocator plugins are handed over to MoveIt!, this implementation takes care of stopping other conflicting controllers based on their claimed resources and the resources for the to-be-started controllers. +MoveIt can decide which controllers have to be started and stopped. +Since only controller names with registered allocator plugins are handed over to MoveIt, this implementation takes care of stopping other conflicting controllers based on their claimed resources and the resources for the to-be-started controllers. ### Namespaces All controller names get prefixed by the namespace of the ros_control node. @@ -56,7 +56,7 @@ It spawns `moveit_ros_control_interface::MoveItControllerManager` instances with ### Setup -Just set the `moveit_controller_manager` parameter in your MoveIt! launch file (e.g. `ROBOT_moveit_config/launch/ROBOT_moveit_controller_manager.launch.xml`) +Just set the `moveit_controller_manager` parameter in your MoveIt launch file (e.g. `ROBOT_moveit_config/launch/ROBOT_moveit_controller_manager.launch.xml`) ``` ``` diff --git a/moveit_plugins/moveit_ros_control_interface/include/moveit_ros_control_interface/ControllerHandle.h b/moveit_plugins/moveit_ros_control_interface/include/moveit_ros_control_interface/ControllerHandle.h index c9527dfacd..9d39837d79 100644 --- a/moveit_plugins/moveit_ros_control_interface/include/moveit_ros_control_interface/ControllerHandle.h +++ b/moveit_plugins/moveit_ros_control_interface/include/moveit_ros_control_interface/ControllerHandle.h @@ -34,8 +34,7 @@ /* Author: Mathias Lüdtke */ -#ifndef MOVEIT_ROS_CONTROL_INTERFACE_CONTROLLER_HANDLE_H -#define MOVEIT_ROS_CONTROL_INTERFACE_CONTROLLER_HANDLE_H +#pragma once #include #include @@ -58,5 +57,3 @@ class ControllerHandleAllocator }; } // namespace moveit_ros_control_interface - -#endif // MOVEIT_ROS_CONTROL_INTERFACE_CONTROLLER_HANDLE_H diff --git a/moveit_plugins/moveit_ros_control_interface/moveit_core_plugins.xml b/moveit_plugins/moveit_ros_control_interface/moveit_core_plugins.xml index f7461f59d5..3bd7e971cc 100644 --- a/moveit_plugins/moveit_ros_control_interface/moveit_core_plugins.xml +++ b/moveit_plugins/moveit_ros_control_interface/moveit_core_plugins.xml @@ -1,10 +1,10 @@ - ros_control controller manager interface for MoveIt! + ros_control controller manager interface for MoveIt - multiple ros_control controller managers interface for MoveIt! + multiple ros_control controller managers interface for MoveIt diff --git a/moveit_plugins/moveit_ros_control_interface/package.xml b/moveit_plugins/moveit_ros_control_interface/package.xml index 98d0206d4b..92bd877cdc 100644 --- a/moveit_plugins/moveit_ros_control_interface/package.xml +++ b/moveit_plugins/moveit_ros_control_interface/package.xml @@ -2,12 +2,12 @@ moveit_ros_control_interface 1.0.1 - ros_control controller manager interface for MoveIt! + ros_control controller manager interface for MoveIt Mathias Lüdtke Mathias Lüdtke - MoveIt! Release Team + MoveIt Release Team BSD diff --git a/moveit_plugins/moveit_simple_controller_manager/CMakeLists.txt b/moveit_plugins/moveit_simple_controller_manager/CMakeLists.txt index af29fd503f..48c02ea8b5 100644 --- a/moveit_plugins/moveit_simple_controller_manager/CMakeLists.txt +++ b/moveit_plugins/moveit_simple_controller_manager/CMakeLists.txt @@ -1,7 +1,8 @@ -cmake_minimum_required(VERSION 2.8.3) +cmake_minimum_required(VERSION 3.1.3) project(moveit_simple_controller_manager) -add_compile_options(-std=c++14) +set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_EXTENSIONS OFF) if(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Release) @@ -32,7 +33,10 @@ add_library(${PROJECT_NAME} set_target_properties(${PROJECT_NAME} PROPERTIES VERSION "${${PROJECT_NAME}_VERSION}") target_link_libraries(${PROJECT_NAME} ${catkin_LIBRARIES} ${Boost_LIBRARIES}) -install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}) +install(TARGETS ${PROJECT_NAME} + LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}) install(FILES moveit_simple_controller_manager_plugin_description.xml DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION} diff --git a/moveit_plugins/moveit_simple_controller_manager/include/moveit_simple_controller_manager/action_based_controller_handle.h b/moveit_plugins/moveit_simple_controller_manager/include/moveit_simple_controller_manager/action_based_controller_handle.h index bfdee6d098..f3a5b8d059 100644 --- a/moveit_plugins/moveit_simple_controller_manager/include/moveit_simple_controller_manager/action_based_controller_handle.h +++ b/moveit_plugins/moveit_simple_controller_manager/include/moveit_simple_controller_manager/action_based_controller_handle.h @@ -35,8 +35,7 @@ /* Author: Michael Ferguson, Ioan Sucan, E. Gil Jones */ -#ifndef MOVEIT_PLUGINS_ACTION_BASED_CONTROLLER_HANDLE -#define MOVEIT_PLUGINS_ACTION_BASED_CONTROLLER_HANDLE +#pragma once #include #include @@ -186,5 +185,3 @@ class ActionBasedControllerHandle : public ActionBasedControllerHandleBase }; } // end namespace moveit_simple_controller_manager - -#endif // MOVEIT_PLUGINS_ACTION_BASED_CONTROLLER_HANDLE diff --git a/moveit_plugins/moveit_simple_controller_manager/include/moveit_simple_controller_manager/follow_joint_trajectory_controller_handle.h b/moveit_plugins/moveit_simple_controller_manager/include/moveit_simple_controller_manager/follow_joint_trajectory_controller_handle.h index dc01ccf011..4675b1c332 100644 --- a/moveit_plugins/moveit_simple_controller_manager/include/moveit_simple_controller_manager/follow_joint_trajectory_controller_handle.h +++ b/moveit_plugins/moveit_simple_controller_manager/include/moveit_simple_controller_manager/follow_joint_trajectory_controller_handle.h @@ -35,8 +35,7 @@ /* Author: Michael Ferguson, Ioan Sucan, E. Gil Jones */ -#ifndef MOVEIT_PLUGINS_FOLLOW_TRAJECTORY_CONTROLLER_HANDLE -#define MOVEIT_PLUGINS_FOLLOW_TRAJECTORY_CONTROLLER_HANDLE +#pragma once #include #include @@ -77,5 +76,3 @@ class FollowJointTrajectoryControllerHandle }; } // end namespace moveit_simple_controller_manager - -#endif // MOVEIT_PLUGINS_FOLLOW_TRAJECTORY_CONTROLLER_HANDLE diff --git a/moveit_plugins/moveit_simple_controller_manager/include/moveit_simple_controller_manager/gripper_controller_handle.h b/moveit_plugins/moveit_simple_controller_manager/include/moveit_simple_controller_manager/gripper_controller_handle.h index 8574dee376..f081853850 100644 --- a/moveit_plugins/moveit_simple_controller_manager/include/moveit_simple_controller_manager/gripper_controller_handle.h +++ b/moveit_plugins/moveit_simple_controller_manager/include/moveit_simple_controller_manager/gripper_controller_handle.h @@ -35,8 +35,7 @@ /* Author: Michael Ferguson, Ioan Sucan, E. Gil Jones */ -#ifndef MOVEIT_PLUGINS_GRIPPER_CONTROLLER_HANDLE -#define MOVEIT_PLUGINS_GRIPPER_CONTROLLER_HANDLE +#pragma once #include #include @@ -102,7 +101,7 @@ class GripperControllerHandle : public ActionBasedControllerHandleMichael Ferguson Michael Görner - MoveIt! Release Team + MoveIt Release Team BSD diff --git a/moveit_plugins/moveit_simple_controller_manager/src/moveit_simple_controller_manager.cpp b/moveit_plugins/moveit_simple_controller_manager/src/moveit_simple_controller_manager.cpp index 2f15a4189a..e9921962db 100644 --- a/moveit_plugins/moveit_simple_controller_manager/src/moveit_simple_controller_manager.cpp +++ b/moveit_plugins/moveit_simple_controller_manager/src/moveit_simple_controller_manager.cpp @@ -145,7 +145,7 @@ class MoveItSimpleControllerManager : public moveit_controller_manager::MoveItCo continue; } - /* add list of joints, used by controller manager and MoveIt! */ + /* add list of joints, used by controller manager and MoveIt */ for (int j = 0; j < controller_list[i]["joints"].size(); ++j) new_handle->addJoint(std::string(controller_list[i]["joints"][j])); diff --git a/moveit_ros/README.md b/moveit_ros/README.md index ba995b41ef..5755639551 100644 --- a/moveit_ros/README.md +++ b/moveit_ros/README.md @@ -1,6 +1,6 @@ -#MoveIt! ROS +#MoveIt ROS -This repository includes components of MoveIt! that use ROS. This is where much of the functionality MoveIt! provides is put together. Libraries from MoveIt! Core and various plugins are used to provide that functionality. +This repository includes components of MoveIt that use ROS. This is where much of the functionality MoveIt provides is put together. Libraries from MoveIt Core and various plugins are used to provide that functionality. - planning - planning interfaces - benchmarking diff --git a/moveit_ros/benchmarks/CHANGELOG.rst b/moveit_ros/benchmarks/CHANGELOG.rst index 98e4914f29..0bfdc8ef5a 100644 --- a/moveit_ros/benchmarks/CHANGELOG.rst +++ b/moveit_ros/benchmarks/CHANGELOG.rst @@ -155,13 +155,13 @@ Changelog for package moveit_ros_benchmarks as a symlink pointing to the versioned file. Because this sets each library's SONAME to the *full version*, this enforces that *every* binary links with the versioned library file from now on and - has to be relinked with *each* new release of MoveIt!. + has to be relinked with *each* new release of MoveIt. The alternative would be to set the SONAME to `$MAJOR.$MINOR` and ignore the patch version, but because we currently stay with one `$MAJOR.$MINOR` number within each ROS distribution, we had (and likely will have) ABI changes in the `$PATCH` version releases too. The reason for this commit is that it is practically impossible to maintain full ABI compatibility within each ROS distribution and still add the the features/patches the community asks for. - This has resulted in more than one ABI-incompatible MoveIt! release in the recent past + This has resulted in more than one ABI-incompatible MoveIt release in the recent past within a ROS distribution. Because the libraries have not been versioned up to now, there was no way to indicate the incompatible changes and users who did not rebuild their whole workspace with the new release encountered weird and hard-to-track segfaults diff --git a/moveit_ros/benchmarks/CMakeLists.txt b/moveit_ros/benchmarks/CMakeLists.txt index d6ce5fad68..8a8f447e19 100644 --- a/moveit_ros/benchmarks/CMakeLists.txt +++ b/moveit_ros/benchmarks/CMakeLists.txt @@ -1,9 +1,10 @@ -cmake_minimum_required(VERSION 2.8.12) +cmake_minimum_required(VERSION 3.1.3) project(moveit_ros_benchmarks) set(MOVEIT_LIB_NAME moveit_ros_benchmarks) -add_compile_options(-std=c++14) +set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_EXTENSIONS OFF) if(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Release) @@ -39,11 +40,21 @@ target_link_libraries(${MOVEIT_LIB_NAME} ${catkin_LIBRARIES} ${Boost_LIBRARIES}) add_executable(moveit_run_benchmark src/RunBenchmark.cpp) target_link_libraries(moveit_run_benchmark ${MOVEIT_LIB_NAME} ${catkin_LIBRARIES} ${Boost_LIBRARIES}) +add_executable(moveit_combine_predefined_poses_benchmark src/simple_benchmarks/CombinePredefinedPosesBenchmark.cpp) +target_link_libraries(moveit_combine_predefined_poses_benchmark ${MOVEIT_LIB_NAME} ${catkin_LIBRARIES} ${Boost_LIBRARIES}) install( TARGETS - ${MOVEIT_LIB_NAME} moveit_run_benchmark + ${MOVEIT_LIB_NAME} + moveit_run_benchmark + moveit_combine_predefined_poses_benchmark LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}) + +install( + TARGETS + moveit_run_benchmark RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}) install(DIRECTORY include/ DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}) diff --git a/moveit_ros/benchmarks/README.md b/moveit_ros/benchmarks/README.md index 775e391586..4823b68253 100644 --- a/moveit_ros/benchmarks/README.md +++ b/moveit_ros/benchmarks/README.md @@ -1,5 +1,5 @@ -# MoveIt! ROS Benchmarks +# MoveIt ROS Benchmarks This package provides methods to benchmark motion planning algorithms and aggregate/plot statistics. Results can be viewed in [Planner Arena](http://plannerarena.org/). -For more information and usage example please see [moveit tutorials](http://docs.ros.org/indigo/api/moveit_tutorials/html/doc/benchmarking_tutorial.html). +For more information and usage example please see [moveit tutorials](https://ros-planning.github.io/moveit_tutorials/doc/benchmarking/benchmarking_tutorial.html). diff --git a/moveit_ros/benchmarks/examples/demo1.yaml b/moveit_ros/benchmarks/examples/demo1.yaml index 92227c3814..d31a58594a 100644 --- a/moveit_ros/benchmarks/examples/demo1.yaml +++ b/moveit_ros/benchmarks/examples/demo1.yaml @@ -1,5 +1,5 @@ # This is an example configuration that loads the "Kitchen" scene from the -# local MoveIt! warehouse and benchmarks the "manipulator" group in the Pick1 +# local MoveIt warehouse and benchmarks the "panda_arm" group in the Pick1 # query using the Start1 initial state (all pre-stored in the local warehouse) # Three different planners from OMPL are run a total of 50 times each, with a @@ -18,8 +18,8 @@ benchmark_config: output_directory: /tmp/moveit_benchmarks/ queries: Pick1 start_states: Start1 - planners: - - plugin: ompl_interface/OMPLPlanner + planning_pipelines: + - name: ompl planners: - RRTConnectkConfigDefault - BKPIECEkConfigDefault diff --git a/moveit_ros/benchmarks/examples/demo2.yaml b/moveit_ros/benchmarks/examples/demo2.yaml index 9151abf075..cb25a6c6c6 100644 --- a/moveit_ros/benchmarks/examples/demo2.yaml +++ b/moveit_ros/benchmarks/examples/demo2.yaml @@ -1,5 +1,5 @@ # This is an example configuration that loads the "Kitchen" scene from the -# local MoveIt! warehouse and benchmarks the "manipulator" group over all pairs +# local MoveIt warehouse and benchmarks the "manipulator" group over all pairs # of motion plan queries and start states in the Kitchen scene. # Five planners from two different plugins are run a total of 50 times each, with a @@ -18,12 +18,12 @@ benchmark_config: output_directory: /home/benchmarks/ queries: .* start_states: .* - planners: - - plugin: ompl_interface/OMPLPlanner + planning_pipelines: + - name: ompl planners: - RRTConnectkConfigDefault - BKPIECEkConfigDefault - KPIECEkConfigDefault - - plugin: my_plugin_ns/my_plugin + - name: my_pipeline planners: - MyPlanner diff --git a/moveit_ros/benchmarks/examples/demo_fanuc.launch b/moveit_ros/benchmarks/examples/demo_fanuc.launch index 75b4f91b8d..cfecc6f5c5 100644 --- a/moveit_ros/benchmarks/examples/demo_fanuc.launch +++ b/moveit_ros/benchmarks/examples/demo_fanuc.launch @@ -8,7 +8,7 @@ - + diff --git a/moveit_ros/benchmarks/examples/demo_obstacles.yaml b/moveit_ros/benchmarks/examples/demo_obstacles.yaml index 70c7604e03..d6a3c3b504 100644 --- a/moveit_ros/benchmarks/examples/demo_obstacles.yaml +++ b/moveit_ros/benchmarks/examples/demo_obstacles.yaml @@ -1,5 +1,5 @@ # This is an example configuration that loads the "Kitchen" scene from the -# local MoveIt! warehouse and benchmarks the "manipulator" group over all pairs +# local MoveIt warehouse and benchmarks the "manipulator" group over all pairs # of motion plan queries and start states in the Kitchen scene. # Five planners from two different plugins are run a total of 50 times each, with a @@ -18,16 +18,16 @@ benchmark_config: output_directory: /tmp/moveit_benchmarks/ queries: .* start_states: .* - planners: - - plugin: ompl_interface/OMPLPlanner + planning_pipelines: + - name: ompl planners: - RRTConnectkConfigDefault - BKPIECEkConfigDefault - KPIECEkConfigDefault - - plugin: chomp_interface/CHOMPPlanner + - name: chomp planners: - CHOMP - - plugin: stomp_moveit/StompPlannerManager + - name: stomp planners: - STOMP diff --git a/moveit_ros/benchmarks/examples/demo_panda.launch b/moveit_ros/benchmarks/examples/demo_panda.launch index f82b5ef8c8..66742658e5 100644 --- a/moveit_ros/benchmarks/examples/demo_panda.launch +++ b/moveit_ros/benchmarks/examples/demo_panda.launch @@ -8,7 +8,7 @@ - + diff --git a/moveit_ros/benchmarks/examples/demo_panda_all_planners.launch b/moveit_ros/benchmarks/examples/demo_panda_all_planners.launch index 161cd4478b..21b2ad58a8 100644 --- a/moveit_ros/benchmarks/examples/demo_panda_all_planners.launch +++ b/moveit_ros/benchmarks/examples/demo_panda_all_planners.launch @@ -7,25 +7,26 @@ - - - - + + - - - + + + + + - - - + + + - - + + + + - diff --git a/moveit_ros/benchmarks/examples/demo_panda_all_planners.yaml b/moveit_ros/benchmarks/examples/demo_panda_all_planners.yaml index 00ac5066e6..5a101151f9 100644 --- a/moveit_ros/benchmarks/examples/demo_panda_all_planners.yaml +++ b/moveit_ros/benchmarks/examples/demo_panda_all_planners.yaml @@ -1,5 +1,5 @@ # This is an example configuration that loads the "Kitchen" scene from the -# local MoveIt! warehouse and benchmarks the "manipulator" group over all pairs +# local MoveIt warehouse and benchmarks the "manipulator" group over all pairs # of motion plan queries and start states in the Kitchen scene. # Five planners from two different plugins are run a total of 50 times each, with a @@ -18,16 +18,15 @@ benchmark_config: output_directory: /tmp/moveit_benchmarks/ queries: .* start_states: .* - planners: - - plugin: ompl_interface/OMPLPlanner + planning_pipelines: + - name: ompl planners: - RRTConnectkConfigDefault - BKPIECEkConfigDefault - KPIECEkConfigDefault - - plugin: chomp_interface/CHOMPPlanner + - name: chomp planners: - CHOMP - - plugin: stomp_moveit/StompPlannerManager + - name: stomp planners: - STOMP - diff --git a/moveit_ros/benchmarks/examples/demo_panda_all_planners_obstacles.launch b/moveit_ros/benchmarks/examples/demo_panda_all_planners_obstacles.launch index 205bab2081..763d16e86a 100644 --- a/moveit_ros/benchmarks/examples/demo_panda_all_planners_obstacles.launch +++ b/moveit_ros/benchmarks/examples/demo_panda_all_planners_obstacles.launch @@ -7,21 +7,23 @@ - - - - + + - - - + + + + + - - - + + + - - + + + + diff --git a/moveit_ros/benchmarks/examples/demo_panda_predefined_poses.launch b/moveit_ros/benchmarks/examples/demo_panda_predefined_poses.launch new file mode 100644 index 0000000000..657fad0a6f --- /dev/null +++ b/moveit_ros/benchmarks/examples/demo_panda_predefined_poses.launch @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/moveit_ros/benchmarks/examples/demo_panda_predefined_poses.yaml b/moveit_ros/benchmarks/examples/demo_panda_predefined_poses.yaml new file mode 100644 index 0000000000..94f7803595 --- /dev/null +++ b/moveit_ros/benchmarks/examples/demo_panda_predefined_poses.yaml @@ -0,0 +1,34 @@ +# This is an example configuration that loads the "Kitchen" scene from the +# local MoveIt warehouse and benchmarks the "manipulator" group over all pairs +# of motion plan queries and start states in the Kitchen scene. + +# Five planners from two different plugins are run a total of 50 times each, with a +# maximum of 10 seconds per run. Output is stored in the /tmp/moveit_benchmarks directory. + +benchmark_config: + warehouse: + host: 127.0.0.1 + port: 33829 + scene_name: Kitchen # Required + parameters: + name: KitchenPick1 + runs: 50 + group: panda_arm # Required + timeout: 10.0 + output_directory: /tmp/moveit_benchmarks/ + predefined_poses_group: panda_arm_hand # Group where the predefined poses are specified + predefined_poses: # List of named targets + - ready + - extended + planning_pipelines: + - name: ompl + planners: + - RRTConnectkConfigDefault + - BKPIECEkConfigDefault + - KPIECEkConfigDefault + - name: chomp + planners: + - CHOMP + - name: stomp + planners: + - STOMP diff --git a/moveit_ros/benchmarks/include/moveit/benchmarks/BenchmarkExecutor.h b/moveit_ros/benchmarks/include/moveit/benchmarks/BenchmarkExecutor.h index ed88584133..92a0a82a36 100644 --- a/moveit_ros/benchmarks/include/moveit/benchmarks/BenchmarkExecutor.h +++ b/moveit_ros/benchmarks/include/moveit/benchmarks/BenchmarkExecutor.h @@ -34,8 +34,7 @@ /* Author: Ryan Luna */ -#ifndef MOVEIT_ROS_BENCHMARKS_BENCHMARK_EXECUTOR_ -#define MOVEIT_ROS_BENCHMARKS_BENCHMARK_EXECUTOR_ +#pragma once #include @@ -46,7 +45,7 @@ #include #include #include -#include +#include #include #include @@ -141,9 +140,30 @@ class BenchmarkExecutor virtual bool initializeBenchmarks(const BenchmarkOptions& opts, moveit_msgs::PlanningScene& scene_msg, std::vector& queries); + /// Initialize benchmark query data from start states and constraints + virtual bool loadBenchmarkQueryData(const BenchmarkOptions& opts, moveit_msgs::PlanningScene& scene_msg, + std::vector& start_states, + std::vector& path_constraints, + std::vector& goal_constraints, + std::vector& traj_constraints, + std::vector& queries); + virtual void collectMetrics(PlannerRunData& metrics, const planning_interface::MotionPlanDetailedResponse& mp_res, bool solved, double total_time); + /// Compute the similarity of each (final) trajectory to all other (final) trajectories in the experiment and write + /// the results to planner_data metrics + void computeAveragePathSimilarities(PlannerBenchmarkData& planner_data, + const std::vector& responses, + const std::vector& solved); + + /// Helper function used by computeAveragePathSimilarities() for computing a heuristic distance metric between two + /// robot trajectories. This function aligns both trajectories in a greedy fashion and computes the mean waypoint + /// distance averaged over all aligned waypoints. Using a greedy approach is more efficient than dynamic time warping, + /// and seems to be sufficient for similar trajectories. + bool computeTrajectoryDistance(const robot_trajectory::RobotTrajectory& traj_first, + const robot_trajectory::RobotTrajectory& traj_second, double& result_distance); + virtual void writeOutput(const BenchmarkRequest& brequest, const std::string& start_time, double benchmark_duration); void shiftConstraintsByOffset(moveit_msgs::Constraints& constraints, const std::vector& offset); @@ -192,8 +212,7 @@ class BenchmarkExecutor BenchmarkOptions options_; - std::shared_ptr> planner_plugin_loader_; - std::map planner_interfaces_; + std::map planning_pipelines_; std::vector benchmark_data_; @@ -205,5 +224,3 @@ class BenchmarkExecutor std::vector query_end_fns_; }; } - -#endif diff --git a/moveit_ros/benchmarks/include/moveit/benchmarks/BenchmarkOptions.h b/moveit_ros/benchmarks/include/moveit/benchmarks/BenchmarkOptions.h index 0bc10321af..92c7671529 100644 --- a/moveit_ros/benchmarks/include/moveit/benchmarks/BenchmarkOptions.h +++ b/moveit_ros/benchmarks/include/moveit/benchmarks/BenchmarkOptions.h @@ -34,8 +34,7 @@ /* Author: Ryan Luna */ -#ifndef MOVEIT_ROS_BENCHMARK_BENCHMARK_OPTIONS_ -#define MOVEIT_ROS_BENCHMARK_BENCHMARK_OPTIONS_ +#pragma once #include #include @@ -48,31 +47,57 @@ namespace moveit_ros_benchmarks class BenchmarkOptions { public: + /** \brief Constructor */ BenchmarkOptions(); + /** \brief Constructor accepting a custom namespace for parameter lookup */ BenchmarkOptions(const std::string& ros_namespace); + /** \brief Destructor */ virtual ~BenchmarkOptions(); + /** \brief Set the ROS namespace the node handle should use for parameter lookup */ void setNamespace(const std::string& ros_namespace); + /** \brief Get the name of the warehouse database host server */ const std::string& getHostName() const; + /** \brief Get the port of the warehouse database host server */ int getPort() const; + /** \brief Get the reference name of the planning scene stored inside the warehouse database */ const std::string& getSceneName() const; + /** \brief Get the specified number of benchmark query runs */ int getNumRuns() const; + /** \brief Get the maximum timeout per planning attempt */ double getTimeout() const; + /** \brief Get the reference name of the benchmark */ const std::string& getBenchmarkName() const; + /** \brief Get the name of the planning group to run the benchmark with */ const std::string& getGroupName() const; + /** \brief Get the target directory for the generated benchmark result data */ const std::string& getOutputDirectory() const; + /** \brief Get the regex expression for matching the names of all queries to run */ const std::string& getQueryRegex() const; + /** \brief Get the regex expression for matching the names of all start states to plan from */ const std::string& getStartStateRegex() const; + /** \brief Get the regex expression for matching the names of all goal constraints to plan to */ const std::string& getGoalConstraintRegex() const; + /** \brief Get the regex expression for matching the names of all path constraints to plan with */ const std::string& getPathConstraintRegex() const; + /** \brief Get the regex expression for matching the names of all trajectory constraints to plan with */ const std::string& getTrajectoryConstraintRegex() const; + /** \brief Get the names of all predefined poses to consider for planning */ + const std::vector& getPredefinedPoses() const; + /** \brief Get the name of the planning group for which the predefined poses are defined */ + const std::string& getPredefinedPosesGroup() const; + /** \brief Get the constant position/orientation offset to be used for shifting all goal constraints */ void getGoalOffsets(std::vector& offsets) const; - const std::map>& getPlannerConfigurations() const; - void getPlannerPluginList(std::vector& plugin_list) const; + /** \brief Get all planning pipeline names mapped to their parameter configuration */ + const std::map>& getPlanningPipelineConfigurations() const; + /** \brief Get all planning pipeline names */ + void getPlanningPipelineNames(std::vector& planning_pipeline_names) const; + /* \brief Get the frame id of the planning workspace */ const std::string& getWorkspaceFrameID() const; + /* \brief Get the parameter set of the planning workspace */ const moveit_msgs::WorkspaceParameters& getWorkspaceParameters() const; protected: @@ -101,13 +126,13 @@ class BenchmarkOptions std::string goal_constraint_regex_; std::string path_constraint_regex_; std::string trajectory_constraint_regex_; + std::vector predefined_poses_; + std::string predefined_poses_group_; double goal_offsets[6]; /// planner configurations - std::map> planners_; + std::map> planning_pipelines_; moveit_msgs::WorkspaceParameters workspace_; }; } - -#endif diff --git a/moveit_ros/benchmarks/package.xml b/moveit_ros/benchmarks/package.xml index cbb64dbe81..acc1789072 100644 --- a/moveit_ros/benchmarks/package.xml +++ b/moveit_ros/benchmarks/package.xml @@ -2,12 +2,12 @@ moveit_ros_benchmarks 1.0.1 - Enhanced tools for benchmarks in MoveIt! + Enhanced tools for benchmarks in MoveIt Ryan Luna Dave Coleman - MoveIt! Release Team + MoveIt Release Team http://moveit.ros.org https://github.com/ros-planning/moveit/issues diff --git a/moveit_ros/benchmarks/scripts/moveit_benchmark_statistics.py b/moveit_ros/benchmarks/scripts/moveit_benchmark_statistics.py index fd84005a33..50896a037d 100755 --- a/moveit_ros/benchmarks/scripts/moveit_benchmark_statistics.py +++ b/moveit_ros/benchmarks/scripts/moveit_benchmark_statistics.py @@ -112,7 +112,7 @@ def readBenchmarkLog(dbname, filenames): # create all tables if they don't already exist c.executescript("""CREATE TABLE IF NOT EXISTS experiments - (id INTEGER PRIMARY KEY AUTOINCREMENT, name VARCHAR(512), + (id INTEGER PRIMARY KEY ON CONFLICT REPLACE AUTOINCREMENT, name VARCHAR(512), totaltime REAL, timelimit REAL, memorylimit REAL, runcount INTEGER, version VARCHAR(128), hostname VARCHAR(1024), cpuinfo TEXT, date DATETIME, seed INTEGER, setup TEXT); @@ -130,7 +130,19 @@ def readBenchmarkLog(dbname, filenames): (runid INTEGER, time REAL, PRIMARY KEY (runid, time), FOREIGN KEY (runid) REFERENCES runs(id) ON DELETE CASCADE)""") - for filename in filenames: + # add placeholder entry for all_experiments + allExperimentsName = "all_experiments" + allExperimentsValues = { + "totaltime": 0.0, "timelimit": 0.0, "memorylimit": 0.0, "runcount": 0, "version": "0.0.0", + "hostname": "", "cpuinfo": "", "date": 0, "seed": 0, "setup": "" + } + addAllExperiments = len(filenames) > 0 + if addAllExperiments: + c.execute('INSERT INTO experiments VALUES (?,?,?,?,?,?,?,?,?,?,?,?)', + (None, allExperimentsName) + tuple(allExperimentsValues.values())) + allExperimentsId = c.lastrowid + + for i, filename in enumerate(filenames): print('Processing ' + filename) logfile = open(filename,'r') start_pos = logfile.tell() @@ -155,7 +167,19 @@ def readBenchmarkLog(dbname, filenames): nrruns = -1 if nrrunsOrNone != None: nrruns = int(nrrunsOrNone) + allExperimentsValues['runcount'] += nrruns totaltime = float(readRequiredLogValue("total time", logfile, 0, {-3 : "collect", -2 : "the", -1 : "data"})) + # fill in fields of all_experiments + allExperimentsValues['totaltime'] += totaltime + allExperimentsValues['memorylimit'] = max(allExperimentsValues['memorylimit'], totaltime) + allExperimentsValues['timelimit'] = max(allExperimentsValues['timelimit'], totaltime) + # copy the fields of the first file to all_experiments so that they are not empty + if (i==0): + allExperimentsValues['version'] = version + allExperimentsValues['date'] = date + allExperimentsValues['setup'] = expsetup + allExperimentsValues['hostname'] = hostname + allExperimentsValues['cpuinfo'] = cpuinfo numEnums = 0 numEnumsOrNone = readOptionalLogValue(logfile, 0, {-2 : "enum"}) if numEnumsOrNone != None: @@ -213,13 +237,17 @@ def readBenchmarkLog(dbname, filenames): numRuns = int(logfile.readline().split()[0]) runIds = [] for j in range(numRuns): - values = tuple([experimentId, plannerId] + \ - [None if len(x) == 0 or x == 'nan' or x == 'inf' else x - for x in logfile.readline().split('; ')[:-1]]) + runValues = [None if len(x) == 0 or x == 'nan' or x == 'inf' else x + for x in logfile.readline().split('; ')[:-1]] + values = tuple([experimentId, plannerId] + runValues) c.execute(insertFmtStr, values) # extract primary key of each run row so we can reference them # in the planner progress data table if needed runIds.append(c.lastrowid) + # add all run data to all_experiments + if addAllExperiments: + values = tuple([allExperimentsId, plannerId] + runValues) + c.execute(insertFmtStr, values) nextLine = logfile.readline().strip() @@ -259,6 +287,15 @@ def readBenchmarkLog(dbname, filenames): logfile.readline() logfile.close() + + if addAllExperiments: + updateString = "UPDATE experiments SET" + for i, (key, val) in enumerate(allExperimentsValues.items()): + if i > 0: + updateString += "," + updateString += " " + str(key) + "='" + str(val) + "'" + updateString += "WHERE id='" + str(allExperimentsId) + "'" + c.execute(updateString) conn.commit() c.close() @@ -306,7 +343,7 @@ def plotAttribute(cur, planners, attribute, typename): color=matplotlib.cm.hot(int(floor(i*256/numValues))), label=descriptions[i]) heights = heights + measurements[i] - xtickNames = plt.xticks([x+width/2. for x in ind], labels, rotation=30) + xtickNames = plt.xticks([x + width / 2. for x in ind], labels, rotation=30, fontsize=8, ha='right') ax.set_ylabel(attribute.replace('_',' ') + ' (%)') box = ax.get_position() ax.set_position([box.x0, box.y0, box.width * 0.8, box.height]) @@ -318,7 +355,11 @@ def plotAttribute(cur, planners, attribute, typename): measurementsPercentage = [sum(m) * 100. / len(m) for m in measurements] ind = range(len(measurements)) plt.bar(ind, measurementsPercentage, width) - xtickNames = plt.xticks([x + width / 2. for x in ind], labels, rotation=30, fontsize=8) + ### uncommenting this line will remove the term 'kConfigDefault' from the labels for OMPL Solvers. + ### Fits situations where you need more control in the plot, such as in an academic publication for example + #labels = [l.replace('kConfigDefault', '') for l in labels] + + xtickNames = plt.xticks([x + width / 2. for x in ind], labels, rotation=30, fontsize=8, ha='right') ax.set_ylabel(attribute.replace('_',' ') + ' (%)') plt.subplots_adjust(bottom=0.3) # Squish the plot into the upper 2/3 of the page. Leave room for labels else: @@ -330,19 +371,24 @@ def plotAttribute(cur, planners, attribute, typename): #xtickNames = plt.xticks(labels, rotation=30, fontsize=10) #plt.subplots_adjust(bottom=0.3) # Squish the plot into the upper 2/3 of the page. Leave room for labels - + + ### uncommenting this line will remove the term 'kConfigDefault' from the labels for OMPL Solvers. + ### Fits situations where you need more control in the plot, such as in an academic publication for example + #labels = [l.replace('kConfigDefault', '') for l in labels] + xtickNames = plt.setp(ax,xticklabels=labels) - plt.setp(xtickNames, rotation=30) + plt.setp(xtickNames, rotation=30, fontsize=8, ha='right') for tick in ax.xaxis.get_major_ticks(): # shrink the font size of the x tick labels tick.label.set_fontsize(8) plt.subplots_adjust(bottom=0.3) # Squish the plot into the upper 2/3 of the page. Leave room for labels - ax.set_xlabel('Motion planning algorithm') + ax.set_xlabel('Motion planning algorithm', fontsize=12) ax.yaxis.grid(True, linestyle='-', which='major', color='lightgrey', alpha=0.5) if max(nanCounts)>0: maxy = max([max(y) for y in measurements]) for i in range(len(labels)): x = i+width/2 if typename=='BOOLEAN' else i+1 - ax.text(x, .95*maxy, str(nanCounts[i]), horizontalalignment='center', size='small') + ### uncommenting the next line, the number of failed planning attempts will be added to each bar + # ax.text(x, .95*maxy, str(nanCounts[i]), horizontalalignment='center', size='small') plt.show() def plotProgressAttribute(cur, planners, attribute): @@ -541,9 +587,9 @@ def computeViews(dbname): (options, args) = parser.parse_args() if len(args) == 0: - parser.error("No arguments were provided. Please provide full path of log file") + parser.error("No arguments were provided. Please provide full path of log file") - if len(args) == 1: + if len(args) > 0: readBenchmarkLog(options.dbname, args) # If we update the database, we recompute the views as well options.view = True diff --git a/moveit_ros/benchmarks/src/BenchmarkExecutor.cpp b/moveit_ros/benchmarks/src/BenchmarkExecutor.cpp index aa59bed3f9..1f55bf7102 100644 --- a/moveit_ros/benchmarks/src/BenchmarkExecutor.cpp +++ b/moveit_ros/benchmarks/src/BenchmarkExecutor.cpp @@ -44,7 +44,11 @@ #include #include #include +#ifndef _WIN32 #include +#else +#include +#endif using namespace moveit_ros_benchmarks; @@ -71,17 +75,6 @@ BenchmarkExecutor::BenchmarkExecutor(const std::string& robot_description_param) tcs_ = nullptr; psm_ = new planning_scene_monitor::PlanningSceneMonitor(robot_description_param); planning_scene_ = psm_->getPlanningScene(); - - // Initialize the class loader for planner plugins - try - { - planner_plugin_loader_.reset(new pluginlib::ClassLoader( - "moveit_core", "planning_interface::PlannerManager")); - } - catch (pluginlib::PluginlibException& ex) - { - ROS_FATAL_STREAM("Exception while creating planning plugin loader " << ex.what()); - } } BenchmarkExecutor::~BenchmarkExecutor() @@ -94,46 +87,39 @@ BenchmarkExecutor::~BenchmarkExecutor() delete psm_; } -void BenchmarkExecutor::initialize(const std::vector& plugin_classes) +void BenchmarkExecutor::initialize(const std::vector& planning_pipeline_names) { - planner_interfaces_.clear(); + planning_pipelines_.clear(); - // Load the planning plugins - const std::vector& classes = planner_plugin_loader_->getDeclaredClasses(); - - for (const std::string& planner_plugin_name : plugin_classes) + ros::NodeHandle pnh("~"); + for (const std::string& planning_pipeline_name : planning_pipeline_names) { - std::vector::const_iterator it = std::find(classes.begin(), classes.end(), planner_plugin_name); - if (it == classes.end()) - { - ROS_ERROR("Failed to find plugin_class %s", planner_plugin_name.c_str()); - return; - } - - try - { - planning_interface::PlannerManagerPtr p = planner_plugin_loader_->createUniqueInstance(planner_plugin_name); - p->initialize(planning_scene_->getRobotModel(), ""); + // Initialize planning pipelines from configured child namespaces + ros::NodeHandle child_nh(pnh, planning_pipeline_name); + planning_pipeline::PlanningPipelinePtr pipeline(new planning_pipeline::PlanningPipeline( + planning_scene_->getRobotModel(), child_nh, "planning_plugin", "request_adapters")); - p->getPlannerConfigurations(); - planner_interfaces_[planner_plugin_name] = p; - } - catch (pluginlib::PluginlibException& ex) + // Verify the pipeline has successfully initialized a planner + if (!pipeline->getPlannerManager()) { - ROS_ERROR_STREAM("Exception while loading planner '" << planner_plugin_name << "': " << ex.what()); + ROS_ERROR("Failed to initialize planning pipeline '%s'", planning_pipeline_name.c_str()); + continue; } + + // Disable visualizations and store pipeline + pipeline->displayComputedMotionPlans(false); + pipeline->checkSolutionPaths(false); + planning_pipelines_[planning_pipeline_name] = pipeline; } - // error check - if (planner_interfaces_.empty()) - ROS_ERROR("No planning plugins have been loaded. Nothing to do for the benchmarking service."); + // Error check + if (planning_pipelines_.empty()) + ROS_ERROR("No planning pipelines have been loaded. Nothing to do for the benchmarking service."); else { - std::stringstream ss; - for (std::map::const_iterator it = planner_interfaces_.begin(); - it != planner_interfaces_.end(); ++it) - ss << it->first << " "; - ROS_INFO("Available planner instances: %s", ss.str().c_str()); + ROS_INFO("Available planning pipelines:"); + for (const std::pair& entry : planning_pipelines_) + ROS_INFO_STREAM("Pipeline: " << entry.first << ", Planner: " << entry.second->getPlannerPluginName()); } } @@ -206,9 +192,9 @@ void BenchmarkExecutor::addQueryCompletionEvent(const QueryCompletionEventFuncti bool BenchmarkExecutor::runBenchmarks(const BenchmarkOptions& opts) { - if (planner_interfaces_.empty()) + if (planning_pipelines_.empty()) { - ROS_ERROR("No planning interfaces configured. Did you call BenchmarkExecutor::initialize?"); + ROS_ERROR("No planning pipelines configured. Did you call BenchmarkExecutor::initialize?"); return false; } @@ -217,7 +203,7 @@ bool BenchmarkExecutor::runBenchmarks(const BenchmarkOptions& opts) if (initializeBenchmarks(opts, scene_msg, queries)) { - if (!queriesAndPlannersCompatible(queries, opts.getPlannerConfigurations())) + if (!queriesAndPlannersCompatible(queries, opts.getPlanningPipelineConfigurations())) return false; for (std::size_t i = 0; i < queries.size(); ++i) @@ -241,7 +227,7 @@ bool BenchmarkExecutor::runBenchmarks(const BenchmarkOptions& opts) ROS_INFO("Benchmarking query '%s' (%lu of %lu)", queries[i].name.c_str(), i + 1, queries.size()); ros::WallTime start_time = ros::WallTime::now(); - runBenchmark(queries[i].request, options_.getPlannerConfigurations(), options_.getNumRuns()); + runBenchmark(queries[i].request, options_.getPlanningPipelineConfigurations(), options_.getNumRuns()); double duration = (ros::WallTime::now() - start_time).toSec(); for (QueryCompletionEventFunction& query_end_fn : query_end_fns_) @@ -259,14 +245,15 @@ bool BenchmarkExecutor::queriesAndPlannersCompatible(const std::vector>& planners) { // Make sure that the planner interfaces can service the desired queries - for (std::map::const_iterator it = planner_interfaces_.begin(); - it != planner_interfaces_.end(); ++it) + for (const std::pair& pipeline_entry : planning_pipelines_) { for (const BenchmarkRequest& request : requests) { - if (!it->second->canServiceRequest(request.request)) + if (!pipeline_entry.second->getPlannerManager()->canServiceRequest(request.request)) { - ROS_ERROR("Interface '%s' cannot service the benchmark request '%s'", it->first.c_str(), request.name.c_str()); + ROS_ERROR("Interface '%s' in pipeline '%s' cannot service the benchmark request '%s'", + pipeline_entry.second->getPlannerPluginName().c_str(), pipeline_entry.first.c_str(), + request.name.c_str()); return false; } } @@ -278,48 +265,19 @@ bool BenchmarkExecutor::queriesAndPlannersCompatible(const std::vector& requests) { - if (!plannerConfigurationsExist(opts.getPlannerConfigurations(), opts.getGroupName())) + if (!plannerConfigurationsExist(opts.getPlanningPipelineConfigurations(), opts.getGroupName())) return false; - try - { - warehouse_ros::DatabaseConnection::Ptr conn = dbloader.loadDatabase(); - conn->setParams(opts.getHostName(), opts.getPort(), 20); - if (conn->connect()) - { - pss_ = new moveit_warehouse::PlanningSceneStorage(conn); - psws_ = new moveit_warehouse::PlanningSceneWorldStorage(conn); - rs_ = new moveit_warehouse::RobotStateStorage(conn); - cs_ = new moveit_warehouse::ConstraintsStorage(conn); - tcs_ = new moveit_warehouse::TrajectoryConstraintsStorage(conn); - } - else - { - ROS_ERROR("Failed to connect to DB"); - return false; - } - } - catch (std::exception& e) - { - ROS_ERROR("Failed to initialize benchmark server: '%s'", e.what()); - return false; - } - std::vector start_states; std::vector path_constraints; std::vector goal_constraints; std::vector traj_constraints; std::vector queries; - bool ok = loadPlanningScene(opts.getSceneName(), scene_msg) && loadStates(opts.getStartStateRegex(), start_states) && - loadPathConstraints(opts.getGoalConstraintRegex(), goal_constraints) && - loadPathConstraints(opts.getPathConstraintRegex(), path_constraints) && - loadTrajectoryConstraints(opts.getTrajectoryConstraintRegex(), traj_constraints) && - loadQueries(opts.getQueryRegex(), opts.getSceneName(), queries); - - if (!ok) + if (!loadBenchmarkQueryData(opts, scene_msg, start_states, path_constraints, goal_constraints, traj_constraints, + queries)) { - ROS_ERROR("Failed to load benchmark stuff"); + ROS_ERROR("Failed to load benchmark query data"); return false; } @@ -429,6 +387,44 @@ bool BenchmarkExecutor::initializeBenchmarks(const BenchmarkOptions& opts, movei return true; } +bool BenchmarkExecutor::loadBenchmarkQueryData(const BenchmarkOptions& opts, moveit_msgs::PlanningScene& scene_msg, + std::vector& start_states, + std::vector& path_constraints, + std::vector& goal_constraints, + std::vector& traj_constraints, + std::vector& queries) +{ + try + { + warehouse_ros::DatabaseConnection::Ptr warehouse_connection = dbloader.loadDatabase(); + warehouse_connection->setParams(opts.getHostName(), opts.getPort(), 20); + if (warehouse_connection->connect()) + { + pss_ = new moveit_warehouse::PlanningSceneStorage(warehouse_connection); + psws_ = new moveit_warehouse::PlanningSceneWorldStorage(warehouse_connection); + rs_ = new moveit_warehouse::RobotStateStorage(warehouse_connection); + cs_ = new moveit_warehouse::ConstraintsStorage(warehouse_connection); + tcs_ = new moveit_warehouse::TrajectoryConstraintsStorage(warehouse_connection); + } + else + { + ROS_ERROR("Failed to connect to DB"); + return false; + } + } + catch (std::exception& e) + { + ROS_ERROR("Failed to initialize benchmark server: '%s'", e.what()); + return false; + } + + return loadPlanningScene(opts.getSceneName(), scene_msg) && loadStates(opts.getStartStateRegex(), start_states) && + loadPathConstraints(opts.getGoalConstraintRegex(), goal_constraints) && + loadPathConstraints(opts.getPathConstraintRegex(), path_constraints) && + loadTrajectoryConstraints(opts.getTrajectoryConstraintRegex(), traj_constraints) && + loadQueries(opts.getQueryRegex(), opts.getSceneName(), queries); +} + void BenchmarkExecutor::shiftConstraintsByOffset(moveit_msgs::Constraints& constraints, const std::vector& offset) { @@ -475,6 +471,10 @@ void BenchmarkExecutor::createRequestCombinations(const BenchmarkRequest& breque { for (const StartState& start_state : start_states) { + // Skip start states that have the same name as the goal + if (start_state.name == brequest.name) + continue; + BenchmarkRequest new_brequest = brequest; new_brequest.request.start_state = start_state.state; @@ -495,33 +495,31 @@ void BenchmarkExecutor::createRequestCombinations(const BenchmarkRequest& breque } } -bool BenchmarkExecutor::plannerConfigurationsExist(const std::map>& planners, - const std::string& group_name) +bool BenchmarkExecutor::plannerConfigurationsExist( + const std::map>& pipeline_configurations, const std::string& group_name) { // Make sure planner plugins exist - for (std::map>::const_iterator it = planners.begin(); it != planners.end(); - ++it) + for (const std::pair>& pipeline_config_entry : pipeline_configurations) { - bool plugin_exists = false; - for (std::map::const_iterator planner_it = - planner_interfaces_.begin(); - planner_it != planner_interfaces_.end() && !plugin_exists; ++planner_it) + bool pipeline_exists = false; + for (const std::pair& pipeline_entry : planning_pipelines_) { - plugin_exists = planner_it->first == it->first; + pipeline_exists = pipeline_entry.first == pipeline_config_entry.first; + if (pipeline_exists) + break; } - if (!plugin_exists) + if (!pipeline_exists) { - ROS_ERROR("Planning plugin '%s' does NOT exist", it->first.c_str()); + ROS_ERROR("Planning pipeline '%s' does NOT exist", pipeline_config_entry.first.c_str()); return false; } } - // Make sure planning algorithms exist within those plugins - for (std::map>::const_iterator it = planners.begin(); it != planners.end(); - ++it) + // Make sure planners exist within those pipelines + for (const std::pair>& entry : pipeline_configurations) { - planning_interface::PlannerManagerPtr pm = planner_interfaces_[it->first]; + planning_interface::PlannerManagerPtr pm = planning_pipelines_[entry.first]->getPlannerManager(); const planning_interface::PlannerConfigurationMap& config_map = pm->getPlannerConfigurations(); // if the planner is chomp or stomp skip this function and return true for checking planner configurations for the @@ -530,24 +528,22 @@ bool BenchmarkExecutor::plannerConfigurationsExist(const std::mapgetDescription().compare("stomp") || pm->getDescription().compare("chomp")) continue; - for (std::size_t i = 0; i < it->second.size(); ++i) + for (std::size_t i = 0; i < entry.second.size(); ++i) { bool planner_exists = false; - for (planning_interface::PlannerConfigurationMap::const_iterator map_it = config_map.begin(); - map_it != config_map.end() && !planner_exists; ++map_it) + for (const std::pair& config_entry : config_map) { - std::string planner_name = group_name + "[" + it->second[i] + "]"; - planner_exists = (map_it->second.group == group_name && map_it->second.name == planner_name); + std::string planner_name = group_name + "[" + entry.second[i] + "]"; + planner_exists = (config_entry.second.group == group_name && config_entry.second.name == planner_name); } if (!planner_exists) { - ROS_ERROR("Planner '%s' does NOT exist for group '%s' in pipeline '%s'", it->second[i].c_str(), - group_name.c_str(), it->first.c_str()); + ROS_ERROR("Planner '%s' does NOT exist for group '%s' in pipeline '%s'", entry.second[i].c_str(), + group_name.c_str(), entry.first.c_str()); std::cout << "There are " << config_map.size() << " planner entries: " << std::endl; - for (planning_interface::PlannerConfigurationMap::const_iterator map_it = config_map.begin(); - map_it != config_map.end() && !planner_exists; ++map_it) - std::cout << map_it->second.name << std::endl; + for (const auto& config_map_entry : config_map) + std::cout << config_map_entry.second.name << std::endl; return false; } } @@ -747,33 +743,42 @@ bool BenchmarkExecutor::loadTrajectoryConstraints(const std::string& regex, } void BenchmarkExecutor::runBenchmark(moveit_msgs::MotionPlanRequest request, - const std::map>& planners, int runs) + const std::map>& pipeline_map, int runs) { benchmark_data_.clear(); unsigned int num_planners = 0; - for (const std::pair>& planner : planners) - num_planners += planner.second.size(); + for (const std::pair>& pipeline_entry : pipeline_map) + num_planners += pipeline_entry.second.size(); boost::progress_display progress(num_planners * runs, std::cout); - // Iterate through all planner plugins - for (const std::pair>& planner : planners) + // Iterate through all planning pipelines + for (const std::pair>& pipeline_entry : pipeline_map) { - // Iterate through all planners associated with the plugin - for (std::size_t i = 0; i < planner.second.size(); ++i) + planning_pipeline::PlanningPipelinePtr planning_pipeline = planning_pipelines_[pipeline_entry.first]; + // Use the planning context if the pipeline only contains the planner plugin + bool use_planning_context = planning_pipeline->getAdapterPluginNames().empty(); + // Iterate through all planners configured for the pipeline + for (const std::string& planner_id : pipeline_entry.second) { // This container stores all of the benchmark data for this planner PlannerBenchmarkData planner_data(runs); + // This vector stores all motion plan results for further evaluation + std::vector responses(runs); + std::vector solved(runs); - request.planner_id = planner.second[i]; + request.planner_id = planner_id; // Planner start events for (PlannerStartEventFunction& planner_start_fn : planner_start_fns_) planner_start_fn(request, planner_data); - planning_interface::PlanningContextPtr context = - planner_interfaces_[planner.first]->getPlanningContext(planning_scene_, request); + planning_interface::PlanningContextPtr planning_context; + if (use_planning_context) + planning_context = planning_pipeline->getPlannerManager()->getPlanningContext(planning_scene_, request); + + // Iterate runs for (int j = 0; j < runs; ++j) { // Pre-run events @@ -781,9 +786,24 @@ void BenchmarkExecutor::runBenchmark(moveit_msgs::MotionPlanRequest request, pre_event_fn(request); // Solve problem - planning_interface::MotionPlanDetailedResponse mp_res; ros::WallTime start = ros::WallTime::now(); - bool solved = context->solve(mp_res); + if (use_planning_context) + { + solved[j] = planning_context->solve(responses[j]); + } + else + { + // The planning pipeline does not support MotionPlanDetailedResponse + planning_interface::MotionPlanResponse response; + solved[j] = planning_pipeline->generatePlan(planning_scene_, request, response); + responses[j].error_code_ = response.error_code_; + if (response.trajectory_) + { + responses[j].description_.push_back("plan"); + responses[j].trajectory_.push_back(response.trajectory_); + responses[j].processing_time_.push_back(response.planning_time_); + } + } double total_time = (ros::WallTime::now() - start).toSec(); // Collect data @@ -791,14 +811,16 @@ void BenchmarkExecutor::runBenchmark(moveit_msgs::MotionPlanRequest request, // Post-run events for (PostRunEventFunction& post_event_fn : post_event_fns_) - post_event_fn(request, mp_res, planner_data[j]); - collectMetrics(planner_data[j], mp_res, solved, total_time); + post_event_fn(request, responses[j], planner_data[j]); + collectMetrics(planner_data[j], responses[j], solved[j], total_time); double metrics_time = (ros::WallTime::now() - start).toSec(); ROS_DEBUG("Spent %lf seconds collecting metrics", metrics_time); ++progress; } + computeAveragePathSimilarities(planner_data, responses, solved); + // Planner completion events for (PlannerCompletionEventFunction& planner_completion_fn : planner_completion_fns_) planner_completion_fn(request, planner_data); @@ -889,6 +911,15 @@ void BenchmarkExecutor::collectMetrics(PlannerRunData& metrics, metrics["path_" + mp_res.description_[j] + "_clearance REAL"] = moveit::core::toString(clearance); metrics["path_" + mp_res.description_[j] + "_smoothness REAL"] = moveit::core::toString(smoothness); metrics["path_" + mp_res.description_[j] + "_time REAL"] = moveit::core::toString(mp_res.processing_time_[j]); + + if (j == mp_res.trajectory_.size() - 1) + { + metrics["final_path_correct BOOLEAN"] = boost::lexical_cast(correct); + metrics["final_path_length REAL"] = moveit::core::toString(traj_len); + metrics["final_path_clearance REAL"] = moveit::core::toString(clearance); + metrics["final_path_smoothness REAL"] = moveit::core::toString(smoothness); + metrics["final_path_time REAL"] = moveit::core::toString(mp_res.processing_time_[j]); + } process_time -= mp_res.processing_time_[j]; } if (process_time <= 0.0) @@ -897,14 +928,129 @@ void BenchmarkExecutor::collectMetrics(PlannerRunData& metrics, } } +void BenchmarkExecutor::computeAveragePathSimilarities( + PlannerBenchmarkData& planner_data, const std::vector& responses, + const std::vector& solved) +{ + ROS_INFO("Computing result path similarity"); + const size_t result_count = planner_data.size(); + size_t unsolved = std::count_if(solved.begin(), solved.end(), [](bool s) { return !s; }); + std::vector average_distances(responses.size()); + for (size_t first_traj_i = 0; first_traj_i < result_count; ++first_traj_i) + { + // If trajectory was not solved there is no valid average distance so it's set to max double only + if (!solved[first_traj_i]) + { + average_distances[first_traj_i] = std::numeric_limits::max(); + continue; + } + // Iterate all result trajectories that haven't been compared yet + for (size_t second_traj_i = first_traj_i + 1; second_traj_i < result_count; ++second_traj_i) + { + // Ignore if other result has not been solved + if (!solved[second_traj_i]) + continue; + + // Get final trajectories + const robot_trajectory::RobotTrajectory& traj_first = *responses[first_traj_i].trajectory_.back(); + const robot_trajectory::RobotTrajectory& traj_second = *responses[second_traj_i].trajectory_.back(); + + // Compute trajectory distance + double trajectory_distance; + if (!computeTrajectoryDistance(traj_first, traj_second, trajectory_distance)) + continue; + + // Add average distance to counters of both trajectories + average_distances[first_traj_i] += trajectory_distance; + average_distances[second_traj_i] += trajectory_distance; + } + // Normalize average distance by number of actual comparisons + average_distances[first_traj_i] /= result_count - unsolved - 1; + } + + // Store results in planner_data + for (size_t i = 0; i < result_count; ++i) + planner_data[i]["average_waypoint_distance REAL"] = moveit::core::toString(average_distances[i]); +} + +bool BenchmarkExecutor::computeTrajectoryDistance(const robot_trajectory::RobotTrajectory& traj_first, + const robot_trajectory::RobotTrajectory& traj_second, + double& result_distance) +{ + // Abort if trajectories are empty + if (traj_first.empty() || traj_second.empty()) + return false; + + // Waypoint counter + size_t pos_first = 0; + size_t pos_second = 0; + const size_t max_pos_first = traj_first.getWayPointCount() - 1; + const size_t max_pos_second = traj_second.getWayPointCount() - 1; + + // Compute total distance between pairwise waypoints of both trajectories. + // The selection of waypoint pairs is based on what steps results in the minimal distance between the next pair of + // waypoints. We first check what steps are still possible or if we reached the end of the trajectories. Then we + // compute the pairwise waypoint distances of the pairs from increasing both, the first, or the second trajectory. + // Finally we select the pair that results in the minimal distance, summarize the total distance and iterate + // accordingly. After that we compute the average trajectory distance by normalizing over the number of steps. + double total_distance = 0; + size_t steps = 0; + double current_distance = traj_first.getWayPoint(pos_first).distance(traj_second.getWayPoint(pos_second)); + while (true) + { + // Keep track of total distance and number of comparisons + total_distance += current_distance; + ++steps; + if (pos_first == max_pos_first && pos_second == max_pos_second) // end reached + break; + + // Determine what steps are still possible + bool can_up_first = pos_first < max_pos_first; + bool can_up_second = pos_second < max_pos_second; + bool can_up_both = can_up_first && can_up_second; + + // Compute pair-wise waypoint distances (increasing both, first, or second trajectories). + double up_both = std::numeric_limits::max(); + double up_first = std::numeric_limits::max(); + double up_second = std::numeric_limits::max(); + if (can_up_both) + up_both = traj_first.getWayPoint(pos_first + 1).distance(traj_second.getWayPoint(pos_second + 1)); + if (can_up_first) + up_first = traj_first.getWayPoint(pos_first + 1).distance(traj_second.getWayPoint(pos_second)); + if (can_up_second) + up_second = traj_first.getWayPoint(pos_first).distance(traj_second.getWayPoint(pos_second + 1)); + + // Select actual step, store new distance value and iterate trajectory positions + if (can_up_both && up_both < up_first && up_both < up_second) + { + ++pos_first; + ++pos_second; + current_distance = up_both; + } + else if ((can_up_first && up_first < up_second) || !can_up_second) + { + ++pos_first; + current_distance = up_first; + } + else if (can_up_second) + { + ++pos_second; + current_distance = up_second; + } + } + // Normalize trajectory distance by number of comparison steps + result_distance = total_distance / static_cast(steps); + return true; +} + void BenchmarkExecutor::writeOutput(const BenchmarkRequest& brequest, const std::string& start_time, double benchmark_duration) { - const std::map>& planners = options_.getPlannerConfigurations(); + const std::map>& pipelines = options_.getPlanningPipelineConfigurations(); size_t num_planners = 0; - for (const std::pair>& planner : planners) - num_planners += planner.second.size(); + for (const std::pair>& pipeline : pipelines) + num_planners += pipeline.second.size(); std::string hostname = getHostname(); if (hostname.empty()) @@ -926,7 +1072,7 @@ void BenchmarkExecutor::writeOutput(const BenchmarkRequest& brequest, const std: return; } - out << "MoveIt! version " << MOVEIT_VERSION << std::endl; + out << "MoveIt version " << MOVEIT_VERSION << std::endl; out << "Experiment " << brequest.name << std::endl; out << "Running on " << hostname << std::endl; out << "Starting at " << start_time << std::endl; @@ -954,12 +1100,12 @@ void BenchmarkExecutor::writeOutput(const BenchmarkRequest& brequest, const std: out << num_planners << " planners" << std::endl; size_t run_id = 0; - for (const std::pair>& planner : planners) + for (const std::pair>& pipeline : pipelines) { - for (std::size_t i = 0; i < planner.second.size(); ++i, ++run_id) + for (std::size_t i = 0; i < pipeline.second.size(); ++i, ++run_id) { - // Write the name of the planner. - out << planner.second[i] << std::endl; + // Write the name of the planner and the used pipeline + out << pipeline.second[i] << " (" << pipeline.first << ")" << std::endl; // in general, we could have properties specific for a planner; // right now, we do not include such properties diff --git a/moveit_ros/benchmarks/src/BenchmarkOptions.cpp b/moveit_ros/benchmarks/src/BenchmarkOptions.cpp index 134d1d4017..96dd820afb 100644 --- a/moveit_ros/benchmarks/src/BenchmarkOptions.cpp +++ b/moveit_ros/benchmarks/src/BenchmarkOptions.cpp @@ -136,22 +136,32 @@ const std::string& BenchmarkOptions::getTrajectoryConstraintRegex() const return trajectory_constraint_regex_; } +const std::vector& BenchmarkOptions::getPredefinedPoses() const +{ + return predefined_poses_; +} + +const std::string& BenchmarkOptions::getPredefinedPosesGroup() const +{ + return predefined_poses_group_; +} + void BenchmarkOptions::getGoalOffsets(std::vector& offsets) const { offsets.resize(6); memcpy(&offsets[0], goal_offsets, 6 * sizeof(double)); } -const std::map>& BenchmarkOptions::getPlannerConfigurations() const +const std::map>& BenchmarkOptions::getPlanningPipelineConfigurations() const { - return planners_; + return planning_pipelines_; } -void BenchmarkOptions::getPlannerPluginList(std::vector& plugin_list) const +void BenchmarkOptions::getPlanningPipelineNames(std::vector& planning_pipeline_names) const { - plugin_list.clear(); - for (const std::pair>& planner : planners_) - plugin_list.push_back(planner.first); + planning_pipeline_names.clear(); + for (const std::pair>& planning_pipeline : planning_pipelines_) + planning_pipeline_names.push_back(planning_pipeline.first); } const std::string& BenchmarkOptions::getWorkspaceFrameID() const @@ -189,6 +199,8 @@ void BenchmarkOptions::readBenchmarkParameters(ros::NodeHandle& nh) nh.param(std::string("benchmark_config/parameters/path_constraints"), path_constraint_regex_, std::string("")); nh.param(std::string("benchmark_config/parameters/trajectory_constraints"), trajectory_constraint_regex_, std::string("")); + nh.param(std::string("benchmark_config/parameters/predefined_poses"), predefined_poses_, {}); + nh.param(std::string("benchmark_config/parameters/predefined_poses_group"), predefined_poses_group_, std::string("")); if (!nh.getParam(std::string("benchmark_config/parameters/group"), group_name_)) ROS_WARN("Benchmark group NOT specified"); @@ -237,48 +249,48 @@ void BenchmarkOptions::readWorkspaceParameters(ros::NodeHandle& nh) void BenchmarkOptions::readPlannerConfigs(ros::NodeHandle& nh) { - planners_.clear(); + planning_pipelines_.clear(); - XmlRpc::XmlRpcValue planner_configs; - if (nh.getParam("benchmark_config/planners", planner_configs)) + XmlRpc::XmlRpcValue pipeline_configs; + if (nh.getParam("benchmark_config/planning_pipelines", pipeline_configs)) { - if (planner_configs.getType() != XmlRpc::XmlRpcValue::TypeArray) + if (pipeline_configs.getType() != XmlRpc::XmlRpcValue::TypeArray) { - ROS_ERROR("Expected a list of planner configurations to benchmark"); + ROS_ERROR("Expected a list of planning pipeline configurations to benchmark"); return; } - for (int i = 0; i < planner_configs.size(); ++i) // NOLINT(modernize-loop-convert) + for (int i = 0; i < pipeline_configs.size(); ++i) // NOLINT(modernize-loop-convert) { - if (planner_configs[i].getType() != XmlRpc::XmlRpcValue::TypeStruct) + if (pipeline_configs[i].getType() != XmlRpc::XmlRpcValue::TypeStruct) { - ROS_WARN("Improper YAML type for planner configurations"); + ROS_WARN("Improper YAML type for planning pipeline configurations"); continue; } - if (!planner_configs[i].hasMember("plugin") || !planner_configs[i].hasMember("planners")) + if (!pipeline_configs[i].hasMember("name") || !pipeline_configs[i].hasMember("planners")) { ROS_WARN("Malformed YAML for planner configurations"); continue; } - if (planner_configs[i]["planners"].getType() != XmlRpc::XmlRpcValue::TypeArray) + if (pipeline_configs[i]["planners"].getType() != XmlRpc::XmlRpcValue::TypeArray) { ROS_WARN("Expected a list of planners to benchmark"); continue; } - const std::string plugin = planner_configs[i]["plugin"]; - ROS_INFO("Reading in planner names for plugin '%s'", plugin.c_str()); + const std::string pipeline_name = pipeline_configs[i]["name"]; + ROS_INFO("Reading in planner names for planning pipeline '%s'", pipeline_name.c_str()); std::vector planners; - planners.reserve(planner_configs[i]["planners"].size()); - for (int j = 0; j < planner_configs[i]["planners"].size(); ++j) - planners.emplace_back(planner_configs[i]["planners"][j]); + planners.reserve(pipeline_configs[i]["planners"].size()); + for (int j = 0; j < pipeline_configs[i]["planners"].size(); ++j) + planners.emplace_back(pipeline_configs[i]["planners"][j]); for (std::size_t j = 0; j < planners.size(); ++j) ROS_INFO(" [%lu]: %s", j, planners[j].c_str()); - planners_[plugin] = planners; + planning_pipelines_[pipeline_name] = planners; } } } diff --git a/moveit_ros/benchmarks/src/RunBenchmark.cpp b/moveit_ros/benchmarks/src/RunBenchmark.cpp index 14082cbcdc..19496e54e6 100644 --- a/moveit_ros/benchmarks/src/RunBenchmark.cpp +++ b/moveit_ros/benchmarks/src/RunBenchmark.cpp @@ -51,9 +51,9 @@ int main(int argc, char** argv) // Setup benchmark server moveit_ros_benchmarks::BenchmarkExecutor server; - std::vector plugins; - opts.getPlannerPluginList(plugins); - server.initialize(plugins); + std::vector planning_pipelines; + opts.getPlanningPipelineNames(planning_pipelines); + server.initialize(planning_pipelines); // Running benchmarks if (!server.runBenchmarks(opts)) diff --git a/moveit_ros/benchmarks/src/simple_benchmarks/CombinePredefinedPosesBenchmark.cpp b/moveit_ros/benchmarks/src/simple_benchmarks/CombinePredefinedPosesBenchmark.cpp new file mode 100644 index 0000000000..1bd9818579 --- /dev/null +++ b/moveit_ros/benchmarks/src/simple_benchmarks/CombinePredefinedPosesBenchmark.cpp @@ -0,0 +1,147 @@ +/********************************************************************* +* Software License Agreement (BSD License) +* +* Copyright (c) 2019, PickNik LLC +* 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 and/or other materials provided +* with the distribution. +* * Neither the name of the PickNik LLC nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* 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 OWNER 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. +*********************************************************************/ + +/* Author: Henning Kayser */ +/* Description: A simple benchmark that plans trajectories for all combinations of specified predefined poses */ + +// MoveIt Benchmark +#include +#include + +// MoveIt +#include +#include +#include + +namespace moveit_ros_benchmarks +{ +constexpr char LOGNAME[] = "combine_predefined_poses_benchmark"; +class CombinePredefinedPosesBenchmark : public BenchmarkExecutor +{ +public: + bool loadBenchmarkQueryData(const BenchmarkOptions& opts, moveit_msgs::PlanningScene& scene_msg, + std::vector& start_states, std::vector& path_constraints, + std::vector& goal_constraints, + std::vector& traj_constraints, + std::vector& queries) override + { + // Load planning scene + if (!psm_) + psm_.reset(new planning_scene_monitor::PlanningSceneMonitor("robot_description")); + if (!psm_->newPlanningSceneMessage(scene_msg)) + { + ROS_ERROR_NAMED(LOGNAME, "Failed to load planning scene"); + return false; + } + + // Load robot model + if (!psm_->getRobotModel()) + { + ROS_ERROR_NAMED(LOGNAME, "Failed to load robot model"); + return false; + } + + // Select planning group to use for predefined poses + std::string predefined_poses_group = opts.getPredefinedPosesGroup(); + if (predefined_poses_group.empty()) + { + ROS_WARN_NAMED(LOGNAME, "Parameter predefined_poses_group is not set, using default planning group instead"); + predefined_poses_group = opts.getGroupName(); + } + const auto& joint_model_group = psm_->getRobotModel()->getJointModelGroup(predefined_poses_group); + if (!joint_model_group) + { + ROS_ERROR_STREAM_NAMED(LOGNAME, "Robot model has no joint model group named '" << predefined_poses_group << "'"); + return false; + } + + // Iterate over all predefined poses and use each as start and goal states + moveit::core::RobotState robot_state(psm_->getRobotModel()); + start_states.clear(); + goal_constraints.clear(); + for (const auto& pose_id : opts.getPredefinedPoses()) + { + if (!robot_state.setToDefaultValues(joint_model_group, pose_id)) + { + ROS_WARN_STREAM_NAMED(LOGNAME, "Failed to set robot state to named target '" << pose_id << "'"); + continue; + } + // Create start state + start_states.emplace_back(); + start_states.back().name = pose_id; + moveit::core::robotStateToRobotStateMsg(robot_state, start_states.back().state); + + // Create goal constraints + goal_constraints.emplace_back(); + goal_constraints.back().name = pose_id; + goal_constraints.back().constraints.push_back( + kinematic_constraints::constructGoalConstraints(robot_state, joint_model_group)); + } + if (start_states.empty() || goal_constraints.empty()) + { + ROS_ERROR_NAMED(LOGNAME, "Failed to init start and goal states from predefined_poses"); + return false; + } + + // We don't use path/trajectory constraints or custom queries + path_constraints.clear(); + traj_constraints.clear(); + queries.clear(); + return true; + } + +private: + planning_scene_monitor::PlanningSceneMonitorPtr psm_; +}; +} // namespace moveit_ros_benchmarks + +int main(int argc, char** argv) +{ + ros::init(argc, argv, "moveit_run_benchmark"); + ros::AsyncSpinner spinner(1); + spinner.start(); + + // Read benchmark options from param server + moveit_ros_benchmarks::BenchmarkOptions opts(ros::this_node::getName()); + // Setup benchmark server + moveit_ros_benchmarks::CombinePredefinedPosesBenchmark server; + + std::vector planning_pipelines; + opts.getPlanningPipelineNames(planning_pipelines); + server.initialize(planning_pipelines); + + // Running benchmarks + if (!server.runBenchmarks(opts)) + ROS_ERROR("Failed to run all benchmarks"); +} diff --git a/moveit_ros/manipulation/CMakeLists.txt b/moveit_ros/manipulation/CMakeLists.txt index 13db73b68f..7173cbb2cc 100644 --- a/moveit_ros/manipulation/CMakeLists.txt +++ b/moveit_ros/manipulation/CMakeLists.txt @@ -1,7 +1,8 @@ -cmake_minimum_required(VERSION 2.8.12) +cmake_minimum_required(VERSION 3.1.3) project(moveit_ros_manipulation) -add_compile_options(-std=c++14) +set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_EXTENSIONS OFF) if(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Release) diff --git a/moveit_ros/manipulation/move_group_pick_place_capability/CMakeLists.txt b/moveit_ros/manipulation/move_group_pick_place_capability/CMakeLists.txt index 8cdfecab66..036197fc58 100644 --- a/moveit_ros/manipulation/move_group_pick_place_capability/CMakeLists.txt +++ b/moveit_ros/manipulation/move_group_pick_place_capability/CMakeLists.txt @@ -11,6 +11,7 @@ target_link_libraries(${MOVEIT_LIB_NAME} moveit_pick_place_planner ${catkin_LIBR install(TARGETS ${MOVEIT_LIB_NAME} ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} - LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}) + LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}) install(DIRECTORY include/ DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}) diff --git a/moveit_ros/manipulation/move_group_pick_place_capability/include/moveit/move_group_pick_place_capability/capability_names.h b/moveit_ros/manipulation/move_group_pick_place_capability/include/moveit/move_group_pick_place_capability/capability_names.h index 8058e204a4..95afa9e2b0 100644 --- a/moveit_ros/manipulation/move_group_pick_place_capability/include/moveit/move_group_pick_place_capability/capability_names.h +++ b/moveit_ros/manipulation/move_group_pick_place_capability/include/moveit/move_group_pick_place_capability/capability_names.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_MOVE_GROUP_PICK_PLACE_CAPABILITY_NAMES -#define MOVEIT_MOVE_GROUP_PICK_PLACE_CAPABILITY_NAMES +#pragma once #include @@ -44,5 +43,3 @@ namespace move_group static const std::string PICKUP_ACTION = "pickup"; // name of 'pickup' action static const std::string PLACE_ACTION = "place"; // name of 'place' action } - -#endif diff --git a/moveit_ros/manipulation/move_group_pick_place_capability/src/pick_place_action_capability.h b/moveit_ros/manipulation/move_group_pick_place_capability/src/pick_place_action_capability.h index d76e6244f2..3ba4abdb2f 100644 --- a/moveit_ros/manipulation/move_group_pick_place_capability/src/pick_place_action_capability.h +++ b/moveit_ros/manipulation/move_group_pick_place_capability/src/pick_place_action_capability.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_MOVE_GROUP_PICK_PLACE_ACTION_CAPABILITY_ -#define MOVEIT_MOVE_GROUP_PICK_PLACE_ACTION_CAPABILITY_ +#pragma once #include #include @@ -101,5 +100,3 @@ class MoveGroupPickPlaceAction : public MoveGroupCapability ros::ServiceClient grasp_planning_service_; }; } - -#endif diff --git a/moveit_ros/manipulation/package.xml b/moveit_ros/manipulation/package.xml index d8168e7329..6b1c82dddc 100644 --- a/moveit_ros/manipulation/package.xml +++ b/moveit_ros/manipulation/package.xml @@ -1,14 +1,14 @@ moveit_ros_manipulation 1.0.1 - Components of MoveIt! used for manipulation + Components of MoveIt used for manipulation Ioan Sucan Sachin Chitta Michael Görner Michael Ferguson - MoveIt! Release Team + MoveIt Release Team BSD diff --git a/moveit_ros/manipulation/pick_place/CMakeLists.txt b/moveit_ros/manipulation/pick_place/CMakeLists.txt index 4e41c8a4e5..fb371ae640 100644 --- a/moveit_ros/manipulation/pick_place/CMakeLists.txt +++ b/moveit_ros/manipulation/pick_place/CMakeLists.txt @@ -14,5 +14,8 @@ set_target_properties(${MOVEIT_LIB_NAME} PROPERTIES VERSION "${${PROJECT_NAME}_V target_link_libraries(${MOVEIT_LIB_NAME} ${catkin_LIBRARIES} ${Boost_LIBRARIES}) -install(TARGETS ${MOVEIT_LIB_NAME} LIBRARY DESTINATION ${CATKIN_GLOBAL_LIB_DESTINATION}) +install(TARGETS ${MOVEIT_LIB_NAME} + LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}) install(DIRECTORY include/ DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}) diff --git a/moveit_ros/manipulation/pick_place/include/moveit/pick_place/approach_and_translate_stage.h b/moveit_ros/manipulation/pick_place/include/moveit/pick_place/approach_and_translate_stage.h index 2709de5136..fc1737229c 100644 --- a/moveit_ros/manipulation/pick_place/include/moveit/pick_place/approach_and_translate_stage.h +++ b/moveit_ros/manipulation/pick_place/include/moveit/pick_place/approach_and_translate_stage.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan, Sachin Chitta */ -#ifndef MOVEIT_PICK_PLACE_APPROACH_AND_TRANSLATE_STAGE_ -#define MOVEIT_PICK_PLACE_APPROACH_AND_TRANSLATE_STAGE_ +#pragma once #include #include @@ -62,5 +61,3 @@ class ApproachAndTranslateStage : public ManipulationStage double jump_factor_; }; } - -#endif diff --git a/moveit_ros/manipulation/pick_place/include/moveit/pick_place/manipulation_pipeline.h b/moveit_ros/manipulation/pick_place/include/moveit/pick_place/manipulation_pipeline.h index f1bc6a920f..12b9dbf855 100644 --- a/moveit_ros/manipulation/pick_place/include/moveit/pick_place/manipulation_pipeline.h +++ b/moveit_ros/manipulation/pick_place/include/moveit/pick_place/manipulation_pipeline.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_PICK_PLACE_MANIPULATION_PIPELINE_ -#define MOVEIT_PICK_PLACE_MANIPULATION_PIPELINE_ +#pragma once #include #include @@ -117,5 +116,3 @@ class ManipulationPipeline bool stop_processing_; }; } - -#endif diff --git a/moveit_ros/manipulation/pick_place/include/moveit/pick_place/manipulation_plan.h b/moveit_ros/manipulation/pick_place/include/moveit/pick_place/manipulation_plan.h index cc3ff2fe74..a8415864cf 100644 --- a/moveit_ros/manipulation/pick_place/include/moveit/pick_place/manipulation_plan.h +++ b/moveit_ros/manipulation/pick_place/include/moveit/pick_place/manipulation_plan.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan, Sachin Chitta */ -#ifndef MOVEIT_PICK_PLACE_MANIPULATION_PLAN_ -#define MOVEIT_PICK_PLACE_MANIPULATION_PLAN_ +#pragma once #include #include @@ -143,5 +142,3 @@ struct ManipulationPlan std::size_t id_; }; } - -#endif diff --git a/moveit_ros/manipulation/pick_place/include/moveit/pick_place/manipulation_stage.h b/moveit_ros/manipulation/pick_place/include/moveit/pick_place/manipulation_stage.h index 5b36f9fb21..4b6e1f7b32 100644 --- a/moveit_ros/manipulation/pick_place/include/moveit/pick_place/manipulation_stage.h +++ b/moveit_ros/manipulation/pick_place/include/moveit/pick_place/manipulation_stage.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan, Sachin Chitta */ -#ifndef MOVEIT_PICK_PLACE_MANIPULATION_STAGE_ -#define MOVEIT_PICK_PLACE_MANIPULATION_STAGE_ +#pragma once #include #include @@ -84,5 +83,3 @@ class ManipulationStage bool verbose_; }; } - -#endif diff --git a/moveit_ros/manipulation/pick_place/include/moveit/pick_place/pick_place.h b/moveit_ros/manipulation/pick_place/include/moveit/pick_place/pick_place.h index 1507ebeaee..722dd3f79c 100644 --- a/moveit_ros/manipulation/pick_place/include/moveit/pick_place/pick_place.h +++ b/moveit_ros/manipulation/pick_place/include/moveit/pick_place/pick_place.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_PICK_PLACE_PICK_PLACE_ -#define MOVEIT_PICK_PLACE_PICK_PLACE_ +#pragma once #include #include @@ -165,5 +164,3 @@ class PickPlace : private boost::noncopyable, public std::enable_shared_from_thi constraint_sampler_manager_loader::ConstraintSamplerManagerLoaderPtr constraint_sampler_manager_loader_; }; } - -#endif diff --git a/moveit_ros/manipulation/pick_place/include/moveit/pick_place/pick_place_params.h b/moveit_ros/manipulation/pick_place/include/moveit/pick_place/pick_place_params.h index baabe4963d..08ae38837f 100644 --- a/moveit_ros/manipulation/pick_place/include/moveit/pick_place/pick_place_params.h +++ b/moveit_ros/manipulation/pick_place/include/moveit/pick_place/pick_place_params.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_PICK_PLACE_PICK_PLACE_PARAMS_ -#define MOVEIT_PICK_PLACE_PICK_PLACE_PARAMS_ +#pragma once namespace pick_place { @@ -52,5 +51,3 @@ struct PickPlaceParams // Get access to a global variable that contains the pick & place params. const PickPlaceParams& GetGlobalPickPlaceParams(); } - -#endif diff --git a/moveit_ros/manipulation/pick_place/include/moveit/pick_place/plan_stage.h b/moveit_ros/manipulation/pick_place/include/moveit/pick_place/plan_stage.h index 58a33e98d8..4810e44edf 100644 --- a/moveit_ros/manipulation/pick_place/include/moveit/pick_place/plan_stage.h +++ b/moveit_ros/manipulation/pick_place/include/moveit/pick_place/plan_stage.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan, Sachin Chitta */ -#ifndef MOVEIT_PICK_PLACE_PLAN_STAGE_ -#define MOVEIT_PICK_PLACE_PLAN_STAGE_ +#pragma once #include #include @@ -58,5 +57,3 @@ class PlanStage : public ManipulationStage planning_pipeline::PlanningPipelinePtr planning_pipeline_; }; } - -#endif diff --git a/moveit_ros/manipulation/pick_place/include/moveit/pick_place/reachable_valid_pose_filter.h b/moveit_ros/manipulation/pick_place/include/moveit/pick_place/reachable_valid_pose_filter.h index 7fe44f06bf..802c5dafe0 100644 --- a/moveit_ros/manipulation/pick_place/include/moveit/pick_place/reachable_valid_pose_filter.h +++ b/moveit_ros/manipulation/pick_place/include/moveit/pick_place/reachable_valid_pose_filter.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan, Sachin Chitta */ -#ifndef MOVEIT_PICK_PLACE_REACHABLE_VALID_POSE_FILTER_ -#define MOVEIT_PICK_PLACE_REACHABLE_VALID_POSE_FILTER_ +#pragma once #include #include @@ -60,5 +59,3 @@ class ReachableAndValidPoseFilter : public ManipulationStage constraint_samplers::ConstraintSamplerManagerPtr constraints_sampler_manager_; }; } - -#endif diff --git a/moveit_ros/manipulation/pick_place/src/pick.cpp b/moveit_ros/manipulation/pick_place/src/pick.cpp index 5b922a6589..f2e868ae79 100644 --- a/moveit_ros/manipulation/pick_place/src/pick.cpp +++ b/moveit_ros/manipulation/pick_place/src/pick.cpp @@ -38,6 +38,7 @@ #include #include #include +#include #include namespace pick_place @@ -230,7 +231,7 @@ PickPlanPtr PickPlace::planPick(const planning_scene::PlanningSceneConstPtr& pla { PickPlanPtr p(new PickPlan(shared_from_this())); - if (planning_scene::PlanningScene::isEmpty(goal.planning_options.planning_scene_diff)) + if (moveit::core::isEmpty(goal.planning_options.planning_scene_diff)) p->plan(planning_scene, goal); else p->plan(planning_scene->diff(goal.planning_options.planning_scene_diff), goal); diff --git a/moveit_ros/manipulation/pick_place/src/place.cpp b/moveit_ros/manipulation/pick_place/src/place.cpp index 098d5c1438..ae7e1f04cf 100644 --- a/moveit_ros/manipulation/pick_place/src/place.cpp +++ b/moveit_ros/manipulation/pick_place/src/place.cpp @@ -39,6 +39,7 @@ #include #include #include +#include #include #include @@ -369,7 +370,7 @@ PlacePlanPtr PickPlace::planPlace(const planning_scene::PlanningSceneConstPtr& p const moveit_msgs::PlaceGoal& goal) const { PlacePlanPtr p(new PlacePlan(shared_from_this())); - if (planning_scene::PlanningScene::isEmpty(goal.planning_options.planning_scene_diff)) + if (moveit::core::isEmpty(goal.planning_options.planning_scene_diff)) p->plan(planning_scene, goal); else p->plan(planning_scene->diff(goal.planning_options.planning_scene_diff), goal); diff --git a/moveit_ros/move_group/CMakeLists.txt b/moveit_ros/move_group/CMakeLists.txt index 71a0bf2759..783f29faa7 100644 --- a/moveit_ros/move_group/CMakeLists.txt +++ b/moveit_ros/move_group/CMakeLists.txt @@ -1,7 +1,8 @@ -cmake_minimum_required(VERSION 2.8.12) +cmake_minimum_required(VERSION 3.1.3) project(moveit_ros_move_group) -add_compile_options(-std=c++14) +set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_EXTENSIONS OFF) if(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Release) @@ -66,10 +67,13 @@ target_link_libraries(move_group moveit_move_group_capabilities_base ${catkin_LI target_link_libraries(moveit_move_group_default_capabilities moveit_move_group_capabilities_base ${catkin_LIBRARIES} ${Boost_LIBRARIES}) target_link_libraries(list_move_group_capabilities ${catkin_LIBRARIES} ${Boost_LIBRARIES}) -install(TARGETS move_group list_move_group_capabilities moveit_move_group_capabilities_base moveit_move_group_default_capabilities +install(TARGETS move_group list_move_group_capabilities + RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}) + +install(TARGETS moveit_move_group_capabilities_base moveit_move_group_default_capabilities ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} - RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}) + RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}) install(DIRECTORY include/ DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}) diff --git a/moveit_ros/move_group/include/moveit/move_group/capability_names.h b/moveit_ros/move_group/include/moveit/move_group/capability_names.h index 7b76ff727b..53f36e07a5 100644 --- a/moveit_ros/move_group/include/moveit/move_group/capability_names.h +++ b/moveit_ros/move_group/include/moveit/move_group/capability_names.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_MOVE_GROUP_DEFAULT_CAPABILITY_NAMES -#define MOVEIT_MOVE_GROUP_DEFAULT_CAPABILITY_NAMES +#pragma once #include @@ -64,5 +63,3 @@ static const std::string APPLY_PLANNING_SCENE_SERVICE_NAME = static const std::string CLEAR_OCTOMAP_SERVICE_NAME = "clear_octomap"; // name of the service that can be used to clear the octomap } - -#endif diff --git a/moveit_ros/move_group/include/moveit/move_group/move_group_capability.h b/moveit_ros/move_group/include/moveit/move_group/move_group_capability.h index e92735fe81..c34ef2363d 100644 --- a/moveit_ros/move_group/include/moveit/move_group/move_group_capability.h +++ b/moveit_ros/move_group/include/moveit/move_group/move_group_capability.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_MOVE_GROUP_CAPABILITY_ -#define MOVEIT_MOVE_GROUP_CAPABILITY_ +#pragma once #include #include @@ -99,5 +98,3 @@ class MoveGroupCapability MoveGroupContextPtr context_; }; } - -#endif diff --git a/moveit_ros/move_group/include/moveit/move_group/move_group_context.h b/moveit_ros/move_group/include/moveit/move_group/move_group_context.h index 845e155b3f..7808a6f3ea 100644 --- a/moveit_ros/move_group/include/moveit/move_group/move_group_context.h +++ b/moveit_ros/move_group/include/moveit/move_group/move_group_context.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_MOVE_GROUP_CONTEXT_ -#define MOVEIT_MOVE_GROUP_CONTEXT_ +#pragma once #include @@ -81,5 +80,3 @@ struct MoveGroupContext bool debug_; }; } - -#endif diff --git a/moveit_ros/move_group/include/moveit/move_group/node_name.h b/moveit_ros/move_group/include/moveit/move_group/node_name.h index 220dca0498..79d0ca4f16 100644 --- a/moveit_ros/move_group/include/moveit/move_group/node_name.h +++ b/moveit_ros/move_group/include/moveit/move_group/node_name.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_MOVE_GROUP_NODE_NAME -#define MOVEIT_MOVE_GROUP_NODE_NAME +#pragma once #include @@ -43,5 +42,3 @@ namespace move_group { static const std::string NODE_NAME = "move_group"; // name of node } - -#endif diff --git a/moveit_ros/move_group/package.xml b/moveit_ros/move_group/package.xml index ffed75a12d..9c1130b9f1 100644 --- a/moveit_ros/move_group/package.xml +++ b/moveit_ros/move_group/package.xml @@ -7,7 +7,7 @@ Michael Ferguson Michael Görner - MoveIt! Release Team + MoveIt Release Team BSD diff --git a/moveit_ros/move_group/src/default_capabilities/apply_planning_scene_service_capability.h b/moveit_ros/move_group/src/default_capabilities/apply_planning_scene_service_capability.h index 3bcd7aeec2..9970cc8fef 100644 --- a/moveit_ros/move_group/src/default_capabilities/apply_planning_scene_service_capability.h +++ b/moveit_ros/move_group/src/default_capabilities/apply_planning_scene_service_capability.h @@ -34,8 +34,7 @@ /* Author: Michael 'v4hn' Goerner */ -#ifndef MOVEIT_MOVE_GROUP_APPLY_PLANNING_SCENE_SERVICE_CAPABILITY_ -#define MOVEIT_MOVE_GROUP_APPLY_PLANNING_SCENE_SERVICE_CAPABILITY_ +#pragma once #include #include @@ -59,5 +58,3 @@ class ApplyPlanningSceneService : public MoveGroupCapability ros::ServiceServer service_; }; } - -#endif // MOVEIT_MOVE_GROUP_APPLY_PLANNING_SCENE_SERVICE_CAPABILITY_ diff --git a/moveit_ros/move_group/src/default_capabilities/cartesian_path_service_capability.cpp b/moveit_ros/move_group/src/default_capabilities/cartesian_path_service_capability.cpp index 15d5d29c60..a2f467b1d9 100644 --- a/moveit_ros/move_group/src/default_capabilities/cartesian_path_service_capability.cpp +++ b/moveit_ros/move_group/src/default_capabilities/cartesian_path_service_capability.cpp @@ -36,7 +36,7 @@ #include "cartesian_path_service_capability.h" #include -#include +#include #include #include #include @@ -131,7 +131,7 @@ bool MoveGroupCartesianPathService::computeService(moveit_msgs::GetCartesianPath robot_state::GroupStateValidityCallbackFn constraint_fn; std::unique_ptr ls; std::unique_ptr kset; - if (req.avoid_collisions || !kinematic_constraints::isEmpty(req.path_constraints)) + if (req.avoid_collisions || !moveit::core::isEmpty(req.path_constraints)) { ls.reset(new planning_scene_monitor::LockedPlanningSceneRO(context_->planning_scene_monitor_)); kset.reset(new kinematic_constraints::KinematicConstraintSet((*ls)->getRobotModel())); diff --git a/moveit_ros/move_group/src/default_capabilities/cartesian_path_service_capability.h b/moveit_ros/move_group/src/default_capabilities/cartesian_path_service_capability.h index cf1fbe9a47..e90efe670c 100644 --- a/moveit_ros/move_group/src/default_capabilities/cartesian_path_service_capability.h +++ b/moveit_ros/move_group/src/default_capabilities/cartesian_path_service_capability.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_MOVE_GROUP_CARTESIAN_PATH_SERVICE_CAPABILITY_ -#define MOVEIT_MOVE_GROUP_CARTESIAN_PATH_SERVICE_CAPABILITY_ +#pragma once #include #include @@ -57,5 +56,3 @@ class MoveGroupCartesianPathService : public MoveGroupCapability bool display_computed_paths_; }; } - -#endif diff --git a/moveit_ros/move_group/src/default_capabilities/clear_octomap_service_capability.h b/moveit_ros/move_group/src/default_capabilities/clear_octomap_service_capability.h index 401a31f8f6..2c5e68b542 100644 --- a/moveit_ros/move_group/src/default_capabilities/clear_octomap_service_capability.h +++ b/moveit_ros/move_group/src/default_capabilities/clear_octomap_service_capability.h @@ -34,8 +34,7 @@ /* Author: David Hershberger */ -#ifndef MOVEIT_MOVE_GROUP_CLEAR_OCTOMAP_SERVICE_CAPABILITY_ -#define MOVEIT_MOVE_GROUP_CLEAR_OCTOMAP_SERVICE_CAPABILITY_ +#pragma once #include #include @@ -55,5 +54,3 @@ class ClearOctomapService : public MoveGroupCapability ros::ServiceServer service_; }; } - -#endif // MOVEIT_MOVE_GROUP_CLEAR_OCTOMAP_SERVICE_CAPABILITY_ diff --git a/moveit_ros/move_group/src/default_capabilities/execute_trajectory_action_capability.h b/moveit_ros/move_group/src/default_capabilities/execute_trajectory_action_capability.h index c143b1e20b..f98965c8ba 100644 --- a/moveit_ros/move_group/src/default_capabilities/execute_trajectory_action_capability.h +++ b/moveit_ros/move_group/src/default_capabilities/execute_trajectory_action_capability.h @@ -38,8 +38,7 @@ * Author: Kentaro Wada * */ -#ifndef MOVEIT_MOVE_GROUP_EXECUTE_TRAJECTORY_ACTION_CAPABILITY_ -#define MOVEIT_MOVE_GROUP_EXECUTE_TRAJECTORY_ACTION_CAPABILITY_ +#pragma once #include #include @@ -66,5 +65,3 @@ class MoveGroupExecuteTrajectoryAction : public MoveGroupCapability }; } // namespace move_group - -#endif // MOVEIT_MOVE_GROUP_EXECUTE_TRAJECTORY_ACTION_CAPABILITY_ diff --git a/moveit_ros/move_group/src/default_capabilities/get_planning_scene_service_capability.h b/moveit_ros/move_group/src/default_capabilities/get_planning_scene_service_capability.h index 63fd7c35e7..c1cbfde2a7 100644 --- a/moveit_ros/move_group/src/default_capabilities/get_planning_scene_service_capability.h +++ b/moveit_ros/move_group/src/default_capabilities/get_planning_scene_service_capability.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_MOVE_GROUP_GET_PLANNING_SCENE_CAPABILITY_ -#define MOVEIT_MOVE_GROUP_GET_PLANNING_SCENE_CAPABILITY_ +#pragma once #include #include @@ -56,5 +55,3 @@ class MoveGroupGetPlanningSceneService : public MoveGroupCapability ros::ServiceServer get_scene_service_; }; } - -#endif diff --git a/moveit_ros/move_group/src/default_capabilities/kinematics_service_capability.cpp b/moveit_ros/move_group/src/default_capabilities/kinematics_service_capability.cpp index 73e3932e18..b1e86fa6b4 100644 --- a/moveit_ros/move_group/src/default_capabilities/kinematics_service_capability.cpp +++ b/moveit_ros/move_group/src/default_capabilities/kinematics_service_capability.cpp @@ -36,7 +36,7 @@ #include "kinematics_service_capability.h" #include -#include +#include #include #include @@ -148,7 +148,7 @@ bool MoveGroupKinematicsService::computeIKService(moveit_msgs::GetPositionIK::Re context_->planning_scene_monitor_->updateFrameTransforms(); // check if the planning scene needs to be kept locked; if so, call computeIK() in the scope of the lock - if (req.ik_request.avoid_collisions || !kinematic_constraints::isEmpty(req.ik_request.constraints)) + if (req.ik_request.avoid_collisions || !moveit::core::isEmpty(req.ik_request.constraints)) { planning_scene_monitor::LockedPlanningSceneRO ls(context_->planning_scene_monitor_); kinematic_constraints::KinematicConstraintSet kset(ls->getRobotModel()); diff --git a/moveit_ros/move_group/src/default_capabilities/kinematics_service_capability.h b/moveit_ros/move_group/src/default_capabilities/kinematics_service_capability.h index d1f10a96a5..30e300ef47 100644 --- a/moveit_ros/move_group/src/default_capabilities/kinematics_service_capability.h +++ b/moveit_ros/move_group/src/default_capabilities/kinematics_service_capability.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_MOVE_GROUP_KINEMATICS_SERVICE_CAPABILITY_ -#define MOVEIT_MOVE_GROUP_KINEMATICS_SERVICE_CAPABILITY_ +#pragma once #include #include @@ -63,5 +62,3 @@ class MoveGroupKinematicsService : public MoveGroupCapability ros::ServiceServer ik_service_; }; } - -#endif diff --git a/moveit_ros/move_group/src/default_capabilities/move_action_capability.cpp b/moveit_ros/move_group/src/default_capabilities/move_action_capability.cpp index cc6c36557a..26c619b7d8 100644 --- a/moveit_ros/move_group/src/default_capabilities/move_action_capability.cpp +++ b/moveit_ros/move_group/src/default_capabilities/move_action_capability.cpp @@ -41,6 +41,7 @@ #include #include #include +#include #include namespace move_group @@ -102,7 +103,7 @@ void MoveGroupMoveAction::executeMoveCallbackPlanAndExecute(const moveit_msgs::M ROS_INFO_NAMED(getName(), "Combined planning and execution request received for MoveGroup action. " "Forwarding to planning and execution pipeline."); - if (planning_scene::PlanningScene::isEmpty(goal->planning_options.planning_scene_diff)) + if (moveit::core::isEmpty(goal->planning_options.planning_scene_diff)) { planning_scene_monitor::LockedPlanningSceneRO lscene(context_->planning_scene_monitor_); const robot_state::RobotState& current_state = lscene->getCurrentState(); @@ -122,10 +123,9 @@ void MoveGroupMoveAction::executeMoveCallbackPlanAndExecute(const moveit_msgs::M plan_execution::PlanExecution::Options opt; const moveit_msgs::MotionPlanRequest& motion_plan_request = - planning_scene::PlanningScene::isEmpty(goal->request.start_state) ? goal->request : - clearRequestStartState(goal->request); + moveit::core::isEmpty(goal->request.start_state) ? goal->request : clearRequestStartState(goal->request); const moveit_msgs::PlanningScene& planning_scene_diff = - planning_scene::PlanningScene::isEmpty(goal->planning_options.planning_scene_diff.robot_state) ? + moveit::core::isEmpty(goal->planning_options.planning_scene_diff.robot_state) ? goal->planning_options.planning_scene_diff : clearSceneRobotState(goal->planning_options.planning_scene_diff); @@ -168,7 +168,7 @@ void MoveGroupMoveAction::executeMoveCallbackPlanOnly(const moveit_msgs::MoveGro // lock the scene so that it does not modify the world representation while diff() is called planning_scene_monitor::LockedPlanningSceneRO lscene(context_->planning_scene_monitor_); const planning_scene::PlanningSceneConstPtr& the_scene = - (planning_scene::PlanningScene::isEmpty(goal->planning_options.planning_scene_diff)) ? + (moveit::core::isEmpty(goal->planning_options.planning_scene_diff)) ? static_cast(lscene) : lscene->diff(goal->planning_options.planning_scene_diff); planning_interface::MotionPlanResponse res; diff --git a/moveit_ros/move_group/src/default_capabilities/move_action_capability.h b/moveit_ros/move_group/src/default_capabilities/move_action_capability.h index d8af647a38..56917e6a67 100644 --- a/moveit_ros/move_group/src/default_capabilities/move_action_capability.h +++ b/moveit_ros/move_group/src/default_capabilities/move_action_capability.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_MOVE_GROUP_MOVE_ACTION_CAPABILITY_ -#define MOVEIT_MOVE_GROUP_MOVE_ACTION_CAPABILITY_ +#pragma once #include #include @@ -71,5 +70,3 @@ class MoveGroupMoveAction : public MoveGroupCapability bool preempt_requested_; }; } - -#endif diff --git a/moveit_ros/move_group/src/default_capabilities/plan_service_capability.h b/moveit_ros/move_group/src/default_capabilities/plan_service_capability.h index b3d7a94250..6ca33b6791 100644 --- a/moveit_ros/move_group/src/default_capabilities/plan_service_capability.h +++ b/moveit_ros/move_group/src/default_capabilities/plan_service_capability.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_MOVE_GROUP_PLAN_SERVICE_CAPABILITY_ -#define MOVEIT_MOVE_GROUP_PLAN_SERVICE_CAPABILITY_ +#pragma once #include #include @@ -55,5 +54,3 @@ class MoveGroupPlanService : public MoveGroupCapability ros::ServiceServer plan_service_; }; } - -#endif diff --git a/moveit_ros/move_group/src/default_capabilities/query_planners_service_capability.h b/moveit_ros/move_group/src/default_capabilities/query_planners_service_capability.h index 656c228a08..5d3a8b632f 100644 --- a/moveit_ros/move_group/src/default_capabilities/query_planners_service_capability.h +++ b/moveit_ros/move_group/src/default_capabilities/query_planners_service_capability.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan, Robert Haschke */ -#ifndef MOVEIT_MOVE_GROUP_QUERY_PLANNERS_SERVICE_CAPABILITY_ -#define MOVEIT_MOVE_GROUP_QUERY_PLANNERS_SERVICE_CAPABILITY_ +#pragma once #include #include @@ -63,5 +62,3 @@ class MoveGroupQueryPlannersService : public MoveGroupCapability ros::ServiceServer set_service_; }; } - -#endif diff --git a/moveit_ros/move_group/src/default_capabilities/state_validation_service_capability.cpp b/moveit_ros/move_group/src/default_capabilities/state_validation_service_capability.cpp index 16e6714665..c333f4a9a7 100644 --- a/moveit_ros/move_group/src/default_capabilities/state_validation_service_capability.cpp +++ b/moveit_ros/move_group/src/default_capabilities/state_validation_service_capability.cpp @@ -36,7 +36,7 @@ #include "state_validation_service_capability.h" #include -#include +#include #include #include @@ -100,7 +100,7 @@ bool MoveGroupStateValidationService::computeService(moveit_msgs::GetStateValidi } // evaluate constraints - if (!kinematic_constraints::isEmpty(req.constraints)) + if (!moveit::core::isEmpty(req.constraints)) { kinematic_constraints::KinematicConstraintSet kset(ls->getRobotModel()); kset.add(req.constraints, ls->getTransforms()); diff --git a/moveit_ros/move_group/src/default_capabilities/state_validation_service_capability.h b/moveit_ros/move_group/src/default_capabilities/state_validation_service_capability.h index 2806a9586c..86dc6c8d52 100644 --- a/moveit_ros/move_group/src/default_capabilities/state_validation_service_capability.h +++ b/moveit_ros/move_group/src/default_capabilities/state_validation_service_capability.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_MOVE_GROUP_STATE_VALIDATION_SERVICE_CAPABILITY_ -#define MOVEIT_MOVE_GROUP_STATE_VALIDATION_SERVICE_CAPABILITY_ +#pragma once #include #include @@ -55,5 +54,3 @@ class MoveGroupStateValidationService : public MoveGroupCapability ros::ServiceServer validity_service_; }; } - -#endif diff --git a/moveit_ros/move_group/test/test_cancel_before_plan_execution.test b/moveit_ros/move_group/test/test_cancel_before_plan_execution.test index 51977ca919..edf4699d93 100644 --- a/moveit_ros/move_group/test/test_cancel_before_plan_execution.test +++ b/moveit_ros/move_group/test/test_cancel_before_plan_execution.test @@ -13,7 +13,7 @@ - + diff --git a/moveit_ros/moveit_ros/CHANGELOG.rst b/moveit_ros/moveit_ros/CHANGELOG.rst index d3a8959214..be0815f44c 100644 --- a/moveit_ros/moveit_ros/CHANGELOG.rst +++ b/moveit_ros/moveit_ros/CHANGELOG.rst @@ -30,7 +30,7 @@ Changelog for package moveit_ros 0.10.2 (2018-10-24) ------------------- -* Fix references to MoveIt! (`#1020 `_) +* Fix references to MoveIt (`#1020 `_) * Contributors: Mohmmad Ayman 0.10.1 (2018-05-25) diff --git a/moveit_ros/moveit_ros/package.xml b/moveit_ros/moveit_ros/package.xml index a64adef04d..60671d1f8f 100644 --- a/moveit_ros/moveit_ros/package.xml +++ b/moveit_ros/moveit_ros/package.xml @@ -1,7 +1,7 @@ moveit_ros 1.0.1 - Components of MoveIt! that use ROS + Components of MoveIt that use ROS Ioan Sucan Sachin Chitta Acorn Pooley @@ -9,7 +9,7 @@ Michael Ferguson Michael Görner Dave Coleman - MoveIt! Release Team + MoveIt Release Team BSD diff --git a/moveit_ros/occupancy_map_monitor/CMakeLists.txt b/moveit_ros/occupancy_map_monitor/CMakeLists.txt index 218148cca1..bdb0bae0f1 100644 --- a/moveit_ros/occupancy_map_monitor/CMakeLists.txt +++ b/moveit_ros/occupancy_map_monitor/CMakeLists.txt @@ -1,8 +1,9 @@ -cmake_minimum_required(VERSION 2.8.12) +cmake_minimum_required(VERSION 3.1.3) project(moveit_ros_occupancy_map_monitor) set(MOVEIT_LIB_NAME ${PROJECT_NAME}) -add_compile_options(-std=c++14) +set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_EXTENSIONS OFF) if(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Release) @@ -55,8 +56,13 @@ target_link_libraries(${MOVEIT_LIB_NAME} ${catkin_LIBRARIES} ${Boost_LIBRARIES}) add_executable(moveit_ros_occupancy_map_server src/occupancy_map_server.cpp) target_link_libraries(moveit_ros_occupancy_map_server ${MOVEIT_LIB_NAME} ${catkin_LIBRARIES} ${Boost_LIBRARIES}) -install(TARGETS ${MOVEIT_LIB_NAME} moveit_ros_occupancy_map_server - LIBRARY DESTINATION ${CATKIN_GLOBAL_LIB_DESTINATION} +install(TARGETS ${MOVEIT_LIB_NAME} + LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION} +) + +install(TARGETS moveit_ros_occupancy_map_server RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} ) install(DIRECTORY include/ DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}) diff --git a/moveit_ros/occupancy_map_monitor/include/moveit/occupancy_map_monitor/occupancy_map.h b/moveit_ros/occupancy_map_monitor/include/moveit/occupancy_map_monitor/occupancy_map.h index e1cff913dd..ee98f95de5 100644 --- a/moveit_ros/occupancy_map_monitor/include/moveit/occupancy_map_monitor/occupancy_map.h +++ b/moveit_ros/occupancy_map_monitor/include/moveit/occupancy_map_monitor/occupancy_map.h @@ -34,10 +34,10 @@ /* Author: Ioan Sucan, Jon Binney */ -#ifndef MOVEIT_OCCUPANCY_MAP_MONITOR_OCCUPANCY_MAP_ -#define MOVEIT_OCCUPANCY_MAP_MONITOR_OCCUPANCY_MAP_ +#pragma once #include +#include #include #include #include @@ -116,5 +116,3 @@ class OccMapTree : public octomap::OcTree typedef std::shared_ptr OccMapTreePtr; typedef std::shared_ptr OccMapTreeConstPtr; } - -#endif diff --git a/moveit_ros/occupancy_map_monitor/include/moveit/occupancy_map_monitor/occupancy_map_monitor.h b/moveit_ros/occupancy_map_monitor/include/moveit/occupancy_map_monitor/occupancy_map_monitor.h index 1558c434ae..ece0658606 100644 --- a/moveit_ros/occupancy_map_monitor/include/moveit/occupancy_map_monitor/occupancy_map_monitor.h +++ b/moveit_ros/occupancy_map_monitor/include/moveit/occupancy_map_monitor/occupancy_map_monitor.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan, Jon Binney */ -#ifndef MOVEIT_PERCEPTION_OCCUPANCY_MAP_MONITOR_ -#define MOVEIT_PERCEPTION_OCCUPANCY_MAP_MONITOR_ +#pragma once #include #include @@ -160,5 +159,3 @@ class OccupancyMapMonitor bool active_; }; } - -#endif diff --git a/moveit_ros/occupancy_map_monitor/include/moveit/occupancy_map_monitor/occupancy_map_updater.h b/moveit_ros/occupancy_map_monitor/include/moveit/occupancy_map_monitor/occupancy_map_updater.h index cd91709567..07c2a0b0c8 100644 --- a/moveit_ros/occupancy_map_monitor/include/moveit/occupancy_map_monitor/occupancy_map_updater.h +++ b/moveit_ros/occupancy_map_monitor/include/moveit/occupancy_map_monitor/occupancy_map_updater.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan, Jon Binney */ -#ifndef MOVEIT_OCCUPANCY_MAP_MONITOR_OCCUPANCY_MAP_UPDATER_ -#define MOVEIT_OCCUPANCY_MAP_MONITOR_OCCUPANCY_MAP_UPDATER_ +#pragma once #include #include @@ -112,5 +111,3 @@ class OccupancyMapUpdater static void readXmlParam(XmlRpc::XmlRpcValue& params, const std::string& param_name, unsigned int* value); }; } - -#endif diff --git a/moveit_ros/occupancy_map_monitor/package.xml b/moveit_ros/occupancy_map_monitor/package.xml index 8c1e95689d..28c302748d 100644 --- a/moveit_ros/occupancy_map_monitor/package.xml +++ b/moveit_ros/occupancy_map_monitor/package.xml @@ -2,14 +2,14 @@ moveit_ros_occupancy_map_monitor 1.0.1 - Components of MoveIt! connecting to occupancy map + Components of MoveIt connecting to occupancy map Ioan Sucan Jon Binney Suat Gedikli Michael Ferguson - MoveIt! Release Team + MoveIt Release Team BSD diff --git a/moveit_ros/occupancy_map_monitor/src/occupancy_map_monitor.cpp b/moveit_ros/occupancy_map_monitor/src/occupancy_map_monitor.cpp index b2200d936c..284f429bb7 100644 --- a/moveit_ros/occupancy_map_monitor/src/occupancy_map_monitor.cpp +++ b/moveit_ros/occupancy_map_monitor/src/occupancy_map_monitor.cpp @@ -330,6 +330,9 @@ bool OccupancyMapMonitor::loadMapCallback(moveit_msgs::LoadMap::Request& request } tree_->unlockWrite(); + if (response.success) + tree_->triggerUpdateCallback(); + return true; } diff --git a/moveit_ros/perception/CMakeLists.txt b/moveit_ros/perception/CMakeLists.txt index 894fa3d28b..9e203bf937 100644 --- a/moveit_ros/perception/CMakeLists.txt +++ b/moveit_ros/perception/CMakeLists.txt @@ -1,7 +1,8 @@ -cmake_minimum_required(VERSION 2.8.12) +cmake_minimum_required(VERSION 3.1.3) project(moveit_ros_perception) -add_compile_options(-std=c++14) +set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_EXTENSIONS OFF) option(WITH_OPENGL "Build the parts that depend on OpenGL" ON) diff --git a/moveit_ros/perception/depth_image_octomap_updater/CMakeLists.txt b/moveit_ros/perception/depth_image_octomap_updater/CMakeLists.txt index 81485c633d..4222cd346a 100644 --- a/moveit_ros/perception/depth_image_octomap_updater/CMakeLists.txt +++ b/moveit_ros/perception/depth_image_octomap_updater/CMakeLists.txt @@ -10,5 +10,8 @@ add_library(${MOVEIT_LIB_NAME} src/updater_plugin.cpp) set_target_properties(${MOVEIT_LIB_NAME} PROPERTIES VERSION "${${PROJECT_NAME}_VERSION}") target_link_libraries(${MOVEIT_LIB_NAME} ${MOVEIT_LIB_NAME}_core ${catkin_LIBRARIES} ${Boost_LIBRARIES}) -install(TARGETS ${MOVEIT_LIB_NAME}_core ${MOVEIT_LIB_NAME} LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}) +install(TARGETS ${MOVEIT_LIB_NAME}_core ${MOVEIT_LIB_NAME} + LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}) install(DIRECTORY include/ DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}) diff --git a/moveit_ros/perception/depth_image_octomap_updater/include/moveit/depth_image_octomap_updater/depth_image_octomap_updater.h b/moveit_ros/perception/depth_image_octomap_updater/include/moveit/depth_image_octomap_updater/depth_image_octomap_updater.h index d223e8d4b4..199c79204d 100644 --- a/moveit_ros/perception/depth_image_octomap_updater/include/moveit/depth_image_octomap_updater/depth_image_octomap_updater.h +++ b/moveit_ros/perception/depth_image_octomap_updater/include/moveit/depth_image_octomap_updater/depth_image_octomap_updater.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_OCCUPANCY_MAP_DEPTH_IMAGE_OCCUPANCY_MAP_UPDATER_ -#define MOVEIT_OCCUPANCY_MAP_DEPTH_IMAGE_OCCUPANCY_MAP_UPDATER_ +#pragma once #include #include @@ -107,5 +106,3 @@ class DepthImageOctomapUpdater : public OccupancyMapUpdater ros::WallTime last_depth_callback_start_; }; } - -#endif diff --git a/moveit_ros/perception/depth_image_octomap_updater/src/depth_image_octomap_updater.cpp b/moveit_ros/perception/depth_image_octomap_updater/src/depth_image_octomap_updater.cpp index 4a33d7c40a..9d1840a118 100644 --- a/moveit_ros/perception/depth_image_octomap_updater/src/depth_image_octomap_updater.cpp +++ b/moveit_ros/perception/depth_image_octomap_updater/src/depth_image_octomap_updater.cpp @@ -394,33 +394,32 @@ void DepthImageOctomapUpdater::depthImageCallback(const sensor_msgs::ImageConstP { sensor_msgs::Image debug_msg; debug_msg.header = depth_msg->header; - debug_msg.height = depth_msg->height; - debug_msg.width = depth_msg->width; + debug_msg.height = h; + debug_msg.width = w; + debug_msg.is_bigendian = HOST_IS_BIG_ENDIAN; debug_msg.encoding = sensor_msgs::image_encodings::TYPE_32FC1; - debug_msg.is_bigendian = depth_msg->is_bigendian; - debug_msg.step = depth_msg->step; + debug_msg.step = w * sizeof(float); debug_msg.data.resize(img_size * sizeof(float)); mesh_filter_->getModelDepth(reinterpret_cast(&debug_msg.data[0])); pub_model_depth_image_.publish(debug_msg, *info_msg); sensor_msgs::Image filtered_depth_msg; filtered_depth_msg.header = depth_msg->header; - filtered_depth_msg.height = depth_msg->height; - filtered_depth_msg.width = depth_msg->width; + filtered_depth_msg.height = h; + filtered_depth_msg.width = w; + filtered_depth_msg.is_bigendian = HOST_IS_BIG_ENDIAN; filtered_depth_msg.encoding = sensor_msgs::image_encodings::TYPE_32FC1; - filtered_depth_msg.is_bigendian = depth_msg->is_bigendian; - filtered_depth_msg.step = depth_msg->step; + filtered_depth_msg.step = w * sizeof(float); filtered_depth_msg.data.resize(img_size * sizeof(float)); - mesh_filter_->getFilteredDepth(reinterpret_cast(&filtered_depth_msg.data[0])); pub_filtered_depth_image_.publish(filtered_depth_msg, *info_msg); sensor_msgs::Image label_msg; label_msg.header = depth_msg->header; - label_msg.height = depth_msg->height; - label_msg.width = depth_msg->width; + label_msg.height = h; + label_msg.width = w; + label_msg.is_bigendian = HOST_IS_BIG_ENDIAN; label_msg.encoding = sensor_msgs::image_encodings::RGBA8; - label_msg.is_bigendian = depth_msg->is_bigendian; label_msg.step = w * sizeof(unsigned int); label_msg.data.resize(img_size * sizeof(unsigned int)); mesh_filter_->getFilteredLabels(reinterpret_cast(&label_msg.data[0])); @@ -430,22 +429,26 @@ void DepthImageOctomapUpdater::depthImageCallback(const sensor_msgs::ImageConstP if (!filtered_cloud_topic_.empty()) { - static std::vector filtered_data; sensor_msgs::Image filtered_msg; filtered_msg.header = depth_msg->header; - filtered_msg.height = depth_msg->height; - filtered_msg.width = depth_msg->width; + filtered_msg.height = h; + filtered_msg.width = w; + filtered_msg.is_bigendian = HOST_IS_BIG_ENDIAN; filtered_msg.encoding = sensor_msgs::image_encodings::TYPE_16UC1; - filtered_msg.is_bigendian = depth_msg->is_bigendian; - filtered_msg.step = depth_msg->step; + filtered_msg.step = w * sizeof(unsigned short); filtered_msg.data.resize(img_size * sizeof(unsigned short)); + + // reuse float buffer across callbacks + static std::vector filtered_data; if (filtered_data.size() < img_size) filtered_data.resize(img_size); + mesh_filter_->getFilteredDepth(reinterpret_cast(&filtered_data[0])); - unsigned short* tmp_ptr = (unsigned short*)&filtered_msg.data[0]; + unsigned short* msg_data = reinterpret_cast(&filtered_msg.data[0]); for (std::size_t i = 0; i < img_size; ++i) { - tmp_ptr[i] = (unsigned short)(filtered_data[i] * 1000 + 0.5); + // rescale depth to millimeter to work with `unsigned short` + msg_data[i] = static_cast(filtered_data[i] * 1000 + 0.5); } pub_filtered_depth_image_.publish(filtered_msg, *info_msg); } diff --git a/moveit_ros/perception/lazy_free_space_updater/CMakeLists.txt b/moveit_ros/perception/lazy_free_space_updater/CMakeLists.txt index ce935b1f36..e9092875c1 100644 --- a/moveit_ros/perception/lazy_free_space_updater/CMakeLists.txt +++ b/moveit_ros/perception/lazy_free_space_updater/CMakeLists.txt @@ -8,5 +8,8 @@ target_link_libraries(${MOVEIT_LIB_NAME} ${catkin_LIBRARIES} ${Boost_LIBRARIES}) add_dependencies(${MOVEIT_LIB_NAME} ${sensor_msgs_EXPORTED_TARGETS}) -install(TARGETS ${MOVEIT_LIB_NAME} LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}) +install(TARGETS ${MOVEIT_LIB_NAME} + LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}) install(DIRECTORY include/ DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}) diff --git a/moveit_ros/perception/lazy_free_space_updater/include/moveit/lazy_free_space_updater/lazy_free_space_updater.h b/moveit_ros/perception/lazy_free_space_updater/include/moveit/lazy_free_space_updater/lazy_free_space_updater.h index cad8b0a48c..270ad565f1 100644 --- a/moveit_ros/perception/lazy_free_space_updater/include/moveit/lazy_free_space_updater/lazy_free_space_updater.h +++ b/moveit_ros/perception/lazy_free_space_updater/include/moveit/lazy_free_space_updater/lazy_free_space_updater.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_OCCUPANCY_MAP_MONITOR_LAZY_FREE_SPACE_UPDATER_ -#define MOVEIT_OCCUPANCY_MAP_MONITOR_LAZY_FREE_SPACE_UPDATER_ +#pragma once #include #include @@ -89,5 +88,3 @@ class LazyFreeSpaceUpdater boost::thread process_thread_; }; } - -#endif /* MOVEIT_OCCUPANCY_MAP_UPDATER_H_ */ diff --git a/moveit_ros/perception/mesh_filter/CMakeLists.txt b/moveit_ros/perception/mesh_filter/CMakeLists.txt index 940772f8da..f08902a474 100644 --- a/moveit_ros/perception/mesh_filter/CMakeLists.txt +++ b/moveit_ros/perception/mesh_filter/CMakeLists.txt @@ -22,5 +22,8 @@ if (CATKIN_ENABLE_TESTING) endif() endif() -install(TARGETS ${MOVEIT_LIB_NAME} LIBRARY DESTINATION ${CATKIN_GLOBAL_LIB_DESTINATION}) +install(TARGETS ${MOVEIT_LIB_NAME} + LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}) install(DIRECTORY include/ DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}) diff --git a/moveit_ros/perception/mesh_filter/include/moveit/mesh_filter/depth_self_filter_nodelet.h b/moveit_ros/perception/mesh_filter/include/moveit/mesh_filter/depth_self_filter_nodelet.h index 6ab4d6ab37..323bc03326 100644 --- a/moveit_ros/perception/mesh_filter/include/moveit/mesh_filter/depth_self_filter_nodelet.h +++ b/moveit_ros/perception/mesh_filter/include/moveit/mesh_filter/depth_self_filter_nodelet.h @@ -34,8 +34,7 @@ /* Author: Suat Gedikli */ -#ifndef MOVEIT_DEPTH_SELF_FILTER_NODELET_ -#define MOVEIT_DEPTH_SELF_FILTER_NODELET_ +#pragma once #include #include @@ -132,5 +131,3 @@ class DepthSelfFiltering : public nodelet::Nodelet }; } // namespace mesh_filter - -#endif diff --git a/moveit_ros/perception/mesh_filter/include/moveit/mesh_filter/filter_job.h b/moveit_ros/perception/mesh_filter/include/moveit/mesh_filter/filter_job.h index a1f098f244..a817245040 100644 --- a/moveit_ros/perception/mesh_filter/include/moveit/mesh_filter/filter_job.h +++ b/moveit_ros/perception/mesh_filter/include/moveit/mesh_filter/filter_job.h @@ -34,8 +34,7 @@ /* Author: Suat Gedikli */ -#ifndef MOVEIT_MESH_FILTER_FILTER_JOB_ -#define MOVEIT_MESH_FILTER_FILTER_JOB_ +#pragma once #include #include @@ -142,4 +141,3 @@ class FilterJob : public Job boost::function exec_; }; } -#endif diff --git a/moveit_ros/perception/mesh_filter/include/moveit/mesh_filter/gl_mesh.h b/moveit_ros/perception/mesh_filter/include/moveit/mesh_filter/gl_mesh.h index 2ba940d7f7..a605425870 100644 --- a/moveit_ros/perception/mesh_filter/include/moveit/mesh_filter/gl_mesh.h +++ b/moveit_ros/perception/mesh_filter/include/moveit/mesh_filter/gl_mesh.h @@ -34,8 +34,7 @@ /* Author: Suat Gedikli */ -#ifndef MOVEIT_MESH_FILTER_GLMESH_ -#define MOVEIT_MESH_FILTER_GLMESH_ +#pragma once #include #include @@ -85,4 +84,3 @@ class GLMesh unsigned int mesh_label_; }; } // namespace mesh_filter -#endif diff --git a/moveit_ros/perception/mesh_filter/include/moveit/mesh_filter/gl_renderer.h b/moveit_ros/perception/mesh_filter/include/moveit/mesh_filter/gl_renderer.h index 67fa5abb1b..8ae3ee9f55 100644 --- a/moveit_ros/perception/mesh_filter/include/moveit/mesh_filter/gl_renderer.h +++ b/moveit_ros/perception/mesh_filter/include/moveit/mesh_filter/gl_renderer.h @@ -34,8 +34,7 @@ /* Author: Suat Gedikli */ -#ifndef MOVEIT_MESH_FILTER_GLRENDERER_ -#define MOVEIT_MESH_FILTER_GLRENDERER_ +#pragma once #include #include @@ -303,4 +302,3 @@ class GLRenderer static bool glutInitialized_; }; } // namespace mesh_filter -#endif diff --git a/moveit_ros/perception/mesh_filter/include/moveit/mesh_filter/mesh_filter.h b/moveit_ros/perception/mesh_filter/include/moveit/mesh_filter/mesh_filter.h index e488aa2883..ed27f7b136 100644 --- a/moveit_ros/perception/mesh_filter/include/moveit/mesh_filter/mesh_filter.h +++ b/moveit_ros/perception/mesh_filter/include/moveit/mesh_filter/mesh_filter.h @@ -34,8 +34,7 @@ /* Author: Suat Gedikli */ -#ifndef MOVEIT_MESH_FILTER_MESHFILTER_ -#define MOVEIT_MESH_FILTER_MESHFILTER_ +#pragma once #include #include @@ -112,4 +111,3 @@ const typename SensorType::Parameters& MeshFilter::parameters() cons } } // namespace mesh_filter -#endif diff --git a/moveit_ros/perception/mesh_filter/include/moveit/mesh_filter/mesh_filter_base.h b/moveit_ros/perception/mesh_filter/include/moveit/mesh_filter/mesh_filter_base.h index 86f85270e0..dc8ee5f3f2 100644 --- a/moveit_ros/perception/mesh_filter/include/moveit/mesh_filter/mesh_filter_base.h +++ b/moveit_ros/perception/mesh_filter/include/moveit/mesh_filter/mesh_filter_base.h @@ -34,8 +34,7 @@ /* Author: Suat Gedikli */ -#ifndef MOVEIT_MESH_FILTER_MESH_FILTER_BASE_ -#define MOVEIT_MESH_FILTER_MESH_FILTER_BASE_ +#pragma once #include #include @@ -294,5 +293,3 @@ class MeshFilterBase float shadow_threshold_; }; } // namespace mesh_filter - -#endif /* __MESH_FILTER_MESH_FILTER_BASE_H__ */ diff --git a/moveit_ros/perception/mesh_filter/include/moveit/mesh_filter/sensor_model.h b/moveit_ros/perception/mesh_filter/include/moveit/mesh_filter/sensor_model.h index 87239b0bd2..8c76cdccef 100644 --- a/moveit_ros/perception/mesh_filter/include/moveit/mesh_filter/sensor_model.h +++ b/moveit_ros/perception/mesh_filter/include/moveit/mesh_filter/sensor_model.h @@ -34,8 +34,7 @@ /* Author: Suat Gedikli */ -#ifndef MOVEIT_MESH_FILTER_SENSOR_MODEL_ -#define MOVEIT_MESH_FILTER_SENSOR_MODEL_ +#pragma once #include #include @@ -170,5 +169,3 @@ class SensorModel virtual ~SensorModel(); }; } // namespace mesh_filter - -#endif diff --git a/moveit_ros/perception/mesh_filter/include/moveit/mesh_filter/stereo_camera_model.h b/moveit_ros/perception/mesh_filter/include/moveit/mesh_filter/stereo_camera_model.h index 2dfac68ad6..d6dc185be1 100644 --- a/moveit_ros/perception/mesh_filter/include/moveit/mesh_filter/stereo_camera_model.h +++ b/moveit_ros/perception/mesh_filter/include/moveit/mesh_filter/stereo_camera_model.h @@ -34,8 +34,7 @@ /* Author: Suat Gedikli */ -#ifndef MOVEIT_MESH_FILTER_STEREO_CAMERA_MODEL_ -#define MOVEIT_MESH_FILTER_STEREO_CAMERA_MODEL_ +#pragma once #include #include @@ -164,4 +163,3 @@ class StereoCameraModel : public SensorModel static const std::string FILTER_FRAGMENT_SHADER_SOURCE; }; } // namespace mesh_filter -#endif diff --git a/moveit_ros/perception/mesh_filter/include/moveit/mesh_filter/transform_provider.h b/moveit_ros/perception/mesh_filter/include/moveit/mesh_filter/transform_provider.h index fe5547edad..eb03286787 100644 --- a/moveit_ros/perception/mesh_filter/include/moveit/mesh_filter/transform_provider.h +++ b/moveit_ros/perception/mesh_filter/include/moveit/mesh_filter/transform_provider.h @@ -34,8 +34,7 @@ /* Author: Suat Gedikli */ -#ifndef MOVEIT_MESH_FILTER_TRANSFORM_PROVIDER_ -#define MOVEIT_MESH_FILTER_TRANSFORM_PROVIDER_ +#pragma once #include #include @@ -167,4 +166,3 @@ class TransformProvider /** \brief update interval in micro seconds*/ unsigned long interval_us_; }; -#endif diff --git a/moveit_ros/perception/package.xml b/moveit_ros/perception/package.xml index 61033ec542..0d3a038102 100644 --- a/moveit_ros/perception/package.xml +++ b/moveit_ros/perception/package.xml @@ -1,14 +1,14 @@ moveit_ros_perception 1.0.1 - Components of MoveIt! connecting to perception + Components of MoveIt connecting to perception Ioan Sucan Jon Binney Suat Gedikli Michael Ferguson - MoveIt! Release Team + MoveIt Release Team BSD diff --git a/moveit_ros/perception/point_containment_filter/CMakeLists.txt b/moveit_ros/perception/point_containment_filter/CMakeLists.txt index ed76980c0a..a672692acb 100644 --- a/moveit_ros/perception/point_containment_filter/CMakeLists.txt +++ b/moveit_ros/perception/point_containment_filter/CMakeLists.txt @@ -6,5 +6,8 @@ set_target_properties(${MOVEIT_LIB_NAME} PROPERTIES COMPILE_FLAGS "${CMAKE_CXX_F set_target_properties(${MOVEIT_LIB_NAME} PROPERTIES LINK_FLAGS "${OpenMP_CXX_FLAGS}") target_link_libraries(${MOVEIT_LIB_NAME} ${catkin_LIBRARIES} ${Boost_LIBRARIES}) -install(TARGETS ${MOVEIT_LIB_NAME} LIBRARY DESTINATION ${CATKIN_GLOBAL_LIB_DESTINATION}) +install(TARGETS ${MOVEIT_LIB_NAME} + LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}) install(DIRECTORY include/ DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}) diff --git a/moveit_ros/perception/point_containment_filter/include/moveit/point_containment_filter/shape_mask.h b/moveit_ros/perception/point_containment_filter/include/moveit/point_containment_filter/shape_mask.h index 2b6ee820bd..67b1b01c7f 100644 --- a/moveit_ros/perception/point_containment_filter/include/moveit/point_containment_filter/shape_mask.h +++ b/moveit_ros/perception/point_containment_filter/include/moveit/point_containment_filter/shape_mask.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_POINT_CONTAINMENT_FILTER_SELF_MASK_ -#define MOVEIT_POINT_CONTAINMENT_FILTER_SELF_MASK_ +#pragma once #include #include @@ -106,7 +105,7 @@ class ShapeMask struct SortBodies { - bool operator()(const SeeShape& b1, const SeeShape& b2) + bool operator()(const SeeShape& b1, const SeeShape& b2) const { if (b1.volume > b2.volume) return true; @@ -129,5 +128,3 @@ class ShapeMask std::vector bspheres_; }; } - -#endif diff --git a/moveit_ros/perception/pointcloud_octomap_updater/CMakeLists.txt b/moveit_ros/perception/pointcloud_octomap_updater/CMakeLists.txt index 503c46fb2f..425a12beed 100644 --- a/moveit_ros/perception/pointcloud_octomap_updater/CMakeLists.txt +++ b/moveit_ros/perception/pointcloud_octomap_updater/CMakeLists.txt @@ -14,4 +14,5 @@ install(DIRECTORY include/ DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}) install(TARGETS ${MOVEIT_LIB_NAME} ${MOVEIT_LIB_NAME}_core ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} - LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}) + LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}) diff --git a/moveit_ros/perception/pointcloud_octomap_updater/include/moveit/pointcloud_octomap_updater/pointcloud_octomap_updater.h b/moveit_ros/perception/pointcloud_octomap_updater/include/moveit/pointcloud_octomap_updater/pointcloud_octomap_updater.h index cf56d68dfe..80ecbfaa11 100644 --- a/moveit_ros/perception/pointcloud_octomap_updater/include/moveit/pointcloud_octomap_updater/pointcloud_octomap_updater.h +++ b/moveit_ros/perception/pointcloud_octomap_updater/include/moveit/pointcloud_octomap_updater/pointcloud_octomap_updater.h @@ -34,8 +34,7 @@ /* Author: Jon Binney, Ioan Sucan */ -#ifndef MOVEIT_PERCEPTION_POINTCLOUD_OCTOMAP_UPDATER_ -#define MOVEIT_PERCEPTION_POINTCLOUD_OCTOMAP_UPDATER_ +#pragma once #include #include @@ -101,5 +100,3 @@ class PointCloudOctomapUpdater : public OccupancyMapUpdater std::vector mask_; }; } - -#endif diff --git a/moveit_ros/perception/semantic_world/CMakeLists.txt b/moveit_ros/perception/semantic_world/CMakeLists.txt index 6ed3c99610..0c6ef4f3f0 100644 --- a/moveit_ros/perception/semantic_world/CMakeLists.txt +++ b/moveit_ros/perception/semantic_world/CMakeLists.txt @@ -9,4 +9,5 @@ install(DIRECTORY include/ DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}) install(TARGETS ${MOVEIT_LIB_NAME} ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} - LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}) + LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}) diff --git a/moveit_ros/perception/semantic_world/include/moveit/semantic_world/semantic_world.h b/moveit_ros/perception/semantic_world/include/moveit/semantic_world/semantic_world.h index bed034f0c9..b53e280328 100644 --- a/moveit_ros/perception/semantic_world/include/moveit/semantic_world/semantic_world.h +++ b/moveit_ros/perception/semantic_world/include/moveit/semantic_world/semantic_world.h @@ -34,8 +34,7 @@ /* Author: Sachin Chitta */ -#ifndef MOVEIT_SEMANTIC_WORLD_ -#define MOVEIT_SEMANTIC_WORLD_ +#pragma once #include #include @@ -164,5 +163,3 @@ class SemanticWorld }; } } - -#endif diff --git a/moveit_ros/perception/semantic_world/src/semantic_world.cpp b/moveit_ros/perception/semantic_world/src/semantic_world.cpp index aa6d99403d..5407d287b7 100644 --- a/moveit_ros/perception/semantic_world/src/semantic_world.cpp +++ b/moveit_ros/perception/semantic_world/src/semantic_world.cpp @@ -38,7 +38,7 @@ #include #include -// MoveIt! +// MoveIt #include #include #include diff --git a/moveit_ros/planning/CMakeLists.txt b/moveit_ros/planning/CMakeLists.txt index 8f9b64aa03..b3833b5447 100644 --- a/moveit_ros/planning/CMakeLists.txt +++ b/moveit_ros/planning/CMakeLists.txt @@ -1,7 +1,8 @@ -cmake_minimum_required(VERSION 2.8.12) +cmake_minimum_required(VERSION 3.1.3) project(moveit_ros_planning) -add_compile_options(-std=c++14) +set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_EXTENSIONS OFF) if(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Release) diff --git a/moveit_ros/planning/collision_plugin_loader/CMakeLists.txt b/moveit_ros/planning/collision_plugin_loader/CMakeLists.txt index 86eea90717..6ad2115652 100644 --- a/moveit_ros/planning/collision_plugin_loader/CMakeLists.txt +++ b/moveit_ros/planning/collision_plugin_loader/CMakeLists.txt @@ -4,5 +4,8 @@ add_library(${MOVEIT_LIB_NAME} src/collision_plugin_loader.cpp) set_target_properties(${MOVEIT_LIB_NAME} PROPERTIES VERSION "${${PROJECT_NAME}_VERSION}") target_link_libraries(${MOVEIT_LIB_NAME} ${catkin_LIBRARIES}) -install(TARGETS ${MOVEIT_LIB_NAME} LIBRARY DESTINATION ${CATKIN_GLOBAL_LIB_DESTINATION}) +install(TARGETS ${MOVEIT_LIB_NAME} + LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}) install(DIRECTORY include/ DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}) diff --git a/moveit_ros/planning/collision_plugin_loader/include/moveit/collision_plugin_loader/collision_plugin_loader.h b/moveit_ros/planning/collision_plugin_loader/include/moveit/collision_plugin_loader/collision_plugin_loader.h index 4527ae450e..b5709e824a 100644 --- a/moveit_ros/planning/collision_plugin_loader/include/moveit/collision_plugin_loader/collision_plugin_loader.h +++ b/moveit_ros/planning/collision_plugin_loader/include/moveit/collision_plugin_loader/collision_plugin_loader.h @@ -32,8 +32,7 @@ * POSSIBILITY OF SUCH DAMAGE. *********************************************************************/ -#ifndef MOVEIT_COLLISION_PLUGIN_LOADER_COLLISION_PLUGIN_LOADER_H -#define MOVEIT_COLLISION_PLUGIN_LOADER_COLLISION_PLUGIN_LOADER_H +#pragma once #include #include @@ -68,5 +67,3 @@ class CollisionPluginLoader }; } // namespace collision_detection - -#endif // MOVEIT_COLLISION_PLUGIN_LOADER_COLLISION_PLUGIN_LOADER_H diff --git a/moveit_ros/planning/constraint_sampler_manager_loader/CMakeLists.txt b/moveit_ros/planning/constraint_sampler_manager_loader/CMakeLists.txt index 8e0dd2dc28..8e11bfaafa 100644 --- a/moveit_ros/planning/constraint_sampler_manager_loader/CMakeLists.txt +++ b/moveit_ros/planning/constraint_sampler_manager_loader/CMakeLists.txt @@ -4,5 +4,8 @@ add_library(${MOVEIT_LIB_NAME} src/constraint_sampler_manager_loader.cpp) set_target_properties(${MOVEIT_LIB_NAME} PROPERTIES VERSION "${${PROJECT_NAME}_VERSION}") target_link_libraries(${MOVEIT_LIB_NAME} ${catkin_LIBRARIES}) -install(TARGETS ${MOVEIT_LIB_NAME} LIBRARY DESTINATION ${CATKIN_GLOBAL_LIB_DESTINATION}) +install(TARGETS ${MOVEIT_LIB_NAME} + LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}) install(DIRECTORY include/ DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}) diff --git a/moveit_ros/planning/constraint_sampler_manager_loader/include/moveit/constraint_sampler_manager_loader/constraint_sampler_manager_loader.h b/moveit_ros/planning/constraint_sampler_manager_loader/include/moveit/constraint_sampler_manager_loader/constraint_sampler_manager_loader.h index 5d24813893..84246d1851 100644 --- a/moveit_ros/planning/constraint_sampler_manager_loader/include/moveit/constraint_sampler_manager_loader/constraint_sampler_manager_loader.h +++ b/moveit_ros/planning/constraint_sampler_manager_loader/include/moveit/constraint_sampler_manager_loader/constraint_sampler_manager_loader.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_CONSTRAINT_SAMPLER_MANAGER_LOADER_ -#define MOVEIT_CONSTRAINT_SAMPLER_MANAGER_LOADER_ +#pragma once #include #include @@ -62,5 +61,3 @@ class ConstraintSamplerManagerLoader HelperPtr impl_; }; } - -#endif diff --git a/moveit_ros/planning/kinematics_plugin_loader/CMakeLists.txt b/moveit_ros/planning/kinematics_plugin_loader/CMakeLists.txt index ebcc035b60..48ce472264 100644 --- a/moveit_ros/planning/kinematics_plugin_loader/CMakeLists.txt +++ b/moveit_ros/planning/kinematics_plugin_loader/CMakeLists.txt @@ -4,5 +4,8 @@ add_library(${MOVEIT_LIB_NAME} src/kinematics_plugin_loader.cpp) set_target_properties(${MOVEIT_LIB_NAME} PROPERTIES VERSION "${${PROJECT_NAME}_VERSION}") target_link_libraries(${MOVEIT_LIB_NAME} moveit_rdf_loader ${catkin_LIBRARIES}) -install(TARGETS ${MOVEIT_LIB_NAME} LIBRARY DESTINATION ${CATKIN_GLOBAL_LIB_DESTINATION}) +install(TARGETS ${MOVEIT_LIB_NAME} + LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}) install(DIRECTORY include/ DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}) diff --git a/moveit_ros/planning/kinematics_plugin_loader/include/moveit/kinematics_plugin_loader/kinematics_plugin_loader.h b/moveit_ros/planning/kinematics_plugin_loader/include/moveit/kinematics_plugin_loader/kinematics_plugin_loader.h index 9bc06594e3..f4c6b0a356 100644 --- a/moveit_ros/planning/kinematics_plugin_loader/include/moveit/kinematics_plugin_loader/kinematics_plugin_loader.h +++ b/moveit_ros/planning/kinematics_plugin_loader/include/moveit/kinematics_plugin_loader/kinematics_plugin_loader.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan, Dave Coleman */ -#ifndef MOVEIT_KINEMATICS_PLUGIN_LOADER_ -#define MOVEIT_KINEMATICS_PLUGIN_LOADER_ +#pragma once #include #include @@ -115,5 +114,3 @@ class KinematicsPluginLoader double default_solver_timeout_; }; } - -#endif diff --git a/moveit_ros/planning/package.xml b/moveit_ros/planning/package.xml index ee9e4f923e..c5f426ebe1 100644 --- a/moveit_ros/planning/package.xml +++ b/moveit_ros/planning/package.xml @@ -2,13 +2,13 @@ moveit_ros_planning 1.0.1 - Planning components of MoveIt! that use ROS + Planning components of MoveIt that use ROS Ioan Sucan Sachin Chitta Michael Ferguson Michael Görner - MoveIt! Release Team + MoveIt Release Team BSD diff --git a/moveit_ros/planning/plan_execution/CMakeLists.txt b/moveit_ros/planning/plan_execution/CMakeLists.txt index 6d2a0c24fe..6b579cfb11 100644 --- a/moveit_ros/planning/plan_execution/CMakeLists.txt +++ b/moveit_ros/planning/plan_execution/CMakeLists.txt @@ -11,5 +11,8 @@ target_link_libraries(${MOVEIT_LIB_NAME} ${catkin_LIBRARIES} ${Boost_LIBRARIES} ) -install(TARGETS ${MOVEIT_LIB_NAME} LIBRARY DESTINATION ${CATKIN_GLOBAL_LIB_DESTINATION}) +install(TARGETS ${MOVEIT_LIB_NAME} + LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}) install(DIRECTORY include/ DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}) diff --git a/moveit_ros/planning/plan_execution/cfg/PlanExecutionDynamicReconfigure.cfg b/moveit_ros/planning/plan_execution/cfg/PlanExecutionDynamicReconfigure.cfg index fd8be081d6..cfc09ea25a 100755 --- a/moveit_ros/planning/plan_execution/cfg/PlanExecutionDynamicReconfigure.cfg +++ b/moveit_ros/planning/plan_execution/cfg/PlanExecutionDynamicReconfigure.cfg @@ -4,6 +4,6 @@ from dynamic_reconfigure.parameter_generator_catkin import * gen = ParameterGenerator() gen.add("max_replan_attempts", int_t, 1, "Set the maximum number of times a sensor can be pointed to parts of the environment doring a motion plan", 5, 0, 1000) -gen.add("record_trajectory_state_frequency", double_t, 6, "The frequency at which to record states when monitoring trajectories", 10.0, 1.0, 1000.0) +gen.add("record_trajectory_state_frequency", double_t, 6, "The frequency at which to record states when monitoring trajectories", 0.0, 0.0, 1000.0) exit(gen.generate(PACKAGE, PACKAGE, "PlanExecutionDynamicReconfigure")) diff --git a/moveit_ros/planning/plan_execution/include/moveit/plan_execution/plan_execution.h b/moveit_ros/planning/plan_execution/include/moveit/plan_execution/plan_execution.h index e673c04031..11023522a9 100644 --- a/moveit_ros/planning/plan_execution/include/moveit/plan_execution/plan_execution.h +++ b/moveit_ros/planning/plan_execution/include/moveit/plan_execution/plan_execution.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_PLAN_EXECUTION_PLAN_EXECUTION_ -#define MOVEIT_PLAN_EXECUTION_PLAN_EXECUTION_ +#pragma once #include #include @@ -166,4 +165,3 @@ class PlanExecution DynamicReconfigureImpl* reconfigure_impl_; }; } -#endif diff --git a/moveit_ros/planning/plan_execution/include/moveit/plan_execution/plan_representation.h b/moveit_ros/planning/plan_execution/include/moveit/plan_execution/plan_representation.h index c400874990..809cb259c7 100644 --- a/moveit_ros/planning/plan_execution/include/moveit/plan_execution/plan_representation.h +++ b/moveit_ros/planning/plan_execution/include/moveit/plan_execution/plan_representation.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_PLAN_EXECUTION_PLAN_REPRESENTATION_ -#define MOVEIT_PLAN_EXECUTION_PLAN_REPRESENTATION_ +#pragma once #include #include @@ -83,4 +82,3 @@ struct ExecutableMotionPlan /// The signature of a function that can compute a motion plan typedef boost::function ExecutableMotionPlanComputationFn; } -#endif diff --git a/moveit_ros/planning/plan_execution/include/moveit/plan_execution/plan_with_sensing.h b/moveit_ros/planning/plan_execution/include/moveit/plan_execution/plan_with_sensing.h index 55a7d57f8a..b0b468cd19 100644 --- a/moveit_ros/planning/plan_execution/include/moveit/plan_execution/plan_with_sensing.h +++ b/moveit_ros/planning/plan_execution/include/moveit/plan_execution/plan_with_sensing.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_PLAN_EXECUTION_PLAN_WITH_SENSING_ -#define MOVEIT_PLAN_EXECUTION_PLAN_WITH_SENSING_ +#pragma once #include #include @@ -135,4 +134,3 @@ class PlanWithSensing DynamicReconfigureImpl* reconfigure_impl_; }; } -#endif diff --git a/moveit_ros/planning/plan_execution/src/plan_execution.cpp b/moveit_ros/planning/plan_execution/src/plan_execution.cpp index afd1694f00..fb8ee5fae1 100644 --- a/moveit_ros/planning/plan_execution/src/plan_execution.cpp +++ b/moveit_ros/planning/plan_execution/src/plan_execution.cpp @@ -38,6 +38,7 @@ #include #include #include +#include #include #include @@ -141,7 +142,7 @@ void plan_execution::PlanExecution::planAndExecute(ExecutableMotionPlan& plan, c void plan_execution::PlanExecution::planAndExecute(ExecutableMotionPlan& plan, const moveit_msgs::PlanningScene& scene_diff, const Options& opt) { - if (planning_scene::PlanningScene::isEmpty(scene_diff)) + if (moveit::core::isEmpty(scene_diff)) planAndExecute(plan, opt); else { @@ -391,8 +392,13 @@ moveit_msgs::MoveItErrorCodes plan_execution::PlanExecution::executeAndMonitor(E } if (!trajectory_monitor_ && planning_scene_monitor_->getStateMonitor()) - trajectory_monitor_.reset( - new planning_scene_monitor::TrajectoryMonitor(planning_scene_monitor_->getStateMonitor())); + { + // Pass current value of reconfigurable parameter plan_execution/record_trajectory_state_frequency + double sampling_frequency = 0.0; + node_handle_.getParam("plan_execution/record_trajectory_state_frequency", sampling_frequency); + trajectory_monitor_ = std::make_shared( + planning_scene_monitor_->getStateMonitor(), sampling_frequency); + } // start recording trajectory states if (trajectory_monitor_) @@ -511,7 +517,7 @@ void plan_execution::PlanExecution::successfulTrajectorySegmentExecution(const E if (index < plan->plan_components_.size() && plan->plan_components_[index].trajectory_ && !plan->plan_components_[index].trajectory_->empty()) { - if (!isRemainingPathValid(*plan, std::make_pair(index, 0))) + if (!isRemainingPathValid(*plan, std::make_pair(static_cast(index), 0))) path_became_invalid_ = true; } } diff --git a/moveit_ros/planning/plan_execution/src/plan_with_sensing.cpp b/moveit_ros/planning/plan_execution/src/plan_with_sensing.cpp index 6c62e6d411..8095e07b78 100644 --- a/moveit_ros/planning/plan_execution/src/plan_with_sensing.cpp +++ b/moveit_ros/planning/plan_execution/src/plan_with_sensing.cpp @@ -248,7 +248,7 @@ bool plan_execution::PlanWithSensing::lookAt(const std::setgetCurrentState() << std::endl; - sleep(1); + ros::Duration(1).sleep(); } } while (nh.ok()); diff --git a/moveit_ros/planning/planning_components_tools/src/print_planning_scene_info.cpp b/moveit_ros/planning/planning_components_tools/src/print_planning_scene_info.cpp index 6811f7b4e0..f7f64c761d 100644 --- a/moveit_ros/planning/planning_components_tools/src/print_planning_scene_info.cpp +++ b/moveit_ros/planning/planning_components_tools/src/print_planning_scene_info.cpp @@ -38,7 +38,7 @@ #include -// MoveIt! +// MoveIt #include static const std::string ROBOT_DESCRIPTION = "robot_description"; diff --git a/moveit_ros/planning/planning_components_tools/src/publish_scene_from_text.cpp b/moveit_ros/planning/planning_components_tools/src/publish_scene_from_text.cpp index 274e250433..b2f441d5c8 100644 --- a/moveit_ros/planning/planning_components_tools/src/publish_scene_from_text.cpp +++ b/moveit_ros/planning/planning_components_tools/src/publish_scene_from_text.cpp @@ -90,7 +90,7 @@ int main(int argc, char** argv) else pub_scene.publish(ps_msg.world); - sleep(1); + ros::Duration(1).sleep(); } } else diff --git a/moveit_ros/planning/planning_pipeline/CMakeLists.txt b/moveit_ros/planning/planning_pipeline/CMakeLists.txt index 853d2efb11..abeb034e3a 100644 --- a/moveit_ros/planning/planning_pipeline/CMakeLists.txt +++ b/moveit_ros/planning/planning_pipeline/CMakeLists.txt @@ -4,5 +4,8 @@ add_library(${MOVEIT_LIB_NAME} src/planning_pipeline.cpp) set_target_properties(${MOVEIT_LIB_NAME} PROPERTIES VERSION "${${PROJECT_NAME}_VERSION}") target_link_libraries(${MOVEIT_LIB_NAME} ${catkin_LIBRARIES} ${Boost_LIBRARIES}) -install(TARGETS ${MOVEIT_LIB_NAME} LIBRARY DESTINATION ${CATKIN_GLOBAL_LIB_DESTINATION}) +install(TARGETS ${MOVEIT_LIB_NAME} + LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}) install(DIRECTORY include/ DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}) diff --git a/moveit_ros/planning/planning_pipeline/include/moveit/planning_pipeline/planning_pipeline.h b/moveit_ros/planning/planning_pipeline/include/moveit/planning_pipeline/planning_pipeline.h index f08af40a04..313f770999 100644 --- a/moveit_ros/planning/planning_pipeline/include/moveit/planning_pipeline/planning_pipeline.h +++ b/moveit_ros/planning/planning_pipeline/include/moveit/planning_pipeline/planning_pipeline.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_PLANNING_PIPELINE_PLANNING_PIPELINE_ -#define MOVEIT_PLANNING_PIPELINE_PLANNING_PIPELINE_ +#pragma once #include #include @@ -197,5 +196,3 @@ class PlanningPipeline MOVEIT_CLASS_FORWARD(PlanningPipeline); } - -#endif diff --git a/moveit_ros/planning/planning_request_adapter_plugins/CMakeLists.txt b/moveit_ros/planning/planning_request_adapter_plugins/CMakeLists.txt index f3a9dbae8d..b32ffe5349 100644 --- a/moveit_ros/planning/planning_request_adapter_plugins/CMakeLists.txt +++ b/moveit_ros/planning/planning_request_adapter_plugins/CMakeLists.txt @@ -19,6 +19,10 @@ target_link_libraries(${MOVEIT_LIB_NAME} ${catkin_LIBRARIES} ${Boost_LIBRARIES}) add_executable(moveit_list_request_adapter_plugins src/list.cpp) target_link_libraries(moveit_list_request_adapter_plugins ${catkin_LIBRARIES} ${Boost_LIBRARIES}) -install(TARGETS ${MOVEIT_LIB_NAME} moveit_list_request_adapter_plugins +install(TARGETS ${MOVEIT_LIB_NAME} LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}) + +install(TARGETS moveit_list_request_adapter_plugins RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}) diff --git a/moveit_ros/planning/planning_request_adapter_plugins/src/add_iterative_spline_parameterization.cpp b/moveit_ros/planning/planning_request_adapter_plugins/src/add_iterative_spline_parameterization.cpp index 6904160457..bf4f89a2b8 100644 --- a/moveit_ros/planning/planning_request_adapter_plugins/src/add_iterative_spline_parameterization.cpp +++ b/moveit_ros/planning/planning_request_adapter_plugins/src/add_iterative_spline_parameterization.cpp @@ -68,7 +68,10 @@ class AddIterativeSplineParameterization : public planning_request_adapter::Plan ROS_DEBUG("Running '%s'", getDescription().c_str()); if (!time_param_.computeTimeStamps(*res.trajectory_, req.max_velocity_scaling_factor, req.max_acceleration_scaling_factor)) - ROS_WARN("Time parametrization for the solution path failed."); + { + ROS_ERROR("Time parametrization for the solution path failed."); + result = false; + } } return result; diff --git a/moveit_ros/planning/planning_request_adapter_plugins/src/add_time_optimal_parameterization.cpp b/moveit_ros/planning/planning_request_adapter_plugins/src/add_time_optimal_parameterization.cpp index 805e6b7329..336307fedb 100644 --- a/moveit_ros/planning/planning_request_adapter_plugins/src/add_time_optimal_parameterization.cpp +++ b/moveit_ros/planning/planning_request_adapter_plugins/src/add_time_optimal_parameterization.cpp @@ -71,7 +71,10 @@ class AddTimeOptimalParameterization : public planning_request_adapter::Planning TimeOptimalTrajectoryGeneration totg; if (!totg.computeTimeStamps(*res.trajectory_, req.max_velocity_scaling_factor, req.max_acceleration_scaling_factor)) - ROS_WARN("Time parametrization for the solution path failed."); + { + ROS_ERROR("Time parametrization for the solution path failed."); + result = false; + } } return result; diff --git a/moveit_ros/planning/planning_request_adapter_plugins/src/add_time_parameterization.cpp b/moveit_ros/planning/planning_request_adapter_plugins/src/add_time_parameterization.cpp index be06624689..e3d1b17522 100644 --- a/moveit_ros/planning/planning_request_adapter_plugins/src/add_time_parameterization.cpp +++ b/moveit_ros/planning/planning_request_adapter_plugins/src/add_time_parameterization.cpp @@ -67,7 +67,10 @@ class AddTimeParameterization : public planning_request_adapter::PlanningRequest ROS_DEBUG("Running '%s'", getDescription().c_str()); if (!time_param_.computeTimeStamps(*res.trajectory_, req.max_velocity_scaling_factor, req.max_acceleration_scaling_factor)) - ROS_WARN("Time parametrization for the solution path failed."); + { + ROS_ERROR("Time parametrization for the solution path failed."); + result = false; + } } return result; diff --git a/moveit_ros/planning/planning_scene_monitor/CMakeLists.txt b/moveit_ros/planning/planning_scene_monitor/CMakeLists.txt index 9ad23d6175..6329feef36 100644 --- a/moveit_ros/planning/planning_scene_monitor/CMakeLists.txt +++ b/moveit_ros/planning/planning_scene_monitor/CMakeLists.txt @@ -14,5 +14,8 @@ target_link_libraries(${MOVEIT_LIB_NAME} add_executable(demo_scene demos/demo_scene.cpp) target_link_libraries(demo_scene ${MOVEIT_LIB_NAME} ${catkin_LIBRARIES} ${Boost_LIBRARIES}) -install(TARGETS ${MOVEIT_LIB_NAME} LIBRARY DESTINATION ${CATKIN_GLOBAL_LIB_DESTINATION}) +install(TARGETS ${MOVEIT_LIB_NAME} + LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}) install(DIRECTORY include/ DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}) diff --git a/moveit_ros/planning/planning_scene_monitor/demos/demo_scene.cpp b/moveit_ros/planning/planning_scene_monitor/demos/demo_scene.cpp index 681d6af0d2..976f1ba678 100644 --- a/moveit_ros/planning/planning_scene_monitor/demos/demo_scene.cpp +++ b/moveit_ros/planning/planning_scene_monitor/demos/demo_scene.cpp @@ -76,7 +76,7 @@ void sendKnife() co.primitive_poses[0].orientation.w = 1.0; pub_aco.publish(aco); - sleep(1); + ros::Duration(1).sleep(); pub_aco.publish(aco); ROS_INFO("Object published."); ros::Duration(1.5).sleep(); diff --git a/moveit_ros/planning/planning_scene_monitor/include/moveit/planning_scene_monitor/current_state_monitor.h b/moveit_ros/planning/planning_scene_monitor/include/moveit/planning_scene_monitor/current_state_monitor.h index 709586792e..806db00daf 100644 --- a/moveit_ros/planning/planning_scene_monitor/include/moveit/planning_scene_monitor/current_state_monitor.h +++ b/moveit_ros/planning/planning_scene_monitor/include/moveit/planning_scene_monitor/current_state_monitor.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_PLANNING_SCENE_MONITOR_CURRENT_STATE_MONITOR_ -#define MOVEIT_PLANNING_SCENE_MONITOR_CURRENT_STATE_MONITOR_ +#pragma once #include #include @@ -213,5 +212,3 @@ class CurrentStateMonitor MOVEIT_CLASS_FORWARD(CurrentStateMonitor); } - -#endif diff --git a/moveit_ros/planning/planning_scene_monitor/include/moveit/planning_scene_monitor/planning_scene_monitor.h b/moveit_ros/planning/planning_scene_monitor/include/moveit/planning_scene_monitor/planning_scene_monitor.h index d03afd28ec..49db508c9f 100644 --- a/moveit_ros/planning/planning_scene_monitor/include/moveit/planning_scene_monitor/planning_scene_monitor.h +++ b/moveit_ros/planning/planning_scene_monitor/include/moveit/planning_scene_monitor/planning_scene_monitor.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_PLANNING_SCENE_MONITOR_PLANNING_SCENE_MONITOR_ -#define MOVEIT_PLANNING_SCENE_MONITOR_PLANNING_SCENE_MONITOR_ +#pragma once #include #include @@ -702,5 +701,3 @@ class LockedPlanningSceneRW : public LockedPlanningSceneRO } }; } - -#endif diff --git a/moveit_ros/planning/planning_scene_monitor/include/moveit/planning_scene_monitor/trajectory_monitor.h b/moveit_ros/planning/planning_scene_monitor/include/moveit/planning_scene_monitor/trajectory_monitor.h index 3c753cffe6..f7638161a7 100644 --- a/moveit_ros/planning/planning_scene_monitor/include/moveit/planning_scene_monitor/trajectory_monitor.h +++ b/moveit_ros/planning/planning_scene_monitor/include/moveit/planning_scene_monitor/trajectory_monitor.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_PLANNING_SCENE_MONITOR_TRAJECTORY_MONITOR_ -#define MOVEIT_PLANNING_SCENE_MONITOR_TRAJECTORY_MONITOR_ +#pragma once #include #include @@ -57,7 +56,7 @@ class TrajectoryMonitor public: /** @brief Constructor. */ - TrajectoryMonitor(const CurrentStateMonitorConstPtr& state_monitor, double sampling_frequency = 5.0); + TrajectoryMonitor(const CurrentStateMonitorConstPtr& state_monitor, double sampling_frequency = 0.0); ~TrajectoryMonitor(); @@ -107,5 +106,3 @@ class TrajectoryMonitor TrajectoryStateAddedCallback state_add_callback_; }; } - -#endif diff --git a/moveit_ros/planning/planning_scene_monitor/src/current_state_monitor.cpp b/moveit_ros/planning/planning_scene_monitor/src/current_state_monitor.cpp index 43f1da2158..64ae7465d2 100644 --- a/moveit_ros/planning/planning_scene_monitor/src/current_state_monitor.cpp +++ b/moveit_ros/planning/planning_scene_monitor/src/current_state_monitor.cpp @@ -443,20 +443,20 @@ void planning_scene_monitor::CurrentStateMonitor::tfCallback() continue; joint_time_[joint] = latest_common_time; - double new_values[joint->getStateSpaceDimension()]; + std::vector new_values(joint->getStateSpaceDimension()); const robot_model::LinkModel* link = joint->getChildLinkModel(); if (link->jointOriginTransformIsIdentity()) - joint->computeVariablePositions(tf2::transformToEigen(transf), new_values); + joint->computeVariablePositions(tf2::transformToEigen(transf), new_values.data()); else joint->computeVariablePositions(link->getJointOriginTransform().inverse() * tf2::transformToEigen(transf), - new_values); + new_values.data()); - if (joint->distance(new_values, robot_state_.getJointPositions(joint)) > 1e-5) + if (joint->distance(new_values.data(), robot_state_.getJointPositions(joint)) > 1e-5) { changes = true; } - robot_state_.setJointPositions(joint, new_values); + robot_state_.setJointPositions(joint, new_values.data()); update = true; } } diff --git a/moveit_ros/planning/planning_scene_monitor/src/planning_scene_monitor.cpp b/moveit_ros/planning/planning_scene_monitor/src/planning_scene_monitor.cpp index 23a0ca3f28..de9a628b5a 100644 --- a/moveit_ros/planning/planning_scene_monitor/src/planning_scene_monitor.cpp +++ b/moveit_ros/planning/planning_scene_monitor/src/planning_scene_monitor.cpp @@ -36,6 +36,7 @@ #include #include +#include #include #include @@ -202,15 +203,15 @@ void PlanningSceneMonitor::initialize(const planning_scene::PlanningScenePtr& sc configureCollisionMatrix(scene_); configureDefaultPadding(); - scene_->getCollisionRobotNonConst()->setPadding(default_robot_padd_); - scene_->getCollisionRobotNonConst()->setScale(default_robot_scale_); + scene_->getCollisionEnvNonConst()->setPadding(default_robot_padd_); + scene_->getCollisionEnvNonConst()->setScale(default_robot_scale_); for (const std::pair& it : default_robot_link_padd_) { - scene_->getCollisionRobotNonConst()->setLinkPadding(it.first, it.second); + scene_->getCollisionEnvNonConst()->setLinkPadding(it.first, it.second); } for (const std::pair& it : default_robot_link_scale_) { - scene_->getCollisionRobotNonConst()->setLinkScale(it.first, it.second); + scene_->getCollisionEnvNonConst()->setLinkScale(it.first, it.second); } scene_->propogateRobotPadding(); } @@ -565,13 +566,13 @@ bool PlanningSceneMonitor::newPlanningSceneMessage(const moveit_msgs::PlanningSc if (no_other_scene_upd) { upd = UPDATE_NONE; - if (!planning_scene::PlanningScene::isEmpty(scene.world)) + if (!moveit::core::isEmpty(scene.world)) upd = (SceneUpdateType)((int)upd | (int)UPDATE_GEOMETRY); if (!scene.fixed_frame_transforms.empty()) upd = (SceneUpdateType)((int)upd | (int)UPDATE_TRANSFORMS); - if (!planning_scene::PlanningScene::isEmpty(scene.robot_state)) + if (!moveit::core::isEmpty(scene.robot_state)) { upd = (SceneUpdateType)((int)upd | (int)UPDATE_STATE); if (!scene.robot_state.attached_collision_objects.empty() || !static_cast(scene.robot_state.is_diff)) diff --git a/moveit_ros/planning/planning_scene_monitor/src/trajectory_monitor.cpp b/moveit_ros/planning/planning_scene_monitor/src/trajectory_monitor.cpp index 69b6e53851..3631760f0c 100644 --- a/moveit_ros/planning/planning_scene_monitor/src/trajectory_monitor.cpp +++ b/moveit_ros/planning/planning_scene_monitor/src/trajectory_monitor.cpp @@ -40,10 +40,12 @@ #include #include +static const std::string LOGNAME = "TrajectoryMonitor"; + planning_scene_monitor::TrajectoryMonitor::TrajectoryMonitor(const CurrentStateMonitorConstPtr& state_monitor, double sampling_frequency) : current_state_monitor_(state_monitor) - , sampling_frequency_(5.0) + , sampling_frequency_(sampling_frequency) , trajectory_(current_state_monitor_->getRobotModel(), "") { setSamplingFrequency(sampling_frequency); @@ -56,10 +58,14 @@ planning_scene_monitor::TrajectoryMonitor::~TrajectoryMonitor() void planning_scene_monitor::TrajectoryMonitor::setSamplingFrequency(double sampling_frequency) { + if (sampling_frequency != sampling_frequency_) + return; // silently return if nothing changes + if (sampling_frequency <= std::numeric_limits::epsilon()) - ROS_ERROR("The sampling frequency for trajectory states should be positive"); + ROS_INFO_NAMED(LOGNAME, "Disabling trajectory recording"); else - sampling_frequency_ = sampling_frequency; + ROS_DEBUG_NAMED(LOGNAME, "Setting trajectory sampling frequency to %.1f", sampling_frequency); + sampling_frequency_ = sampling_frequency; } bool planning_scene_monitor::TrajectoryMonitor::isActive() const @@ -69,10 +75,10 @@ bool planning_scene_monitor::TrajectoryMonitor::isActive() const void planning_scene_monitor::TrajectoryMonitor::startTrajectoryMonitor() { - if (!record_states_thread_) + if (sampling_frequency_ > std::numeric_limits::epsilon() && !record_states_thread_) { record_states_thread_.reset(new boost::thread(boost::bind(&TrajectoryMonitor::recordStates, this))); - ROS_DEBUG("Started trajectory monitor"); + ROS_DEBUG_NAMED(LOGNAME, "Started trajectory monitor"); } } @@ -83,7 +89,7 @@ void planning_scene_monitor::TrajectoryMonitor::stopTrajectoryMonitor() std::unique_ptr copy; copy.swap(record_states_thread_); copy->join(); - ROS_DEBUG("Stopped trajectory monitor"); + ROS_DEBUG_NAMED(LOGNAME, "Stopped trajectory monitor"); } } diff --git a/moveit_ros/planning/rdf_loader/CMakeLists.txt b/moveit_ros/planning/rdf_loader/CMakeLists.txt index 0a0dbe5055..0b91cafd81 100644 --- a/moveit_ros/planning/rdf_loader/CMakeLists.txt +++ b/moveit_ros/planning/rdf_loader/CMakeLists.txt @@ -4,5 +4,8 @@ add_library(${MOVEIT_LIB_NAME} src/rdf_loader.cpp) set_target_properties(${MOVEIT_LIB_NAME} PROPERTIES VERSION "${${PROJECT_NAME}_VERSION}") target_link_libraries(${MOVEIT_LIB_NAME} ${catkin_LIBRARIES}) -install(TARGETS ${MOVEIT_LIB_NAME} LIBRARY DESTINATION ${CATKIN_GLOBAL_LIB_DESTINATION}) +install(TARGETS ${MOVEIT_LIB_NAME} + LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}) install(DIRECTORY include/ DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}) diff --git a/moveit_ros/planning/rdf_loader/include/moveit/rdf_loader/rdf_loader.h b/moveit_ros/planning/rdf_loader/include/moveit/rdf_loader/rdf_loader.h index 76efd13c8e..bf506a96bf 100644 --- a/moveit_ros/planning/rdf_loader/include/moveit/rdf_loader/rdf_loader.h +++ b/moveit_ros/planning/rdf_loader/include/moveit/rdf_loader/rdf_loader.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan, Mathias Lüdtke, Dave Coleman */ -#ifndef MOVEIT_PLANNING_RDF_LOADER_ -#define MOVEIT_PLANNING_RDF_LOADER_ +#pragma once #include #include @@ -102,4 +101,3 @@ class RDFLoader urdf::ModelInterfaceSharedPtr urdf_; }; } -#endif diff --git a/moveit_ros/planning/rdf_loader/src/rdf_loader.cpp b/moveit_ros/planning/rdf_loader/src/rdf_loader.cpp index eb655c1710..d4885f1fd3 100644 --- a/moveit_ros/planning/rdf_loader/src/rdf_loader.cpp +++ b/moveit_ros/planning/rdf_loader/src/rdf_loader.cpp @@ -34,7 +34,7 @@ /* Author: Ioan Sucan, Mathias Lüdtke, Dave Coleman */ -// MoveIt! +// MoveIt #include #include @@ -50,6 +50,11 @@ #include #include +#ifdef _WIN32 +#define popen _popen +#define pclose _pclose +#endif + rdf_loader::RDFLoader::RDFLoader(const std::string& robot_description) { moveit::tools::Profiler::ScopedStart prof_start; diff --git a/moveit_ros/planning/robot_model_loader/CMakeLists.txt b/moveit_ros/planning/robot_model_loader/CMakeLists.txt index 13af8cdd78..9790d1bcc3 100644 --- a/moveit_ros/planning/robot_model_loader/CMakeLists.txt +++ b/moveit_ros/planning/robot_model_loader/CMakeLists.txt @@ -8,5 +8,8 @@ add_library(${MOVEIT_LIB_NAME} src/robot_model_loader.cpp) set_target_properties(${MOVEIT_LIB_NAME} PROPERTIES VERSION "${${PROJECT_NAME}_VERSION}") target_link_libraries(${MOVEIT_LIB_NAME} moveit_rdf_loader moveit_kinematics_plugin_loader ${catkin_LIBRARIES}) -install(TARGETS ${MOVEIT_LIB_NAME} LIBRARY DESTINATION ${CATKIN_GLOBAL_LIB_DESTINATION}) +install(TARGETS ${MOVEIT_LIB_NAME} + LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}) install(DIRECTORY include/ DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}) diff --git a/moveit_ros/planning/robot_model_loader/include/moveit/robot_model_loader/robot_model_loader.h b/moveit_ros/planning/robot_model_loader/include/moveit/robot_model_loader/robot_model_loader.h index def0d10d75..c39d9f1056 100644 --- a/moveit_ros/planning/robot_model_loader/include/moveit/robot_model_loader/robot_model_loader.h +++ b/moveit_ros/planning/robot_model_loader/include/moveit/robot_model_loader/robot_model_loader.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_PLANNING_MODELS_LOADER_ROBOT_MODEL_LOADER_ -#define MOVEIT_PLANNING_MODELS_LOADER_ROBOT_MODEL_LOADER_ +#pragma once #include #include @@ -134,4 +133,3 @@ class RobotModelLoader kinematics_plugin_loader::KinematicsPluginLoaderPtr kinematics_loader_; }; } -#endif diff --git a/moveit_ros/planning/trajectory_execution_manager/CMakeLists.txt b/moveit_ros/planning/trajectory_execution_manager/CMakeLists.txt index 51b7336ac1..14a2c23be8 100644 --- a/moveit_ros/planning/trajectory_execution_manager/CMakeLists.txt +++ b/moveit_ros/planning/trajectory_execution_manager/CMakeLists.txt @@ -5,7 +5,10 @@ set_target_properties(${MOVEIT_LIB_NAME} PROPERTIES VERSION "${${PROJECT_NAME}_V target_link_libraries(${MOVEIT_LIB_NAME} moveit_planning_scene_monitor moveit_robot_model_loader ${catkin_LIBRARIES} ${Boost_LIBRARIES}) add_dependencies(${MOVEIT_LIB_NAME} ${moveit_ros_planning_EXPORTED_TARGETS}) # don't build until necessary msgs are finish -install(TARGETS ${MOVEIT_LIB_NAME} LIBRARY DESTINATION ${CATKIN_GLOBAL_LIB_DESTINATION}) +install(TARGETS ${MOVEIT_LIB_NAME} + LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}) install(DIRECTORY include/ DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}) add_library(test_controller_manager_plugin test/test_moveit_controller_manager_plugin.cpp) diff --git a/moveit_ros/planning/trajectory_execution_manager/dox/trajectory_execution.dox b/moveit_ros/planning/trajectory_execution_manager/dox/trajectory_execution.dox index bb4b9068a4..ab7a5e683e 100644 --- a/moveit_ros/planning/trajectory_execution_manager/dox/trajectory_execution.dox +++ b/moveit_ros/planning/trajectory_execution_manager/dox/trajectory_execution.dox @@ -1,11 +1,11 @@ /** \page trajectory_execution Trajectory Execution Manager -@b MoveIt! includes a library for managing controllers and the execution of trajectories. This code exists in the trajectory_execution_manager namespace. +@b MoveIt includes a library for managing controllers and the execution of trajectories. This code exists in the trajectory_execution_manager namespace. The trajectory_execution_manager::TrajectoryExecutionManager class allows two main operations: - trajectory_execution_manager::TrajectoryExecutionManager::push() adds trajectories specified as a moveit_msgs::RobotTrajectory message type to a queue of trajectories to be executed in sequence. Each trajectory can be specified for any set of joints in the robot. Because controllers may only be available for certain groups of joints, this function may decide to split one trajectory into multiple ones and pass them to corresponding controllers (this time in parallel, using the same time stamp for the trajectory points). This approach assumes that controllers respect the time stamps specified for the waypoints. - trajectory_execution_manager::TrajectoryExecutionManager::execute() passes the appropriate trajectories to different controllers, monitors execution, optionally waits for completion of the execution and, very importantly, switches active controllers as needed (optionally) to be able to execute the specified trajectories. -The functionality of the trajectory execution in MoveIt! usually needs robot-specific interaction with controllers. For this reason, the concept of a controller manager specific to MoveIt! (moveit_controller_manager::MoveItControllerManager) was defined. This is an abstract class that defines the functionality needed by trajectory_execution_manager::TrajectoryExecutionManager and needs to be implemented for each robot type. Often, the implementation of these plugins are quite similar and it is easy to modify existing code to achieve the desired functionality (see for example pr2_moveit_controller_manager::Pr2MoveItControllerManager). +The functionality of the trajectory execution in MoveIt usually needs robot-specific interaction with controllers. For this reason, the concept of a controller manager specific to MoveIt (moveit_controller_manager::MoveItControllerManager) was defined. This is an abstract class that defines the functionality needed by trajectory_execution_manager::TrajectoryExecutionManager and needs to be implemented for each robot type. Often, the implementation of these plugins are quite similar and it is easy to modify existing code to achieve the desired functionality (see for example pr2_moveit_controller_manager::Pr2MoveItControllerManager). */ \ No newline at end of file diff --git a/moveit_ros/planning/trajectory_execution_manager/include/moveit/trajectory_execution_manager/trajectory_execution_manager.h b/moveit_ros/planning/trajectory_execution_manager/include/moveit/trajectory_execution_manager/trajectory_execution_manager.h index ea2f1a0d6d..1800068f42 100644 --- a/moveit_ros/planning/trajectory_execution_manager/include/moveit/trajectory_execution_manager/trajectory_execution_manager.h +++ b/moveit_ros/planning/trajectory_execution_manager/include/moveit/trajectory_execution_manager/trajectory_execution_manager.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_TRAJECTORY_EXECUTION_MANAGER_TRAJECTORY_EXECUTION_MANAGER_ -#define MOVEIT_TRAJECTORY_EXECUTION_MANAGER_TRAJECTORY_EXECUTION_MANAGER_ +#pragma once #include #include @@ -362,5 +361,3 @@ class TrajectoryExecutionManager bool wait_for_trajectory_completion_; }; } - -#endif diff --git a/moveit_ros/planning/trajectory_execution_manager/test/test_moveit_controller_manager.h b/moveit_ros/planning/trajectory_execution_manager/test/test_moveit_controller_manager.h index 731d2e65c4..46584f00cd 100644 --- a/moveit_ros/planning/trajectory_execution_manager/test/test_moveit_controller_manager.h +++ b/moveit_ros/planning/trajectory_execution_manager/test/test_moveit_controller_manager.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef TEST_MOVEIT_CONTROLLER_MANAGER_ -#define TEST_MOVEIT_CONTROLLER_MANAGER_ +#pragma once #include @@ -160,4 +159,3 @@ class TestMoveItControllerManager : public moveit_controller_manager::MoveItCont std::map > controller_joints_; }; } -#endif diff --git a/moveit_ros/planning_interface/CMakeLists.txt b/moveit_ros/planning_interface/CMakeLists.txt index 55686b8ff8..d1b5594b18 100644 --- a/moveit_ros/planning_interface/CMakeLists.txt +++ b/moveit_ros/planning_interface/CMakeLists.txt @@ -1,7 +1,8 @@ -cmake_minimum_required(VERSION 2.8.12) +cmake_minimum_required(VERSION 3.1.3) project(moveit_ros_planning_interface) -add_compile_options(-std=c++14) +set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_EXTENSIONS OFF) if(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Release) diff --git a/moveit_ros/planning_interface/common_planning_interface_objects/CMakeLists.txt b/moveit_ros/planning_interface/common_planning_interface_objects/CMakeLists.txt index f5b6953406..71b61285a4 100644 --- a/moveit_ros/planning_interface/common_planning_interface_objects/CMakeLists.txt +++ b/moveit_ros/planning_interface/common_planning_interface_objects/CMakeLists.txt @@ -6,6 +6,7 @@ target_link_libraries(${MOVEIT_LIB_NAME} ${catkin_LIBRARIES} ${PYTHON_LIBRARIES} install(TARGETS ${MOVEIT_LIB_NAME} ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} - LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}) + LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}) install(DIRECTORY include/ DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}) diff --git a/moveit_ros/planning_interface/common_planning_interface_objects/include/moveit/common_planning_interface_objects/common_objects.h b/moveit_ros/planning_interface/common_planning_interface_objects/include/moveit/common_planning_interface_objects/common_objects.h index bffa91d836..10248a0f96 100644 --- a/moveit_ros/planning_interface/common_planning_interface_objects/include/moveit/common_planning_interface_objects/common_objects.h +++ b/moveit_ros/planning_interface/common_planning_interface_objects/include/moveit/common_planning_interface_objects/common_objects.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_PLANNING_INTERFACE_COMMON_OBJECTS_ -#define MOVEIT_PLANNING_INTERFACE_COMMON_OBJECTS_ +#pragma once #include @@ -73,5 +72,3 @@ planning_scene_monitor::CurrentStateMonitorPtr getSharedStateMonitor(const robot } // namespace planning interface } // namespace moveit - -#endif // end of MOVEIT_PLANNING_INTERFACE_COMMON_OBJECTS_ diff --git a/moveit_ros/planning_interface/move_group_interface/CMakeLists.txt b/moveit_ros/planning_interface/move_group_interface/CMakeLists.txt index eacfa2aecb..b9a4eeaa01 100644 --- a/moveit_ros/planning_interface/move_group_interface/CMakeLists.txt +++ b/moveit_ros/planning_interface/move_group_interface/CMakeLists.txt @@ -11,14 +11,19 @@ add_dependencies(${MOVEIT_LIB_NAME}_python ${catkin_EXPORTED_TARGETS}) set_target_properties(${MOVEIT_LIB_NAME}_python PROPERTIES VERSION "${${PROJECT_NAME}_VERSION}") set_target_properties(${MOVEIT_LIB_NAME}_python PROPERTIES OUTPUT_NAME _moveit_move_group_interface PREFIX "") set_target_properties(${MOVEIT_LIB_NAME}_python PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CATKIN_DEVEL_PREFIX}/${CATKIN_PACKAGE_PYTHON_DESTINATION}") +if(WIN32) + set_target_properties(${MOVEIT_LIB_NAME}_python PROPERTIES SUFFIX .pyd) +endif(WIN32) install(TARGETS ${MOVEIT_LIB_NAME} ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} - LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}) + LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}) install(TARGETS ${MOVEIT_LIB_NAME}_python ARCHIVE DESTINATION ${CATKIN_PACKAGE_PYTHON_DESTINATION} - LIBRARY DESTINATION ${CATKIN_PACKAGE_PYTHON_DESTINATION}) + LIBRARY DESTINATION ${CATKIN_PACKAGE_PYTHON_DESTINATION} + RUNTIME DESTINATION ${CATKIN_PACKAGE_PYTHON_DESTINATION}) install(DIRECTORY include/ DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}) diff --git a/moveit_ros/planning_interface/move_group_interface/include/moveit/move_group_interface/move_group_interface.h b/moveit_ros/planning_interface/move_group_interface/include/moveit/move_group_interface/move_group_interface.h index 727b626fbe..ae4d3a3b7d 100644 --- a/moveit_ros/planning_interface/move_group_interface/include/moveit/move_group_interface/move_group_interface.h +++ b/moveit_ros/planning_interface/move_group_interface/include/moveit/move_group_interface/move_group_interface.h @@ -35,8 +35,7 @@ /* Author: Ioan Sucan, Sachin Chitta */ -#ifndef MOVEIT_MOVE_GROUP_INTERFACE_MOVE_GROUP_INTERFACE_ -#define MOVEIT_MOVE_GROUP_INTERFACE_MOVE_GROUP_INTERFACE_ +#pragma once #include #include @@ -58,7 +57,7 @@ namespace moveit { -/** \brief Simple interface to MoveIt! components */ +/** \brief Simple interface to MoveIt components */ namespace planning_interface { class MoveItErrorCode : public moveit_msgs::MoveItErrorCodes @@ -1003,5 +1002,3 @@ class MoveGroupInterface }; } // namespace planning_interface } // namespace moveit - -#endif diff --git a/moveit_ros/planning_interface/move_group_interface/src/demo.cpp b/moveit_ros/planning_interface/move_group_interface/src/demo.cpp index 6aba08bcc6..0bd7017fce 100644 --- a/moveit_ros/planning_interface/move_group_interface/src/demo.cpp +++ b/moveit_ros/planning_interface/move_group_interface/src/demo.cpp @@ -115,7 +115,7 @@ int main(int argc, char** argv) moveit::planning_interface::MoveGroupInterface group(argc > 1 ? argv[1] : "right_arm"); demoPlace(group); - sleep(2); + ros::Duration(2).sleep(); return 0; } diff --git a/moveit_ros/planning_interface/move_group_interface/src/wrap_python_move_group.cpp b/moveit_ros/planning_interface/move_group_interface/src/wrap_python_move_group.cpp index c367477343..50646a8777 100644 --- a/moveit_ros/planning_interface/move_group_interface/src/wrap_python_move_group.cpp +++ b/moveit_ros/planning_interface/move_group_interface/src/wrap_python_move_group.cpp @@ -486,7 +486,7 @@ class MoveGroupInterfaceWrapper : protected py_bindings_tools::ROScppInitializer std::string retimeTrajectory(const std::string& ref_state_str, const std::string& traj_str, double velocity_scaling_factor, double acceleration_scaling_factor, - std::string algorithm) + const std::string& algorithm) { // Convert reference state message to object moveit_msgs::RobotState ref_state_msg; @@ -536,17 +536,28 @@ class MoveGroupInterfaceWrapper : protected py_bindings_tools::ROScppInitializer } } - Eigen::MatrixXd getJacobianMatrixPython(bp::list& joint_values) + Eigen::MatrixXd getJacobianMatrixPython(const bp::list& joint_values, + const bp::object& reference_point = bp::object()) { - std::vector v = py_bindings_tools::doubleFromList(joint_values); + const std::vector v = py_bindings_tools::doubleFromList(joint_values); + std::vector ref; + if (reference_point.is_none()) + ref = { 0.0, 0.0, 0.0 }; + else + ref = py_bindings_tools::doubleFromList(reference_point); + if (ref.size() != 3) + throw std::invalid_argument("reference point needs to have 3 elements, got " + std::to_string(ref.size())); + robot_state::RobotState state(getRobotModel()); state.setToDefaultValues(); auto group = state.getJointModelGroup(getName()); state.setJointGroupPositions(group, v); - return state.getJacobian(group); + return state.getJacobian(group, Eigen::Map(&ref[0])); } }; +BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(getJacobianMatrixOverloads, getJacobianMatrixPython, 1, 2) + static void wrap_move_group_interface() { eigenpy::enableEigenPy(); @@ -683,7 +694,8 @@ static void wrap_move_group_interface() move_group_interface_class.def("get_named_targets", &MoveGroupInterfaceWrapper::getNamedTargetsPython); move_group_interface_class.def("get_named_target_values", &MoveGroupInterfaceWrapper::getNamedTargetValuesPython); move_group_interface_class.def("get_current_state_bounded", &MoveGroupInterfaceWrapper::getCurrentStateBoundedPython); - move_group_interface_class.def("get_jacobian_matrix", &MoveGroupInterfaceWrapper::getJacobianMatrixPython); + move_group_interface_class.def("get_jacobian_matrix", &MoveGroupInterfaceWrapper::getJacobianMatrixPython, + getJacobianMatrixOverloads()); } } // namespace planning_interface } // namespace moveit diff --git a/moveit_ros/planning_interface/package.xml b/moveit_ros/planning_interface/package.xml index 3690783e3f..5c57d296b1 100644 --- a/moveit_ros/planning_interface/package.xml +++ b/moveit_ros/planning_interface/package.xml @@ -1,13 +1,13 @@ moveit_ros_planning_interface 1.0.1 - Components of MoveIt! that offer simpler interfaces to planning and execution + Components of MoveIt that offer simpler interfaces to planning and execution Ioan Sucan Michael Ferguson Michael Görner - MoveIt! Release Team + MoveIt Release Team BSD diff --git a/moveit_ros/planning_interface/planning_scene_interface/CMakeLists.txt b/moveit_ros/planning_interface/planning_scene_interface/CMakeLists.txt index 7658b2583e..6a3b1a3f9b 100644 --- a/moveit_ros/planning_interface/planning_scene_interface/CMakeLists.txt +++ b/moveit_ros/planning_interface/planning_scene_interface/CMakeLists.txt @@ -9,13 +9,16 @@ set_target_properties(${MOVEIT_LIB_NAME}_python PROPERTIES VERSION "${${PROJECT_ target_link_libraries(${MOVEIT_LIB_NAME}_python ${MOVEIT_LIB_NAME} ${PYTHON_LIBRARIES} ${catkin_LIBRARIES} ${Boost_LIBRARIES} moveit_py_bindings_tools) set_target_properties(${MOVEIT_LIB_NAME}_python PROPERTIES OUTPUT_NAME _moveit_planning_scene_interface PREFIX "") set_target_properties(${MOVEIT_LIB_NAME}_python PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CATKIN_DEVEL_PREFIX}/${CATKIN_PACKAGE_PYTHON_DESTINATION}") +if(WIN32) + set_target_properties(${MOVEIT_LIB_NAME}_python PROPERTIES SUFFIX .pyd) +endif(WIN32) install(TARGETS ${MOVEIT_LIB_NAME} ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} - LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}) + LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}) install(TARGETS ${MOVEIT_LIB_NAME}_python - ARCHIVE DESTINATION ${CATKIN_PACKAGE_PYTHON_DESTINATION} - LIBRARY DESTINATION ${CATKIN_PACKAGE_PYTHON_DESTINATION}) + DESTINATION ${CATKIN_PACKAGE_PYTHON_DESTINATION}) install(DIRECTORY include/ DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}) diff --git a/moveit_ros/planning_interface/planning_scene_interface/include/moveit/planning_scene_interface/planning_scene_interface.h b/moveit_ros/planning_interface/planning_scene_interface/include/moveit/planning_scene_interface/planning_scene_interface.h index d421b5484a..9dc25385e0 100644 --- a/moveit_ros/planning_interface/planning_scene_interface/include/moveit/planning_scene_interface/planning_scene_interface.h +++ b/moveit_ros/planning_interface/planning_scene_interface/include/moveit/planning_scene_interface/planning_scene_interface.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_PLANNING_INTERFACE_PLANNING_SCENE_INTERFACE_ -#define MOVEIT_PLANNING_INTERFACE_PLANNING_SCENE_INTERFACE_ +#pragma once #include #include @@ -146,5 +145,3 @@ class PlanningSceneInterface }; } } - -#endif diff --git a/moveit_ros/planning_interface/planning_scene_interface/src/planning_scene_interface.cpp b/moveit_ros/planning_interface/planning_scene_interface/src/planning_scene_interface.cpp index ea61ff3d02..aaec69288f 100644 --- a/moveit_ros/planning_interface/planning_scene_interface/src/planning_scene_interface.cpp +++ b/moveit_ros/planning_interface/planning_scene_interface/src/planning_scene_interface.cpp @@ -45,17 +45,22 @@ namespace moveit { namespace planning_interface { +static const std::string LOGNAME = "planning_scene_interface"; + class PlanningSceneInterface::PlanningSceneInterfaceImpl { public: explicit PlanningSceneInterfaceImpl(const std::string& ns = "") { node_handle_ = ros::NodeHandle(ns); + planning_scene_diff_publisher_ = node_handle_.advertise("planning_scene", 1); planning_scene_service_ = node_handle_.serviceClient(move_group::GET_PLANNING_SCENE_SERVICE_NAME); apply_planning_scene_service_ = node_handle_.serviceClient(move_group::APPLY_PLANNING_SCENE_SERVICE_NAME); - planning_scene_diff_publisher_ = node_handle_.advertise("planning_scene", 1); + + waitForService(planning_scene_service_); + waitForService(apply_planning_scene_service_); } std::vector getKnownObjectNames(bool with_type) @@ -89,7 +94,7 @@ class PlanningSceneInterface::PlanningSceneInterfaceImpl request.components.components = request.components.WORLD_OBJECT_GEOMETRY; if (!planning_scene_service_.call(request, response)) { - ROS_WARN_NAMED("planning_scene_interface", "Could not call planning scene service to get object names"); + ROS_WARN_NAMED(LOGNAME, "Could not call planning scene service to get object names"); return result; } @@ -133,7 +138,7 @@ class PlanningSceneInterface::PlanningSceneInterfaceImpl request.components.components = request.components.WORLD_OBJECT_GEOMETRY; if (!planning_scene_service_.call(request, response)) { - ROS_WARN_NAMED("planning_scene_interface", "Could not call planning scene service to get object names"); + ROS_WARN_NAMED(LOGNAME, "Could not call planning scene service to get object names"); return result; } @@ -160,7 +165,7 @@ class PlanningSceneInterface::PlanningSceneInterfaceImpl request.components.components = request.components.WORLD_OBJECT_GEOMETRY; if (!planning_scene_service_.call(request, response)) { - ROS_WARN_NAMED("planning_scene_interface", "Could not call planning scene service to get object geometries"); + ROS_WARN_NAMED(LOGNAME, "Could not call planning scene service to get object geometries"); return result; } @@ -184,8 +189,7 @@ class PlanningSceneInterface::PlanningSceneInterfaceImpl request.components.components = request.components.ROBOT_STATE_ATTACHED_OBJECTS; if (!planning_scene_service_.call(request, response)) { - ROS_WARN_NAMED("planning_scene_interface", - "Could not call planning scene service to get attached object geometries"); + ROS_WARN_NAMED(LOGNAME, "Could not call planning scene service to get attached object geometries"); return result; } @@ -208,7 +212,7 @@ class PlanningSceneInterface::PlanningSceneInterfaceImpl request.scene = planning_scene; if (!apply_planning_scene_service_.call(request, response)) { - ROS_WARN_NAMED("planning_scene_interface", "Failed to call ApplyPlanningScene service"); + ROS_WARN_NAMED(LOGNAME, "Failed to call ApplyPlanningScene service"); return false; } return response.success; @@ -248,6 +252,17 @@ class PlanningSceneInterface::PlanningSceneInterfaceImpl } private: + void waitForService(ros::ServiceClient& srv) + { + ros::Duration time_before_warning(5.0); + srv.waitForExistence(time_before_warning); + if (!srv.exists()) + { + ROS_WARN_STREAM_NAMED(LOGNAME, "service '" << srv.getService() << "' not advertised yet. Continue waiting..."); + srv.waitForExistence(); + } + } + ros::NodeHandle node_handle_; ros::ServiceClient planning_scene_service_; ros::ServiceClient apply_planning_scene_service_; diff --git a/moveit_ros/planning_interface/py_bindings_tools/CMakeLists.txt b/moveit_ros/planning_interface/py_bindings_tools/CMakeLists.txt index 6d1e6899a6..1f82d7e4dc 100644 --- a/moveit_ros/planning_interface/py_bindings_tools/CMakeLists.txt +++ b/moveit_ros/planning_interface/py_bindings_tools/CMakeLists.txt @@ -6,16 +6,19 @@ target_link_libraries(${MOVEIT_LIB_NAME} ${catkin_LIBRARIES} ${Boost_LIBRARIES} install(TARGETS ${MOVEIT_LIB_NAME} ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} - LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}) + LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}) add_library(${MOVEIT_LIB_NAME}_python src/wrap_python_roscpp_initializer.cpp) target_link_libraries(${MOVEIT_LIB_NAME}_python ${MOVEIT_LIB_NAME} ${PYTHON_LIBRARIES} ${catkin_LIBRARIES} ${Boost_LIBRARIES}) set_target_properties(${MOVEIT_LIB_NAME}_python PROPERTIES VERSION "${${PROJECT_NAME}_VERSION}") set_target_properties(${MOVEIT_LIB_NAME}_python PROPERTIES OUTPUT_NAME _moveit_roscpp_initializer PREFIX "") set_target_properties(${MOVEIT_LIB_NAME}_python PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CATKIN_DEVEL_PREFIX}/${CATKIN_PACKAGE_PYTHON_DESTINATION}") +if(WIN32) + set_target_properties(${MOVEIT_LIB_NAME}_python PROPERTIES SUFFIX .pyd) +endif(WIN32) install(TARGETS ${MOVEIT_LIB_NAME}_python - ARCHIVE DESTINATION ${CATKIN_PACKAGE_PYTHON_DESTINATION} - LIBRARY DESTINATION ${CATKIN_PACKAGE_PYTHON_DESTINATION}) + DESTINATION ${CATKIN_PACKAGE_PYTHON_DESTINATION}) install(DIRECTORY include/ DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}) diff --git a/moveit_ros/planning_interface/py_bindings_tools/include/moveit/py_bindings_tools/py_conversions.h b/moveit_ros/planning_interface/py_bindings_tools/include/moveit/py_bindings_tools/py_conversions.h index fbf4d191ff..47825360ba 100644 --- a/moveit_ros/planning_interface/py_bindings_tools/include/moveit/py_bindings_tools/py_conversions.h +++ b/moveit_ros/planning_interface/py_bindings_tools/include/moveit/py_bindings_tools/py_conversions.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_PY_BINDINGS_TOOLS_PY_CONVERSIONS_ -#define MOVEIT_PY_BINDINGS_TOOLS_PY_CONVERSIONS_ +#pragma once #include #include @@ -95,5 +94,3 @@ boost::python::list listFromString(const std::vector& v) } } } - -#endif diff --git a/moveit_ros/planning_interface/py_bindings_tools/include/moveit/py_bindings_tools/roscpp_initializer.h b/moveit_ros/planning_interface/py_bindings_tools/include/moveit/py_bindings_tools/roscpp_initializer.h index 3796d64760..1effb467a5 100644 --- a/moveit_ros/planning_interface/py_bindings_tools/include/moveit/py_bindings_tools/roscpp_initializer.h +++ b/moveit_ros/planning_interface/py_bindings_tools/include/moveit/py_bindings_tools/roscpp_initializer.h @@ -34,15 +34,14 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_PY_BINDINGS_TOOLS_ROSCPP_INITIALIZER_ -#define MOVEIT_PY_BINDINGS_TOOLS_ROSCPP_INITIALIZER_ +#pragma once #include #include namespace moveit { -/** \brief Tools for creating python bindings for MoveIt! */ +/** \brief Tools for creating python bindings for MoveIt */ namespace py_bindings_tools { /** \brief The constructor of this class ensures that ros::init() has @@ -73,5 +72,3 @@ void roscpp_init(); void roscpp_shutdown(); } } - -#endif diff --git a/moveit_ros/planning_interface/py_bindings_tools/include/moveit/py_bindings_tools/serialize_msg.h b/moveit_ros/planning_interface/py_bindings_tools/include/moveit/py_bindings_tools/serialize_msg.h index 5000fccbbe..5b9a9a306f 100644 --- a/moveit_ros/planning_interface/py_bindings_tools/include/moveit/py_bindings_tools/serialize_msg.h +++ b/moveit_ros/planning_interface/py_bindings_tools/include/moveit/py_bindings_tools/serialize_msg.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_PY_BINDINGS_TOOLS_SERIALIZE_MSG_ -#define MOVEIT_PY_BINDINGS_TOOLS_SERIALIZE_MSG_ +#pragma once #include @@ -71,5 +70,3 @@ void deserializeMsg(const std::string& data, T& msg) } } } - -#endif diff --git a/moveit_ros/planning_interface/robot_interface/CMakeLists.txt b/moveit_ros/planning_interface/robot_interface/CMakeLists.txt index 56cb7b4098..3944155fbf 100644 --- a/moveit_ros/planning_interface/robot_interface/CMakeLists.txt +++ b/moveit_ros/planning_interface/robot_interface/CMakeLists.txt @@ -6,7 +6,9 @@ target_link_libraries(${MOVEIT_LIB_NAME}_python ${PYTHON_LIBRARIES} ${catkin_LIB set_target_properties(${MOVEIT_LIB_NAME}_python PROPERTIES VERSION "${${PROJECT_NAME}_VERSION}") set_target_properties(${MOVEIT_LIB_NAME}_python PROPERTIES OUTPUT_NAME _moveit_robot_interface PREFIX "") set_target_properties(${MOVEIT_LIB_NAME}_python PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CATKIN_DEVEL_PREFIX}/${CATKIN_PACKAGE_PYTHON_DESTINATION}") +if(WIN32) + set_target_properties(${MOVEIT_LIB_NAME}_python PROPERTIES SUFFIX .pyd) +endif(WIN32) install(TARGETS ${MOVEIT_LIB_NAME}_python - ARCHIVE DESTINATION ${CATKIN_PACKAGE_PYTHON_DESTINATION} - LIBRARY DESTINATION ${CATKIN_PACKAGE_PYTHON_DESTINATION}) + DESTINATION ${CATKIN_PACKAGE_PYTHON_DESTINATION}) diff --git a/moveit_ros/planning_interface/test/python_move_group.py b/moveit_ros/planning_interface/test/python_move_group.py index 4e388a6f16..0cc27cd09d 100755 --- a/moveit_ros/planning_interface/test/python_move_group.py +++ b/moveit_ros/planning_interface/test/python_move_group.py @@ -80,6 +80,13 @@ def test_get_jacobian_matrix(self): [ 1. , 0. , 0. , 0. , 0. , 0. ]]) self.assertTrue(np.allclose(result, expected)) + result = self.group.get_jacobian_matrix(current, [1.0, 1.0, 1.0]) + expected = np.array([[ 1. , 1.8 , -1.2 , 0. , -1. , 0. ], + [ 1.89, 0. , 0. , 1. , 0. , 1. ], + [ 0. , -1.74, 1.74, 1. , 1.1 , 1. ], + [ 0. , 0. , 0. , -1. , 0. , -1. ], + [ 0. , 1. , -1. , 0. , -1. , 0. ], + [ 1. , 0. , 0. , 0. , 0. , 0. ]]) if __name__ == '__main__': PKGNAME = 'moveit_ros_planning_interface' diff --git a/moveit_ros/robot_interaction/CHANGELOG.rst b/moveit_ros/robot_interaction/CHANGELOG.rst index 93a596b313..9851f4f460 100644 --- a/moveit_ros/robot_interaction/CHANGELOG.rst +++ b/moveit_ros/robot_interaction/CHANGELOG.rst @@ -46,7 +46,7 @@ Changelog for package moveit_ros_robot_interaction 0.10.2 (2018-10-24) ------------------- -* [fix] Text refrences to MoveIt! (`#1020 `_) +* [fix] Text refrences to MoveIt (`#1020 `_) * Contributors: Mohmmad Ayman, Robert Haschke, mike lautman 0.10.1 (2018-05-25) diff --git a/moveit_ros/robot_interaction/CMakeLists.txt b/moveit_ros/robot_interaction/CMakeLists.txt index 08ef6ef7fd..d18735a809 100644 --- a/moveit_ros/robot_interaction/CMakeLists.txt +++ b/moveit_ros/robot_interaction/CMakeLists.txt @@ -1,7 +1,8 @@ -cmake_minimum_required(VERSION 2.8.12) +cmake_minimum_required(VERSION 3.1.3) project(moveit_ros_robot_interaction) -add_compile_options(-std=c++14) +set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_EXTENSIONS OFF) if(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Release) @@ -53,7 +54,10 @@ if (CATKIN_ENABLE_TESTING) ${Boost_LIBRARIES}) endif() -install(TARGETS ${MOVEIT_LIB_NAME} LIBRARY DESTINATION ${CATKIN_GLOBAL_LIB_DESTINATION}) +install(TARGETS ${MOVEIT_LIB_NAME} + LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}) install(DIRECTORY include/ DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}) install(DIRECTORY resources DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}) diff --git a/moveit_ros/robot_interaction/include/moveit/robot_interaction/interaction.h b/moveit_ros/robot_interaction/include/moveit/robot_interaction/interaction.h index 1fdafbf667..b0027cf0f2 100644 --- a/moveit_ros/robot_interaction/include/moveit/robot_interaction/interaction.h +++ b/moveit_ros/robot_interaction/include/moveit/robot_interaction/interaction.h @@ -34,8 +34,7 @@ /* Author: Acorn Pooley */ -#ifndef MOVEIT_ROBOT_INTERACTION_INTERACTION_ -#define MOVEIT_ROBOT_INTERACTION_INTERACTION_ +#pragma once #include #include @@ -175,5 +174,3 @@ struct JointInteraction double size; }; } - -#endif diff --git a/moveit_ros/robot_interaction/include/moveit/robot_interaction/interaction_handler.h b/moveit_ros/robot_interaction/include/moveit/robot_interaction/interaction_handler.h index 5cc6ed89a5..3ea644e86a 100644 --- a/moveit_ros/robot_interaction/include/moveit/robot_interaction/interaction_handler.h +++ b/moveit_ros/robot_interaction/include/moveit/robot_interaction/interaction_handler.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan, Adam Leeper */ -#ifndef MOVEIT_ROBOT_INTERACTION_INTERACTION_HANDLER_ -#define MOVEIT_ROBOT_INTERACTION_INTERACTION_HANDLER_ +#pragma once #include #include @@ -311,5 +310,3 @@ class InteractionHandler : public LockedRobotState static std::string fixName(std::string name); }; } - -#endif diff --git a/moveit_ros/robot_interaction/include/moveit/robot_interaction/interactive_marker_helpers.h b/moveit_ros/robot_interaction/include/moveit/robot_interaction/interactive_marker_helpers.h index 5810e7d244..16e821eab0 100644 --- a/moveit_ros/robot_interaction/include/moveit/robot_interaction/interactive_marker_helpers.h +++ b/moveit_ros/robot_interaction/include/moveit/robot_interaction/interactive_marker_helpers.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan, Acorn Pooley, Adam Leeper */ -#ifndef MOVEIT_ROBOT_INTERACTION_INTERACTIVE_MARKER_HELPERS_ -#define MOVEIT_ROBOT_INTERACTION_INTERACTIVE_MARKER_HELPERS_ +#pragma once #include #include @@ -69,5 +68,3 @@ void addPositionControl(visualization_msgs::InteractiveMarker& int_marker, bool void addViewPlaneControl(visualization_msgs::InteractiveMarker& int_marker, double radius, const std_msgs::ColorRGBA& color, bool position = true, bool orientation = true); } - -#endif diff --git a/moveit_ros/robot_interaction/include/moveit/robot_interaction/kinematic_options.h b/moveit_ros/robot_interaction/include/moveit/robot_interaction/kinematic_options.h index 43b8e7bbc2..8a0248a60a 100644 --- a/moveit_ros/robot_interaction/include/moveit/robot_interaction/kinematic_options.h +++ b/moveit_ros/robot_interaction/include/moveit/robot_interaction/kinematic_options.h @@ -34,8 +34,7 @@ /* Author: Acorn Pooley */ -#ifndef MOVEIT_ROBOT_INTERACTION_KINEMATIC_OPTIONS_ -#define MOVEIT_ROBOT_INTERACTION_KINEMATIC_OPTIONS_ +#pragma once #include #include @@ -89,5 +88,3 @@ struct KinematicOptions kinematics::KinematicsQueryOptions options_; }; } - -#endif diff --git a/moveit_ros/robot_interaction/include/moveit/robot_interaction/kinematic_options_map.h b/moveit_ros/robot_interaction/include/moveit/robot_interaction/kinematic_options_map.h index 033fd0ac4b..f9c6a986b9 100644 --- a/moveit_ros/robot_interaction/include/moveit/robot_interaction/kinematic_options_map.h +++ b/moveit_ros/robot_interaction/include/moveit/robot_interaction/kinematic_options_map.h @@ -34,8 +34,7 @@ /* Author: Acorn Pooley */ -#ifndef MOVEIT_ROBOT_INTERACTION_KINEMATIC_OPTIONS_MAP_ -#define MOVEIT_ROBOT_INTERACTION_KINEMATIC_OPTIONS_MAP_ +#pragma once #include #include @@ -104,5 +103,3 @@ class KinematicOptionsMap M_options options_; }; } - -#endif diff --git a/moveit_ros/robot_interaction/include/moveit/robot_interaction/locked_robot_state.h b/moveit_ros/robot_interaction/include/moveit/robot_interaction/locked_robot_state.h index 286a86a95d..fd6b3f3616 100644 --- a/moveit_ros/robot_interaction/include/moveit/robot_interaction/locked_robot_state.h +++ b/moveit_ros/robot_interaction/include/moveit/robot_interaction/locked_robot_state.h @@ -35,8 +35,7 @@ /* Author: Ioan Sucan, Acorn Pooley */ -#ifndef MOVEIT_ROBOT_INTERACTION_LOCKED_ROBOT_STATE_ -#define MOVEIT_ROBOT_INTERACTION_LOCKED_ROBOT_STATE_ +#pragma once #include #include @@ -109,5 +108,3 @@ class LockedRobotState robot_state::RobotStatePtr state_; }; } - -#endif diff --git a/moveit_ros/robot_interaction/include/moveit/robot_interaction/robot_interaction.h b/moveit_ros/robot_interaction/include/moveit/robot_interaction/robot_interaction.h index a5ebcc0001..494386af0f 100644 --- a/moveit_ros/robot_interaction/include/moveit/robot_interaction/robot_interaction.h +++ b/moveit_ros/robot_interaction/include/moveit/robot_interaction/robot_interaction.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan, Adam Leeper */ -#ifndef MOVEIT_ROBOT_INTERACTION_ROBOT_INTERACTION_ -#define MOVEIT_ROBOT_INTERACTION_ROBOT_INTERACTION_ +#pragma once #include #include @@ -234,5 +233,3 @@ class RobotInteraction KinematicOptionsMapPtr kinematic_options_map_; }; } - -#endif diff --git a/moveit_ros/robot_interaction/package.xml b/moveit_ros/robot_interaction/package.xml index 25cc5b7107..83116910cf 100644 --- a/moveit_ros/robot_interaction/package.xml +++ b/moveit_ros/robot_interaction/package.xml @@ -1,13 +1,13 @@ moveit_ros_robot_interaction 1.0.1 - Components of MoveIt! that offer interaction via interactive markers + Components of MoveIt that offer interaction via interactive markers Ioan Sucan Michael Ferguson Robert Haschke - MoveIt! Release Team + MoveIt Release Team BSD diff --git a/moveit_ros/visualization/CMakeLists.txt b/moveit_ros/visualization/CMakeLists.txt index 5d79b0c50b..ba60500eb6 100644 --- a/moveit_ros/visualization/CMakeLists.txt +++ b/moveit_ros/visualization/CMakeLists.txt @@ -1,7 +1,9 @@ -cmake_minimum_required(VERSION 2.8.12) +cmake_minimum_required(VERSION 3.1.3) project(moveit_ros_visualization) -add_compile_options(-std=c++14) +set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_EXTENSIONS OFF) + if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") # suppress warning in Ogre add_compile_options(-Wno-deprecated-register) diff --git a/moveit_ros/visualization/motion_planning_rviz_plugin/CMakeLists.txt b/moveit_ros/visualization/motion_planning_rviz_plugin/CMakeLists.txt index 41c9b07b59..6f4ce1f245 100644 --- a/moveit_ros/visualization/motion_planning_rviz_plugin/CMakeLists.txt +++ b/moveit_ros/visualization/motion_planning_rviz_plugin/CMakeLists.txt @@ -36,4 +36,5 @@ install(DIRECTORY include/ DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}) install(TARGETS ${MOVEIT_LIB_NAME} ${MOVEIT_LIB_NAME}_core ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} - LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}) + LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}) diff --git a/moveit_ros/visualization/motion_planning_rviz_plugin/include/moveit/motion_planning_rviz_plugin/motion_planning_display.h b/moveit_ros/visualization/motion_planning_rviz_plugin/include/moveit/motion_planning_rviz_plugin/motion_planning_display.h index a8c30c9cb0..52cd9b5640 100644 --- a/moveit_ros/visualization/motion_planning_rviz_plugin/include/moveit/motion_planning_rviz_plugin/motion_planning_display.h +++ b/moveit_ros/visualization/motion_planning_rviz_plugin/include/moveit/motion_planning_rviz_plugin/motion_planning_display.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan, Dave Coleman, Adam Leeper, Sachin Chitta */ -#ifndef MOVEIT_MOTION_PLANNING_RVIZ_PLUGIN_MOTION_PLANNING_DISPLAY_ -#define MOVEIT_MOTION_PLANNING_RVIZ_PLUGIN_MOTION_PLANNING_DISPLAY_ +#pragma once #include #include @@ -301,5 +300,3 @@ private Q_SLOTS: }; } // namespace moveit_rviz_plugin - -#endif diff --git a/moveit_ros/visualization/motion_planning_rviz_plugin/include/moveit/motion_planning_rviz_plugin/motion_planning_frame.h b/moveit_ros/visualization/motion_planning_rviz_plugin/include/moveit/motion_planning_rviz_plugin/motion_planning_frame.h index d49e100204..e9a7398a90 100644 --- a/moveit_ros/visualization/motion_planning_rviz_plugin/include/moveit/motion_planning_rviz_plugin/motion_planning_frame.h +++ b/moveit_ros/visualization/motion_planning_rviz_plugin/include/moveit/motion_planning_rviz_plugin/motion_planning_frame.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_MOTION_PLANNING_RVIZ_PLUGIN_MOTION_PLANNING_FRAME_ -#define MOVEIT_MOTION_PLANNING_RVIZ_PLUGIN_MOTION_PLANNING_FRAME_ +#pragma once #include #include @@ -315,7 +314,7 @@ private Q_SLOTS: ros::Publisher planning_scene_publisher_; ros::Publisher planning_scene_world_publisher_; - collision_detection::CollisionWorld::ObjectConstPtr scaled_object_; + collision_detection::CollisionEnv::ObjectConstPtr scaled_object_; std::vector > known_collision_objects_; long unsigned int known_collision_objects_version_; @@ -365,5 +364,3 @@ void MotionPlanningFrame::waitForAction(const T& action, const ros::NodeHandle& ROS_DEBUG("Connected to '%s'", name.c_str()); }; } - -#endif diff --git a/moveit_ros/visualization/motion_planning_rviz_plugin/include/moveit/motion_planning_rviz_plugin/motion_planning_param_widget.h b/moveit_ros/visualization/motion_planning_rviz_plugin/include/moveit/motion_planning_rviz_plugin/motion_planning_param_widget.h index 91242225c4..99658c4f2d 100644 --- a/moveit_ros/visualization/motion_planning_rviz_plugin/include/moveit/motion_planning_rviz_plugin/motion_planning_param_widget.h +++ b/moveit_ros/visualization/motion_planning_rviz_plugin/include/moveit/motion_planning_rviz_plugin/motion_planning_param_widget.h @@ -34,8 +34,7 @@ /* Author: Robert Haschke */ -#ifndef MOVEIT_MOTION_PLANNING_RVIZ_PLUGIN_MOTION_PLANNING_PARAM_WIDGET_ -#define MOVEIT_MOTION_PLANNING_RVIZ_PLUGIN_MOTION_PLANNING_PARAM_WIDGET_ +#pragma once #include #include @@ -77,5 +76,3 @@ private Q_SLOTS: std::string planner_id_; }; } - -#endif diff --git a/moveit_ros/visualization/motion_planning_rviz_plugin/src/motion_planning_frame_context.cpp b/moveit_ros/visualization/motion_planning_rviz_plugin/src/motion_planning_frame_context.cpp index f2773ed915..87c1321723 100644 --- a/moveit_ros/visualization/motion_planning_rviz_plugin/src/motion_planning_frame_context.cpp +++ b/moveit_ros/visualization/motion_planning_rviz_plugin/src/motion_planning_frame_context.cpp @@ -81,7 +81,7 @@ void MotionPlanningFrame::planningAlgorithmIndexChanged(int index) void MotionPlanningFrame::resetDbButtonClicked() { - if (QMessageBox::warning(this, "Data about to be deleted", "The following dialog will allow you to drop a MoveIt! " + if (QMessageBox::warning(this, "Data about to be deleted", "The following dialog will allow you to drop a MoveIt " "Warehouse database. Are you sure you want to continue?", QMessageBox::Yes | QMessageBox::No) == QMessageBox::No) return; diff --git a/moveit_ros/visualization/motion_planning_rviz_plugin/src/motion_planning_frame_objects.cpp b/moveit_ros/visualization/motion_planning_rviz_plugin/src/motion_planning_frame_objects.cpp index 9914f945de..81b7e43565 100644 --- a/moveit_ros/visualization/motion_planning_rviz_plugin/src/motion_planning_frame_objects.cpp +++ b/moveit_ros/visualization/motion_planning_rviz_plugin/src/motion_planning_frame_objects.cpp @@ -156,7 +156,7 @@ void MotionPlanningFrame::removeObjectButtonClicked() } } -static QString decideStatusText(const collision_detection::CollisionWorld::ObjectConstPtr& obj) +static QString decideStatusText(const collision_detection::CollisionEnv::ObjectConstPtr& obj) { QString status_text = "'" + QString::fromStdString(obj->id_) + "' is a collision object with "; if (obj->shapes_.empty()) @@ -228,7 +228,7 @@ void MotionPlanningFrame::selectedCollisionObjectChanged() Eigen::Isometry3d obj_pose; { const planning_scene_monitor::LockedPlanningSceneRO& ps = planning_display_->getPlanningSceneRO(); - const collision_detection::CollisionWorld::ObjectConstPtr& obj = + const collision_detection::CollisionEnv::ObjectConstPtr& obj = ps->getWorld()->getObject(sel[0]->text().toStdString()); if (obj) { @@ -302,7 +302,7 @@ void MotionPlanningFrame::updateCollisionObjectPose(bool update_marker_position) planning_scene_monitor::LockedPlanningSceneRW ps = planning_display_->getPlanningSceneRW(); if (ps) { - collision_detection::CollisionWorld::ObjectConstPtr obj = ps->getWorld()->getObject(sel[0]->text().toStdString()); + collision_detection::CollisionEnv::ObjectConstPtr obj = ps->getWorld()->getObject(sel[0]->text().toStdString()); if (obj && obj->shapes_.size() == 1) { Eigen::Isometry3d p; @@ -392,7 +392,7 @@ void MotionPlanningFrame::copySelectedCollisionObject() for (const QListWidgetItem* item : sel) { std::string name = item->text().toStdString(); - collision_detection::CollisionWorld::ObjectConstPtr obj = ps->getWorld()->getObject(name); + collision_detection::CollisionEnv::ObjectConstPtr obj = ps->getWorld()->getObject(name); if (!obj) continue; @@ -689,7 +689,7 @@ void MotionPlanningFrame::createSceneInteractiveMarker() if (!ps) return; - const collision_detection::CollisionWorld::ObjectConstPtr& obj = + const collision_detection::CollisionEnv::ObjectConstPtr& obj = ps->getWorld()->getObject(sel[0]->text().toStdString()); if (obj && obj->shapes_.size() == 1) { @@ -755,7 +755,7 @@ void MotionPlanningFrame::renameCollisionObject(QListWidgetItem* item) if (item->checkState() == Qt::Unchecked) { planning_scene_monitor::LockedPlanningSceneRW ps = planning_display_->getPlanningSceneRW(); - collision_detection::CollisionWorld::ObjectConstPtr obj = + collision_detection::CollisionEnv::ObjectConstPtr obj = ps->getWorld()->getObject(known_collision_objects_[item->type()].first); if (obj) { diff --git a/moveit_ros/visualization/motion_planning_rviz_plugin/src/ui/motion_planning_rviz_plugin_frame.ui b/moveit_ros/visualization/motion_planning_rviz_plugin/src/ui/motion_planning_rviz_plugin_frame.ui index b0debfae37..0f6825b916 100644 --- a/moveit_ros/visualization/motion_planning_rviz_plugin/src/ui/motion_planning_rviz_plugin_frame.ui +++ b/moveit_ros/visualization/motion_planning_rviz_plugin/src/ui/motion_planning_rviz_plugin_frame.ui @@ -11,7 +11,7 @@ - MoveIt! Planning Frame + MoveIt Planning Frame diff --git a/moveit_ros/visualization/package.xml b/moveit_ros/visualization/package.xml index 7b93f92cb1..a0f4183906 100644 --- a/moveit_ros/visualization/package.xml +++ b/moveit_ros/visualization/package.xml @@ -1,7 +1,7 @@ moveit_ros_visualization 1.0.1 - Components of MoveIt! that offer visualization + Components of MoveIt that offer visualization Ioan Sucan Dave Coleman @@ -9,7 +9,7 @@ Jon Binney Michael Ferguson - MoveIt! Release Team + MoveIt Release Team BSD diff --git a/moveit_ros/visualization/planning_scene_rviz_plugin/CMakeLists.txt b/moveit_ros/visualization/planning_scene_rviz_plugin/CMakeLists.txt index 77a06066ac..109bb569f6 100644 --- a/moveit_ros/visualization/planning_scene_rviz_plugin/CMakeLists.txt +++ b/moveit_ros/visualization/planning_scene_rviz_plugin/CMakeLists.txt @@ -14,4 +14,5 @@ install(DIRECTORY include/ DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}) install(TARGETS ${MOVEIT_LIB_NAME}_core ${MOVEIT_LIB_NAME} ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} - LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}) + LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}) diff --git a/moveit_ros/visualization/planning_scene_rviz_plugin/include/moveit/planning_scene_rviz_plugin/planning_scene_display.h b/moveit_ros/visualization/planning_scene_rviz_plugin/include/moveit/planning_scene_rviz_plugin/planning_scene_display.h index b18c4a0140..06e30bef58 100644 --- a/moveit_ros/visualization/planning_scene_rviz_plugin/include/moveit/planning_scene_rviz_plugin/planning_scene_display.h +++ b/moveit_ros/visualization/planning_scene_rviz_plugin/include/moveit/planning_scene_rviz_plugin/planning_scene_display.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_VISUALIZATION_SCENE_DISPLAY_RVIZ_PLUGIN_SCENE_DISPLAY_ -#define MOVEIT_VISUALIZATION_SCENE_DISPLAY_RVIZ_PLUGIN_SCENE_DISPLAY_ +#pragma once #include @@ -213,5 +212,3 @@ protected Q_SLOTS: }; } // namespace moveit_rviz_plugin - -#endif diff --git a/moveit_ros/visualization/robot_state_rviz_plugin/CMakeLists.txt b/moveit_ros/visualization/robot_state_rviz_plugin/CMakeLists.txt index 6a4d92f2f7..8db0bf29fc 100644 --- a/moveit_ros/visualization/robot_state_rviz_plugin/CMakeLists.txt +++ b/moveit_ros/visualization/robot_state_rviz_plugin/CMakeLists.txt @@ -15,5 +15,6 @@ install(DIRECTORY include/ DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}) install(TARGETS ${MOVEIT_LIB_NAME}_core ${MOVEIT_LIB_NAME} ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} - LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}) + LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}) diff --git a/moveit_ros/visualization/robot_state_rviz_plugin/include/moveit/robot_state_rviz_plugin/robot_state_display.h b/moveit_ros/visualization/robot_state_rviz_plugin/include/moveit/robot_state_rviz_plugin/robot_state_display.h index c1692d94d7..e087dd3a62 100644 --- a/moveit_ros/visualization/robot_state_rviz_plugin/include/moveit/robot_state_rviz_plugin/robot_state_display.h +++ b/moveit_ros/visualization/robot_state_rviz_plugin/include/moveit/robot_state_rviz_plugin/robot_state_display.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_VISUALIZATION_ROBOT_STATE_DISPLAY_RVIZ_ROBOT_STATE_DISPLAY_ -#define MOVEIT_VISUALIZATION_ROBOT_STATE_DISPLAY_RVIZ_ROBOT_STATE_DISPLAY_ +#pragma once #include @@ -146,5 +145,3 @@ private Q_SLOTS: }; } // namespace moveit_rviz_plugin - -#endif diff --git a/moveit_ros/visualization/robot_state_rviz_plugin/src/robot_state_display.cpp b/moveit_ros/visualization/robot_state_rviz_plugin/src/robot_state_display.cpp index 0865765a83..98e024fea0 100644 --- a/moveit_ros/visualization/robot_state_rviz_plugin/src/robot_state_display.cpp +++ b/moveit_ros/visualization/robot_state_rviz_plugin/src/robot_state_display.cpp @@ -36,6 +36,7 @@ #include #include +#include #include #include @@ -289,6 +290,8 @@ void RobotStateDisplay::changedRobotStateTopic() if (static_cast(robot_state_)) robot_state_->setToDefaultValues(); update_state_ = true; + robot_->setVisible(false); + setStatus(rviz::StatusProperty::Warn, "RobotState", "No msg received"); robot_state_subscriber_ = root_nh_.subscribe(robot_state_topic_property_->getStdString(), 10, &RobotStateDisplay::newRobotStateCallback, this); @@ -303,17 +306,28 @@ void RobotStateDisplay::newRobotStateCallback(const moveit_msgs::DisplayRobotSta // possibly use TF to construct a robot_state::Transforms object to pass in to the conversion function? try { - robot_state::robotStateMsgToRobotState(state_msg->state, *robot_state_); + if (!moveit::core::isEmpty(state_msg->state)) + robot_state::robotStateMsgToRobotState(state_msg->state, *robot_state_); setRobotHighlights(state_msg->highlight_links); - setStatus(rviz::StatusProperty::Ok, "RobotState", ""); } catch (const moveit::Exception& e) { robot_state_->setToDefaultValues(); setRobotHighlights(moveit_msgs::DisplayRobotState::_highlight_links_type()); setStatus(rviz::StatusProperty::Error, "RobotState", e.what()); + robot_->setVisible(false); return; } + + if (robot_->isVisible() != !state_msg->hide) + { + robot_->setVisible(!state_msg->hide); + if (robot_->isVisible()) + setStatus(rviz::StatusProperty::Ok, "RobotState", ""); + else + setStatus(rviz::StatusProperty::Warn, "RobotState", "Hidden"); + } + update_state_ = true; } @@ -366,14 +380,13 @@ void RobotStateDisplay::loadRobotModel() root_link_name_property_->setStdString(getRobotModel()->getRootLinkName()); root_link_name_property_->blockSignals(old_state); update_state_ = true; - setStatus(rviz::StatusProperty::Ok, "RobotState", "Planning Model Loaded Successfully"); + setStatus(rviz::StatusProperty::Ok, "RobotModel", "Loaded successfully"); changedEnableVisualVisible(); changedEnableCollisionVisible(); - robot_->setVisible(true); } else - setStatus(rviz::StatusProperty::Error, "RobotState", "No Planning Model Loaded"); + setStatus(rviz::StatusProperty::Error, "RobotModel", "Loading failed"); highlights_.clear(); } diff --git a/moveit_ros/visualization/rviz_plugin_render_tools/CMakeLists.txt b/moveit_ros/visualization/rviz_plugin_render_tools/CMakeLists.txt index 9baca76cfb..a9769d25d1 100644 --- a/moveit_ros/visualization/rviz_plugin_render_tools/CMakeLists.txt +++ b/moveit_ros/visualization/rviz_plugin_render_tools/CMakeLists.txt @@ -35,4 +35,5 @@ install(DIRECTORY include/ DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}) install(TARGETS ${MOVEIT_LIB_NAME} ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} - LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}) + LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}) diff --git a/moveit_ros/visualization/rviz_plugin_render_tools/include/moveit/rviz_plugin_render_tools/octomap_render.h b/moveit_ros/visualization/rviz_plugin_render_tools/include/moveit/rviz_plugin_render_tools/octomap_render.h index 92bd6dd2bb..9c4f3c60b2 100644 --- a/moveit_ros/visualization/rviz_plugin_render_tools/include/moveit/rviz_plugin_render_tools/octomap_render.h +++ b/moveit_ros/visualization/rviz_plugin_render_tools/include/moveit/rviz_plugin_render_tools/octomap_render.h @@ -34,8 +34,7 @@ /* Author: Julius Kammerl */ -#ifndef MOVEIT_VISUALIZATION_SCENE_DISPLAY_RVIZ_OCTOMAP_RENDER_ -#define MOVEIT_VISUALIZATION_SCENE_DISPLAY_RVIZ_OCTOMAP_RENDER_ +#pragma once #include #include @@ -100,4 +99,3 @@ class OcTreeRender std::size_t octree_depth_; }; } -#endif diff --git a/moveit_ros/visualization/rviz_plugin_render_tools/include/moveit/rviz_plugin_render_tools/planning_link_updater.h b/moveit_ros/visualization/rviz_plugin_render_tools/include/moveit/rviz_plugin_render_tools/planning_link_updater.h index 0f8f417f37..0d757ef7c5 100644 --- a/moveit_ros/visualization/rviz_plugin_render_tools/include/moveit/rviz_plugin_render_tools/planning_link_updater.h +++ b/moveit_ros/visualization/rviz_plugin_render_tools/include/moveit/rviz_plugin_render_tools/planning_link_updater.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_PLANNING_SCENE_RVIZ_PLUGIN_PLANNING_LINK_UPDATER_ -#define MOVEIT_PLANNING_SCENE_RVIZ_PLUGIN_PLANNING_LINK_UPDATER_ +#pragma once #include #include @@ -58,5 +57,3 @@ class PlanningLinkUpdater : public rviz::LinkUpdater robot_state::RobotStateConstPtr kinematic_state_; }; } - -#endif diff --git a/moveit_ros/visualization/rviz_plugin_render_tools/include/moveit/rviz_plugin_render_tools/planning_scene_render.h b/moveit_ros/visualization/rviz_plugin_render_tools/include/moveit/rviz_plugin_render_tools/planning_scene_render.h index 84106db313..987425752c 100644 --- a/moveit_ros/visualization/rviz_plugin_render_tools/include/moveit/rviz_plugin_render_tools/planning_scene_render.h +++ b/moveit_ros/visualization/rviz_plugin_render_tools/include/moveit/rviz_plugin_render_tools/planning_scene_render.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_VISUALIZATION_SCENE_DISPLAY_RVIZ_PLUGIN_PLANNING_SCENE_RENDER_ -#define MOVEIT_VISUALIZATION_SCENE_DISPLAY_RVIZ_PLUGIN_PLANNING_SCENE_RENDER_ +#pragma once #include #include @@ -88,5 +87,3 @@ class PlanningSceneRender RobotStateVisualizationPtr scene_robot_; }; } - -#endif diff --git a/moveit_ros/visualization/rviz_plugin_render_tools/include/moveit/rviz_plugin_render_tools/render_shapes.h b/moveit_ros/visualization/rviz_plugin_render_tools/include/moveit/rviz_plugin_render_tools/render_shapes.h index fa891bcccd..808d91b710 100644 --- a/moveit_ros/visualization/rviz_plugin_render_tools/include/moveit/rviz_plugin_render_tools/render_shapes.h +++ b/moveit_ros/visualization/rviz_plugin_render_tools/include/moveit/rviz_plugin_render_tools/render_shapes.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_VISUALIZATION_SCENE_DISPLAY_RVIZ_RENDER_SHAPES_ -#define MOVEIT_VISUALIZATION_SCENE_DISPLAY_RVIZ_RENDER_SHAPES_ +#pragma once #include #include @@ -79,5 +78,3 @@ class RenderShapes std::vector octree_voxel_grids_; }; } - -#endif diff --git a/moveit_ros/visualization/rviz_plugin_render_tools/include/moveit/rviz_plugin_render_tools/robot_state_visualization.h b/moveit_ros/visualization/rviz_plugin_render_tools/include/moveit/rviz_plugin_render_tools/robot_state_visualization.h index 24f246dcc3..09ffce9234 100644 --- a/moveit_ros/visualization/rviz_plugin_render_tools/include/moveit/rviz_plugin_render_tools/robot_state_visualization.h +++ b/moveit_ros/visualization/rviz_plugin_render_tools/include/moveit/rviz_plugin_render_tools/robot_state_visualization.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_PLANNING_SCENE_RVIZ_PLUGIN_ROBOT_STATE_VISUALIZATION_ -#define MOVEIT_PLANNING_SCENE_RVIZ_PLUGIN_ROBOT_STATE_VISUALIZATION_ +#pragma once #include #include @@ -70,6 +69,11 @@ class RobotStateVisualization const std::map& color_map); void setDefaultAttachedObjectColor(const std_msgs::ColorRGBA& default_attached_object_color); + bool isVisible() const + { + return visible_; + } + /** * \brief Set the robot as a whole to be visible or not * @param visible Should we be visible? @@ -105,5 +109,3 @@ class RobotStateVisualization bool collision_visible_; }; } - -#endif diff --git a/moveit_ros/visualization/rviz_plugin_render_tools/include/moveit/rviz_plugin_render_tools/trajectory_panel.h b/moveit_ros/visualization/rviz_plugin_render_tools/include/moveit/rviz_plugin_render_tools/trajectory_panel.h index e4c7d731d1..c552f7ec84 100644 --- a/moveit_ros/visualization/rviz_plugin_render_tools/include/moveit/rviz_plugin_render_tools/trajectory_panel.h +++ b/moveit_ros/visualization/rviz_plugin_render_tools/include/moveit/rviz_plugin_render_tools/trajectory_panel.h @@ -34,8 +34,7 @@ /* Author: Yannick Jonetzko */ -#ifndef MOVEIT_TRAJECTORY_RVIZ_PLUGIN_TRAJECTORY_PANEL_ -#define MOVEIT_TRAJECTORY_RVIZ_PLUGIN_TRAJECTORY_PANEL_ +#pragma once #ifndef Q_MOC_RUN #include @@ -93,5 +92,3 @@ private Q_SLOTS: }; } // namespace moveit_rviz_plugin - -#endif diff --git a/moveit_ros/visualization/rviz_plugin_render_tools/include/moveit/rviz_plugin_render_tools/trajectory_visualization.h b/moveit_ros/visualization/rviz_plugin_render_tools/include/moveit/rviz_plugin_render_tools/trajectory_visualization.h index 1c309a46d7..23aa020bf6 100644 --- a/moveit_ros/visualization/rviz_plugin_render_tools/include/moveit/rviz_plugin_render_tools/trajectory_visualization.h +++ b/moveit_ros/visualization/rviz_plugin_render_tools/include/moveit/rviz_plugin_render_tools/trajectory_visualization.h @@ -34,8 +34,7 @@ /* Author: Dave Coleman */ -#ifndef MOVEIT_TRAJECTORY_RVIZ_PLUGIN__TRAJECTORY_VISUALIZATION -#define MOVEIT_TRAJECTORY_RVIZ_PLUGIN__TRAJECTORY_VISUALIZATION +#pragma once #include #include @@ -170,5 +169,3 @@ private Q_SLOTS: }; } // namespace moveit_rviz_plugin - -#endif diff --git a/moveit_ros/visualization/rviz_plugin_render_tools/src/planning_scene_render.cpp b/moveit_ros/visualization/rviz_plugin_render_tools/src/planning_scene_render.cpp index 85ba49b3e3..4ec1d4aa4e 100644 --- a/moveit_ros/visualization/rviz_plugin_render_tools/src/planning_scene_render.cpp +++ b/moveit_ros/visualization/rviz_plugin_render_tools/src/planning_scene_render.cpp @@ -90,7 +90,7 @@ void PlanningSceneRender::renderPlanningScene(const planning_scene::PlanningScen const std::vector& ids = scene->getWorld()->getObjectIds(); for (const std::string& id : ids) { - collision_detection::CollisionWorld::ObjectConstPtr object = scene->getWorld()->getObject(id); + collision_detection::CollisionEnv::ObjectConstPtr object = scene->getWorld()->getObject(id); rviz::Color color = default_env_color; float alpha = default_scene_alpha; if (scene->hasObjectColor(id)) diff --git a/moveit_ros/visualization/src/moveit_ros_visualization/moveitjoy_module.py b/moveit_ros/visualization/src/moveit_ros_visualization/moveitjoy_module.py index 0ad0a176d6..3868b0e3ad 100644 --- a/moveit_ros/visualization/src/moveit_ros_visualization/moveitjoy_module.py +++ b/moveit_ros/visualization/src/moveit_ros_visualization/moveitjoy_module.py @@ -35,7 +35,7 @@ # ********************************************************************/ # Author: Ryohei Ueda, Dave Coleman -# Desc: Interface between PS3/XBox controller and MoveIt! Motion Planning Rviz Plugin +# Desc: Interface between PS3/XBox controller and MoveIt Motion Planning Rviz Plugin from __future__ import print_function diff --git a/moveit_ros/visualization/trajectory_rviz_plugin/CMakeLists.txt b/moveit_ros/visualization/trajectory_rviz_plugin/CMakeLists.txt index 081058868c..97b09ca864 100644 --- a/moveit_ros/visualization/trajectory_rviz_plugin/CMakeLists.txt +++ b/moveit_ros/visualization/trajectory_rviz_plugin/CMakeLists.txt @@ -27,5 +27,6 @@ target_link_libraries(${MOVEIT_LIB_NAME} ${MOVEIT_LIB_NAME}_core ${catkin_LIBRAR install(DIRECTORY include/ DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}) install(TARGETS ${MOVEIT_LIB_NAME} ${MOVEIT_LIB_NAME}_core + LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} - LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}) + RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}) diff --git a/moveit_ros/visualization/trajectory_rviz_plugin/include/moveit/trajectory_rviz_plugin/trajectory_display.h b/moveit_ros/visualization/trajectory_rviz_plugin/include/moveit/trajectory_rviz_plugin/trajectory_display.h index 209778d44f..d4c0ab28a8 100644 --- a/moveit_ros/visualization/trajectory_rviz_plugin/include/moveit/trajectory_rviz_plugin/trajectory_display.h +++ b/moveit_ros/visualization/trajectory_rviz_plugin/include/moveit/trajectory_rviz_plugin/trajectory_display.h @@ -36,8 +36,7 @@ Desc: Wraps a trajectory_visualization playback class for Rviz into a stand alone display */ -#ifndef MOVEIT_TRAJECTORY_RVIZ_PLUGIN__TRAJECTORY_DISPLAY -#define MOVEIT_TRAJECTORY_RVIZ_PLUGIN__TRAJECTORY_DISPLAY +#pragma once #include @@ -96,5 +95,3 @@ private Q_SLOTS: }; } // namespace moveit_rviz_plugin - -#endif diff --git a/moveit_ros/warehouse/CHANGELOG.rst b/moveit_ros/warehouse/CHANGELOG.rst index e3d3c6dd37..ee636c4c9d 100644 --- a/moveit_ros/warehouse/CHANGELOG.rst +++ b/moveit_ros/warehouse/CHANGELOG.rst @@ -32,7 +32,7 @@ Changelog for package moveit_ros_warehouse 0.10.2 (2018-10-24) ------------------- -* [fix] Text refrences to MoveIt! (`#1020 `_) +* [fix] Text refrences to MoveIt (`#1020 `_) * [enhancement] warehouse: added params for timeout + #retries (`#1008 `_) * [maintenance] various compiler warnings (`#1038 `_) * Contributors: Mohmmad Ayman, Robert Haschke, dg-shadow, mike lautman diff --git a/moveit_ros/warehouse/CMakeLists.txt b/moveit_ros/warehouse/CMakeLists.txt index 2cb1205312..9efe441920 100644 --- a/moveit_ros/warehouse/CMakeLists.txt +++ b/moveit_ros/warehouse/CMakeLists.txt @@ -1,7 +1,8 @@ -cmake_minimum_required(VERSION 2.8.12) +cmake_minimum_required(VERSION 3.1.3) project(moveit_ros_warehouse) -add_compile_options(-std=c++14) +set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_EXTENSIONS OFF) if(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Release) diff --git a/moveit_ros/warehouse/package.xml b/moveit_ros/warehouse/package.xml index 976cdd1c79..14512ec42f 100644 --- a/moveit_ros/warehouse/package.xml +++ b/moveit_ros/warehouse/package.xml @@ -1,12 +1,12 @@ moveit_ros_warehouse 1.0.1 - Components of MoveIt! connecting to MongoDB + Components of MoveIt connecting to MongoDB Ioan Sucan Michael Ferguson - MoveIt! Release Team + MoveIt Release Team BSD diff --git a/moveit_ros/warehouse/warehouse/CMakeLists.txt b/moveit_ros/warehouse/warehouse/CMakeLists.txt index 2a459f97c0..5f1b0e000c 100644 --- a/moveit_ros/warehouse/warehouse/CMakeLists.txt +++ b/moveit_ros/warehouse/warehouse/CMakeLists.txt @@ -32,12 +32,17 @@ target_link_libraries(moveit_warehouse_services ${catkin_LIBRARIES} ${MOVEIT_LIB install( TARGETS ${MOVEIT_LIB_NAME} + LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}) + +install( + TARGETS moveit_save_to_warehouse moveit_warehouse_broadcast moveit_warehouse_import_from_text moveit_warehouse_save_as_text moveit_init_demo_warehouse moveit_warehouse_services - LIBRARY DESTINATION ${CATKIN_GLOBAL_LIB_DESTINATION} RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}) install(DIRECTORY include/ DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}) diff --git a/moveit_ros/warehouse/warehouse/include/moveit/warehouse/constraints_storage.h b/moveit_ros/warehouse/warehouse/include/moveit/warehouse/constraints_storage.h index 4bee5469a5..7e507bb257 100644 --- a/moveit_ros/warehouse/warehouse/include/moveit/warehouse/constraints_storage.h +++ b/moveit_ros/warehouse/warehouse/include/moveit/warehouse/constraints_storage.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_MOVEIT_WAREHOUSE_CONSTRAINTS_STORAGE_ -#define MOVEIT_MOVEIT_WAREHOUSE_CONSTRAINTS_STORAGE_ +#pragma once #include "moveit/warehouse/moveit_message_storage.h" #include @@ -84,5 +83,3 @@ class ConstraintsStorage : public MoveItMessageStorage ConstraintsCollection constraints_collection_; }; } - -#endif diff --git a/moveit_ros/warehouse/warehouse/include/moveit/warehouse/moveit_message_storage.h b/moveit_ros/warehouse/warehouse/include/moveit/warehouse/moveit_message_storage.h index 6b8b179258..f6b6be0c3e 100644 --- a/moveit_ros/warehouse/warehouse/include/moveit/warehouse/moveit_message_storage.h +++ b/moveit_ros/warehouse/warehouse/include/moveit/warehouse/moveit_message_storage.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_MOVEIT_WAREHOUSE_MOVEIT_MESSAGE_STORAGE_ -#define MOVEIT_MOVEIT_WAREHOUSE_MOVEIT_MESSAGE_STORAGE_ +#pragma once #include #include @@ -66,5 +65,3 @@ class MoveItMessageStorage /// \brief Load a database connection typename warehouse_ros::DatabaseConnection::Ptr loadDatabase(); } - -#endif diff --git a/moveit_ros/warehouse/warehouse/include/moveit/warehouse/planning_scene_storage.h b/moveit_ros/warehouse/warehouse/include/moveit/warehouse/planning_scene_storage.h index ec7d65c4b3..1878942ecd 100644 --- a/moveit_ros/warehouse/warehouse/include/moveit/warehouse/planning_scene_storage.h +++ b/moveit_ros/warehouse/warehouse/include/moveit/warehouse/planning_scene_storage.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_MOVEIT_WAREHOUSE_PLANNING_SCENE_STORAGE_ -#define MOVEIT_MOVEIT_WAREHOUSE_PLANNING_SCENE_STORAGE_ +#pragma once #include "moveit/warehouse/moveit_message_storage.h" #include @@ -120,5 +119,3 @@ class PlanningSceneStorage : public MoveItMessageStorage RobotTrajectoryCollection robot_trajectory_collection_; }; } - -#endif diff --git a/moveit_ros/warehouse/warehouse/include/moveit/warehouse/planning_scene_world_storage.h b/moveit_ros/warehouse/warehouse/include/moveit/warehouse/planning_scene_world_storage.h index bafb6ab688..fec6384e54 100644 --- a/moveit_ros/warehouse/warehouse/include/moveit/warehouse/planning_scene_world_storage.h +++ b/moveit_ros/warehouse/warehouse/include/moveit/warehouse/planning_scene_world_storage.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_MOVEIT_WAREHOUSE_PLANNING_SCENE_WORLD_STORAGE_ -#define MOVEIT_MOVEIT_WAREHOUSE_PLANNING_SCENE_WORLD_STORAGE_ +#pragma once #include #include @@ -73,5 +72,3 @@ class PlanningSceneWorldStorage : public MoveItMessageStorage PlanningSceneWorldCollection planning_scene_world_collection_; }; } - -#endif diff --git a/moveit_ros/warehouse/warehouse/include/moveit/warehouse/state_storage.h b/moveit_ros/warehouse/warehouse/include/moveit/warehouse/state_storage.h index fed8808143..ce592f9fa0 100644 --- a/moveit_ros/warehouse/warehouse/include/moveit/warehouse/state_storage.h +++ b/moveit_ros/warehouse/warehouse/include/moveit/warehouse/state_storage.h @@ -34,8 +34,7 @@ /* Author: Ioan Sucan */ -#ifndef MOVEIT_MOVEIT_WAREHOUSE_STATE_STORAGE_ -#define MOVEIT_MOVEIT_WAREHOUSE_STATE_STORAGE_ +#pragma once #include #include @@ -79,5 +78,3 @@ class RobotStateStorage : public MoveItMessageStorage RobotStateCollection state_collection_; }; } - -#endif diff --git a/moveit_ros/warehouse/warehouse/include/moveit/warehouse/trajectory_constraints_storage.h b/moveit_ros/warehouse/warehouse/include/moveit/warehouse/trajectory_constraints_storage.h index 1b0cbe501d..7246618a41 100644 --- a/moveit_ros/warehouse/warehouse/include/moveit/warehouse/trajectory_constraints_storage.h +++ b/moveit_ros/warehouse/warehouse/include/moveit/warehouse/trajectory_constraints_storage.h @@ -34,8 +34,7 @@ /* Author: Mario Prats, Ioan Sucan */ -#ifndef MOVEIT_MOVEIT_WAREHOUSE_TRAJECTORY_CONSTRAINTS_STORAGE_ -#define MOVEIT_MOVEIT_WAREHOUSE_TRAJECTORY_CONSTRAINTS_STORAGE_ +#pragma once #include "moveit/warehouse/moveit_message_storage.h" #include @@ -87,5 +86,3 @@ class TrajectoryConstraintsStorage : public MoveItMessageStorage TrajectoryConstraintsCollection constraints_collection_; }; } - -#endif diff --git a/moveit_ros/warehouse/warehouse/include/moveit/warehouse/warehouse_connector.h b/moveit_ros/warehouse/warehouse/include/moveit/warehouse/warehouse_connector.h index d61df45bae..3555097ccd 100644 --- a/moveit_ros/warehouse/warehouse/include/moveit/warehouse/warehouse_connector.h +++ b/moveit_ros/warehouse/warehouse/include/moveit/warehouse/warehouse_connector.h @@ -34,8 +34,7 @@ /* Author: E. Gil Jones */ -#ifndef MOVEIT_MOVEIT_WAREHOUSE_WAREHOUSE_CONNECTOR_ -#define MOVEIT_MOVEIT_WAREHOUSE_WAREHOUSE_CONNECTOR_ +#pragma once #include @@ -55,5 +54,3 @@ class WarehouseConnector int child_pid_; }; } - -#endif diff --git a/moveit_ros/warehouse/warehouse/src/initialize_demo_db.cpp b/moveit_ros/warehouse/warehouse/src/initialize_demo_db.cpp index 28cc32568f..595cae59c1 100644 --- a/moveit_ros/warehouse/warehouse/src/initialize_demo_db.cpp +++ b/moveit_ros/warehouse/warehouse/src/initialize_demo_db.cpp @@ -132,7 +132,7 @@ int main(int argc, char** argv) cs.addConstraints(cmsg, psm.getRobotModel()->getName(), jmg->getName()); ROS_INFO("Added default constraint: '%s'", cmsg.name.c_str()); } - ROS_INFO("Default MoveIt! Warehouse was reset."); + ROS_INFO("Default MoveIt Warehouse was reset."); ros::shutdown(); diff --git a/moveit_runtime/package.xml b/moveit_runtime/package.xml index 8efd4a159f..f331186799 100644 --- a/moveit_runtime/package.xml +++ b/moveit_runtime/package.xml @@ -2,7 +2,7 @@ moveit_runtime 1.0.1 - moveit_runtime meta package contains MoveIt! packages that are essential for its runtime (e.g. running MoveIt! on robots). + moveit_runtime meta package contains MoveIt packages that are essential for its runtime (e.g. running MoveIt on robots). Isaac I. Y. Saito Isaac I. Y. Saito diff --git a/moveit_setup_assistant/CHANGELOG.rst b/moveit_setup_assistant/CHANGELOG.rst index a117cec6fa..dba4173b1f 100644 --- a/moveit_setup_assistant/CHANGELOG.rst +++ b/moveit_setup_assistant/CHANGELOG.rst @@ -51,7 +51,7 @@ Changelog for package moveit_setup_assistant * [capability][chomp] Failure recovery options for CHOMP by tweaking parameters (`#987 `_) * [capability] New screen for automatically generating interfaces to low level controllers(`#951 `_, `#994 `_, `#908 `_) * [capability] Perception screen for using laser scanner point clouds. (`#969 `_) -* [enhancement][GUI] Logo for MoveIt! 2.0, cleanup appearance (`#1059 `_) +* [enhancement][GUI] Logo for MoveIt 2.0, cleanup appearance (`#1059 `_) * [enhancement][GUI] added a setup assistant window icon (`#1028 `_) * [enhancement][GUI] Planning Groups screen (`#1017 `_) * [enhancement] use panda for test, and write test file in tmp dir (`#1042 `_) diff --git a/moveit_setup_assistant/CMakeLists.txt b/moveit_setup_assistant/CMakeLists.txt index dc6339422f..f01787d422 100644 --- a/moveit_setup_assistant/CMakeLists.txt +++ b/moveit_setup_assistant/CMakeLists.txt @@ -1,7 +1,9 @@ -cmake_minimum_required(VERSION 2.8.12) +cmake_minimum_required(VERSION 3.1.3) project(moveit_setup_assistant) -add_compile_options(-std=c++14) +set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_EXTENSIONS OFF) + if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") # suppress warning in Ogre add_compile_options(-Wno-deprecated-register) @@ -139,9 +141,14 @@ set_target_properties(${PROJECT_NAME}_updater PROPERTIES OUTPUT_NAME collisions_updater PREFIX "") -install(TARGETS ${PROJECT_NAME} ${PROJECT_NAME}_widgets ${PROJECT_NAME}_tools ${PROJECT_NAME}_updater - LIBRARY DESTINATION ${CATKIN_GLOBAL_LIB_DESTINATION} +install(TARGETS ${PROJECT_NAME} ${PROJECT_NAME}_updater RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}) + +install(TARGETS ${PROJECT_NAME}_widgets ${PROJECT_NAME}_tools + LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}) + install(DIRECTORY include/ DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}) install(DIRECTORY launch DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}) diff --git a/moveit_setup_assistant/README.md b/moveit_setup_assistant/README.md index 07feef853a..f346ead9ae 100644 --- a/moveit_setup_assistant/README.md +++ b/moveit_setup_assistant/README.md @@ -1 +1 @@ -# MoveIt! Setup Assistant +# MoveIt Setup Assistant diff --git a/moveit_setup_assistant/include/moveit/setup_assistant/tools/compute_default_collisions.h b/moveit_setup_assistant/include/moveit/setup_assistant/tools/compute_default_collisions.h index 207e24bd13..c19bc2e0f5 100644 --- a/moveit_setup_assistant/include/moveit/setup_assistant/tools/compute_default_collisions.h +++ b/moveit_setup_assistant/include/moveit/setup_assistant/tools/compute_default_collisions.h @@ -34,8 +34,7 @@ /* Author: Dave Coleman */ -#ifndef MOVEIT_MOVEIT_SETUP_ASSISTANT_TOOLS_COMPUTE_DEFAULT_COLLISIONS_ -#define MOVEIT_MOVEIT_SETUP_ASSISTANT_TOOLS_COMPUTE_DEFAULT_COLLISIONS_ +#pragma once #include #include @@ -110,5 +109,3 @@ const std::string disabledReasonToString(DisabledReason reason); */ DisabledReason disabledReasonFromString(const std::string& reason); } - -#endif diff --git a/moveit_setup_assistant/include/moveit/setup_assistant/tools/moveit_config_data.h b/moveit_setup_assistant/include/moveit/setup_assistant/tools/moveit_config_data.h index 788cfa0111..0e42bac586 100644 --- a/moveit_setup_assistant/include/moveit/setup_assistant/tools/moveit_config_data.h +++ b/moveit_setup_assistant/include/moveit/setup_assistant/tools/moveit_config_data.h @@ -34,8 +34,7 @@ /* Author: Dave Coleman */ -#ifndef MOVEIT_MOVEIT_SETUP_ASSISTANT_TOOLS_MOVEIT_CONFIG_DATA_ -#define MOVEIT_MOVEIT_SETUP_ASSISTANT_TOOLS_MOVEIT_CONFIG_DATA_ +#pragma once #include #include // for getting kinematic model @@ -175,7 +174,7 @@ class GenericParameter MOVEIT_CLASS_FORWARD(MoveItConfigData); /** \brief This class is shared with all widgets and contains the common configuration data - needed for generating each robot's MoveIt! configuration package. + needed for generating each robot's MoveIt configuration package. All SRDF data is contained in a subclass of this class - srdf_writer.cpp. This class also contains the functions for writing @@ -203,7 +202,7 @@ class MoveItConfigData }; unsigned long changes; // bitfield of changes (composed of InformationFields) - // All of the data needed for creating a MoveIt! Configuration Files + // All of the data needed for creating a MoveIt Configuration Files // ****************************************************************************************** // URDF Data @@ -411,7 +410,7 @@ class MoveItConfigData bool createFullSRDFPath(const std::string& package_path); /** - * Input .setup_assistant file - contains data used for the MoveIt! Setup Assistant + * Input .setup_assistant file - contains data used for the MoveIt Setup Assistant * * @param file_path path to .setup_assistant file * @return true if the file was read correctly @@ -482,6 +481,16 @@ class MoveItConfigData */ std::vector > getSensorPluginConfig(); + /** + * \brief Helper function to get the default start state group for moveit_sim_hw_interface + */ + std::string getDefaultStartStateGroup(); + + /** + * \brief Helper function to get the default start pose for moveit_sim_hw_interface + */ + std::string getDefaultStartPose(); + /** * \brief Custom std::set comparator, used for sorting the joint_limits.yaml file into alphabetical order * \param jm1 - a pointer to the first joint model to compare @@ -515,5 +524,3 @@ class MoveItConfigData }; } // namespace - -#endif diff --git a/moveit_setup_assistant/launch/setup_assistant.launch b/moveit_setup_assistant/launch/setup_assistant.launch index 4d908ba325..852c19c4ce 100644 --- a/moveit_setup_assistant/launch/setup_assistant.launch +++ b/moveit_setup_assistant/launch/setup_assistant.launch @@ -1,4 +1,4 @@ - + diff --git a/moveit_setup_assistant/package.xml b/moveit_setup_assistant/package.xml index 6db06b5a51..99c93b56e0 100644 --- a/moveit_setup_assistant/package.xml +++ b/moveit_setup_assistant/package.xml @@ -2,13 +2,13 @@ moveit_setup_assistant 1.0.1 - Generates a configuration package that makes it easy to use MoveIt! + Generates a configuration package that makes it easy to use MoveIt Dave Coleman Dave Coleman Robert Haschke - MoveIt! Release Team + MoveIt Release Team BSD diff --git a/moveit_setup_assistant/resources/source/MoveIt_Setup_Asst_Sm.xcf b/moveit_setup_assistant/resources/source/MoveIt_Setup_Asst_Sm.xcf index a3935559fd..a468ef5730 100644 Binary files a/moveit_setup_assistant/resources/source/MoveIt_Setup_Asst_Sm.xcf and b/moveit_setup_assistant/resources/source/MoveIt_Setup_Asst_Sm.xcf differ diff --git a/moveit_setup_assistant/src/collisions_updater.cpp b/moveit_setup_assistant/src/collisions_updater.cpp index b5f16d98c4..e6d2e015b9 100644 --- a/moveit_setup_assistant/src/collisions_updater.cpp +++ b/moveit_setup_assistant/src/collisions_updater.cpp @@ -127,7 +127,7 @@ int main(int argc, char* argv[]) uint32_t never_trials = 0; po::options_description desc("Allowed options"); - desc.add_options()("help", "show help")("config-pkg", po::value(&config_pkg_path), "path to MoveIt! config package")( + desc.add_options()("help", "show help")("config-pkg", po::value(&config_pkg_path), "path to MoveIt config package")( "urdf", po::value(&urdf_path), "path to URDF ( or xacro)")("srdf", po::value(&srdf_path), "path to SRDF ( or xacro)")("output", po::value(&output_path), "output path for SRDF") diff --git a/moveit_setup_assistant/src/tools/collision_linear_model.h b/moveit_setup_assistant/src/tools/collision_linear_model.h index 9744170243..9b702fcc73 100644 --- a/moveit_setup_assistant/src/tools/collision_linear_model.h +++ b/moveit_setup_assistant/src/tools/collision_linear_model.h @@ -34,8 +34,7 @@ /* Author: Robert Haschke */ -#ifndef MOVEIT_ROS_MOVEIT_SETUP_ASSISTANT_WIDGETS_COLLISION_LINEAR_MODEL_H -#define MOVEIT_ROS_MOVEIT_SETUP_ASSISTANT_WIDGETS_COLLISION_LINEAR_MODEL_H +#pragma once #include #include @@ -100,5 +99,3 @@ private Q_SLOTS: QVector sort_columns_; // sorting history QVector sort_orders_; // corresponding sort orders }; - -#endif // MOVEIT_ROS_MOVEIT_SETUP_ASSISTANT_WIDGETS_COLLISION_LINEAR_MODEL_H diff --git a/moveit_setup_assistant/src/tools/collision_matrix_model.h b/moveit_setup_assistant/src/tools/collision_matrix_model.h index dccbc2eed1..ed5d67e894 100644 --- a/moveit_setup_assistant/src/tools/collision_matrix_model.h +++ b/moveit_setup_assistant/src/tools/collision_matrix_model.h @@ -34,8 +34,7 @@ /* Author: Robert Haschke */ -#ifndef MOVEIT_ROS_MOVEIT_SETUP_ASSISTANT_WIDGETS_COLLISION_MATRIX_MODEL_ -#define MOVEIT_ROS_MOVEIT_SETUP_ASSISTANT_WIDGETS_COLLISION_MATRIX_MODEL_ +#pragma once #include @@ -79,5 +78,3 @@ public Q_SLOTS: QList q_names; // names of links QList visual_to_index; // map from visual index to actual index }; - -#endif // MOVEIT_ROS_MOVEIT_SETUP_ASSISTANT_WIDGETS_COLLISION_MATRIX_MODEL_ diff --git a/moveit_setup_assistant/src/tools/moveit_config_data.cpp b/moveit_setup_assistant/src/tools/moveit_config_data.cpp index b563b7e882..0bbd81f4c2 100644 --- a/moveit_setup_assistant/src/tools/moveit_config_data.cpp +++ b/moveit_setup_assistant/src/tools/moveit_config_data.cpp @@ -63,7 +63,7 @@ MoveItConfigData::MoveItConfigData() : config_pkg_generated_timestamp_(0) // Not in debug mode debug_ = false; - // Get MoveIt! Setup Assistant package path + // Get MoveIt Setup Assistant package path setup_assistant_path_ = ros::package::getPath("moveit_setup_assistant"); if (setup_assistant_path_.empty()) { @@ -148,7 +148,7 @@ void MoveItConfigData::loadAllowedCollisionMatrix() } // ****************************************************************************************** -// Output MoveIt! Setup Assistant hidden settings file +// Output MoveIt Setup Assistant hidden settings file // ****************************************************************************************** bool MoveItConfigData::outputSetupAssistantFile(const std::string& file_path) { @@ -775,7 +775,7 @@ void MoveItConfigData::outputFollowJointTrajectoryYAML(YAML::Emitter& emitter, emitter << YAML::EndMap; } } - ros_controllers_config_output.erase(controller_it); + controller_it = ros_controllers_config_output.erase(controller_it); emitter << YAML::EndMap; } else @@ -787,6 +787,26 @@ void MoveItConfigData::outputFollowJointTrajectoryYAML(YAML::Emitter& emitter, } } +// ****************************************************************************************** +// Helper function to get the default start state group for moveit_sim_hw_interface +// ****************************************************************************************** +std::string MoveItConfigData::getDefaultStartStateGroup() +{ + if (!srdf_->srdf_model_->getGroups().empty()) + return srdf_->srdf_model_->getGroups()[0].name_; + return "todo_no_group_selected"; +} + +// ****************************************************************************************** +// Helper function to get the default start pose for moveit_sim_hw_interface +// ****************************************************************************************** +std::string MoveItConfigData::getDefaultStartPose() +{ + if (!srdf_->group_states_.empty()) + return srdf_->group_states_[0].name_; + return "todo_no_pose_selected"; +} + // ****************************************************************************************** // Output controllers config files // ****************************************************************************************** @@ -823,19 +843,23 @@ bool MoveItConfigData::outputROSControllersYAML(const std::string& file_path) emitter << YAML::BeginMap; { - emitter << YAML::Comment("MoveIt-specific simulation settings"); + emitter << YAML::Comment("Simulation settings for using moveit_sim_controllers"); emitter << YAML::Key << "moveit_sim_hw_interface" << YAML::Value << YAML::BeginMap; - // MoveIt! Simulation Controller settings for setting initial pose + // MoveIt Simulation Controller settings for setting initial pose { + // Use the first planning group if initial joint_model_group was not set, else write a default value emitter << YAML::Key << "joint_model_group"; - emitter << YAML::Value << "controllers_initial_group_"; + emitter << YAML::Value << getDefaultStartStateGroup(); + + // Use the first robot pose if initial joint_model_group_pose was not set, else write a default value emitter << YAML::Key << "joint_model_group_pose"; - emitter << YAML::Value << "controllers_initial_pose_"; + emitter << YAML::Value << getDefaultStartPose(); + emitter << YAML::EndMap; } // Settings for ros_control control loop emitter << YAML::Newline; - emitter << YAML::Comment("Settings for ros_control control loop"); + emitter << YAML::Comment("Settings for ros_control_boilerplate control loop"); emitter << YAML::Key << "generic_hw_control_loop" << YAML::Value << YAML::BeginMap; { emitter << YAML::Key << "loop_hz"; @@ -1522,7 +1546,7 @@ bool MoveItConfigData::createFullSRDFPath(const std::string& package_path) } // ****************************************************************************************** -// Input .setup_assistant file - contains data used for the MoveIt! Setup Assistant +// Input .setup_assistant file - contains data used for the MoveIt Setup Assistant // ****************************************************************************************** bool MoveItConfigData::inputSetupAssistantYAML(const std::string& file_path) { @@ -1693,7 +1717,7 @@ std::string MoveItConfigData::appendPaths(const std::string& path1, const std::s { fs::path result = path1; result /= path2; - return result.make_preferred().native(); + return result.make_preferred().string(); } srdf::Model::Group* MoveItConfigData::findGroupByName(const std::string& name) diff --git a/moveit_setup_assistant/src/tools/rotated_header_view.h b/moveit_setup_assistant/src/tools/rotated_header_view.h index 27854b7140..5bf288d84c 100644 --- a/moveit_setup_assistant/src/tools/rotated_header_view.h +++ b/moveit_setup_assistant/src/tools/rotated_header_view.h @@ -34,8 +34,7 @@ /* Author: Robert Haschke */ -#ifndef MOVEIT_ROS_MOVEIT_SETUP_ASSISTANT_WIDGETS_ROTATED_HEADERVIEW_H -#define MOVEIT_ROS_MOVEIT_SETUP_ASSISTANT_WIDGETS_ROTATED_HEADERVIEW_H +#pragma once #include @@ -50,5 +49,3 @@ class RotatedHeaderView : public QHeaderView int sectionSizeHint(int logicalIndex) const; }; } - -#endif // MOVEIT_ROS_MOVEIT_SETUP_ASSISTANT_WIDGETS_ROTATED_HEADERVIEW_H diff --git a/moveit_setup_assistant/src/widgets/author_information_widget.cpp b/moveit_setup_assistant/src/widgets/author_information_widget.cpp index fc9dc50727..a73c84e2ec 100644 --- a/moveit_setup_assistant/src/widgets/author_information_widget.cpp +++ b/moveit_setup_assistant/src/widgets/author_information_widget.cpp @@ -47,7 +47,7 @@ namespace moveit_setup_assistant { // ****************************************************************************************** -// Outer User Interface for MoveIt! Configuration Assistant +// Outer User Interface for MoveIt Configuration Assistant // ****************************************************************************************** AuthorInformationWidget::AuthorInformationWidget(QWidget* parent, const MoveItConfigDataPtr& config_data) : SetupScreenWidget(parent), config_data_(config_data) @@ -66,7 +66,7 @@ AuthorInformationWidget::AuthorInformationWidget(QWidget* parent, const MoveItCo layout->addWidget(header); QLabel* name_title = new QLabel(this); - name_title->setText("Name of the maintainer this MoveIt! configuration:"); + name_title->setText("Name of the maintainer this MoveIt configuration:"); layout->addWidget(name_title); name_edit_ = new QLineEdit(this); @@ -74,7 +74,7 @@ AuthorInformationWidget::AuthorInformationWidget(QWidget* parent, const MoveItCo layout->addWidget(name_edit_); QLabel* email_title = new QLabel(this); - email_title->setText("Email of the maintainer of this MoveIt! configuration:"); + email_title->setText("Email of the maintainer of this MoveIt configuration:"); layout->addWidget(email_title); email_edit_ = new QLineEdit(this); diff --git a/moveit_setup_assistant/src/widgets/author_information_widget.h b/moveit_setup_assistant/src/widgets/author_information_widget.h index 15ed0036ec..94763edf93 100644 --- a/moveit_setup_assistant/src/widgets/author_information_widget.h +++ b/moveit_setup_assistant/src/widgets/author_information_widget.h @@ -34,8 +34,7 @@ /* Author: Dave Coleman, Michael 'v4hn' Goerner */ -#ifndef MOVEIT_ROS_MOVEIT_SETUP_ASSISTANT_WIDGETS_AUTHOR_INFORMATION_WIDGET_ -#define MOVEIT_ROS_MOVEIT_SETUP_ASSISTANT_WIDGETS_AUTHOR_INFORMATION_WIDGET_ +#pragma once #include #include @@ -86,5 +85,3 @@ private Q_SLOTS: }; } // namespace moveit_setup_assistant - -#endif diff --git a/moveit_setup_assistant/src/widgets/configuration_files_widget.cpp b/moveit_setup_assistant/src/widgets/configuration_files_widget.cpp index 1f87a5a506..5356e9801b 100644 --- a/moveit_setup_assistant/src/widgets/configuration_files_widget.cpp +++ b/moveit_setup_assistant/src/widgets/configuration_files_widget.cpp @@ -60,7 +60,7 @@ namespace fs = boost::filesystem; const std::string SETUP_ASSISTANT_FILE = ".setup_assistant"; // ****************************************************************************************** -// Outer User Interface for MoveIt! Configuration Assistant +// Outer User Interface for MoveIt Configuration Assistant // ****************************************************************************************** ConfigurationFilesWidget::ConfigurationFilesWidget(QWidget* parent, const MoveItConfigDataPtr& config_data) : SetupScreenWidget(parent), config_data_(config_data), has_generated_pkg_(false), first_focusGiven_(true) @@ -82,7 +82,7 @@ ConfigurationFilesWidget::ConfigurationFilesWidget(QWidget* parent, const MoveIt // Stack Path Dialog stack_path_ = new LoadPathWidget("Configuration Package Save Path", - "Specify the desired directory for the MoveIt! configuration package to be " + "Specify the desired directory for the MoveIt configuration package to be " "generated. Overwriting an existing configuration package directory is acceptable. " "Example: /u/robot/ros/panda_moveit_config", this, true); // is directory @@ -183,7 +183,7 @@ bool ConfigurationFilesWidget::loadGenFiles() fs::path template_package_path = config_data_->setup_assistant_path_; template_package_path /= "templates"; template_package_path /= "moveit_config_pkg_template"; - config_data_->template_package_path_ = template_package_path.make_preferred().native(); + config_data_->template_package_path_ = template_package_path.make_preferred().string(); if (!fs::is_directory(config_data_->template_package_path_)) { @@ -225,7 +225,7 @@ bool ConfigurationFilesWidget::loadGenFiles() // config/ -------------------------------------------------------------------------------------- file.file_name_ = "config/"; file.rel_path_ = file.file_name_; - file.description_ = "Folder containing all MoveIt! configuration files for your robot. This folder is required and " + file.description_ = "Folder containing all MoveIt configuration files for your robot. This folder is required and " "cannot be disabled."; file.gen_func_ = boost::bind(&ConfigurationFilesWidget::createFolder, this, _1); file.write_on_changes = 0; @@ -325,9 +325,8 @@ bool ConfigurationFilesWidget::loadGenFiles() // launch/ -------------------------------------------------------------------------------------- file.file_name_ = "launch/"; file.rel_path_ = file.file_name_; - file.description_ = - "Folder containing all MoveIt! launch files for your robot. This folder is required and cannot be " - "disabled."; + file.description_ = "Folder containing all MoveIt launch files for your robot. " + "This folder is required and cannot be disabled."; file.gen_func_ = boost::bind(&ConfigurationFilesWidget::createFolder, this, _1); file.write_on_changes = 0; gen_files_.push_back(file); @@ -445,7 +444,7 @@ bool ConfigurationFilesWidget::loadGenFiles() file.file_name_ = robot_name + "_moveit_controller_manager.launch.xml"; file.rel_path_ = config_data_->appendPaths(launch_path, file.file_name_); template_path = config_data_->appendPaths(template_launch_path, "moveit_controller_manager.launch.xml"); - file.description_ = "Placeholder for settings specific to the MoveIt! controller manager implemented for you robot."; + file.description_ = "Placeholder for settings specific to the MoveIt controller manager implemented for you robot."; file.gen_func_ = boost::bind(&ConfigurationFilesWidget::copyTemplate, this, template_path, _1); file.write_on_changes = 0; gen_files_.push_back(file); @@ -454,7 +453,7 @@ bool ConfigurationFilesWidget::loadGenFiles() file.file_name_ = robot_name + "_moveit_sensor_manager.launch.xml"; file.rel_path_ = config_data_->appendPaths(launch_path, file.file_name_); template_path = config_data_->appendPaths(template_launch_path, "moveit_sensor_manager.launch.xml"); - file.description_ = "Placeholder for settings specific to the MoveIt! sensor manager implemented for you robot."; + file.description_ = "Placeholder for settings specific to the MoveIt sensor manager implemented for you robot."; file.gen_func_ = boost::bind(&ConfigurationFilesWidget::copyTemplate, this, template_path, _1); file.write_on_changes = 0; gen_files_.push_back(file); @@ -520,7 +519,7 @@ bool ConfigurationFilesWidget::loadGenFiles() template_path = config_data_->appendPaths( template_launch_path, "edit_configuration_package.launch"); // named this so that this launch file is not mixed // up with the SA's real launch file - file.description_ = "Launch file for easily re-starting the MoveIt! Setup Assistant to edit this robot's generated " + file.description_ = "Launch file for easily re-starting the MoveIt Setup Assistant to edit this robot's generated " "configuration package."; file.gen_func_ = boost::bind(&ConfigurationFilesWidget::copyTemplate, this, template_path, _1); file.write_on_changes = 0; @@ -552,7 +551,7 @@ bool ConfigurationFilesWidget::loadGenFiles() // .setup_assistant ------------------------------------------------------------------ file.file_name_ = SETUP_ASSISTANT_FILE; file.rel_path_ = file.file_name_; - file.description_ = "MoveIt! Setup Assistant's hidden settings file. You should not need to edit this file."; + file.description_ = "MoveIt Setup Assistant's hidden settings file. You should not need to edit this file."; file.gen_func_ = boost::bind(&MoveItConfigData::outputSetupAssistantFile, config_data_, _1); file.write_on_changes = -1; // write on any changes gen_files_.push_back(file); @@ -635,7 +634,7 @@ bool ConfigurationFilesWidget::checkDependencies() if (!required_actions) { dep_message.append("
Press Ok to continue generating files."); - if (QMessageBox::question(this, "Incomplete MoveIt! Setup Assistant Steps", dep_message, + if (QMessageBox::question(this, "Incomplete MoveIt Setup Assistant Steps", dep_message, QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Cancel) { return false; // abort @@ -643,7 +642,7 @@ bool ConfigurationFilesWidget::checkDependencies() } else { - QMessageBox::warning(this, "Incomplete MoveIt! Setup Assistant Steps", dep_message); + QMessageBox::warning(this, "Incomplete MoveIt Setup Assistant Steps", dep_message); return false; } } @@ -885,7 +884,7 @@ bool ConfigurationFilesWidget::generatePackage() if (new_package_path.empty()) { QMessageBox::warning(this, "Error Generating", "No package path provided. Please choose a directory location to " - "generate the MoveIt! configuration files."); + "generate the MoveIt configuration files."); return false; } @@ -913,7 +912,7 @@ bool ConfigurationFilesWidget::generatePackage() { QMessageBox::warning( this, "Incorrect Folder/Package", - QString("The chosen package location already exists but was not previously created using this MoveIt! Setup " + QString("The chosen package location already exists but was not previously created using this MoveIt Setup " "Assistant. " "If this is a mistake, add the missing file: ") .append(setup_assistant_file.c_str())); @@ -986,7 +985,7 @@ void ConfigurationFilesWidget::exitSetupAssistant() { if (has_generated_pkg_ || QMessageBox::question(this, "Exit Setup Assistant", - QString("Are you sure you want to exit the MoveIt! Setup Assistant?"), + QString("Are you sure you want to exit the MoveIt Setup Assistant?"), QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Ok) { QApplication::quit(); @@ -1008,7 +1007,7 @@ const std::string ConfigurationFilesWidget::getPackageName(std::string package_p std::string package_name; fs::path fs_package_path = package_path; - package_name = fs_package_path.filename().c_str(); + package_name = fs_package_path.filename().string(); // check for empty if (package_name.empty()) diff --git a/moveit_setup_assistant/src/widgets/configuration_files_widget.h b/moveit_setup_assistant/src/widgets/configuration_files_widget.h index f0787af004..da0946e4dd 100644 --- a/moveit_setup_assistant/src/widgets/configuration_files_widget.h +++ b/moveit_setup_assistant/src/widgets/configuration_files_widget.h @@ -34,8 +34,7 @@ /* Author: Dave Coleman */ -#ifndef MOVEIT_ROS_MOVEIT_SETUP_ASSISTANT_WIDGETS_CONFIGURATION_FILES_WIDGET_ -#define MOVEIT_ROS_MOVEIT_SETUP_ASSISTANT_WIDGETS_CONFIGURATION_FILES_WIDGET_ +#pragma once #include #include @@ -205,5 +204,3 @@ private Q_SLOTS: }; } // namespace moveit_setup_assistant - -#endif diff --git a/moveit_setup_assistant/src/widgets/controller_edit_widget.cpp b/moveit_setup_assistant/src/widgets/controller_edit_widget.cpp index 2d4140a4e8..5840fe2894 100644 --- a/moveit_setup_assistant/src/widgets/controller_edit_widget.cpp +++ b/moveit_setup_assistant/src/widgets/controller_edit_widget.cpp @@ -195,12 +195,11 @@ void ControllerEditWidget::loadControllersTypesComboBox() return; has_loaded_ = true; - const std::array default_types = { + const std::array default_types = { "effort_controllers/JointTrajectoryController", "effort_controllers/JointPositionController", "effort_controllers/JointVelocityController", "effort_controllers/JointEffortController", - "joint_state_controller/JointStateController", "position_controllers/JointPositionController", - "position_controllers/JointTrajectoryController", "velocity_controllers/JointTrajectoryController", - "velocity_controllers/JointvelocityController" + "position_controllers/JointPositionController", "position_controllers/JointTrajectoryController", + "velocity_controllers/JointTrajectoryController", "velocity_controllers/JointVelocityController" }; // Remove all old items diff --git a/moveit_setup_assistant/src/widgets/controller_edit_widget.h b/moveit_setup_assistant/src/widgets/controller_edit_widget.h index 2113005c8a..f7a2679164 100644 --- a/moveit_setup_assistant/src/widgets/controller_edit_widget.h +++ b/moveit_setup_assistant/src/widgets/controller_edit_widget.h @@ -33,8 +33,7 @@ /* Author: Mohamad Ayman */ -#ifndef MOVEIT_ROS_MOVEIT_SETUP_ASSISTANT_WIDGETS_CONTROLLER_EDIT_WIDGET_H -#define MOVEIT_ROS_MOVEIT_SETUP_ASSISTANT_WIDGETS_CONTROLLER_EDIT_WIDGET_H +#pragma once #include #include @@ -142,5 +141,3 @@ private Q_SLOTS: moveit_setup_assistant::MoveItConfigDataPtr config_data_; }; } - -#endif diff --git a/moveit_setup_assistant/src/widgets/default_collisions_widget.h b/moveit_setup_assistant/src/widgets/default_collisions_widget.h index cef78d3c0b..d69cedefd3 100644 --- a/moveit_setup_assistant/src/widgets/default_collisions_widget.h +++ b/moveit_setup_assistant/src/widgets/default_collisions_widget.h @@ -34,8 +34,7 @@ /* Author: Dave Coleman */ -#ifndef MOVEIT_MOVEIT_SETUP_ASSISTANT_WIDGETS_DEFAULT_COLLISIONS_WIDGET__ -#define MOVEIT_MOVEIT_SETUP_ASSISTANT_WIDGETS_DEFAULT_COLLISIONS_WIDGET__ +#pragma once #include #include @@ -257,5 +256,3 @@ class MonitorThread : public QThread bool canceled_; }; } - -#endif diff --git a/moveit_setup_assistant/src/widgets/double_list_widget.h b/moveit_setup_assistant/src/widgets/double_list_widget.h index c4e511bd14..1d983134aa 100644 --- a/moveit_setup_assistant/src/widgets/double_list_widget.h +++ b/moveit_setup_assistant/src/widgets/double_list_widget.h @@ -34,8 +34,7 @@ /* Author: Dave Coleman */ -#ifndef MOVEIT_MOVEIT_SETUP_ASSISTANT_WIDGETS_DOUBLE_LIST_WIDGET_ -#define MOVEIT_MOVEIT_SETUP_ASSISTANT_WIDGETS_DOUBLE_LIST_WIDGET_ +#pragma once #include #include @@ -141,5 +140,3 @@ private Q_SLOTS: }; } // namespace moveit_setup_assistant - -#endif diff --git a/moveit_setup_assistant/src/widgets/end_effectors_widget.h b/moveit_setup_assistant/src/widgets/end_effectors_widget.h index 1c5b17247c..a6be88ed6f 100644 --- a/moveit_setup_assistant/src/widgets/end_effectors_widget.h +++ b/moveit_setup_assistant/src/widgets/end_effectors_widget.h @@ -34,8 +34,7 @@ /* Author: Dave Coleman */ -#ifndef MOVEIT_ROS_MOVEIT_SETUP_ASSISTANT_WIDGETS_END_EFFECTORS_WIDGET_ -#define MOVEIT_ROS_MOVEIT_SETUP_ASSISTANT_WIDGETS_END_EFFECTORS_WIDGET_ +#pragma once // Qt #include @@ -184,5 +183,3 @@ private Q_SLOTS: }; } // namespace - -#endif diff --git a/moveit_setup_assistant/src/widgets/group_edit_widget.cpp b/moveit_setup_assistant/src/widgets/group_edit_widget.cpp index c822edd000..ed1643ea86 100644 --- a/moveit_setup_assistant/src/widgets/group_edit_widget.cpp +++ b/moveit_setup_assistant/src/widgets/group_edit_widget.cpp @@ -250,7 +250,7 @@ void GroupEditWidget::setSelected(const std::string& group_name) QString("Unable to find the kinematic solver '") .append(kin_solver.c_str()) .append("'. Trying running rosmake for this package. Until fixed, this setting will be " - "lost the next time the MoveIt! configuration files are generated")); + "lost the next time the MoveIt configuration files are generated")); return; } else @@ -318,7 +318,7 @@ void GroupEditWidget::loadKinematicPlannersComboBox() // Warn if no plugins are found if (classes.empty()) { - QMessageBox::warning(this, "Missing Kinematic Solvers", "No MoveIt!-compatible kinematics solvers found. Try " + QMessageBox::warning(this, "Missing Kinematic Solvers", "No MoveIt-compatible kinematics solvers found. Try " "installing moveit_kinematics (sudo apt-get install " "ros-${ROS_DISTRO}-moveit-kinematics)"); return; diff --git a/moveit_setup_assistant/src/widgets/group_edit_widget.h b/moveit_setup_assistant/src/widgets/group_edit_widget.h index e5ae0ec884..60a6a67b6e 100644 --- a/moveit_setup_assistant/src/widgets/group_edit_widget.h +++ b/moveit_setup_assistant/src/widgets/group_edit_widget.h @@ -34,8 +34,7 @@ /* Author: Dave Coleman */ -#ifndef MOVEIT_ROS_MOVEIT_SETUP_ASSISTANT_WIDGETS_GROUP_EDIT_WIDGET_ -#define MOVEIT_ROS_MOVEIT_SETUP_ASSISTANT_WIDGETS_GROUP_EDIT_WIDGET_ +#pragma once #include #include @@ -127,5 +126,3 @@ private Q_SLOTS: // ****************************************************************************************** }; } - -#endif diff --git a/moveit_setup_assistant/src/widgets/header_widget.h b/moveit_setup_assistant/src/widgets/header_widget.h index 40793d36a0..a5661beb83 100644 --- a/moveit_setup_assistant/src/widgets/header_widget.h +++ b/moveit_setup_assistant/src/widgets/header_widget.h @@ -34,8 +34,7 @@ /* Author: Dave Coleman */ -#ifndef MOVEIT_ROS_MOVEIT_SETUP_ASSISTANT_WIDGETS_HEADER_WIDGET_ -#define MOVEIT_ROS_MOVEIT_SETUP_ASSISTANT_WIDGETS_HEADER_WIDGET_ +#pragma once #include #include @@ -119,5 +118,3 @@ class LoadPathArgsWidget : public LoadPathWidget void setArgsEnabled(bool enabled = true); }; } - -#endif diff --git a/moveit_setup_assistant/src/widgets/kinematic_chain_widget.h b/moveit_setup_assistant/src/widgets/kinematic_chain_widget.h index da63182675..4c5764cdfd 100644 --- a/moveit_setup_assistant/src/widgets/kinematic_chain_widget.h +++ b/moveit_setup_assistant/src/widgets/kinematic_chain_widget.h @@ -34,8 +34,7 @@ /* Author: Dave Coleman */ -#ifndef MOVEIT_MOVEIT_SETUP_ASSISTANT_WIDGETS_KINEMATIC_CHAIN_WIDGET_ -#define MOVEIT_MOVEIT_SETUP_ASSISTANT_WIDGETS_KINEMATIC_CHAIN_WIDGET_ +#pragma once #include #include @@ -135,5 +134,3 @@ private Q_SLOTS: // ****************************************************************************************** }; } - -#endif diff --git a/moveit_setup_assistant/src/widgets/navigation_widget.h b/moveit_setup_assistant/src/widgets/navigation_widget.h index 962a7d1dc0..76084c869e 100644 --- a/moveit_setup_assistant/src/widgets/navigation_widget.h +++ b/moveit_setup_assistant/src/widgets/navigation_widget.h @@ -34,8 +34,7 @@ /* Author: Dave Coleman */ -#ifndef MOVEIT_ROS_MOVEIT_SETUP_ASSISTANT_WIDGETS_NAVIGATION_WIDGET_ -#define MOVEIT_ROS_MOVEIT_SETUP_ASSISTANT_WIDGETS_NAVIGATION_WIDGET_ +#pragma once #include #include @@ -84,5 +83,3 @@ class NavDelegate : public QStyledItemDelegate void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const override; }; } - -#endif diff --git a/moveit_setup_assistant/src/widgets/passive_joints_widget.h b/moveit_setup_assistant/src/widgets/passive_joints_widget.h index c7dc8dd1d5..344b133d3a 100644 --- a/moveit_setup_assistant/src/widgets/passive_joints_widget.h +++ b/moveit_setup_assistant/src/widgets/passive_joints_widget.h @@ -34,8 +34,7 @@ /* Author: Dave Coleman */ -#ifndef MOVEIT_MOVEIT_SETUP_ASSISTANT_WIDGETS_PASSIVE_JOINTS_WIDGET_ -#define MOVEIT_MOVEIT_SETUP_ASSISTANT_WIDGETS_PASSIVE_JOINTS_WIDGET_ +#pragma once // Qt #include @@ -102,5 +101,3 @@ private Q_SLOTS: }; } // namespace - -#endif diff --git a/moveit_setup_assistant/src/widgets/perception_widget.cpp b/moveit_setup_assistant/src/widgets/perception_widget.cpp index cc13ee2226..6af5bc8dfe 100644 --- a/moveit_setup_assistant/src/widgets/perception_widget.cpp +++ b/moveit_setup_assistant/src/widgets/perception_widget.cpp @@ -57,7 +57,7 @@ PerceptionWidget::PerceptionWidget(QWidget* parent, const MoveItConfigDataPtr& c HeaderWidget* header = new HeaderWidget("Setup 3D Perception Sensors", - "Configure your 3D sensors to work with Moveit! " + "Configure your 3D sensors to work with Moveit " "Please see Perception Documentation " diff --git a/moveit_setup_assistant/src/widgets/perception_widget.h b/moveit_setup_assistant/src/widgets/perception_widget.h index 336fe8a80e..e9c6952d6d 100644 --- a/moveit_setup_assistant/src/widgets/perception_widget.h +++ b/moveit_setup_assistant/src/widgets/perception_widget.h @@ -33,8 +33,7 @@ /* Author: Mohamad Ayman */ -#ifndef MOVEIT_MOVEIT_SETUP_ASSISTANT_WIDGETS_PERCEPTION_WIDGET_ -#define MOVEIT_MOVEIT_SETUP_ASSISTANT_WIDGETS_PERCEPTION_WIDGET_ +#pragma once // Qt #include @@ -125,5 +124,3 @@ private Q_SLOTS: }; } // namespace moveit_setup_assistant - -#endif diff --git a/moveit_setup_assistant/src/widgets/planning_groups_widget.cpp b/moveit_setup_assistant/src/widgets/planning_groups_widget.cpp index a014914fc7..195bf6395b 100644 --- a/moveit_setup_assistant/src/widgets/planning_groups_widget.cpp +++ b/moveit_setup_assistant/src/widgets/planning_groups_widget.cpp @@ -374,7 +374,7 @@ void PlanningGroupsWidget::loadGroupsTreeRecursive(srdf::Model::Group& group_it, { warn_once = false; QMessageBox::warning(this, "Group with Multiple Kinematic Chains", - "Warning: this MoveIt! Setup Assistant is only designed to handle one kinematic chain per " + "Warning: this MoveIt Setup Assistant is only designed to handle one kinematic chain per " "group. The loaded SRDF has more than one kinematic chain for a group. A possible loss of " "data may occur."); } diff --git a/moveit_setup_assistant/src/widgets/planning_groups_widget.h b/moveit_setup_assistant/src/widgets/planning_groups_widget.h index 85bcf64259..0d40c6cc9e 100644 --- a/moveit_setup_assistant/src/widgets/planning_groups_widget.h +++ b/moveit_setup_assistant/src/widgets/planning_groups_widget.h @@ -34,8 +34,7 @@ /* Author: Dave Coleman */ -#ifndef MOVEIT_MOVEIT_SETUP_ASSISTANT_WIDGETS_PLANNING_GROUPS_WIDGET_ -#define MOVEIT_MOVEIT_SETUP_ASSISTANT_WIDGETS_PLANNING_GROUPS_WIDGET_ +#pragma once // Qt class QPushButton; @@ -232,5 +231,3 @@ class PlanGroupType }; Q_DECLARE_METATYPE(PlanGroupType); - -#endif diff --git a/moveit_setup_assistant/src/widgets/robot_poses_widget.cpp b/moveit_setup_assistant/src/widgets/robot_poses_widget.cpp index 501cb4a87e..6d8c9ab840 100644 --- a/moveit_setup_assistant/src/widgets/robot_poses_widget.cpp +++ b/moveit_setup_assistant/src/widgets/robot_poses_widget.cpp @@ -49,7 +49,7 @@ namespace moveit_setup_assistant { // ****************************************************************************************** -// Outer User Interface for MoveIt! Configuration Assistant +// Outer User Interface for MoveIt Configuration Assistant // ****************************************************************************************** RobotPosesWidget::RobotPosesWidget(QWidget* parent, const MoveItConfigDataPtr& config_data) : SetupScreenWidget(parent), config_data_(config_data) @@ -93,7 +93,7 @@ RobotPosesWidget::RobotPosesWidget(QWidget* parent, const MoveItConfigDataPtr& c pub_robot_state_ = nh.advertise(MOVEIT_ROBOT_STATE, 1); // Set the planning scene - config_data_->getPlanningScene()->setName("MoveIt! Planning Scene"); + config_data_->getPlanningScene()->setName("MoveIt Planning Scene"); // Collision Detection initializtion ------------------------------- @@ -144,7 +144,7 @@ QWidget* RobotPosesWidget::createContentsWidget() controls_layout->setAlignment(btn_default, Qt::AlignLeft); // Set play button - QPushButton* btn_play = new QPushButton("&MoveIt!", this); + QPushButton* btn_play = new QPushButton("&MoveIt", this); btn_play->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); btn_play->setMaximumWidth(300); connect(btn_play, SIGNAL(clicked()), this, SLOT(playPoses())); diff --git a/moveit_setup_assistant/src/widgets/robot_poses_widget.h b/moveit_setup_assistant/src/widgets/robot_poses_widget.h index 6614273cca..bdf6aa3e2f 100644 --- a/moveit_setup_assistant/src/widgets/robot_poses_widget.h +++ b/moveit_setup_assistant/src/widgets/robot_poses_widget.h @@ -34,8 +34,7 @@ /* Author: Dave Coleman */ -#ifndef MOVEIT_MOVEIT_SETUP_ASSISTANT_WIDGETS_ROBOT_POSES_WIDGET_ -#define MOVEIT_MOVEIT_SETUP_ASSISTANT_WIDGETS_ROBOT_POSES_WIDGET_ +#pragma once // Qt #include @@ -295,5 +294,3 @@ private Q_SLOTS: // Declare std::string as metatype so we can use it in a signal Q_DECLARE_METATYPE(std::string) - -#endif diff --git a/moveit_setup_assistant/src/widgets/ros_controllers_widget.cpp b/moveit_setup_assistant/src/widgets/ros_controllers_widget.cpp index 05f27403bf..815045ca34 100644 --- a/moveit_setup_assistant/src/widgets/ros_controllers_widget.cpp +++ b/moveit_setup_assistant/src/widgets/ros_controllers_widget.cpp @@ -49,7 +49,7 @@ namespace moveit_setup_assistant { // ****************************************************************************************** -// Outer User Interface for MoveIt! Configuration Assistant +// Outer User Interface for MoveIt Configuration Assistant // ****************************************************************************************** ROSControllersWidget::ROSControllersWidget(QWidget* parent, const MoveItConfigDataPtr& config_data) : SetupScreenWidget(parent), config_data_(config_data) @@ -64,7 +64,7 @@ ROSControllersWidget::ROSControllersWidget(QWidget* parent, const MoveItConfigDa // Top Header Area ------------------------------------------------ moveit_setup_assistant::HeaderWidget* header = new moveit_setup_assistant::HeaderWidget( - "Setup ROS Controllers", "Configure MoveIt! to work with ROS Control to control the robot's physical hardware", + "Setup ROS Controllers", "Configure MoveIt to work with ROS Control to control the robot's physical hardware", this); layout->addWidget(header); diff --git a/moveit_setup_assistant/src/widgets/ros_controllers_widget.h b/moveit_setup_assistant/src/widgets/ros_controllers_widget.h index 57fc7d3c8b..c1c05e609b 100644 --- a/moveit_setup_assistant/src/widgets/ros_controllers_widget.h +++ b/moveit_setup_assistant/src/widgets/ros_controllers_widget.h @@ -33,8 +33,7 @@ /* Author: Mohamad Ayman */ -#ifndef MOVEIT_MOVEIT_SETUP_ASSISTANT_WIDGETS_ROS_CONTROLLERS_WIDGET_H -#define MOVEIT_MOVEIT_SETUP_ASSISTANT_WIDGETS_ROS_CONTROLLERS_WIDGET_H +#pragma once // Qt #include @@ -160,5 +159,3 @@ private Q_SLOTS: }; } // namespace moveit_setup_assistant - -#endif diff --git a/moveit_setup_assistant/src/widgets/setup_assistant_widget.cpp b/moveit_setup_assistant/src/widgets/setup_assistant_widget.cpp index 1f7f0595b4..511463a968 100644 --- a/moveit_setup_assistant/src/widgets/setup_assistant_widget.cpp +++ b/moveit_setup_assistant/src/widgets/setup_assistant_widget.cpp @@ -47,6 +47,7 @@ #include #include #include +#include #include // for loading all avail kinematic planners // Rviz #include @@ -58,7 +59,7 @@ namespace moveit_setup_assistant { // ****************************************************************************************** -// Outer User Interface for MoveIt! Configuration Assistant +// Outer User Interface for MoveIt Configuration Assistant // ****************************************************************************************** SetupAssistantWidget::SetupAssistantWidget(QWidget* parent, const boost::program_options::variables_map& args) : QWidget(parent) @@ -66,7 +67,7 @@ SetupAssistantWidget::SetupAssistantWidget(QWidget* parent, const boost::program rviz_manager_ = nullptr; rviz_render_panel_ = nullptr; - // Create object to hold all MoveIt! configuration data + // Create object to hold all MoveIt configuration data config_data_.reset(new MoveItConfigData()); // Set debug mode flag if necessary @@ -113,13 +114,7 @@ SetupAssistantWidget::SetupAssistantWidget(QWidget* parent, const boost::program } else { - // Open the directory where the MSA was started from. - // cf. http://stackoverflow.com/a/7413516/577001 - QString pwdir(""); - char* pwd; - pwd = getenv("PWD"); - pwdir.append(pwd); - start_screen_widget_->stack_path_->setPath(pwdir); + start_screen_widget_->stack_path_->setPath(QDir::currentPath()); } // Add Navigation Buttons (but do not load widgets yet except start screen) @@ -164,7 +159,7 @@ SetupAssistantWidget::SetupAssistantWidget(QWidget* parent, const boost::program this->setLayout(layout); // Title - this->setWindowTitle("MoveIt! Setup Assistant"); // title of window + this->setWindowTitle("MoveIt Setup Assistant"); // title of window // Show screen before message QApplication::processEvents(); @@ -391,7 +386,7 @@ void SetupAssistantWidget::loadRviz() // Set the fixed and target frame rviz_manager_->setFixedFrame(QString::fromStdString(config_data_->getRobotModel()->getModelFrame())); - // Create the MoveIt! Rviz Plugin and attach to display + // Create the MoveIt Rviz Plugin and attach to display robot_state_display_ = new moveit_rviz_plugin::RobotStateDisplay(); robot_state_display_->setName("Robot State"); @@ -484,7 +479,7 @@ void SetupAssistantWidget::closeEvent(QCloseEvent* event) if (!config_data_->debug_) { if (QMessageBox::question(this, "Exit Setup Assistant", - QString("Are you sure you want to exit the MoveIt! Setup Assistant?"), + QString("Are you sure you want to exit the MoveIt Setup Assistant?"), QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Cancel) { event->ignore(); diff --git a/moveit_setup_assistant/src/widgets/setup_assistant_widget.h b/moveit_setup_assistant/src/widgets/setup_assistant_widget.h index 48ccf7d26a..51f07cf56f 100644 --- a/moveit_setup_assistant/src/widgets/setup_assistant_widget.h +++ b/moveit_setup_assistant/src/widgets/setup_assistant_widget.h @@ -34,8 +34,7 @@ /* Author: Dave Coleman */ -#ifndef MOVEIT_ROS_MOVEIT_SETUP_ASSISTANT_WIDGETS_SETUP_ASSISTANT_WIDGET_ -#define MOVEIT_ROS_MOVEIT_SETUP_ASSISTANT_WIDGETS_SETUP_ASSISTANT_WIDGET_ +#pragma once // Qt #include @@ -237,5 +236,3 @@ private Q_SLOTS: // ****************************************************************************************** }; } - -#endif diff --git a/moveit_setup_assistant/src/widgets/setup_screen_widget.h b/moveit_setup_assistant/src/widgets/setup_screen_widget.h index 805350e9d5..7898b4f25e 100644 --- a/moveit_setup_assistant/src/widgets/setup_screen_widget.h +++ b/moveit_setup_assistant/src/widgets/setup_screen_widget.h @@ -34,8 +34,7 @@ /* Author: Dave Coleman */ -#ifndef MOVEIT_ROS_MOVEIT_SETUP_ASSISTANT_WIDGETS_SETUP_SCREEN_WIDGET_ -#define MOVEIT_ROS_MOVEIT_SETUP_ASSISTANT_WIDGETS_SETUP_SCREEN_WIDGET_ +#pragma once #include @@ -75,5 +74,3 @@ class SetupScreenWidget : public QWidget /// Event for telling rviz to unhighlight all links of the robot void unhighlightAll(); }; - -#endif diff --git a/moveit_setup_assistant/src/widgets/simulation_widget.cpp b/moveit_setup_assistant/src/widgets/simulation_widget.cpp index abac044fb7..e5bc3ed2df 100644 --- a/moveit_setup_assistant/src/widgets/simulation_widget.cpp +++ b/moveit_setup_assistant/src/widgets/simulation_widget.cpp @@ -63,7 +63,7 @@ SimulationWidget::SimulationWidget(QWidget* parent, const MoveItConfigDataPtr& c HeaderWidget* header = new HeaderWidget("Simulate With Gazebo", "The following tool will auto-generate the URDF changes needed " - "for Gazebo compatibility with ROSControl and MoveIt!. The " + "for Gazebo compatibility with ROSControl and MoveIt. The " "needed changes are shown in green.", this); layout->addWidget(header); diff --git a/moveit_setup_assistant/src/widgets/simulation_widget.h b/moveit_setup_assistant/src/widgets/simulation_widget.h index 2b3ac58331..029874d065 100644 --- a/moveit_setup_assistant/src/widgets/simulation_widget.h +++ b/moveit_setup_assistant/src/widgets/simulation_widget.h @@ -33,8 +33,7 @@ /* Author: Mohamad Ayman */ -#ifndef MOVEIT_MOVEIT_SETUP_ASSISTANT_WIDGETS_SIMULATION_WIDGET_H -#define MOVEIT_MOVEIT_SETUP_ASSISTANT_WIDGETS_SIMULATION_WIDGET_H +#pragma once // Qt #include @@ -93,5 +92,3 @@ private Q_SLOTS: }; } // namespace moveit_setup_assistant - -#endif diff --git a/moveit_setup_assistant/src/widgets/start_screen_widget.cpp b/moveit_setup_assistant/src/widgets/start_screen_widget.cpp index 8a8fadbd27..110ba6391a 100644 --- a/moveit_setup_assistant/src/widgets/start_screen_widget.cpp +++ b/moveit_setup_assistant/src/widgets/start_screen_widget.cpp @@ -59,13 +59,20 @@ // MoveIt #include +// chdir +#ifdef _WIN32 +#include +#else +#include +#endif + namespace moveit_setup_assistant { // Boost file system namespace fs = boost::filesystem; // ****************************************************************************************** -// Start screen user interface for MoveIt! Configuration Assistant +// Start screen user interface for MoveIt Configuration Assistant // ****************************************************************************************** StartScreenWidget::StartScreenWidget(QWidget* parent, const MoveItConfigDataPtr& config_data) : SetupScreenWidget(parent), config_data_(config_data) @@ -104,9 +111,9 @@ StartScreenWidget::StartScreenWidget(QWidget* parent, const MoveItConfigDataPtr& // Top Label Area --------------------------------------------------- HeaderWidget* header = - new HeaderWidget("MoveIt! Setup Assistant", "These tools will assist you in creating a Semantic Robot " - "Description Format (SRDF) file, various yaml configuration and many " - "roslaunch files for utilizing all aspects of MoveIt! functionality.", + new HeaderWidget("MoveIt Setup Assistant", "These tools will assist you in creating a Semantic Robot " + "Description Format (SRDF) file, various yaml configuration and many " + "roslaunch files for utilizing all aspects of MoveIt functionality.", this); layout->addWidget(header); @@ -120,8 +127,8 @@ StartScreenWidget::StartScreenWidget(QWidget* parent, const MoveItConfigDataPtr& // Stack Path Dialog stack_path_ = - new LoadPathArgsWidget("Load MoveIt! Configuration Package", - "Specify the package name or path of an existing MoveIt! configuration package to be " + new LoadPathArgsWidget("Load MoveIt Configuration Package", + "Specify the package name or path of an existing MoveIt configuration package to be " "edited for your robot. Example package name: panda_moveit_config", "optional xacro arguments:", this, true); // directory // user needs to select option before this is shown @@ -332,7 +339,7 @@ bool StartScreenWidget::loadPackageSettings(bool show_warnings) if (show_warnings) QMessageBox::warning( this, "Incorrect Directory/Package", - QString("The chosen package location exists but was not created using MoveIt! Setup Assistant. " + QString("The chosen package location exists but was not created using MoveIt Setup Assistant. " "If this is a mistake, provide the missing file: ") .append(setup_assistant_path.c_str())); return false; @@ -400,14 +407,14 @@ bool StartScreenWidget::loadExistingFiles() fs::path kinematics_yaml_path = config_data_->config_pkg_path_; kinematics_yaml_path /= "config/kinematics.yaml"; - if (!config_data_->inputKinematicsYAML(kinematics_yaml_path.make_preferred().native())) + if (!config_data_->inputKinematicsYAML(kinematics_yaml_path.make_preferred().string())) { QMessageBox::warning(this, "No Kinematic YAML File", QString("Failed to parse kinematics yaml file. This file is not critical but any previous " "kinematic solver settings have been lost. To re-populate this file edit each " "existing planning group and choose a solver, then save each change. \n\nFile error " "at location ") - .append(kinematics_yaml_path.make_preferred().native().c_str())); + .append(kinematics_yaml_path.make_preferred().string().c_str())); } // Load 3d_sensors config file @@ -416,11 +423,11 @@ bool StartScreenWidget::loadExistingFiles() // Load ros controllers yaml file if available----------------------------------------------- fs::path ros_controllers_yaml_path = config_data_->config_pkg_path_; ros_controllers_yaml_path /= "config/ros_controllers.yaml"; - config_data_->inputROSControllersYAML(ros_controllers_yaml_path.make_preferred().native()); + config_data_->inputROSControllersYAML(ros_controllers_yaml_path.make_preferred().string()); fs::path ompl_yaml_path = config_data_->config_pkg_path_; ompl_yaml_path /= "config/ompl_planning.yaml"; - config_data_->inputOMPLYAML(ompl_yaml_path.make_preferred().native()); + config_data_->inputOMPLYAML(ompl_yaml_path.make_preferred().string()); // DONE LOADING -------------------------------------------------------------------------- @@ -561,7 +568,7 @@ bool StartScreenWidget::loadURDFFile(const std::string& urdf_file_path, const st while (!nh.ok() && steps < 4) { ROS_WARN("Waiting for node handle"); - sleep(1); + ros::Duration(1).sleep(); steps++; ros::spinOnce(); } @@ -610,7 +617,7 @@ bool StartScreenWidget::setSRDFFile(const std::string& srdf_string) while (!nh.ok() && steps < 4) { ROS_WARN("Waiting for node handle"); - sleep(1); + ros::Duration(1).sleep(); steps++; ros::spinOnce(); } @@ -645,7 +652,7 @@ bool StartScreenWidget::extractPackageNameFromPath() // Copy path into vector of parts for (fs::path::iterator it = urdf_directory.begin(); it != urdf_directory.end(); ++it) - path_parts.push_back(it->native()); + path_parts.push_back(it->string()); bool package_found = false; @@ -670,7 +677,7 @@ bool StartScreenWidget::extractPackageNameFromPath() // check if this directory has a package.xml package_path = sub_path; package_path /= "package.xml"; - ROS_DEBUG_STREAM("Checking for " << package_path.make_preferred().native()); + ROS_DEBUG_STREAM("Checking for " << package_path.make_preferred().string()); // Check if the files exist if (fs::is_regular_file(package_path) || fs::is_regular_file(sub_path / "manifest.xml")) @@ -711,7 +718,7 @@ bool StartScreenWidget::extractPackageNameFromPath() // Success config_data_->urdf_pkg_name_ = package_name; - config_data_->urdf_pkg_relative_path_ = relative_path.make_preferred().native(); + config_data_->urdf_pkg_relative_path_ = relative_path.make_preferred().string(); } ROS_DEBUG_STREAM("URDF Package Name: " << config_data_->urdf_pkg_name_); @@ -781,12 +788,12 @@ bool StartScreenWidget::load3DSensorsFile() if (!fs::is_regular_file(sensors_3d_yaml_path)) { - return config_data_->input3DSensorsYAML(default_sensors_3d_yaml_path.make_preferred().native()); + return config_data_->input3DSensorsYAML(default_sensors_3d_yaml_path.make_preferred().string()); } else { - return config_data_->input3DSensorsYAML(default_sensors_3d_yaml_path.make_preferred().native(), - sensors_3d_yaml_path.make_preferred().native()); + return config_data_->input3DSensorsYAML(default_sensors_3d_yaml_path.make_preferred().string(), + sensors_3d_yaml_path.make_preferred().string()); } } @@ -827,9 +834,9 @@ SelectModeWidget::SelectModeWidget(QWidget* parent) : QFrame(parent) widget_instructions_->setWordWrap(true); widget_instructions_->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); widget_instructions_->setText( - "All settings for MoveIt! are stored in the MoveIt! configuration package. Here you have " + "All settings for MoveIt are stored in the MoveIt configuration package. Here you have " "the option to create a new configuration package or load an existing one. Note: " - "changes to a MoveIt! configuration package outside this Setup Assistant are likely to be " + "changes to a MoveIt configuration package outside this Setup Assistant are likely to be " "overwritten by this tool."); layout->addWidget(widget_instructions_); diff --git a/moveit_setup_assistant/src/widgets/start_screen_widget.h b/moveit_setup_assistant/src/widgets/start_screen_widget.h index 6e0a83a37f..d06dd6a6ce 100644 --- a/moveit_setup_assistant/src/widgets/start_screen_widget.h +++ b/moveit_setup_assistant/src/widgets/start_screen_widget.h @@ -34,8 +34,7 @@ /* Author: Dave Coleman */ -#ifndef MOVEIT_MOVEIT_SETUP_ASSISTANT_WIDGETS_START_SCREEN_WIDGET_ -#define MOVEIT_MOVEIT_SETUP_ASSISTANT_WIDGETS_START_SCREEN_WIDGET_ +#pragma once #include #include @@ -59,7 +58,7 @@ class SelectModeWidget; class LoadPathArgsWidget; /** - * \brief Start screen user interface for MoveIt! Configuration Assistant + * \brief Start screen user interface for MoveIt Configuration Assistant */ class StartScreenWidget : public SetupScreenWidget { @@ -71,7 +70,7 @@ class StartScreenWidget : public SetupScreenWidget // ****************************************************************************************** /** - * \brief Start screen user interface for MoveIt! Configuration Assistant + * \brief Start screen user interface for MoveIt Configuration Assistant */ StartScreenWidget(QWidget* parent, const MoveItConfigDataPtr& config_data); @@ -190,5 +189,3 @@ private Q_SLOTS: QLabel* widget_instructions_; }; } - -#endif diff --git a/moveit_setup_assistant/src/widgets/virtual_joints_widget.h b/moveit_setup_assistant/src/widgets/virtual_joints_widget.h index b1bb87a68b..e3c6f5d4ec 100644 --- a/moveit_setup_assistant/src/widgets/virtual_joints_widget.h +++ b/moveit_setup_assistant/src/widgets/virtual_joints_widget.h @@ -34,8 +34,7 @@ /* Author: Dave Coleman */ -#ifndef MOVEIT_MOVEIT_SETUP_ASSISTANT_WIDGETS_VIRTUAL_JOINTS_WIDGET_ -#define MOVEIT_MOVEIT_SETUP_ASSISTANT_WIDGETS_VIRTUAL_JOINTS_WIDGET_ +#pragma once // Qt #include @@ -188,5 +187,3 @@ private Q_SLOTS: }; } // namespace - -#endif diff --git a/moveit_setup_assistant/templates/moveit_config_pkg_template/CMakeLists.txt b/moveit_setup_assistant/templates/moveit_config_pkg_template/CMakeLists.txt index f95c9c1029..e0c28ee223 100644 --- a/moveit_setup_assistant/templates/moveit_config_pkg_template/CMakeLists.txt +++ b/moveit_setup_assistant/templates/moveit_config_pkg_template/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8.3) +cmake_minimum_required(VERSION 3.1.3) project([GENERATED_PACKAGE_NAME]) find_package(catkin REQUIRED) diff --git a/moveit_setup_assistant/templates/moveit_config_pkg_template/launch/chomp_planning_pipeline.launch.xml b/moveit_setup_assistant/templates/moveit_config_pkg_template/launch/chomp_planning_pipeline.launch.xml index 33d6ce4a57..1f83008b8d 100644 --- a/moveit_setup_assistant/templates/moveit_config_pkg_template/launch/chomp_planning_pipeline.launch.xml +++ b/moveit_setup_assistant/templates/moveit_config_pkg_template/launch/chomp_planning_pipeline.launch.xml @@ -1,5 +1,5 @@ - + diff --git a/moveit_setup_assistant/templates/moveit_config_pkg_template/launch/demo.launch b/moveit_setup_assistant/templates/moveit_config_pkg_template/launch/demo.launch index a66b756773..7cb5bebbf7 100644 --- a/moveit_setup_assistant/templates/moveit_config_pkg_template/launch/demo.launch +++ b/moveit_setup_assistant/templates/moveit_config_pkg_template/launch/demo.launch @@ -14,7 +14,7 @@ - + diff --git a/moveit_setup_assistant/templates/moveit_config_pkg_template/launch/demo_gazebo.launch b/moveit_setup_assistant/templates/moveit_config_pkg_template/launch/demo_gazebo.launch index ec5d85541d..cf4d1981c9 100644 --- a/moveit_setup_assistant/templates/moveit_config_pkg_template/launch/demo_gazebo.launch +++ b/moveit_setup_assistant/templates/moveit_config_pkg_template/launch/demo_gazebo.launch @@ -11,7 +11,7 @@ - + diff --git a/moveit_setup_assistant/templates/moveit_config_pkg_template/launch/edit_configuration_package.launch b/moveit_setup_assistant/templates/moveit_config_pkg_template/launch/edit_configuration_package.launch index 6a313304a9..04d28dac6e 100644 --- a/moveit_setup_assistant/templates/moveit_config_pkg_template/launch/edit_configuration_package.launch +++ b/moveit_setup_assistant/templates/moveit_config_pkg_template/launch/edit_configuration_package.launch @@ -1,4 +1,4 @@ - + diff --git a/moveit_setup_assistant/templates/moveit_config_pkg_template/launch/ompl_planning_pipeline.launch.xml b/moveit_setup_assistant/templates/moveit_config_pkg_template/launch/ompl_planning_pipeline.launch.xml index 7b2ad777a2..eb408ed545 100644 --- a/moveit_setup_assistant/templates/moveit_config_pkg_template/launch/ompl_planning_pipeline.launch.xml +++ b/moveit_setup_assistant/templates/moveit_config_pkg_template/launch/ompl_planning_pipeline.launch.xml @@ -1,6 +1,6 @@ - + + + + + + + + + + + + + + + + + + + + diff --git a/moveit_setup_assistant/templates/moveit_config_pkg_template/launch/trajectory_execution.launch.xml b/moveit_setup_assistant/templates/moveit_config_pkg_template/launch/trajectory_execution.launch.xml index 9354d7a7c1..aec604748b 100644 --- a/moveit_setup_assistant/templates/moveit_config_pkg_template/launch/trajectory_execution.launch.xml +++ b/moveit_setup_assistant/templates/moveit_config_pkg_template/launch/trajectory_execution.launch.xml @@ -2,7 +2,7 @@ - + diff --git a/moveit_setup_assistant/templates/moveit_config_pkg_template/launch/trajopt_planning_pipeline.launch.xml b/moveit_setup_assistant/templates/moveit_config_pkg_template/launch/trajopt_planning_pipeline.launch.xml new file mode 100644 index 0000000000..cf5735429d --- /dev/null +++ b/moveit_setup_assistant/templates/moveit_config_pkg_template/launch/trajopt_planning_pipeline.launch.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + diff --git a/moveit_setup_assistant/templates/moveit_config_pkg_template/package.xml.template b/moveit_setup_assistant/templates/moveit_config_pkg_template/package.xml.template index ba305540fc..bf69cdf642 100644 --- a/moveit_setup_assistant/templates/moveit_config_pkg_template/package.xml.template +++ b/moveit_setup_assistant/templates/moveit_config_pkg_template/package.xml.template @@ -3,7 +3,7 @@ [GENERATED_PACKAGE_NAME] 0.3.0 - An automatically generated package with all the configuration and launch files for using the [ROBOT_NAME] with the MoveIt! Motion Planning Framework + An automatically generated package with all the configuration and launch files for using the [ROBOT_NAME] with the MoveIt Motion Planning Framework [AUTHOR_NAME] [AUTHOR_NAME] diff --git a/moveit_setup_assistant/test/moveit_config_data_test.cpp b/moveit_setup_assistant/test/moveit_config_data_test.cpp index 911be67575..9cd489015d 100644 --- a/moveit_setup_assistant/test/moveit_config_data_test.cpp +++ b/moveit_setup_assistant/test/moveit_config_data_test.cpp @@ -106,7 +106,7 @@ TEST_F(MoveItConfigData, ReadingControllers) // ros_controller.yaml written correctly EXPECT_EQ(config_data->outputROSControllersYAML(test_file), true); - // Reset MoveIt! config MoveItConfigData + // Reset MoveIt config MoveItConfigData config_data.reset(new moveit_setup_assistant::MoveItConfigData()); // Initially no controllers
Package