ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
I can think of two possibilities:
or some combination of the 2...
e.g. #1:
import rospy
from smach import State
class State1(State):
def __init__(self):
State.__init__(self, outcomes=['still_working', 'done'])
self._in_progress = False
self._prev_data = None
# etc. etc.
def execute(self):
# entry
current_data = []
if self._in_progress:
current_data = self._prev_data
sensor_input = False
while not sensor_input and not rospy.is_shutdown():
# do a bit of work here
current_data.append(do_just_a_bit_of_work())
if check_if_work_done():
self._in_progress = False
self._prev_data = None
return 'done'
if check_for_sensor_input():
self._in_progress = True
self._prev_data = current_data
return 'still_working'
For #2, state1 would pass out different userdata values based on whether or not it had completed before being interrupted. You'd probably want a state3 that would determine the next transition after state2 based on the userdata dictionary.
2 | No.2 Revision |
I can think of two possibilities:
or some combination of the 2...
e.g. #1:
import rospy
from smach import State
class State1(State):
def __init__(self):
State.__init__(self, outcomes=['still_working', 'done'])
rate = rospy.Rate(200) # Loop at 200 Hz
self._in_progress = False
self._prev_data = None
# etc. etc.
def execute(self):
# entry
current_data = []
if self._in_progress:
current_data = self._prev_data
sensor_input = False
while not sensor_input and not rospy.is_shutdown():
# do a bit of work here
current_data.append(do_just_a_bit_of_work())
if check_if_work_done():
self._in_progress = False
self._prev_data = None
return 'done'
if check_for_sensor_input():
self._in_progress = True
self._prev_data = current_data
return 'still_working'
rate.sleep()
For #2, state1 would pass out different userdata values based on whether or not it had completed before being interrupted. You'd probably want a state3 that would determine the next transition after state2 based on the userdata dictionary.
3 | No.3 Revision |
I can think of two Two possibilities:
or some combination of the 2...
e.g. #1:
import rospy
from smach import State
class State1(State):
def __init__(self):
State.__init__(self, outcomes=['still_working', 'done'])
rate = rospy.Rate(200) # Loop at 200 Hz
self._in_progress = False
self._prev_data = None
# etc. etc.
def execute(self):
# entry
current_data = []
if self._in_progress:
current_data = self._prev_data
sensor_input = False
while not sensor_input and not rospy.is_shutdown():
# do a bit of work here
current_data.append(do_just_a_bit_of_work())
if check_if_work_done():
self._in_progress = False
self._prev_data = None
return 'done'
if check_for_sensor_input():
self._in_progress = True
self._prev_data = current_data
return 'still_working'
rate.sleep()
For #2, state1 would pass out different userdata values based on whether or not it had completed before being interrupted. You'd probably want a state3 that would determine the next transition after state2 based on the userdata dictionary.
4 | No.4 Revision |
Two possibilities:
or some combination of the 2...
e.g. #1:
import rospy
from smach import State
class State1(State):
def __init__(self):
State.__init__(self, outcomes=['still_working', 'done'])
rate = rospy.Rate(200) # Loop at 200 Hz
self._in_progress = False
self._prev_data = None
# etc. etc.
def execute(self):
# entry
current_data = []
if self._in_progress:
current_data = self._prev_data
sensor_input = False
while not sensor_input and not rospy.is_shutdown():
# do a bit of work here
current_data.append(do_just_a_bit_of_work())
if check_if_work_done():
self._in_progress = False
self._prev_data = None
return 'done'
if check_for_sensor_input():
self._in_progress = True
self._prev_data = current_data
return 'still_working'
rate.sleep()
For #2, state1 would pass out different userdata values based on whether or not it had completed before being interrupted. You'd probably want a state3 that would determine the next transition after state2 based on the userdata dictionary.