Skip to content

Commit 3710025

Browse files
committed
updated message_to_json to handle NaN values
1 parent 4d403f8 commit 3710025

File tree

1 file changed

+6
-3
lines changed
  • formant_ros2_adapter/scripts/message_utils

1 file changed

+6
-3
lines changed

formant_ros2_adapter/scripts/message_utils/utils.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
np.float32: float,
2222
np.float64: float,
2323
bool_type: bool,
24-
bool:bool,
24+
bool: bool,
2525
}
2626

2727

@@ -36,13 +36,16 @@ def get_ros2_type_from_string(message_type_string: str):
3636
return getattr(module, path[-1])
3737
except Exception as e:
3838
print(
39-
"WARNING: Couldn't import ROS2 message type from string: %s %s" %
40-
(message_type_string, str(e)),
39+
"WARNING: Couldn't import ROS2 message type from string: %s %s"
40+
% (message_type_string, str(e)),
4141
)
4242
return None
4343

4444

4545
def parse(m):
46+
if type(m) == float:
47+
if float(m) != float(m):
48+
return None
4649
if type(m) in [bool, str, int, float]:
4750
return m
4851
elif type(m) == bytes:

0 commit comments

Comments
 (0)