util.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 from math import cos, degrees, sin
34 
35 from geometry_msgs.msg import Pose2D
36 
37 from python_qt_binding.QtGui import QColor
38 
39 FIELDS = {'x': 'black', 'y': 'green', 'theta': 'blue'}
40 
41 
42 def scale(v, minval, maxval, dest_size=1.0, offset=0.0):
43  if minval == maxval:
44  return offset
45  return (v - minval) / (maxval - minval) * dest_size + offset
46 
47 
48 def subtractPose(pose_a, pose_b):
49  dx = pose_a.x - pose_b.x
50  dy = pose_a.y - pose_b.y
51  s = sin(-pose_b.theta)
52  c = cos(-pose_b.theta)
53  x = dx * c - dy * s
54  y = dx * s + dy * c
55  return Pose2D(x, y, pose_a.theta - pose_b.theta)
56 
57 
58 def debug(pose):
59  return '%.2f %.2f %.2f' % (pose.x, pose.y, degrees(pose.theta))
60 
61 
62 PALETTE = [QColor(204, 65, 37), QColor(246, 178, 107), QColor(255, 217, 102), QColor(147, 196, 125), # noqa(E241)
63  QColor(109, 158, 235), QColor(142, 124, 195), QColor(224, 102, 102), QColor(118, 165, 175),
64  QColor(111, 168, 220), QColor(194, 123, 160)]
rqt_dwb_plugin.util.scale
def scale(v, minval, maxval, dest_size=1.0, offset=0.0)
Definition: util.py:42
rqt_dwb_plugin.util.subtractPose
def subtractPose(pose_a, pose_b)
Definition: util.py:48
rqt_dwb_plugin.util.debug
def debug(pose)
Definition: util.py:58


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