Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Larc2023 #29

Open
wants to merge 29 commits into
base: LARC2022
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
93d925e
Change vision to use ssl-vision packets
FelipeMartins96 Mar 31, 2023
9a56ded
fix(Constants): changes qtPlayers
ersaraujo Aug 21, 2023
b75720b
fix(Referee): Remove collision detection
ersaraujo Aug 21, 2023
1a1ec8f
refactor(Constants): Increase transition time to robot placement
ersaraujo Aug 21, 2023
e323482
fix(Referee): Remove replacer call
ersaraujo Aug 21, 2023
c7f8e14
feat(SoccerView): adding buttons for enable or disable the teleport
acrucha Sep 19, 2023
7d46fbf
feat(Replacer): sending teleport only if the teleport is enabled by t…
acrucha Sep 19, 2023
836fd7f
feat(Constants): adding vss-vision address and port
acrucha Sep 19, 2023
aa897ac
feat(SoccerView): adding buttons to choose vision packet type
acrucha Sep 19, 2023
fc8b6f3
feat(VIsion): using ui vision buttons to change the vision packet type
acrucha Sep 19, 2023
18de86c
Merge branch 'SSL-VISION-PACKETS' into LARC2023
acrucha Sep 19, 2023
ff63d85
chore(Vision): changing the debug text color
acrucha Sep 19, 2023
0b20427
fix(Referee): calling replacer only if its FIRA vision
acrucha Sep 19, 2023
d918811
env(Docker): create Dockerfile and docker run script
ersaraujo Sep 23, 2023
5e8eb47
refactor(soccerview): adjust font size
ersaraujo Sep 24, 2023
110c0a7
feat(UI/UX): create request for team names
ersaraujo Sep 25, 2023
dc7cc98
refactor(Socket): remove interface definition
ersaraujo Sep 28, 2023
8e73a05
refactor(Main): remove the window to get team's names
ersaraujo Sep 28, 2023
778ff0f
feat(UI): adds team choice on interface
ersaraujo Sep 28, 2023
1ef1105
fix(SoccerView): adjust teams names
ersaraujo Sep 29, 2023
888d49e
refactor(SoccerView): change vision buttons position
ersaraujo Sep 29, 2023
6c17c9b
send multiple packages
ersaraujo Oct 4, 2023
070560d
remove halt
ersaraujo Oct 8, 2023
f7def2f
add "GAME_ON" suggestion
ersaraujo Oct 9, 2023
3d0581c
ACABOU OS GOLS INFINITOS
ersaraujo Oct 9, 2023
b41ae24
AGORA SIM ACABOU OS GOLS INFINITOS
ersaraujo Oct 9, 2023
c19403d
feat(*): add timeout and var
acrucha Oct 9, 2023
74b94cd
add timout and var buttons
ersaraujo Oct 9, 2023
3390477
default ports
ersaraujo Oct 17, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM ubuntu:22.04

RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends \
libqt5opengl5-dev \
qtbase5-dev \
build-essential \
freeglut3-dev \
protobuf-compiler \
libprotobuf-dev

COPY . /opt/vssreferee

WORKDIR /opt/vssreferee/build

RUN qmake .. && make -j4

WORKDIR /opt/vssreferee/bin

CMD ["./VSSReferee","--3v3","--record","false"]
6 changes: 6 additions & 0 deletions VSSReferee.pro
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ SOURCES += \
include/vssref_command.pb.cc \
include/vssref_common.pb.cc \
include/vssref_placement.pb.cc \
include/messages_robocup_ssl_detection.pb.cc \
include/messages_robocup_ssl_geometry.pb.cc \
include/wrapper.pb.cc \
main.cpp \
src/constants/constants.cpp \
src/recorder/recorder.cpp \
Expand Down Expand Up @@ -90,6 +93,9 @@ HEADERS += \
include/vssref_command.pb.h \
include/vssref_common.pb.h \
include/vssref_placement.pb.h \
include/messages_robocup_ssl_detection.pb.h \
include/messages_robocup_ssl_geometry.pb.h \
include/wrapper.pb.h \
src/constants/constants.h \
src/recorder/recorder.h \
src/refereecore.h \
Expand Down
5 changes: 5 additions & 0 deletions docker_run
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

