Skip to content

Commit

Permalink
Catch keyboard interruption in skill_executor.py (#285)
Browse files Browse the repository at this point in the history
* add sys.exit

* use os exit, verify on the hardware

---------

Co-authored-by: Jimmy Yang <jimmytyyang@meta.com>
  • Loading branch information
jimmytyyang and Jimmy Yang authored Dec 16, 2024
1 parent 0159236 commit 37be446
Showing 1 changed file with 21 additions and 14 deletions.
35 changes: 21 additions & 14 deletions spot_rl_experiments/spot_rl/utils/skill_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import os
import os.path as osp
import pickle
import sys
import threading
import time
import traceback
Expand Down Expand Up @@ -591,21 +592,27 @@ def main():
parser.add_argument("--useful_parameters", action="store_true")
_ = parser.parse_args()

while True:
reset_ros_param()
# Call the skill manager
spotskillmanager = SpotSkillManager(
use_mobile_pick=True, use_semantic_place=True, use_place_ee=True
)
executor = None
try:
while True:
reset_ros_param()
# Call the skill manager
spotskillmanager = SpotSkillManager(
use_mobile_pick=True, use_semantic_place=True, use_place_ee=True
)
executor = None
try:
rospy.set_param("skill_in_execution_lock", False)
executor = SpotRosSkillExecutor(spotskillmanager)
# While loop to run in the background
while not rospy.is_shutdown() and not executor.end:
executor.execute_skills()
except Exception as e:
print(f"Ending script: {e}\n Full exception : {traceback.print_exc()}")
except KeyboardInterrupt:
try:
rospy.set_param("skill_in_execution_lock", False)
executor = SpotRosSkillExecutor(spotskillmanager)
# While loop to run in the background
while not rospy.is_shutdown() and not executor.end:
executor.execute_skills()
except Exception as e:
print(f"Ending script: {e}\n Full exception : {traceback.print_exc()}")
sys.exit(0)
except SystemExit:
os._exit(0)


if __name__ == "__main__":
Expand Down

0 comments on commit 37be446

Please sign in to comment.