qtGui + ROS + RViz

Continuing the discussion from Encountering problems when packaging RViz:

I made a nice pyqt5 gui with an RViz window. I could ‘easily’ snap the qt-gui by it’s own.
Now I cannot snapcraft the gui including RViz.

OPTION-1:
name: rosgui# you probably want to 'snapcraft register ’
version: ‘0.1’ # just for humans, typically ‘1.2+git’ or ‘1.3.2’
summary: this app is a pyqt frontend for ROS commands # 79 char long summary
description: |
This a snap post-processing for a self contained post-processing of data acquired.

grade: devel # must be ‘stable’ to release into candidate/stable channels
confinement: devmode # use ‘strict’ once you have the right plugs and slots

parts:
app:
plugin: dump
source: ./app_src
organize:
main.py: app

stage-packages:
  - python-pyqt5
  - python3-pyqt5
  - python3-pyqt5.qtquick
  - overlay-scrollbar-gtk2
  - libatk-adaptor
  - libcanberra-gtk-module
  - libogre-1.9.0v5
  - g++
  - libboost-all-dev
  - libeigen3-dev
  - ros-kinetic-desktop-full

ros-workspace:
source: ./ros_src
plugin: catkin
rosdistro: kinetic
source-space: roscpp_tutorials/
catkin-packages:
- roscpp_tutorials

apps:
postprocessortest:
command: envwrap desktop-launch $SNAP/app
plugs: [unity7,unity8,desktop, desktop-legacy, wayland, x11, opengl, network, network-bind, home, locale-control, gsettings, pulseaudio]
environment:
LD_LIBRARY_PATH: “$SNAP/usr/lib/x86_64-linux-gnu/OGRE-1.9.0:$SNAP/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms:$SNAP/usr/lib/x86_64-linux-gnu/qt5/plugins:$LD_LIBRARY_PATH”
QT_QPA_PLATFORM_PLUGIN_PATH: “$SNAP/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms”
QT_PLUGIN_PATH: “$SNAP/usr/lib/x86_64-linux-gnu/qt5/plugins”

It didn’t worked, so I tried building RViz only from sources, ( as described in the link), so i created a new directory in my project and included RViz sources from git ( git clone -b kinetic-devel https://github.com/ros-visualization/rviz.git ) and modified my snapcraft.yaml as follow:

name: postprocessortest # you probably want to 'snapcraft register ’
version: ‘0.1’ # just for humans, typically ‘1.2+git’ or ‘1.3.2’
summary: this app is a frontend for Blam-ROS commands # 79 char long summary
description: |
This a snap post-processing full appliation .bag --> {point-cloud.pcd, odometry.csv}, suitable for a self contained post-processing of data acqurired from 3DT-slam-backpack.

grade: devel # must be ‘stable’ to release into candidate/stable channels
confinement: devmode # use ‘strict’ once you have the right plugs and slots

parts:
app:
plugin: dump
source: ./app_src
organize:
main.py: app

stage-packages:
  - qtdeclarative5-qtquick2-plugin
  - python-pyqt5
  - overlay-scrollbar-gtk2
  - libatk-adaptor
  - libcanberra-gtk-module
  - libogre-1.9.0v5
  - build-essential
  - g++
  - libeigen3-dev

stage:
  - -usr/bin/curl-config
  - -usr/lib/x86_64-linux-gnu/libcurl.a
  - -usr/lib/x86_64-linux-gnu/libcurl.la
  - -usr/lib/x86_64-linux-gnu/libcurl.so
  - -usr/lib/x86_64-linux-gnu/pkgconfig/libcurl.pc



after: [desktop-qt5, rviz-workspace, ros-workspace]

ros-workspace:
source: ./ros_src
plugin: catkin
rosdistro: kinetic
source-space: roscpp_tutorials/
catkin-packages:
- roscpp_tutorials

rviz-workspace:
source: ./rviz_src
plugin: catkin
rosdistro: kinetic
source-space: rviz/
catkin-packages:
- rviz
catkin-cmake-args: [
“-DOGRE_PLUGIN_PATH=/snap/slampostprocessortest/current/usr/lib/x86_64-linux-gnu/OGRE-1.9.0”
]
apps:
postprocessortest:
command: desktop-launch $SNAP/app
plugs: [unity7, x11, opengl, network, network-bind, home, locale-control, gsettings]
environment:
LD_LIBRARY_PATH: “$SNAP/usr/lib/x86_64-linux-gnu/OGRE-1.9.0:$SNAP/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms:$SNAP/usr/lib/x86_64-linux-gnu/qt5/plugins:$LD_LIBRARY_PATH”
QT_QPA_PLATFORM_PLUGIN_PATH: “$SNAP/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms”
QT_PLUGIN_PATH: “$SNAP/usr/lib/x86_64-linux-gnu/qt5/plugins”

It actually compiles everything, but when launching the GUI i receive this error:

terminate called after throwing an instance of ‘std::bad_cast’
what(): std::bad_cast
Aborted (core dumped)

What am I doing wrong ??

@astroteo I’m having some serious problems parsing that code, would you mind surrounding the YAML with three backticks so that it’s properly formatted?

To answer explicitly in this thread.

One problem is OGRE_PLUGIN_PATH is overwritten in rviz’s CMakeLists.txt file. I had to make a modification to get it to take. The modification I made is here https://github.com/cratliff/rviz

There may be other issues, but I’m sure you’re running into that one.