xhost +
docker run -e DISPLAY=$DISPLAY --network=host -it vssreferee
xhost -
32 changes: 32 additions & 0 deletions include/proto/messages_robocup_ssl_detection.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
syntax = "proto2";

message SSL_DetectionBall {
required float confidence = 1;
optional uint32 area = 2;
required float x = 3;
required float y = 4;
optional float z = 5;
required float pixel_x = 6;
required float pixel_y = 7;
}

message SSL_DetectionRobot {
required float confidence = 1;
optional uint32 robot_id = 2;
required float x = 3;
required float y = 4;
optional float orientation = 5;
required float pixel_x = 6;
required float pixel_y = 7;
optional float height = 8;
}

message SSL_DetectionFrame {
required uint32 frame_number = 1;
required double t_capture = 2;
required double t_sent = 3;
required uint32 camera_id = 4;
repeated SSL_DetectionBall balls = 5;
repeated SSL_DetectionRobot robots_yellow = 6;
repeated SSL_DetectionRobot robots_blue = 7;
}
151 changes: 151 additions & 0 deletions include/proto/messages_robocup_ssl_geometry.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
syntax = "proto2";
// A 2D float vector.
message Vector2f {
// X-coordinate in mm
required float x = 1;
// Y-coordinate in mm
required float y = 2;
}

// Represents a field marking as a line segment represented by a start point p1,
// and end point p2, and a line thickness. The start and end points are along
// the center of the line, so the thickness of the line extends by thickness / 2
// on either side of the line.
message SSL_FieldLineSegment {
// Name of this field marking.
required string name = 1;
// Start point of the line segment.
required Vector2f p1 = 2;
// End point of the line segment.
required Vector2f p2 = 3;
// Thickness of the line segment.
required float thickness = 4;
// The type of this shape
optional SSL_FieldShapeType type = 5;
}

// Represents a field marking as a circular arc segment represented by center point, a
// start angle, an end angle, and an arc thickness.
message SSL_FieldCircularArc {
// Name of this field marking.
required string name = 1;
// Center point of the circular arc.
required Vector2f center = 2;
// Radius of the arc.
required float radius = 3;
// Start angle in counter-clockwise order.
required float a1 = 4;
// End angle in counter-clockwise order.
required float a2 = 5;
// Thickness of the arc.
required float thickness = 6;
// The type of this shape
optional SSL_FieldShapeType type = 7;
}

message SSL_GeometryFieldSize {
// Field length (distance between goal lines) in mm
required int32 field_length = 1;
// Field width (distance between touch lines) in mm
required int32 field_width = 2;
// Goal width (distance between inner edges of goal posts) in mm
required int32 goal_width = 3;
// Goal depth (distance from outer goal line edge to inner goal back) in mm
required int32 goal_depth = 4;
// Boundary width (distance from touch/goal line centers to boundary walls) in mm
required int32 boundary_width = 5;
// Generated line segments based on the other parameters
repeated SSL_FieldLineSegment field_lines = 6;
// Generated circular arcs based on the other parameters
repeated SSL_FieldCircularArc field_arcs = 7;
// Depth of the penalty/defense area (measured between line centers) in mm
optional int32 penalty_area_depth = 8;
// Width of the penalty/defense area (measured between line centers) in mm
optional int32 penalty_area_width = 9;
// Radius of the center circle (measured between line centers) in mm
optional int32 center_circle_radius = 10;
// Thickness/width of the lines on the field in mm
optional int32 line_thickness = 11;
// Distance between the goal center and the center of the penalty mark in mm
optional int32 goal_center_to_penalty_mark = 12;
// Goal height in mm
optional int32 goal_height = 13;
// Ball radius in mm (note that this is a float type to represent sub-mm precision)
optional float ball_radius = 14;
// Max allowed robot radius in mm (note that this is a float type to represent sub-mm precision)
optional float max_robot_radius = 15;
}

message SSL_GeometryCameraCalibration {
required uint32 camera_id = 1;
required float focal_length = 2;
required float principal_point_x = 3;
required float principal_point_y = 4;
required float distortion = 5;
required float q0 = 6;
required float q1 = 7;
required float q2 = 8;
required float q3 = 9;
required float tx = 10;
required float ty = 11;
required float tz = 12;
optional float derived_camera_world_tx = 13;
optional float derived_camera_world_ty = 14;
optional float derived_camera_world_tz = 15;
optional uint32 pixel_image_width = 16;
optional uint32 pixel_image_height = 17;
}

