Skip to content

Commit

Permalink
Remove NaN from dict
Browse files Browse the repository at this point in the history
  • Loading branch information
lukes3315 committed Apr 22, 2024
1 parent 9e3cf6b commit 54ad48a
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions python/status_server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 54ad48a

Please sign in to comment.