Post

GUI Simplified

Index

JdRobot Division

Robots Academy

Repository with the exercises and frontend, here are the classes and the specific functions of each exercise.

RoboticsApplicationManager

Repository for communications between browser - manager - user.

RoboticsInfrastructure

Repository with robot models, gazebo maps and launchers. It also contains libraries such as HAL.

issue #2640

GUI was divided into two classes, which was not efficient as this could actually be simplified. We simplified the functions and created a single global class called ThreadingGUI. Once this was done, we realised that acks are never checked. We also solved the problem.

RoboticsInfrastructure Starting Guide

For our changes to this package to take effect in our docker we must bind the changes, they will be uploaded to the docker ws from where we will use a terminal to compile it.

GUI as library

We have been trying to further simplify the GUI class and create a library for its main functions. To do this, the HAL library has been used as a template. Once created (thanks to another contributor) to test the changes we must follow these steps:

First we must enter RoboticsAcademy/compose_cfg and modify the dev_humble.yaml we are using, adding these lines:

1
2
3
- type: bind
        source: /home/duro/Escritorio/PRACTICAS/RoboticsInfrastructure/gui_interfaces
        target: /home/ws/src/gui_interfaces

Then, we will have to launch the docker, enter an exercise and from the terminal:

1
2
cd /home/ws
colcon build --symlink-install

Once this is done, the changes will be saved and we should be ready to test the changes.

Right now we don’t know why, but it doesn’t work as we want, here is an example of how the GUI.py file of one of the simplest exercises (basic vacuum cleaner) would look like:

1
2
3
4
5
6
7
8
from console import start_console
from gui_interfaces.general.threading_gui import  ThreadingGUI

host = "ws://127.0.0.1:2303"
gui = ThreadingGUI(host)

# Redirect the console
start_console()

Gui interfaces and console interfaces created

The problem we were having is that we had to generate an image in order to test the new ‘libraries’, when trying to compile from the console inside docker, they were not linking correctly.

Here is an example of the vacuum cleaner GUI.py, to see the difference from when it didn’t work:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import json

from gui_interfaces.general.threading_gui import ThreadingGUI
from console_interfaces.general.console import start_console
from map import Map
from HAL import getPose3d

class GUI(ThreadingGUI):

    def __init__(self, host="ws://127.0.0.1:2303"):
        super().__init__(host)

        # Payload vars
        # Specific variables....
        #
        #

        self.start()

    # Prepares and sends a map to the websocket server
    def update_gui(self):
        # Specific function for each exercise
        # Mainly sends info to update gui
        #
        #

    def reset_gui(self):
        self.map.reset()

host = "ws://127.0.0.1:2303"
gui = GUI(host)

# Redirect the console
start_console()

All exercises were modified, simplified and all repetitive code was removed, honestly, it is now much clearer and each exercise only has its own specific code. The rescue_people and follow_person exercises were the least simplified because of their greater complexity compared to the others.

Thanks to this breakthrough and some changes provided by other contributors, the new version 4.6.2 has been released.

This post is licensed under CC BY 4.0 by the author.

Trending Tags