twist_mux.h
Go to the documentation of this file.
1 /*********************************************************************
2  * Software License Agreement (CC BY-NC-SA 4.0 License)
3  *
4  * Copyright (c) 2014, PAL Robotics, S.L.
5  * All rights reserved.
6  *
7  * This work is licensed under the Creative Commons
8  * Attribution-NonCommercial-ShareAlike 4.0 International License.
9  *
10  * To view a copy of this license, visit
11  * http://creativecommons.org/licenses/by-nc-sa/4.0/
12  * or send a letter to
13  * Creative Commons, 444 Castro Street, Suite 900,
14  * Mountain View, California, 94041, USA.
15  *********************************************************************/
16 
17 /*
18  * @author Enrique Fernandez
19  * @author Siegfried Gevatter
20  */
21 
22 #ifndef TWIST_MUX_H
23 #define TWIST_MUX_H
24 
25 #include <ros/ros.h>
26 #include <std_msgs/Bool.h>
27 #include <geometry_msgs/Twist.h>
28 
29 #include <list>
30 
31 namespace twist_mux
32 {
33 
34 // Forwarding declarations:
35 class TwistMuxDiagnostics;
36 struct TwistMuxDiagnosticsStatus;
37 class VelocityTopicHandle;
38 class LockTopicHandle;
39 
44 class TwistMux
45 {
46 public:
47 
48  // @todo use this type alias when the compiler supports this C++11 feat.
49  //template<typename T>
50  //using handle_container = std::list<T>;
51  // @todo alternatively we do the following:
52  typedef std::list<VelocityTopicHandle> velocity_topic_container;
53  typedef std::list<LockTopicHandle> lock_topic_container;
54 
55  TwistMux(int window_size = 10);
56  ~TwistMux();
57 
59 
60  void publishTwist(const geometry_msgs::TwistConstPtr& msg);
61 
62  void updateDiagnostics(const ros::TimerEvent& event);
63 
64 protected:
65 
68 
70 
71  static constexpr double DIAGNOSTICS_PERIOD = 1.0;
72 
79  // @todo use handle_container (see above)
80  //handle_container<VelocityTopicHandle> velocity_hs_;
81  //handle_container<LockTopicHandle> lock_hs_;
84 
86 
87  geometry_msgs::Twist last_cmd_;
88 
89  template<typename T>
90  void getTopicHandles(ros::NodeHandle& nh, ros::NodeHandle& nh_priv, const std::string& param_name, std::list<T>& topic_hs);
91 
92  int getLockPriority();
93 
96 };
97 
98 } // namespace twist_mux
99 
100 #endif // TWIST_MUX_H
void updateDiagnostics(const ros::TimerEvent &event)
Definition: twist_mux.cpp:77
bool hasPriority(const VelocityTopicHandle &twist)
Definition: twist_mux.cpp:141
TwistMux(int window_size=10)
Definition: twist_mux.cpp:51
ros::Timer diagnostics_timer_
Definition: twist_mux.h:69
boost::shared_ptr< velocity_topic_container > velocity_hs_
velocity_hs_ Velocity topics&#39; handles. Note that if we use a vector, as a consequence of the re-alloc...
Definition: twist_mux.h:82
TwistMuxDiagnostics diagnostics_type
Definition: twist_mux.h:66
TwistMuxDiagnosticsStatus status_type
Definition: twist_mux.h:67
geometry_msgs::Twist last_cmd_
Definition: twist_mux.h:87
def twist(x=0.0, r=0.0)
boost::shared_ptr< lock_topic_container > lock_hs_
Definition: twist_mux.h:83
boost::shared_ptr< status_type > status_
Definition: twist_mux.h:95
ros::Publisher cmd_pub_
Definition: twist_mux.h:85
boost::shared_ptr< diagnostics_type > diagnostics_
Definition: twist_mux.h:94
The TwistMux class implements a top-level twist multiplexer module that priorize different velocity c...
Definition: twist_mux.h:44
void getTopicHandles(ros::NodeHandle &nh, ros::NodeHandle &nh_priv, const std::string &param_name, std::list< T > &topic_hs)
Definition: twist_mux.cpp:89
static constexpr double DIAGNOSTICS_PERIOD
Definition: twist_mux.h:71
std::list< VelocityTopicHandle > velocity_topic_container
Definition: twist_mux.h:52
void publishTwist(const geometry_msgs::TwistConstPtr &msg)
Definition: twist_mux.cpp:83
std::list< LockTopicHandle > lock_topic_container
Definition: twist_mux.h:53


twist_mux
Author(s): Enrique Fernandez , Siegfried-A. Gevatter Pujals
autogenerated on Wed Oct 26 2022 02:14:17