Skip to content

Commit

Permalink
Merge pull request #63 from FormantIO/fix-ros2-ingesting-data-from-paths
Browse files Browse the repository at this point in the history
Fix: Ros2 data properly ingests when message path is set
  • Loading branch information
fvolcic authored Sep 4, 2024
2 parents 5cac23e + fe9fa01 commit 199a4fe
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions formant_ros2_adapter/scripts/components/subscriber/ingester.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,15 @@ def ingest(
# Handle the message based on its type
try:
if msg_type in [str, String, Char]:

# if msg has the data field, use that
if hasattr(msg, "data"):
ingested_data = msg.data

# if msg is already a string, use the msg itself.
elif type(msg) in [str]:
ingested_data = msg

self._fclient.post_text(
formant_stream,
str(ingested_data),
Expand All @@ -78,9 +84,15 @@ def ingest(
)

elif msg_type in [Bool, bool]:

# if msg has the data field, use that
if hasattr(msg, "data"):
ingested_data = msg.data

# if msg is already a bool, use the msg itself.
elif type(msg) in [bool]:
ingested_data = msg

self._fclient.post_bitset(
formant_stream,
{topic: ingested_data},
Expand All @@ -103,8 +115,13 @@ def ingest(
UInt64,
]:

# If msg has the data field, use that
if hasattr(msg, "data"):
ingested_data = msg.data

# If msg is already numeric type, use the msg itself.
elif type(msg) in [int, float]:
ingested_data = msg

self._fclient.post_numeric(
formant_stream,
Expand Down

0 comments on commit 199a4fe

Please sign in to comment.