From b474cb65193f59c6c054f53dd4b315e3290a1e2a Mon Sep 17 00:00:00 2001 From: Cem Gokmen Date: Mon, 27 Mar 2017 20:09:08 -0700 Subject: [PATCH] Added docker creation instructions, updated volume and device names and fixed the time reporting on the main script --- .gitignore | 3 +- Dockerfile | 3 +- README.md | 15 +- RTIMULib.ini | 658 +++++++++++++++++++++++++++++++++++++++++++++++++++ main.py | 8 +- 5 files changed, 682 insertions(+), 5 deletions(-) create mode 100644 RTIMULib.ini diff --git a/.gitignore b/.gitignore index f5f13de..293bf46 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ env -.idea \ No newline at end of file +.idea +*.pyc diff --git a/Dockerfile b/Dockerfile index 7c2947b..cb78009 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,7 +12,8 @@ RUN ./install_rtimulib.sh RUN pip install -r requirements.txt -VOLUME /dev/geigerCounter +VOLUME /dev/uart +VOLUME /dev/i2c-0 VOLUME /dev/i2c-1 VOLUME /data diff --git a/README.md b/README.md index 26d08f0..ebfc415 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,20 @@ Note that this step is completely optional and that it should be done only if no ### Installing and Running -To run the project, a container must be created with this image and the correct parameters, including the unless-stopped restart policy and the correct volume links to any devices. Instructions will be added here shortly. +To run the project, a container must be created with this image and the correct parameters, including the unless-stopped restart policy and the correct volume links to any devices. For example: + +``` +docker create \ + --name=verne + -v /dev/ttyAMA0:/dev/uart \ + -v /dev/i2c-0:/dev/i2c-0 \ + -v /dev/i2c-0:/dev/i2c-1 \ + -v /home/pi/vernedata:/data \ + --restart=unless-stopped \ + gtviples/verne +``` + +Then, the container can be started and stopped using the `docker start verne` and `docker stop verne` commands. ## Built With diff --git a/RTIMULib.ini b/RTIMULib.ini new file mode 100644 index 0000000..e9fe2a0 --- /dev/null +++ b/RTIMULib.ini @@ -0,0 +1,658 @@ +# ##################################################################### +# +# RTIMULib settings file + +# General settings +# + +# IMU type - +# 0 = Auto discover +# 1 = Null (used when data is provided from a remote IMU +# 2 = InvenSense MPU-9150 +# 3 = STM L3GD20H + LSM303D +# 4 = STM L3GD20 + LSM303DLHC +# 5 = STM LSM9DS0 +# 6 = STM LSM9DS1 +# 7 = InvenSense MPU-9250 +# 8 = STM L3GD20H + LSM303DLHC +# 9 = Bosch BMX055 +# 10 = Bosch BNX055 +IMUType=0 + +# +# Fusion type type - +# 0 - Null. Use if only sensor data required without fusion +# 1 - Kalman STATE4 +# 2 - RTQF +FusionType=2 + +# +# Is bus I2C: 'true' for I2C, 'false' for SPI +BusIsI2C=true + +# +# I2C Bus (between 0 and 7) +I2CBus=1 + +# +# SPI Bus (between 0 and 7) +SPIBus=0 + +# +# SPI select (between 0 and 1) +SPISelect=0 + +# +# SPI Speed in Hz +SPISpeed=500000 + +# +# I2C slave address (filled in automatically by auto discover) +I2CSlaveAddress=0 + +# +# IMU axis rotation - see RTIMU.h for details +AxisRotation=0 + +# Pressure sensor type - +# 0 = Auto discover +# 1 = Null (no hardware or don't use) +# 2 = BMP180 +# 3 = LPS25H +# 4 = MS5611 +# 5 = MS5637 +PressureType=0 + +# +# I2C pressure sensor address (filled in automatically by auto discover) +I2CPressureAddress=0 + +# Humidity sensor type - +# 0 = Auto discover +# 1 = Null (no hardware or don't use) +# 2 = HTS221 +# 3 = HTU21D +HumidityType=0 + +# +# I2C humidity sensor address (filled in automatically by auto discover) +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 + +# ##################################################################### +# + +# Compass adjustment settings +# Compass declination is in radians and is subtracted from calculated heading +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 + +# ##################################################################### +# + +# Accel calibration +AccelCalValid=false +AccelCalMinX=0.000000 +AccelCalMinY=0.000000 +AccelCalMinZ=0.000000 +AccelCalMaxX=0.000000 +AccelCalMaxY=0.000000 +AccelCalMaxZ=0.000000 + +# ##################################################################### +# + +# Saved gyro bias data +GyroBiasValid=false +GyroBiasX=0.000000 +GyroBiasY=0.000000 +GyroBiasZ=0.000000 + +# ##################################################################### +# +# MPU-9150 settings +# + +# Gyro sample rate (between 5Hz and 1000Hz) +MPU9150GyroAccelSampleRate=50 + +# +# Compass sample rate (between 1Hz and 100Hz) +MPU9150CompassSampleRate=25 + +# +# Gyro/accel low pass filter - +# 0 - gyro: 256Hz, accel: 260Hz +# 1 - gyro: 188Hz, accel: 184Hz +# 2 - gyro: 98Hz, accel: 98Hz +# 3 - gyro: 42Hz, accel: 44Hz +# 4 - gyro: 20Hz, accel: 21Hz +# 5 - gyro: 10Hz, accel: 10Hz +# 6 - gyro: 5Hz, accel: 5Hz +MPU9150GyroAccelLpf=4 + +# +# Gyro full scale range - +# 0 - +/- 250 degress per second +# 8 - +/- 500 degress per second +# 16 - +/- 1000 degress per second +# 24 - +/- 2000 degress per second +MPU9150GyroFSR=16 + +# +# Accel full scale range - +# 0 - +/- 2g +# 8 - +/- 4g +# 16 - +/- 8g +# 24 - +/- 16g +MPU9150AccelFSR=16 + +# ##################################################################### +# +# MPU-9250 settings +# + +# Gyro sample rate (between 5Hz and 1000Hz plus 8000Hz and 32000Hz) +MPU9250GyroAccelSampleRate=80 + +# +# Compass sample rate (between 1Hz and 100Hz) +MPU9250CompassSampleRate=40 + +# +# Gyro low pass filter - +# 0x11 - 8800Hz, 0.64mS delay +# 0x10 - 3600Hz, 0.11mS delay +# 0x00 - 250Hz, 0.97mS delay +# 0x01 - 184Hz, 2.9mS delay +# 0x02 - 92Hz, 3.9mS delay +# 0x03 - 41Hz, 5.9mS delay +# 0x04 - 20Hz, 9.9mS delay +# 0x05 - 10Hz, 17.85mS delay +# 0x06 - 5Hz, 33.48mS delay +MPU9250GyroLpf=3 + +# +# Accel low pass filter - +# 0x08 - 1130Hz, 0.75mS delay +# 0x00 - 460Hz, 1.94mS delay +# 0x01 - 184Hz, 5.80mS delay +# 0x02 - 92Hz, 7.80mS delay +# 0x03 - 41Hz, 11.80mS delay +# 0x04 - 20Hz, 19.80mS delay +# 0x05 - 10Hz, 35.70mS delay +# 0x06 - 5Hz, 66.96mS delay +MPU9250AccelLpf=3 + +# +# Gyro full scale range - +# 0 - +/- 250 degress per second +# 8 - +/- 500 degress per second +# 16 - +/- 1000 degress per second +# 24 - +/- 2000 degress per second +MPU9250GyroFSR=16 + +# +# Accel full scale range - +# 0 - +/- 2g +# 8 - +/- 4g +# 16 - +/- 8g +# 24 - +/- 16g +MPU9250AccelFSR=16 + +# ##################################################################### +# +# L3GD20H + LSM303D settings + +# +# Gyro sample rate - +# 0 = 12.5Hz +# 1 = 25Hz +# 2 = 50Hz +# 3 = 100Hz +# 4 = 200Hz +# 5 = 400Hz +# 6 = 800Hz +GD20HM303DGyroSampleRate=2 + +# +# Gyro full scale range - +# 0 = 245 degrees per second +# 1 = 500 degrees per second +# 2 = 2000 degrees per second +GD20HM303DGyroFsr=1 + +# +# Gyro high pass filter - +# 0 - 9 but see the L3GD20H manual for details +GD20HM303DGyroHpf=4 + +# +# Gyro bandwidth - +# 0 - 3 but see the L3GD20H manual for details +GD20HM303DGyroBW=1 + +# Accel sample rate - +# 1 = 3.125Hz +# 2 = 6.25Hz +# 3 = 12.5Hz +# 4 = 25Hz +# 5 = 50Hz +# 6 = 100Hz +# 7 = 200Hz +# 8 = 400Hz +# 9 = 800Hz +# 10 = 1600Hz +GD20HM303DAccelSampleRate=5 + +# +# Accel full scale range - +# 0 = +/- 2g +# 1 = +/- 4g +# 2 = +/- 6g +# 3 = +/- 8g +# 4 = +/- 16g +GD20HM303DAccelFsr=3 + +# +# Accel low pass filter - +# 0 = 773Hz +# 1 = 194Hz +# 2 = 362Hz +# 3 = 50Hz +GD20HM303DAccelLpf=3 + +# +# Compass sample rate - +# 0 = 3.125Hz +# 1 = 6.25Hz +# 2 = 12.5Hz +# 3 = 25Hz +# 4 = 50Hz +# 5 = 100Hz +GD20HM303DCompassSampleRate=4 + +# +# Compass full scale range - +# 0 = +/- 200 uT +# 1 = +/- 400 uT +# 2 = +/- 800 uT +# 3 = +/- 1200 uT +GD20HM303DCompassFsr=0 + +# ##################################################################### +# +# L3GD20 + LSM303DLHC settings +# + +# Gyro sample rate - +# 0 = 95z +# 1 = 190Hz +# 2 = 380Hz +# 3 = 760Hz +GD20M303DLHCGyroSampleRate=0 + +# +# Gyro full scale range - +# 0 = 250 degrees per second +# 1 = 500 degrees per second +# 2 = 2000 degrees per second +GD20M303DLHCGyroFsr=1 + +# +# Gyro high pass filter - +# 0 - 9 but see the L3GD20 manual for details +GD20M303DLHCGyroHpf=4 + +# +# Gyro bandwidth - +# 0 - 3 but see the L3GD20 manual for details +GD20M303DLHCGyroBW=1 + +# Accel sample rate - +# 1 = 1Hz +# 2 = 10Hz +# 3 = 25Hz +# 4 = 50Hz +# 5 = 100Hz +# 6 = 200Hz +# 7 = 400Hz +GD20M303DLHCAccelSampleRate=4 + +# +# Accel full scale range - +# 0 = +/- 2g +# 1 = +/- 4g +# 2 = +/- 8g +# 3 = +/- 16g +GD20M303DLHCAccelFsr=2 + +# +# Compass sample rate - +# 0 = 0.75Hz +# 1 = 1.5Hz +# 2 = 3Hz +# 3 = 7.5Hz +# 4 = 15Hz +# 5 = 30Hz +# 6 = 75Hz +# 7 = 220Hz +GD20M303DLHCCompassSampleRate=5 + +# +# Compass full scale range - +# 1 = +/- 130 uT +# 2 = +/- 190 uT +# 3 = +/- 250 uT +# 4 = +/- 400 uT +# 5 = +/- 470 uT +# 6 = +/- 560 uT +# 7 = +/- 810 uT +GD20M303DLHCCompassFsr=1 + +# ##################################################################### +# +# L3GD20H + LSM303DLHC settings +# + +# +# Gyro sample rate - +# 0 = 12.5Hz +# 1 = 25Hz +# 2 = 50Hz +# 3 = 100Hz +# 4 = 200Hz +# 5 = 400Hz +# 6 = 800Hz +GD20HM303DLHCGyroSampleRate=2 + +# +# Gyro full scale range - +# 0 = 245 degrees per second +# 1 = 500 degrees per second +# 2 = 2000 degrees per second +GD20HM303DLHCGyroFsr=1 + +# +# Gyro high pass filter - +# 0 - 9 but see the L3GD20H manual for details +GD20HM303DLHCGyroHpf=4 + +# +# Gyro bandwidth - +# 0 - 3 but see the L3GD20H manual for details +GD20HM303DLHCGyroBW=1 + +# Accel sample rate - +# 1 = 1Hz +# 2 = 10Hz +# 3 = 25Hz +# 4 = 50Hz +# 5 = 100Hz +# 6 = 200Hz +# 7 = 400Hz +GD20HM303DLHCAccelSampleRate=4 + +# +# Accel full scale range - +# 0 = +/- 2g +# 1 = +/- 4g +# 2 = +/- 8g +# 3 = +/- 16g +GD20HM303DLHCAccelFsr=2 + +# +# Compass sample rate - +# 0 = 0.75Hz +# 1 = 1.5Hz +# 2 = 3Hz +# 3 = 7.5Hz +# 4 = 15Hz +# 5 = 30Hz +# 6 = 75Hz +# 7 = 220Hz +GD20HM303DLHCCompassSampleRate=5 + +# +# Compass full scale range - +# 1 = +/- 130 uT +# 2 = +/- 190 uT +# 3 = +/- 250 uT +# 4 = +/- 400 uT +# 5 = +/- 470 uT +# 6 = +/- 560 uT +# 7 = +/- 810 uT +GD20HM303DLHCCompassFsr=1 + +# ##################################################################### +# +# LSM9DS0 settings +# + +# Gyro sample rate - +# 0 = 95z +# 1 = 190Hz +# 2 = 380Hz +# 3 = 760Hz +LSM9DS0GyroSampleRate=0 + +# +# Gyro full scale range - +# 0 = 250 degrees per second +# 1 = 500 degrees per second +# 2 = 2000 degrees per second +LSM9DS0GyroFsr=1 + +# +# Gyro high pass filter - +# 0 - 9 but see the LSM9DS0 manual for details +LSM9DS0GyroHpf=4 + +# +# Gyro bandwidth - +# 0 - 3 but see the LSM9DS0 manual for details +LSM9DS0GyroBW=1 + +# Accel sample rate - +# 1 = 3.125Hz +# 2 = 6.25Hz +# 3 = 12.5Hz +# 4 = 25Hz +# 5 = 50Hz +# 6 = 100Hz +# 7 = 200Hz +# 8 = 400Hz +# 9 = 800Hz +# 10 = 1600Hz +LSM9DS0AccelSampleRate=5 + +# +# Accel full scale range - +# 0 = +/- 2g +# 1 = +/- 4g +# 2 = +/- 6g +# 3 = +/- 8g +# 4 = +/- 16g +LSM9DS0AccelFsr=3 + +# +# Accel low pass filter - +# 0 = 773Hz +# 1 = 194Hz +# 2 = 362Hz +# 3 = 50Hz +LSM9DS0AccelLpf=3 + +# +# Compass sample rate - +# 0 = 3.125Hz +# 1 = 6.25Hz +# 2 = 12.5Hz +# 3 = 25Hz +# 4 = 50Hz +# 5 = 100Hz +LSM9DS0CompassSampleRate=4 + +# +# Compass full scale range - +# 0 = +/- 200 uT +# 1 = +/- 400 uT +# 2 = +/- 800 uT +# 3 = +/- 1200 uT +LSM9DS0CompassFsr=0 + +# ##################################################################### +# +# LSM9DS1 settings +# + +# Gyro sample rate - +# 0 = 95Hz +# 1 = 190Hz +# 2 = 380Hz +# 3 = 760Hz +LSM9DS1GyroSampleRate=2 + +# +# Gyro full scale range - +# 0 = 250 degrees per second +# 1 = 500 degrees per second +# 2 = 2000 degrees per second +LSM9DS1GyroFsr=1 + +# +# Gyro high pass filter - +# 0 - 9 but see the LSM9DS1 manual for details +LSM9DS1GyroHpf=4 + +# +# Gyro bandwidth - +# 0 - 3 but see the LSM9DS1 manual for details +LSM9DS1GyroBW=1 + +# Accel sample rate - +# 1 = 14.9Hz +# 2 = 59.5Hz +# 3 = 119Hz +# 4 = 238Hz +# 5 = 476Hz +# 6 = 952Hz +LSM9DS1AccelSampleRate=3 + +# +# Accel full scale range - +# 0 = +/- 2g +# 1 = +/- 16g +# 2 = +/- 4g +# 3 = +/- 8g +LSM9DS1AccelFsr=3 + +# +# Accel low pass filter - +# 0 = 408Hz +# 1 = 211Hz +# 2 = 105Hz +# 3 = 50Hz +LSM9DS1AccelLpf=3 + +# +# Compass sample rate - +# 0 = 0.625Hz +# 1 = 1.25Hz +# 2 = 2.5Hz +# 3 = 5Hz +# 4 = 10Hz +# 5 = 20Hz +# 6 = 40Hz +# 7 = 80Hz +LSM9DS1CompassSampleRate=5 + +# +# Compass full scale range - +# 0 = +/- 400 uT +# 1 = +/- 800 uT +# 2 = +/- 1200 uT +# 3 = +/- 1600 uT +LSM9DS1CompassFsr=0 + +# ##################################################################### +# +# BMX055 settings +# + +# +# Gyro sample rate - +# 0 = 2000Hz (532Hz filter) +# 1 = 2000Hz (230Hz filter) +# 2 = 1000Hz (116Hz filter) +# 3 = 400Hz (47Hz filter) +# 4 = 200Hz (23Hz filter) +# 5 = 100Hz (12Hz filter) +# 6 = 200Hz (64Hz filter) +# 7 = 100Hz (32Hz filter) +BMX055GyroSampleRate=7 + +# +# Gyro full scale range - +# 0 = 2000 deg/s +# 1 = 1000 deg/s +# 2 = 500 deg/s +# 3 = 250 deg/s +# 4 = 125 deg/s +BMX055GyroFsr=2 + +# +# Accel sample rate - +# 0 = 15.63Hz +# 1 = 31.25 +# 2 = 62.5 +# 3 = 125 +# 4 = 250 +# 5 = 500 +# 6 = 1000 +# 7 = 2000 +BMX055AccelSampleRate=3 + +# +# Accel full scale range - +# 0 = +/- 2g +# 1 = +/- 4g +# 2 = +/- 8g +# 3 = +/- 16g +BMX055AccelFsr=2 + +# +# Mag presets - +# 0 = Low power +# 1 = Regular +# 2 = Enhanced +# 3 = High accuracy +BMX055MagPreset=1 diff --git a/main.py b/main.py index 5cc4b19..d0e5da7 100644 --- a/main.py +++ b/main.py @@ -2,8 +2,12 @@ import logging import signal import csv +import time +# TODO: Improve the time function! +millis = lambda: int(round(time.time() * 1000)) + class GracefulKiller: kill_now = False @@ -23,7 +27,7 @@ def exit_gracefully(self, signum, frame): logger = logging.getLogger("verne") modules['imu'] = IMUModule(logger.getChild("imu")) - modules['geiger'] = GeigerCounterModule(logger.getChild("geiger"), "/dev/geigerCounter", 9600) + modules['geiger'] = GeigerCounterModule(logger.getChild("geiger"), "/dev/uart", 9600) for m in modules.keys(): f = open('%s.csv' % m, 'wb') @@ -36,7 +40,7 @@ def exit_gracefully(self, signum, frame): data = modules[m].poll() if len(data) > 0: - currentTime = None # Todo: get the time here. + currentTime = millis() writer = csvs[m][0] for datum in data: