Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: 2x processing speedup #581

Merged
merged 8 commits into from
Nov 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .driving_log_replayer.cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"youtalk",
"UMiho",
"nuscenes",
"devkit"
"devkit",
"fastjsonschema"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@

from ament_index_python.packages import get_package_share_directory
from builtin_interfaces.msg import Time
import fastjsonschema
from geometry_msgs.msg import Point
from geometry_msgs.msg import Polygon as RosPolygon
from geometry_msgs.msg import Pose
from geometry_msgs.msg import Quaternion as RosQuaternion
from geometry_msgs.msg import Vector3
import jsonschema
import numpy as np
from perception_eval.common import ObjectType
from perception_eval.common.object import DynamicObject
Expand Down Expand Up @@ -305,25 +305,28 @@ def fill_xyzw_quat(q: Quaternion | None) -> dict:
# utils for writing each perception frame result to a file
class FrameDescriptionWriter:
schema: dict = None
validate_func = None

@classmethod
def load_schema(cls) -> None:
if cls.schema is None:
if cls.schema is None or cls.validate_func is None:
package_share_directory = get_package_share_directory("driving_log_replayer")
schema_file_path = (
Path(package_share_directory) / "config" / "object_output_schema.json"
)
with schema_file_path.open() as file:
cls.schema = json.load(file)
cls.validate_func = fastjsonschema.compile(cls.schema)

@classmethod
def is_object_structure_valid(cls, objdata: dict | None) -> bool:
cls.load_schema()
try:
jsonschema.validate(objdata, cls.schema)
except jsonschema.exceptions.ValidationError:
cls.validate_func(objdata)
except fastjsonschema.exceptions.JsonSchemaException:
return False
return True
else:
return True

@staticmethod
def object_to_description(obj: ObjectType | None) -> dict:
Expand Down
2 changes: 1 addition & 1 deletion driving_log_replayer/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<exec_depend>driving_log_replayer_analyzer</exec_depend>
<exec_depend>lanelet2_extension_python</exec_depend>
<exec_depend>perception_eval</exec_depend>
<exec_depend>python3-jsonschema</exec_depend>
<exec_depend>python3-fastjsonschema</exec_depend>
<exec_depend>python3-pandas</exec_depend>
<exec_depend>python3-simplejson</exec_depend>
<exec_depend>python3-termcolor</exec_depend>
Expand Down
Loading