in deepracer_navigation_pkg/deepracer_navigation_pkg/deepracer_navigation_node.py [0:0]
def __init__(self):
"""Create a DRNavigationNode.
"""
super().__init__('deepracer_navigation_node')
self.get_logger().info("deepracer_navigation_node started")
# Initialize the listener for inference data
self.infer_listener()
# Publisher that sends driving messages to the servo
# Create a reentrant callback group to publish autonomous drive messages.
auto_drive_pub_msg_cb_group = ReentrantCallbackGroup()
self.auto_drive_publisher = self.create_publisher(ServoCtrlMsg,
constants.AUTO_DRIVE_TOPIC_NAME,
1)
# Service for dynamically setting the throttle in autonomous mode
self.throttle_service_cb_group = ReentrantCallbackGroup()
self.throttle_service = self.create_service(NavThrottleSrv,
constants.NAVIGATION_THROTTLE_SERVICE_NAME,
self.set_throttle_scale_cb,
callback_group=self.throttle_service_cb_group)
# Throttle can be set dynamically through the navigation_throttle service
self.throttle_scale = 0.0
# Service for setting the action space
self.action_space_service = self.create_service(LoadModelSrv,
constants.LOAD_ACTION_SPACE_SERVICE_NAME,
self.set_action_space_cb)
# Action space that maps inference results to steering and throttle values
self.action_space = constants.DEFAULT_ACTION_SPACE
# Action space type passed as part of model_metadata.json
self.action_space_type = constants.ActionSpaceTypes.DISCRETE
# Dictionary that stores the max of the steering and max value of the throttle
# These values are used to map the action space to valid steering and throttle values
self.max_action_space_values = {constants.ModelMetadataKeys.STEERING: 0.0,
constants.ModelMetadataKeys.SPEED: 0.0}
# Coeffiecent for the non linear mapping of the velocity
self.speed_mapping_coeficients = {'a': 0.0, 'b': 0.0}
# Set the action value scales for the default space.
self.set_action_space_scales()
self.timer_count = 0
self.timer = self.create_timer(5.0, self.timer_callback)
self.get_logger().info("DeepRacer navigation node successfully created")