Hi,
I am building a manipulator with joint potentiometers.
I am using a Adafruit ADS1115 with a raspberry pi to read angular values from a Bourns 3382 rotary position sensor. I have used the knowledge from the ROS basics in 5 days course to create a publisher for the positional sensor. I am publishing the readings to a ros topic however I cannot seem to publish with a rate higher than 7Hz. As far as i understand the ADS is possible of up to 860Hz. I have tried increasing the rospy.rate, however when using the rospy.info it never exceeds 7 readings per second. My code is shown below- am I somehow limiting the publishing speed?
#!/usr/bin/env python
import rospy
from ads1115.msg import IntList
import time
import adafruit_ads1x15.ads1115 as ADS
from adafruit_ads1x15.analog_in import AnalogIn
from adafruit_extended_bus import ExtendedI2C as I2C
import numpy as np
import random
PKG = 'ads1115'
import roslib; roslib.load_manifest(PKG)
################## RETRIVE DATA FROM ADS1115 ##################
# Create the I2C buses
i2c1 = I2C(1)
i2c2 = I2C(3)
i2c3 = I2C(4)
# Create the ADC object using the I2C bus
ads11 = ADS.ADS1115(i2c1,1,16,0x0100,0x48)
ads12 = ADS.ADS1115(i2c1,1,16,0x0100,0x49)
# Create single-ended input on channel 0
chan1480 = AnalogIn(ads11, ADS.P0)
chan1481 = AnalogIn(ads11, ADS.P1)
chan1482 = AnalogIn(ads11, ADS.P2)
chan1483 = AnalogIn(ads11, ADS.P3)
chan1490 = AnalogIn(ads12, ADS.P0)
chan1491 = AnalogIn(ads12, ADS.P1)
chan1492 = AnalogIn(ads12, ADS.P2)
chan1493 = AnalogIn(ads12, ADS.P3)
adc_value1 = [chan1480.value,chan1481.value,chan1482.value,chan1483.value,chan1490.value,chan1491.value,chan1492.value,chan1493.value]
print(adc_value1)
print(type(adc_value1))
adc_voltage2 = [chan1480.voltage,chan1481.voltage,chan1482.voltage,chan1483.voltage,chan1490.voltage,chan1491.voltage,chan1492.voltage,chan1493.voltage]
def talker():
pub = rospy.Publisher('ads1115_data', IntList, queue_size=10)
rospy.init_node('ads1115_talker', anonymous=True)
rate = rospy.Rate(1000) # 10hz
while not rospy.is_shutdown():
chanVoltage = np.array([chan1480.voltage,chan1481.voltage,chan1482.voltage,chan1483.voltage,chan1490.voltage,chan1491.voltage,chan1492.voltage,chan1493.voltage], dtype=np.float32)
rospy.loginfo(chanVoltage)
pub.publish(chanVoltage)
rate.sleep()
if __name__ == '__main__':
try:
talker()
except rospy.ROSInterruptException:
pass