NimbRo ROS Soccer Package
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
limb_control.h
1 // Motion module for individual control of robot limbs
2 // Author: Philipp Allgeuer
3 
4 // Ensure header is only included once
5 #ifndef LIMB_CONTROL_H
6 #define LIMB_CONTROL_H
7 
8 // Includes
9 #include <list>
10 #include <ros/time.h>
11 #include <ros/service.h>
12 #include <config_server/parameter.h>
13 #include <robotcontrol/motionmodule.h>
14 #include <robotcontrol/model/robotmodel.h>
15 #include <limb_control/PlayCommandsSrv.h>
16 
17 // Limbcontrol namespace
18 namespace limb_control
19 {
20  // LimbCmd struct
21  struct LimbCmd
22  {
23  LimbCommand LC;
24  robotcontrol::Joint::Ptr joint;
25  double initPos;
26  double duration;
27  };
28 
29  // LimbControl class
30  class LimbControl : public robotcontrol::MotionModule
31  {
32  public:
33  // Constructor
34  LimbControl();
35 
36  // Motion module overloads
37  virtual bool init(robotcontrol::RobotModel* model);
38  virtual void step();
39  virtual bool isTriggered();
40 
41  private:
42  // Constants
43  const std::string CONFIG_PARAM_PATH;
44 
45  // RobotModel reference
46  robotcontrol::RobotModel* m_model;
47 
48  // Config server parameters
49  config_server::Parameter<bool> m_limbControlEnabled;
50  bool m_lastEnabledState;
51 
52  // ROS services
53  ros::ServiceServer m_srv_playCommands;
54  bool handlePlayCommands(limb_control::PlayCommands::Request& req, limb_control::PlayCommands::Response& res);
55 
56  // Utility functions
57  void removeDuplicateJoints();
58  double getRemainingTime();
59  double getCurrentMotionTime() const;
60 
61  // Limb command list
62  std::list<LimbCmd> m_LCA;
63 
64  // Motion playing variables
65  ros::Time m_motionStartTime;
66  uint8_t m_curTimeRef;
67  size_t m_numMotions;
68  };
69 }
70 
71 #endif /* LIMB_CONTROL_H */
72 // EOF