From 449dd44741c5093a567d69c71fc70f250c7fb5c9 Mon Sep 17 00:00:00 2001 From: Oleg Kalachev Date: Mon, 14 Jul 2025 09:52:49 +0300 Subject: [PATCH] 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. --- gazebo/Preferences.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) 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 } }