Ben recently tried this and I wanted to see if I could do it my way

I’ve seen this done (Bartosz?) before but I tried to do it without looking anything up.

The comonad is an interesting pattern to use. It automates the translation invariant nature off the cellular automata. This would also be useful for translationally invariant PDEs like the simple wave equation or others.

I used the laziness of Haskell to start with an infinite plane of zeros. Of course if you ever want to look at it, you need to pick a finite slice at the end using dtake

{-# LANGUAGE DeriveFunctor, DeriveFoldable, DeriveTraversable #-}
import Control.Comonad
import Data.Bits
{-
example usage
This pushes forward the initial state forward by 1 time step according to rule 30
let s1 = extend (cellRule 30) initState
Comments:
My rule is coming out right-left swapped compared to Wolfram?
I should probably custom implement Show, since the left list is printed out of order
-}
-- a two sided list with focus
--alternatively may be preferable to not use those inner lists and instead make more recursive.
--I have implicitly assume that these lists are infinite, which is bad practice. Sorry.
data DoubleList a = DList [a] a [a] deriving (Functor, Show)
data CellValue = Alive | Dead deriving Show
lshift (DList (l:ls) x rs) = DList ls l (x:rs)
rshift (DList ls x (r:rs)) = DList (x:ls) r rs
toList (DList ls x rs) = ls ++ [x] ++ rs
lList (DList ls _ _) = ls
rList (DList _ _ rs) = rs
-- truncates the Dlist to 2n + 1
dtake n (DList ls x rs) = DList (take n ls) x (take n rs)
--kind of ugly
--f is a function that uses the context
-- patches together the result out of doing it on shifted Dlists
instance Comonad DoubleList where
extract (DList _ x _) = x
extend f z = DList (l:ls) (f z) (r:rs) where
lDList = extend f (lshift z)
ls = lList lDList
l = extract lDList
rDList = extend f (rshift z)
rs = rList rDList
r = extract rDList
cellToNum Alive = 1
cellToNum Dead = 0
cellNeighborToNum x y z = x' + 2 * y' + 4 * z' where
x' = cellToNum x
y' = cellToNum y
z' = cellToNum z
cellRule :: Int -> (DoubleList CellValue -> CellValue )
cellRule rulenum (DList (l:ls) x (r:rs)) = if testBit rulenum y then Alive else Dead where
y = cellNeighborToNum l x r :: Int
initState = DList deads Alive deads where deads = repeat Dead

Already has an inequality type. That may have been better to use.

Exploration and guesswork was necessary. How the heck do I get a hotkey for holes in atom?

The first couple Opairs are ordinary pairs. Just exploring the syntax.

I switched out of InEq which explicitly stores the number it is talking about to better match the equality type.

The Inequality type acts something like a mix of Nat and Equality.

My head hurts and I’m dehydrated.

data OPair1 a = SimplePair1 a a
data OPair2 : Type -> Type where
SimplePair2 : a -> a -> OPair2 a
data OPair3 : Type -> Type where
SimplePair3 : (Ord a) => a -> a -> OPair3 a
data InEq : Nat -> Nat -> Type where
Refly : (t:Nat) -> InEq t t
Succy : InEq a b -> InEq a (S b)
data InEq' : Nat -> Nat -> Type where
Refly' : InEq' t t
Succy' : InEq' a b -> InEq' a (S b)
data InEq'' : Nat -> Nat -> Type where
Refly'' : InEq'' Z t
Succy'' : InEq'' a b -> InEq'' (S a) (S b)
data OPair4 : Type where
SPair : (t : Nat) -> (s : Nat) -> (InEq t s) -> OPair4
data OPair5 : Type where
SPair5 : (t : Nat) -> (s : Nat) -> (InEq' t s) -> OPair5
-- a useful lemma
convert4 : InEq' s t -> InEq' (S s) (S t)
convert4 Refly' = Refly'
convert4 (Succy' x) = Succy' (convert4 x)
addpair : OPair5 -> OPair5 -> OPair5
addpair (SPair5 s s Refly') (SPair5 k k Refly') = SPair5 (s+k) (s+k) Refly'
addpair (SPair5 Z Z Refly') (SPair5 t b p) = (SPair5 t b p)
addpair (SPair5 (S x) (S x) Refly') (SPair5 t b p) = addpair (SPair5 x x Refly') (SPair5 (S t) (S b) (convert4 p))
addpair (SPair5 x (S y) (Succy' z)) (SPair5 t b p) = addpair (SPair5 x y z) (SPair5 t (S b) (Succy' p))
--addpair (SPair5 t (S b) (Succy' x)) (SPair5 k s y) = addpair (SPair5 t b x) (SPair5 k (S s) (Succy' y))
convert : (t : Nat) -> (s : Nat) -> InEq' t (s + t)
convert t Z = Refly'
convert t (S k) = Succy' (convert t k)
convert2 : (s : Nat) -> InEq' 0 (plus s 0)
convert2 s = convert Z s
--convert3 : InEq' 0 (plus s 0) -> InEq' 0 s
--convert3 p = replace ?sda ?sdf
convert3 : (s : Nat) -> InEq' 0 s
convert3 s = replace (plusZeroRightNeutral s) (convert2 s)
incrementpair : OPair5 -> OPair5
incrementpair (SPair5 x y z) = SPair5 (S x) (S y) (convert4 z)
sortpair : (Nat,Nat) -> OPair5
sortpair (Z, Z) = SPair5 Z Z Refly'
sortpair (Z, y) = SPair5 Z y (convert3 y)
sortpair (y, Z) = sortpair (Z, y)
sortpair (S x, S y) = incrementpair (sortpair (x,y))
--sortpair (S x, S y) = addpair (SPair5 1 1 Refly') (sortpair (x,y))
--addpair (SPair5 x x Refly') (SPair5 x2 y2 p) = (SPair5 (x2+x) (y2+x) p)
--addpair (SPair5 x (S y) (Succy' p1)) (SPair5 x2 y2 p) = addpair (SPair5 x y p1) (SPair5 x2 (S y2) (Succy' p1))
{-
natToInEq : Nat -> InEq' Z t
natToInEq Z = Refly'
notToIneq (S x) = Succy' (natToInEq x)
maybeOPair : Nat -> Nat -> Maybe OPair5
maybeOPair a b = if (a <= b) then Just (SPair5 a b (natToInEq (b-a)))else Nothing
-- sortpair is a better maybepair. maybepair could be implemented
-}

I have been aware of machine learning projects that use RSSI (signal strength) (for example, try typing iwconfig in a linux terminal. You can grep that for signal strength.)

CSI (channel state information) is more though. Uses alternative firmware. Gets you phase sensitivity.

Eventually I apt get installed libuhd-dev which makes gqrx run now with an rtl-sdr

gqrx with line

soapy=0,driver=lime

should work but didn’t

Hmm another twist

Limesdr is power hungry

I may not have a usb3 port on my 2012 desktop insane as that sounds

so i need external power? I wonder if that is what the blinking led signifies

Trying to install in windows now. Maybe that will work better

Install PothosSDR

After running zadig can recognize an rtl-sdr in gqrx

https://wiki.myriadrf.org/Lime_Suite#USB_driver

Install the drivers as specified for limesdr.

I accidentally installed the x86 instead of the x64 drivers and needed to uninstall with deletion and then reinstall properly. Got error code 48

It appears to be working.

https://wiki.myriadrf.org/LimeSDR-USB_Quick_Test

GQRX opens.

It has been months since I tried in ubuntu 16.04. Maybe things have gotten better.

ok. At first gqrx wouldn’t load but after fiddling with the sampling and bandwidth it does. I don’t get any FM signals with nothing attached to the Lime. That is either good or bad. It does appear to be receiving data at least though.

So I have not gotten gqrx to actually receive signals with limesdr, but gnuradio appears to be working to some degree. This graph plays audio on 101.5 although very crappily. I hope it just needs filtering (I think I should be low passing those resamplers. Also I probably shouldn’t be receiving on the middle of the band where the DC spike is). I doubled the resampler because a single resampler through an error for too much decimation. Is this standard procedure?

Dang. I’m pretty impressed. With a bad calibration file and no tuning, it works ok in short term. Blur clearly seems like an issue.

The contents of the example yaml config

%YAML:1.0
#--------------------------------------------------------------------------------------------
# Camera Parameters. Adjust them!
#--------------------------------------------------------------------------------------------
# Camera calibration and distortion parameters (OpenCV)
Camera.fx: 517.306408
Camera.fy: 516.469215
Camera.cx: 318.643040
Camera.cy: 255.313989
Camera.k1: 0.262383
Camera.k2: -0.953104
Camera.p1: -0.005358
Camera.p2: 0.002628
Camera.k3: 1.163314
# Camera frames per second
Camera.fps: 30.0
# Color order of the images (0: BGR, 1: RGB. It is ignored if images are grayscale)
Camera.RGB: 1
#--------------------------------------------------------------------------------------------
# ORB Parameters
#--------------------------------------------------------------------------------------------
# ORB Extractor: Number of features per image
ORBextractor.nFeatures: 1000
# ORB Extractor: Scale factor between levels in the scale pyramid
ORBextractor.scaleFactor: 1.2
# ORB Extractor: Number of levels in the scale pyramid
ORBextractor.nLevels: 8
# ORB Extractor: Fast threshold
# Image is divided in a grid. At each cell FAST are extracted imposing a minimum response.
# Firstly we impose iniThFAST. If no corners are detected we impose a lower value minThFAST
# You can lower these values if your images have low contrast
ORBextractor.iniThFAST: 20
ORBextractor.minThFAST: 7
#--------------------------------------------------------------------------------------------
# Viewer Parameters
#--------------------------------------------------------------------------------------------
Viewer.KeyFrameSize: 0.05
Viewer.KeyFrameLineWidth: 1
Viewer.GraphLineWidth: 0.9
Viewer.PointSize:2
Viewer.CameraSize: 0.08
Viewer.CameraLineWidth: 3
Viewer.ViewpointX: 0
Viewer.ViewpointY: -0.7
Viewer.ViewpointZ: -1.8
Viewer.ViewpointF: 500

Other things to consider LSD-SLAM

SVO

DSO

Actually, many people are recommending svo and dso saying orb_slam while the better behaving one, works poorly on the pi