Skip to content

Commit

Permalink
BUGFIX: Cleaning up robot exit
Browse files Browse the repository at this point in the history
  • Loading branch information
vikashplus committed Dec 31, 2023
1 parent 3397e80 commit 535388e
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions robohive/robot/robot.py
Original file line number Diff line number Diff line change
Expand Up @@ -781,16 +781,21 @@ def reset(self,


# close connection and exit out of the robot
def close(self):
prompt("Closing {}".format(self.name), 'white', 'on_grey', flush=True)
if self.is_hardware:
status = self.hardware_close()
prompt("Closed (Status: {})".format(status), 'white', 'on_grey', flush=True)
def close_robot(self):
if self.robot_config:
status = self.hardware_close() if self.is_hardware else True
if status:
prompt(f"Closed {self.name} (Status: {status})", 'white', 'on_grey', flush=True)
self.robot_config = None
else:
prompt(f"Error closing {self.name} (Status: {status})", 'red', 'on_grey', flush=True, type=Prompt.ERROR)
else:
prompt(f"Trying to close a non-existent robot", flush=True, type=Prompt.WARN)


# destructor
def __del__(self):
self.close()
self.close_robot()


def demo_robot():
Expand Down

0 comments on commit 535388e

Please sign in to comment.