Measurements

Vehicle data measurement types pre-defined in OpenXC.

class openxc.measurements.AcceleratorPedalPosition(value, **kwargs)
name = 'accelerator_pedal_position'
class openxc.measurements.BooleanMeasurement(value, **kwargs)
DATA_TYPE

alias of bool

class openxc.measurements.BrakePedalStatus(value, **kwargs)
name = 'brake_pedal_status'
class openxc.measurements.ButtonEvent(value, **kwargs)
name = 'button_event'
states = ['up', 'down', 'left', 'right', 'ok']
class openxc.measurements.CanMessage(name, value, event=None, override_unit=False, **kwargs)

Construct a new Measurement with the given name and value.

Args:
name (str): The Measurement’s generic name in OpenXC. value (str, float, or bool): The Measurement’s value.
Kwargs:

event (str, bool): An optional event for compound Measurements. override_unit (bool): The value will be coerced to the correct units

if it is a plain number.
Raises:
UnrecognizedMeasurementError if the value is not the correct units, e.g. if it’s a string and we’re expecting a numerical value
name = 'can_message'
class openxc.measurements.DoorStatus(value, **kwargs)
name = 'door_status'
states = ['driver', 'rear_left', 'rear_right', 'passenger']
class openxc.measurements.EngineSpeed(value, **kwargs)
name = 'engine_speed'
unit = ComposedUnit([LeafUnit('rotations', False)], [LeafUnit('m', True)], 1)
valid_range = <openxc.utils.Range object>
class openxc.measurements.EventedMeasurement(value, **kwargs)
DATA_TYPE

alias of unicode

class openxc.measurements.FuelConsumed(value, **kwargs)
name = 'fuel_consumed_since_restart'
unit = NamedComposedUnit('L', ComposedUnit([LeafUnit('m', True), LeafUnit('m', True), LeafUnit('m', True)], [], 0.0010000000000000002), True)
valid_range = <openxc.utils.Range object>
class openxc.measurements.FuelLevel(value, **kwargs)
name = 'fuel_level'
class openxc.measurements.HeadlampStatus(value, **kwargs)
name = 'headlamp_status'
class openxc.measurements.HighBeamStatus(value, **kwargs)
name = 'high_beam_status'
class openxc.measurements.IgnitionStatus(value, **kwargs)
name = 'ignition_status'
states = ['off', 'accessory', 'run', 'start']
class openxc.measurements.LateralAcceleration(value, **kwargs)
name = 'lateral_acceleration'
unit = ComposedUnit([LeafUnit('m', True)], [LeafUnit('s', True), LeafUnit('s', True)], 1)
valid_range = <openxc.utils.Range object>
class openxc.measurements.Latitude(value, **kwargs)
name = 'latitude'
unit = LeafUnit('deg', False)
valid_range = <openxc.utils.Range object>
class openxc.measurements.Longitude(value, **kwargs)
name = 'longitude'
unit = LeafUnit('deg', False)
valid_range = <openxc.utils.Range object>
class openxc.measurements.LongitudinalAcceleration(value, **kwargs)
name = 'longitudinal_acceleration'
unit = ComposedUnit([LeafUnit('m', True)], [LeafUnit('s', True), LeafUnit('s', True)], 1)
valid_range = <openxc.utils.Range object>
class openxc.measurements.Measurement(name, value, event=None, override_unit=False, **kwargs)

The Measurement is the base type of all values read from an OpenXC vehicle interface. All values encapsulated in a Measurement have an associated scalar unit (e.g. meters, degrees, etc) to avoid crashing a rover into Mars.

Construct a new Measurement with the given name and value.

Args:
name (str): The Measurement’s generic name in OpenXC. value (str, float, or bool): The Measurement’s value.
Kwargs:

event (str, bool): An optional event for compound Measurements. override_unit (bool): The value will be coerced to the correct units

