node.cpp
Go to the documentation of this file.
1 
18 #include <LeicaStateMachine.h>
19 #include "leica_scanstation_utils/LeicaUtils.h"
20 
21 typedef pcl::PointCloud<pcl::PointXYZ> PointCloudXYZ;
22 typedef pcl::PointCloud<pcl::PointXYZRGB> PointCloudRGB;
23 
24 const float FREQ = 0.1; // Hz
25 
26 int main(int argc, char** argv)
27 {
28  ros::init(argc, argv, "statemachine");
29  ros::NodeHandle nh;
30  ros::Rate r(FREQ);
31 
32  PointCloudRGB::Ptr source_cloud(new PointCloudRGB);
33  PointCloudRGB::Ptr target_cloud(new PointCloudRGB);
34 
35  sensor_msgs::PointCloud2ConstPtr cloud_msg;
36  cloud_msg = ros::topic::waitForMessage<sensor_msgs::PointCloud2>(SOURCE_CLOUD_TOPIC);
37  pcl::fromROSMsg(*cloud_msg, *source_cloud);
38  ROS_INFO("Received cloud from topic: %s", SOURCE_CLOUD_TOPIC.c_str());
39 
40  cloud_msg = ros::topic::waitForMessage<sensor_msgs::PointCloud2>(TARGET_CLOUD_TOPIC);
41  pcl::fromROSMsg(*cloud_msg, *target_cloud);
42  ROS_INFO("Received cloud from topic: %s", TARGET_CLOUD_TOPIC.c_str());
43 
44  if (Utils::isValidCloud(source_cloud) && Utils::isValidCloud(target_cloud))
45  {
46  std::shared_ptr<StateMachine> FSM = std::make_shared<StateMachine>(source_cloud, target_cloud, nh);
47  FSM->initiate();
48  FSM->process_event(StartEvent());
49 
50  while(ros::ok())
51  {
52  FSM->process_event(PublishEvent());
53  ros::spinOnce();
54  r.sleep();
55  }
56  }
57 
58  ROS_ERROR("NO VALID MSGS");
59 
60  ros::spin();
61 
62  return 0;
63 }
pcl::PointCloud< pcl::PointXYZRGB > PointCloudRGB
const float FREQ
Definition: node.cpp:24
const std::string SOURCE_CLOUD_TOPIC
Definition: Utils.cpp:25
pcl::PointCloud< pcl::PointXYZ > PointCloudXYZ
Definition: node.cpp:21
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
static bool isValidCloud(PointCloudXYZ::Ptr cloud)
Check whether cloud contains data and is not empty.
Definition: Utils.cpp:46
ROSCPP_DECL void spin(Spinner &spinner)
const std::string TARGET_CLOUD_TOPIC
Definition: Utils.cpp:24
#define ROS_INFO(...)
ROSCPP_DECL bool ok()
bool sleep()
pcl::PointCloud< pcl::PointXYZRGB > PointCloudRGB
Definition: node.cpp:22
int main(int argc, char **argv)
Definition: node.cpp:26
ROSCPP_DECL void spinOnce()
#define ROS_ERROR(...)


leica_point_cloud_processing
Author(s): Ines Lara Sicilia
autogenerated on Fri Feb 5 2021 03:20:30