Skip to content

Commit 441ae6a

Browse files
authored
fix: missing stubs/types causing build failure (#84)
* Added CD features * Carried out PR requested changes * Amended ValueError vs. eva_error usages * Fixed incorrect expected status code * Reinstated whitespace * Added sleep comment for clarity * Added missing types/stubs to Pipfile
1 parent 4967b79 commit 441ae6a

File tree

4 files changed

+38
-1
lines changed

4 files changed

+38
-1
lines changed

Pipfile

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ verify_ssl = true
44
name = "pypi"
55

66
[packages]
7+
types-requests = "*"
78
requests = "*"
89
websockets = "*"
9-
zeroconf = "==0.27.1"
10+
zeroconf = "*"
11+
types-dataclasses = "*"
1012
dataclasses = "*"
1113
pytransform3d = "==1.2.1"
1214

evasdk/Eva.py

+8
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,14 @@ def control_reset_errors(self, wait_for_ready=True):
234234
self.__logger.debug('Eva.control_reset_errors called')
235235
return self.__http_client.control_reset_errors(wait_for_ready=wait_for_ready)
236236

237+
# Collision Detection
238+
def control_configure_collision_detection(self, enabled, sensitivity):
239+
self.__logger.debug('Eva.collision_detection called')
240+
return self.__http_client.control_configure_collision_detection(enabled=enabled, sensitivity=sensitivity)
241+
242+
def control_acknowledge_collision(self, wait_for_ready=True):
243+
self.__logger.debug('Eva.acknowledge_collision called')
244+
return self.__http_client.control_acknowledge_collision(wait_for_ready=wait_for_ready)
237245

238246
# Calc
239247
def calc_forward_kinematics(self, joints, fk_type='both', tcp_config=None):

evasdk/eva_http_client.py

+26
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,8 @@ def control_wait_for(self, goal, interval_sec=1):
323323

324324
if robot_state == RobotState.ERROR:
325325
eva_error('Eva is in error control state')
326+
if robot_state == RobotState.COLLISION:
327+
eva_error('Eva has encountered a collision. Please acknowledge collision.')
326328
elif robot_state == parsed_goal:
327329
return
328330

@@ -413,6 +415,30 @@ def control_reset_errors(self, wait_for_ready=True):
413415
time.sleep(0.1) # sleep for small period to avoid race condition between updating cache and reading state
414416
self.control_wait_for(RobotState.READY)
415417

418+
# COLLISION DETECTION
419+
def control_configure_collision_detection(self, enabled, sensitivity):
420+
"""
421+
Allows toggling on/off and setting the sensitivity of collision detection
422+
"""
423+
if sensitivity not in ['low', 'medium', 'high']:
424+
raise ValueError('collision_detection error, no such sensitivity ' + sensitivity)
425+
if enabled not in [True, False]:
426+
raise ValueError('collision_detection error, must be True/False')
427+
r = self.api_call_with_auth('POST', 'controls/collision_detection',
428+
json.dumps({'enabled': enabled, 'sensitivity': sensitivity}))
429+
if r.status_code != 204:
430+
eva_error('control_collision_detection error', r)
431+
432+
def control_acknowledge_collision(self, wait_for_ready=True):
433+
"""
434+
When a collision is encountered, it must be acknowledged before the robot can be reset
435+
"""
436+
r = self.api_call_with_auth('POST', 'controls/acknowledge_collision')
437+
if r.status_code != 204:
438+
eva_error('control_acknowledge_collision error', r)
439+
elif wait_for_ready:
440+
time.sleep(0.1) # sleep for small period to avoid race condition between updating cache and reading state
441+
self.control_wait_for(RobotState.READY)
416442

417443
# CALCULATIONS
418444
def calc_forward_kinematics(self, joints, fk_type='both', tcp_config=None):

evasdk/robot_state.py

+1
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ class RobotState(enum.Enum):
1212
UPDATING = 'updating'
1313
DISABLED = 'disabled'
1414
SHUTTING_DOWN = 'shutting_down'
15+
COLLISION = 'collision'

0 commit comments

Comments
 (0)