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_); }
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_
ros::WallDuration dur_
Definition: MsgRx.h:36
MsgRx(const ros::WallDuration &thresh)
Definition: MsgRx.h:24
bool fresh(ros::WallDuration delta) const
Definition: MsgRx.h:28
ros::WallDuration age() const
Definition: MsgRx.h:30
MsgRx(const ros::WallDuration &thresh, const MsgT &msg)
Definition: MsgRx.h:25
Definition: MsgRx.h:22
bool fresh() const
Definition: MsgRx.h:29
static WallTime now()
const ros::WallTime & stamp() const
Definition: MsgRx.h:32
void clear()
Definition: MsgRx.h:27
MsgT msg_
Definition: MsgRx.h:34
ros::WallTime stamp_
Definition: MsgRx.h:35


dataspeed_ulc_can
Author(s): Micho Radovnikovich
autogenerated on Thu Jul 9 2020 03:45:43