38 const auto old_linear_x = std::abs(old_twist.linear.x);
39 const auto new_linear_x = std::abs(new_twist.linear.x);
41 const auto old_angular_z = std::abs(old_twist.angular.z);
42 const auto new_angular_z = std::abs(new_twist.angular.z);
44 return (old_linear_x < new_linear_x ) ||
45 (old_angular_z < new_angular_z);
57 velocity_hs_ = boost::make_shared<velocity_topic_container>();
58 lock_hs_ = boost::make_shared<lock_topic_container>();
67 status_ = boost::make_shared<status_type>();
97 std::string name, topic;
100 for (
int i = 0; i < output.
size(); ++i)
109 topic_hs.emplace_back(nh, name, topic, timeout, priority,
this);
124 for (
const auto& lock_h : *
lock_hs_)
126 if (lock_h.isLocked())
128 auto tmp = lock_h.getPriority();
146 std::string velocity_name =
"NULL";
152 if (!velocity_h.isMasked(lock_priority))
154 const auto velocity_priority = velocity_h.getPriority();
155 if (priority < velocity_priority)
157 priority = velocity_priority;
158 velocity_name = velocity_h.getName();
163 return twist.
getName() == velocity_name;
void updateDiagnostics(const ros::TimerEvent &event)
bool hasPriority(const VelocityTopicHandle &twist)
TwistMux(int window_size=10)
ros::Timer diagnostics_timer_
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...
Timer createTimer(Rate r, Handler h, Obj o, bool oneshot=false, bool autostart=true) const
void getStructMember(Struct &col, const std::string &member, T &output)
boost::shared_ptr< lock_topic_container > lock_hs_
void fetchParam(ros::NodeHandle nh, const std::string ¶m_name, T &output)
boost::shared_ptr< status_type > status_
bool hasIncreasedAbsVelocity(const geometry_msgs::Twist &old_twist, const geometry_msgs::Twist &new_twist)
hasIncreasedAbsVelocity Check if the absolute velocity has increased in any of the components: linear...
void publish(const boost::shared_ptr< M > &message) const
#define ROS_FATAL_STREAM(args)
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
void getArrayItem(Array &col, int index, T &output)
boost::shared_ptr< diagnostics_type > diagnostics_
#define ROS_DEBUG_STREAM(args)
void getTopicHandles(ros::NodeHandle &nh, ros::NodeHandle &nh_priv, const std::string ¶m_name, std::list< T > &topic_hs)
static constexpr double DIAGNOSTICS_PERIOD
const std::string & getName() const
base_type::priority_type priority_type
void publishTwist(const geometry_msgs::TwistConstPtr &msg)