deepbots.robots.controllers
- class deepbots.robots.EmitterReceiverRobot(*args: Any, **kwargs: Any)[source]
Bases:
Robot
This EmitterReceiverRobot implements only the most basic run method, that steps the robot and calls the handle_emitter, handle_receiver methods that are needed for communication with the supervisor.
This class must be inherited by all robot controllers created by the user and the handle_emitter, handle_receiver, initialize_comms methods are all abstract and need to be implemented according to their docstrings. For a simpler RobotController that implements the methods in a basic form inherit the CSVRobot subclass or other emitter-receiver subclasses.
- property timestep
Getter of _timestep field. Timestep is defined in milliseconds
- Returns
The timestep of the controller in milliseconds
- initialize_comms(emitter_name, receiver_name)[source]
This method should initialize and return the emitter and receiver in a tuple as expected by the constructor.
A basic example implementation can be:
emitter = self.getDevice(“emitter”) receiver = self.getDevice(“receiver”) receiver.enable(self.timestep) return emitter, receiver
- Returns
(emitter, receiver) tuple, as initialized
- handle_emitter()[source]
This method should take data from the robot, eg. sensor data, parse it into a message and use the robot’s emitter to send it to the supervisor. This message will be used as the observation of the robot.
- class deepbots.robots.CSVRobot(*args: Any, **kwargs: Any)[source]
Bases:
EmitterReceiverRobot
Basic implementation of a robot that can emit and receive messages to/from the supervisor in string utf-8 form that are Comma Separated Values, i.e. a list.
- initialize_comms(emitter_name, receiver_name)[source]
This method implements the basic emitter/receiver initialization that assumes that an emitter and a receiver component are present on the Webots robot with appropriate DEFs (“emitter”/”receiver”).
- Parameters
emitter_name – The name of the emitter device on the supervisor node
receiver_name – The name of the receiver device on the supervisor node
- Returns
The initialized emitter and receiver references
- handle_emitter()[source]
This emitter uses the user-implemented create_message() method to get whatever data the robot gathered, convert it to a string if needed and then use the emitter to send the data in a string utf-8 encoding to the supervisor.
- handle_receiver()[source]
This receiver uses the basic Webots receiver-handling code. The use_message_data() method should be implemented to actually use the data received from the supervisor.