qsrlib_io.world_trace module¶
-
class
qsrlib_io.world_trace.Object_State(name, timestamp, x=nan, y=nan, z=nan, xsize=nan, ysize=nan, zsize=nan, rotation=(), *args, **kwargs)[source]¶ Bases:
objectData class structure that is holding various information about an object.
-
name= None¶ str: The name of the object
-
return_bounding_box_2d(xsize_minimal=0, ysize_minimal=0)[source]¶ Compute the 2D bounding box of the object.
Parameters: - xsize_minimal (int or float) – If object has no x-size (i.e. simply a point) then compute bounding box based on this minimal x-size.
- ysize_minimal – If object has no y-size (i.e. simply a point) then compute bounding box based on this minimal y-size.
Returns: The coordinates of the upper-left and bottom-right corners of the bounding box.
Return type: list
-
rotation¶ tuple or list of floats: Rotation of the object in roll-pitch-yaw form or quaternion (x,y,z,w) one.
-
timestamp= None¶ float: The timestamp of the object state, which matches the corresponding key t in World_Trace.trace[t].
-
x= None¶ int or float: x-coordinate of the center point.
-
xsize¶ positive int or float: Total x-size
-
y= None¶ int or float: y-coordinate of the center point.
-
ysize¶ positive int or float: Total y-size
-
z= None¶ int or float: z-coordinate of the center point.
-
zsize¶ positive int or float: Total z-size
-
-
class
qsrlib_io.world_trace.World_State(timestamp, objects=None)[source]¶ Bases:
objectData class structure that is holding various information about the world at a particular time.
-
add_object_state(object_state)[source]¶ Add/Overwrite an object state.
Parameters: object_state (Object_State) – Object state to be added in the world state. Returns:
-
objects= None¶ dict: Holds the state of the objects that exist in this world state, i.e. a dict of objects of type Object_State with the keys being the objects names.
-
timestamp= None¶ float: The timestamp of the object, which matches the corresponding key t in World_Trace.trace[t].
-
-
class
qsrlib_io.world_trace.World_Trace(description='', trace=None)[source]¶ Bases:
objectData class structure that is holding a time series of the world states.
-
add_object_state(object_state, timestamp=None)[source]¶ Add/Overwrite an Object_State object.
Parameters: - object_state (Object_State) – The object state.
- timestamp (int or float) – The timestamp where the object state is to be inserted, if not given it is added in the timestamp of the object state.
Returns:
-
add_object_state_series(object_states)[source]¶ Add a series of object states.
Parameters: object_states (list or tuple) – The object states, i.e. a list of Object_State objects. Returns:
-
add_object_track_from_list(obj_name, track, t0=0, **kwargs)[source]¶ Add the objects data to the world_trace from a list of values
Parameters: - obj_name (str) – name of object
- track (list) – List of values as [[x1, y1, w1, l1], [x2, y2, w2, l2], ...] or [[x1, y1], [x2, y2], ...].
- t0 (int or float) – First timestamp to offset timestamps.
- kwargs – Optional arguments.
Returns:
-
description= None¶ str: Optional description of the world.
-
get_at_timestamp_range(start, finish=None, copy_by_reference=False, include_finish=True)[source]¶ Return a subsample between start and finish timestamps.
Parameters: - start (int or float) – The start timestamp.
- finish – The finish timestamp. If empty then finish is set to the last timestamp.
- copy_by_reference (bool) – Return by value or by reference.
- include_finish (bool) – Whether to include or not the world state at the finish timestamp.
Returns: A subsample between start and finish.
Return type:
-
get_for_objects(objects_names, copy_by_reference=False)[source]¶ Return a subsample for requested objects.
Parameters: - objects_names (list or tuple) – The requested objects names.
- copy_by_reference (bool) – Return by value or by reference.
Returns: A subsample for the requested objects.
Return type:
-
get_for_objects_at_timestamp_range(start, finish, objects_names, copy_by_reference=False, include_finish=True, time_slicing_first=True)[source]¶ Return a subsample for requested objects between start and finish timestamps.
Parameters: - start (int or float) – The start timestamp.
- finish (bool) – The finish timestamp.
- objects_names – The requested objects names.
- copy_by_reference (bool) – Return by value or by reference.
- include_finish (bool) – Whether to include or not the world state at the finish timestamp.
- time_slicing_first (bool) – Perform time slicing first or object slicing, can be used to optimize the call.
Returns: A subsample for the requested objects between start and finish timestamps.
Return type:
-
get_last_state(copy_by_reference=False)[source]¶ Get the last world state.
Parameters: copy_by_reference (bool) – Return by value or by reference. Returns:
-
get_sorted_timestamps()[source]¶ Return a sorted list of the timestamps.
Returns: A sorted list of the timestamps. Return type: list
-
trace= None¶ dict: A time series of world states, i.e. a dict of objects of type World_State with the keys being the timestamps.
-