Skip to content

armgit / flix

Public Imported from GitHub
0

Making an ESP32-based quadcopter from scratch

Fix storing nans and infs in preferences in simulator Turns out file streams cannot parse nans and infs on some platforms, so use std::stof to parse.

Oleg Kalachev449dd44741c5
diff --git a/gazebo/Preferences.h b/gazebo/Preferences.h
index 73bf589..de7199f 100644
--- a/gazebo/Preferences.h
+++ b/gazebo/Preferences.h
@@ -14,10 +14,9 @@ private:
void readFromFile() {
std::ifstream file(storagePath);
- std::string key;
- float value;
+ std::string key, value;
while (file >> key >> value) {
- storage[key] = value;
+ storage[key] = std::stof(value); // using stof to support NaN and Infinity
}
}