diff --git a/.github/workflows/docker/Dockerfile b/.github/workflows/docker/Dockerfile new file mode 100644 index 00000000..bbc81418 --- /dev/null +++ b/.github/workflows/docker/Dockerfile @@ -0,0 +1,47 @@ +FROM ubuntu:22.04 + +ARG DEBIAN_FRONTEND=noninteractive + +LABEL org.opencontainers.image.authors="RoboCIn-Unification" + +# essentials +RUN apt-get update \ + && apt-get -y upgrade \ + && apt-get install -y \ + build-essential \ + libssl-dev \ + libffi-dev \ + python3-dev \ + python3-pip \ + wget \ + unzip \ + git \ + sudo \ + pkg-config \ + locales \ + && apt-get clean + +# Set the locale +RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && \ + locale-gen + +ENV LANG en_US.UTF-8 +ENV LANGUAGE en_US:en +ENV LC_ALL en_US.UTF-8 + +# set vulkan environment +RUN wget -qO- https://packages.lunarg.com/lunarg-signing-key-pub.asc | sudo tee /etc/apt/trusted.gpg.d/lunarg.asc && \ + wget -qO /etc/apt/sources.list.d/lunarg-vulkan-jammy.list http://packages.lunarg.com/vulkan/lunarg-vulkan-jammy.list &&\ + apt-get update && \ + apt-get install vulkan-sdk -y + + +# ssl-unification +RUN git clone --recursive https://github.com/robocin/soccer-common.git && \ + cd soccer-common/scripts && \ + ./setup.py --essentials && \ + cd ../.. && \ + rm -r soccer-common + + +WORKDIR /home/soccer-common \ No newline at end of file diff --git a/.github/workflows/docker/buildAndPush.sh b/.github/workflows/docker/buildAndPush.sh new file mode 100644 index 00000000..da698672 --- /dev/null +++ b/.github/workflows/docker/buildAndPush.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +REPO_DOCKER_NAME="robocin/soccer-common" +REPO_DOCKER_TAG="latest" + +docker build . -f Dockerfile -t ${REPO_DOCKER_NAME}:${REPO_DOCKER_TAG} + +docker push ${REPO_DOCKER_NAME}:${REPO_DOCKER_TAG} \ No newline at end of file diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7458254d..2eba9dd4 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -8,19 +8,15 @@ on: jobs: build: runs-on: ubuntu-latest - + container: robocin/soccer-common:latest # Steps represent a sequence of tasks that will be executed as part of the job steps: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - name: checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: submodules: recursive - # Install all dependencies using setup.py script inside scripts folder - - name: install-dependencies - run: cd ${GITHUB_WORKSPACE}/scripts && sudo ./setup.py --essentials - - name: check-coding-style run: | ( diff --git a/include/soccer-common/Geometry/Geometry.h b/include/soccer-common/Geometry/Geometry.h index 07cb05bc..7c222535 100644 --- a/include/soccer-common/Geometry/Geometry.h +++ b/include/soccer-common/Geometry/Geometry.h @@ -650,14 +650,14 @@ namespace Geometry2D { * @tparam PT Requires '.x()' and '.y()' members. * @param a, b, c line through (a, b) and point c. * @return Projects the point c onto segment through a and b. - * @note assuming a != b. + * @note assuming if a == b it returns one of the points. */ template constexpr std::enable_if_t>, PT> projectPointSegment(const PT& a, const PT& b, const PT& c) { - if (a == b) { - throw std::runtime_error("'a' and 'b' doesn't define a line."); - } + // if (a == b) { + // throw std::runtime_error("'a' and 'b' doesn't define a line."); + // } CoordType r = dot(b - a, b - a); if (isNullable(r)) { return a; diff --git a/include/soccer-common/Gui/Widgets/ParametersWindow/ParametersWindow.cpp b/include/soccer-common/Gui/Widgets/ParametersWindow/ParametersWindow.cpp index aa9fdc48..83a9a361 100644 --- a/include/soccer-common/Gui/Widgets/ParametersWindow/ParametersWindow.cpp +++ b/include/soccer-common/Gui/Widgets/ParametersWindow/ParametersWindow.cpp @@ -4,6 +4,9 @@ #include "soccer-common/Gui/Widgets/ParameterWidget/ParameterWidget.h" #include "soccer-common/Parameters/Parameters.h" +#include +#include + ParametersWindow::ParametersWindow(QWidget* parent) : QWidget(parent), ui(new Ui::ParametersWindow) { @@ -33,11 +36,17 @@ void ParametersWindow::build(QMap& widgets, for (const QString& key : keys) { currentPath.push_back(key); - if (Parameters::isParameterType(json[key].toObject())) { + + if (key == Parameters::Detail::Tool) { + addParametersTool(widgets, currentPath, key, json[key].toObject()); + } else if (key == Parameters::Detail::Tab) { + addParametersTab(widgets, currentPath, key, json[key].toObject()); + } else if (Parameters::isParameterType(json[key].toObject())) { addParameterWidget(widgets, currentPath, key, json[key].toObject()); } else { addParametersWindow(widgets, currentPath, key, json[key].toObject()); } + currentPath.pop_back(); } } @@ -87,3 +96,51 @@ void ParametersWindow::addParametersWindow(QMap& pw->build(widgets, currentPath, name, json); ui->scrollAreaLayout->addWidget(pw); } + +void ParametersWindow::addParametersTool(QMap& widgets, + QStringList& currentPath, + const QString& name, + const QJsonObject& json) { + auto addSingleItem = [&](const QString& tabName, QToolBox* toolBox) { + ParametersWindow* pw = new ParametersWindow(toolBox); + + pw->setObjectName(tabName); + pw->build(widgets, currentPath, tabName, json[tabName].toObject()); + pw->ui->groupBox->setTitle(""); // Avoid showing the name of the item in the group box. + + toolBox->addItem(pw, tabName); + }; + + QToolBox* toolBox = new QToolBox(ui->scrollAreaWidgetContents); + ui->scrollAreaLayout->addWidget(toolBox); + + for (const QString& item : json.keys()) { + currentPath.push_back(item); + addSingleItem(item, toolBox); + currentPath.pop_back(); + } +} + +void ParametersWindow::addParametersTab(QMap& widgets, + QStringList& currentPath, + const QString& name, + const QJsonObject& json) { + auto addSingleTab = [&](const QString& tabName, QTabWidget* tabWidget) { + ParametersWindow* pw = new ParametersWindow(tabWidget); + + pw->setObjectName(tabName); + pw->build(widgets, currentPath, tabName, json[tabName].toObject()); + pw->ui->groupBox->setTitle(""); // Avoid showing the name of the tab in the group box. + + tabWidget->addTab(pw, tabName); + }; + + QTabWidget* tabWidget = new QTabWidget(ui->scrollAreaWidgetContents); + ui->scrollAreaLayout->addWidget(tabWidget); + + for (const QString& tab : json.keys()) { + currentPath.push_back(tab); + addSingleTab(tab, tabWidget); + currentPath.pop_back(); + } +} \ No newline at end of file diff --git a/include/soccer-common/Gui/Widgets/ParametersWindow/ParametersWindow.h b/include/soccer-common/Gui/Widgets/ParametersWindow/ParametersWindow.h index ab9f32b6..342e3fcf 100644 --- a/include/soccer-common/Gui/Widgets/ParametersWindow/ParametersWindow.h +++ b/include/soccer-common/Gui/Widgets/ParametersWindow/ParametersWindow.h @@ -4,6 +4,7 @@ #include #include +class QTabWidget; class ParameterWidget; namespace Ui { @@ -44,6 +45,14 @@ class ParametersWindow : public QWidget { QStringList& currentPath, const QString& name, const QJsonObject& json); + void addParametersTool(QMap& widgets, + QStringList& currentPath, + const QString& name, + const QJsonObject& json); + void addParametersTab(QMap& widgets, + QStringList& currentPath, + const QString& name, + const QJsonObject& json); }; #endif // SOCCER_COMMON_PARAMETERSWINDOW_H diff --git a/include/soccer-common/Parameters/ParameterType/ParameterType.h b/include/soccer-common/Parameters/ParameterType/ParameterType.h index 0c2240dc..38ba4f16 100644 --- a/include/soccer-common/Parameters/ParameterType/ParameterType.h +++ b/include/soccer-common/Parameters/ParameterType/ParameterType.h @@ -40,6 +40,8 @@ namespace Parameters { static constexpr const char* Parent = "Parent"; static constexpr const char* Filter = "Filter"; static constexpr const char* DefaultDirectory = "DefaultDirectory"; + static constexpr const char* Tab = "Tab"; + static constexpr const char* Tool = "Tool"; } // namespace Detail struct ParameterBase { diff --git a/include/soccer-common/Utils/Protobuf/Protobuf.h b/include/soccer-common/Utils/Protobuf/Protobuf.h index 75ecfafa..68f78e6f 100644 --- a/include/soccer-common/Utils/Protobuf/Protobuf.h +++ b/include/soccer-common/Utils/Protobuf/Protobuf.h @@ -11,7 +11,7 @@ namespace Protobuf { template QByteArray toByteArray(const Proto& proto) { - QByteArray datagram(static_cast(proto.ByteSize()), static_cast(0)); + QByteArray datagram(static_cast(proto.ByteSizeLong()), static_cast(0)); proto.SerializeToArray(datagram.data(), datagram.size()); return datagram; } diff --git a/include/soccer-common/Utils/StateMachine/StateMachine.h b/include/soccer-common/Utils/StateMachine/StateMachine.h index c42ac90c..3a03046f 100644 --- a/include/soccer-common/Utils/StateMachine/StateMachine.h +++ b/include/soccer-common/Utils/StateMachine/StateMachine.h @@ -30,8 +30,8 @@ class StateMachine { std::invoke_result_t)>>; public: - using return_type = decltype( - std::visit(std::declval>(), std::declval())); + using return_type = decltype(std::visit(std::declval>(), + std::declval())); StateMachine() requires(std::default_initializable) = default; diff --git a/include/soccer-common/Utils/meta/static_block/static_block.h b/include/soccer-common/Utils/meta/static_block/static_block.h index 7a1da3b2..da987d94 100644 --- a/include/soccer-common/Utils/meta/static_block/static_block.h +++ b/include/soccer-common/Utils/meta/static_block/static_block.h @@ -6,7 +6,7 @@ namespace __rc_meta { // NOLINT(bugprone-reserved-identifier) struct [[maybe_unused]] static_block_tag { template - inline explicit static_block_tag(Functor && f) { + inline explicit static_block_tag(Functor&& f) { std::forward(f)(); } ~static_block_tag() = default; @@ -16,7 +16,7 @@ namespace __rc_meta { // NOLINT(bugprone-reserved-identifier) static_block_tag& operator=(const static_block_tag&) = delete; // disable_move: - static_block_tag(static_block_tag &&) = delete; + static_block_tag(static_block_tag&&) = delete; static_block_tag& operator=(static_block_tag&&) = delete; }; } // namespace __rc_meta