Robotics StackExchange | Archived questions

rqt plugin crhashes static map rviz

Dear all,

I have created a rqt plugin in python. When I run the application rqt and then I invoke the launch file within my plugin.py and then I tick the static map option in Rviz, I get the following error:

[ WARN] [1394792185.671328003]: Failed to create full-size map texture, likely because your graphics card does not support textures of size > 2048.  Downsampling to [2048 x 2048]...
terminate called after throwing an instance of 'Ogre::RenderingAPIException'
  what():  OGRE EXCEPTION(3:RenderingAPIException): Zero sized texture surface on texture MapTexture0Downsampled face 0 mipmap 0. Probably, the GL driver refused to create the texture. in GLTexture::_createSurfaceList at /build/buildd/ogre-1.7.4/RenderSystems/GL/src/OgreGLTexture.cpp (line 406)
Aborted (core dumped)

But the funny thing is that, if I run Rviz separately from the plugin with the command rosrun rviz rviz and then I run map server command and then I tick the static map in Rviz. I have no error and the map is uploaded into Rviz.

To be sincere I have no clue what is triggering this error.

I will appreciate any help.

The code is just down here

from __future__ import division
import os
import rospy
import sys
import rospkg
import subprocess

from actionlib_msgs.msg import GoalID
from PyQt4 import QtCore, QtGui
from rosgraph import rosenv
from rqt_gui_py.plugin import Plugin
from python_qt_binding import loadUi
from python_qt_binding.QtGui import QWidget, QKeySequence, QShortcut, QFileDialog, QIcon, QDialog, QStandardItem
from rqt_msg.messages_widget import MessagesWidget
from python_qt_binding.QtCore import Qt, QTimer, Slot,  QModelIndex, Signal

import roslaunch
from roslaunch.core import RLException

 #from rqt_py_common import rosaction


