mrpt.hwdrivers

mrpt.hwdrivers: sensor drivers.

Any driver can be created by class name and configured from an .ini section, the same way rawlog-grabber does it:

import mrpt.config, mrpt.hwdrivers as hw
sensor = hw.CGenericSensor.createSensor("CGPSInterface")
sensor.loadConfig(mrpt.config.CConfigFile("sensors.ini"), "GPS")
sensor.initialize()
while True:
    sensor.doProcess()
    for timestamp, obs in sensor.getObservations():
        print(obs)

A few drivers also have setters to be configured without a config file: CTaoboticsIMU, CGPSInterface, CHokuyoURG, CRoboPeakLidar, CVelodyneScanner. CJoystick reads joysticks and gamepads.

Package Contents

class mrpt.hwdrivers.CGPSInterface

C++ API: class mrpt::hwdrivers::CGPSInterface

Bases: CGenericSensor

getSerialPortName() → str
setSerialPortName(COM_port: str) → None
setSetupCommands(cmds: list[str]) → None
setSetupCommandsDelay(delay_secs: float) → None
setShutdownCommands(cmds: list[str]) → None
class mrpt.hwdrivers.CGenericSensor

C++ API: class mrpt::hwdrivers::CGenericSensor

class TSensorState(value: int)

Members:

ssInitializing

ssWorking

ssError

ssUninitialized

property name: str
property value: int
ssError: ClassVar[CGenericSensor]
ssInitializing: ClassVar[CGenericSensor]
ssUninitialized: ClassVar[CGenericSensor]
ssWorking: ClassVar[CGenericSensor]
ssError: ClassVar[CGenericSensor]
ssInitializing: ClassVar[CGenericSensor]
ssUninitialized: ClassVar[CGenericSensor]
ssWorking: ClassVar[CGenericSensor]
static createSensor(className: str) → CGenericSensor

Creates a sensor driver by its class name (e.g. ‘CGPSInterface’), or returns None if the class is unknown. Configure it with loadConfig().

doProcess() → None

Reads from the device. Call it periodically, e.g. at getProcessRate() Hz.

enableVerbose(enabled: bool = True) → None
getClassName() → str
getObservations() → list[tuple[datetime.timedelta, mrpt.serialization.CSerializable]]

Returns (and removes) the observations gathered so far, as a list of (timestamp, observation) tuples

getProcessRate() → float

Suggested doProcess() rate (Hz)

getSensorLabel() → str
getState() → CGenericSensor
initialize() → None

Opens the device and prepares it for capturing (call after configuring)

loadConfig(configSource: mrpt.config.CConfigFileBase, section: str) → None

Loads the sensor parameters from a config file section

setPathForExternalImages(directory: str) → None

For camera sensors: directory where to save images as external files

setSensorLabel(sensorLabel: str) → None
class mrpt.hwdrivers.CHokuyoURG

C++ API: class mrpt::hwdrivers::CHokuyoURG

Bases: CGenericSensor

setIPandPort(ip: str, port: int) → None
setReducedFOV(fov: float) → None
setScanInterval(skipScanCount: int) → None
setSerialPort(port_name: str) → None
class mrpt.hwdrivers.CJoystick

C++ API: class mrpt::hwdrivers::CJoystick

class State
property axes: list[float]

Normalized axis positions

property axes_raw: list[int]

Raw axis positions

buttons: list[bool]
getJoystickPosition(nJoy: int = 0) → CJoystick | None

Reads the state of joystick nJoy, or None on error

static getJoysticksCount() → int
setLimits(minPerAxis: list[int], maxPerAxis: list[int]) → None

Sets the raw range of each axis, used to normalize positions

class mrpt.hwdrivers.CRoboPeakLidar

C++ API: class mrpt::hwdrivers::CRoboPeakLidar

Bases: CGenericSensor

setSerialPort(port_name: str) → None
class mrpt.hwdrivers.CTaoboticsIMU

C++ API: class mrpt::hwdrivers::CTaoboticsIMU

Bases: CGenericSensor

setSerialBaudRate(rate: int) → None
setSerialPort(serialPort: str) → None
class mrpt.hwdrivers.CVelodyneScanner

C++ API: class mrpt::hwdrivers::CVelodyneScanner

Bases: CGenericSensor

class model_t(value: int)

Members:

VLP16

HDL32

HDL64

property name: str
property value: int
HDL32: ClassVar[CVelodyneScanner]
HDL64: ClassVar[CVelodyneScanner]
VLP16: ClassVar[CVelodyneScanner]
HDL32: ClassVar[CVelodyneScanner]
HDL64: ClassVar[CVelodyneScanner]
VLP16: ClassVar[CVelodyneScanner]
setDeviceIP(ip: str) → None
setModelName(model: CVelodyneScanner) → None
setPCAPInputFile(pcap_file: str) → None

Replays packets from a PCAP file instead of reading from the network