4 io.py - ROS wrappers for ArbotiX I/O 5 Copyright (c) 2010-2011 Vanadium Labs LLC. All right reserved. 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. 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. 34 """ Class for a digital output. """ 35 def __init__(self, name, pin, value, rate, device):
41 rospy.Subscriber(
'~'+name, Digital, self.
stateCb)
45 self.
value = msg.value
48 if rospy.Time.now() > self.
t_next:
53 """ Class for a digital input. """ 54 def __init__(self, name, pin, value, rate, device):
57 self.device.setDigital(pin, value, 0)
58 self.
pub = rospy.Publisher(
'~'+name, Digital, queue_size=5)
62 if rospy.Time.now() > self.
t_next:
64 msg.header.stamp = rospy.Time.now()
65 msg.value = self.device.getDigital(self.
pin)
70 """ Class for an analog input. """ 71 def __init__(self, name, pin, value, rate, leng, device):
74 self.device.setDigital(pin, value, 0)
75 self.
pub = rospy.Publisher(
'~'+name, Analog, queue_size=5)
80 if rospy.Time.now() > self.
t_next:
82 msg.header.stamp = rospy.Time.now()
83 msg.value = self.device.getAnalog(self.
pin, self.
leng)
def __init__(self, name, pin, value, rate, leng, device)
def __init__(self, name, pin, value, rate, device)
def __init__(self, name, pin, value, rate, device)