class AWCPlugin(Plugin):
    def __init__(self, context):
        super(AWCPlugin, self).__init__(context)
        self.setObjectName('AWCPlugin')

        self._publisher = None
        self._rospack = rospkg.RosPack()

        self._widget = QWidget()  # MessagesWidget(rosaction.MODE_ACTION)
        rp = rospkg.RosPack()
        ui_file = os.path.join(rp.get_path('rqt_awc'), 'resource', 'awc_gui.ui')
        loadUi(ui_file, self._widget)
        self._widget.setObjectName('AWCPlugin')


       # self._widget.setWindowTitle('AWC')



        if context.serial_number() > 1:
            self._widget.setWindowTitle(self._widget.windowTitle() + (' (%d)' % context.serial_number()))
        context.add_widget(self._widget)


        # self._widget.start.pressed.connect(self._on_start_clicked)
        self._widget.restart.pressed.connect(self._on_restart_clicked)
        self._widget.autonomous.pressed.connect(self._handle_autonomous)
        self._widget.joystick.pressed.connect(self._handle_joystick)
         #self._widget.stop_joystick.pressed.connect(self._on_stop_joystick_clicked)
        self._widget.stop.pressed.connect(self._on_stop_pressed)
        self._widget.semi_autonomous.clicked[bool].connect(self._handle_semi_autonomous)
        # self._widget.stopautonomous.pressed.connect(self._on_stop_autonomous)


    global joystick_flag, start_flag,re_start_flag, autonomous_flag,semiautonomous_flag,runner_start,stop_flag   
    joystick_flag        = 0    
    start_flag           = 0
    re_start_flag        = 0
    autonomous_flag      = 0
    semiautonomous_flag  = 0
    stop_flag            = 0
     #runner_start = 0
    @Slot(str)
    def _handle_autonomous(self): 
        global  start_flag,joystick_flag,autonomous_flag,runner_start,start_flag
        if autonomous_flag == 0:
            self._widget.textEdit.setText("<font size = '30' color ='red'>AUTONOMOUS</font>")
            self._widget.textEdit.setAlignment(QtCore.Qt.AlignCenter)
            launchfile_name = 'patrolbot_navigation.launch'
            folder_name_launchfile = 'launch'
            pkg_name  =  'awc_navigation'
            # try:
             #launchfile = os.path.join(rospkg.RosPack().get_path(pkg_name), folder_name_launchfile, launchfile_name)
             #print( launchfile)
            args =  roslaunch.rlutil.resolve_launch_arguments([pkg_name, launchfile_name])
            rospy.loginfo("Starting task: %s"%args)
            runner_start = roslaunch.parent.ROSLaunchParent(rospy.get_param("/run_id"), args)
            runner_start.start()
                 #start_flag = 0
            autonomous_flag =1
                 #re_start_flag = 1
             #return start_flag
            # except IndexError as e:
                # raise RLException('IndexError: {}'.format(e.message))           
        if autonomous_flag == 1:
            self._widget.textEdit.setText("<font size = '30' color ='red'>AUTONOMOUS </font>")
            self._widget.textEdit.setAlignment(QtCore.Qt.AlignCenter)
        # if start_flag == 0:
           #  self._widget.textEdit.setText("<font size = '30' color ='red' style='text-align:center'>PRESS START</font>")
            # self._widget.textEdit.setAlignment(QtCore.Qt.AlignCenter)
        if joystick_flag == 1:
            runner_joystick.shutdown()
            joystick_flag = 0 

    # def _on_start_clicked(self):
       #  global start_flag,re_start_flag,runner_start, start_flag
        #self._widget.textEdit.setText('Start')
         #self._widget.textEdit.setStyleSheet("background-color: blue");
       #  if start_flag == 0:
          #   self._widget.textEdit.setText("<font size = '30' color ='red'>START</font>")
         #    self._widget.textEdit.setAlignment(QtCore.Qt.AlignCenter)
          #   launchfile_name = 'start.launch'
          #   folder_name_launchfile = 'launch'
          #   pkg_name  =  'awc_navigation'

          #   try:
             #launchfile = os.path.join(rospkg.RosPack().get_path(pkg_name), folder_name_launchfile, launchfile_name)
             #print( launchfile)
            #     args =  roslaunch.rlutil.resolve_launch_arguments([pkg_name, launchfile_name])
             #    rospy.loginfo("Starting task: %s"%args)
              #   runner_start = roslaunch.parent.ROSLaunchParent(rospy.get_param("/run_id"), args)
            #     runner_start.start()
            #     start_flag = 1
                 #re_start_flag = 1
             #return start_flag

           #  except IndexError as e:
           #      raise RLException('IndexError: {}'.format(e.message))
       #  if start_flag == 1:
          #   self._widget.textEdit.setText("<font size = '30' color ='red'>START </font>")
          #   self._widget.textEdit.setAlignment(QtCore.Qt.AlignCenter)

    def _on_restart_clicked(self):
        global start_flag,re_start_flag,runner_start,joystick_flag,autonomous_flag,stop_flag
        if autonomous_flag == 1 or joystick_flag == 1 or stop_flag == 1:
            self._widget.textEdit.setText("<font size = '30' color ='red' style='text-align:center'>RE START</font>")
            self._widget.textEdit.setAlignment(QtCore.Qt.AlignCenter)
            runner_start.shutdown()
            launchfile_name = 'patrolbot_navigation.launch'
            folder_name_launchfile = 'launch'
            pkg_name  =  'awc_navigation'
            #try:
             #launchfile = os.path.join(rospkg.RosPack().get_path(pkg_name), folder_name_launchfile, launchfile_name)
             #print( launchfile)
            args =  roslaunch.rlutil.resolve_launch_arguments([pkg_name, launchfile_name])
            rospy.loginfo("Starting task: %s"%args)
            runner_start = roslaunch.parent.ROSLaunchParent(rospy.get_param("/run_id"), args)
            runner_start.start()
                 #start_flag = 0
            autonomous_flag =1
            stop_flag = 0;
                 #re_start_flag = 1
             #return start_flag
            #except IndexError as e:
             #   raise RLException('IndexError: {}'.format(e.message))  


    def _on_stop_pressed(self):
        #self._widget.x_linear_slider.setValue(0)
         #self._widget.textEdit.setText('Stop')
        global runner_start, runner_joystick, start_flag,joystick_flag,autonomous_flag,stop_flag
          #if start_flag == 0:
             # self._widget.textEdit.setText("<font size = '30' color ='red' style='text-align:center'>PRESS START</font>")
             # self._widget.textEdit.setAlignment(QtCore.Qt.AlignCenter)
        if  autonomous_flag == 1:
            self._widget.textEdit.setText("<font size = '30' color ='red' style='text-align:center'>STOP</font>")
            self._widget.textEdit.setAlignment(QtCore.Qt.AlignCenter)
            #try:
            nav_abort_pub = rospy.Publisher("move_base/cancel", GoalID)
            abort_msg = GoalID()
            nav_abort_pub.publish(abort_msg)
                # autonomous_flag = 0
                #print("We got here")
                #subprocess.Popen("rostopic pub movbase/cancel actionlib_msgs/GoalID '{}'")
            #except IndexError as e:
            #    raise RLException('IndexError: {}'.format(e.message))
         #if start_flag == 1:
            # self._widget.textEdit.setText("<font size = '30' color ='red' style='text-align:center'>STOP</font>")
            # self._widget.textEdit.setAlignment(QtCore.Qt.AlignCenter)
            # runner_start.shutdown()
            # start_flag = 0
        if joystick_flag == 1:
             self._widget.textEdit.setText("<font size = '30' color ='red' style='text-align:center'>STOP</font>")
             self._widget.textEdit.setAlignment(QtCore.Qt.AlignCenter)
             runner_joystick.shutdown()
             joystick_flag = 0
        stop_flag = 1;




    # def _on_stop_autonomous(self):
       #  global  autonomous_flag
        # self._widget.textEdit.setText("<font size = '5' color ='red' style='text-align:center'>STOP AUTONOMOUS</font>")
        # self._widget.textEdit.setAlignment(QtCore.Qt.AlignCenter)
        # if  autonomous_flag == 1:
          #   try:
           #      nav_abort_pub = rospy.Publisher("move_base/cancel", GoalID)
            #     abort_msg = GoalID()
             #    nav_abort_pub.publish(abort_msg)
                # autonomous_flag = 0
                #print("We got here")
                #subprocess.Popen("rostopic pub movbase/cancel actionlib_msgs/GoalID '{}'")
            # except IndexError as e:
             #    raise RLException('IndexError: {}'.format(e.message))



     #def _on_restart_pressed(self):
        # if joystick_flag == 1 or autonomous_flag ==1:
             # self._widget.textEdit.setText("<font size = '30' color ='red' style='text-align:center'>STOP</font>")
          #   self._widget.textEdit.setAlignment(QtCore.Qt.AlignCenter)
          #   runner_start.shutdown()
          #   start_flag = 0



    def _handle_semi_autonomous(self):
        global  start_flag,joystick_flag,semiautonomous_flag
        if semiautonomous_flag == 0:
            self._widget.textEdit.setText("<font size = '5' color ='red' style='text-align:center'>SEMIAUTONOMOUS</font>")
            self._widget.textEdit.setAlignment(QtCore.Qt.AlignCenter)



        # filename = QFileDialog.getOpenFileName(self._widget, self.tr('Load from File'), "/home/acp/patrol_ws/sandbox/patrol_navigation/maps", self.tr("maps (*.pgm)"))
         #if filename[0] != '':
           # try:
             #   handle = open(filename[0])
           # except IOError as e:
             #    qWarning(str(e))
              #   return
          #  self._datamodel.load_from_file(handle)
          #  handle.close()

     #def _on_stop_joystick_clicked(self):
      #   global  joystick_flag
      #   if joystick_flag == 1:
       #      self._widget.textEdit.setText("<font size = '30' color ='red' style='text-align:center'>STOP JOYSTICK</font>")
        #     self._widget.textEdit.setAlignment(QtCore.Qt.AlignCenter)
         #    runner_joystick.shutdown()
          #   joystick_flag = 0

    def _handle_joystick(self):
        global  start_flag,joystick_flag,autonomous_flag,runner_joystick
        # if start_flag == 0:
            # self._widget.textEdit.setText("<font size = '30' color ='red' style='text-align:center'>PRESS START</font>")
            # self._widget.textEdit.setAlignment(QtCore.Qt.AlignCenter)
        if  autonomous_flag == 0:
            self._widget.textEdit.setText("<font size = '4' color ='red' style='text-align:center'>JOYSTICK</font>")
            self._widget.textEdit.setAlignment(QtCore.Qt.AlignCenter)

            launchfile_name = 'patrolbot_navigation.launch'
            folder_name_launchfile = 'launch'
            pkg_name  =  'awc_navigation'
            #try:
             #launchfile = os.path.join(rospkg.RosPack().get_path(pkg_name), folder_name_launchfile, launchfile_name)
             #print( launchfile)
            args =  roslaunch.rlutil.resolve_launch_arguments([pkg_name, launchfile_name])
            rospy.loginfo("Starting task: %s"%args)
            runner_start = roslaunch.parent.ROSLaunchParent(rospy.get_param("/run_id"), args)
            runner_start.start()
                 #start_flag = 0
            autonomous_flag =1
                 #re_start_flag = 1
             #return start_flag
            #except IndexError as e:
            #    raise RLException('IndexError: {}'.format(e.message)) 

            launchfile_name = 'joystick.launch'
            folder_name_launchfile = 'launch'
            pkg_name  =  'awc_navigation'

            #try:
             #launchfile = os.path.join(rospkg.RosPack().get_path(pkg_name), folder_name_launchfile, launchfile_name)
             #print( launchfile)
            args =  roslaunch.rlutil.resolve_launch_arguments([pkg_name, launchfile_name])
            rospy.loginfo("Starting task: %s"%args)
            runner_joystick = roslaunch.parent.ROSLaunchParent(rospy.get_param("/run_id"), args)
            runner_joystick.start()
            joystick_flag = 1
                #return joystick_flag
            #except IndexError as e:
             #   raise RLException('IndexError: {}'.format(e.message))
        if   joystick_flag  == 1:
            self._widget.textEdit.setText("<font size = '30' color ='red' style='text-align:center'>JOYSTICK</font>")
            self._widget.textEdit.setAlignment(QtCore.Qt.AlignCenter)
        if   joystick_flag  == 0:
            self._widget.textEdit.setText("<font size = '30' color ='red' style='text-align:center'>JOYSTICK</font>")
            self._widget.textEdit.setAlignment(QtCore.Qt.AlignCenter)
            launchfile_name = 'joystick.launch'
            folder_name_launchfile = 'launch'
            pkg_name  =  'awc_navigation'

            #try:
             #launchfile = os.path.join(rospkg.RosPack().get_path(pkg_name), folder_name_launchfile, launchfile_name)
             #print( launchfile)
            args =  roslaunch.rlutil.resolve_launch_arguments([pkg_name, launchfile_name])
            rospy.loginfo("Starting task: %s"%args)
            runner_joystick = roslaunch.parent.ROSLaunchParent(rospy.get_param("/run_id"), args)
            runner_joystick.start()
            joystick_flag = 1
                #return joystick_flag
            #except IndexError as e:
             #   raise RLException('IndexError: {}'.format(e.message))

    def shutdown_plugin(self):
        pass
        #self._widget.cleanup_browsers_on_close()

    def save_settings(self, plugin_settings, instance_settings):
        # instance_settings.set_value(k, v)
        pass

    def restore_settings(self, plugin_settings, instance_settings):
        # v = instance_settings.value(k)
        pass

