Skip to content

Commit

Permalink
Transform the internal LiDAR odometry map to lidar frame
Browse files Browse the repository at this point in the history
I honestly do not know why this is not working, but we can see in the
future. It's just to save so computation in the ROS node
  • Loading branch information
nachovizzo committed Jul 23, 2024
1 parent d903451 commit aeb1cf4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
16 changes: 7 additions & 9 deletions ros/src/OdometryServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,15 +194,13 @@ void OdometryServer::PublishOdometry(const Sophus::SE3d &kiss_pose,

void OdometryServer::PublishClouds(const std::vector<Eigen::Vector3d> frame,
const std::vector<Eigen::Vector3d> keypoints,
const std_msgs::msg::Header &lidar_header) {
// The internal map representation is in the lidar_odom_frame_
std_msgs::msg::Header map_header;
map_header.frame_id = lidar_odom_frame_;
map_header.stamp = lidar_header.stamp;

frame_publisher_->publish(std::move(EigenToPointCloud2(frame, lidar_header)));
kpoints_publisher_->publish(std::move(EigenToPointCloud2(keypoints, lidar_header)));
map_publisher_->publish(std::move(EigenToPointCloud2(kiss_icp_->LocalMap(), map_header)));
const std_msgs::msg::Header &header) {
const auto kiss_map = kiss_icp_->LocalMap();
const auto kiss_pose = kiss_icp_->pose().inverse();

frame_publisher_->publish(std::move(EigenToPointCloud2(frame, header)));
kpoints_publisher_->publish(std::move(EigenToPointCloud2(keypoints, header)));
map_publisher_->publish(std::move(EigenToPointCloud2(kiss_map, kiss_pose, header)));
}
} // namespace kiss_icp_ros

Expand Down
10 changes: 10 additions & 0 deletions ros/src/Utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,16 @@ inline std::unique_ptr<PointCloud2> EigenToPointCloud2(const std::vector<Eigen::
return msg;
}

inline std::unique_ptr<PointCloud2> EigenToPointCloud2(const std::vector<Eigen::Vector3d> &points,
const Sophus::SE3d &T,
const Header &header) {
std::vector<Eigen::Vector3d> points_t;
points_t.resize(points.size());
std::transform(points.cbegin(), points.cend(), points_t.begin(),
[&](const auto &point) { return T * point; });
return EigenToPointCloud2(points_t, header);
}

inline std::unique_ptr<PointCloud2> EigenToPointCloud2(const std::vector<Eigen::Vector3d> &points,
const std::vector<double> &timestamps,
const Header &header) {
Expand Down

0 comments on commit aeb1cf4

Please sign in to comment.