-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactored Deepbots: DeepbotsEnv & Robot Class
1. Inherited from Webots Robot class 2. Refactored SupervisorEnv name to DeepbotsEnv 3. Shortened imports 4. Removed setup folder 5. Renamed lots of class name
- Loading branch information
1 parent
3ae23e6
commit bbc3342
Showing
13 changed files
with
107 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from deepbots.robots.controllers.csv_robot import CSVRobot | ||
from deepbots.robots.controllers.emitter_receiver_robot import EmitterReceiverRobot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
from deepbots.supervisor.controllers.robot_supervisor_env import RobotSupervisorEnv | ||
from deepbots.supervisor.controllers.csv_supervisor_env import CSVSupervisorEnv | ||
from deepbots.supervisor.controllers.deepbots_supervisor_env import DeepbotsSupervisorEnv | ||
from deepbots.supervisor.controllers.emitter_receiver_supervisor_env import EmitterReceiverSupervisorEnv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
from collections.abc import Iterable | ||
|
||
from deepbots.supervisor.controllers.emitter_receiver_supervisor_env import EmitterReceiverSupervisorEnv | ||
|
||
|
||
class CSVSupervisorEnv(EmitterReceiverSupervisorEnv): | ||
""" | ||
This class implements the emitter-receiver scheme using Comma Separated | ||
Values. | ||
""" | ||
def __init__(self, | ||
emitter_name="emitter", | ||
receiver_name="receiver", | ||
timestep=None): | ||
""" | ||
The constructor just passes the arguments provided to the parent | ||
class contructor. | ||
:param emitter_name: The name of the emitter device on the | ||
supervisor node | ||
:param receiver_name: The name of the receiver device on the | ||
supervisor node | ||
:param timestep: The supervisor controller timestep | ||
""" | ||
super(CSVSupervisorEnv, self).__init__(emitter_name, receiver_name, | ||
timestep) | ||
|
||
def handle_emitter(self, action): | ||
""" | ||
Implementation of the handle_emitter method expecting an iterable | ||
with Comma Separated Values (CSV). | ||
:param action: Whatever the use-case uses as an action, e.g. | ||
an integer representing discrete actions | ||
:type action: Iterable, for multiple values the CSV format is | ||
required, e.g. [0, 1] for two actions | ||
""" | ||
assert isinstance(action, Iterable), \ | ||
"The action object should be Iterable" | ||
|
||
message = (",".join(map(str, action))).encode("utf-8") | ||
self.emitter.send(message) | ||
|
||
def handle_receiver(self): | ||
""" | ||
Implementation of the handle_receiver method expecting an iterable | ||
with Comma Separated Values (CSV). | ||
:return: Returns the message received from the robot, returns None | ||
if no message is received | ||
:rtype: List of string values | ||
""" | ||
if self.receiver.getQueueLength() > 0: | ||
try: | ||
string_message = self.receiver.getString() | ||
except AttributeError: | ||
string_message = self.receiver.getData().decode("utf-8") | ||
self.receiver.nextPacket() | ||
return string_message.split(",") | ||
else: | ||
return None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from deepbots.supervisor.wrappers.keyboard_printer import KeyboardPrinter | ||
from deepbots.supervisor.wrappers.tensorboard_wrapper import TensorboardLogger |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters