slampy module

class slampy.Sensor(value)

Bases: enum.Enum

This class is used to set the type of the sensor
Values:

MONOCULAR STEREO MONOCULAR_IMU STEREO_IMU RGBD

MONOCULAR = 1
MONOCULAR_IMU = 3
RGBD = 5
STEREO = 2
STEREO_IMU = 4
class slampy.State(value)

Bases: enum.Enum

This class is used to get the actual state of the tracking Values:

OK LOST NOT_INITIALIZED

LOST = 2
NOT_INITIALIZED = 3
OK = 1
SYSTEM_NOT_READY = 4
class slampy.System(params_file, sensor_type)

Bases: object

This class is a wrapper for the SLAM method in the slam_method folder,

Build the wrapper

Parameters
  • params_file (str) – the Path to the .yaml file.

  • sensor_type (Enum) – the sensort type of the SLAM

get_abs_cloud()

Get the point cloud at the current frame stored in absolute coordinates.

Returns

an array with the 3D coordinate of the point, None if the traking is failed

get_camera_matrix()

Get the camera instrinsics

Returns

np.ndarray with shape 3x4 containing the camera parameters.

get_depth()

Get the depth computed in the current image.

Returns

an array of the image shape with depth when it is aviable otherwise -1 , None if the traking is failed

get_point_cloud()

Get the point cloud at the current frame form the wiev of the current position .

Returns

an array with the 3D coordinate of the point, None if the traking is failed

get_point_cloud_colored()

Get the point cloud at the current frame form the wiev of the current position with the RGB color of the point .

Returns

an array with the 3D coordinate of the point and the relative RGB color, None if the traking is failed

get_pose_from_target()

Get the pose from the current frame T to the reference one 0.

get_pose_to_target(precedent_frame=- 1)

Get the pose between a previous frame X in the sequence and the current one T.

The param precedent_frame allows to distinguish between different situations: * precedent_frame = -1: X is the first frame of the sequence. We get the pose between 0->T * precedent_frame > 0 : X is frame at (T-precedent_frame). For instance, if precedent_frame=1, it means we are computing the pose (T-1) -> T.

Parameters

precedent_frame – id of the frame to use when computing the pose between frame. Default is -1 (i.e., pose 0->T)

Returns

the 4x4 pose matrix corresponding to the transormation between the precedent_frame and the current one. If the state is not State.OK, return None

Examples

>>> slam.get_pose_to_target() # return the pose 0 -> T
>>> slam.get_pose_to_target(precedent_frame=1) # return the pose (T-1) -> T
>>> slam.get_pose_to_target(precedent_frame=2) # return the pose (T-2) -> T
get_state()

Get the current state of the SLAM system

Returns

a State corresponding to the state

process_image_imu_mono(image, tframe, imu)

Process an image mono with the imu data.

Note: it works only if the sensor type is MONOCULAR_IMU

Parameters
  • image (ndarray) – image as HxWx3

  • tframe (float) – the timestamp when the image was capture

  • imu – the imu data stored in an float array in the form of [ AccX ,AccY ,AccZ, GyroX, vGyroY, vGyroZ, Timestamp]

Returns

the state of the traking in this frame

Raises

Exception – if the sensor type is different from MONOCULAR_IMU

process_image_imu_stereo(image_left, image_right, tframe, imu)

Process an image stereo with the imu data.

Note: it work only if the sensor type is STEREO_IMU

Parameters
  • image_left (ndarray) – left image as HxWx3

  • image_right (ndarray) – right image as HxWx3

  • tframe (float) – the timestamp when the image was capture

  • imu – the imu data stored in an float array in the form of [ AccX ,AccY ,AccZ, GyroX, vGyroY, vGyroZ, Timestamp]

Returns

the state of the traking in this frame

Raises

Exception – if the sensor type is different from STEREO_IMU

process_image_mono(image, tframe)

Process an image mono.

Note: it works only if the sensor type is MONOCULAR

Parameters
  • image – ndarray of the image

  • tframe (float) – the timestamp when the image was capture

Returns

the state of the traking in this frame

Raises

Exception – if the sensor type is different from MONOCULAR

process_image_rgbd(image, tframe)

Process an rgbd image.

Note: it works only if the sensor type is RGBD

Parameters
  • image (ndarray) – RGBD image as HxWx4

  • tframe (float) – the timestamp when the image was capture

Returns

the new state of the SLAM system

Raises

Exception – if the sensor type is different from RGBD

process_image_stereo(image_left, image_right, tframe)

Process a stereo pair.

Note: it works only if the sensor type is STEREO

Parameters
  • image_left (ndarray) – left image as HxWx3

  • image_right (ndarray) – right image as HxWx3

  • tframe (float) – the timestamp when the image was capture

Returns

the state of the traking in this frame

Raises

Exception – if the sensor type is different from STEREO

reset()

Reset SLAM system

shutdown()

Shutdown the SLAM system