Parameters backward compatibility: check for typed parameters (not only string)

This commit is contained in:
matlabbe
2018-04-30 18:53:18 -04:00
parent d1763bd52e
commit 2c64849807
2 changed files with 44 additions and 4 deletions
+22 -2
View File
@@ -305,14 +305,34 @@ void CoreWrapper::onInit()
++iter)
{
std::string vStr;
bool vBool;
int vInt;
double vDouble;
std::string paramValue;
if(pnh.getParam(iter->first, vStr))
{
paramValue = vStr;
}
else if(pnh.getParam(iter->first, vBool))
{
paramValue = uBool2Str(vBool);
}
else if(pnh.getParam(iter->first, vDouble))
{
paramValue = uNumber2Str(vDouble);
}
else if(pnh.getParam(iter->first, vInt))
{
paramValue = uNumber2Str(vInt);
}
if(!paramValue.empty())
{
if(iter->second.first)
{
// can be migrated
uInsert(parameters_, ParametersPair(iter->second.second, vStr));
uInsert(parameters_, ParametersPair(iter->second.second, paramValue));
NODELET_WARN("Rtabmap: Parameter name changed: \"%s\" -> \"%s\". Please update your launch file accordingly. Value \"%s\" is still set to the new parameter name.",
iter->first.c_str(), iter->second.second.c_str(), vStr.c_str());
iter->first.c_str(), iter->second.second.c_str(), paramValue.c_str());
}
else
{
+22 -2
View File
@@ -129,14 +129,34 @@ private:
++iter)
{
std::string vStr;
bool vBool;
int vInt;
double vDouble;
std::string paramValue;
if(pnh.getParam(iter->first, vStr))
{
paramValue = vStr;
}
else if(pnh.getParam(iter->first, vBool))
{
paramValue = uBool2Str(vBool);
}
else if(pnh.getParam(iter->first, vDouble))
{
paramValue = uNumber2Str(vDouble);
}
else if(pnh.getParam(iter->first, vInt))
{
paramValue = uNumber2Str(vInt);
}
if(!paramValue.empty())
{
if(iter->second.first)
{
// can be migrated
uInsert(parameters, rtabmap::ParametersPair(iter->second.second, vStr));
uInsert(parameters, rtabmap::ParametersPair(iter->second.second, paramValue));
NODELET_ERROR("obstacles_detection: Parameter name changed: \"%s\" -> \"%s\". Please update your launch file accordingly. Value \"%s\" is still set to the new parameter name.",
iter->first.c_str(), iter->second.second.c_str(), vStr.c_str());
iter->first.c_str(), iter->second.second.c_str(), paramValue.c_str());
}
else
{