Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def control_wait_for(self, goal, interval_sec=1):
"""
control_wait_for will poll Eva's state, waiting for Eva to reach the goal state
"""
parsed_goal = RobotState(goal)
while True:
robot_state = RobotState(self.data_snapshot()['control']['state'])
if robot_state == RobotState.ERROR:
eva_error('Eva is in error control state')
elif robot_state == parsed_goal:
return
time.sleep(interval_sec)
def control_wait_for(self, goal, interval_sec=1):
"""
control_wait_for will poll Eva's state, waiting for Eva to reach the goal state
"""
parsed_goal = RobotState(goal)
while True:
robot_state = RobotState(self.data_snapshot()['control']['state'])
if robot_state == RobotState.ERROR:
eva_error('Eva is in error control state')
elif robot_state == parsed_goal:
return
time.sleep(interval_sec)
def control_resume(self, wait_for_ready=True):
r = self.api_call_with_auth('POST', 'controls/resume')
if r.status_code != 200:
eva_error('control_resume error', r)
elif wait_for_ready:
time.sleep(0.1) # sleep for small period to avoid race condition between updating cache and reading state
self.control_wait_for(RobotState.READY)