diff --git a/Dockerfile b/Dockerfile index cb78009..d38876f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,20 +1,14 @@ -FROM python:2.7 +FROM armhf/python:2.7 MAINTAINER Cem Gokmen COPY . /verne WORKDIR /verne -RUN chmod +x install_git.sh -RUN ./install_git.sh - RUN chmod +x install_rtimulib.sh RUN ./install_rtimulib.sh RUN pip install -r requirements.txt -VOLUME /dev/uart -VOLUME /dev/i2c-0 -VOLUME /dev/i2c-1 VOLUME /data CMD python main.py diff --git a/README.md b/README.md index dd05bd5..26912b5 100644 --- a/README.md +++ b/README.md @@ -26,10 +26,10 @@ To run the project, a container must be created with this image and the correct ``` docker create \ --name=verne - -v /dev/ttyAMA0:/dev/uart \ - -v /dev/i2c-1:/dev/i2c-1 \ + --device /dev/ttyAMA0 \ + --device /dev/i2c-1 \ -v /home/pi/vernedata:/data \ - --restart=unless-stopped \ + --restart=on-failure \ gtviples/verne ``` diff --git a/RTIMULib.ini b/RTIMULib.ini index e9fe2a0..a8c60ed 100644 --- a/RTIMULib.ini +++ b/RTIMULib.ini @@ -17,7 +17,7 @@ # 8 = STM L3GD20H + LSM303DLHC # 9 = Bosch BMX055 # 10 = Bosch BNX055 -IMUType=0 +IMUType=6 # # Fusion type type - @@ -48,7 +48,7 @@ SPISpeed=500000 # # I2C slave address (filled in automatically by auto discover) -I2CSlaveAddress=0 +I2CSlaveAddress=107 # # IMU axis rotation - see RTIMU.h for details @@ -82,13 +82,13 @@ I2CHumidityAddress=0 # # Compass calibration settings -CompassCalValid=false -CompassCalMinX=0.000000 -CompassCalMinY=0.000000 -CompassCalMinZ=0.000000 -CompassCalMaxX=0.000000 -CompassCalMaxY=0.000000 -CompassCalMaxZ=0.000000 +CompassCalValid=true +CompassCalMinX=-59.988636 +CompassCalMinY=-23.912876 +CompassCalMinZ=-61.714367 +CompassCalMaxX=47.611153 +CompassCalMaxY=86.796547 +CompassCalMaxZ=42.061466 # ##################################################################### # @@ -101,40 +101,40 @@ compassAdjDeclination=0.000000 # # Compass ellipsoid calibration -compassCalEllipsoidValid=false -compassCalOffsetX=0.000000 -compassCalOffsetY=0.000000 -compassCalOffsetZ=0.000000 -compassCalCorr11=1.000000 -compassCalCorr12=0.000000 -compassCalCorr13=0.000000 -compassCalCorr21=0.000000 -compassCalCorr22=1.000000 -compassCalCorr23=0.000000 -compassCalCorr31=0.000000 -compassCalCorr32=0.000000 -compassCalCorr33=1.000000 +compassCalEllipsoidValid=true +compassCalOffsetX=-0.523097 +compassCalOffsetY=2.773693 +compassCalOffsetZ=-1.804364 +compassCalCorr11=0.980180 +compassCalCorr12=0.010728 +compassCalCorr13=0.001986 +compassCalCorr21=0.010728 +compassCalCorr22=0.992445 +compassCalCorr23=-0.007001 +compassCalCorr31=0.001986 +compassCalCorr32=-0.007001 +compassCalCorr33=0.979710 # ##################################################################### # # Accel calibration -AccelCalValid=false -AccelCalMinX=0.000000 -AccelCalMinY=0.000000 -AccelCalMinZ=0.000000 -AccelCalMaxX=0.000000 -AccelCalMaxY=0.000000 -AccelCalMaxZ=0.000000 +AccelCalValid=true +AccelCalMinX=-0.992136 +AccelCalMinY=-1.006543 +AccelCalMinZ=-1.011658 +AccelCalMaxX=1.011742 +AccelCalMaxY=0.999970 +AccelCalMaxZ=0.990727 # ##################################################################### # # Saved gyro bias data -GyroBiasValid=false -GyroBiasX=0.000000 -GyroBiasY=0.000000 -GyroBiasZ=0.000000 +GyroBiasValid=true +GyroBiasX=0.006298 +GyroBiasY=0.044090 +GyroBiasZ=-0.000801 # ##################################################################### # diff --git a/install_git.sh b/install_git.sh index b8053db..5898918 100755 --- a/install_git.sh +++ b/install_git.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh set -ex #Fail if any line fails, print everything apt-get update diff --git a/install_rtimulib.sh b/install_rtimulib.sh index d247bae..2395914 100755 --- a/install_rtimulib.sh +++ b/install_rtimulib.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh set -ex #Fail if any line fails, print everything apt-get update diff --git a/main.py b/main.py index 528009e..e0b6445 100644 --- a/main.py +++ b/main.py @@ -27,7 +27,8 @@ def getCSVFilesFromModules(modules, missionTime, i): f = open('/data/%s-%d.csv' % (m, i), 'wb') writer = csv.writer(f, delimiter=' ', quotechar='|', quoting=csv.QUOTE_MINIMAL) - writer.writerow([missionTime]) + printableMissionTime = missionTime - datetime.fromtimestamp(0) + writer.writerow([int(printableMissionTime.total_seconds() * 1000)]) csvs[m] = (f, writer) @@ -61,7 +62,7 @@ def closeCSVFiles(csvs): # Load the modules modules = {} modules['imu'] = IMUModule(logger.getChild("imu")) - modules['geiger'] = GeigerCounterModule(logger.getChild("geiger"), "/dev/uart", 9600) + modules['geiger'] = GeigerCounterModule(logger.getChild("geiger"), "/dev/ttyAMA0", 9600) missionTime = datetime.now() timeToKill = missionTime + timedelta(hours=killScriptAfterHours) @@ -102,8 +103,8 @@ def closeCSVFiles(csvs): for m in modules.keys(): data = modules[m].poll(missionElapsedTime) - if len(data) > 0: - writer = csvs[m][0] + if data is not None and len(data) > 0: + writer = csvs[m][1] for datum in data: writer.writerow([missionElapsedTime] + list(datum)) @@ -111,4 +112,6 @@ def closeCSVFiles(csvs): if killer.kill_now: break - logger.info("The eagle has landed: stopping recording. Goodbye!") + closeCSVFiles(csvs) + + logger.info("The eagle has landed: stopping recording. Goodbye!") \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 738c33e..1bb1c67 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,2 @@ -pyserial==3.3 \ No newline at end of file +pyserial==3.3 +PyYAML==3.12 \ No newline at end of file diff --git a/sensormodules/GeigerCounterModule.py b/sensormodules/GeigerCounterModule.py index 96c985e..4226e00 100644 --- a/sensormodules/GeigerCounterModule.py +++ b/sensormodules/GeigerCounterModule.py @@ -13,9 +13,9 @@ def poll(self, dt): data = self.sm.poll(dt) - retval = [] + if data is not None: + retval = [] + for c in data: + retval.append(c) - for c in data: - retval.append(c) - - return retval \ No newline at end of file + return retval diff --git a/sensormodules/IMUModule.py b/sensormodules/IMUModule.py index c9ddc43..d94bfc6 100644 --- a/sensormodules/IMUModule.py +++ b/sensormodules/IMUModule.py @@ -32,8 +32,10 @@ def __init__(self, logger): imu.setCompassEnable(True) self.imu = imu - self.pollInterval = imu.IMUGetPollInterval() + self.pollInterval = IMUModule.MILLISECOND_POLLING_INTERVAL self.logger = logger + self.data = None + self.lastPoll = None def poll(self, dt): if self.imu.IMURead():