MsgRx.h
Go to the documentation of this file.
1 /*********************************************************************
2  * Software License Agreement (Proprietary and Confidential)
3  *
4  * Copyright (c) 2017-2018, Dataspeed Inc.
5  * All rights reserved.
6  *
7  * NOTICE: All information contained herein is, and remains the
8  * property of Dataspeed Inc. The intellectual and technical concepts
9  * contained herein are proprietary to Dataspeed Inc. and may be
10  * covered by U.S. and Foreign Patents, patents in process, and are
11  * protected by trade secret or copyright law. Dissemination of this
12  * information or reproduction of this material is strictly forbidden
13  * unless prior written permission is obtained from Dataspeed Inc.
14  *********************************************************************/
15 
16 #ifndef _MSG_RX_H_
17 #define _MSG_RX_H_
18 
19 #include <ros/ros.h>
20 
21 template <typename MsgT>
22 class MsgRx {
23 public:
24  MsgRx(const ros::WallDuration& thresh) : dur_(thresh) {};
25  MsgRx(const ros::WallDuration& thresh, const MsgT& msg) : dur_(thresh) { set(msg); };
26  void set(const MsgT& msg) { msg_ = msg; stamp_ = ros::WallTime::now(); }
27  void clear() { stamp_ = ros::WallTime(0); }
28  bool fresh(ros::WallDuration delta) const { return age() < delta; }
29  bool fresh() const { return fresh(dur_); }
30  ros::WallDuration age() const { return !stamp_.isZero() ? ros::WallTime::now() - stamp_ : ros::WallDuration(9999.0); }
31  const MsgT& get() const { return msg_; }
32  const ros::WallTime& stamp() const { return stamp_; }
33 private:
34  MsgT msg_;
37 };
38 
39 #endif // _MSG_RX_H_
MsgRx::msg_
MsgT msg_
Definition: MsgRx.h:47
MsgRx::stamp_
ros::WallTime stamp_
Definition: MsgRx.h:48
ros.h
MsgRx::get
const MsgT & get() const
Definition: MsgRx.h:44
TimeBase< WallTime, WallDuration >::isZero
bool isZero() const
ros::WallTime::now
static WallTime now()
ros::WallTime
MsgRx::fresh
bool fresh() const
Definition: MsgRx.h:42
MsgRx
Definition: MsgRx.h:22
MsgRx::age
ros::WallDuration age() const
Definition: MsgRx.h:43
MsgRx::dur_
ros::WallDuration dur_
Definition: MsgRx.h:49
ros::WallDuration
MsgRx::MsgRx
MsgRx(const ros::WallDuration &thresh)
Definition: MsgRx.h:37
MsgRx::set
void set(const MsgT &msg)
Definition: MsgRx.h:39
MsgRx::stamp
const ros::WallTime & stamp() const
Definition: MsgRx.h:45
MsgRx::clear
void clear()
Definition: MsgRx.h:40


dataspeed_ulc_can
Author(s): Micho Radovnikovich
autogenerated on Sat Dec 3 2022 03:34:49