// Two-Phase model for straight-kicked balls.
// There are two phases with different accelerations during the ball kicks:
// 1. Sliding
// 2. Rolling
// The full model is described in the TDP of ER-Force from 2016, which can be found here:
// https://ssl.robocup.org/wp-content/uploads/2019/01/2016_ETDP_ER-Force.pdf
message SSL_BallModelStraightTwoPhase {
// Ball sliding acceleration [m/s^2] (should be negative)
required double acc_slide = 1;
// Ball rolling acceleration [m/s^2] (should be negative)
required double acc_roll = 2;
// Fraction of the initial velocity where the ball starts to roll
required double k_switch = 3;
}

// Fixed-Loss model for chipped balls.
// Uses fixed damping factors for xy and z direction per hop.
message SSL_BallModelChipFixedLoss {
// Chip kick velocity damping factor in XY direction for the first hop
required double damping_xy_first_hop = 1;
// Chip kick velocity damping factor in XY direction for all following hops
required double damping_xy_other_hops = 2;
// Chip kick velocity damping factor in Z direction for all hops
required double damping_z = 3;
}

message SSL_GeometryModels {
optional SSL_BallModelStraightTwoPhase straight_two_phase = 1;
optional SSL_BallModelChipFixedLoss chip_fixed_loss = 2;
}

message SSL_GeometryData {
required SSL_GeometryFieldSize field = 1;
repeated SSL_GeometryCameraCalibration calib = 2;
optional SSL_GeometryModels models = 3;
}

enum SSL_FieldShapeType {
Undefined = 0;
CenterCircle = 1;
TopTouchLine = 2;
BottomTouchLine = 3;
LeftGoalLine = 4;
RightGoalLine = 5;
HalfwayLine = 6;
CenterLine = 7;
LeftPenaltyStretch = 8;
RightPenaltyStretch = 9;
LeftFieldLeftPenaltyStretch = 10;
LeftFieldRightPenaltyStretch = 11;
RightFieldLeftPenaltyStretch = 12;
RightFieldRightPenaltyStretch = 13;
}
8 changes: 8 additions & 0 deletions include/proto/wrapper.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
syntax = "proto2";
import "messages_robocup_ssl_detection.proto";
import "messages_robocup_ssl_geometry.proto";

message SSL_WrapperPacket {
optional SSL_DetectionFrame detection = 1;
optional SSL_GeometryData geometry = 2;
}
3 changes: 2 additions & 1 deletion main.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <QCommandLineParser>
#include <QCommandLineOption>
#include <QNetworkInterface>
#include <QInputDialog>

