跳转至

GpsSensor

robodyno.components.can_bus.gps_sensor

GPS sensor driver.

This module provides a class to get the GPS data from the GPS sensor which is based on a GT-U12 module.

Examples:

>>> from robodyno.components import GpsSensor
>>> from robodyno.interfaces import CanBus
>>> can = CanBus()
>>> gps = GpsSensor(can)
>>> gps.get_position()
{'timestamp': datetime.time(0, 0, 0, 0), 'longitude': 0.0, 'latitude': 0.0}
>>> can.disconnect()

GpsSensor

Bases: CanBusDevice

GPS sensor driver.

属性:

名称 类型 描述
id int

Device id.

type Model

Device type.

fw_ver float

Firmware version.

timestamp float

Timestamp of the last received data.

__init__(can, id_=50)

Initialize the GPS sensor driver.

参数:

名称 类型 描述 默认
can CanBus

CanBus object.

必需
id_ int

Device id. Defaults to 0x32.

50

引发:

类型 描述
ValueError

If the device type is not GPS sensor.

get_position(timeout=None)

Get the position of the GPS sensor.

参数:

名称 类型 描述 默认
timeout float

Timeout. Defaults to None.

None

返回:

类型 描述
Optional[dict]

Optional[dict]: Timestamp, longitude and latitude.

get_position_str(timeout=None)

Get the position of the GPS sensor in string format.

参数:

名称 类型 描述 默认
timeout float

Timeout. Defaults to None.

None

返回:

类型 描述
Optional[str]

Optional[str]: Position (timestamp, longitude, latitude) in string format.

config_can_bus(new_id=None, bitrate=1000000)

Configures the can bus.

参数:

名称 类型 描述 默认
new_id int

New device id.

None
bitrate int

Can bus bitrate.

1000000

引发:

类型 描述
ValueError

If the new id is invalid.