Skip to content

Commit

Permalink
Merge branch 'feat/sync-categories' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Riei-Joaquim committed Oct 24, 2023
2 parents d6d2f37 + 5f71ed8 commit c87ce3e
Show file tree
Hide file tree
Showing 10 changed files with 135 additions and 16 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions .github/workflows/docker/buildAndPush.sh
Original file line number Diff line number Diff line change
@@ -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}
8 changes: 2 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
(
Expand Down
8 changes: 4 additions & 4 deletions include/soccer-common/Geometry/Geometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <class PT>
constexpr std::enable_if_t<std::is_floating_point_v<CoordType<PT>>, 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<PT> r = dot<PT>(b - a, b - a);
if (isNullable(r)) {
return a;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
#include "soccer-common/Gui/Widgets/ParameterWidget/ParameterWidget.h"
#include "soccer-common/Parameters/Parameters.h"

#include <QTabWidget>
#include <QToolBox>

ParametersWindow::ParametersWindow(QWidget* parent) :
QWidget(parent),
ui(new Ui::ParametersWindow) {
Expand Down Expand Up @@ -33,11 +36,17 @@ void ParametersWindow::build(QMap<QStringList, ParameterWidget*>& 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();
}
}
Expand Down Expand Up @@ -87,3 +96,51 @@ void ParametersWindow::addParametersWindow(QMap<QStringList, ParameterWidget*>&
pw->build(widgets, currentPath, name, json);
ui->scrollAreaLayout->addWidget(pw);
}

void ParametersWindow::addParametersTool(QMap<QStringList, ParameterWidget*>& 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<QStringList, ParameterWidget*>& 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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <QWidget>
#include <QJsonObject>

class QTabWidget;
class ParameterWidget;

namespace Ui {
Expand Down Expand Up @@ -44,6 +45,14 @@ class ParametersWindow : public QWidget {
QStringList& currentPath,
const QString& name,
const QJsonObject& json);
void addParametersTool(QMap<QStringList, ParameterWidget*>& widgets,
QStringList& currentPath,
const QString& name,
const QJsonObject& json);
void addParametersTab(QMap<QStringList, ParameterWidget*>& widgets,
QStringList& currentPath,
const QString& name,
const QJsonObject& json);
};

#endif // SOCCER_COMMON_PARAMETERSWINDOW_H
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion include/soccer-common/Utils/Protobuf/Protobuf.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
namespace Protobuf {
template <class Proto>
QByteArray toByteArray(const Proto& proto) {
QByteArray datagram(static_cast<int>(proto.ByteSize()), static_cast<char>(0));
QByteArray datagram(static_cast<int>(proto.ByteSizeLong()), static_cast<char>(0));
proto.SerializeToArray(datagram.data(), datagram.size());
return datagram;
}
Expand Down
4 changes: 2 additions & 2 deletions include/soccer-common/Utils/StateMachine/StateMachine.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ class StateMachine {
std::invoke_result_t<decltype(PointerToMatchingFunctorDeclval<T, Fs...>)>>;

public:
using return_type = decltype(
std::visit(std::declval<overloaded_visitor_t<Functors...>>(), std::declval<State>()));
using return_type = decltype(std::visit(std::declval<overloaded_visitor_t<Functors...>>(),
std::declval<State>()));

StateMachine() requires(std::default_initializable<State>) = default;

Expand Down
4 changes: 2 additions & 2 deletions include/soccer-common/Utils/meta/static_block/static_block.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
namespace __rc_meta { // NOLINT(bugprone-reserved-identifier)
struct [[maybe_unused]] static_block_tag {
template <class Functor>
inline explicit static_block_tag(Functor && f) {
inline explicit static_block_tag(Functor&& f) {
std::forward<Functor>(f)();
}
~static_block_tag() = default;
Expand All @@ -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
Expand Down

0 comments on commit c87ce3e

Please sign in to comment.