About flying cars

About three years ago I spent a lot of time thinking about this. Recently Elon Musk has spoken about flying cars.

So now seems a good time to publish this. It’s long, and it’s half-baked. I decided I had too much else on my plate, so I dropped it. Anyone who wants to pick this up and run with it – go for it!

TLDR: Flying cars must be safe and cheapThe way to do that is automation and redundancy.

Redundant systems make things cheap because (a) they don’t have to be highly reliable (as do conventional aviation components), and (b) more units means mass-production prices. Redundant brushless electric motors driving simple fixed-pitch props are the solution.

Here’s how.  (PDF version is here; 37 pages. PDF doesn’t have the crappy CSS formatting…)

1   The vision

“Liftoff”

You step into your vehicle and settle into your seat as you say “liftoff”.

Your voice is recognized as that of an authorized user – the vehicle actually belongs to your wife.  There’s a quiet click as the charging plug automatically retracts into its compartment, then 100 thrusters –  near-silent electric motors, each with a small fixed-pitch propeller – spin up all around the vehicle.  Over a few seconds, they gradually take up the weight of the vehicle with you in it.

As they do, the vehicle determines the total takeoff weight by measuring how much power it needs to send to the motors to lift you off the ground.  It checks that all the motors are supplying the expected amount of thrust and are running smoothly and in balance.

Oh no – it discovers that 2 of the 100 thrusters are producing less thrust than they should, one is producing no thrust at all, and a fourth is wobbling, probably due to a chipped prop or loose mounting bolts.  It shuts down all four, noting the problems with each one in its maintenance log.  (You meant to replace a couple of those, but things have been busy.)

96 out of 100 motors in good condition is still within the “green” zone for safe flight[1] and the batteries have enough charge, so the vehicle rises vertically toward it’s default hover height, 50 meters above the ground.  It automatically maintains its balance, rising level and straight, directing a little extra power to the motors near the 4 failed units.

You stretch out, putting your feet up and opening your magazine.  The vehicle senses the beginnings of the tilt as you lean backwards (moving the center of gravity), and shifts some of the thrust that way to compensate.

20 meters up, you rise above the treetops and the gusty wind pushes on the vehicle, but you barely notice because the vehicle’s gyro sensors and accelerometers, together with the GPS receiver, sense the movement caused by the wind.  Power is shifted to the opposite side as needed to keep you rising straight above your parking spot.

To the garden

You’re looking forward to your lunch at the rooftop restaurant (convenient free parking!).  Normally, you’d just tell the vehicle “take me to Fred’s” and let it do the flying for you[2], but it’s a beautiful sunny day and you feel like a quick look at the progress with the cactus-planting at the little garden you designed for the parks department to replace the old freeway interchange, so you lean forward and grab the control knob.

It’s a stubby rubber knob an inch high, that hardly moves at all.  You give it a gentle twist to the left against its internal spring, and the vehicle yaws the same way, slightly increasing the speed of the clockwise-turning props and decreasing the speed of the counter-clockwise props, to torque the vehicle around.   As those ugly apartment buildings across the river come into view, you let go of the knob.  It returns to its neutral position and the vehicle stops turning.  Then you press the knob forward and the vehicle tilts the same way, shifting a little power to the back and moving forward[3].  The vehicle holds it’s altitude and attitude as it moves toward the gap between the buildings.

Your phone rings.  You click the “hold” button on the knob and let go of the knob, reaching for the phone in your pocket.  The vehicle keeps going exactly on the course and speed you had it.

It’s your business partner, who is going to meet you for lunch.  She’s wrapping up the design for the playground, due to the client this afternoon.  Should the water slide empty into the duck pond or the mud bath?  The client left it up to you.  You find the alternative versions of the plans and stare at each, trying to decide – she can’t leave for lunch until this is done.

While your head is buried in the plans, the vehicle has been flying toward the apartment buildings.  You didn’t really aim it very well – you meant to go through the gap, but it’s a small gap and a ways off.  On the course you set, the vehicle would collide with the larger building in a few seconds. Read the rest of this entry »

A big number

I’ve been reading Edward Teller’s autobiography.

In a footnote (p. 247), Teller mentions that “the electron in a hydrogen atom will eventually jump to a proton if it is close enough”.

Teller and Francis Owen Rice calculated how long it would take, if the proton is 1 centimeter away.

Their answer was 10100,000,000.

A long time. A “big number”.

 

That’s the same as 10108, which is more than a googol (10100), but much less than a googolplex (1010100).

 

