ImpactSensor
robodyno.components.can_bus.impact_sensor
Impact sensor driver
The impact sensor can be used to get the trigger status.
示例:
>>> 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
属性:
| 名称 | 类型 | 描述 |
|---|---|---|
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.
引发:
| 类型 | 描述 |
|---|---|
ValueError
|
If the device id is invalid. |
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. |
get_status(timeout=0.02)
Reads the distance.
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
timeout
|
float
|
Timeout in seconds. |
0.02
|
返回:
| 类型 | 描述 |
|---|---|
float | None
|
The trigger status read by the impact sensor. Returns None if the read times out. |