Пример #1
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)
Пример #2
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))
Пример #3
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))
Пример #4
0
def handle_rwt_srv(req):
    srv = rosmsg.MODE_SRV
    pkg = RosPack()
    package = rosmsg.iterate_packages(pkg, srv)
    messageList = []
    for pack in package:
        service, path = pack
        message = rosmsg.list_srvs(service)
        messageList.append(str(message))
    return SrvListResponse(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)