class PhidgetsAccelerometer: def __init__(self): rospy.init_node('accelerometer', anonymous=True) self.name = rospy.get_param('~name', '') self.serial = rospy.get_param('~serial_number', -1) self.x_axis_id = rospy.get_param('~x_axis_id', 0) self.y_axis_id = rospy.get_param('~y_axis_id', 1) self.z_axis_id = rospy.get_param('~z_axis_id', 2) self.sensitivity = rospy.get_param('~sensitivity', 0.0) if self.serial == -1: rospy.logwarn( "No serial number specified. This node will connect to the first accelerometer attached." ) self.accelerometer = Accelerometer() def initialize(self): try: self.accelerometer.setOnAttachHandler(self.accelerometerAttached) self.accelerometer.setOnDetachHandler(self.accelerometerDetached) self.accelerometer.setOnErrorhandler(self.accelerometerError) self.accelerometer.setOnAccelerationChangeHandler( self.accelerationChanged) self.accelerometer.openPhidget(self.serial) except PhidgetException, e: rospy.logfatal("Phidget Exception %i: %s" % (e.code, e.message)) sys.exit(1)
def __init__(self): rospy.init_node('accelerometer', anonymous=True) self.name = rospy.get_param('~name', '') self.serial = rospy.get_param('~serial_number', -1) self.x_axis_id = rospy.get_param('~x_axis_id', 0) self.y_axis_id = rospy.get_param('~y_axis_id', 1) self.z_axis_id = rospy.get_param('~z_axis_id', 2) self.sensitivity = rospy.get_param('~sensitivity', 0.0) if self.serial == -1: rospy.logwarn( "No serial number specified. This node will connect to the first accelerometer attached." ) self.accelerometer = Accelerometer()
def __init__(self): rospy.init_node('accelerometer', anonymous=True) self.name = rospy.get_param('~name', '') self.serial = rospy.get_param('~serial_number', -1) self.x_axis_id = rospy.get_param('~x_axis_id', 0) self.y_axis_id = rospy.get_param('~y_axis_id', 1) self.z_axis_id = rospy.get_param('~z_axis_id', 2) self.sensitivity = rospy.get_param('~sensitivity', 0.0) if self.serial == -1: rospy.logwarn("No serial number specified. This node will connect to the first accelerometer attached.") self.accelerometer = Accelerometer()
class PhidgetsAccelerometer: def __init__(self): rospy.init_node('accelerometer', anonymous=True) self.name = rospy.get_param('~name', '') self.serial = rospy.get_param('~serial_number', -1) self.x_axis_id = rospy.get_param('~x_axis_id', 0) self.y_axis_id = rospy.get_param('~y_axis_id', 1) self.z_axis_id = rospy.get_param('~z_axis_id', 2) self.sensitivity = rospy.get_param('~sensitivity', 0.0) if self.serial == -1: rospy.logwarn("No serial number specified. This node will connect to the first accelerometer attached.") self.accelerometer = Accelerometer() def initialize(self): try: self.accelerometer.setOnAttachHandler(self.accelerometerAttached) self.accelerometer.setOnDetachHandler(self.accelerometerDetached) self.accelerometer.setOnErrorhandler(self.accelerometerError) self.accelerometer.setOnAccelerationChangeHandler(self.accelerationChanged) self.accelerometer.openPhidget(self.serial) except PhidgetException, e: rospy.logfatal("Phidget Exception %i: %s" % (e.code, e.message)) sys.exit(1)
__author__ = 'Adam Stelmack' __version__ = '2.1.4' __date__ = 'May 02 2008' #Basic imports from threading import * from ctypes import * import sys #Phidget specific imports from Phidgets.PhidgetException import * from Phidgets.Events.Events import * from Phidgets.Devices.Accelerometer import * #Create an accelerometer object accelerometer = Accelerometer() #Information Display Function def DisplayDeviceInfo(): print "|------------|----------------------------------|--------------|------------|" print "|- Attached -|- Type -|- Serial No. -|- Version -|" print "|------------|----------------------------------|--------------|------------|" print "|- %8s -|- %30s -|- %10d -|- %8d -|" % ( accelerometer.isAttached(), accelerometer.getDeviceType(), accelerometer.getSerialNum(), accelerometer.getDeviceVersion()) print "|------------|----------------------------------|--------------|------------|" print "Number of Axes: %i" % (accelerometer.getAxisCount()) return 0
__author__ = 'Adam Stelmack' __version__ = '2.1.4' __date__ = 'May 02 2008' #Basic imports from threading import * from ctypes import * import sys #Phidget specific imports from Phidgets.PhidgetException import * from Phidgets.Events.Events import * from Phidgets.Devices.Accelerometer import * #Create an accelerometer object accelerometer = Accelerometer() #Information Display Function def DisplayDeviceInfo(): print "|------------|----------------------------------|--------------|------------|" print "|- Attached -|- Type -|- Serial No. -|- Version -|" print "|------------|----------------------------------|--------------|------------|" print "|- %8s -|- %30s -|- %10d -|- %8d -|" % (accelerometer.isAttached(), accelerometer.getDeviceType(), accelerometer.getSerialNum(), accelerometer.getDeviceVersion()) print "|------------|----------------------------------|--------------|------------|" print "Number of Axes: %i" % (accelerometer.getAxisCount()) return 0 #Event Handler Callback Functions def AccelerometerAttached(e): attached = e.device print "Accelerometer %i Attached!" % (attached.getSerialNum())