Commit d829935d authored by NicolaiO's avatar NicolaiO 🐼 Committed by TIGERs GitLab
Browse files

[#1470] Add wrapper frame around tracked frame

Closes #1470

See merge request main/Sumatra!1207

sumatra-commit: 7125a1d45fbfece1e1db7bda950bd99fa5852728
parent 2531d083
Pipeline #7386 passed with stage
in 1 minute and 35 seconds
......@@ -7,11 +7,13 @@ package edu.tigers.sumatra.wp.exporter;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;
import edu.tigers.moduli.AModule;
import edu.tigers.sumatra.MessagesRobocupSslDetectionTracked;
import edu.tigers.sumatra.MessagesRobocupSslDetectionTracked.TrackedFrame;
import edu.tigers.sumatra.MessagesRobocupSslWrapperTracked.TrackerWrapperPacket;
import edu.tigers.sumatra.cam.SSLVisionCam;
import edu.tigers.sumatra.cam.TimeSync;
import edu.tigers.sumatra.ids.BotID;
......@@ -35,6 +37,7 @@ import edu.tigers.sumatra.wp.data.WorldFrameWrapper;
*/
public class VisionTrackerSender extends AModule implements IWorldFrameObserver
{
private static final String SOURCE_NAME = "TIGERs";
private static final Set<MessagesRobocupSslDetectionTracked.Capability> CAPABILITIES = new HashSet<>();
static
......@@ -46,6 +49,7 @@ public class VisionTrackerSender extends AModule implements IWorldFrameObserver
private MulticastUDPTransmitter transmitter;
private int frameNumber = 0;
private TimeSync timeSync;
private String uuid = "";
@Override
public void startModule()
......@@ -54,6 +58,8 @@ public class VisionTrackerSender extends AModule implements IWorldFrameObserver
int port = getSubnodeConfiguration().getInt("port", 10010);
transmitter = new MulticastUDPTransmitter(address, port);
uuid = UUID.randomUUID().toString();
SumatraModel.getInstance().getModule(AWorldPredictor.class).addObserver(this);
timeSync = SumatraModel.getInstance().getModuleOpt(SSLVisionCam.class).map(SSLVisionCam::getTimeSync)
.orElseGet(TimeSync::new);
......@@ -80,7 +86,11 @@ public class VisionTrackerSender extends AModule implements IWorldFrameObserver
.map(s -> buildKickEvent(wfw.getSimpleWorldFrame(), s))
.ifPresent(frame::setKickedBall);
frame.addAllCapabilities(CAPABILITIES);
transmitter.send(frame.build().toByteArray());
TrackerWrapperPacket.Builder wrapper = TrackerWrapperPacket.newBuilder();
wrapper.setUuid(uuid);
wrapper.setSourceName(SOURCE_NAME);
wrapper.setTrackedFrame(frame);
transmitter.send(wrapper.build().toByteArray());
}
......
syntax = "proto2";
import "messages_robocup_ssl_detection_tracked.proto";
package edu.tigers.sumatra;
// A wrapper packet containing meta data of the source
// Also serves for the possibility to extend the protocol later
message TrackerWrapperPacket {
// A random UUID of the source that is kept constant at the source while running
// If multiple sources are broadcasting to the same network, this id can be used to identify individual sources
required string uuid = 1;
// The name of the source software that is producing this messages.
optional string source_name = 2;
// The tracked frame
optional TrackedFrame tracked_frame = 3;
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment