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

Fix sending zeroes? #48

Merged
merged 7 commits into from
Nov 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
26 changes: 26 additions & 0 deletions app/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,32 @@ <h2>Pose Data:</h2>
document.getElementById('brightness').disabled = true;

function formatPoseData(data) {

if (data.EMPTY == "true"){
let toReturn = '';
toReturn += `
<div class="tag-detection">
<div class="tag-detection-header">
<div class="tag-info">
<h3>No Tag Found</h3>
<p>No Tag Found</p>
<p>No Tag Found</p>
</div>
<div class="rotation-matrix">
<h4>Rotation Matrix:</h4>
<div class="pose-matrix">
No Tag Found
</div>
</div>
</div>
<h4>Translation Vector:</h4>
<div class="translation-vector">
No Tag Found
</div>
</div>
`;
return toReturn;
}
let html = '';
data.detections.forEach(detection => {
html += `
Expand Down
19 changes: 10 additions & 9 deletions src/ws_server.cu
Original file line number Diff line number Diff line change
Expand Up @@ -321,10 +321,14 @@ class AprilTagHandler : public seasocks::WebSocket::Handler {
broadcastImage(buffer);
frame_counter = 0;
}

std::vector<double> networktables_pose_data = {};
json empty_detections_record;
std::string pose_json = "";
empty_detections_record["type"] = "pose_data";
empty_detections_record["EMPTY"] = "true";
pose_json = empty_detections_record.dump();
// Determine the pose of the tags.
if (zarray_size(detections) > 0) {
std::vector<double> networktables_pose_data = {};
// std::vector<std::vector<double>> poses = {};
json detections_record;
detections_record["type"] = "pose_data";
Expand Down Expand Up @@ -367,9 +371,7 @@ class AprilTagHandler : public seasocks::WebSocket::Handler {
}

// Send the pose data
std::string pose_json = detections_record.dump();
broadcastPoseData(pose_json);
tagSender_.sendValue(networktables_pose_data);
pose_json = detections_record.dump();

auto overallend = std::chrono::high_resolution_clock::now();
auto overallduration =
Expand All @@ -387,11 +389,10 @@ class AprilTagHandler : public seasocks::WebSocket::Handler {
<< std::endl;

detector.ReinitializeDetections();
} else {
// no tag, so send empty data.
std::vector<double> networktables_pose_data = {};
tagSender_.sendValue(networktables_pose_data);
}
broadcastPoseData(pose_json);
tagSender_.sendValue(networktables_pose_data);

} catch (const std::exception& ex) {
std::cout << "Encounted exception " << ex.what() << std::endl;
std::cout << "Continuing." << std::endl;
Expand Down
Loading