Skip to content

Commit

Permalink
feat: add config variable to override parking space length
Browse files Browse the repository at this point in the history
  • Loading branch information
HeadTriXz committed Jun 13, 2024
1 parent 6140aea commit be88535
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
9 changes: 6 additions & 3 deletions configs/config.defaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,15 @@ overtake:
range_threshold: 4.0 # meters

parking:
max_speed: 3
min_barrier_distance: -1.0 # meters
available_space:
static: true
static_value: 4.5 # meters
max_speed: 3.0 # km/h
min_barrier_distance: 0.0 # meters
min_distance: 2.0 # meters
angle_tolerance: 7 # degrees
straight_angle_margin: 3 # degrees
start_steering_offset: 0.0 # meters
start_steering_offset: -0.2 # meters

crosswalk:
lost_frames: 10
Expand Down
14 changes: 12 additions & 2 deletions src/utils/parking.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def park(self) -> None:
self.__wait_until_opening()
self.__wait_until_wall(estimate_length=True)

available_space = np.median(self.__lengths) / 1000
available_space = self.__get_available_space()
logging.info("Estimated parking space length: %.2f meters.", available_space)

if available_space < config["kart"]["dimensions"]["length"]:
Expand Down Expand Up @@ -104,6 +104,16 @@ def __estimate_length(self) -> None:
distance = math.sqrt(dist_front**2 + dist_back**2 - 2 * dist_front * dist_back * math.cos(angle_diff))
self.__lengths.append(distance)

def __get_available_space(self) -> float:
"""Get the available space in the parking spot.
:return: The available space in the parking spot.
"""
if config["parking"]["available_space"]["static"]:
return config["parking"]["available_space"]["static_value"]

return np.median(self.__lengths) / 1000

def __is_at_45_degree_angle(self) -> bool:
"""Check if the go-kart is at a 45-degree angle.
Expand Down Expand Up @@ -284,7 +294,7 @@ def __wait_until_wall(self, consecutive: int = 3, estimate_length: bool = False)
"""
found_wall = 0
while found_wall < consecutive:
if estimate_length:
if estimate_length and not config["parking"]["available_space"]["static"]:
self.__estimate_length()

if self.__lidar.free_range(265, 275, 3000):
Expand Down

0 comments on commit be88535

Please sign in to comment.