mirror of
https://github.com/YikeStone/ros_arduino_bridge.git
synced 2025-08-03 11:14:08 +05:30
Added missing pin_mode statements to Analog and AnalogFloat sensor types
This commit is contained in:
parent
f2d40aa724
commit
8e6b2ff0ce
@ -89,6 +89,13 @@ class AnalogSensor(Sensor):
|
|||||||
|
|
||||||
self.pub = rospy.Publisher("~sensor/" + self.name, Analog)
|
self.pub = rospy.Publisher("~sensor/" + self.name, Analog)
|
||||||
|
|
||||||
|
if self.direction == "output":
|
||||||
|
self.controller.pin_mode(self.pin, OUTPUT)
|
||||||
|
else:
|
||||||
|
self.controller.pin_mode(self.pin, INPUT)
|
||||||
|
|
||||||
|
self.value = LOW
|
||||||
|
|
||||||
def read_value(self):
|
def read_value(self):
|
||||||
return self.controller.analog_read(self.pin)
|
return self.controller.analog_read(self.pin)
|
||||||
|
|
||||||
@ -105,6 +112,19 @@ class AnalogFloatSensor(Sensor):
|
|||||||
self.msg.header.frame_id = self.frame_id
|
self.msg.header.frame_id = self.frame_id
|
||||||
|
|
||||||
self.pub = rospy.Publisher("~sensor/" + self.name, AnalogFloat)
|
self.pub = rospy.Publisher("~sensor/" + self.name, AnalogFloat)
|
||||||
|
|
||||||
|
if self.direction == "output":
|
||||||
|
self.controller.pin_mode(self.pin, OUTPUT)
|
||||||
|
else:
|
||||||
|
self.controller.pin_mode(self.pin, INPUT)
|
||||||
|
|
||||||
|
self.value = LOW
|
||||||
|
|
||||||
|
def read_value(self):
|
||||||
|
return self.controller.analog_read(self.pin)
|
||||||
|
|
||||||
|
def write_value(self, value):
|
||||||
|
return self.controller.analog_write(self.pin, value)
|
||||||
|
|
||||||
|
|
||||||
class DigitalSensor(Sensor):
|
class DigitalSensor(Sensor):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user