19 #ifndef _LEICA_STATE_MACHINE_H 20 #define _LEICA_STATE_MACHINE_H 23 #include <boost/statechart/event.hpp> 24 #include <boost/statechart/state_machine.hpp> 25 #include <boost/statechart/simple_state.hpp> 26 #include <boost/statechart/state.hpp> 27 #include <boost/statechart/transition.hpp> 28 #include <boost/statechart/custom_reaction.hpp> 31 #include <std_msgs/Int16.h> 37 class ValidEvent :
public boost::statechart::event<ValidEvent>
44 : source_cloud_(source_cloud) {}
46 ValidEvent(PointCloudRGB::Ptr source_cloud, PointCloudRGB::Ptr target_cloud)
47 : source_cloud_(source_cloud), target_cloud_(target_cloud){}
56 ValidFODEvent(
int n_fods, std::vector<PointCloudRGB::Ptr> fods_cloud_array)
57 : n_fod_(n_fods), fods_cloud_array_(fods_cloud_array){}
60 class NoValidEvent :
public boost::statechart::event<NoValidEvent> {};
61 class StartEvent :
public boost::statechart::event<StartEvent> {};
62 class PublishEvent :
public boost::statechart::event<PublishEvent> {};
76 class StateMachine :
public boost::statechart::state_machine< StateMachine, IdleState >
128 return source_cloud_filtered_;
132 return target_cloud_filtered_;
137 source_cloud_filtered_ = cloud_ptr;
141 target_cloud_filtered_ = cloud_ptr;
146 return cloud_transform_;
151 cloud_transform_ = tf;
161 return fods_cloud_array_;
166 class IdleState :
public boost::statechart::simple_state< IdleState, StateMachine >
172 typedef boost::statechart::custom_reaction<StartEvent>
reactions;
177 return transit< FilterState >();
181 class FilterState :
public boost::statechart::state< FilterState, StateMachine >
186 typedef boost::mpl::list<
187 boost::statechart::custom_reaction<ValidEvent>,
188 boost::statechart::custom_reaction<NoValidEvent>
194 return transit< ErrorState >();
204 class AlignState :
public boost::statechart::state< AlignState, StateMachine >
209 typedef boost::mpl::list<
210 boost::statechart::custom_reaction<ValidEvent>,
211 boost::statechart::custom_reaction<NoValidEvent>
217 return transit< ErrorState >();
227 class GICPState :
public boost::statechart::state< GICPState, StateMachine >
232 typedef boost::mpl::list<
233 boost::statechart::custom_reaction<ValidEvent>,
234 boost::statechart::custom_reaction<NoValidEvent>
240 return transit< ErrorState >();
245 ROS_INFO(
"Transit to FODDetectionState");
255 typedef boost::mpl::list<
256 boost::statechart::custom_reaction<ValidFODEvent>,
257 boost::statechart::custom_reaction<NoValidEvent>
263 return transit< ErrorState >();
268 ROS_INFO(
"Transit to PublishState");
273 class ErrorState :
public boost::statechart::simple_state< ErrorState, StateMachine >
279 class PublishState :
public boost::statechart::state< PublishState, StateMachine >
284 typedef boost::mpl::list<
285 boost::statechart::custom_reaction<PublishEvent>,
286 boost::statechart::custom_reaction<StopPublishEvent>
292 return transit< PublishState >();
PointCloudRGB::Ptr getTargetCloud()
pcl::PointCloud< pcl::PointXYZRGB > PointCloudRGB
boost::mpl::list< boost::statechart::custom_reaction< ValidEvent >, boost::statechart::custom_reaction< NoValidEvent > > reactions
boost::mpl::list< boost::statechart::custom_reaction< ValidFODEvent >, boost::statechart::custom_reaction< NoValidEvent > > reactions
std::vector< PointCloudRGB::Ptr > getFODCloudArray()
Eigen::Matrix4f getCloudTransform()
void updateCloud(const ValidEvent &cloud)
PointCloudRGB::Ptr source_cloud_
boost::statechart::result react(const NoValidEvent &)
ros::Publisher target_pub_
boost::statechart::result react(const ValidFODEvent &cloud)
ValidEvent(PointCloudRGB::Ptr source_cloud)
std::vector< PointCloudRGB::Ptr > fods_cloud_array_
boost::mpl::list< boost::statechart::custom_reaction< ValidEvent >, boost::statechart::custom_reaction< NoValidEvent > > reactions
PointCloudRGB::Ptr getTargetCloudFiltered()
ros::Publisher source_pub_
Eigen::Matrix4f cloud_transform_
void setCloudTransform(Eigen::Matrix4f tf)
PointCloudRGB::Ptr source_cloud_filtered_
void storeFODInfo(const ValidFODEvent &fod_info)
boost::statechart::result react(const ValidEvent &cloud)
boost::mpl::list< boost::statechart::custom_reaction< ValidEvent >, boost::statechart::custom_reaction< NoValidEvent > > reactions
boost::statechart::result react(const StartEvent &)
ValidEvent(PointCloudRGB::Ptr source_cloud, PointCloudRGB::Ptr target_cloud)
PointCloudRGB::Ptr getSourceCloudFiltered()
ValidFODEvent(int n_fods, std::vector< PointCloudRGB::Ptr > fods_cloud_array)
boost::statechart::result react(const NoValidEvent &)
boost::statechart::result react(const NoValidEvent &)
boost::statechart::result react(const ValidEvent &clouds)
PointCloudRGB::Ptr target_cloud_filtered_
void updateClouds(const ValidEvent &clouds)
boost::statechart::result react(const StopPublishEvent &)
boost::statechart::result react(const NoValidEvent &)
void setSourceCloudFiltered(PointCloudRGB::Ptr cloud_ptr)
boost::statechart::custom_reaction< StartEvent > reactions
void setTargetCloudFiltered(PointCloudRGB::Ptr cloud_ptr)
ros::Publisher n_fods_pub_
boost::mpl::list< boost::statechart::custom_reaction< PublishEvent >, boost::statechart::custom_reaction< StopPublishEvent > > reactions
boost::statechart::result react(const ValidEvent &cloud)
pcl::PointCloud< pcl::PointXYZ > PointCloudXYZ
PointCloudRGB::Ptr getSourceCloud()
PointCloudRGB::Ptr target_cloud_
std::vector< PointCloudRGB::Ptr > fods_cloud_array_
PointCloudRGB::Ptr source_cloud_
PointCloudRGB::Ptr target_cloud_
boost::statechart::result react(const PublishEvent &)