-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
conversion from cont. to discretized
- Loading branch information
1 parent
fe9f22b
commit c1d0a38
Showing
4 changed files
with
37 additions
and
3 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -4,7 +4,7 @@ examples/debug.py | |
examples/test.py | ||
|
||
build_vscode/ | ||
|
||
venv_arch | ||
# NumPy saves and videos | ||
results/ | ||
tmp/ | ||
|
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
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 |
---|---|---|
@@ -1,20 +1,41 @@ | ||
from .waypoint import Waypoint | ||
from typing import List | ||
from .trajectory import Trajectory | ||
|
||
class DiscretizedTrajectory: | ||
waypoints: List[Waypoint] | ||
|
||
def __init__(self) -> None: | ||
pass | ||
|
||
def __len__(self) -> int: | ||
""" | ||
Number of waypoints of discretized trajectory. | ||
Must be implemented by child class. | ||
""" | ||
raise NotImplementedError("Must be implemented by child class.") | ||
|
||
def __getitem__(self, idx: int) -> Waypoint: | ||
""" | ||
Yields waypoint with index 'idx'. | ||
Must be implemented by child class. | ||
""" | ||
raise NotImplementedError("Must be implemented by child class.") | ||
raise NotImplementedError("Must be implemented by child class.") | ||
|
||
|
||
class DiscreteTrajectoryFromContinuous: | ||
_n_discretization_level: int | ||
_cont_trajectory: Trajectory | ||
|
||
def __init__(self, cont_traj: Trajectory, n_discretization_level: int=100) -> None: | ||
self._n_discretization_level = n_discretization_level | ||
self._cont_trajectory = cont_traj | ||
|
||
def __len__(self) -> int: | ||
return self._n_discretization_level | ||
|
||
def __getitem__(self, idx: int) -> Waypoint: | ||
t = float(idx) / float(self._n_discretization_level) | ||
wp = self._cont_trajectory.get_waypoint(t) | ||
return wp |
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