コード例 #1
0
 def copy(self):
     '''Makes a copy of the instance'''
     action = ProgrammedAction(self.action_index, self.step_click_cb)
     action.seq = ActionStepSequence()
     for i in range(len(self.seq.seq)):
         action_step = self.seq.seq[i]
         copy = ProgrammedAction._copy_action_step(action_step)
         action.seq.seq.append(copy)
     return action
コード例 #2
0
 def clear(self):
     '''Clears the action.'''
     self.reset_viz()
     self.lock.acquire()
     self.seq = ActionStepSequence()
     self.r_markers = []
     self.l_markers = []
     self.r_links = dict()
     self.l_links = dict()
     self.lock.release()
コード例 #3
0
    def copy(self):
        '''Returns a copy of this instance.

        Returns:
            ProgrammedAction
        '''
        action = ProgrammedAction(self._world, self.action_index, self.step_click_cb)
        action.seq = ActionStepSequence()
        for action_step in self.seq.seq:
            copy = ProgrammedAction._copy_action_step(action_step)
            action.seq.seq.append(copy)
        return action
コード例 #4
0
    def __init__(self, action_index, step_click_cb):
        self.seq = ActionStepSequence()
        self.action_index = action_index
        self.step_click_cb = step_click_cb
        self.r_markers = []
        self.l_markers = []
        self.r_links = dict()
        self.l_links = dict()
        self.lock = threading.Lock()

        if ProgrammedAction._marker_publisher == None:
            ProgrammedAction._marker_publisher = rospy.Publisher(
                'visualization_marker_array', MarkerArray)
コード例 #5
0
    def __init__(self, world, action_index, step_click_cb):
        '''
        Args:
            action_index (int): The index of this action.
            step_click_cb (function(int)): The function to call when a
                step is clicked on (normally in the GUI). The function
                should take the UID of the step as calculated in
                ActionStepMarker.calc_uid(...).
        '''
        # Initialize a bunch of state.
        self.name = ''  # Human-friendly name for this action.
        self._world = world
        self.seq = ActionStepSequence()
        self.action_index = action_index
        self.step_click_cb = step_click_cb
        self.r_markers = []
        self.l_markers = []
        self.r_links = {}
        self.l_links = {}

        # NOTE(mbforbes): It appears that this is locking manipulation
        # of the internal sequence (self.seq). There have been race
        # conditions involving this (e.g. marker_click_cb(...)), in
        # which it was actually necessary to lock when accessing
        # self.r_markers and self.l_markers.
        #
        # In general, be aware the other code calling these methods
        # with with data about this class (like how many steps it holds)
        # is bad because that means the outside code is assuming that it
        # knows about state internal to this class, and that information
        # may not be true by the time the code here gets executed. This
        # is because there are several callbacks that trigger here so
        # we must reason asyncronously.
        #
        # Unless the information you have (e.g. about the number of
        # steps that exist) was learned while this lock was acquired,
        # you cannot assume it is true.
        self.lock = threading.Lock()

        if ProgrammedAction._marker_publisher is None:
            ProgrammedAction._marker_publisher = rospy.Publisher(TOPIC_MARKERS,
                                                                 MarkerArray)