跳转至

ImpactSensor

robodyno.components.can_bus.impact_sensor

Impact sensor driver

The impact sensor can be used to get the trigger status.

Examples:

>>> from robodyno.components import ImpactSensor
>>> from robodyno.interfaces import CanBus
>>> can = CanBus()
>>> impact_sensor = ImpactSensor(can)
>>> print(impact_sensor.get_status())
1

ImpactSensor

Bases: CanBusDevice

Impact sensor driver

Attributes:

Name Type Description
id(int)

Device id.

type(Model)

Device type.

fw_ver(float)

Firmware version.

__init__(can, id_=52)

Initializes the impact driver. Args: can(CanBus):Can bus instance. id_(int):Device id.

Raises:

Type Description
ValueError

If the device id is invalid.

config_can_bus(new_id=None, bitrate=1000000)

Configures the can bus.

Parameters:

Name Type Description Default
new_id int

New device id.

None
bitrate int

Can bus bitrate.

1000000

Raises:

Type Description
ValueError

If the new id is invalid.

get_status(timeout=0.02)

Reads the distance.

Parameters:

Name Type Description Default
timeout float

Timeout in seconds.

0.02

Returns:

Type Description
float | None

The trigger status read by the impact sensor. Returns None if the read times out.