Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions main_loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ def main(connection=None):
const.FUNCTION_REQUEST_CONFIG: robot_control.send_config,
const.FUNCTION_REQUEST_PID: robot_control.send_pid_factors,
const.FUNCTION_SET_COIL_INDEX: robot_control.on_set_coil_index,
const.FUNCTION_CLEAN_ERRORS: robot_control.on_clean_errors,
}
get_function[const.PUB_MESSAGES.index(topic[i])](buf[i]["data"])

Expand Down
4 changes: 3 additions & 1 deletion robot/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@
"Neuronavigation to Robot: Update robot control pid factors",
"Neuronavigation to Robot: Request config",
"Dashboard to Robot: Request pid factors",
"Neuronavigation to Robot: Set coil index"
"Neuronavigation to Robot: Set coil index",
"Neuronavigation to Robot: Reset errors"
]

FUNCTION_CONNECT_TO_ROBOT = 0
Expand All @@ -184,3 +185,4 @@
FUNCTION_REQUEST_CONFIG = 17
FUNCTION_REQUEST_PID = 18
FUNCTION_SET_COIL_INDEX = 19
FUNCTION_CLEAN_ERRORS = 20
5 changes: 5 additions & 0 deletions robot/control/robot_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -1370,3 +1370,8 @@ def send_pid_factors(self, data):
self.remote_control.send_message(
"Robot to Dashboard: PID factors",
{"pid_factors": self.pid_group.get_pid_factors()})

def on_clean_errors(self, data):
if self.robot:
self.on_set_objective({"objective": RobotObjective.NONE.value})
self.robot.clean_errors()
6 changes: 6 additions & 0 deletions robot/robots/dobot/dobot.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,3 +228,9 @@ def _motion_loop(self):
print("break: TIMEOUT_MOTION")
break
time.sleep(0.001)

def clean_errors(self):
self.connection.clear_error()
time.sleep(0.5)
self.connection.reset_robot()
time.sleep(1)
7 changes: 7 additions & 0 deletions robot/robots/elfin/elfin.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,10 @@ def disable_free_drive(self):
def close(self):
self.stop_robot()
self.disconnect()

def clean_errors(self):
self.connection.stop_robot()
sleep(0.5)
self.connection.clean_errors()
sleep(1)
self.connection.power_on_robot()
12 changes: 12 additions & 0 deletions robot/robots/elfin/elfin_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,3 +411,15 @@ def move_circular(self, start_position, waypoint, target):

success, _ = self._send_and_receive(request, verbose=True)
return success

def power_on_robot(self):
request = "GrpPowerOn," + str(self.ROBOT_ID)
success, _ = self._send_and_receive(request, verbose=True)
return success

def clean_errors(self):
request = ("GrpReset,"
+ str(self.ROBOT_ID))

success, _ = self._send_and_receive(request, verbose=True)
return success
7 changes: 7 additions & 0 deletions robot/robots/robot.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,10 @@ def close(self):
Perform necessary cleanup and disconnection procedures for the robot.
"""
pass

@abstractmethod
def clean_errors(self):
"""
Clean robot errors
"""
pass
3 changes: 3 additions & 0 deletions robot/robots/universal_robot/universal_robot.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,3 +194,6 @@ def enable_free_drive(self):

def disable_free_drive(self):
pass

def clean_errors(self):
pass
Loading