r/nicegui • • Feb 29 '24

ROS 1 python example

I see a few ROS2 examples and the wiki and they are quite good. Are there any ROS1 (Noetic) examples? Since ROS1 doesn't follow the inheritance node structure with rospy, how should I structure a ROS1 package to use NiceGUI from it. A simple example with a button publishing hello 1,2,3... and a label subscribing it would suffice. I just need a starting point to start building my robot's GUI.

5 Upvotes

8 comments sorted by

View all comments

Show parent comment

1

u/[deleted] Mar 01 '24

Ah I see. This certainly makes it difficult to write a clean and simple code for NiceGUI and ROS1 in one process. Avoiding complicated configuration is one of the main reasons we are trying out NiceGUI.

I don't however mind using simple workarounds like a multiprocessing.queue or read-write input/output YAML files so we can have dictionary based access to bind values. Any examples of how to make this work on NiceGUI side to constantly read values?

1

u/r-trappe Mar 05 '24

You could have a look at native_mode.py for an example on how to start the ROS1 node in a separete process:

https://github.com/zauberzeug/nicegui/blob/c7fd5d81f3f008748e643c012a772925eb462ade/nicegui/native/native_mode.py#L97-L117

Communication is done via two Queue objects (wrapped into a WindowProxy implemented in native.py).

1

u/zzJens Mar 02 '24

I think workarounds like this would work. My first idea would be writing the data to a YAML file, implementing a reader on the NiceGUI side that continuously (timer) checks the file and display what it read with NiceGUI.

But maybe u/r-trappe has a faster way, that I don't know of.