WebotsDevice
robodyno.components.webots.webots_device
Provides base class for all robodyno devices in webots.
Examples:
from robodyno.components import WebotsDevice
from robodyno.interfaces import Webots
webots = Webots()
class MyDevice(WebotsDevice):
def __init__(self, webots, device_id):
super().__init__(webots, device_id)
self.type = Model.MY_DEVICE
self.register()
def __del__(self):
self.deregister()
def step(self):
pass
def parallel_step(self):
pass
WebotsDevice
Bases: object
Base class for all robodyno devices in webots.
All robodyno devices in webots should inherit from this class.
属性:
| 名称 | 类型 | 描述 |
|---|---|---|
id |
int
|
Device id. |
type |
Model
|
Device type. |
__init__(webots, device_id)
Initializes WebotsDevice with webots and device id.
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
webots
|
Webots
|
Webots instance. |
必需 |
device_id
|
int
|
Device id. |
必需 |
引发:
| 类型 | 描述 |
|---|---|
TypeError
|
If webots is not an instance of Webots class. |
register()
Registers node to webots.
deregister()
Deregisters node from webots.
get_version()
Gets version of the device.
返回:
| 名称 | 类型 | 描述 |
|---|---|---|
dict |
dict
|
Version of the device. |
parallel_step()
Parallel step function.
This function is called in parallel with the webots simulation step.
step()
Step function.
This function is called after the webots simulation step.