Validity Checker declaration error
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?
Asked by Costuz on 2019-08-13 10:27:37 UTC
Comments
Your method definition
double ob::ValidityChecker::clearance(const ob::State* state)
refers toValidityChecker
within the ob namespace. But it is declared outside of a namespace from the code snipped you've given. Trydouble ValidityChecker::clearance(const ob::State* state)
Asked by PeteBlackerThe3rd on 2019-08-13 10:39:14 UTC
Now i get 2 errors:
and
Asked by Costuz on 2019-08-13 11:02:02 UTC
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
Asked by PeteBlackerThe3rd on 2019-08-13 11:33:55 UTC
Oh you're right! Thank you!
Asked by Costuz on 2019-08-13 12:14:05 UTC