tools package

Submodules

tools.Quaternion module

class tools.Quaternion.Quaternion(val: Optional[np.ndarray, Quaternion] = None, x: Optional[float] = None, y: Optional[float] = None, z: Optional[float] = None, w: Optional[float] = None, v: Optional[np.ndarray] = None, do_normalise: bool = False, euler: str = '')

Bases: object

Quaternion convenience class. Euler rotations are extrinsic: rotations about the fixed CS.

static about_axis(angle: ndarray, axis: ndarray) Quaternion

Returns the quaternion about the given axis. From: https://github.com/aipiano/ESEKF_IMU/blob/master/transformations.py

property angle

in radians

property axis
property conjugate
property euler_xyz_deg
property euler_xyz_rad
property euler_zyx_deg
property euler_zyx_rad
normalise() None

Normalises quaternion vector.

property rot
property sp_rot

Scipy Rotation object

property v
property wxyz
property xyzw

tools.config module

class tools.config.CameraConfig(*, start_frame: int = None, total_frames: Optional[Union[str, int]] = None, scale: int, with_notch: bool = False, noise: CameraNoise)

Bases: BaseModel

Configuration of the camera trajectory.

noise: CameraNoise
scale: int
classmethod set_total_frames(v) Optional[int]
start_frame: Optional[int]
total_frames: Optional[Union[str, int]]
with_notch: bool
class tools.config.CameraNoise(*, position: List[float], theta: List[float], notch: float)

Bases: BaseModel

Settings for the noise matrix of the visual measurements. Angle values are given in degrees by the user in the yaml file, but are converted to radians for simulation.

notch: float
position: List[float]
theta: List[float]
classmethod to_radians(v) Union[list, float]
property vec: ndarray
class tools.config.Config(filepath: Union[Path, str])

Bases: object

Configuration object that contains settings for the simulation, models, trajectories as well as initial conditions.

property dofs_updated: bool
print() None
update_dofs(probe: Probe) None
class tools.config.DofsNoise(*, translation: List[float], rotation: List[float], notch_accel: float)

Bases: BaseModel

Settings for the process matrix (DOFs random walk parameters).

notch_accel: float
rotation: List[float]
classmethod to_radians(v) Union[list, float]
translation: List[float]
property vec: ndarray
class tools.config.FilterConfig(*, ic: InitialConditions, process_noise: Dict)

Bases: BaseModel

Configuration of the filter.

ic: InitialConditions
property noise_dofs: DofsNoise
process_noise: Dict
class tools.config.ImuConfig(*, interframe_vals: int, noise_sample_rate: float, gravity: float)

Bases: BaseModel

Configuration of the IMU trajectory.

gravity: float
interframe_vals: int
property noise_gyro: float

in deg/s.

noise_sample_rate: float
property stdev_accel: ndarray

in cm/s^2

property stdev_omega: List[float]

in rad/s.

class tools.config.InitialConditions(*, cov0: States, x0: States)

Bases: BaseModel

Initial values of the filter states.

cov0: States
property cov0_matrix: ndarray
x0: States
class tools.config.ModelConfig(*, length: float, angle: float)

Bases: BaseModel

Dimensions of the sensor setup model.

angle: float
length: float
classmethod to_radians(v) float
class tools.config.SimConfig(*, mode: SimMode, img_path: Path, traj_path: Path, traj_name: Path, notch_traj_name: Path, traj_fp: Path = None, notch_fp: Path = None, num_kf_runs: int = 1, frozen_dofs: List[int], do_plot: bool, do_fast_sim: bool)

Bases: BaseModel

Configuration of the simulation.

do_fast_sim: bool
do_plot: bool
frozen_dofs: List[int]
img_path: Path
mode: SimMode
notch_fp: Optional[Path]
notch_traj_name: Path
num_kf_runs: int
classmethod paths_exist(v: Path) Path
classmethod set_mode(v) SimMode
traj_fp: Optional[Path]
traj_name: Path
traj_path: Path
class tools.config.States(*, imu_pos: List[float], imu_vel: List[float], imu_theta: List[float], dofs_rot: List[float], dofs_trans: List[float], notch: List[float], camera_pos: List[float], camera_theta: List[float])

Bases: BaseModel

Values of the filter states.

camera_pos: List[float]
camera_theta: List[float]
dofs_rot: List[float]
dofs_trans: List[float]
imu_pos: List[float]
imu_theta: List[float]
imu_vel: List[float]
notch: List[float]
classmethod to_radians(v) List[float]
property vec: ndarray

tools.config_enums module

class tools.config_enums.SimMode(value)

Bases: Enum

Simulation categories: either run the filter or tune the filter.

RUN = 'run'
TUNE = 'tune'

tools.files module

tools.files.get_dataframe(filepath: str, max_vals: int) DataFrame

Extracts data from file into a dataframe. :param filepath: filepath containing measurement data :param max_vals: maxinum number of data to store

tools.files.handle_not_exist(filepath: str) None
tools.files.save_trajectory(trajectory: TrajectoryBase, filename: str)

Writes trajectory to disk.

tools.files.save_tuned_params(x, filename=None)
tools.files.write_angvel_data(filename: str, imu_frames_interp: SE3, t_interp: np.ndarray, dt: float) None

tools.math module

tools.math.euler_error_checking(euler_xyz: ndarray, euler_yzx: ndarray) None

Checks the values of two sets of Euler angles.

tools.math.skew(x: ndarray)

Returns the skew matrix of a 3-element vector. :param x: :return:

tools.plots module

tools.plots.plot_imu(t: np.ndarray, p: np.ndarray, v: np.ndarray, a: np.ndarray, r: np.ndarray, omega: np.ndarray, p_recon: np.ndarray, v_recon: np.ndarray, eul_recon: np.ndarray) None

tools.printing module

tools.printing.np_string(arr: ndarray, precision: int = 4) str

Formats numpy arrays for printing.

tools.spatial module

tools.spatial.get_omega_local(imu_frames: SE3) ndarray
tools.spatial.interpolate(frames: SE3, n_interframe: int) SE3
tools.spatial.solve_for_omega(q0: Quaternion, q1: Quaternion, dt: float, eval_at_q0: bool = True) np.ndarray

tools.utils module

tools.utils.generate_imudof_ic(gt_dofs: ndarray) ndarray

Generates synthetic initial conditions of the IMU dofs by perturbing the real DOFs

e.g. DOFs (real) : [ 0. 0. 0. 0. 0. 20.] DOFs (IC) : [ 0.05 0. 0. 3. 3. 23.]

tools.utils.get_ic(camera: Camera, imu: Imu, imudof_ic: np.ndarray) State

Returns the initial states given the camera and IMU states, as well as the initial values of the IMU DOFS. :param camera: camera object :param imu: IMU object :param imudof_ic: initial conditions of IMU degrees of freedom :return:

tools.utils.get_upd_values(obj: object, comp: str, indices: Union[int, list])

returns obj (e.g. self.traj or self.imu.ref) component at update timestamps only.

Module contents