19 #include <gtest/gtest.h> 31 void cubeXYZ(PointCloudXYZ::Ptr cloud,
float dim,
float step){
33 for (
float i=0; i<dim; i+=step) {
34 for (
float j=0; j<dim; j+=step){
35 for (
float k=0; k<dim; k+=step){
39 cloud->push_back(p_rgb);
45 void cubeRGB(PointCloudRGB::Ptr cloud,
float dim,
float step){
46 pcl::PointXYZRGB p_rgb;
47 for (
float i=0; i<dim; i+=step) {
48 for (
float j=0; j<dim; j+=step){
49 for (
float k=0; k<dim; k+=step){
56 cloud->push_back(p_rgb);
65 PointCloudXYZ::Ptr cloudXYZ {
new pcl::PointCloud<pcl::PointXYZ>};
66 PointCloudRGB::Ptr cloudRGB {
new pcl::PointCloud<pcl::PointXYZRGB>};
80 PointCloudXYZ::Ptr cloudXYZ {
new pcl::PointCloud<pcl::PointXYZ>};
81 PointCloudRGB::Ptr cloudRGB {
new pcl::PointCloud<pcl::PointXYZRGB>};
88 EXPECT_TRUE((res_pc >= res-0.05) && (res_pc <= res+0.05));
91 EXPECT_TRUE((res_pc >= res-0.05) && (res_pc <= res+0.05));
96 PointCloudXYZ::Ptr cloudXYZ {
new pcl::PointCloud<pcl::PointXYZ>};
97 PointCloudRGB::Ptr cloudRGB {
new pcl::PointCloud<pcl::PointXYZRGB>};
107 PointCloudRGB::Ptr cloudRGB {
new pcl::PointCloud<pcl::PointXYZRGB>};
110 sensor_msgs::PointCloud2 cloudMsg;
116 PointCloudRGB::Ptr cloudRGB_orig {
new pcl::PointCloud<pcl::PointXYZRGB>};
117 PointCloudRGB::Ptr cloudRGB_tras {
new pcl::PointCloud<pcl::PointXYZRGB>};
119 cubeRGB(cloudRGB_orig, 3, 0.1);
121 std::cout << cloudRGB_tras->points[0].x << std::endl;
122 ASSERT_EQ(cloudRGB_tras->points[0].x, 5);
125 std::cout << cloudRGB_tras->points[0].x << std::endl;
126 ASSERT_EQ(cloudRGB_tras->points[0].x, 0);
142 int main(
int argc,
char **argv){
143 testing::InitGoogleTest(&argc, argv);
145 return RUN_ALL_TESTS();
int main(int argc, char **argv)
static void cloudToXYZRGB(PointCloudXYZ::Ptr cloud, PointCloudRGB::Ptr cloud_rgb, int R, int G, int B)
Convert XYZ cloud to XYZRGB cloud with specified RGB values.
static bool isValidCloud(PointCloudXYZ::Ptr cloud)
Check whether cloud contains data and is not empty.
TEST_F(TestUtils, testValidCloud)
void cubeRGB(PointCloudRGB::Ptr cloud, float dim, float step)
void cubeXYZ(PointCloudXYZ::Ptr cloud, float dim, float step)
static void cloudToROSMsg(PointCloudRGB::Ptr cloud, sensor_msgs::PointCloud2 &cloud_msg, const std::string &frameid="world")
Convert XYZRGB cloud to PointCloud2.
pcl::PointCloud< pcl::PointXYZRGB > PointCloudRGB
static void translateCloud(PointCloudRGB::Ptr cloud_in, PointCloudRGB::Ptr cloud_out, double x_offset=0, double y_offset=0, double z_offset=0)
Apply translation to Cloud. Values given in [m].
static double computeCloudResolution(PointCloudXYZ::Ptr cloud)
Obtain the resolution of the cloud.
pcl::PointCloud< pcl::PointXYZ > PointCloudXYZ