ASCO Aerial Autonomy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
common_system_handler.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <ros/ros.h>
4 #include <std_msgs/String.h>
5 
6 #include "common_system_handler_config.pb.h"
11 
19 template <class LogicStateMachineT, class EventManagerT, class RobotSystemT>
21 public:
36  CommonSystemHandler(const CommonSystemHandlerConfig &config,
37  RobotSystemT &robot_system)
38  : nh_("~common"), logic_state_machine_(std::ref(robot_system)),
42  std::bind(
43  &SystemStatusPublisher<LogicStateMachineT>::publishSystemStatus,
44  std::ref(system_status_pub_)),
45  std::chrono::milliseconds(config.status_timer_duration())),
47  std::bind(&LogicStateMachineT::template process_event<
49  std::ref(logic_state_machine_),
51  std::chrono::milliseconds(config.state_machine_timer_duration())) {}
52 
56  CommonSystemHandler(const CommonSystemHandler &) = delete;
57 
62  bool isConnected() {
63  return state_machine_gui_connector_.isEventManagerConnected() &&
64  state_machine_gui_connector_.isPoseCommandConnected();
65  }
66 
70  void startTimers() {
71  logic_state_machine_.start();
74  }
75 
76 protected:
77  ros::NodeHandle nh_;
78  LogicStateMachineT
80  EventManagerT event_manager_;
88 };
Responsible for publishing system status message.
Definition: system_status_publisher.h:14
StateMachineGUIConnector< EventManagerT, LogicStateMachineT > state_machine_gui_connector_
Definition: common_system_handler.h:82
AsyncTimer status_timer_
Update uav status and state machine status.
Definition: common_system_handler.h:86
EventManagerT event_manager_
Event manager used by the state machine.
Definition: common_system_handler.h:80
void start()
Starts running the timer thread.
Definition: async_timer.cpp:16
void startTimers()
Start state machine internal event processing and status timer.
Definition: common_system_handler.h:70
Calls given function on a timer in its own thread.
Definition: async_timer.h:11
ros::NodeHandle nh_
Definition: common_system_handler.h:77
AsyncTimer logic_state_machine_timer_
Timer for running state machine.
Definition: common_system_handler.h:87
Provides logic common to different system handlers to reduce code duplication.
Definition: common_system_handler.h:20
LogicStateMachineT logic_state_machine_
State machine that gets run by the system.
Definition: common_system_handler.h:79
bool isConnected()
Checks if internal ROS topics are connected.
Definition: common_system_handler.h:62
The InternalTransitionEvent struct used to trigger action behaviors in states.
Definition: internal_transition_event.h:6
CommonSystemHandler(const CommonSystemHandlerConfig &config, RobotSystemT &robot_system)
Constructor.
Definition: common_system_handler.h:36
SystemStatusPublisher< LogicStateMachineT > system_status_pub_
publishes status messages
Definition: common_system_handler.h:85
Connects a logic state machine to the GUI over a ROS interface.
Definition: state_machine_gui_connector.h:20