Skip to content

Commit ea1e3c4

Browse files
committed
catch error if ros 2 stream is not in current publishers
1 parent 4503318 commit ea1e3c4

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

formant_ros2_adapter/scripts/components/publisher/generic_publisher.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,17 @@ def publish_command(self, formant_stream, msg: str):
9696
self._publish_ros2_numeric(publisher, ros2_msg_type, msg)
9797
else:
9898
self._logger.warn(
99-
"Unsupported ROS2 message type for command: %s" % formant_stream
99+
"Unsupported ROS2 message type for command: %s"
100+
% formant_stream
100101
)
101102
continue
102103
else:
103-
self._logger.info(f"No publisher for formant stream {formant_stream}, skipping")
104+
self._logger.info(
105+
f"No publisher for formant stream {formant_stream}, skipping"
106+
)
104107

105108
def publish(self, formant_stream, msg):
106-
for publisher in self._publishers[formant_stream]:
109+
for publisher in self._publishers.get(formant_stream, []):
107110
# Get the ROS2 message type as a string
108111
ros2_msg_type = publisher.msg_type.__name__
109112

0 commit comments

Comments
 (0)