Validity Checker declaration error

asked 2019-08-13 10:27:37 -0500

Costuz gravatar image

I'm having a problem with my code. It was working but when i decided to separate it in multiple files i get an error.

I have looked for other similar posts but still can't find what's wrong. This is my code:

.h

 #ifndef VALIDITYCHECKER_H
 #define VALIDITYCHECKER_H
 //#including various libraries...
 namespace ob = ompl::base;
class ValidityChecker : public ob::StateValidityChecker
 {
 public:
    ValidityChecker(const ob::SpaceInformationPtr& si) :
    ob::StateValidityChecker(si) {}
    bool isValid(const ob::State* state) const override
     {      
         return this-> clearance(state) > 0.0;
     }
    double clearance(const ob::State* state) const override;
  };
 #endif

.cpp

 #include "push_optimal_planner/validitychecker.h"
 //#including various libraries...
 namespace ob = ompl::base;
 namespace og = ompl::geometric;

 double ob::ValidityChecker::clearance(const ob::State* state)
 {  //some code for the function
  return lenght;
  }

I get this error:

error: ‘ob::ValidityChecker’ has not been declared  double ob::ValidityChecker::clearance(const ob::State* state)

What should i do?

edit retag flag offensive close merge delete

Comments

Your method definition double ob::ValidityChecker::clearance(const ob::State* state) refers to ValidityChecker within the ob namespace. But it is declared outside of a namespace from the code snipped you've given. Try double ValidityChecker::clearance(const ob::State* state)

PeteBlackerThe3rd gravatar imagePeteBlackerThe3rd ( 2019-08-13 10:39:14 -0500 )edit

Now i get 2 errors:

error: prototype for ‘double ValidityChecker::clearance(const ompl::base::State*)’ does not match any in class ‘ValidityChecker’

and

error: candidate is: virtual double ValidityChecker::clearance(const ompl::base::State*) const
     double clearance(const ob::State* state) const override;
Costuz gravatar imageCostuz ( 2019-08-13 11:02:02 -0500 )edit
1

Almost there. You're missing the const at the end of your method definition so it's not matching the declaration in your class. it should be: double ValidityChecker::clearance(const ob::State* state) const

PeteBlackerThe3rd gravatar imagePeteBlackerThe3rd ( 2019-08-13 11:33:55 -0500 )edit
1

Oh you're right! Thank you!

Costuz gravatar imageCostuz ( 2019-08-13 12:14:05 -0500 )edit