Skip to content

Commit

Permalink
Merge pull request #27 from robocin/add_protobuf
Browse files Browse the repository at this point in the history
feat(Protobuf): creates protobuf packets, protobuf files generator and paths include in cmake, receiver code for tests,
  • Loading branch information
ersaraujo authored Feb 24, 2023
2 parents eeb3c88 + 41c76e8 commit 53d4c75
Show file tree
Hide file tree
Showing 20 changed files with 154,035 additions and 153,648 deletions.
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
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:/dev/video0",
"-e", "DISPLAY=${env:DISPLAY}",
"-v", "/tmp/.X11-unix:/tmp/.X11-unix",
"--network=host"
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ src/Utils/dest.txt
build/
bin/
*avi
.cache/

#All logging files (including rotative)
src/Log/*
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 \
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
6 changes: 5 additions & 1 deletion InstallDependencies
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,8 @@ sudo apt install libopencv-dev -y
sudo apt install freeglut3-dev -y

# Install QT5
sudo apt install qt5-default -y
sudo apt install qt5-default -y

# Intall Protobuf
sudo apt install libprotobuf -y
sudo apt install protobuf-compiler -y
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Qt5
OpenCV
SFML
TBB
Protobuf
```
## Running with docker
1. Build the vss-vision image using the shell script
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="224.5.23.2",
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()

9 changes: 1 addition & 8 deletions docker_run
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,6 @@ then
else
echo "setting camera /dev/video$1"
# Camera id argument supplied
docker run \
--rm \
--device=/dev/video$1:/dev/video0 \ # Mount camera device
-v vss-vision-config:/opt/vss-vision/src/Config \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-e DISPLAY=$DISPLAY \
--network=host \
vss-vision
docker run --rm --device=/dev/video$1:/dev/video0 -v vss-vision-config:/opt/vss-vision/src/Config -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=$DISPLAY --network=host vss-vision
fi
xhost -
Loading

0 comments on commit 53d4c75

Please sign in to comment.