sfm2.interface package¶
Submodules¶
sfm2.interface.config_types module¶
-
class
sfm2.interface.config_types.
SampleRate
(value)¶ Bases:
enum.Enum
An enumeration.
-
OFF
= 0¶
-
HZ_0
= 0¶
-
HZ_12_5
= 13¶
-
HZ_26
= 26¶
-
HZ_52
= 52¶
-
HZ_104
= 104¶
-
HZ_208
= 208¶
-
HZ_417
= 417¶
-
HZ_833
= 833¶
-
HZ_1667
= 1667¶
-
MAX
= 1667¶
-
sfm2.interface.env_sensor_config_types module¶
-
class
sfm2.interface.env_sensor_config_types.
PressureSampleRate
(value)¶ Bases:
enum.Enum
An enumeration.
-
OFF
= 0¶
-
HZ_0
= 0¶
-
HZ_1
= 1¶
-
HZ_10
= 10¶
-
HZ_25
= 25¶
-
HZ_50
= 50¶
-
HZ_75
= 75¶
-
HZ_100
= 100¶
-
MAX
= 100¶
-
-
class
sfm2.interface.env_sensor_config_types.
TemperatureSamplingMode
(value)¶ Bases:
enum.Enum
An enumeration.
-
OFF
= 'OFF'¶
-
INTERVAL
= 'INTERVAL'¶
-
CONTINUOUS
= 'CONTINUOUS'¶
-
-
class
sfm2.interface.env_sensor_config_types.
TemperatureSamplingSetup
(mode: sfm2.interface.env_sensor_config_types.TemperatureSamplingMode, sampling_interval: datetime.timedelta)¶ Bases:
object
Holds the complete setup of temperature/humidity sensor. Use one of the static factory methods to easily create an instance.
-
static
interval
(interval: datetime.timedelta) → sfm2.interface.env_sensor_config_types.TemperatureSamplingSetup¶
-
static
interval_s
(seconds: float) → sfm2.interface.env_sensor_config_types.TemperatureSamplingSetup¶
-
static
continuous
() → sfm2.interface.env_sensor_config_types.TemperatureSamplingSetup¶
-
mode
: TemperatureSamplingMode¶
-
sampling_interval
: timedelta¶
-
static
sfm2.interface.exceptions module¶
-
exception
sfm2.interface.exceptions.
Sfm2Exception
¶ Bases:
Exception
-
raise_and_log_fatal
(log=<Logger sfm2.interface.exceptions (WARNING)>, cause: Optional[Exception] = None)¶
-
raise_and_log_error
(log=<Logger sfm2.interface.exceptions (WARNING)>, cause: Optional[Exception] = None)¶
-
raise_and_log_warning
(log=<Logger sfm2.interface.exceptions (WARNING)>, cause: Optional[Exception] = None)¶
-
raise_and_log_info
(log=<Logger sfm2.interface.exceptions (WARNING)>, cause: Optional[Exception] = None)¶
-
-
exception
sfm2.interface.exceptions.
Sfm2InternalException
(msg: str)¶
-
exception
sfm2.interface.exceptions.
NoSfm2FoundException
¶
-
exception
sfm2.interface.exceptions.
SerialPortSynchronizationFailed
¶
-
exception
sfm2.interface.exceptions.
MalformedDataException
(msg: str)¶
-
exception
sfm2.interface.exceptions.
UnsupportedFirmwareVersionException
(msg: str)¶
-
exception
sfm2.interface.exceptions.
InvalidStateException
¶
-
exception
sfm2.interface.exceptions.
TimeNotValidException
¶
-
exception
sfm2.interface.exceptions.
SerialPortNotActiveException
¶
-
exception
sfm2.interface.exceptions.
CommandResponseTimeoutException
(command_name: str, timeout_s: float)¶
-
exception
sfm2.interface.exceptions.
UnexpectedDataException
¶
-
exception
sfm2.interface.exceptions.
CommandResponseValueMismatch
(command_name: str, set_value: str, got_value: str)¶
-
exception
sfm2.interface.exceptions.
CommandFailedException
(command_name: str)¶
-
exception
sfm2.interface.exceptions.
SerialPortRxTimeoutException
¶
-
exception
sfm2.interface.exceptions.
InvalidArgumentException
¶
-
exception
sfm2.interface.exceptions.
DuplicateKeyException
¶
sfm2.interface.sample_types module¶
-
class
sfm2.interface.sample_types.
SampleFieldType
(name: str, unit: Optional[str])¶ Bases:
object
Describes the type of a single field in Sample
-
name
: str¶
-
unit
: Optional[str]¶
-
-
class
sfm2.interface.sample_types.
SampleType
(name: str, fields: Tuple[sfm2.interface.sample_types.SampleFieldType, …])¶ Bases:
object
Describes the type of a Sample
-
name
: str¶
-
fields
: Tuple[SampleFieldType, …]¶
-
-
class
sfm2.interface.sample_types.
Sample
(type: sfm2.interface.sample_types.SampleType, timestamp: Optional[datetime.timedelta], device_timestamp: int, fields: Tuple)¶ Bases:
object
Base class for data sample contains a collection of values (fields) as well as the definition of the sample type.
-
type
: SampleType¶
-
timestamp
: Optional[timedelta]¶
-
device_timestamp
: int¶
-
fields
: Tuple¶
-
add_timestamp
(timestamp: datetime.timedelta) → sfm2.interface.sample_types.Sample¶
-
-
class
sfm2.interface.sample_types.
VectorSample
(type: sfm2.interface.sample_types.SampleType, timestamp: Optional[datetime.timedelta], device_timestamp: int, fields: Tuple)¶ Bases:
sfm2.interface.sample_types.Sample
Data sample which value is a 3-dimensional vector
-
property
x
¶
-
property
y
¶
-
property
z
¶
-
property
magnitude
¶
-
type
¶
-
timestamp
¶
-
device_timestamp
¶
-
fields
¶
-
property
-
class
sfm2.interface.sample_types.
QuaternionSample
(type: sfm2.interface.sample_types.SampleType, timestamp: Optional[datetime.timedelta], device_timestamp: int, fields: Tuple)¶ Bases:
sfm2.interface.sample_types.Sample
Data sample which value is a quaternion
-
property
w
¶
-
property
x
¶
-
property
y
¶
-
property
z
¶
-
type
¶
-
timestamp
¶
-
device_timestamp
¶
-
fields
¶
-
property
-
class
sfm2.interface.sample_types.
HeadingTiltSample
(type: sfm2.interface.sample_types.SampleType, timestamp: Optional[datetime.timedelta], device_timestamp: int, fields: Tuple)¶ Bases:
sfm2.interface.sample_types.Sample
Data sample which value consists of two angles: heading and tilt.
-
property
heading
¶
-
property
tilt
¶
-
type
¶
-
timestamp
¶
-
device_timestamp
¶
-
fields
¶
-
property
-
class
sfm2.interface.sample_types.
FloatSample
(type: sfm2.interface.sample_types.SampleType, timestamp: Optional[datetime.timedelta], device_timestamp: int, fields: Tuple[float, …])¶ Bases:
float
,sfm2.interface.sample_types.Sample
Data sample which value is single float value. Can be used directly in place of a float value.
-
property
value
¶
-
type
¶
-
timestamp
¶
-
device_timestamp
¶
-
fields
¶
-
property
-
class
sfm2.interface.sample_types.
TimeSyncSample
(type: sfm2.interface.sample_types.SampleType, timestamp: Optional[datetime.timedelta], device_timestamp: int, fields: Tuple)¶ Bases:
sfm2.interface.sample_types.Sample
Time sync signal matching device timestamp with a precision clock.
-
property
clock
¶
-
property
config_idx
¶
-
type
¶
-
timestamp
¶
-
device_timestamp
¶
-
fields
¶
-
property
sfm2.interface.sfm2 module¶
-
class
sfm2.interface.sfm2.
Sfm2
¶ Bases:
rx.core.abc.disposable.Disposable
Main interface for a connected SFM2 device.
The object can be disposed to disconnect from the device, close serial port and free resources.
-
abstract property
id
¶ Gets the SFM2 ID
Currently, the ID is always the Serial Port name
- Type
str
-
abstract property
name
¶ Gets or sets the SFM2s name.
All characters must be ASCII and the maximum length is 16.
The name is stored in persistent memory.
- Type
str
- Raises
InvalidArgumentException – The name that was set does not meet requirements.
-
abstract property
sensor_fusion
¶ Gets the high-level interface for Sensor Fusion
- Return type
-
abstract property
accelerometer
¶ Gets the high-level interface for accelerometer
- Return type
-
abstract property
gyroscope
¶ Gets the high-level interface for gyroscope
- Return type
-
abstract property
magnetometer
¶ Gets the high-level interface for magnetometer
- Return type
-
abstract property
env_sensors
¶ - Gets the high-level interface for environmental sensors:
Temperature
Humidity
Pressure
Altitude
- Return type
-
abstract property
reference
¶ Gets the interface for reference frame manipulation.
- Return type
Sfm2Reference
-
abstract property
time
¶ Gets the interface for timestamp reading and manipulation
- Return type
-
abstract property
config
¶ Gets the low-level interface for config.
- Return type
-
abstract property
data
¶ Gets the low-level interface for reading sensor data.
- Return type
-
abstract property
version
¶ Reads the firmware version
- Return type
str
-
abstract
reset
() → None¶ Resets the configuration to default. This disables all sensors.
-
abstract
run_self_test
() → bool¶ Runs the built-in self-test.
It checks all IMU sensors. It may take a few seconds. Remember to keep the SFM2 still during the whole process!
- Return type
bool
- Returns
True if the test passed, False if failed.
-
property
sf
¶ Gets the high-level interface for Sensor Fusion. Alias for
sensor_fusion()
- Return type
-
property
acc
¶ Gets the high-level interface for accelerometer. Alias for
accelerometer
- Return type
-
property
mag
¶ - Gets the high-level interface for magnetometer.
Alias for
magnetometer
- Return type
-
property
env
¶ - Gets the high-level interface for environmental sensors:
Temperature
Humidity
Pressure
Altitude
Alias for
env_sensors
- Return type
-
abstract property
sfm2.interface.sfm2 module¶
-
class
sfm2.interface.found_sfm2.
FoundSfm2
¶ Bases:
abc.ABC
Represents a found SFM2 device that can be connected to.
-
abstract property
label
¶ Returns the label of the found device.
The label may be any string that identifies the device, such as serial port name.
- Return type
str
-
abstract
connect
() → sfm2.interface.sfm2.Sfm2¶ Connects to the device.
- Return type
-
abstract property
sfm2.interface.sfm2_accelerometer module¶
-
class
sfm2.interface.sfm2_accelerometer.
Sfm2Accelerometer
¶ Bases:
abc.ABC
High-level interface for SFM2 accelerometer
-
abstract property
data
¶ Gets the accelerometer output (AD)
- Return type
Observable[VectorSample]
-
abstract property
rate
¶ Reads or sets accelerometer sampling rate.
Can be set to a float value, in this case the closest available setting will be applied.
- Type
Union[SampleRate, float]
- Return type
-
abstract property
range
¶ Reads or sets accelerometer range.
- Type
-
abstract property
sfm2.interface.sfm2_config module¶
-
class
sfm2.interface.sfm2_config.
Sfm2Config
¶ Bases:
abc.ABC
Allows to access the SFM2 config. Each property corresponds to and is named after a command.
-
abstract property
asr
¶
-
abstract property
afr
¶
-
abstract property
gsr
¶
-
abstract property
gfr
¶
-
abstract property
msr
¶
-
abstract property
sfor
¶
-
abstract property
sfop
¶
-
abstract property
psr
¶
-
abstract property
altzero
¶
-
abstract property
pln
¶
-
abstract property
tint
¶
-
abstract property
tmode
¶
-
abstract property
sfm2.interface.sfm2_data module¶
-
class
sfm2.interface.sfm2_data.
Sfm2Data
¶ Bases:
abc.ABC
Allows to access all the available data streams.
-
abstract property
ad
¶
-
abstract property
gd
¶
-
abstract property
md
¶
-
abstract property
sfq
¶
-
abstract property
sfqt
¶
-
abstract property
sfla
¶
-
abstract property
sfea
¶
-
abstract property
sfcht
¶
-
abstract property
sfm
¶
-
abstract property
pd
¶
-
abstract property
altd
¶
-
abstract property
td
¶
-
abstract property
hd
¶
-
abstract property
ts
¶
-
abstract property
sfm2.interface.sfm2_env_sensors module¶
-
class
sfm2.interface.sfm2_env_sensors.
Sfm2EnvSensors
¶ Bases:
abc.ABC
High-level interface for SFM2 env. sensors: - Temperature - Humidity - Pressure - Altitude
-
abstract property
pressure
¶
-
abstract property
altitude
¶
-
abstract property
temperature
¶
-
abstract property
humidity
¶
-
abstract property
pressure_altitude_sample_rate
¶ Reads or sets the sampling rate of pressure/altitude sensor.
Cen be set to an int value representing rate in Hertz but the value must match one of available settings. If IMU sensors are disabled, setting this rate will also enable accelerometer.
- Type
Union[PressureSampleRate, int]
- Return type
-
abstract property
temperature_humidity_sampling_setup
¶ Reads or sets the sampling setup of temperature/humidity sensor.
See TemperatureSamplingSetup for a reference.
-
abstract
tare_altitude
() → None¶ Tares altitude.
Taring requires the pressure/altitude sampling rate to be configured (not 0).
-
abstract property
sfm2.interface.sfm2_gyroscope module¶
-
class
sfm2.interface.sfm2_gyroscope.
Sfm2Gyroscope
¶ Bases:
abc.ABC
High-level interface for SFM2 gyroscope
-
abstract property
data
¶ Gets the gyroscope output (GD)
- Return type
Observable[VectorSample]
-
abstract property
rate
¶ Reads or sets gyroscope sampling rate.
Can be set to a float value, in this case the closest available setting will be applied.
- Type
Union[SampleRate, float]
- Return type
-
abstract property
range
¶ Reads or sets gyroscope range. See
GyroFullRange
- Type
-
abstract property
sfm2.interface.sfm2_init_options module¶
-
class
sfm2.interface.sfm2_init_options.
Sfm2InitOptions
(skip_version_check: bool = False, cache_name: bool = True, terminate_serial_on_error: bool = False, response_timeout_s: float = 2, log_all_cmds: bool = False, verify_all_cmd_response_values: bool = True, reset_retries_after_timeout: int = 3, delay_after_reset_s: float = 0.5, serial_port_sync_enabled: bool = True, serial_port_sync_timeout_s: float = 10, serial_rx_timeout_s: float = 1, self_test_timeout_s: float = 20, enable_acc_for_env_sensors: bool = True)¶ Bases:
object
Aggregates extra options that can be passed when creating
Sfm2
instances. All fields have default values so you only need to specify those you want to change.-
skip_version_check
: bool = False¶
-
cache_name
: bool = True¶
-
terminate_serial_on_error
: bool = False¶
-
response_timeout_s
: float = 2¶
-
log_all_cmds
: bool = False¶
-
verify_all_cmd_response_values
: bool = True¶
-
reset_retries_after_timeout
: int = 3¶
-
delay_after_reset_s
: float = 0.5¶
-
serial_port_sync_enabled
: bool = True¶
-
serial_port_sync_timeout_s
: float = 10¶
-
serial_rx_timeout_s
: float = 1¶
-
self_test_timeout_s
: float = 20¶
-
enable_acc_for_env_sensors
: bool = True¶
-
-
class
sfm2.interface.sfm2_init_options.
Sfm2CollectionInitOptions
(ignore_connection_errors: bool = False, key_by_id_not_name: bool = False, allow_duplicate_keys: bool = False)¶ Bases:
object
Aggregates extra options that apply to
Sfm2Collection
-
ignore_connection_errors
: bool = False¶
-
key_by_id_not_name
: bool = False¶
-
allow_duplicate_keys
: bool = False¶
-
sfm2.interface.sfm2_magnetometer module¶
-
class
sfm2.interface.sfm2_magnetometer.
Sfm2Magnetometer
¶ Bases:
abc.ABC
High-level interface for SFM2 magnetometer
-
abstract property
data
¶ Gets the magnetometer output (MD)
- Return type
Observable[VectorSample]
-
abstract property
rate
¶ Reads or sets magnetometer sampling rate.
Can be set to a float value, in this case the closest available setting will be applied. Setting this rate will automatically configure accelerometer sample rate if necessary.
- Type
Union[SampleRate, float]
- Return type
-
abstract property
sfm2.interface.sfm2_sensor_fusion module¶
-
class
sfm2.interface.sfm2_sensor_fusion.
Sfm2SensorFusion
¶ Bases:
abc.ABC
High-level interface for SFM2 Sensor Fusion
-
abstract property
quaternion
¶ Gets the quaternion output of Sensor Fusion (SFQT)
- Return type
Observable[QuaternionSample]
-
abstract property
untared_quaternion
¶ Gets the untared quaternion output of Sensor Fusion (SFQ). This output differs from others in that it’s not affected by taring.
- Return type
Observable[QuaternionSample]
-
abstract property
linear_acceleration
¶ Gets the linear acceleration output of Sensor Fusion (SFLA).
- Return type
Observable[VectorSample]
-
abstract property
euler_angles
¶ Gets the Euler angles output of Sensor Fusion (SFEA).
- Return type
Observable[VectorSample]
-
abstract property
heading_tilt
¶ Gets the heading-tilt output of Sensor Fusion (SFCHT).
- Return type
Observable[HeadingTiltSample]
-
abstract property
calibrated_magnetometer
¶ Gets the calibrated magnetometer output of Sensor Fusion (SFM).
- Return type
Observable[VectorSample]
-
abstract property
rate
¶ Reads or sets Sensor Fusion rate.
Can be set to a float value, in this case the closest available setting will be applied. The library will check if the IMU sensors configuration is appropriate for the requested Sensor Fusion rate. If it’s not, the IMU sensors will be configured first.
- Type
Union[SampleRate, float]
- Return type
-
abstract property
output_prescaler
¶
-
abstract property
sfm2.interface.sfm2_time module¶
-
class
sfm2.interface.sfm2_time.
Sfm2Time
¶ Bases:
abc.ABC
Allows to read and manipulate the SFM2 time.
-
abstract
get
() → datetime.timedelta¶ Reads the time.
- Return type
timedelta
-
abstract
set
(ts: datetime.timedelta) → None¶ Sets the time.
- Parameters
ts (timedelta) – Time to be set
-
abstract
reset
() → None¶ Sets time to 0.
-
abstract
apply_offset
(offset: Union[datetime.timedelta, int]) → None¶ Offsets time by a given time delta.
- Parameters
offset (timedelta) – Time offset to be applied
-
abstract property
reports
¶
-
abstract property
reports_rate_hz
¶
-
abstract property
trim
¶
-
abstract
calibrate
(time_passed_on_sfm2: datetime.timedelta, time_passed_on_pc: datetime.timedelta) → None¶
-
abstract