Main Page
Namespaces
Classes
Files
File List
src
rqt_py_trees
topic_helper.py
Go to the documentation of this file.
1
# Software License Agreement (BSD License)
2
#
3
# Copyright (c) 2012, Willow Garage, Inc.
4
# All rights reserved.
5
#
6
# Redistribution and use in source and binary forms, with or without
7
# modification, are permitted provided that the following conditions
8
# are met:
9
#
10
# * Redistributions of source code must retain the above copyright
11
# notice, this list of conditions and the following disclaimer.
12
# * Redistributions in binary form must reproduce the above
13
# copyright notice, this list of conditions and the following
14
# disclaimer in the documentation and/or other materials provided
15
# with the distribution.
16
# * Neither the name of Willow Garage, Inc. nor the names of its
17
# contributors may be used to endorse or promote products derived
18
# from this software without specific prior written permission.
19
#
20
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICTS
29
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31
# POSSIBILITY OF SUCH DAMAGE.
32
33
"""
34
Helper functions for bag files and timestamps.
35
"""
36
37
import
time
38
import
rospy
39
40
41
def
stamp_to_str
(t):
42
"""
43
Convert a rospy.Time to a human-readable string.
44
45
@param t: time to convert
46
@type t: rospy.Time
47
"""
48
t_sec = t.to_sec()
49
if
t < rospy.Time.from_sec(60 * 60 * 24 * 365 * 5):
50
# Display timestamps earlier than 1975 as seconds
51
return
'%.3fs'
% t_sec
52
else
:
53
return
time.strftime(
'%b %d %Y %H:%M:%S'
, time.localtime(t_sec)) +
'.%03d'
% (t.nsecs / 1000000)
54
55
def
get_start_stamp
(topic):
56
"""
57
Get the earliest timestamp in the topic.
58
59
:param topic: topic tuple
60
:type topic: ``DynamicTimeline.Topic`` named tuple
61
:return: earliest timestamp, ``rospy.Time``
62
"""
63
start_stamp =
None
64
try
:
65
start_stamp = topic.queue[0].stamp
66
except
IndexError:
67
pass
68
69
return
start_stamp
70
71
def
get_end_stamp
(topic):
72
"""
73
Get the latest timestamp in the topic.
74
75
:param topic: topic tuple
76
:type topic: ``DynamicTimeline.Topic`` named tuple
77
:return: latest timestamp, ``rospy.Time``
78
"""
79
end_stamp =
None
80
try
:
81
end_stamp = topic.queue[-1].stamp
82
except
IndexError:
83
pass
84
85
return
end_stamp
rqt_py_trees.topic_helper.get_end_stamp
def get_end_stamp(topic)
Definition:
topic_helper.py:71
rqt_py_trees.topic_helper.stamp_to_str
def stamp_to_str(t)
Definition:
topic_helper.py:41
rqt_py_trees.topic_helper.get_start_stamp
def get_start_stamp(topic)
Definition:
topic_helper.py:55
rqt_py_trees
Author(s): Thibault Kruse, Michal Staniaszek, Daniel Stonier, Naveed Usmani
autogenerated on Mon Jun 10 2019 14:55:56