Convert aos over to flatbuffers
Everything builds, and all the tests pass. I suspect that some entries
are missing from the config files, but those will be found pretty
quickly on startup.
There is no logging or live introspection of queue messages.
Change-Id: I496ee01ed68f202c7851bed7e8786cee30df29f5
diff --git a/aos/vision/blob/BUILD b/aos/vision/blob/BUILD
index 7d5f930..e025ed3 100644
--- a/aos/vision/blob/BUILD
+++ b/aos/vision/blob/BUILD
@@ -11,7 +11,7 @@
"//aos/vision/image:image_types",
"//aos/vision/math:segment",
"//aos/vision/math:vector",
- "//third_party/eigen",
+ "@org_tuxfamily_eigen//:eigen",
],
)
@@ -72,7 +72,7 @@
":contour",
":disjoint_set",
":range_image",
- "//third_party/eigen",
+ "@org_tuxfamily_eigen//:eigen",
],
)
@@ -90,7 +90,7 @@
":range_image",
"//aos/vision/debug:overlay",
"//aos/vision/math:segment",
- "//third_party/eigen",
+ "@org_tuxfamily_eigen//:eigen",
],
)
@@ -102,7 +102,7 @@
":range_image",
"//aos/vision/debug:overlay",
"//aos/vision/math:segment",
- "//third_party/eigen",
+ "@org_tuxfamily_eigen//:eigen",
],
)
diff --git a/aos/vision/blob/threshold.h b/aos/vision/blob/threshold.h
index 8251b3a..f126b14 100644
--- a/aos/vision/blob/threshold.h
+++ b/aos/vision/blob/threshold.h
@@ -1,6 +1,7 @@
#ifndef AOS_VISION_BLOB_THRESHOLD_H_
#define AOS_VISION_BLOB_THRESHOLD_H_
+#include <array>
#include <condition_variable>
#include <mutex>
#include <thread>
diff --git a/aos/vision/blob/threshold_test.cc b/aos/vision/blob/threshold_test.cc
index 108da35..3bbef1d 100644
--- a/aos/vision/blob/threshold_test.cc
+++ b/aos/vision/blob/threshold_test.cc
@@ -49,84 +49,84 @@
std::vector<char> image;
image.resize(8 * 8 * 2);
// --+-----
- image[0 * 2 + 0 * 16] = 0;
- image[1 * 2 + 0 * 16] = 0;
- image[2 * 2 + 0 * 16] = 128;
- image[3 * 2 + 0 * 16] = 127;
- image[4 * 2 + 0 * 16] = 0;
- image[5 * 2 + 0 * 16] = 0;
- image[6 * 2 + 0 * 16] = 0;
- image[7 * 2 + 0 * 16] = 0;
+ image[0 * 2 + 0 * 16] = static_cast<char>(0);
+ image[1 * 2 + 0 * 16] = static_cast<char>(0);
+ image[2 * 2 + 0 * 16] = static_cast<char>(128);
+ image[3 * 2 + 0 * 16] = static_cast<char>(127);
+ image[4 * 2 + 0 * 16] = static_cast<char>(0);
+ image[5 * 2 + 0 * 16] = static_cast<char>(0);
+ image[6 * 2 + 0 * 16] = static_cast<char>(0);
+ image[7 * 2 + 0 * 16] = static_cast<char>(0);
expected_ranges.push_back({{{2, 3}}});
// +------+
- image[0 * 2 + 1 * 16] = 128;
- image[1 * 2 + 1 * 16] = 0;
- image[2 * 2 + 1 * 16] = 0;
- image[3 * 2 + 1 * 16] = 10;
- image[4 * 2 + 1 * 16] = 30;
- image[5 * 2 + 1 * 16] = 50;
- image[6 * 2 + 1 * 16] = 70;
- image[7 * 2 + 1 * 16] = 255;
+ image[0 * 2 + 1 * 16] = static_cast<char>(128);
+ image[1 * 2 + 1 * 16] = static_cast<char>(0);
+ image[2 * 2 + 1 * 16] = static_cast<char>(0);
+ image[3 * 2 + 1 * 16] = static_cast<char>(10);
+ image[4 * 2 + 1 * 16] = static_cast<char>(30);
+ image[5 * 2 + 1 * 16] = static_cast<char>(50);
+ image[6 * 2 + 1 * 16] = static_cast<char>(70);
+ image[7 * 2 + 1 * 16] = static_cast<char>(255);
expected_ranges.push_back({{{0, 1}, {7, 8}}});
// -++++++-
- image[0 * 2 + 2 * 16] = 73;
- image[1 * 2 + 2 * 16] = 246;
- image[2 * 2 + 2 * 16] = 247;
- image[3 * 2 + 2 * 16] = 248;
- image[4 * 2 + 2 * 16] = 249;
- image[5 * 2 + 2 * 16] = 250;
- image[6 * 2 + 2 * 16] = 250;
- image[7 * 2 + 2 * 16] = 45;
+ image[0 * 2 + 2 * 16] = static_cast<char>(73);
+ image[1 * 2 + 2 * 16] = static_cast<char>(246);
+ image[2 * 2 + 2 * 16] = static_cast<char>(247);
+ image[3 * 2 + 2 * 16] = static_cast<char>(248);
+ image[4 * 2 + 2 * 16] = static_cast<char>(249);
+ image[5 * 2 + 2 * 16] = static_cast<char>(250);
+ image[6 * 2 + 2 * 16] = static_cast<char>(250);
+ image[7 * 2 + 2 * 16] = static_cast<char>(45);
expected_ranges.push_back({{{1, 7}}});
// +++-++++
- image[0 * 2 + 3 * 16] = 128;
- image[1 * 2 + 3 * 16] = 134;
- image[2 * 2 + 3 * 16] = 250;
- image[3 * 2 + 3 * 16] = 0;
- image[4 * 2 + 3 * 16] = 230;
- image[5 * 2 + 3 * 16] = 230;
- image[6 * 2 + 3 * 16] = 230;
- image[7 * 2 + 3 * 16] = 210;
+ image[0 * 2 + 3 * 16] = static_cast<char>(128);
+ image[1 * 2 + 3 * 16] = static_cast<char>(134);
+ image[2 * 2 + 3 * 16] = static_cast<char>(250);
+ image[3 * 2 + 3 * 16] = static_cast<char>(0);
+ image[4 * 2 + 3 * 16] = static_cast<char>(230);
+ image[5 * 2 + 3 * 16] = static_cast<char>(230);
+ image[6 * 2 + 3 * 16] = static_cast<char>(230);
+ image[7 * 2 + 3 * 16] = static_cast<char>(210);
expected_ranges.push_back({{{0, 3}, {4, 8}}});
// --------
- image[0 * 2 + 4 * 16] = 7;
- image[1 * 2 + 4 * 16] = 120;
- image[2 * 2 + 4 * 16] = 127;
- image[3 * 2 + 4 * 16] = 0;
- image[4 * 2 + 4 * 16] = 50;
- image[5 * 2 + 4 * 16] = 80;
- image[6 * 2 + 4 * 16] = 110;
- image[7 * 2 + 4 * 16] = 25;
+ image[0 * 2 + 4 * 16] = static_cast<char>(7);
+ image[1 * 2 + 4 * 16] = static_cast<char>(120);
+ image[2 * 2 + 4 * 16] = static_cast<char>(127);
+ image[3 * 2 + 4 * 16] = static_cast<char>(0);
+ image[4 * 2 + 4 * 16] = static_cast<char>(50);
+ image[5 * 2 + 4 * 16] = static_cast<char>(80);
+ image[6 * 2 + 4 * 16] = static_cast<char>(110);
+ image[7 * 2 + 4 * 16] = static_cast<char>(25);
expected_ranges.push_back({{}});
// ++++-+++
- image[0 * 2 + 5 * 16] = 140;
- image[1 * 2 + 5 * 16] = 140;
- image[2 * 2 + 5 * 16] = 140;
- image[3 * 2 + 5 * 16] = 140;
- image[4 * 2 + 5 * 16] = 0;
- image[5 * 2 + 5 * 16] = 140;
- image[6 * 2 + 5 * 16] = 140;
- image[7 * 2 + 5 * 16] = 140;
+ image[0 * 2 + 5 * 16] = static_cast<char>(140);
+ image[1 * 2 + 5 * 16] = static_cast<char>(140);
+ image[2 * 2 + 5 * 16] = static_cast<char>(140);
+ image[3 * 2 + 5 * 16] = static_cast<char>(140);
+ image[4 * 2 + 5 * 16] = static_cast<char>(0);
+ image[5 * 2 + 5 * 16] = static_cast<char>(140);
+ image[6 * 2 + 5 * 16] = static_cast<char>(140);
+ image[7 * 2 + 5 * 16] = static_cast<char>(140);
expected_ranges.push_back({{{0, 4}, {5, 8}}});
// ++++++++
- image[0 * 2 + 6 * 16] = 128;
- image[1 * 2 + 6 * 16] = 128;
- image[2 * 2 + 6 * 16] = 128;
- image[3 * 2 + 6 * 16] = 128;
- image[4 * 2 + 6 * 16] = 128;
- image[5 * 2 + 6 * 16] = 128;
- image[6 * 2 + 6 * 16] = 128;
- image[7 * 2 + 6 * 16] = 128;
+ image[0 * 2 + 6 * 16] = static_cast<char>(128);
+ image[1 * 2 + 6 * 16] = static_cast<char>(128);
+ image[2 * 2 + 6 * 16] = static_cast<char>(128);
+ image[3 * 2 + 6 * 16] = static_cast<char>(128);
+ image[4 * 2 + 6 * 16] = static_cast<char>(128);
+ image[5 * 2 + 6 * 16] = static_cast<char>(128);
+ image[6 * 2 + 6 * 16] = static_cast<char>(128);
+ image[7 * 2 + 6 * 16] = static_cast<char>(128);
expected_ranges.push_back({{{0, 8}}});
// +-+-+--+
- image[0 * 2 + 7 * 16] = 200;
- image[1 * 2 + 7 * 16] = 0;
- image[2 * 2 + 7 * 16] = 200;
- image[3 * 2 + 7 * 16] = 0;
- image[4 * 2 + 7 * 16] = 200;
- image[5 * 2 + 7 * 16] = 0;
- image[6 * 2 + 7 * 16] = 0;
- image[7 * 2 + 7 * 16] = 200;
+ image[0 * 2 + 7 * 16] = static_cast<char>(200);
+ image[1 * 2 + 7 * 16] = static_cast<char>(0);
+ image[2 * 2 + 7 * 16] = static_cast<char>(200);
+ image[3 * 2 + 7 * 16] = static_cast<char>(0);
+ image[4 * 2 + 7 * 16] = static_cast<char>(200);
+ image[5 * 2 + 7 * 16] = static_cast<char>(0);
+ image[6 * 2 + 7 * 16] = static_cast<char>(0);
+ image[7 * 2 + 7 * 16] = static_cast<char>(200);
expected_ranges.push_back({{{0, 1}, {2, 3}, {4, 5}, {7, 8}}});
const RangeImage expected_result(0, std::move(expected_ranges));
diff --git a/aos/vision/events/BUILD b/aos/vision/events/BUILD
index b887872..a991968 100644
--- a/aos/vision/events/BUILD
+++ b/aos/vision/events/BUILD
@@ -52,6 +52,7 @@
deps = [
"//aos:macros",
"//aos/scoped:scoped_fd",
+ "@com_github_google_glog//:glog",
],
)
diff --git a/aos/vision/events/udp.cc b/aos/vision/events/udp.cc
index 8734443..7ac72e8 100644
--- a/aos/vision/events/udp.cc
+++ b/aos/vision/events/udp.cc
@@ -2,23 +2,23 @@
#include <string.h>
-#include "aos/logging/logging.h"
+#include "glog/logging.h"
namespace aos {
namespace events {
TXUdpSocket::TXUdpSocket(const std::string &ip_addr, int port)
- : fd_(AOS_PCHECK(socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP))) {
+ : fd_(socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) {
+ PCHECK(fd_.get() != -1);
sockaddr_in destination_in;
memset(&destination_in, 0, sizeof(destination_in));
destination_in.sin_family = AF_INET;
destination_in.sin_port = htons(port);
- if (inet_aton(ip_addr.c_str(), &destination_in.sin_addr) == 0) {
- AOS_LOG(FATAL, "invalid IP address %s\n", ip_addr.c_str());
- }
+ CHECK(inet_aton(ip_addr.c_str(), &destination_in.sin_addr) != 0)
+ << ": invalid IP address " << ip_addr;
- AOS_PCHECK(connect(fd_.get(), reinterpret_cast<sockaddr *>(&destination_in),
- sizeof(destination_in)));
+ PCHECK(connect(fd_.get(), reinterpret_cast<sockaddr *>(&destination_in),
+ sizeof(destination_in)) == 0);
}
int TXUdpSocket::Send(const char *data, int size) {
@@ -27,7 +27,8 @@
}
int RXUdpSocket::SocketBindListenOnPort(int port) {
- int fd = AOS_PCHECK(socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP));
+ int fd;
+ PCHECK((fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) != -1);
sockaddr_in bind_address;
memset(&bind_address, 0, sizeof(bind_address));
@@ -35,15 +36,17 @@
bind_address.sin_port = htons(port);
bind_address.sin_addr.s_addr = htonl(INADDR_ANY);
- AOS_PCHECK(bind(fd, reinterpret_cast<sockaddr *>(&bind_address),
- sizeof(bind_address)));
+ PCHECK(bind(fd, reinterpret_cast<sockaddr *>(&bind_address),
+ sizeof(bind_address)) == 0);
return fd;
}
RXUdpSocket::RXUdpSocket(int port) : fd_(SocketBindListenOnPort(port)) {}
int RXUdpSocket::Recv(void *data, int size) {
- return AOS_PCHECK(recv(fd_.get(), static_cast<char *>(data), size, 0));
+ int result;
+ PCHECK((result = recv(fd_.get(), static_cast<char *>(data), size, 0)) != -1);
+ return result;
}
} // namespace events
diff --git a/aos/vision/image/BUILD b/aos/vision/image/BUILD
index 21dbbb8..9b6d30a 100644
--- a/aos/vision/image/BUILD
+++ b/aos/vision/image/BUILD
@@ -5,6 +5,9 @@
cc_library(
name = "image_types",
hdrs = ["image_types.h"],
+ deps = [
+ "@com_google_absl//absl/strings",
+ ],
)
cc_proto_library(
diff --git a/aos/vision/image/image_dataset.cc b/aos/vision/image/image_dataset.cc
index d4dde95..33bf0e4 100644
--- a/aos/vision/image/image_dataset.cc
+++ b/aos/vision/image/image_dataset.cc
@@ -37,10 +37,10 @@
res.reserve(pos.size() + 1);
i = 0;
for (auto p : pos) {
- res.emplace_back(inp.substr(i, p - i).to_string());
+ res.emplace_back(std::string(inp.substr(i, p - i)));
i = p + 1;
}
- res.emplace_back(inp.substr(i).to_string());
+ res.emplace_back(std::string(inp.substr(i)));
return res;
}
} // namespace
diff --git a/aos/vision/image/image_types.h b/aos/vision/image/image_types.h
index a620d8a..aff7056 100644
--- a/aos/vision/image/image_types.h
+++ b/aos/vision/image/image_types.h
@@ -6,7 +6,7 @@
#include <memory>
#include <sstream>
-#include <experimental/string_view>
+#include "absl/strings/string_view.h"
namespace aos {
namespace vision {
@@ -20,7 +20,7 @@
};
// This will go into c++17. No sense writing my own version.
-using DataRef = std::experimental::string_view;
+using DataRef = absl::string_view;
// Represents the dimensions of an image.
struct ImageFormat {
diff --git a/aos/vision/math/BUILD b/aos/vision/math/BUILD
index 0fbdf7a..2c71e8f 100644
--- a/aos/vision/math/BUILD
+++ b/aos/vision/math/BUILD
@@ -12,8 +12,7 @@
"vector.h",
],
deps = [
- "//third_party/eigen",
- "@com_google_ceres_solver//:ceres",
+ "@org_tuxfamily_eigen//:eigen",
],
)