Skip to content
Snippets Groups Projects
Commit 245670f5 authored by Joseph Mirabel's avatar Joseph Mirabel Committed by Joseph Mirabel
Browse files

GraphSteeringMethod is built with a const Problem& (not a ProblemPtr_t)

parent a3cce3b8
No related branches found
No related tags found
No related merge requests found
...@@ -38,16 +38,16 @@ namespace hpp { ...@@ -38,16 +38,16 @@ namespace hpp {
public: public:
/// Create instance and return shared pointer /// Create instance and return shared pointer
/// \warning core::ProblemPtr_t will be casted to ProblemPtr_t /// \warning core::Problem will be casted to Problem
static GraphSteeringMethodPtr_t create static GraphSteeringMethodPtr_t create
(const core::ProblemPtr_t& problem); (const core::Problem& problem);
template <typename T> template <typename T>
static GraphSteeringMethodPtr_t create static GraphSteeringMethodPtr_t create
(const core::ProblemPtr_t& problem); (const core::Problem& problem);
/// Create instance and return shared pointer /// Create instance and return shared pointer
static GraphSteeringMethodPtr_t create (const ProblemPtr_t& problem); static GraphSteeringMethodPtr_t create (const Problem& problem);
/// Create copy and return shared pointer /// Create copy and return shared pointer
static GraphSteeringMethodPtr_t createCopy static GraphSteeringMethodPtr_t createCopy
...@@ -71,7 +71,7 @@ namespace hpp { ...@@ -71,7 +71,7 @@ namespace hpp {
protected: protected:
/// Constructor /// Constructor
GraphSteeringMethod (const ProblemPtr_t& problem); GraphSteeringMethod (const Problem& problem);
/// Copy constructor /// Copy constructor
GraphSteeringMethod (const GraphSteeringMethod&); GraphSteeringMethod (const GraphSteeringMethod&);
...@@ -86,7 +86,7 @@ namespace hpp { ...@@ -86,7 +86,7 @@ namespace hpp {
private: private:
/// A pointer to the problem /// A pointer to the problem
ProblemPtr_t problem_; const Problem& problem_;
/// Weak pointer to itself /// Weak pointer to itself
GraphSteeringMethodWkPtr_t weak_; GraphSteeringMethodWkPtr_t weak_;
/// The encapsulated steering method /// The encapsulated steering method
...@@ -95,7 +95,7 @@ namespace hpp { ...@@ -95,7 +95,7 @@ namespace hpp {
template <typename T> template <typename T>
GraphSteeringMethodPtr_t GraphSteeringMethod::create GraphSteeringMethodPtr_t GraphSteeringMethod::create
(const core::ProblemPtr_t& problem) (const core::Problem& problem)
{ {
GraphSteeringMethodPtr_t gsm = GraphSteeringMethod::create (problem); GraphSteeringMethodPtr_t gsm = GraphSteeringMethod::create (problem);
gsm->innerSteeringMethod (T::create (problem)); gsm->innerSteeringMethod (T::create (problem));
......
...@@ -27,16 +27,15 @@ ...@@ -27,16 +27,15 @@
namespace hpp { namespace hpp {
namespace manipulation { namespace manipulation {
GraphSteeringMethodPtr_t GraphSteeringMethod::create GraphSteeringMethodPtr_t GraphSteeringMethod::create
(const core::ProblemPtr_t& problem) (const core::Problem& problem)
{ {
assert (dynamic_cast <const ProblemPtr_t> (problem) != NULL dynamic_cast <const Problem&> (problem);
&& "Cast to const ProblemPtr_t failed"); const Problem& p = static_cast <const Problem&> (problem);
const ProblemPtr_t& p = static_cast <const ProblemPtr_t> (problem);
return create (p); return create (p);
} }
GraphSteeringMethodPtr_t GraphSteeringMethod::create GraphSteeringMethodPtr_t GraphSteeringMethod::create
(const ProblemPtr_t& problem) (const Problem& problem)
{ {
GraphSteeringMethod* ptr = new GraphSteeringMethod (problem); GraphSteeringMethod* ptr = new GraphSteeringMethod (problem);
GraphSteeringMethodPtr_t shPtr (ptr); GraphSteeringMethodPtr_t shPtr (ptr);
...@@ -53,7 +52,7 @@ namespace hpp { ...@@ -53,7 +52,7 @@ namespace hpp {
return shPtr; return shPtr;
} }
GraphSteeringMethod::GraphSteeringMethod (const ProblemPtr_t& problem) : GraphSteeringMethod::GraphSteeringMethod (const Problem& problem) :
SteeringMethod (problem), problem_ (problem), weak_ () SteeringMethod (problem), problem_ (problem), weak_ ()
{ {
} }
...@@ -66,7 +65,7 @@ namespace hpp { ...@@ -66,7 +65,7 @@ namespace hpp {
PathPtr_t GraphSteeringMethod::impl_compute (ConfigurationIn_t q1, ConfigurationIn_t q2) const PathPtr_t GraphSteeringMethod::impl_compute (ConfigurationIn_t q1, ConfigurationIn_t q2) const
{ {
graph::Edges_t possibleEdges; graph::Edges_t possibleEdges;
graph::Graph& graph = *problem_->constraintGraph (); const graph::Graph& graph = *problem_.constraintGraph ();
try { try {
possibleEdges = graph.getEdges possibleEdges = graph.getEdges
(graph.getState (q1), graph.getState (q2)); (graph.getState (q1), graph.getState (q2));
......
...@@ -27,7 +27,7 @@ namespace hpp { ...@@ -27,7 +27,7 @@ namespace hpp {
Problem::Problem (DevicePtr_t robot) Problem::Problem (DevicePtr_t robot)
: Parent (robot), graph_() : Parent (robot), graph_()
{ {
Parent::steeringMethod (GraphSteeringMethod::create (this)); Parent::steeringMethod (GraphSteeringMethod::create (*this));
distance (WeighedDistance::create (robot, graph_)); distance (WeighedDistance::create (robot, graph_));
setPathValidationFactory(core::DiscretizedCollisionChecking::create, 0.05); setPathValidationFactory(core::DiscretizedCollisionChecking::create, 0.05);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment