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

feat(Protobuf): creates protobuf packets, protobuf files generator and paths include in cmake, receiver code for tests, #27

Merged
merged 34 commits into from
Feb 24, 2023
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
4e76827
added protobuf v0
bmmuc Feb 4, 2023
6a5ccf4
fix: undefined reference
ersaraujo Feb 8, 2023
d44985e
wip
ersaraujo Feb 8, 2023
f38c2a5
fix: add Protobuf package on CMakeLists.txt
joseviccruz Feb 8, 2023
a5c9d79
feat(protobuf): created protobuf packet
ersaraujo Feb 15, 2023
206bd48
fix (protobuf): fix cm to mm
bmmuc Feb 15, 2023
311b7d3
Merge branch 'change-origin' into add_protobuf
bmmuc Feb 15, 2023
494e167
fix field packet
ersaraujo Feb 17, 2023
5f8e3dc
fix entities vector
ersaraujo Feb 17, 2023
1ebbc67
wip
ersaraujo Feb 19, 2023
19232eb
Fix protobuf generation
joseviccruz Feb 19, 2023
f375a92
fix entities
ersaraujo Feb 19, 2023
9cc053b
removed unnecessary prints and comments
ersaraujo Feb 20, 2023
1f7c46c
Update docker_run
ersaraujo Feb 22, 2023
3287eb4
adjust server.h
ersaraujo Feb 22, 2023
6109ba2
fix(server): fix team check
ersaraujo Feb 22, 2023
9434c98
added dependecies
ersaraujo Feb 22, 2023
502dd56
added args for cam
ersaraujo Feb 22, 2023
f6fc0cb
removes changes
ersaraujo Feb 22, 2023
72e61a4
Update src/Network/visionServer/server.h
ersaraujo Feb 22, 2023
7034fae
removes unnecessary files
ersaraujo Feb 22, 2023
0fb4a21
include protobuf generation
ersaraujo Feb 22, 2023
1b2eb38
Update src/Network/visionServer/server.cpp
ersaraujo Feb 22, 2023
eb4f8d8
fixed devconatiner
ersaraujo Feb 22, 2023
1f2a4cc
adding .cache in gitignore
ersaraujo Feb 22, 2023
ee8c9bc
Merge branch 'add_protobuf' of github.com:robocin/vss-vision into add…
ersaraujo Feb 22, 2023
f1e90b6
Update multicast ip
ersaraujo Feb 22, 2023
49d5b86
update dependencies
ersaraujo Feb 22, 2023
5b54a21
add cmake extension to devcontainer
FelipeMartins96 Feb 16, 2023
2b941e7
remove useless and buggy position processing
FelipeMartins96 Feb 16, 2023
d2c7863
remove bug for findEnemies which was removed on previous commit
FelipeMartins96 Feb 16, 2023
38750f5
update missed origin translation conversion values
FelipeMartins96 Feb 16, 2023
4edfb9a
wip
bmmuc Feb 22, 2023
41c76e8
Update client/python/receiver.py
ersaraujo Feb 23, 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
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ RUN if [ "${REINSTALL_CMAKE_VERSION_FROM_SOURCE}" != "none" ]; then \

# [Optional] Uncomment this section to install additional packages.
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends qt5-default libsfml-dev libopencv-dev freeglut3-dev
&& apt-get -y install --no-install-recommends qt5-default libsfml-dev libopencv-dev freeglut3-dev protobuf-compiler libprotobuf-dev
ersaraujo marked this conversation as resolved.
Show resolved Hide resolved
1 change: 1 addition & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
},

"runArgs": [
"--device=/dev/video1:/dev/video0",
ersaraujo marked this conversation as resolved.
Show resolved Hide resolved
"-e", "DISPLAY=${env:DISPLAY}",
"-v", "/tmp/.X11-unix:/tmp/.X11-unix",
"--network=host"
Expand Down
31 changes: 22 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(EXECUTABLE_OUTPUT_PATH "${PROJECT_SOURCE_DIR}/src")


set(SOURCES
src/main.cpp
src/Utils/Utils.cpp
Expand Down Expand Up @@ -48,6 +47,7 @@ set(SOURCES
src/Windows/RobotWidget.cpp
src/trackconfigdialog.cpp
src/Network/Network.cpp
src/Network/visionServer/server.cpp
)

set(HEADERS
Expand Down Expand Up @@ -90,26 +90,39 @@ set(HEADERS
src/trackconfigdialog.h
src/Windows/FileConstants.h
src/Network/Network.h
src/Network/visionServer/server.h
)

set(RESOURCES
src/image.qrc
src/iconTools/icontools.qrc
)

add_executable(VSS-VISION ${SOURCES} ${HEADERS} ${RESOURCES})
set(PROTOS
src/Network/protobuf/proto/messages_robocup_ssl_detection.proto
src/Network/protobuf/proto/messages_robocup_ssl_geometry.proto
src/Network/protobuf/proto/wrapper.proto
)

find_package(Protobuf REQUIRED)
protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS ${PROTOS})

target_include_directories(VSS-VISION PUBLIC "${PROJECT_SOURCE_DIR}/src")
target_include_directories(VSS-VISION PUBLIC "${PROJECT_SOURCE_DIR}/include")
add_executable(${PROJECT_NAME} ${SOURCES} ${HEADERS} ${RESOURCES} ${PROTO_SRCS} ${PROTO_HDRS})

find_package(Qt5 REQUIRED COMPONENTS Core Widgets Gui)
target_link_libraries(VSS-VISION Qt5::Core Qt5::Widgets Qt5::Gui)
target_include_directories(${PROJECT_NAME} PUBLIC "${PROJECT_SOURCE_DIR}/src")
target_include_directories(${PROJECT_NAME} PUBLIC "${PROJECT_SOURCE_DIR}/include")
target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_BINARY_DIR})

find_package(Qt5 REQUIRED COMPONENTS Core Widgets Gui Network)
target_link_libraries(${PROJECT_NAME} Qt5::Core Qt5::Widgets Qt5::Gui Qt5::Network)

find_package(OpenCV REQUIRED)
target_link_libraries(VSS-VISION ${OpenCV_LIBS})
target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBS})

find_package(TBB REQUIRED)
target_link_libraries(VSS-VISION TBB::tbb)
target_link_libraries(${PROJECT_NAME} TBB::tbb)

find_package(SFML REQUIRED COMPONENTS network system)
target_link_libraries(VSS-VISION sfml-network sfml-system)
target_link_libraries(${PROJECT_NAME} sfml-network sfml-system)

target_link_libraries(${PROJECT_NAME} ${Protobuf_LIBRARIES})
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
libsfml-dev \
libopencv-dev \
freeglut3-dev \
protobuf-compiler \
libprotobuf-dev \
ersaraujo marked this conversation as resolved.
Show resolved Hide resolved
cmake

COPY . /opt/vss-vision

WORKDIR /opt/vss-vision/build

RUN cmake clean .. && make -j4
RUN cmake clean .. -Wno-dev && make -j4

WORKDIR /opt/vss-vision/src

Expand Down
57 changes: 57 additions & 0 deletions client/python/receiver.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import socket
import struct
from time import time
import wrapper_pb2 as wr

class FiraClient:

def __init__(self,
vision_ip="127.0.0.1",
ersaraujo marked this conversation as resolved.
Show resolved Hide resolved
vision_port=10015):
"""
Init SSLClient object.
Extended description of function.
Parameters
----------
vision_ip : str
Multicast Vision IP in format '255.255.255.255'.
vision_port : int
Vision Port up to 1024.
"""

self.vision_ip = vision_ip
self.vision_port = vision_port

self.vision_sock = socket.socket(
socket.AF_INET, socket.SOCK_DGRAM)
self.vision_sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
self.vision_sock.setsockopt(socket.IPPROTO_IP,
socket.IP_MULTICAST_TTL, 128)
self.vision_sock.setsockopt(socket.IPPROTO_IP,
socket.IP_MULTICAST_LOOP, 1)
self.vision_sock.bind((self.vision_ip, self.vision_port))

# self.vision_sock.setblocking(True)
self.frame = None
self.det_frame = None

def receive_frame(self):
"""Receive package and decode."""
data = None
while True:
try:
data, _ = self.vision_sock.recvfrom(1024)
except Exception as e:
print(e)
if data != None:
break

if data != None:
decoded_data = wr.SSL_WrapperPacket().FromString(data)
print(decoded_data)
# return self.frame, self.det_frame

a = FiraClient()
while(1):
a.receive_frame()

1 change: 1 addition & 0 deletions src/Entity/Entity.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ typedef Entity Player;
typedef Player Ally;
typedef Player Enemy;


using Entities = Vector<Entity>;
using Players = Vector<Player>;

Expand Down
32 changes: 32 additions & 0 deletions src/Network/protobuf/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 src/Network/protobuf/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 src/Network/protobuf/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;
}
Loading