Skip to content

Commit

Permalink
add get_goal_status_text method to proxy_action_client; add user_data…
Browse files Browse the repository at this point in the history
…_state to flexbe_states
  • Loading branch information
David Conner committed Apr 30, 2023
1 parent c3d521c commit ae7289e
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 0 deletions.
17 changes: 17 additions & 0 deletions flexbe_core/src/flexbe_core/proxy/proxy_action_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,23 @@ def get_result(self, topic):
@param topic: The topic of interest.
"""
return ProxyActionClient._result.get(topic)

def get_goal_status_text(self, topic):
"""
Returns the result status text if any.
@type topic: string
@param topic: The topic of interest.
"""

if (not topic in ProxyActionClient._clients):
return "Failed to get status text: Invalid action topic = [" + topic +"]"

try:
status = ProxyActionClient._clients[topic].get_goal_status_text()
return status
except:
return "Failed to retrieve goal status text for topic = [" + topic +"]"

def remove_result(self, topic):
"""
Expand Down
46 changes: 46 additions & 0 deletions flexbe_states/src/flexbe_states/user_data_state.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/usr/bin/env python

from flexbe_core import EventState, Logger

'''
Created on 14-Feb-2018
@author: David Conner
'''

class UserDataState(EventState):
'''
Implements a state that defines user data
-- data type Data for given user data
#> data User data
<= done Created the user data
'''


def __init__(self, data ):
'''
Constructor
'''
super(UserDataState, self).__init__( output_keys=["data"], outcomes=["done"])

self._my_data = data
self._return_code = None

def execute(self, userdata):
'''
Execute this state
'''
return self._return_code


def on_enter(self, userdata):

try:
# Add the user data
userdata.data = self._my_data
self._return_code = 'done'
except:
raise ValueError('UserDataState %s - invalid data ' % self.name)
1 change: 1 addition & 0 deletions flexbe_states/tests/run_tests.launch
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
$(arg path)/operator_decision_state_suggested.test
$(arg path)/subscriber_state_unavailable.test
$(arg path)/subscriber_state_pose.test
$(arg path)/user_data_state.test
$(arg path)/wait_state_short.test
" />
Expand Down
10 changes: 10 additions & 0 deletions flexbe_states/tests/user_data_state.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
path: flexbe_states.user_data_state
class: UserDataState

params:
data: "Test data"

output:
data: "Test data"

outcome: done

0 comments on commit ae7289e

Please sign in to comment.