-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: ktro2828 <[email protected]>
- Loading branch information
Showing
17 changed files
with
639 additions
and
11 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
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 |
---|---|---|
|
@@ -20,4 +20,6 @@ | |
|
||
::: t4_devkit.dataclass.trajectory | ||
|
||
::: t4_devkit.dataclass.transform | ||
|
||
<!-- prettier-ignore-end --> |
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,12 @@ | ||
# `filtering` | ||
|
||
<!-- prettier-ignore-start --> | ||
::: t4_devkit.filtering.compose | ||
|
||
::: t4_devkit.filtering.functional | ||
options: | ||
filters: ["!BaseBoxFilter"] | ||
show_bases: false | ||
|
||
::: t4_devkit.filtering.parameter | ||
<!-- prettier-ignore-end --> |
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
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
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
from .compose import BoxFilter | ||
from .parameter import FilterParams | ||
|
||
__all__ = ["BoxFilter", "FilterParams"] |
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,53 @@ | ||
from __future__ import annotations | ||
|
||
from typing import TYPE_CHECKING, Sequence | ||
|
||
from .functional import ( | ||
FilterByDistance, | ||
FilterByLabel, | ||
FilterByNumPoints, | ||
FilterByPosition, | ||
FilterBySpeed, | ||
FilterByUUID, | ||
) | ||
from .parameter import FilterParams | ||
|
||
if TYPE_CHECKING: | ||
from t4_devkit.dataclass import BoxType, TransformBuffer | ||
|
||
from .functional import FilterLike | ||
|
||
|
||
class BoxFilter: | ||
"""A class composes multiple filtering functions.""" | ||
|
||
def __init__(self, params: FilterParams, tf_buffer: TransformBuffer) -> None: | ||
"""Construct a new object. | ||
Args: | ||
params (FilterParams): Filtering parameters. | ||
tf_buffer (TransformBuffer): Transformation buffer. | ||
""" | ||
self.filters: list[FilterLike] = [ | ||
FilterByLabel.from_params(params), | ||
FilterByUUID.from_params(params), | ||
FilterByDistance.from_params(params), | ||
FilterByPosition.from_params(params), | ||
FilterBySpeed.from_params(params), | ||
FilterByNumPoints.from_params(params), | ||
] | ||
|
||
self.tf_buffer = tf_buffer | ||
|
||
def __call__(self, boxes: Sequence[BoxType]) -> list[BoxType]: | ||
output: list[BoxType] = [] | ||
|
||
for box in boxes: | ||
tf_matrix = self.tf_buffer.lookup_transform(box.frame_id, "base_link") | ||
|
||
is_ok = all(func(box, tf_matrix) for func in self.filters) | ||
|
||
if is_ok: | ||
output.append(box) | ||
|
||
return output |
Oops, something went wrong.