Loading...
Searching...
No Matches
VampMotionValidator.h
1#pragma once
2
3#include <ompl/base/MotionValidator.h>
4#include <ompl/base/SpaceInformation.h>
5#include <ompl/base/State.h>
6#include <ompl/base/spaces/RealVectorStateSpace.h>
7#include <ompl/util/Exception.h>
8
9#include <ompl/vamp/Utils.h>
10
11#include <vamp/planning/validate.hh>
12#include <vamp/collision/environment.hh>
13
14namespace ompl::vamp
15{
16 namespace ob = ompl::base;
17
18 //==========================================================================
19 // VAMP Motion Validator for OMPL
20 //==========================================================================
21
22 template <typename Robot, std::size_t rake = ::vamp::FloatVectorWidth>
23 class VampMotionValidator : public ob::MotionValidator
24 {
25 public:
26 using Environment = ::vamp::collision::Environment<::vamp::FloatVector<rake>>;
27
28 VampMotionValidator(ob::SpaceInformation *si, const Environment &env) : ob::MotionValidator(si), env_(env)
29 {
30 }
31
32 VampMotionValidator(const ob::SpaceInformationPtr &si, const Environment &env)
33 : ob::MotionValidator(si), env_(env)
34 {
35 }
36
37 auto checkMotion(const ob::State *s1, const ob::State *s2) const -> bool override
38 {
39 return ::vamp::planning::validate_motion<Robot, rake, Robot::resolution>(ompl_to_vamp<Robot>(s1),
40 ompl_to_vamp<Robot>(s2), env_);
41 }
42
43 auto checkMotion(const ob::State *s1, const ob::State *s2, std::pair<ob::State *, double> &last_valid) const
44 -> bool override
45 {
46 // throw ompl::Exception("VampMotionValidator::checkMotion with lastValid not implemented");
47 // TODO: VAMP does not support returning the last valid state, but it may become available in the future
48 last_valid.first = nullptr;
49 last_valid.second = 0.0;
50 return ::vamp::planning::validate_motion<Robot, rake, Robot::resolution>(ompl_to_vamp<Robot>(s1),
51 ompl_to_vamp<Robot>(s2), env_);
52 }
53
54 private:
55 const Environment &env_;
56 };
57
58} // namespace ompl::vamp
Abstract definition for a class checking the validity of motions – path segments between states....
The base class for space information. This contains all the information about the space planning is d...
Definition of an abstract state.
Definition State.h:50
auto checkMotion(const ob::State *s1, const ob::State *s2, std::pair< ob::State *, double > &last_valid) const -> bool override
Check if the path between two states is valid. Also compute the last state that was valid and the tim...
auto checkMotion(const ob::State *s1, const ob::State *s2) const -> bool override
Check if the path between two states (from s1 to s2) is valid. This function assumes s1 is valid.
This namespace contains sampling based planning routines shared by both planning under geometric cons...