test_laserscan_to_pointcloud.cpp
Go to the documentation of this file.
1 #include <ros/ros.h>
2 #include <gtest/gtest.h>
3 #include "sensor_msgs/PointCloud2.h"
4 #include "std_srvs/Trigger.h"
5 #include "boost/filesystem.hpp"
6 #include "leica_scanstation_utils/LeicaUtils.h"
7 
8 
9 // Test laserscan_to_pointcloud publish total point cloud from laser_scan rosbag
10 TEST(TestNode, testTotalPointCloudPublisher)
11 {
12  sensor_msgs::PointCloud2ConstPtr total_cloud_msg;
13 
14  total_cloud_msg = ros::topic::waitForMessage<sensor_msgs::PointCloud2>("simulator/cloud");
15 
16  EXPECT_TRUE((total_cloud_msg->row_step*total_cloud_msg->height) != 0);
17 }
18 
19 // Test call save_pcloud service in laserscan_to_pointcloud, it should return success
20 TEST(TestNode, testSaveCloudService)
21 {
22  ros::NodeHandle nh;
23  ros::ServiceClient client;
24  client = nh.serviceClient<std_srvs::Trigger>("store_cloud");
25  bool exists = client.waitForExistence(ros::Duration(1));
26  ASSERT_TRUE(exists);
27 
28  std_srvs::Trigger srv;
29 
30  if(client.call(srv))
31  {
32  // check if file exist
33  std::string path = LeicaUtils::getFilePath("scan.pcd");
34  ROS_INFO("Check for existance %s", path.c_str());
35 
36  ASSERT_TRUE(boost::filesystem::exists(path));
37  }
38  else ADD_FAILURE()<< "Failed to call service";
39 }
40 
41 int main(int argc,char **argv)
42 {
43  ros::init(argc, argv, "test_laserscan_to_pointcloud");
44  testing::InitGoogleTest(&argc, argv);
45  return RUN_ALL_TESTS();
46 }
ServiceClient serviceClient(const std::string &service_name, bool persistent=false, const M_string &header_values=M_string())
TEST(TestNode, testTotalPointCloudPublisher)
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
bool call(MReq &req, MRes &res)
int main(int argc, char **argv)
bool waitForExistence(ros::Duration timeout=ros::Duration(-1))
#define ROS_INFO(...)
ROSCPP_DECL bool exists(const std::string &service_name, bool print_failure_reason)


leica_gazebo_simulation
Author(s): Ines Lara Sicilia
autogenerated on Mon Feb 22 2021 03:50:48