def _update_thread_run(self):
        # update type_combo_box
        message_type_names = []
        try:
            # this only works on fuerte and up
            packages = sorted([
                pkg_tuple[0] for pkg_tuple in rosmsg.iterate_packages(
                    self._rospack, rosmsg.MODE_MSG)
            ])
        except:
            # this works up to electric
            packages = sorted(rosmsg.list_packages())
        for package in packages:
            for base_type_str in rosmsg.list_msgs(package,
                                                  rospack=self._rospack):
                message_class = roslib.message.get_message_class(base_type_str)
                if message_class is not None:
                    message_type_names.append(base_type_str)

        self.type_combo_box.setItems.emit(sorted(message_type_names))

        # update topic_combo_box
        _, _, topic_types = rospy.get_master().getTopicTypes()
        self._topic_dict = dict(topic_types)
        self.topic_combo_box.setItems.emit(sorted(self._topic_dict.keys()))
Example #2
0
    def _update_thread_run(self):
        # update type_combo_box
        message_type_names = []
        try:
            # this only works on fuerte and up
            packages = sorted([
                pkg_tuple[0] for pkg_tuple in rosmsg.iterate_packages(
                    self._rospack, rosmsg.MODE_MSG)
            ])
        except:
            # this works up to electric
            packages = sorted(rosmsg.list_packages())
        for package in packages:
            for base_type_str in rosmsg.list_msgs(package,
                                                  rospack=self._rospack):
                message_class = roslib.message.get_message_class(base_type_str)
                if message_class is not None:
                    message_type_names.append(base_type_str)

        # TODO: get all ROS packages and launch files here instead
        #self.type_combo_box.setItems.emit(sorted(message_type_names))
        packages = sorted([
            pkg_tuple[0]
            for pkg_tuple in RqtRoscommUtil.iterate_packages('launch')
        ])
        self.package_combo_box.setItems.emit(packages)
Example #3
0
    def _refresh_msgs(self, package=None):
        if package is None or len(package) == 0:
            return
        self._msgs = []
        if (self._mode == rosmsg.MODE_MSG or
            self._mode == rosaction.MODE_ACTION):
            msg_list = rosmsg.list_msgs(package)
        elif self._mode == rosmsg.MODE_SRV:
            msg_list = rosmsg.list_srvs(package)

        rospy.logdebug('_refresh_msgs package={} msg_list={}'.format(package,
                                                                    msg_list))
        for msg in msg_list:
            if (self._mode == rosmsg.MODE_MSG or
                self._mode == rosaction.MODE_ACTION):
                msg_class = roslib.message.get_message_class(msg)
            elif self._mode == rosmsg.MODE_SRV:
                msg_class = roslib.message.get_service_class(msg)

            rospy.logdebug('_refresh_msgs msg_class={}'.format(msg_class))

            if msg_class is not None:
                self._msgs.append(msg)

        self._msgs = [x.split('/')[1] for x in self._msgs]

        self._msgs_combo.clear()
        self._msgs_combo.addItems(self._msgs)
Example #4
0
def scan_ros_distro():
    global main_widget
    global ROS_PKGS, ROS_MSGS, ROS_SRVS
    # reset current
    ROS_MSGS = []
    ROS_SRVS = []
    # scan with progress shown
    progress_dialog = QProgressDialog('Scanning ROS Distro', 'Cancel', 0, len(ROS_PKGS), parent=main_widget)
    progress_dialog.setWindowModality(Qt.WindowModal)
    count = 0
    total = len(ROS_PKGS)
    for package in ROS_PKGS:
        if progress_dialog.wasCanceled():
            ROS_MSGS = []
            ROS_SRVS = []
            break
        progress_dialog.setValue(count)
        progress_dialog.setLabelText('Scanning ROS Distro\nscanning {0} from {1}: {2}...'.format(
            count+1, total, package))
        if len(rosmsg.list_msgs(package)) > 0:
            ROS_MSGS.append(package)
            progress_dialog.setLabelText('Scanning ROS Distro\nscanning {0} from {1}: {2}...\nfound messages...'.format(
                count+1, total, package))
        if len(rosmsg.list_srvs(package)) > 0:
            progress_dialog.setLabelText('Scanning ROS Distro\nscanning {0} from {1}: {2}...\nfound services...'.format(
                count+1, total, package))
            ROS_SRVS.append(package)
        count += 1
    progress_dialog.setValue(len(ROS_PKGS))
    # store settings
    store_settings()
    print 'stored {0} msgs and {1} srvs...'.format(len(ROS_MSGS), len(ROS_SRVS))
