Skip to content

Commit

Permalink
fix: fix parking space hdg
Browse files Browse the repository at this point in the history
  • Loading branch information
daohu527 committed Sep 11, 2024
1 parent f8be5c7 commit df2be2b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
12 changes: 6 additions & 6 deletions imap/lib/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,16 +145,16 @@ def calc_length(points):
return length


def get_rotated_rectangle_points(center, hdg, height, width):
def get_rotated_rectangle_points(center, hdg, length, width):
cx, cy = center
half_height, half_width = height / 2, width / 2
half_length, half_width = length / 2, width / 2

# Rectangle's 4 corners relative to the center
corners = [
(-half_width, -half_height), # bottom-left
(half_width, -half_height), # bottom-right
(half_width, half_height), # top-right
(-half_width, half_height) # top-left
(-half_length, -half_width), # bottom-left
(half_length, -half_width), # bottom-right
(half_length, half_width), # top-right
(-half_length, half_width) # top-left
]

# Rotate each corner and translate by the center
Expand Down
7 changes: 5 additions & 2 deletions imap/lib/opendrive/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def parse_from(self, raw_object):
self.hdg = float(raw_object.attrib.get('hdg'))
self.pitch = float(raw_object.attrib.get('pitch'))
self.roll = float(raw_object.attrib.get('roll'))
self.radius = float(raw_object.attrib.get('radius'))
self.radius = raw_object.attrib.get('radius')
self.validLength = float(raw_object.attrib.get('validLength'))
self.dynamic = raw_object.attrib.get('dynamic')
self.perpToRoad = raw_object.attrib.get('perpToRoad')
Expand Down Expand Up @@ -91,8 +91,11 @@ def process_corners(self, reference_line):
reference_point3d = reference_line[idx]
inertial_point3d = shift_t(reference_point3d, self.t)
center = [inertial_point3d.x, inertial_point3d.y]
# todo(zero): Because the object's angle is relative to the road,
# the road's angle needs to be added 'self.hdg + reference_point3d.yaw',
# but do we need to consider the inclination of the road?
corners = get_rotated_rectangle_points(
center, self.hdg, self.height, self.width)
center, self.hdg + reference_point3d.yaw, self.length, self.width)
return corners


Expand Down

0 comments on commit df2be2b

Please sign in to comment.