in deepracer_systems_pkg/deepracer_systems_pkg/otg_module/otg_control_node.py [0:0]
def __init__(self):
"""Create a OTGControlNode.
"""
super().__init__("otg_control_node")
self.get_logger().info("otg_control_node started")
# Setup and Start OTG monitor.
self.init_otg()
# Threading lock object to safely check connection details and enable/disable otg.
self.otg_guard = threading.Lock()
# Flag to identify if the host is connected.
self.otg_connected = True
# Scheduler to queue the function calls and run them in a separate thread.
self.scheduler = scheduler.Scheduler(self.get_logger())
self.stop = threading.Event()
# Timer to periodically check for host connection and enable/disable otg.
if otg_config.ENABLE_OTG_PERIODIC_CHECK:
self.otg_check_timer = \
self.create_timer(otg_config.OTG_CHECK_PERIOD_IN_SECONDS,
self.check_otg_connection)
# Service to return host connection flag.
self.get_otg_link_state_service = \
self.create_service(OTGLinkStateSrv,
otg_config.GET_OTG_LINK_STATE_SERVICE_NAME,
self.get_otg_link_state)
# Heartbeat timer.
self.timer_count = 0
self.timer = self.create_timer(5.0, self.timer_callback)
self.get_logger().info("OTG Control node successfully created")