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
twist_mux::TwistMux::diagnostics_
boost::shared_ptr< diagnostics_type > diagnostics_
Definition: twist_mux.h:108
ros::Publisher
twist_mux
Definition: topic_handle.h:38
boost::shared_ptr< velocity_topic_container >
twist_mux::TwistMux::velocity_topic_container
std::list< VelocityTopicHandle > velocity_topic_container
Definition: twist_mux.h:66
ros.h
twist_mux::TwistMux::DIAGNOSTICS_PERIOD
static constexpr double DIAGNOSTICS_PERIOD
Definition: twist_mux.h:85
twist_mux::TwistMux::getTopicHandles
void getTopicHandles(ros::NodeHandle &nh, ros::NodeHandle &nh_priv, const std::string &param_name, std::list< T > &topic_hs)
Definition: twist_mux.cpp:89
twist_mux::TwistMux::lock_topic_container
std::list< LockTopicHandle > lock_topic_container
Definition: twist_mux.h:67
twist_mux::TwistMux::~TwistMux
~TwistMux()
Definition: twist_mux.cpp:74
twist_mux::TwistMux::TwistMux
TwistMux(int window_size=10)
Definition: twist_mux.cpp:51
twist_mux::TwistMuxDiagnostics
Definition: twist_mux_diagnostics.h:48
system_blackbox.twist
def twist(x=0.0, r=0.0)
Definition: system_blackbox.py:33
twist_mux::TwistMux::diagnostics_type
TwistMuxDiagnostics diagnostics_type
Definition: twist_mux.h:80
twist_mux::VelocityTopicHandle
Definition: topic_handle.h:156
twist_mux::TwistMux::publishTwist
void publishTwist(const geometry_msgs::TwistConstPtr &msg)
Definition: twist_mux.cpp:83
ros::TimerEvent
twist_mux::TwistMux::hasPriority
bool hasPriority(const VelocityTopicHandle &twist)
Definition: twist_mux.cpp:141
twist_mux::TwistMux::diagnostics_timer_
ros::Timer diagnostics_timer_
Definition: twist_mux.h:83
twist_mux::TwistMux::velocity_hs_
boost::shared_ptr< velocity_topic_container > velocity_hs_
velocity_hs_ Velocity topics' handles. Note that if we use a vector, as a consequence of the re-alloc...
Definition: twist_mux.h:96
twist_mux::TwistMux::updateDiagnostics
void updateDiagnostics(const ros::TimerEvent &event)
Definition: twist_mux.cpp:77
twist_mux::TwistMux::getLockPriority
int getLockPriority()
Definition: twist_mux.cpp:118
twist_mux::TwistMux::status_type
TwistMuxDiagnosticsStatus status_type
Definition: twist_mux.h:81
twist_mux::TwistMux::cmd_pub_
ros::Publisher cmd_pub_
Definition: twist_mux.h:99
twist_mux::TwistMux::last_cmd_
geometry_msgs::Twist last_cmd_
Definition: twist_mux.h:101
twist_mux::TwistMux::lock_hs_
boost::shared_ptr< lock_topic_container > lock_hs_
Definition: twist_mux.h:97
ros::Timer
twist_mux::TwistMuxDiagnosticsStatus
Definition: twist_mux_diagnostics_status.h:46
ros::NodeHandle
twist_mux::TwistMux::status_
boost::shared_ptr< status_type > status_
Definition: twist_mux.h:109


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