Embedding RViz2 within a custom PyQt5 GUI - python

I am trying to make a GUI application to control my robot. The purpose of the GUI is to be able to call appropriate services/publish some data when the button is pressed. I have been able to do these by connecting the callbacks of the button elements to the ROS2 service callbacks/publisher callbacks. I am currently using RViz to visualise my robot and the environment. I would like to embed the RViz GUI within my PyQt5 GUI, so that I can see the robot and interact(rotate, zoom, etc.) with the robot, but inside my GUI.
I attach an example of what it should look like in the image below:
I know that I can publish the camera feed as images using TextLabels, but this would defeat my purpose of being able to interact with the environment within RViz. Does anybody know how to do that, or have a minimal example of how I can embed RViz inside my PyQt5 app? I am completely new to GUI development, which is why I am facing some issues with understanding what sort of QWidget I would need to use.
Thanks in advance for your help!

At the moment rviz2 doesn't seem to have Python bindings. It's been requested as a feature though. Check the following issue for updates on its implementation:
https://github.com/ros2/rviz/issues/640
Rviz for ROS 1 does have Python bindings. See the following tutorial for how to integrate rviz visualization frames into your pyqt5 application:
http://docs.ros.org/en/melodic/api/rviz_python_tutorial/html/index.html
You could possibly use the ros1_bridge to interface an rviz1 application to ROS 2:
https://github.com/ros2/ros1_bridge

Related

How to make GUI in another application with python?

For exampe, there is a game called Hearthstone, and this is how it looks normaly:
Normal Hearthstone
But you can download a deck tracker tool like this one, and it will add more UI right in the game window:
Deck tracker
How should I approach a project like that, if I want to add some text, for example, to another application? Preferably in python. Any library recomendations?
I've looked into Tkinter and other GUI libraries, but they focus on making your own window applications, not adding to the existing one.

Application for windows and mac using python

I'm in a dilemma. I've got a python code that works for each of the yellow squares shown below but I want to make an application that looks like below and uses the information from the first text box and the second drag and drop box. Then depending on what the user clicked on, the code for that would run. I'm not sure how to approach this. Any help would be greatly appreciated!
You can use Python GUI libraries like:
Tkinter
PyQT
WxPython
Kivy
Pyglet
(This list is not exhaustive.)
Each has their own advantages and disadvantages. Choose the one that fits your project the best.
My personal recommendation for your particular project would be Kivy.

pyqt embed in photoshop

This is complex to explain, I hope this will not end up being a vague question getting vague answers.
If this is not the right place to ask this, you may help me to find the proper one.
I have a plugin for Photoshop based on the Listener, so it captures any input from the user.
The plugin creates a python module (called here "ps") containing basically the hInstance and the hwnd of the photoshop window.
Then this plugin, using plain python commands in the plugin for the module like those
PyRun_SimpleString("import Photoshop");
PyRun_SimpleString("Photoshop.showTools()");
will load a special module (here called "Photoshop") that will initialize pyqt and using the QtWinMigrate and the ps module to get the hInstance like this: QMfcApp.pluginInstance(ps.GetPluginInstance()), will start pyqt in photoshop. Here an example code of the Photoshop module using the ps module:
from PyQt4.QtWinMigrate import QMfcApp
from PyQt4.QtGui import QPushButton
import ps #this is implemented in the photoshop plugin (based on the Listener plugin)
#create the plugin instance here
app=QMfcApp.pluginInstance(ps.GetPluginInstance())
def showTools():
box = QPushButton()
box.show()
app.exec_()
Again then, the sequence is like this:
When the plugin starts in photoshop "ps" module is created, then it will load the "Photoshop" module that will load and bind properly pyqt. In the "Photoshop" module I can load any python module, widgets are properly working and everything works really well inside Photoshop.
But now the problem is: using Wacom tablets in Photoshop loose stroke sensitivity, the driver works and everything else works but the pressure sensitivity.
Apparently QMfcApp.pluginInstance will install an event filter to drive the Qt event loop while photoshop still owns the event loop. ( http://doc.qt.digia.com/solutions/4/qtwinmigrate/qmfcapp.html )
and on the paper looks fine to me.. but I could not manage to solve this by myself and I tried, more or less carefully, different approaches:
the listener plugin is not the problem. If Listener plugin runs but python is not initialized sensitivity works fine.
python itself is not a problem. If the listener starts python without gui nor pyqt, then works fine.
as soon as I call pluginInstance which should create the QApplication the issue starts and pressure is lost from the tablet. Even with the small code I wrote before.
Someone may have put pyqt as a plugin somewhere else, since the only purpose of QMfcApp is apparently this one. There is something I can configure to make it work? Is a known issue?
I would rather keep the approach (instead of connecting to photoshop externally like with COM)
I am not able to post the entire code here but let me know if you need something.. I probably can show more.
Thanks a lot for your help

A wx python application that uses Google maps

I intend to makea wx python application that can request and show the google map (or map from another similar map service) for a specific set of coordinates.
The application should:
Show a particular section of the map, rather than the whole screen.
Be able to adjust the resolution/magnification of image.
Be able to show map view and satelite image.
Where do I start?
Where to start:
import wx
Now that I have that out of my system :-) ... The first place you should start is to determine if wx can host a browser capable of displaying google maps. wxPython on windows can natively host IE so you could use that for displaying google maps on windows. (Dig around in the demo)
I am not sure if you can host Mozilla or Chrome inside a wx application. So, first determine if you can even display google maps in a wx app.
There is no pre-made widget that can do this for you. wxPython does have a WebView widget, starting in wxPython 2.9, that uses a web browser on the backend and is a bit more robust than the ActiveX version of the widget that was in older versions of wx. You could use that to display the map. Note that you will still need to figure out how to send Google API commands to the wrapped browser instance to manipulate the map.
You might also take a look at PySlip, which can be used to display large images in a tiled manner: https://code.google.com/p/pyslip/wiki/Introduction

Raspberry Pi Python Graph continually updating

I'm using a raspberry pi currently for a engineering project, and am collecting data using the GPIO pins from various sensors. Id like to display this data on a graph. I've used matplotlib to get a graph to show, but for the program to continue you need to close the graph window. I've researched, but can't seem to find a way to make the graph stay open, and have it continually updated with the program running in the background. Is there a way to do this? Or should I try creating a HTML file with a graph in it and have the program open that?
Thanks for any help!
You can use the Plotly Python API to log and stream data to a graph in your browser from your RasPi. You can fork the code from GitHub to setup an online graph like this. The example here is temperature.
Once you've generated your graph, you can embed it as an iframe with this snippet:
<iframe id="igraph" src="https://plot.ly/~abhishek.mitra.963/1/400/250/"
width="400" height="250" seamless="seamless" scrolling="no"></iframe>
You'll want to swap in your URL in the snippet. You can edit the width and height in the URL string and fields to change how it looks. Here's how it looks:
(Full disclosure: I'm on team Plotly).
You could show the Graph in another Thread by using the module thread or the module threading (which is an object oriented and more powerful alternative). For more infos on these module have a look the python documentation for thread or threading.

Categories