#include <src/utils/exithandler/exithandler.h>
#include <src/refereecore.h>
Expand Down Expand Up @@ -71,7 +72,7 @@ int main(int argc, char *argv[])
}
else if(parser.value(record).toLower() == "true") {
// Allocate recorder
QString logFileName = PROJECT_PATH + QString("/logs/") + Timer::getActualTime() + QString("|%1 - %2_%3").arg(constants->gameType()).arg(constants->blueTeamName()).arg(constants->yellowTeamName()) + ".log";
QString logFileName = PROJECT_PATH + QString("/logs/") + Timer::getActualTime() + QString("|%1 - %2_%3").arg(constants->gameType()).arg("Blue Team").arg("Yellow Team") + ".log";
recorder = new Recorder(logFileName, constants->visionAddress(), constants->visionPort(), constants->refereeAddress(), constants->refereePort());
}
}
Expand Down
73 changes: 60 additions & 13 deletions src/constants/constants.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,15 @@ void Constants::readVisionConstants() {

_visionPort = visionMap["visionPort"].toUInt();
std::cout << Text::purple("[CONSTANTS] ", true) << Text::bold("Loaded visionPort: " + std::to_string(_visionPort)) + '\n';

_firaVisionAddress = visionMap["firaVisionAddress"].toString();
std::cout << Text::purple("[CONSTANTS] ", true) << Text::bold("Loaded firaVisionAddress: '" + _firaVisionAddress.toStdString() + "'\n");

_firaVisionPort = visionMap["firaVisionPort"].toUInt();
std::cout << Text::purple("[CONSTANTS] ", true) << Text::bold("Loaded firaVisionPort: " + std::to_string(_firaVisionPort)) + '\n';

_isFIRAVision = visionMap["isFIRAVision"].toUInt();
std::cout << Text::purple("[CONSTANTS] ", true) << Text::bold("Loaded isFIRAVision: " + std::to_string(_isFIRAVision)) + '\n';

// Filter constants
QVariantMap filterMap = visionMap["filters"].toMap();
Expand Down Expand Up @@ -150,16 +159,21 @@ void Constants::readReplacerConstants() {
void Constants::readTeamConstants() {
// Taking team mapping in json
QVariantMap teamMap = documentMap()["Team"].toMap();
QVariantList teams = teamMap["teams"].toList();

// Filling vars
_qtPlayers = teamMap["qtPlayers"].toInt();
std::cout << Text::purple("[CONSTANTS] ", true) << Text::bold("Loaded qtPlayers: " + std::to_string(_qtPlayers)) + '\n';

_blueTeamName = teamMap["blueTeamName"].toString();
std::cout << Text::purple("[CONSTANTS] ", true) << Text::bold("Loaded blueTeamName: '" + _blueTeamName.toStdString() + "'\n");
_teams.clear();

_yellowTeamName = teamMap["yellowTeamName"].toString();
std::cout << Text::purple("[CONSTANTS] ", true) << Text::bold("Loaded yellowTeamName: '" + _yellowTeamName.toStdString() + "'\n");
foreach (const QVariant &t, teams) {
if (t.canConvert<QString>()) {
QString teamName = t.toString();
_teams.append(teamName);
std::cout << Text::purple("[CONSTANTS] ", true) << Text::bold("Loaded team: " + teamName.toStdString()) + '\n';
}
}

_blueIsLeftSide = teamMap["blueIsLeftSide"].toInt();
std::cout << Text::purple("[CONSTANTS] ", true) << Text::bold("Loaded blueIsLeftSide: " + ((_blueIsLeftSide) ? QString("true").toStdString() : QString("false").toStdString()) + '\n');
Expand Down Expand Up @@ -253,6 +267,18 @@ quint16 Constants::visionPort() {
return _visionPort;
}

QString Constants::firaVisionAddress() {
return _firaVisionAddress;
}

quint16 Constants::firaVisionPort() {
return _firaVisionPort;
}

bool Constants::isFIRAVision() {
return _isFIRAVision;
}

bool Constants::useKalman() {
return _useKalman;
}
Expand All @@ -265,6 +291,10 @@ int Constants::lossTime() {
return _lossTime;
}

QStringList Constants::teams() {
return _teams;
}

QString Constants::replacerAddress() {
return _replacerAddress;
}
Expand All @@ -285,20 +315,11 @@ int Constants::qtPlayers() {
return _qtPlayers;
}

QString Constants::blueTeamName() {
return _blueTeamName;
}

QString Constants::yellowTeamName() {
return _yellowTeamName;
}

bool Constants::blueIsLeftSide() {
return _blueIsLeftSide;
}

void Constants::swapSides() {
std::swap(_blueTeamName, _yellowTeamName);
_blueIsLeftSide = !_blueIsLeftSide;
}

Expand All @@ -309,3 +330,29 @@ QString Constants::getHID() {
QString Constants::getHToken() {
return _hToken;
}



int Constants::varsPerTeam() {
QString varsPerTeam = _documentMap["Referee"].toMap()["game"].toMap()["varPerTeam"].toString();
bool converted = false;
int varsPerTeamInt = varsPerTeam.toInt(&converted);

return varsPerTeamInt;
}

int Constants::timeoutsPerTeam() {
QString timeoutsPerTeam = _documentMap["Referee"].toMap()["game"].toMap()["timeoutsPerTeam"].toString();
bool converted = false;
int timeoutsPerTeamInt = timeoutsPerTeam.toInt(&converted);

return timeoutsPerTeamInt;
}

float Constants::timeoutLength() {
QString timeoutLength = _documentMap["Referee"].toMap()["game"].toMap()["timeoutLength"].toString();
bool converted = false;
float timeoutLengthFloat = timeoutLength.toFloat(&converted);

return timeoutLengthFloat;
}
Loading