error: ‘this’ argument discards qualifiers [-fpermissive]
This is my code for the Adaptive Monte Carlo localization(AMCL) algorithm, a plugin using for ign gazebo(citadel) and ROS(melodic).
void amcl::Configure(const Entity &_entity, const std::shared_ptr<const sdf::element=""> &_sdf, EntityComponentManager &_ecm, EventManager &_eventMgr)
{ this->dataPtr->model = Model(_entity); if (!this->dataPtr->model.Valid(_ecm)) {
ignerr << "amcl plugin should be attached to a model entity. "
<< "Failed to initialize." << std::endl;
return;
}
// Obtain parameters from xacro file
if(_sdf->HasElement("topicRate"))
{
rate_ = _sdf->GetElement("topicRate")->Get<double>(); #############ERROR IN THIS LINE
}
else
{
rate_ = 10.0;
}
if(_sdf->HasElement("fixedFrame"))
{
fixed_frame_ = _sdf->GetElement("fixedFrame")->Get<std::string>(); ########ERROR IN THIS LINE
}
else
{
fixed_frame_ = "map";
}
if(_sdf->HasElement("robotFrame"))
{
robot_frame_ = _sdf->GetElement("robotFrame")->Get<std::string>(); #####ERROR IN THIS LINE
}
else
{
robot_frame_ = "base_link";
}
Error (as shown in the terminal)
error: passing ‘std::__shared_ptr_access<const sdf::v9::element,="" (__gnu_cxx::lock_policy)2,="" false,="" false="">::element_type’ {aka ‘const sdf::v9::Element’} as ‘this’ argument discards qualifiers [-fpermissive] rate = _sdf->GetElement("topicRate")->Get();
I have marked the lines in the code which throw this error.
Complete code can be found here with the header file (Amcl.hh)
Can anybody suggest a solution?