예제 #1
0
 def stop_all_interactions(self):
     """
     This is the big showstopper - stop them all!
     """
     console.loginfo("Stopping all interactions")
     for interaction_hash in self.launched_interactions.active():
         self.stop_interaction(interaction_hash)
예제 #2
0
 def _start_dummy_interaction(self, interaction, unused_filename):
     console.loginfo(
         "InteractiveClientInterface : starting paired dummy interaction")
     anonymous_name = interaction.name + "_" + uuid.uuid4().hex
     #process_listener = partial(self._process_listeners, anonymous_name, 1)
     #process = rocon_python_utils.system.Popen([rosrunnable_filename], postexec_fn=process_listener)
     interaction.launch_list[anonymous_name] = LaunchInfo(
         anonymous_name, True, None)  # empty shutdown function
     return True
예제 #3
0
 def stop_interaction(self, interaction_hash):
     """
     This stops all launches for an interaction of a particular type.
     """
     interaction = self.interactions_table.find(interaction_hash)
     if interaction is None:
         console.logerror("Couldn't find interaction with hash '%s'" % interaction_hash)
         return (False, "interaction key %s not found in interactions table" % interaction_hash)
     console.loginfo("Stopping all instances of '%s'" % interaction.name)
     try:
         for unused_launch_name, launch_info in self.launched_interactions.get_launch_details(interaction.hash).iteritems():
             if launch_info.running:
                 launch_info.shutdown()
                 console.loginfo("  instance stopped [%s]" % (launch_info.name))
             elif launch_info.process is None:
                 launch_info.running = False
                 console.loginfo("  no attached interaction process to stop [%s]" % (launch_info.name))
             else:
                 console.loginfo("  instance is already stopped [%s]" % (launch_info.name))
         self.launched_interactions.clear_launch_details(interaction.hash)
     except Exception as e:
         console.logerror("Error trying to stop all instances of an interaction [%s][%s]" % (type(e), str(e)))
         # this is bad...should not create bottomless exception buckets.
         return (False, "unknown failure - (%s)(%s)" % (type(e), str(e)))
     if interaction.is_paired_type():
         self.active_paired_interaction_hashes = [h for h in self.active_paired_interaction_hashes if h != interaction_hash]
     self.signal_updated.emit()
     self._publish_remocon_status()
     return (True, "success")
예제 #4
0
    def __init__(self, ros_master_uri, host_name):
        super(InteractionsRemocon, self).__init__()
        self.key = uuid.uuid4()
        self.ros_master_uri = ros_master_uri
        self.ros_master_port = urlparse(self.ros_master_uri).port
        self.host_name = host_name
        self.name = "rqt_remocon_" + self.key.hex
        console.loginfo("Connection Details")
        console.loginfo("   Node Name: " + self.name)
        console.loginfo("   ROS_MASTER_URI: " + self.ros_master_uri)
        console.loginfo("   ROS_HOSTNAME: " + self.host_name)
        self.launched_interactions = LaunchedInteractions()

        # terminal for roslaunchers and other shell executables
        try:
            self.roslaunch_terminal = rocon_launch.create_terminal()
        except (rocon_launch.UnsupportedTerminal,
                rocon_python_comms.NotFoundException) as e:
            console.warning(
                "Cannot find a suitable terminal, falling back to the current terminal [%s]"
                % str(e))
            self.roslaunch_terminal = rocon_launch.create_terminal(
                rocon_launch.terminals.active)

        self.namespaces = []
        self.active_namespace = None
        self.rocon_uri = "rocon:/"
        self.active_pairing = None
        self.active_paired_interaction_hashes = []
        # TODO a configurable icon...with a default
        self.platform_info = rocon_std_msgs.MasterInfo(
            version=rocon_std_msgs.Strings.ROCON_VERSION,
            rocon_uri=str(self.rocon_uri),
            icon=rocon_std_msgs.Icon(),
            description="")
        self.service_proxies = None
        self.subscribers = None
        self.pairings_table = get_pairings(self.active_namespace)
        self.interactions_table = get_interactions(self.active_namespace,
                                                   "rocon:/")

        self.namespace_scanner = NamespaceScanner()
        self.namespace_scanner.signal_updated.connect(self.interactions_found,
                                                      Qt.QueuedConnection)
        # self.namespace_scanner.busy_dialog.show()
        self.namespace_scanner.start()

        self.remocon_status_publisher = rospy.Publisher(
            "/remocons/" + self.name,
            interaction_msgs.RemoconStatus,
            latch=True,
            queue_size=5)
        self._publish_remocon_status()
 def stop_interaction(self, interaction_hash):
     """
     This stops all launches for an interaction of a particular type.
     """
     interaction = self._interactions_table.find(interaction_hash)
     if interaction is None:
         error_message = "interaction key %s not found in interactions table" % interaction_hash
         console.logwarn(
             "Interactive Client : could not stop interactions of this kind [%s]"
             % error_message)
         return (False, "%s" % error_message)
     else:
         console.logdebug(
             "Interactive Client : stopping all '%s' interactions" %
             interaction.display_name)
     try:
         for launch_info in interaction.launch_list.values():
             if launch_info.running:
                 launch_info.shutdown()
                 console.loginfo(
                     "Interactive Client : interaction stopped [%s]" %
                     (launch_info.name))
                 del interaction.launch_list[launch_info.name]
             elif launch_info.process is None:
                 launch_info.running = False
                 console.loginfo(
                     "Interactive Client : no attached interaction process to stop [%s]"
                     % (launch_info.name))
                 del interaction.launch_list.launch_list[launch_info.name]
             else:
                 console.loginfo(
                     "Interactive Client : interaction is already stopped [%s]"
                     % (launch_info.name))
                 del interaction.launch_list.launch_list[launch_info.name]
     except Exception as e:
         console.logerror(
             "Interactive Client : error trying to stop an interaction [%s][%s]"
             % (type(e), str(e)))
         # this is bad...should not create bottomless exception buckets.
         return (False, "unknown failure - (%s)(%s)" % (type(e), str(e)))
     # console.logdebug("Interactive Client : interaction's updated launch list- %s" % str(interaction.launch_list))
     if interaction.is_paired_type():
         self.currently_pairing_interaction_hashes = [
             h for h in self.currently_pairing_interaction_hashes
             if h != interaction_hash
         ]
     self._publish_remocon_status()
     return (True, "success")
예제 #6
0
 def __del__(self):
     console.loginfo("RemoconMain: Destroy")