Skip to content
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
7 changes: 7 additions & 0 deletions cpp/bindings/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,13 @@ inline void make_types(nb::module_& m) {
"List of points in the "
"point cloud. Note, this is always in row major format."
)
.def_static(
"from_vec_positions",
&LidarMeasurement::from_vec_positions,
"stamp"_a,
"positions"_a,
"Construct a LidarMeasurement from a stamp and a (n,3) numpy array."
)
.def(
"to_vec_positions",
&LidarMeasurement::to_vec_positions,
Expand Down
10 changes: 10 additions & 0 deletions cpp/evalio/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,16 @@ struct LidarMeasurement {
return oss.str();
}

static LidarMeasurement
from_vec_positions(Stamp stamp, const Eigen::MatrixX3d& positions) {
std::vector<Point> pts;
pts.reserve(positions.rows());
for (const auto& p : positions.rowwise()) {
pts.push_back(Point {.x = p.x(), .y = p.y(), .z = p.z()});
}
return LidarMeasurement(stamp, pts);
}

std::vector<Eigen::Vector3d> to_vec_positions() const {
std::vector<Eigen::Vector3d> eigen_points;
eigen_points.reserve(points.size());
Expand Down
Loading