NimbRo ROS Soccer Package
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
standing_demo.h
1 // Motion demonstration on a standing robot
2 // Authors: Philipp Allgeuer <pallgeuer@ais.uni-bonn.de>
3 // Sebastian Schüller <schuell1@cs.uni-bonn.de>
4 
5 // Ensure header is only included once
6 #ifndef STANDING_DEMO_H
7 #define STANDING_DEMO_H
8 
9 // Includes
10 #include <nimbro_op_interface/LEDCommand.h>
11 #include <standing_demo/standing_demo_fsm.h>
12 #include <limb_control/PlayCommandsSrv.h>
13 #include <nimbro_op_interface/Button.h>
14 #include <config_server/parameter.h>
15 #include <demo_msgs/DemoFSMState.h>
16 #include <robotcontrol/State.h>
17 #include <ros/service.h>
18 #include <ros/time.h>
19 
20 // Standing demo namespace
21 namespace standing_demo
22 {
23  // StandingDemo class
24  class StandingDemo
25  {
26  public:
27  // Constructor/destructor
28  StandingDemo();
29 
30  // Initialisation
31  void loadDemoMotions();
32 
33  // Main loop step
34  bool step();
35  bool halt();
36 
37  // Motion functions
38  void playMotion(int motionID);
39  double sendLimbCommands(const limb_control::PlayCommandsRequest& PCmdReq);
40 
41  // Utility functions
42  void publishFSMState(const demo_msgs::DemoFSMState& state);
43  void publishAction(const demo_msgs::DemoFSMState& action);
44 
45  // Get functions
46  inline int numMotions() const { return (int) m_demoMotions.size(); }
47  inline bool haveMotions() const { return m_haveMotions; }
48  inline bool enabled() const { return m_enabled && m_standingDemoEnabled(); }
49  inline bool robotIsStanding() const { return m_robotIsStanding; }
50  inline const ros::Time& curStepTime() const { return m_curStepTime; }
51  inline const ros::Time& limbControlFinishTime() const { return m_limbControlFinishTime; }
52 
53  private:
54  // Demo state controller
55  StandingDemoSC m_sc;
56 
57  // ROS topics
58  ros::Publisher m_pub_FSMState;
59  ros::Publisher m_pub_action;
60  ros::Publisher m_pub_LEDCommand;
61 
62  // Robot LEDs
63  void publishLEDCommand();
64  nimbro_op_interface::LEDCommand m_LED;
65 
66  // ROS services
67  ros::ServiceClient m_srv_playMotion;
68  ros::ServiceClient m_srv_playCommands;
69 
70  // Robotcontrol robot state
71  ros::Subscriber m_sub_robotState;
72  void handleRobotState(const robotcontrol::StateConstPtr& msg);
73  std::string m_robotStateName;
74  bool m_robotIsStanding;
75 
76  // Button presses
77  ros::Subscriber m_sub_button;
78  void handleButton(const nimbro_op_interface::ButtonConstPtr& msg);
79  bool m_buttonPressed;
80  bool m_enabled;
81 
82  // Configuration parameters
83  config_server::Parameter<bool> m_standingDemoEnabled;
84  void handleDemoEnabled();
85 
86  // Motions
87  std::vector<std::string> m_demoMotions;
88  bool m_haveMotions;
89 
90  // Internal variables
91  ros::Time m_curStepTime;
92  ros::Time m_limbControlFinishTime;
93  };
94 }
95 
96 #endif
boost::shared_ptr< State const > StateConstPtr
Used to represent a Boost shared pointer to a constant State object.
Definition: state_controller.h:413