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.
Attributes:
Name | Type | Description |
---|---|---|
id |
int
|
Device id. |
type |
Model
|
Device type. |
__init__(webots, device_id)
Initializes WebotsDevice with webots and device id.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
webots |
Webots
|
Webots instance. |
required |
device_id |
int
|
Device id. |
required |
Raises:
Type | Description |
---|---|
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.
Returns:
Name | Type | Description |
---|---|---|
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.