Part 11 (C++ GUI)
In this section, we’ll build a very simple user interface for talking to your pipeline. Building a C++ GUI is very similar to building a pipeline, but with slightly different nomenclature and rules.
Let’s start by editing ${APP_ROOT}/tutorial/gui/tutorial_gui.cc
:
#include "ark/gui/gui_application.hh"
#include "ark/config/gui/config_package_plugin.hh"
#include "ark/debuglog/gui/debug_logger_plugin.hh"
#include "ark/logging/gui/log_writer_plugin.hh"
#include "ark/perf/gui/tracer_plugin.hh"
#include "ark/pipeline/gui/pipeline_metrics_plugin.hh"
#include "ark/plotting/gui/json_decoder_plugin.hh"
#include "ark/plotting/gui/plotting_host_plugin.hh"
int main(int argc, const char **argv)
{
ark::gui::GuiApplicationConfig app_config;
app_config.name = "Tutorial GUI";
ark::gui::GuiApplication application(std::move(app_config), argc, argv);
application.register_central_plugin<ark::config::ConfigPackagePlugin>();
application.register_central_plugin<ark::perf::TracerPlugin>();
application.register_central_plugin<ark::pipeline::PipelineMetricsPlugin>();
application.register_central_plugin<ark::plotting::PlottingHostPlugin>();
application.register_bottom_plugin<ark::debuglog::DebugLoggerPlugin>();
application.register_right_plugin<ark::logging::LogWriterPlugin>();
application.register_right_plugin<ark::plotting::JsonDecoderPlugin>();
return application.execute();
}
This is adding a bit more then we did before. It adds seven plugins in total. Four of them will be in a central pane, one will be at the bottom, and two will be on the right hand side of the GUI.
These are just a few prebuilt Ark plugins to help you inspect pipelines. Most developer GUIs will have these plugins.
Let’s edit the ${APP_ROOT}/tutorial/gui/CMakeLists.txt
file to add the GUI:
qt_add_resources(resources_source ${QDARKSTYLE_RESOURCE})
add_library(tutorial_resources ${resources_source})
add_executable(tutorial_gui tutorial_gui.cc)
target_link_libraries(
tutorial_gui
PRIVATE ark::gui
ark::config_package_plugin
ark::debug_logger_plugin
ark::tracer_plugin
ark::log_writer_plugin
ark::pipeline_metrics_plugin
ark::plotting_host_plugin
ark::json_decoder_plugin
-Wl,--whole-archive
tutorial_resources
-Wl,--no-whole-archive)
And finally, edit the top-level CMakeLists.txt file, and add this line:
build_qt_gui(tutorial/gui)
We use build_qt_gui
here instead of add_subdirectory
to ensure that we don’t
build GUI components on platforms/systems that do not support building GUI components.
Building should proceed without error, and you should then run your
tutorial_pipeline
in one terminal, then run the GUI in a new terminal with:
./build/tutorial_gui
It should open a window, and look something like this:
From here, you should be able to do things like see profiling metrics, plot variables, view JSON versions of messages, or start/stop logging.
Pipeline Metrics
You’ll notice the “Pipeline Metrics” tab is empty. This is because we aren’t
sending them yet! If you want to see them, let’s update your tutorial_pipeline.cc
file once again, and add this line to your MainOffboardConfiguration
:
config.add_pipeline_metrics_stage = true;
Rebuild and re-run your pipeline. Your GUI will automatically reconnect, and you should now see pipeline metrics populated. This tells you how many messages your stages are sending, among other things:
From here, you can see the three stages that we built, and notice that they are emitting and receiving messages at the expected rates.
Continue to Part 12.