Skip to content

Commit

Permalink
fix issue with input action server
Browse files Browse the repository at this point in the history
  • Loading branch information
David Conner committed Aug 25, 2024
1 parent 2c35eec commit 82f9aa8
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions flexbe_input/flexbe_input/input_action_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,19 +172,23 @@ def execute_callback(self, goal_handle):
return result
else:
if type_class is str:
print(f"Process data as string '{self._input}' with request {type_class}", flush=True)
result.data = self._input
data_len = 1
else:
print(f"Process data '{self._input}' as {type_class}", flush=True)
input_data = ast.literal_eval(self._input) # convert string to Python data
result.data = str(pickle.dumps(input_data))
print(f" input data[{type(input_data)}] = {input_data}", flush=True)
data_len = 1 if isinstance(input_data, (int, float)) else len(input_data)

if not isinstance(result.data, type_class):
result.data = f"Invalid input type '{type(result.data)}' not '{type_class}' - expected '{type_text}'"
result.result_code = BehaviorInput.Result.RESULT_FAILED
Logger.localwarn(result.data)
goal_handle.abort()
return result
if not isinstance(input_data, type_class):
result.data = f"Invalid input type '{type(result.data)}' not '{type_class}' - expected '{type_text}'"
result.result_code = BehaviorInput.Result.RESULT_FAILED
Logger.localwarn(result.data)
goal_handle.abort()
return result
# Convert binary to string for transport
result.data = str(pickle.dumps(input_data))

if data_len != expected_elements:
result.data = (f'Invalid number of elements {data_len} not {expected_elements} '
Expand Down

0 comments on commit 82f9aa8

Please sign in to comment.