Skip to content

Commit

Permalink
shorter line lengths
Browse files Browse the repository at this point in the history
  • Loading branch information
InvincibleRMC committed Apr 30, 2024
1 parent a644095 commit 52a6cb7
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions mqtt_ros_bridge/bridge_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,14 @@ def __init__(self, args: list[str]) -> None:

for topic_info in self.topics.values():
if topic_info.publish_on_ros:
publisher = self.create_publisher(topic_info.msg_type, topic_info.topic, topic_info.ros_qos)
publisher = self.create_publisher(topic_info.msg_type, topic_info.topic,
topic_info.ros_qos)
self.ros_publishers[topic_info.topic] = publisher
self.mqtt_client.subscribe(topic_info.topic, qos=topic_info.mqtt_qos)
else:
callback = self.make_ros_callback(topic_info)
self.create_subscription(topic_info.msg_type, topic_info.topic, callback, topic_info.ros_qos)
self.create_subscription(topic_info.msg_type, topic_info.topic, callback,
topic_info.ros_qos)

self.mqtt_client.on_message = self.mqtt_callback

Expand Down Expand Up @@ -164,7 +166,8 @@ def make_ros_callback(self, topic_info: TopicMsgInfo[MsgLikeT]) -> Callable[[Msg
"""
def callback(msg: MsgLikeT) -> None:
self.get_logger().info(f'ROS RECEIVED: Topic: "{topic_info.topic}" Payload: "{msg}"')
self.mqtt_client.publish(topic_info.topic, topic_info.serializer.serialize(msg), topic_info.mqtt_qos)
self.mqtt_client.publish(topic_info.topic, topic_info.serializer.serialize(msg),
topic_info.mqtt_qos)

return callback

Expand Down

0 comments on commit 52a6cb7

Please sign in to comment.