Is there a way to create and fill a PointCloud2 message in ROS2?
wjwwood
December 19, 2016, 6:34pm
2
You can certainly create and manipulate a PointCloud2:
#include "sensor_msgs/msg/point_cloud2.hpp"
int main(int argc, char * argv[])
{
sensor_msgs::msg::PointCloud2 point_cloud2_msg;
point_cloud2_msg.data.reserve(10);
point_cloud2_msg.fields.reserve(10);
// ...
}
But I don’t know what you mean by fill. You mean from a PCL type or OpenCV type?
Sorry, I mean actually adding the points. In Ros1, I think the easiest way to create a PointCloud2, was to create a pcl::PointCloud and convert it to PointCloud2, since the pcl::PointCloud allowed you to push_back points.
Now I’m wondering how to go from a list of points to a PointCloud2, preferably without just copying pcl::toROSMsg
Thanks for the reply.
wjwwood
December 22, 2016, 12:36am
4
Unfortunately we don’t have anything like that at the moment. You might be able to use this header from ROS 1 as a starting point:
/*
* Software License Agreement (BSD License)
*
* Copyright (c) 2013, Open Source Robotics Foundation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Open Source Robotics Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
This file has been truncated. show original