if it is a plain number.
Raises:
UnrecognizedMeasurementError if the value is not the correct units, e.g. if it’s a string and we’re expecting a numerical value
DATA_TYPE

alias of Number

classmethod from_dict(data)

Create a new Measurement subclass instance using the given dict.

If Measurement.name_from_class was previously called with this data’s associated Measurement sub-class in Python, the returned object will be an instance of that sub-class. If the measurement name in data is unrecognized, the returned object will be of the generic Measurement type.

Args:
data (dict): the data for the new measurement, including at least a
name and value.
name = 'generic'
classmethod name_from_class(measurement_class)

For a given measurement class, return its generic name.

The given class is expected to have a name attribute, otherwise this function will raise an execption. The point of using this method instead of just trying to grab that attribute in the application is to cache measurement name to class mappings for future use.

Returns:
the generic OpenXC name for a measurement class.
Raise:
UnrecognizedMeasurementError: if the class does not have a valid
generic name
unit = LeafUnit('undef', False)
value
class openxc.measurements.NamedMeasurement(value, **kwargs)

A NamedMeasurement has a class-level name variable and thus the name argument is not required in its constructor.

class openxc.measurements.NumericMeasurement(value, **kwargs)

A NumericMeasurement must have a numeric value and thus a valid range of acceptable values.

percentage_within_range()
valid_range = None
within_range()
class openxc.measurements.Odometer(value, **kwargs)
name = 'odometer'
unit = NamedComposedUnit('km', ComposedUnit([LeafUnit('m', True)], [], 1000), False)
valid_range = <openxc.utils.Range object>
class openxc.measurements.ParkingBrakeStatus(value, **kwargs)
name = 'parking_brake_status'
class openxc.measurements.PercentageMeasurement(value, **kwargs)
unit = LeafUnit('%', False)
valid_range = <openxc.utils.Range object>
class openxc.measurements.StatefulMeasurement(value, **kwargs)

Must have a class-level states member that defines a set of valid string states for this measurement’s value.

DATA_TYPE

alias of unicode

states = None
valid_state()

Determine if the current state is valid, given the class’ state member.

Returns:
True if the value is a valid state.
class openxc.measurements.SteeringWheelAngle(value, **kwargs)
name = 'steering_wheel_angle'
unit = LeafUnit('deg', False)
valid_range = <openxc.utils.Range object>
class openxc.measurements.TorqueAtTransmission(value, **kwargs)
name = 'torque_at_transmission'
unit = NamedComposedUnit('Nm', ComposedUnit([NamedComposedUnit('N', ComposedUnit([LeafUnit('m', True), NamedComposedUnit('kg', ComposedUnit([LeafUnit('g', True)], [], 1000), False)], [LeafUnit('s', True), LeafUnit('s', True)], 1), True), LeafUnit('m', True)], [], 1), True)
valid_range = <openxc.utils.Range object>
class openxc.measurements.TransmissionGearPosition(value, **kwargs)
name = 'transmission_gear_position'
states = ['first', 'second', 'third', 'fourth', 'fifth', 'sixth', 'seventh', 'eighth', 'neutral', 'reverse', 'park']
class openxc.measurements.TurnSignalStatus(value, **kwargs)
name = 'turn_signal_status'
exception openxc.measurements.UnrecognizedMeasurementError
class openxc.measurements.VehicleSpeed(value, **kwargs)
name = 'vehicle_speed'
unit = ComposedUnit([NamedComposedUnit('km', ComposedUnit([LeafUnit('m', True)], [], 1000), False)], [NamedComposedUnit('h', ComposedUnit([NamedComposedUnit('min', ComposedUnit([LeafUnit('s', True)], [], 60.0), False)], [], 60.0), False)], 1)
valid_range = <openxc.utils.Range object>
class openxc.measurements.WindshieldWiperStatus(value, **kwargs)
name = 'windshield_wiper_status'
openxc.measurements.all_measurements()