-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #267 from marip8/feature/new-planner-profiles-v2
Revised planner profile interfaces
- Loading branch information
Showing
10 changed files
with
520 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
tesseract_motion_planners/core/include/tesseract_motion_planners/core/profile_dictionary.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
/** | ||
* @file profile_dictionary.h | ||
* @brief This is a profile dictionary for storing all profiles | ||
* | ||
* @author Michael Ripperger | ||
* @date January 11, 2022 | ||
* @version TODO | ||
* @bug No known bugs | ||
* | ||
* @copyright Copyright (c) 2020, Southwest Research Institute | ||
* | ||
* @par License | ||
* Software License Agreement (Apache License) | ||
* @par | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* @par | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
#ifndef TESSERACT_MOTION_PLANNERS_CORE_PROFILE_DICTIONARY_H | ||
#define TESSERACT_MOTION_PLANNERS_CORE_PROFILE_DICTIONARY_H | ||
|
||
#include <tesseract_common/macros.h> | ||
TESSERACT_COMMON_IGNORE_WARNINGS_PUSH | ||
#include <any> | ||
#include <boost/serialization/serialization.hpp> | ||
#include <iostream> | ||
#include <unordered_map> | ||
#include <memory> | ||
#include <shared_mutex> | ||
TESSERACT_COMMON_IGNORE_WARNINGS_POP | ||
|
||
#ifdef SWIG | ||
%shared_ptr(tesseract_planning::ProfileDictionary) | ||
#endif // SWIG | ||
#include <tesseract_motion_planners/core/profiles.h> | ||
|
||
namespace tesseract_planning::tmp | ||
{ | ||
/** | ||
* @brief Stores profiles for motion planning and process planning | ||
* @details This class is thread-safe | ||
*/ | ||
template <typename ProfileT> | ||
class ProfileDictionary | ||
{ | ||
public: | ||
using Ptr = std::shared_ptr<ProfileDictionary<ProfileT>>; | ||
using ConstPtr = std::shared_ptr<const ProfileDictionary<ProfileT>>; | ||
|
||
ProfileDictionary() = default; | ||
virtual ~ProfileDictionary() = default; | ||
|
||
ProfileDictionary(const ProfileDictionary& rhs); | ||
ProfileDictionary(ProfileDictionary&& rhs) noexcept; | ||
ProfileDictionary& operator=(const ProfileDictionary& rhs); | ||
ProfileDictionary& operator=(ProfileDictionary&& rhs) noexcept; | ||
|
||
/** | ||
* @brief Checks if a profile exists in the provided namespace | ||
* @return True if exists, false otherwise | ||
*/ | ||
bool hasProfile(const std::string& ns, const std::string& profile) const; | ||
|
||
/** | ||
* @brief Gets a profile by name under a given namespace | ||
* @throws Runtime exception if the namespace or profile do not exist | ||
*/ | ||
typename ProfileT::ConstPtr getProfile(const std::string& ns, const std::string& profile_name) const; | ||
|
||
/** | ||
* @brief Gets a profile entry from a given namespace | ||
*/ | ||
std::unordered_map<std::string, typename ProfileT::ConstPtr> getProfileEntry(const std::string& ns) const; | ||
|
||
/** | ||
* @brief Adds a profile with the input name under the given namespace | ||
*/ | ||
void addProfile(const std::string& ns, const std::string& profile_name, typename ProfileT::ConstPtr profile); | ||
|
||
/** | ||
* @brief Removes a profile entry from a given namespace | ||
*/ | ||
void removeProfile(const std::string& ns, const std::string& profile); | ||
|
||
protected: | ||
std::unordered_map<std::string, std::unordered_map<std::string, typename ProfileT::ConstPtr>> profiles_; | ||
mutable std::shared_mutex mutex_; | ||
}; | ||
|
||
using WaypointProfileDictionary = ProfileDictionary<WaypointProfile>; | ||
using CompositeProfileDictionary = ProfileDictionary<CompositeProfile>; | ||
using PlannerProfileDictionary = ProfileDictionary<PlannerProfile>; | ||
|
||
} // namespace tesseract_planning::tmp | ||
|
||
#endif // TESSERACT_MOTION_PLANNERS_CORE_PROFILE_DICTIONARY_H |
131 changes: 131 additions & 0 deletions
131
tesseract_motion_planners/core/include/tesseract_motion_planners/core/profiles.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
/** | ||
* @file profile_dictionary.h | ||
* @brief This is a profile dictionary for storing all profiles | ||
* | ||
* @author Levi Armstrong | ||
* @date December 2, 2020 | ||
* @version TODO | ||
* @bug No known bugs | ||
* | ||
* @copyright Copyright (c) 2020, Southwest Research Institute | ||
* | ||
* @par License | ||
* Software License Agreement (Apache License) | ||
* @par | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* @par | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
#ifndef TESSERACT_MOTION_PLANNERS_CORE_PROFILES_H | ||
#define TESSERACT_MOTION_PLANNERS_CORE_PROFILES_H | ||
|
||
#include <tesseract_common/macros.h> | ||
TESSERACT_COMMON_IGNORE_WARNINGS_PUSH | ||
#include <any> | ||
#include <iostream> | ||
#include <typeindex> | ||
#include <unordered_map> | ||
#include <memory> | ||
#include <mutex> | ||
#include <shared_mutex> | ||
TESSERACT_COMMON_IGNORE_WARNINGS_POP | ||
|
||
#include <tesseract_environment/environment.h> | ||
#include <tesseract_command_language/move_instruction.h> | ||
#include <tesseract_command_language/composite_instruction.h> | ||
|
||
namespace tesseract_planning | ||
{ | ||
/** | ||
* @brief Struct to produce a planner-specific planning profile to apply to a single waypoint. | ||
* @details Examples of waypoint profiles might include costs/constraints for a waypoint or a waypoint sampler | ||
*/ | ||
class WaypointProfile | ||
{ | ||
public: | ||
using Ptr = std::shared_ptr<WaypointProfile>; | ||
using ConstPtr = std::shared_ptr<const WaypointProfile>; | ||
|
||
WaypointProfile() = default; | ||
WaypointProfile(const WaypointProfile&) = delete; | ||
WaypointProfile& operator=(const WaypointProfile&) = delete; | ||
WaypointProfile(WaypointProfile&&) = delete; | ||
WaypointProfile&& operator=(WaypointProfile&&) = delete; | ||
|
||
virtual ~WaypointProfile() = default; | ||
|
||
virtual std::any create(const MoveInstruction& instruction, | ||
tesseract_environment::Environment::ConstPtr env) const = 0; | ||
|
||
protected: | ||
friend class boost::serialization::access; | ||
template <class Archive> | ||
void serialize(Archive&, const unsigned int); // NOLINT | ||
}; | ||
|
||
/** | ||
* @brief Struct to produce a planner-specific planning profile to apply to a collection of waypoints defined in a | ||
* composite instruction. | ||
* @details Examples of composite profiles include costs/constraints that apply collectively to a group of waypoints | ||
*/ | ||
class CompositeProfile | ||
{ | ||
public: | ||
using Ptr = std::shared_ptr<CompositeProfile>; | ||
using ConstPtr = std::shared_ptr<const CompositeProfile>; | ||
|
||
CompositeProfile() = default; | ||
CompositeProfile(const CompositeProfile&) = delete; | ||
CompositeProfile& operator=(const CompositeProfile&) = delete; | ||
CompositeProfile(CompositeProfile&&) = delete; | ||
CompositeProfile&& operator=(CompositeProfile&&) = delete; | ||
|
||
virtual ~CompositeProfile() = default; | ||
virtual std::any create(const CompositeInstruction& instruction, | ||
tesseract_environment::Environment::ConstPtr env) const = 0; | ||
|
||
protected: | ||
friend class boost::serialization::access; | ||
template <class Archive> | ||
void serialize(Archive&, const unsigned int); // NOLINT | ||
}; | ||
|
||
/** | ||
* @brief Struct to produce configuration parameters for the motion planner | ||
*/ | ||
struct PlannerProfile | ||
{ | ||
public: | ||
using Ptr = std::shared_ptr<PlannerProfile>; | ||
using ConstPtr = std::shared_ptr<const PlannerProfile>; | ||
|
||
PlannerProfile() = default; | ||
PlannerProfile(const PlannerProfile&) = delete; | ||
PlannerProfile& operator=(const PlannerProfile&) = delete; | ||
PlannerProfile(PlannerProfile&&) = delete; | ||
PlannerProfile&& operator=(PlannerProfile&&) = delete; | ||
|
||
virtual ~PlannerProfile() = default; | ||
|
||
virtual std::any create() const = 0; | ||
|
||
protected: | ||
friend class boost::serialization::access; | ||
template <class Archive> | ||
void serialize(Archive&, const unsigned int); // NOLINT | ||
}; | ||
|
||
} // namespace tesseract_planning | ||
|
||
BOOST_SERIALIZATION_ASSUME_ABSTRACT(tesseract_planning::WaypointProfile); | ||
BOOST_SERIALIZATION_ASSUME_ABSTRACT(tesseract_planning::CompositeProfile); | ||
BOOST_SERIALIZATION_ASSUME_ABSTRACT(tesseract_planning::PlannerProfile); | ||
|
||
#endif // TESSERACT_MOTION_PLANNERS_CORE_PROFILES_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.