What’s that? You want to know what units?

You mean is the 10100,000,000 in Planck times (5.4 x 10-44 seconds), or seconds, or years, or time periods since the Big Bang?

Doesn’t matter. (Think about it.)

That’s how big a number it is.

Flatten files in a folder hierarchy

Have you ever had a huge complicated folder tree with thousands of files buried layers deep in folders-within-folders?

And wanted to flatten them out so all the files are in a single folder, but without filename collisions (that is, lots of files with the same name)?

I did. The closest thing I could find off-the-shelf was this, so I wrote the Python script below.

I hope it’s helpful to someone.

To run it (assuming you have Python installed – you’ll need Python 3 in case some of your pathnames have Unicode characters), do this:

python flatten.py [root folder to be flattened] DOIT

If you leave off “DOIT” (all caps), then it will simulate what it’s going to do, without actually doing anything.

The way it works is by copying all the files to the root folder, renaming them with the original path to the file, but substituting “¦” for the “/” or “\” (Windows, Unix respectively).

So if you have (using the example from the link above) this inside “Folder0″:

Folder0 
          Folder1 
                    File1.1.txt 
                    File1.2.txt 
                    FolderA 
                              FileA.txt 
                    FolderB 
                              FileB.1.txt 
                              FileB.2.txt 
          Folder2 
                    FolderC 
                              FileC.txt

Then doing:

python flatten.py c:\path\to\Folder0 DOIT

Gets you these six files inside Folder0:

Folder1¦File1.1.txt
Folder1¦File1.2.txt
Folder1¦FolderA¦FileA.txt
Folder1¦FolderB¦FileB.1.txt
Folder1¦FolderB¦FileB.2.txt
Folder2¦FolderC¦FileC.txt

Enjoy, and if you make improvements, please post a comment here.

# -*- coding: utf-8 -*-
# for Python3 (needs Unicode)

import os, shutil, sys

def splitPath(p):
    """Returns a list of folder names in path to p

    From user1556435 at http://stackoverflow.com/questions/3167154/how-to-split-a-dos-path-into-its-components-in-python"""
    a,b = os.path.split(p)
    return (splitPath(a) if len(a) and len(b) else []) + [b]

def safeprint(s):
    """This is needed to prevent the Windows console (command line) from choking on Unicode characters in paths.
    
    From Giampaolo Rodolà at http://stackoverflow.com/questions/5419/python-unicode-and-the-windows-console"""
    try:
        print(s)
    except UnicodeEncodeError:
        if sys.version_info >= (3,):
            print(s.encode('utf8').decode(sys.stdout.encoding))
        else:
            print(s.encode('utf8'))

def flatten(root, doit):
    """Flattens a directory by moving all nested files up to the root and renaming uniquely based on the original path.

    Converts all occurances of "SEP" to "REPL" in names (this allows un-flatting later, but at the cost of the replacement).
    
    If doit is True, does action; otherwise just simulates.
    
    """
    
    SEP  = "¦"
    REPL = "?"

    folderCount = 0
    fileCount = 0

    if not doit:
        print("Simulating:")

    for path, dirs, files in os.walk(root, topdown=False):

        if path != root:

            for f in files:

                sp = splitPath(path)

                np = ""

                for element in sp[1:]:
                    e2 = element.replace(SEP, REPL)
                    np += e2 + SEP

                f2 = f.replace(SEP, REPL)
                newName = np + f2

                safeprint("Moved:   "+ newName )
                if doit:
                    shutil.move(os.path.join(path, f), os.path.join(root, newName))
                fileCount += 1

            safeprint("Removed: "+ path)
            if doit:
                os.rmdir(path)
            folderCount += 1

    if doit:
        print("Done.")        
    else:
        print("Simulation complete.")


    print("Moved files:", fileCount)
    print("Removed folders:", folderCount)

