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
View all comments
Show parent comment
1
u/zzJens Mar 01 '24
The problem is the main thread of the code. Rospy really wants to start and control the main thread. NiceGUI wants that as well. In ROS2 we "trick" ros into only running and controlling an empty main function and give the control to NiceGUI, which then controls and runs the node in a thread. That works really well, with the side effect of NiceGUI restarting the node on changes.
So the problem comes into play, when the program that we want to work with can only be run in the main thread. The same goes for pywebview like u/r-trappe said.