WIP: new visitors for cost & time#87
WIP: new visitors for cost & time#87colin-lewis-19 wants to merge 1 commit intoswri-robotics:masterfrom
Conversation
| #include <chrono> | ||
| #include <descartes_light/bgl/boost_graph_types.h> | ||
|
|
||
| #include <descartes_light/descartes_macros.h> | ||
| DESCARTES_IGNORE_WARNINGS_PUSH | ||
| #include <boost/graph/visitors.hpp> |
There was a problem hiding this comment.
Put includes from outside this project in between the ignore warnings macro
- #include <chrono>
#include <descartes_light/bgl/boost_graph_types.h>
#include <descartes_light/descartes_macros.h>
DESCARTES_IGNORE_WARNINGS_PUSH
#include <boost/graph/visitors.hpp>
+#include <chrono>|
|
||
| /** | ||
| * @brief Event visitor that terminates the search when a vertex in the last rung of the graph is found | ||
| * to be below the provided cost threshold |
There was a problem hiding this comment.
| * to be below the provided cost threshold | |
| * to be below the provided distance threshold |
| * @details Throws the vertex descriptor that is the termination of the path a valid vertex in the last rung | ||
| * is found |
There was a problem hiding this comment.
I assume this is only relevant for non-optimal searches like DFS, right? I would make note of that here
|
|
||
|
|
||
| /** | ||
| * @brief Event visitor that terminates the once a time threshold is met |
There was a problem hiding this comment.
| * @brief Event visitor that terminates the once a time threshold is met | |
| * @brief Event visitor that terminates the search after a time threshold has been exceeded |
|
|
||
| /** | ||
| * @brief Event visitor that terminates the once a time threshold is met | ||
| * @details How will this throw an end descriptor |
|
|
||
|
|
||
| /** | ||
| * @brief The timeout_exception class |
| * is found | ||
| */ | ||
| template <typename FloatType, typename EventType> | ||
| struct distance_terminator : public boost::base_visitor<distance_terminator<FloatType, EventType>> |
There was a problem hiding this comment.
Is there value in keeping this separate from the early_terminator? I could see these being combined where the distance_threshold has a default value of max float
| } | ||
| catch(const descartes_light::timeout_exception& te) | ||
| { | ||
| // If this has to be called in two places, make it a function. |
There was a problem hiding this comment.
I don't think I would be opposed to adding this as a helper function to BGLSolverBase since it's used multiple times here and in the Dijkstra search
| template <typename FloatType, typename EventType> | ||
| void time_terminator<FloatType, EventType>::operator()(VertexDesc<FloatType> u, const BGLGraph<FloatType>& g) | ||
| { | ||
| //if (time_threshold_ < std::chrono::duration<double>(std::chrono::steady_clock::now() - start_time_).count()) | ||
| throw false; | ||
| } |
There was a problem hiding this comment.
| template <typename FloatType, typename EventType> | |
| void time_terminator<FloatType, EventType>::operator()(VertexDesc<FloatType> u, const BGLGraph<FloatType>& g) | |
| { | |
| //if (time_threshold_ < std::chrono::duration<double>(std::chrono::steady_clock::now() - start_time_).count()) | |
| throw false; | |
| } | |
| template <typename FloatType, typename EventType> | |
| template<typename T> | |
| void time_terminator<FloatType, EventType>::operator()(T, const BGLGraph<FloatType>&) | |
| { | |
| if (time_threshold_ < std::chrono::duration<double>(std::chrono::steady_clock::now() - start_time_).count()) | |
| throw timeout_exception; | |
| } |
| class timeout_exception : public std::runtime_error { | ||
| public: | ||
| using std::runtime_error::runtime_error; | ||
| }; |
There was a problem hiding this comment.
I think if you use the default constructor of runtime_error you'll have to construct this exception with a string message which may not make sense. If you don't want to do this, you might be better off inheriting directly from std::exception
|
@marip8, @marrts, and @colin-lewis-19 what is left for this to be merged? |
New visitors for time & cost thresholds. Setting up the unit tests started to get out of hand, so I've opened this WIP so we can discuss the initial steps