"""

if __name__ == "__main__":
    print("")

    print("Flatten v1.00 (c) 2014 Nerdfever.com")
    print("Use and modification permitted without limit; credit to NerdFever.com requested.")

    if len(sys.argv) < 2:
        print("Flattens all files in a path recursively, moving them all to the")
        print("root folder, renaming based on the path to the original folder.")
        print("Removes all now-empty subfolders of the given path.")
        print("")
        print("Syntax: flatten [path] [DOIT]")
        print("")
        print("The DOIT parameter makes flatten do the action; without it the action is only simualted.")
        print("Examples:")
        print("  flatten //machine/path/foo          Simulates flattening all contents of the given path")
        print("  flatten //machine/path/bar DOIT     Actually flattens given path")
    else:
        if len(sys.argv) == 3 and sys.argv[2] == "DOIT":
            flatten(sys.argv[1], True)
        else:
            flatten(sys.argv[1], False)

Hewlett Packard > Agilent > Keysight … WTF?

What a way to ruin a great brand. For no apparent reason at all.

They could have called it “Pewlett Hackard”. Heck, they could have called it “Tektronix”. (Those guys in Beaverton seem to have no use for that name anymore.)

The monkeys are running the henhouse. (Or, um, something like that.)



Oh, and…get off my lawn!

Saleae Logic Analyzer

I’ve had this thing in my drawer for 2 years; just got to use it for the first time yesterday.

It’s fantastic – really worth $150.

Saleae Logic Analyzer

Saleae Logic Analyzer

Now they have new versions that do analog, too (low-bandwidth, tho).

The nice thing about the Saleae thing is the software – it’s really amazingly simple and effective (you can download a demo from their website without the hardware).

I’ve used other logic analyzers – this is miles ahead. (Also way, way, better than the protocol decode on my new Rigol DS2072A DSO.)

https://www.saleae.com/logic

[No, they didn’t pay me anything to write this.]

Directions

My 11-year-old son asked me last night if there was an East Pole or West Pole.

I told him he should be able to figure that out for himself; I asked him the leading question “what is the definition of East?”.

It didn’t go well. Then he asked if it would be different on Mars if Mars was “upside down” compared to the Earth. That didn’t go well either – severe conflict of mental models.

They don’t teach geography (or in this case perhaps astronomy) very clearly in school.

But then dictionaries have huge trouble with this, too.

Here are my definitions:

East: The direction in which the Earth (or any planet) spins.

West: The direction opposite to East.

North: The direction 90 degrees to the left of East.

South: The direction 90 degrees to the right of East.

Compare that with any dictionary you like.

 

How to see a Google-shared location on the desktop

If somebody is sharing their location with you via Google, there is a way to see their location on a desktop. Most people seem to think you can only see the location on an Android or iOS device, but you can see it on any web browser.

Go to Google+, and search on the name of the person you’re trying to find. This will take you to their Google+ home page.

Look on the top left, just below their picture and name, and above the list of circles the person is in, number of followers, etc.

The last line of the little summary about the person (“Works at…”) is:

Currently in <place>.

Click on the <place>. It will take you to a Google Maps page with a pin showing their current location.

This works as of this posting (June 2014). It’s very obscure and hard to find – I expect Google will eventually rework the user interface to make it easier to find.

HowTo3

 

Numpy == goodness! (deinterlacing video in Numpy)

A few posts back I was trying to get Linux to record and play video at the same time.

I gave up on that, but got it working under Windows with Python; I’ll post the source for that here at some point.

A big part of the solution was OpenCV, PyGame and Numpy.

I’m hardly the first to say it, but I’m excited – Numpy is goodness!

My (stupid) video capture device grabs both interlaced fields of SDTV and composes them into a single frame. So instead of getting clean 720×240 at 60 Hz (sampling every other line, interlaced), you get 720×480 at 30 Hz with horrible herringbone interlace artifacts if there is any movement in the scene.

The artifacts were really annoying, so I found a way to get Numpy to copy all the even numbered lines on top of the odd numbered lines to get rid of the interlace artifacts:

img[1::2] = img[::2]

That’s it – one line of code. And it’s fast (machine speed)! My laptop does it easily in real time. And I learned enough to do it after just 20 minutes reading the Numpy tutorial.

Then, I decided I could do better – instead of just doubling the even lines, I could interpolate between them to produce the odd-numbered lines as the average of the even-numbered lines (above and below):

img[1:-1:2] = img[0:-2:2]/2 + img[2::2]/2

It works great! Numpy == goodness!

 


PS: Yes, I know I’m still throwing away half the information (the odd numbered lines); if you know a better way, please post a comment. Also, I’d like to record audio too, but OpenCV doesn’t seem to support that – if I get that working, I’ll post here.

Prime Telephoto + Tiny Sensor = Super telephoto?

Sometimes I get an idea in my head and just can’t get it out.

Modern digital cameras often have tiny sensors compared to 35mm film.

High-quality 1970s “prime” 35mm lenses had a reputation for being very sharp.

When one of those lenses is mounted on a small-sensor camera, the sensor covers only a tiny central region of the 35mm-sized image formed by the lens – essentially the sensor is cropping from the middle of the image, resulting in a telephoto effect.

This gives rise to the “crop factor” of small sensor cameras – at a given focal length, the field of view of the small sensor is much smaller (more “zoomed in”) than on the original 35mm film the lens was designed for.

What, I wondered, would images from a high-quality 1970s prime 35mm lens mounted on a modern small-sensor camera look like? Especially, could I get super-telephoto effects by mounting lenses that were considered long (telephoto) by 35mm standards, multiplied the “crop factor”?

I had to try it.

35mm film frame vs Pentax Q sensor

35mm film frame vs Pentax Q sensor

Above is a diagram showing the relative sizes of a 35mm film frame compared to the 1/2.3″ sensor in the Pentax Q.

The Q has the smallest sensor of any interchangeable lens camera I know of. While this may make it – ahem – less than ideal for general photography purposes (altho to be fair the latest versions of the Q have moved to a larger 1/1.7″ sensor, a huge improvement), that little 6.17 x 4.55 mm sensor does have an immense “crop factor” of 5.6x (comparing effective field of view at the same focal length – the number isn’t exact because the Q’s sensor has a 4:3 aspect ratio, while 35mm film is 3:2).

Off-topic, but other points in favor of the Q are the tiny flange focal distance of 9.2mm – it can mount just about any lens ever made – and Pentax’s excellent UI. I’m not sure there’s a mass market for a camera like this, but it sure can do some things that no other camera can.

So, while a “normal” 50mm lens on a 35mm camera has a 39.6 degree field of view (horizontal), the same lens on the Q sees only 7.1 degrees.

And – here’s the neat thing – a “telephoto” 200mm lens on a 35mm camera sees 10.3 degrees – but on the Q, only 1.8 degrees. That’s the equivalent of an immense 1120 mm lens in 35mm format. And a super-telephoto 500 mm lens sees just 0.71 degrees on the Q – equivalent to 2800 mm on 35mm.

So, I tried it. I got some Minolta MD/MC type prime (non-zoom) lenses on eBay, mainly because they have an excellent reputation and are a bit cheaper than other brands (because they don’t fit many modern cameras), and an adapter for the Q (also on eBay – remember I said the Q can mount almost anything?).

Here’s what I ended up with:

Lenses tested

Lenses tested

Left to right:

  • Minolta 50mm f/1.7 MD Rokkor-X PF
  • Minolta 135mm f/3.5 MD Celtic
  • Minolta 200mm f/4.5 MC Tele-Rokkor  PE
  • Minolta 500mm f/8 RF Rokkor-X

From what I can tell online, these are all highly-regarded lenses. The “Celtic” line was Minolta’s cheaper brand, but it seems the economy came from using cheaper materials in the mount, etc. – supposedly it is optically identical the to more expensive “Rokkor” line. And of course, these are all primes – not zooms. Even today primes are generally sharper than zooms; this was even more true in the 1970s before improved manufacturing and computerized optical design.

In the second row you see the Pentax Q with a Tamron 3.5-8mm zoom f/1.8 lens in CS mount, via a “Hawk’s Factory” CS mount adapter (I told you the Q can mount most anything…), and the Minolta MD-to-Pentax Q adapter (just a hunk of metal – no glass).
Read the rest of this entry »

CreepAway

Back in 1996 I had an idea I called the “CreepAway”.

It was a device that would screen your phone calls – it would auto-answer (blocking the local ring), and then ask the caller to “Enter Extension Number” (really a password).

If the caller entered the correct password, it would ring the phone so you can answer.

If they didn’t, the caller would be sent to voicemail.

The idea is that you give both your phone number and your “extension” to your friends – they dial your number, enter your “extension”, and the phone rings.

Telemarketers and others calling at random only get to leave a voicemail.

I think this would be easy to do today with an Android app.

I’m sick and tired of getting robocalls offering me legal help with my (non-existent) IRS debt.

Somebody please build this.


Update, 2013-12:

I recently realized that not only would this be easy to do in an Android or iOS app (intercept the incoming call at the API level, assuming those APIs are exposed), but there’s an even simpler way.

Do it as a service.

Your phone company (Vonage, Google Voice, the PTT, whatever) would provide you with two numbers – a public one (to be given out) and a private one (known only to the phone company).

When people call the public number, the service provider (phone company) would prompt for the extension (or password, whatever). If the caller gives the correct one, the call is forwarded to your private number. If not, to voicemail.

That’s it. It would be trivial to implement in a modern SIP or H.323 based phone system. And they could charge for the service.

Hey – somebody – DO THIS.