Skip to content

Instantly share code, notes, and snippets.

View ricklon's full-sized avatar

Rick Anderson ricklon

View GitHub Profile
@ricklon
ricklon / view.py
Created May 3, 2017 01:26
otto view collected image
import numpy as np
a = np.load("imgs_2017-05-02_21:12:18.npz")
a.shape
a[0]
a[0]
a
dir(a)
a.keys
a.keys()
a['arr_0']

Fix for matplotlib error: TypeError: Couldn't find foreign struct converter for 'cairo.Context'

sudo apt-get install python3-cairocffi
sudo pip3 install cairocffi
sudo apt-get install python3-gi-cairo 
import time
import picamera
import numpy as np
from picamera import PiCamera
camera = PiCamera()
camera.resolution = (320, 240)
camera.framerate = 24
time.sleep(2)
output = np.empty((240, 320, 3), dtype=np.uint8)
camera.capture(output, 'rgb')
@ricklon
ricklon / show.py
Created March 25, 2017 23:47
Show image from array in npz file
import matplotlib.pyplot as plt
import numpy as np
dfile = "imgs_2017-03-25_18:40:42.npz"
images = np.load(dfile)["arr_0"]
images.shape
plt.ion()
plt.figure()
plt.imshow(images[0].transpose((1,2,0)))
@ricklon
ricklon / BLEPeripheralUNO32.ino
Created December 19, 2016 18:19
TODOs for updating BLEPeripheral Library
// Copyright (c) Sandeep Mistry. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//TODO: Convert BLEPeripheral to use serial or SPI
//Import libraries (BLEPeripheral depends on SPI)
// #include <SPI.h>
#include <BLEPeripheral.h>
// define pins (varies per shield/board)
//TODO: Define pins for rn4871 and other Microchip chips
https://github.com/RedBearLab/nRF8001/
@ricklon
ricklon / compile_error.txt
Created October 19, 2016 21:21
chipKIT-core compile error 20161019
/Applications/Arduino.app/Contents/Java/arduino-builder -dump-prefs -logger=machine -hardware /Applications/Arduino.app/Contents/Java/hardware -hardware /Users/rickanderson/Library/Arduino15/packages -hardware /Users/rickanderson/Documents/Arduino/hardware -tools /Applications/Arduino.app/Contents/Java/tools-builder -tools /Applications/Arduino.app/Contents/Java/hardware/tools/avr -tools /Users/rickanderson/Library/Arduino15/packages -built-in-libraries /Applications/Arduino.app/Contents/Java/libraries -libraries /Users/rickanderson/Documents/Arduino/libraries -fqbn=chipkit-core:pic32:fubarino_sd -ide-version=10611 -build-path /var/folders/bx/zg7wx2513knbft_4ch_p5m6c0000gp/T/build16074617a2b163c1c137bf4bd1209a5c.tmp -warnings=none -prefs=build.warn_data_percentage=75 -verbose /Users/rickanderson/projects/ricklon/autonomous/arduino/OTTOFullAutoDrive/OTTOFullAutoDrive.ino
/Applications/Arduino.app/Contents/Java/arduino-builder -compile -logger=machine -hardware /Applications/Arduino.app/Contents/Java/hardware -
@ricklon
ricklon / mpu9250datacollection.txt
Last active September 9, 2016 15:43
mpu9250datacollection
MPU9250 I AM 71 I should be 71
MPU9250 is online...
x-axis self test: acceleration trim within : -1.4% of factory value
y-axis self test: acceleration trim within : -1.8% of factory value
z-axis self test: acceleration trim within : 0.8% of factory value
x-axis self test: gyration trim within : -0.7% of factory value
y-axis self test: gyration trim within : 0.1% of factory value
z-axis self test: gyration trim within : -0.7% of factory value
MPU9250 initialized for active data mode....
AK8963 I AM 48 I should be 48
@ricklon
ricklon / sparkfunmpu9250.ino
Created September 9, 2016 15:04
sparkfunmpu9250.ino
/* MPU9250 Basic Example Code
by: Kris Winer
date: April 1, 2014
license: Beerware - Use this code however you'd like. If you
find it useful you can buy me a beer some time.
Modified by Brent Wilkins July 19, 2016
Demonstrate basic MPU-9250 functionality including parameterizing the register
addresses, initializing the sensor, getting properly scaled accelerometer,
gyroscope, and magnetometer data out. Added display functions to allow display
@ricklon
ricklon / mpu9250test.ino
Created September 6, 2016 19:25
nolcd mpu test for interrupts
/* MPU9250 Basic Example Code
by: Kris Winer
date: April 1, 2014
license: Beerware - Use this code however you'd like. If you
find it useful you can buy me a beer some time.
Modified by Brent Wilkins July 19, 2016
Demonstrate basic MPU-9250 functionality including parameterizing the register
addresses, initializing the sensor, getting properly scaled accelerometer,
gyroscope, and magnetometer data out. Added display functions to allow display