mirror of
https://github.com/introlab/rtabmap.git
synced 2026-09-02 01:20:25 +08:00
changed all std::atof() to uStr2Float() to fix locale comma float conversion problem
This commit is contained in:
@@ -75,7 +75,7 @@ void BayesFilter::setPredictionLC(const std::string & prediction)
|
|||||||
bool valid = true;
|
bool valid = true;
|
||||||
for(std::list<std::string>::iterator iter = strValues.begin(); iter!=strValues.end(); ++iter)
|
for(std::list<std::string>::iterator iter = strValues.begin(); iter!=strValues.end(); ++iter)
|
||||||
{
|
{
|
||||||
tmpValues[i] = std::atof((*iter).c_str());
|
tmpValues[i] = uStr2Float((*iter).c_str());
|
||||||
//UINFO("%d=%e", i, tmpValues[i]);
|
//UINFO("%d=%e", i, tmpValues[i]);
|
||||||
if(tmpValues[i] < 0.0 || tmpValues[i]>1.0)
|
if(tmpValues[i] < 0.0 || tmpValues[i]>1.0)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -251,7 +251,7 @@ cv::Rect Feature2D::computeRoi(const cv::Mat & image, const std::string & roiRat
|
|||||||
unsigned int i=0;
|
unsigned int i=0;
|
||||||
for(std::list<std::string>::iterator iter = strValues.begin(); iter!=strValues.end(); ++iter)
|
for(std::list<std::string>::iterator iter = strValues.begin(); iter!=strValues.end(); ++iter)
|
||||||
{
|
{
|
||||||
values[i] = std::atof((*iter).c_str());
|
values[i] = uStr2Float(*iter);
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -439,12 +439,12 @@ bool loadTOROGraph(const std::string & fileName,
|
|||||||
{
|
{
|
||||||
//VERTEX3
|
//VERTEX3
|
||||||
int id = atoi(strList[1].c_str());
|
int id = atoi(strList[1].c_str());
|
||||||
float x = atof(strList[2].c_str());
|
float x = uStr2Float(strList[2]);
|
||||||
float y = atof(strList[3].c_str());
|
float y = uStr2Float(strList[3]);
|
||||||
float z = atof(strList[4].c_str());
|
float z = uStr2Float(strList[4]);
|
||||||
float roll = atof(strList[5].c_str());
|
float roll = uStr2Float(strList[5]);
|
||||||
float pitch = atof(strList[6].c_str());
|
float pitch = uStr2Float(strList[6]);
|
||||||
float yaw = atof(strList[7].c_str());
|
float yaw = uStr2Float(strList[7]);
|
||||||
Transform pose = Transform::fromEigen3f(pcl::getTransformation(x, y, z, roll, pitch, yaw));
|
Transform pose = Transform::fromEigen3f(pcl::getTransformation(x, y, z, roll, pitch, yaw));
|
||||||
std::map<int, Transform>::iterator iter = poses.find(id);
|
std::map<int, Transform>::iterator iter = poses.find(id);
|
||||||
if(iter != poses.end())
|
if(iter != poses.end())
|
||||||
@@ -461,12 +461,12 @@ bool loadTOROGraph(const std::string & fileName,
|
|||||||
//EDGE3
|
//EDGE3
|
||||||
int idFrom = atoi(strList[1].c_str());
|
int idFrom = atoi(strList[1].c_str());
|
||||||
int idTo = atoi(strList[2].c_str());
|
int idTo = atoi(strList[2].c_str());
|
||||||
float x = atof(strList[3].c_str());
|
float x = uStr2Float(strList[3]);
|
||||||
float y = atof(strList[4].c_str());
|
float y = uStr2Float(strList[4]);
|
||||||
float z = atof(strList[5].c_str());
|
float z = uStr2Float(strList[5]);
|
||||||
float roll = atof(strList[6].c_str());
|
float roll = uStr2Float(strList[6]);
|
||||||
float pitch = atof(strList[7].c_str());
|
float pitch = uStr2Float(strList[7]);
|
||||||
float yaw = atof(strList[8].c_str());
|
float yaw = uStr2Float(strList[8]);
|
||||||
Transform transform = Transform::fromEigen3f(pcl::getTransformation(x, y, z, roll, pitch, yaw));
|
Transform transform = Transform::fromEigen3f(pcl::getTransformation(x, y, z, roll, pitch, yaw));
|
||||||
if(poses.find(idFrom) != poses.end() && poses.find(idTo) != poses.end())
|
if(poses.find(idFrom) != poses.end() && poses.find(idTo) != poses.end())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -611,7 +611,7 @@ void Memory::setRoi(const std::string & roi)
|
|||||||
unsigned int i=0;
|
unsigned int i=0;
|
||||||
for(std::list<std::string>::iterator iter = strValues.begin(); iter!=strValues.end(); ++iter)
|
for(std::list<std::string>::iterator iter = strValues.begin(); iter!=strValues.end(); ++iter)
|
||||||
{
|
{
|
||||||
tmpValues[i] = std::atof((*iter).c_str());
|
tmpValues[i] = uStr2Float(*iter);
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
#include <rtabmap/utilite/UConversion.h>
|
#include <rtabmap/utilite/UConversion.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
namespace rtabmap
|
namespace rtabmap
|
||||||
{
|
{
|
||||||
@@ -112,7 +113,7 @@ void Parameters::parse(const ParametersMap & parameters, const std::string & key
|
|||||||
ParametersMap::const_iterator iter = parameters.find(key);
|
ParametersMap::const_iterator iter = parameters.find(key);
|
||||||
if(iter != parameters.end())
|
if(iter != parameters.end())
|
||||||
{
|
{
|
||||||
value = atof(iter->second.c_str());
|
value = uStr2Float(iter->second);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void Parameters::parse(const ParametersMap & parameters, const std::string & key, double & value)
|
void Parameters::parse(const ParametersMap & parameters, const std::string & key, double & value)
|
||||||
@@ -120,7 +121,7 @@ void Parameters::parse(const ParametersMap & parameters, const std::string & key
|
|||||||
ParametersMap::const_iterator iter = parameters.find(key);
|
ParametersMap::const_iterator iter = parameters.find(key);
|
||||||
if(iter != parameters.end())
|
if(iter != parameters.end())
|
||||||
{
|
{
|
||||||
value = atof(iter->second.c_str());
|
value = uStr2Double(iter->second);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void Parameters::parse(const ParametersMap & parameters, const std::string & key, std::string & value)
|
void Parameters::parse(const ParametersMap & parameters, const std::string & key, std::string & value)
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ void VWDictionary::parseParameters(const ParametersMap & parameters)
|
|||||||
Parameters::parse(parameters, Parameters::kKpNndrRatio(), _nndrRatio);
|
Parameters::parse(parameters, Parameters::kKpNndrRatio(), _nndrRatio);
|
||||||
Parameters::parse(parameters, Parameters::kKpNewWordsComparedTogether(), _newWordsComparedTogether);
|
Parameters::parse(parameters, Parameters::kKpNewWordsComparedTogether(), _newWordsComparedTogether);
|
||||||
|
|
||||||
UASSERT(_nndrRatio > 0.0f);
|
UASSERT_MSG(_nndrRatio > 0.0f, uFormat("String=%s value=%f", uContains(parameters, Parameters::kKpNndrRatio())?parameters.at(Parameters::kKpNndrRatio()).c_str():"", _nndrRatio).c_str());
|
||||||
|
|
||||||
std::string dictionaryPath = _dictionaryPath;
|
std::string dictionaryPath = _dictionaryPath;
|
||||||
bool incrementalDictionary = _incrementalDictionary;
|
bool incrementalDictionary = _incrementalDictionary;
|
||||||
@@ -167,7 +167,7 @@ void VWDictionary::setFixedDictionary(const std::string & dictionaryPath)
|
|||||||
//get descriptor
|
//get descriptor
|
||||||
for(;i<dimension && iter != strList.end(); ++i, ++iter)
|
for(;i<dimension && iter != strList.end(); ++i, ++iter)
|
||||||
{
|
{
|
||||||
descriptor.at<float>(i) = std::atof(iter->c_str());
|
descriptor.at<float>(i) = uStr2Float(*iter);
|
||||||
}
|
}
|
||||||
if(i != dimension)
|
if(i != dimension)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -423,7 +423,7 @@ MainWindow::MainWindow(PreferencesDialog * prefDialog, QWidget * parent) :
|
|||||||
// update loop closure viewer parameters
|
// update loop closure viewer parameters
|
||||||
ParametersMap parameters = _preferencesDialog->getAllParameters();
|
ParametersMap parameters = _preferencesDialog->getAllParameters();
|
||||||
_ui->widget_loopClosureViewer->setDecimation(atoi(parameters.at(Parameters::kLccIcp3Decimation()).c_str()));
|
_ui->widget_loopClosureViewer->setDecimation(atoi(parameters.at(Parameters::kLccIcp3Decimation()).c_str()));
|
||||||
_ui->widget_loopClosureViewer->setMaxDepth(atof(parameters.at(Parameters::kLccIcp3MaxDepth()).c_str()));
|
_ui->widget_loopClosureViewer->setMaxDepth(uStr2Float(parameters.at(Parameters::kLccIcp3MaxDepth())));
|
||||||
_ui->widget_loopClosureViewer->setSamples(atoi(parameters.at(Parameters::kLccIcp3Samples()).c_str()));
|
_ui->widget_loopClosureViewer->setSamples(atoi(parameters.at(Parameters::kLccIcp3Samples()).c_str()));
|
||||||
|
|
||||||
//update ui
|
//update ui
|
||||||
@@ -1942,7 +1942,7 @@ void MainWindow::applyPrefSettings(const rtabmap::ParametersMap & parameters)
|
|||||||
}
|
}
|
||||||
if(uContains(parameters, Parameters::kLccIcp3MaxDepth()))
|
if(uContains(parameters, Parameters::kLccIcp3MaxDepth()))
|
||||||
{
|
{
|
||||||
_ui->widget_loopClosureViewer->setMaxDepth(atof(parameters.at(Parameters::kLccIcp3MaxDepth()).c_str()));
|
_ui->widget_loopClosureViewer->setMaxDepth(uStr2Float(parameters.at(Parameters::kLccIcp3MaxDepth())));
|
||||||
}
|
}
|
||||||
if(uContains(parameters, Parameters::kLccIcp3Samples()))
|
if(uContains(parameters, Parameters::kLccIcp3Samples()))
|
||||||
{
|
{
|
||||||
@@ -2320,8 +2320,8 @@ void MainWindow::startDetection()
|
|||||||
_preferencesDialog->isSourceDatabaseUsed())
|
_preferencesDialog->isSourceDatabaseUsed())
|
||||||
{
|
{
|
||||||
float inputRate = _preferencesDialog->getGeneralInputRate();
|
float inputRate = _preferencesDialog->getGeneralInputRate();
|
||||||
float detectionRate = std::atof(parameters.at(Parameters::kRtabmapDetectionRate()).c_str());
|
float detectionRate = uStr2Float(parameters.at(Parameters::kRtabmapDetectionRate()));
|
||||||
int bufferingSize = std::atof(parameters.at(Parameters::kRtabmapImageBufferSize()).c_str());
|
int bufferingSize = uStr2Float(parameters.at(Parameters::kRtabmapImageBufferSize()));
|
||||||
if((detectionRate!=0.0f && detectionRate < inputRate) || (detectionRate > 0.0f && inputRate == 0.0f))
|
if((detectionRate!=0.0f && detectionRate < inputRate) || (detectionRate > 0.0f && inputRate == 0.0f))
|
||||||
{
|
{
|
||||||
int button = QMessageBox::question(this,
|
int button = QMessageBox::question(this,
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
#include "rtabmap/utilite/ULogger.h"
|
#include "rtabmap/utilite/ULogger.h"
|
||||||
#include "rtabmap/utilite/UFile.h"
|
#include "rtabmap/utilite/UFile.h"
|
||||||
#include "rtabmap/utilite/UDirectory.h"
|
#include "rtabmap/utilite/UDirectory.h"
|
||||||
|
#include "rtabmap/utilite/UConversion.h"
|
||||||
#include <opencv2/highgui/highgui.hpp>
|
#include <opencv2/highgui/highgui.hpp>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
@@ -61,7 +62,7 @@ int main(int argc, char * argv[])
|
|||||||
++i;
|
++i;
|
||||||
if(i < argc)
|
if(i < argc)
|
||||||
{
|
{
|
||||||
rate = std::atof(argv[i]);
|
rate = uStr2Float(argv[i]);
|
||||||
if(rate < 0)
|
if(rate < 0)
|
||||||
{
|
{
|
||||||
showUsage();
|
showUsage();
|
||||||
|
|||||||
@@ -144,7 +144,7 @@ int main(int argc, char * argv[])
|
|||||||
++i;
|
++i;
|
||||||
if(i < argc)
|
if(i < argc)
|
||||||
{
|
{
|
||||||
rate = std::atof(argv[i]);
|
rate = uStr2Float(argv[i]);
|
||||||
if(rate < 0)
|
if(rate < 0)
|
||||||
{
|
{
|
||||||
showUsage();
|
showUsage();
|
||||||
@@ -161,7 +161,7 @@ int main(int argc, char * argv[])
|
|||||||
++i;
|
++i;
|
||||||
if(i < argc)
|
if(i < argc)
|
||||||
{
|
{
|
||||||
rate = std::atof(argv[i]);
|
rate = uStr2Float(argv[i]);
|
||||||
if(rate < 0)
|
if(rate < 0)
|
||||||
{
|
{
|
||||||
showUsage();
|
showUsage();
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
|
|
||||||
#include <rtabmap/utilite/ULogger.h>
|
#include <rtabmap/utilite/ULogger.h>
|
||||||
#include <rtabmap/utilite/UFile.h>
|
#include <rtabmap/utilite/UFile.h>
|
||||||
|
#include <rtabmap/utilite/UConversion.h>
|
||||||
#include <rtabmap/core/CameraThread.h>
|
#include <rtabmap/core/CameraThread.h>
|
||||||
#include <rtabmap/core/CameraRGBD.h>
|
#include <rtabmap/core/CameraRGBD.h>
|
||||||
#include <rtabmap/core/Camera.h>
|
#include <rtabmap/core/Camera.h>
|
||||||
@@ -91,7 +92,7 @@ int main (int argc, char * argv[])
|
|||||||
++i;
|
++i;
|
||||||
if(i < argc)
|
if(i < argc)
|
||||||
{
|
{
|
||||||
rate = std::atof(argv[i]);
|
rate = uStr2Float(argv[i]);
|
||||||
if(rate < 0.0f)
|
if(rate < 0.0f)
|
||||||
{
|
{
|
||||||
showUsage();
|
showUsage();
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ int main(int argc, char *argv[])
|
|||||||
++i;
|
++i;
|
||||||
if(i < argc)
|
if(i < argc)
|
||||||
{
|
{
|
||||||
planeDistanceThreshold = std::atof(argv[i]);
|
planeDistanceThreshold = uStr2Float(argv[i]);
|
||||||
if(planeDistanceThreshold < 0.0f)
|
if(planeDistanceThreshold < 0.0f)
|
||||||
{
|
{
|
||||||
showUsage();
|
showUsage();
|
||||||
@@ -89,7 +89,7 @@ int main(int argc, char *argv[])
|
|||||||
++i;
|
++i;
|
||||||
if(i < argc)
|
if(i < argc)
|
||||||
{
|
{
|
||||||
planeEpsAngle = std::atof(argv[i]);
|
planeEpsAngle = uStr2Float(argv[i]);
|
||||||
if(planeEpsAngle < 0.0f)
|
if(planeEpsAngle < 0.0f)
|
||||||
{
|
{
|
||||||
showUsage();
|
showUsage();
|
||||||
@@ -106,7 +106,7 @@ int main(int argc, char *argv[])
|
|||||||
++i;
|
++i;
|
||||||
if(i < argc)
|
if(i < argc)
|
||||||
{
|
{
|
||||||
clusterTolerance = std::atof(argv[i]);
|
clusterTolerance = uStr2Float(argv[i]);
|
||||||
if(clusterTolerance <= 0.0f)
|
if(clusterTolerance <= 0.0f)
|
||||||
{
|
{
|
||||||
showUsage();
|
showUsage();
|
||||||
|
|||||||
@@ -175,7 +175,7 @@ int main (int argc, char * argv[])
|
|||||||
++i;
|
++i;
|
||||||
if(i < argc)
|
if(i < argc)
|
||||||
{
|
{
|
||||||
nndr = std::atof(argv[i]);
|
nndr = uStr2Float(argv[i]);
|
||||||
if(nndr < 0.0f)
|
if(nndr < 0.0f)
|
||||||
{
|
{
|
||||||
showUsage();
|
showUsage();
|
||||||
@@ -192,7 +192,7 @@ int main (int argc, char * argv[])
|
|||||||
++i;
|
++i;
|
||||||
if(i < argc)
|
if(i < argc)
|
||||||
{
|
{
|
||||||
rate = std::atof(argv[i]);
|
rate = uStr2Float(argv[i]);
|
||||||
if(rate < 0)
|
if(rate < 0)
|
||||||
{
|
{
|
||||||
showUsage();
|
showUsage();
|
||||||
@@ -244,7 +244,7 @@ int main (int argc, char * argv[])
|
|||||||
++i;
|
++i;
|
||||||
if(i < argc)
|
if(i < argc)
|
||||||
{
|
{
|
||||||
sec = std::atof(argv[i]);
|
sec = uStr2Float(argv[i]);
|
||||||
if(sec < 0.0f)
|
if(sec < 0.0f)
|
||||||
{
|
{
|
||||||
showUsage();
|
showUsage();
|
||||||
@@ -261,7 +261,7 @@ int main (int argc, char * argv[])
|
|||||||
++i;
|
++i;
|
||||||
if(i < argc)
|
if(i < argc)
|
||||||
{
|
{
|
||||||
distance = std::atof(argv[i]);
|
distance = uStr2Float(argv[i]);
|
||||||
if(distance <= 0)
|
if(distance <= 0)
|
||||||
{
|
{
|
||||||
showUsage();
|
showUsage();
|
||||||
@@ -312,7 +312,7 @@ int main (int argc, char * argv[])
|
|||||||
++i;
|
++i;
|
||||||
if(i < argc)
|
if(i < argc)
|
||||||
{
|
{
|
||||||
maxDepth = std::atof(argv[i]);
|
maxDepth = uStr2Float(argv[i]);
|
||||||
if(maxDepth < 0)
|
if(maxDepth < 0)
|
||||||
{
|
{
|
||||||
showUsage();
|
showUsage();
|
||||||
@@ -380,7 +380,7 @@ int main (int argc, char * argv[])
|
|||||||
++i;
|
++i;
|
||||||
if(i < argc)
|
if(i < argc)
|
||||||
{
|
{
|
||||||
voxel = std::atof(argv[i]);
|
voxel = uStr2Float(argv[i]);
|
||||||
if(voxel < 0)
|
if(voxel < 0)
|
||||||
{
|
{
|
||||||
showUsage();
|
showUsage();
|
||||||
@@ -414,7 +414,7 @@ int main (int argc, char * argv[])
|
|||||||
++i;
|
++i;
|
||||||
if(i < argc)
|
if(i < argc)
|
||||||
{
|
{
|
||||||
ratio = std::atof(argv[i]);
|
ratio = uStr2Float(argv[i]);
|
||||||
if(ratio < 0.0f)
|
if(ratio < 0.0f)
|
||||||
{
|
{
|
||||||
showUsage();
|
showUsage();
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ int main(int argc, char * argv[])
|
|||||||
//get descriptor
|
//get descriptor
|
||||||
for(;i<dimension && iter != strList.end(); ++i, ++iter)
|
for(;i<dimension && iter != strList.end(); ++i, ++iter)
|
||||||
{
|
{
|
||||||
descriptor[i] = std::atof(iter->c_str());
|
descriptor[i] = uStr2Float(*iter);
|
||||||
}
|
}
|
||||||
if(i != dimension)
|
if(i != dimension)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -117,6 +117,22 @@ std::string UTILITE_EXP uNumber2Str(float number);
|
|||||||
*/
|
*/
|
||||||
std::string UTILITE_EXP uNumber2Str(double number);
|
std::string UTILITE_EXP uNumber2Str(double number);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert a string to a float independent of the locale (comma/dot).
|
||||||
|
* @param the string
|
||||||
|
* @return the number
|
||||||
|
*/
|
||||||
|
float UTILITE_EXP uStr2Float(const std::string & str);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert a string to a double independent of the locale (comma/dot).
|
||||||
|
* @param the string
|
||||||
|
* @return the number
|
||||||
|
*/
|
||||||
|
double UTILITE_EXP uStr2Double(const std::string & str);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert a bool to a string.
|
* Convert a bool to a string.
|
||||||
* The format used is "true" and "false".
|
* The format used is "true" and "false".
|
||||||
|
|||||||
@@ -113,6 +113,24 @@ std::string uNumber2Str(double number)
|
|||||||
return s.str();
|
return s.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float uStr2Float(const std::string & str)
|
||||||
|
{
|
||||||
|
float value = 0.0f;
|
||||||
|
std::istringstream istr(uReplaceChar(str, ',', '.').c_str());
|
||||||
|
istr.imbue(std::locale("C"));
|
||||||
|
istr >> value;
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
double uStr2Double(const std::string & str)
|
||||||
|
{
|
||||||
|
double value = 0.0;
|
||||||
|
std::istringstream istr(uReplaceChar(str, ',', '.').c_str());
|
||||||
|
istr.imbue(std::locale("C"));
|
||||||
|
istr >> value;
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
std::string uBool2Str(bool boolean)
|
std::string uBool2Str(bool boolean)
|
||||||
{
|
{
|
||||||
std::string s;
|
std::string s;
|
||||||
|
|||||||
Reference in New Issue
Block a user