Package intera_interface :: Module lights
[hide private]
[frames] | no frames]

Source Code for Module intera_interface.lights

 1  # Copyright (c) 2016, Rethink Robotics 
 2  # All rights reserved. 
 3  # 
 4  # Redistribution and use in source and binary forms, with or without 
 5  # modification, are permitted provided that the following conditions are met: 
 6  # 
 7  # 1. Redistributions of source code must retain the above copyright notice, 
 8  #    this list of conditions and the following disclaimer. 
 9  # 2. Redistributions in binary form must reproduce the above copyright 
10  #    notice, this list of conditions and the following disclaimer in the 
11  #    documentation and/or other materials provided with the distribution. 
12  # 3. Neither the name of the Rethink Robotics nor the names of its 
13  #    contributors may be used to endorse or promote products derived from 
14  #    this software without specific prior written permission. 
15  # 
16  # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
17  # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
18  # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
19  # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
20  # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
21  # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
22  # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
23  # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
24  # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
25  # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
26  # POSSIBILITY OF SUCH DAMAGE. 
27   
28  import rospy 
29  from intera_io import IODeviceInterface 
30   
31   
32 -class Lights(object):
33 """ 34 Interface class for the lights on the Intera robots. 35 """ 36
37 - def __init__(self):
38 """ 39 Constructor. 40 41 """ 42 self._lights_io = IODeviceInterface("robot", "robot")
43
44 - def list_all_lights(self):
45 """ 46 Returns a list of strings describing all available lights 47 48 @rtype: list [str] 49 @return: a list of string representing light names 50 Each light name of the following format: 51 '<assembly>_<color>_light' 52 """ 53 return [name for name in self._lights_io.list_signal_names() if "light" in name]
54
55 - def set_light_state(self, name, on=True):
56 """ 57 Sets the named light the desired state (on=True, off=False) 58 59 @type name: str 60 @param name: Light name of the following format: 61 '<assembly>_<color>_light' 62 @type on: bool 63 @param on: value to set the light (on=True, off=False) 64 65 @rtype: bool 66 @return: True if the light state is set, False otherwise 67 """ 68 return self._lights_io.set_signal_value(name, on)
69
70 - def get_light_state(self, name):
71 """ 72 Returns a boolean describing whether the requested light is 'ON'. 73 (True: on, False: off) 74 75 @type name: str 76 @param name: Light name of the following format: 77 '<assembly>_<color>_light' 78 @rtype: bool 79 @return: a variable representing light state: (True: on, False: off) 80 """ 81 return self._lights_io.get_signal_value(name)
82