Asked by acp on 2014-03-14 01:25:04 UTC

Comments

Can you show your code in plugin.py?

Asked by ZdenekM on 2014-03-14 03:24:00 UTC

The code is just up here, the funny thing is that it was working well.

Asked by acp on 2014-03-14 05:14:00 UTC

Souns like the launchfile you're launching is publishing a huge map. You can do "rostopic echo /map --noarr" and watch the output when you run your plugin to see the exact size.

Asked by jbinney on 2014-03-14 13:03:30 UTC

Well, I get this map size width: 1984 height: 1984 Then I get another error: terminate called after throwing an instance of 'Ogre::InternalErrorException' what(): OGRE EXCEPTION(7:InternalErrorException): Cannot create GL vertex buffer in GLHardwareVertexBuffer::GLHardwareVertexBuffer at /build/buildd/ogre-1.7.4/RenderSystems/GL/src/OgreGLHardwareVertexBuffer.cpp (line 46)

Asked by acp on 2014-03-16 03:18:59 UTC

The funny thing is that it works quite well when I launch the application in a launch file outside the rqt plugin GUI.

I have installed rosserial following this site, http://wiki.ros.org/rosserial_arduino/Tutorials/Arduino%20IDE%20Setup maybe that installation somehow screw up my rqt plugin

Asked by acp on 2014-03-16 03:25:12 UTC

Answers