sensors.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 """
4  sensors.py - various conversions from raw analog to sensor range
5  Copyright (c) 2011 Vanadium Labs LLC. All right reserved.
6 
7  Redistribution and use in source and binary forms, with or without
8  modification, are permitted provided that the following conditions are met:
9  * Redistributions of source code must retain the above copyright
10  notice, this list of conditions and the following disclaimer.
11  * Redistributions in binary form must reproduce the above copyright
12  notice, this list of conditions and the following disclaimer in the
13  documentation and/or other materials provided with the distribution.
14  * Neither the name of Vanadium Labs LLC nor the names of its
15  contributors may be used to endorse or promote products derived
16  from this software without specific prior written permission.
17 
18  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21  DISCLAIMED. IN NO EVENT SHALL VANADIUM LABS BE LIABLE FOR ANY DIRECT, INDIRECT,
22  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
24  OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
26  OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
27  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 """
29 
30 from sensor_msgs.msg import Range
31 
32 class SharpIR:
33  radiation_type = Range.INFRARED
34  field_of_view = 0.001
35  min_range = 0.0
36  max_range = 1.0
37 
38  def convert(self, raw):
39  """ Convert raw analog (10-bit) to distance. """
40  return raw
41 
43  """ Ultra long-range Sharp IR sensor. """
44  min_range = 0.75
45  max_range = 5.50
46 
47  def convert(self, raw):
48  """ Convert raw analog (10-bit) to distance. """
49  if raw > 100:
50  return (497.0/(raw-56))
51  else:
52  return self.max_range+0.1
53 
55  min_range = 0.20
56  max_range = 1.50
57 
58  def convert(self, raw):
59  """ Convert raw analog (10-bit) to distance. """
60  if raw > 80:
61  return (115.0/(raw-12))
62  else:
63  return self.max_range+0.1
64 
65 class gp2d12(SharpIR):
66  """ The typical GP2D12 IR ranger. """
67  min_range = 0.10
68  max_range = 0.80
69 
70  def convert(self, raw):
71  """ Convert raw analog (10-bit) to distance. """
72  if raw > 40:
73  return (52.0/(raw-12))
74  else:
75  return self.max_range+0.1
76 
77 class maxSonar():
78  radiation_type = Range.ULTRASOUND
79  field_of_view = 0.785398163
80  min_range = 0.0
81  max_range = 6.4516
82 
83  def convert(self, raw):
84  """ Convert raw analog (10-bit) to distance. """
85  return 12.7 * (raw/1024.0)
86 
def convert(self, raw)
Definition: sensors.py:70


arbotix_sensors
Author(s): Michael Ferguson
autogenerated on Mon Jun 10 2019 12:43:41