Flexbe unabel to reache action_server
I'currently trying to work with Flexbe and trying to include an action but I keep getting the following error:
[22:03:59] Behavior execution failed! [-]
Could not execute state 'turn' of type '': Traceback (most recent call last):
File "/opt/ros/kinetic/lib/python2.7/dist-packages/smach/state_machine.py", line 247, in _update_once
self._remappings[self._current_label]))
File "/home/sil/us_ws/src/flexbe_behavior_engine/flexbe_core/src/flexbe_core/core/event_state.py", line 71, in _event_execute
self.on_exit(*args, **kwargs)
File "/home/sil/us_ws/src/husky_behaviors/husky_flexbe_states/src/husky_flexbe_states/turn_state.py", line 66, in on_exit
if not self._client.has_result(self._server_name):
File "/home/sil/us_ws/src/flexbe_behavior_engine/flexbe_core/src/flexbe_core/proxy/proxy_action_client.py", line 114, in has_result
return ProxyActionClient._result[topic] is not None
KeyError: '/TurnHusky'
I checked that the the Action exists by looking at my currently available rostopics. They seem to be there. Are there any other possibilities why flexbe cannot find the action or why I get this error. The state that calls the action is as followed:
#!/usr/bin/env python
import rospy
import math
from action_tut.msg import turn_huskyAction, turn_huskyGoal, turn_huskyResult, turn_huskyFeedback
from flexbe_core import EventState, Logger
from flexbe_core.proxy import ProxyActionClient
'''
This state will turn teh husky by calling the necessary action
-- turn_angel float Angel between 180 - (-180) the Husky will turn
-- speed flaot Speed with which the robot will try to get to the angle
-- topic string topic of the server that turn the Husky
<= done if turn is completed successfully
'''
class TurnState(EventState):
'''
Class that defines the state to turn the husky
'''
def __init__(self, angle, speed):
super(TurnState, self).__init__(outcomes=['done', 'failed'])
self._angle =angle
self._speed = speed
self._server_name='/TurnHusky'
self._client = ProxyActionClient({self._server_name: turn_huskyAction}) # pass required clients as dict (topic: type)
self._error_flag = False
def execute(self, userdata):
if self._error_flag:
return 'failed'
if self._client.has_result(self._server_name):
result= self._client.get_result(self._server_name)
restult_val=result.done
if restult_val=="done":
return 'done'
else:
return 'failed'
if self._client.has_feedback(self._server_name):
feedback= self._client.get_feedback(self._server_name)
Logger.loginfo('Current heading is : %s' %str(feedback.heading))
def on_enter(self, userdata):
goal=turn_huskyGoal()
goal.angle= self._angle
goal.turn_speed= self._speed
#Send the goal
self._error_flag= False
try:
self._client.send_goal(self._server_name)
except Exception as e:
Logger.logwarn('Failed to send the Turn command: \n %s' %str(e))
self._error_flag=True
def on_exit(self, userdata):
Logger.loginfo('exit the Turn state')
if not self._client.has_result(self._server_name):
self._client.cancel(self._server_name)
Logger.loginfo('Canceslled the active turning')
def on_start(self):
Logger.loginfo('State is read to turn husky')
def on_stop(self):
Logger.loginfo('The state has been stopped')
if not self._client.has_result(self._server_name):
self._client.cancel(self._server_name)
Logger.loginfo('Canceslled the active turning')
Any help would be useful.
Hi, did you find a solution to this problem?