本文整理汇总了Python中flexbe_core.proxy.ProxyActionClient.get_state方法的典型用法代码示例。如果您正苦于以下问题:Python ProxyActionClient.get_state方法的具体用法?Python ProxyActionClient.get_state怎么用?Python ProxyActionClient.get_state使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类flexbe_core.proxy.ProxyActionClient
的用法示例。
在下文中一共展示了ProxyActionClient.get_state方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MoveBaseState
# 需要导入模块: from flexbe_core.proxy import ProxyActionClient [as 别名]
# 或者: from flexbe_core.proxy.ProxyActionClient import get_state [as 别名]
class MoveBaseState(EventState):
"""
Navigates a robot to a desired position and orientation using move_base.
># waypoint Pose2D Target waypoint for navigation.
<= arrived Navigation to target pose succeeded.
<= failed Navigation to target pose failed.
"""
def __init__(self):
"""Constructor"""
super(MoveBaseState, self).__init__(outcomes = ['arrived', 'failed'],
input_keys = ['waypoint'])
self._action_topic = "/move_base"
self._client = ProxyActionClient({self._action_topic: MoveBaseAction})
self._arrived = False
self._failed = False
def execute(self, userdata):
"""Wait for action result and return outcome accordingly"""
if self._arrived:
return 'arrived'
if self._failed:
return 'failed'
if self._client.has_result(self._action_topic):
status = self._client.get_state(self._action_topic)
if status == GoalStatus.SUCCEEDED:
self._arrived = True
return 'arrived'
elif status in [GoalStatus.PREEMPTED, GoalStatus.REJECTED,
GoalStatus.RECALLED, GoalStatus.ABORTED]:
Logger.logwarn('Navigation failed: %s' % str(status))
self._failed = True
return 'failed'
def on_enter(self, userdata):
"""Create and send action goal"""
self._arrived = False
self._failed = False
# Create and populate action goal
goal = MoveBaseGoal()
pt = Point(x = userdata.waypoint.x, y = userdata.waypoint.y)
qt = transformations.quaternion_from_euler(0, 0, userdata.waypoint.theta)
goal.target_pose.pose = Pose(position = pt,
orientation = Quaternion(*qt))
goal.target_pose.header.frame_id = "odom"
# goal.target_pose.header.stamp.secs = 5.0
# Send the action goal for execution
try:
self._client.send_goal(self._action_topic, goal)
except Exception as e:
Logger.logwarn("Unable to send navigation action goal:\n%s" % str(e))
self._failed = True
def on_exit(self, userdata):
if not self._client.has_result(self._action_topic):
self._client.cancel(self._action_topic)
Logger.loginfo('Cancelled active action goal.')