16template <
int Rows,
int Cols,
int Options,
int MaxRows,
int MaxCols>
25 static std::optional<frc::Matrixd<Rows, Cols, Options, MaxRows, MaxCols>>
27 constexpr bool isSmall = Rows * Cols *
sizeof(double) < 256;
29 std::conditional_t<isSmall, wpi::UnpackCallback<double, Rows * Cols>,
32 data.
Vec().reserve(Rows * Cols);
35 msg.
data = data.Callback();
44 auto items = data.Items();
46 if (items.size() != Rows * Cols) {
51 for (
int i = 0; i < Rows * Cols; i++) {
61 std::span<const double> dataSpan{value.data(),
62 static_cast<size_t>(Rows * Cols)};
67 .data = data.Callback(),
A callback method that will pack elements when called.
Definition ProtobufCallbacks.h:486
Class for wrapping a nanopb ostream.
Definition Protobuf.h:119
bool Encode(const typename Protobuf< std::remove_cvref_t< T > >::MessageStruct &msg)
Decodes a protobuf.
Definition Protobuf.h:211
A DirectUnpackCallback backed by a std::vector.
Definition ProtobufCallbacks.h:381
std::vector< T > & Vec() noexcept
Gets a reference to the backing vector.
Definition ProtobufCallbacks.h:410
Eigen::Matrix< double, Rows, Cols, Options, MaxRows, MaxCols > Matrixd
Definition EigenCore.h:21
Definition wpimath.npb.h:18
uint32_t num_rows
Definition wpimath.npb.h:23
pb_callback_t data
Definition wpimath.npb.h:25
uint32_t num_cols
Definition wpimath.npb.h:24
static std::optional< frc::Matrixd< Rows, Cols, Options, MaxRows, MaxCols > > Unpack(InputStream &stream)
Definition MatrixProto.h:26
static bool Pack(OutputStream &stream, const frc::Matrixd< Rows, Cols, Options, MaxRows, MaxCols > &value)
Definition MatrixProto.h:58
Protobuf serialization template.
Definition Protobuf.h:36
struct _wpi_proto_ProtobufMatrix wpi_proto_ProtobufMatrix