-
Notifications
You must be signed in to change notification settings - Fork 760
Description
I found a strange error in the convertFromString method. If I use the behaviortree in a rqt-gui plugin, the conversion from string to double is wrong. For example "1.23" is converted to 1 instead of 1.23. This only happens if I use a rqt-gui plugin. When I use the behaviortree in a normal ROS node everything works fine.
I think this error is related to this topic: https://www.reddit.com/r/cpp/comments/2e68nd/stdstod_is_locale_dependant_but_the_docs_does_not/
Maybe Qt changes the used locale to another value, but I am not sure about this.
I have fixed it by using std::istringstream for the conversion instead of std::stod like it is explained in the post. My new version of convertFromString in basic_types.cpp is now the following:
template <>
double convertFromString<double>(StringView str)
{
std::istringstream iss(str.data());
iss.imbue(std::locale("C"));
double temp;
iss >> temp;
return temp;
}
This error is very confusing and generates really unexpected behaviors, so can you please fix it? But all in all I really like the library!