import rospy
from std_msgs.msg import Int64
from std_msgs.msg import Header
from boat_imu.msg import measurements

history_length = 5
airPressure = [0 for x in range(history_length)]

def accelerometerPrint(data):
    rospy.loginfo(rospy.get_caller_id()+"""
    I heard x acceleration is %i, 
    y acceleration is %i, 
    z acceleration is %i;
    Header: %s""", data.x_value, data.y_value, data.z_value, data.header)
     
def airPressurePrint(data):
    rospy.loginfo(rospy.get_caller_id()+"""
    I heard air pressure is %i""",
    data.data)

def storeAirPressure(data):
    airPressure.insert(0,data.data)
    airPressure.pop()
    print(airPressure)

def listener():
    rospy.init_node('listener', anonymous=True)
    rospy.Subscriber("AirPressure", Int64, airPressurePrint)
    rospy.Subscriber("Accelerometer", measurements, accelerometerPrint)
    rospy.Subscriber("AirPressure", Int64, storeAirPressure)
    rospy.spin()
                                                    

if __name__ == '__main__':
    listener()

@@ -1,12 +1,106 @@
+#!/usr/bin/env python%0A# this line is needed so the execution happens in python environment%0A%0A%0A%0A
 import rospy
@@ -206,26 +206,104 @@
 ts%0A%0A
-history_length = 5
+%0A# number of remembered values%0Ahistory_length = 5%0A# Air pressure history%0A# AirPressure%5B0%5D newest
 %0Aair
@@ -348,16 +348,58 @@
 ength)%5D%0A
+air = %5B0 for x in range(history_length)%5D%0A%0A
 %0Adef acc
@@ -866,16 +866,119 @@
 ssure)%0A%0A
+def storeIntROS(data, storage):%0A    storage.insert(0,data.data)%0A    storage.pop()%0A    print(storage)%0A%0A%0A
 def list
@@ -1033,24 +1033,25 @@
 s=True)%0A    
+#
 rospy.Subscr
@@ -1091,32 +1091,33 @@
 ssurePrint)%0A    
+#
 rospy.Subscriber
@@ -1229,16 +1229,77 @@
 essure)%0A
+    rospy.Subscriber(%22AirPressure%22, Int64, storeIntROS, air)%0A
     rosp

add more generic storage system