in deepracer_follow_the_leader_ws/ftl_navigation_pkg/ftl_navigation_pkg/ftl_navigation_node.py [0:0]
def plan_action(self, delta):
"""Helper method to calculate action to be undertaken from the detection delta
received from object_detection_node.
Args:
delta (list of floats): detection deltas in x and y axes respectively.
Returns:
(int): Action Space Category defined in constants.py
"""
delta_x = delta[0]
delta_y = delta[1]
if delta_y > constants.DeltaValueMap.REVERSE_DELTA_Y:
# Reverse Bracket
if delta_x <= constants.DeltaValueMap.REVERSE_RIGHT_DELTA_X:
# Fast Right
return constants.ACTION_SPACE[9][constants.ActionSpaceKeys.CATEGORY]
elif delta_x >= constants.DeltaValueMap.REVERSE_LEFT_DELTA_X:
# Fast Left
return constants.ACTION_SPACE[8][constants.ActionSpaceKeys.CATEGORY]
else:
# No steering
return constants.ACTION_SPACE[7][constants.ActionSpaceKeys.CATEGORY]
elif delta_y <= constants.DeltaValueMap.REVERSE_DELTA_Y \
and delta_y > constants.DeltaValueMap.FORWARD_DELTA_Y:
# No Action Bracket
return constants.ACTION_SPACE[1][constants.ActionSpaceKeys.CATEGORY]
elif delta_y <= constants.DeltaValueMap.FORWARD_DELTA_Y:
# Forward Bracket
if delta_x < constants.DeltaValueMap.FORWARD_LEFT_DELTA_X \
and delta_x > constants.DeltaValueMap.FORWARD_FAST_LEFT_DELTA_X:
# Slow Left
return constants.ACTION_SPACE[3][constants.ActionSpaceKeys.CATEGORY]
elif delta_x <= constants.DeltaValueMap.FORWARD_FAST_LEFT_DELTA_X:
# Fast Left
return constants.ACTION_SPACE[4][constants.ActionSpaceKeys.CATEGORY]
elif delta_x > constants.DeltaValueMap.FORWARD_RIGHT_DELTA_X \
and delta_x < constants.DeltaValueMap.FORWARD_FAST_RIGHT_DELTA_X:
# Slow Right
return constants.ACTION_SPACE[5][constants.ActionSpaceKeys.CATEGORY]
elif delta_x >= constants.DeltaValueMap.FORWARD_FAST_RIGHT_DELTA_X:
# Fast Right
return constants.ACTION_SPACE[6][constants.ActionSpaceKeys.CATEGORY]
else:
# No steering
return constants.ACTION_SPACE[2][constants.ActionSpaceKeys.CATEGORY]
else:
# No Action
return constants.ACTION_SPACE[1][constants.ActionSpaceKeys.CATEGORY]