Example #5
0
 def package_changed(self):
     # display messages or services from selected package
     package = str(self.ui.packageComboBox.currentText())
     comm = str(self.ui.commComboBox.currentText())
     self.ui.typeComboBox.clear()
     if comm in ['Publisher', 'Subscriber']:
         self.ui.typeComboBox.addItems(rosmsg.list_msgs(package))
     else:
         self.ui.typeComboBox.addItems(rosmsg.list_srvs(package))
def handle_rwt_action(req):
    action = rosaction.MODE_ACTION
    pkg = RosPack()
    package = rosaction.iterate_packages(pkg, action)
    messageList = []
    for pack in package:
        action, path = pack
        message = rosmsg.list_msgs(action)
        messageList.append(str(message))
    return ActionListResponse(messageList)
    def messages(self):
        '''List of names of the messages defined by the package'''
        msgs = rosmsg.list_msgs(self.pkg_name, self.rospack)
        srvs = rosmsg.list_srvs(self.pkg_name, self.rospack)
        # Remove prefix 'package_name/'
        msgs = [msg.replace(self.pkg_name + '/', '', 1) for msg in msgs]
        srvs = [srv.replace(self.pkg_name + '/', '', 1) for srv in srvs]

        self.has_msg = (len(msgs) > 0)
        self.has_service = (len(srvs) > 0)

        srv_list = []
        for elm in srvs:
            srv_list.append(elm + "Request")
            srv_list.append(elm + "Response")
        return msgs + srv_list
    def _refresh_messages(self, package=None):
        if package is None or len(package) == 0:
            return
        self._messages = []
        if self._mode == rosmsg.MODE_MSG:
            message_list = rosmsg.list_msgs(package)
        elif self._mode == rosmsg.MODE_SRV:
            message_list = rosmsg.list_srvs(package)
        for message in message_list:
            if self._mode == rosmsg.MODE_MSG:
                message_class = roslib.message.get_message_class(message)
            elif self._mode == rosmsg.MODE_SRV:
                message_class = roslib.message.get_service_class(message)
            if message_class is not None:
                self._messages.append(message)

        self._messages = [x.split('/')[1] for x in self._messages]

        self.message_combo.clear()
        self.message_combo.addItems(self._messages)
Example #9
0
def find_ros_type(rospack, asn1Type):
    '''
    Finds the ROS type corresponding to an ASN.1 type. 
    Receives a rospack object with the ROS packages information and
    the name of the ASN.1 type. Returns (found, package, message), 
    where found is a bool indicating success or failure, and if True, 
    then package and message are  the ROS package name and message 
    names corresponding to the input asn1Type.
    '''

    packages = [
        pkg for pkg, _ in rosmsg.iterate_packages(rospack, rosmsg.MODE_MSG)
    ]

    for pkg in packages:
        for msg in rosmsg.list_msgs(pkg, rospack):
            if type_name_matches(asn1Type, msg):
                return (True, pkg, msg)

    return (False, None, None)
    def _update_thread_run(self):
        # update type_combo_box
        message_type_names = []
        try:
            # this only works on fuerte and up
            packages = sorted([pkg_tuple[0] for pkg_tuple in rosmsg.iterate_packages(self._rospack, rosmsg.MODE_MSG)])
        except:
            # this works up to electric
            packages = sorted(rosmsg.list_packages())
        for package in packages:
            for base_type_str in rosmsg.list_msgs(package, rospack=self._rospack):
                message_class = roslib.message.get_message_class(base_type_str)
                if message_class is not None:
                    message_type_names.append(base_type_str)

        self.type_combo_box.setItems.emit(sorted(message_type_names))

        # update topic_combo_box
        _, _, topic_types = rospy.get_master().getTopicTypes()
        self._topic_dict = dict(topic_types)
        self.topic_combo_box.setItems.emit(sorted(self._topic_dict.keys()))