-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Nitish Bhupathi Raju
authored and
Nitish Bhupathi Raju
committed
Jan 18, 2025
1 parent
31afdb3
commit 7dacc12
Showing
6 changed files
with
690 additions
and
14 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
from enum import Enum, auto | ||
|
||
|
||
class AgentMode(Enum): | ||
Normal = auto() | ||
SwitchLeft = auto() | ||
SwitchRight = auto() | ||
|
||
|
||
class TrackMode(Enum): | ||
T0 = auto() | ||
T1 = auto() | ||
M01 = auto() | ||
M10 = auto() | ||
|
||
|
||
class State: | ||
x: float | ||
y: float | ||
theta: float | ||
v: float | ||
agent_mode: AgentMode | ||
track_mode: TrackMode | ||
|
||
def __init__(self, x, y, theta, v, agent_mode: AgentMode, track_mode: TrackMode): | ||
pass | ||
|
||
|
||
from typing import List | ||
import copy | ||
|
||
#DL 1 | ||
# def decisionLogic(ego: State, other: State, track_map): | ||
# output = copy.deepcopy(ego) | ||
# if ego.agent_mode == AgentMode.Normal: | ||
# if ego.track_mode == other.track_mode and 6 < (other.x - ego.x) and (other.x - ego.x) < 8: | ||
# if track_map.h_exist(ego.track_mode, ego.agent_mode, AgentMode.SwitchLeft): | ||
# output.agent_mode = AgentMode.SwitchLeft | ||
# output.track_mode = track_map.h(ego.track_mode, ego.agent_mode, AgentMode.SwitchLeft) | ||
|
||
# if ego.track_mode == other.track_mode and 6 < (other.x - ego.x) and (other.x - ego.x) < 8: | ||
# if track_map.h_exist(ego.track_mode, ego.agent_mode, AgentMode.SwitchRight): | ||
# output.agent_mode = AgentMode.SwitchRight | ||
# output.track_mode = track_map.h(ego.track_mode, ego.agent_mode, AgentMode.SwitchRight) | ||
|
||
# if ego.agent_mode == AgentMode.SwitchLeft: | ||
# if ego.y >= 2.5: | ||
# output.agent_mode = AgentMode.Normal | ||
# output.track_mode = track_map.h(ego.track_mode, ego.agent_mode, AgentMode.Normal) | ||
# if ego.agent_mode == AgentMode.SwitchRight: | ||
# if ego.y <= -2.5: | ||
# output.agent_mode = AgentMode.Normal | ||
# output.track_mode = track_map.h(ego.track_mode, ego.agent_mode, AgentMode.Normal) | ||
# return output | ||
|
||
#DL 2 and 3 | ||
def decisionLogic(ego: State, other: State, track_map): | ||
output = copy.deepcopy(ego) | ||
if ego.agent_mode == AgentMode.Normal: | ||
if ego.track_mode == other.track_mode and 6 < other.dist and other.dist < 8: | ||
if track_map.h_exist(ego.track_mode, ego.agent_mode, AgentMode.SwitchLeft): | ||
output.agent_mode = AgentMode.SwitchLeft | ||
output.track_mode = track_map.h(ego.track_mode, ego.agent_mode, AgentMode.SwitchLeft) | ||
|
||
#drop | ||
#if ego.track_mode == other.track_mode and 6 < other.dist and other.dist < 8: | ||
if track_map.h_exist(ego.track_mode, ego.agent_mode, AgentMode.SwitchRight): | ||
output.agent_mode = AgentMode.SwitchRight | ||
output.track_mode = track_map.h(ego.track_mode, ego.agent_mode, AgentMode.SwitchRight) | ||
|
||
if ego.agent_mode == AgentMode.SwitchLeft: | ||
if ego.y >= 2.5: | ||
output.agent_mode = AgentMode.Normal | ||
output.track_mode = track_map.h(ego.track_mode, ego.agent_mode, AgentMode.Normal) | ||
if ego.agent_mode == AgentMode.SwitchRight: | ||
if ego.y <= -2.5: | ||
output.agent_mode = AgentMode.Normal | ||
output.track_mode = track_map.h(ego.track_mode, ego.agent_mode, AgentMode.Normal) | ||
return output |
Oops, something went wrong.