You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the Bug
I am working on a Webots project in which four E-puck robots are used that push box to target locations with separate controller ,each controller consists of "Class Environment, class robot followed by main control loop"
_robot_instance = None
_supervisor_instance = None
def __init__(self, use_supervisor=False):
self.use_supervisor = use_supervisor
self.robot = None
self.webots_supervisor = None
self.TIME_STEP = 64
if use_supervisor:
if Environment._supervisor_instance is None:
Environment._supervisor_instance = Supervisor()
self.webots_supervisor = Environment._supervisor_instance
self.robot = self.webots_supervisor.getFromDef("Agent1")
else:
if Environment._robot_instance is None:
Environment._robot_instance = Robot()
self.robot = Environment._robot_instance
self.webots_supervisor = None
self.time_step = self.robot.getBasicTimeStep() if not use_supervisor else None
def reset(self):
print(f"Supervisor: {self.webots_supervisor}")
# Release existing Robot/Supervisor instance if it exists
if self.use_supervisor and Environment._supervisor_instance is not None:
del Environment._supervisor_instance
elif not self.use_supervisor and Environment._robot_instance is not None:
del Environment._robot_instance
# Create a new Robot/Supervisor instance
if self.use_supervisor:
Environment._supervisor_instance = Supervisor()
self.webots_supervisor = Environment._supervisor_instance
self.robot = self.webots_supervisor.getFromDef("Agent1")
else:
Environment._robot_instance = Robot()
self.robot = Environment._robot_instance
self.webots_supervisor = None
try:
# Corrected the Supervisor instance
root = self.webots_supervisor.getRoot()
self.print_node_names(root)
when I run it I end up getting an error like this: "Only one instance of the Robot class should be created per controller process"
I have been trying for days to solve the issue, but unfortunately, I am unable to figure it out. I would be grateful if you could provide me with some suggestions to help me solve the problem.
This discussion was converted from issue #6496 on February 09, 2024 06:35.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Describe the Bug
I am working on a Webots project in which four E-puck robots are used that push box to target locations with separate controller ,each controller consists of "Class Environment, class robot followed by main control loop"
when I run it I end up getting an error like this: "Only one instance of the Robot class should be created per controller process"
I have been trying for days to solve the issue, but unfortunately, I am unable to figure it out. I would be grateful if you could provide me with some suggestions to help me solve the problem.
Beta Was this translation helpful? Give feedback.
All reactions