def __get_msg(self):
     
     msg = InterfaceState()
     msg.is_diff = True
     msg.interface_id = self.interface_id
     msg.items.append(InterfaceStateItem())
     return msg
 def __publish_state(self):
     
     msg = InterfaceState()
     msg.is_diff = False
     msg.interface_id = self.interface_id
     
     sys_state = InterfaceStateItem()
     sys_state.type = self.state.current_syst_state
     
     if self.state.current_syst_state in [InterfaceStateItem.STATE_LEARNING,  InterfaceStateItem.STATE_PROGRAM_STOPPED,  InterfaceStateItem.STATE_PROGRAM_RUNNING]:
                 
         sys_state.idata.append(self.state.program_id)
         sys_state.idata.append(self.state.instruction_id)
                 
     elif self.state.current_syst_state == InterfaceStateItem.STATE_PROGRAM_FINISHED:
         
         sys_state.idata.append(self.state.program_id)
         
     msg.items.append(sys_state)
     
     for obj_id in self.state.selected_object_ids:
         
         tmp = InterfaceStateItem()
         tmp.type = InterfaceStateItem.SELECTED_OBJECT_ID
         tmp.data.append(obj_id)
         msg.items.append(tmp)
         
     for obj_type in self.state.selected_object_types:
         
         tmp = InterfaceStateItem()
         tmp.type = InterfaceStateItem.SELECTED_OBJECT_TYPE
         tmp.data.append(obj_type)
         msg.items.append(tmp)
         
     for place in self.state.selected_places:
         
         tmp = InterfaceStateItem()
         tmp.type = InterfaceStateItem.SELECTED_PLACE
         tmp.place = place
         msg.items.append(tmp)
         
     for polygon in self.state.polygons:
         
         tmp = InterfaceStateItem()
         tmp.type = InterfaceStateItem.POLYGON
         tmp.polygon = polygon
         msg.items.append(tmp)
     
     self.interface_state_pub.publish(msg)
Exemplo n.º 3
0
    def __init__(self, interface_id, cb=None):

        self.brain = False
        self.state = InterfaceState()
        self.interface_id = interface_id
        self.cb = cb

        if self.state.interface_id == InterfaceState.BRAIN_ID:

            rospy.loginfo('InterfaceStateManager: brain mode')
            self.brain = True
            self.interface_state_pub = rospy.Publisher("/art/interface/state",
                                                       InterfaceState,
                                                       queue_size=10,
                                                       latch=True)

        else:

            rospy.loginfo('InterfaceStateManager: interface mode')
            self.interface_state_pub = rospy.Publisher("/art/interface/state",
                                                       InterfaceState,
                                                       queue_size=10)

        self.interface_state_sub = rospy.Subscriber('/art/interface/state',
                                                    InterfaceState,
                                                    self.state_cb)