executive_smach: smach | smach_msgs | smach_ros
- Code API
- diamondback
- electric
- fuerte
- unstable - Tutorials
- Troubleshooting
- FAQ
- Reviews (Doc reviewed)
Used by (31)
Package Summary
The smach_ros package contains extensions for the SMACH library to integrate it tightly with ROS. For example, SMACH-ROS can call ROS services, listen to ROS topics, and integrate with actionlib both as a client, and a provider of action servers. SMACH is a new library that takes advantage of very old concepts in order to quickly create robust robot behavior with maintainable and modular code.
- Author: Jonathan Bohren
- License: BSD
- Repository: wg-kforge
- Source: hg https://kforge.ros.org/smach/executive_smach
Contents
ROS integration
For example, if you want to call an actionlib action from SMACH, you can of course write a generic state, which would look something like this:
1 class ManualActionState(smach.State):
2 def __init__(self, outcomes=['succeeded',
3 'aborted',
4 'preempted']):
5 self.action_client = SimpleActionClient('action_name',
6 ActionType)
7 self.action_client.wait_for_server()
8
9
10 def execute(self, userdata):
11 goal = ActionGoal()
12 ret = self.action_client.send_goal_and_wait
13 if ret == ActionStatus.SUCCEEDED:
14 return 'succeeded'
15 elif ret == ActionStatus.PREEMPTED:
16 return 'preempted'
17 elif ret == ActionStatus.ABORTED:
18 return 'aborted'
19
20
21 sm = StateMachine(['succeeded','aborted','preempted'])
22 with sm:
23 smach.StateMachine.add('TRIGGER_GRIPPER',
24 ManualActionState(),
25 rransitions={'succeeded':'APPROACH_PLUG'})
But you can call that same action with much less coding, using the SimpleActionState:
SMACH ROS offers the same type of support for ROS services and ROS topics. For more details take a look at the tutorials.






