8 from flexbe_msgs.msg
import Container, OutcomeRequest
9 from std_msgs.msg
import UInt8, String
16 A state that supports autonomy levels and silent mode. 17 Also, it allows being tracked by a GUI or anything else 18 as it reports each transition and its initial structure. 19 An additional method is provided to report custom status messages to the widget. 23 super(OperatableState, self).
__init__(*args, **kwargs)
33 self.
_pub = ProxyPublisher()
41 Adds this state to the initial structure message. 44 @param prefix: A path consisting of the container hierarchy containing this state. 46 @type msg: ContainerStructure 47 @param msg: The message that will finally contain the structure message. 51 name = prefix + self.
name 62 for i
in range(len(outcomes)):
64 if outcome ==
'preempted':
65 transitions.append(
'preempted')
69 autonomy.append(self.
autonomy[outcome])
72 msg.containers.append(Container(name, children, outcomes, transitions, autonomy))
79 log_requested_outcome = outcome
82 if not self.
_force_transition and (self.autonomy.has_key(outcome)
and self.
autonomy[outcome] >= OperatableStateMachine.autonomy_level):
83 if self._sent_outcome_requests.count(outcome) == 0:
84 self._pub.publish(self.
_request_topic, OutcomeRequest(outcome=self._outcome_list.index(outcome), target=self._parent._get_path() +
"/" + self.
name))
85 rospy.loginfo(
"<-- Want result: %s > %s", self.
name, outcome)
87 self._sent_outcome_requests.append(outcome)
88 outcome = OperatableState._loopback_name
91 elif outcome != OperatableState._loopback_name:
93 rospy.loginfo(
"State result: %s > %s", self.
name, outcome)
94 self._pub.publish(self.
_outcome_topic, UInt8(self._outcome_list.index(outcome)))
def _operatable_execute(self, args, kwargs)
def _notify_skipped(self)
def __init__(self, args, kwargs)
def _enable_ros_control(self)
def _build_msg(self, prefix, msg)