evaluation_cache.py
Go to the documentation of this file.
1 # Software License Agreement (BSD License)
2 #
3 # Copyright (c) 2018-2019, Locus Robotics
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 the copyright holder 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 HOLDER 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, STRICT
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 import collections
34 
35 from .bounds import Bounds
36 from .util import FIELDS
37 
38 cache = None
39 
40 
41 def get_cache():
42  global cache
43  if cache is None:
44  cache = EvaluationCache()
45  return cache
46 
47 
49  """This class loads all the Evaluation messages from the bag files and maintains stats about the range of values."""
50 
51  def __init__(self):
52  Bounds.__init__(self)
53  self.cache = collections.defaultdict(dict)
54  self.v_max = None
55  self.v_min = None
56 
57  def getMessages(self, scene, topic, start, end):
58  msgs = []
59  for bag, entry in scene.get_entries_with_bags([topic], start, end):
60  if entry.position in self.cache[bag]:
61  msgs.append(self.cache[bag][entry.position])
62  continue
63  topic, msg, t = scene.read_message(bag, entry.position)
64  self.cache[bag][entry.position] = t.to_sec(), msg
65  msgs.append(self.cache[bag][entry.position])
66 
67  # Check trajectory bounds
68  self.process_evaluation(msg)
69 
70  # Check Stats
71  best = msg.twists[msg.best_index].traj.velocity
72  for field in FIELDS:
73  value = getattr(best, field)
74  if self.v_max is None:
75  self.v_max = value
76  self.v_min = value
77  else:
78  self.v_max = max(self.v_max, value)
79  self.v_min = min(self.v_min, value)
80 
81  return msgs
rqt_dwb_plugin.evaluation_cache.EvaluationCache.v_min
v_min
Definition: evaluation_cache.py:55
rqt_dwb_plugin.evaluation_cache.EvaluationCache.v_max
v_max
Definition: evaluation_cache.py:54
rqt_dwb_plugin.bounds.Bounds
Definition: bounds.py:36
rqt_dwb_plugin.evaluation_cache.EvaluationCache
Definition: evaluation_cache.py:48
rqt_dwb_plugin.evaluation_cache.EvaluationCache.getMessages
def getMessages(self, scene, topic, start, end)
Definition: evaluation_cache.py:57
rqt_dwb_plugin.evaluation_cache.EvaluationCache.cache
cache
Definition: evaluation_cache.py:53
rqt_dwb_plugin.evaluation_cache.get_cache
def get_cache()
Definition: evaluation_cache.py:41
rqt_dwb_plugin.evaluation_cache.EvaluationCache.__init__
def __init__(self)
Definition: evaluation_cache.py:51
rqt_dwb_plugin.bounds.Bounds.process_evaluation
def process_evaluation(self, msg)
Definition: bounds.py:45


rqt_dwb_plugin
Author(s):
autogenerated on Sun May 18 2025 02:47:58