Skip to content

Commit

Permalink
Fix code formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
timonegk committed Apr 18, 2024
1 parent f1a3373 commit dc84e14
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
1 change: 0 additions & 1 deletion udp_bridge/message_handler.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import base64
import pickle
import zlib

Expand Down
18 changes: 10 additions & 8 deletions udp_bridge/sender.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@

import socket
from queue import Empty, Full, Queue
import zlib

import rclpy
from bitbots_utils.utils import get_parameters_from_other_node
from rclpy.executors import SingleThreadedExecutor
from rclpy.logging import LoggingSeverity
from rclpy.node import Node
from rclpy.qos import DurabilityPolicy, QoSProfile
from rclpy.subscription import Subscription
from rclpy.timer import Timer
from rclpy.qos import DurabilityPolicy, QoSProfile
from rclpy.logging import LoggingSeverity
from ros2topic.api import get_msg_class, get_topic_names

from udp_bridge.message_handler import MessageHandler
Expand Down Expand Up @@ -69,10 +68,10 @@ def __subscribe(self, backoff=1.0):
self.__subscriber = self.node.create_subscription(data_class, self.topic, self.__message_callback, 1)
if latched:
self.__latched_subscriber = self.node.create_subscription(
data_class,
self.topic,
lambda msg: self.__message_callback(msg, latched=True),
QoSProfile(depth=1, durability=DurabilityPolicy.TRANSIENT_LOCAL)
data_class,
self.topic,
lambda msg: self.__message_callback(msg, latched=True),
QoSProfile(depth=1, durability=DurabilityPolicy.TRANSIENT_LOCAL),
)
self.node.get_logger().debug(f"Subscribed to topic {self.topic}")
else:
Expand All @@ -81,7 +80,9 @@ def __subscribe(self, backoff=1.0):
logging_severity = LoggingSeverity.WARN
else:
logging_severity = LoggingSeverity.DEBUG
self.node.get_logger().log(f"Topic {self.topic} is not yet known. Retrying in {backoff} seconds", logging_severity)
self.node.get_logger().log(
f"Topic {self.topic} is not yet known. Retrying in {backoff} seconds", logging_severity
)
self.timer = self.node.create_timer(backoff, lambda: self.__subscribe(backoff * 1.2))

def __message_callback(self, data, latched=False):
Expand All @@ -104,6 +105,7 @@ def __message_callback(self, data, latched=False):
self.timer.cancel()
self.timer = self.node.create_timer(10.0, lambda: self.__message_callback(data, latched=True))


# @TODO: replace by usage of https://github.com/PickNikRobotics/generate_parameter_library
def validate_params(node: Node) -> bool:
result = True
Expand Down

0 comments on commit dc84e14

Please sign in to comment.