smach groovy
Hello,
i try to run a simple example code with ros groovy
#!/usr/bin/env python
import roslib;
import rospy
import smach
import smach_ros
# define state Foo
class Foo(smach.State):
def __init__(self):
smach.State.__init__(self, outcomes=['outcome1','outcome2'])
self.counter = 0
def execute(self, userdata):
rospy.loginfo('Executing state FOO')
if self.counter < 3:
self.counter += 1
return 'outcome1'
else:
return 'outcome2'
# define state Bar
class Bar(smach.State):
def __init__(self):
smach.State.__init__(self, outcomes=['outcome1'])
def execute(self, userdata):
rospy.loginfo('Executing state BAR')
return 'outcome1'
def main():
rospy.init_node('smach_example_state_machine')
# Create a SMACH state machine
sm = smach.StateMachine(outcomes=['outcome4'])
# Open the container
with sm:
# Add states to the container
smach.StateMachine.add('FOO', Foo(),
transitions={'outcome1':'BAR', 'outcome2':'outcome4'})
smach.StateMachine.add('BAR', Bar(),
transitions={'outcome1':'FOO'})
# Execute SMACH plan
outcome = sm.execute()
if __name__ == '__main__':
main()
The problem is that python didn't find smach. I tried to add smach and smach_ros to my CMakelists.txt
find_package(catkin REQUIRED COMPONENTS smach_ros smach rospy)
and package.xml
<buildtool_depend>smach</buildtool_depend>
<buildtool_depend>smach_ros</buildtool_depend>
<buildtool_depend>smach_msgs</buildtool_depend>
<buildtool_depend>rospy</buildtool_depend>
<run_depend>rospy</run_depend>
<run_depend>smach</run_depend>
<run_depend>smach_ros</run_depend>
<run_depend>smach_msgs</run_depend>
but then i get following error
CMake Error at /opt/ros/groovy/share/catkin/cmake/catkinConfig.cmake:72 (find_package): Could not find a configuration file for package smach_ros.
Set smach_ros_DIR to the directory containing a CMake configuration file for smach_ros. The file will have one of the following names:
smach_rosConfig.cmake
smach_ros-config.cmake
Does anyone have an idea what I forgot , or where my error is?