CSVROSData Class¶
- class rosdata.utils.datareader.CSVROSData(csvfile: str)[source]¶
A utility class to provide easy accessibility to a CSV file created by ROSData tools.
- __getitem__(item)[source]¶
Can be used as a shorthand for the get_data method.
Examples
# equivalent to csvrosdata_obj.get_data(indices=0)csvrosdata_obj[0]# equivalent to csvrosdata_obj.get_data(fields=’timestamp’)csvrosdata_obj[‘timestamp’]# equivalent to csvrosdata_obj.get_data(indices=0, fields=’timestamp’)csvrosdata_obj[0, ‘timestamp’]
- __init__(csvfile: str) None [source]¶
Initialises a CSVROSData object where the class attributes, referred to as fields, will be the headers of the CSV file. For the pose data functions to be accesible the CSV file must contain the headers [‘pos_x’, ‘pos_y’, ‘pos_z’, ‘quat_w’, ‘quat_x’, ‘quat_y’, ‘quat_z’]. Numeric data will be stored as floats, all other data will be stored as strings except for the string ‘none’ which will be stored as None.
- Parameters
csvfile (str) – the path to the ROSData CSV file
- __len__() int [source]¶
returns the length of the data
- Returns
the length of the data
- Return type
int
- field_exists(field: str) bool [source]¶
Checks to see if a field exists within this CSV data
- Parameters
field (str) – the field
- Returns
true if the field exists
- Return type
bool
- get_data(indices=None, fields=None)[source]¶
Gets the entire data for a specific index, or the value for a field for a index, or gets the field for the entire data (e.g., all timestamps).
Examples
# return data for index 0data = csvrosdata_obj.get_data(0)# return all pos_x datadata = csvrosdata_obj.get_data(‘pos_x’)# return all fields for multiple indicesdata = csvrosdata_obj.get_data([0, 2])# return all data for a set of fieldsdata = csvrosdata_obj.get_data([‘pos_x’, ‘pos_z’])# return multiple fields for a specified index or a set of indicesdata = csvrosdata_obj.get_data(0, [‘pos_x’, ‘pos_z’])data = csvrosdata_obj.get_data([0, 2], [‘pos_x’, ‘pos_z’])- Parameters
indices (int, str, list) – the index or indices to be retrieved
fields (optional, int or str) – the field or fields to be retrieved
- Raises
ValueError – if too many arguments are provided
- Returns
either the data (list) for a given index, the value for a given index/field or the data (list) for a field across all indices.
- Return type
variable
- get_pose(index: int) spatialmath.pose3d.SE3 [source]¶
Gets the transform (spatialmath.SE3 object) for the given index.
- Parameters
index (int) – the index for the desired transform
- Returns
returns a spatialmath.SE3 object with the given transform, or None if a transform does not exist for this index.
- Return type
spatialmath.SE3
- get_pose_data(index: int) list [source]¶
Gets the transform (spatialmath.SE3 object) for the given index.
- Parameters
index (int) – the index for the desired transform
- Returns
returns a spatialmath.SE3 object with the given transform, or None if a transform does not exist for this index.
- Return type
spatialmath.SE3