Skip to content

Commit

Permalink
feat: complete pRange for paramPoly3
Browse files Browse the repository at this point in the history
  • Loading branch information
daohu527 committed Nov 23, 2022
1 parent d2fe5be commit c2c0ec1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion imap/lib/opendrive/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ def convert_speed(speed_limit, speed_unit) -> float:
elif speed_unit == 'mph':
return float(speed_limit) * 0.44704
else:
print("Not support speed unit: {}".format(speed_unit))
print("Unsupported speed unit: {}".format(speed_unit))
return float(speed_limit)
15 changes: 11 additions & 4 deletions imap/lib/opendrive/plan_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,16 +183,23 @@ def parse_from(self, raw_geometry):
self.pRange = raw_param_poly3.attrib.get('pRange')

def sampling(self, delta_s):
# todo(zero): need to deal with pRange==normalized
sample_count = math.ceil(self.length / delta_s) + 1
tf = Transform(self.x, self.y, 0, self.hdg, 0, 0)

points = []
for i in range(sample_count):
local_s = min(i * delta_s, self.length)
s, t, theta = parametric_cubic_curve(
self.aU, self.bU, self.cU, self.dU,
self.aV, self.bV, self.cV, self.dV, local_s)
if pRange == "arcLength":
s, t, theta = parametric_cubic_curve(
self.aU, self.bU, self.cU, self.dU,
self.aV, self.bV, self.cV, self.dV, local_s)
elif pRange == "normalized":
s, t, theta = parametric_cubic_curve(
self.aU, self.bU, self.cU, self.dU,
self.aV, self.bV, self.cV, self.dV, local_s/self.length)
else:
print("Unsupported pRange type: {}".format(pRange))
return []
x, y, z = tf.transform(s, t, 0.0)

absolute_s = self.s + local_s
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="imap_box",
version="0.0.9",
version="0.1.0",
author="daohu527",
author_email="[email protected]",
description="High-resolution map visualization and conversion tool",
Expand Down

0 comments on commit c2c0ec1

Please sign in to comment.