diff --git a/python/status_server/server.py b/python/status_server/server.py index 71fbfbe0..82d08c83 100644 --- a/python/status_server/server.py +++ b/python/status_server/server.py @@ -43,12 +43,20 @@ def stopped(self): latest_pose_message = {} +def replace_nan_in_dict(d): + for k, v in d.items(): + if isinstance(v, dict): + replace_nan_in_dict(v) + elif isinstance(v, str) and v == "NaN": + d[k] = "0.0" + @app.route('/', methods=['GET', 'POST']) def index(): global latest_pose_message mutex.acquire() latest_json_data = latest_pose_message mutex.release() + replace_nan_in_dict(latest_json_data) return jsonify(latest_json_data), 200 def start_fe_server(options):