medhelp sleep graph replacement using python

In other words, graphing time of day versus date in python.

This morning I logged on to only to see that it had gone from somewhat usable for my purposes:

from my previous post,

where I can at least type in the times to some extent, even if there is no batch input (e.g. uploading a text file), to

wtf is this? i am clearly not in their target demographic…

So I decided to get up off my lazy butt and do some python plotting.

This is the end result:

(it’s flipped, so time increases going upward like you would expect a graph to do but opposite of how you would read the medhelp graph, where time increases going downwards, which I feel makes more intuitive sense).

The code is here:

I keep track of my sleep in a google doc that I just downloaded as a csv file. See the github repo.


brain/linkdump as i was working out how to do this

can set line width but the plot does not adjust to this (how to pad the dates out so the lines won’t ever overlap?)

unix time

bar plot
 now just need to adjust so not height, but also have start time

x = ‘3/18/2013’

x = 1365739200
# datetime.datetime(2013, 4, 12, 0, 0)
dates.DateFormatter(‘%B %d, %Y’) # January 16, 1970
okay, this solves the y-axis problem! excellent.
In particular,genfromtxt is able to take missing data into account, when other faster and simpler functions like loadtxt cannot

does not deal well with quotation marks in data
“Line #31 (got 8 columns instead of 7)”

24:00 –> 0:00:00 else

ValueError: time data '3/18/2013 24:00:00' does not match format '%m/%d/%Y %H:%M:%S'

also does not like 0 instead of 0:00:00

acrylic bracelets, lasercut cards, red bull contest

acrylic bracelets

I woke up early one day and tested this instructables before class:

I was tempted to skip class and lasercut things, but I did not! (It’s an music theory 101 class, 21M.301, that I’m listening in on and am completely lost in at this point).

The first one I cut was about 8.5” x 2” and I made it in coreldraw. I wanted to put a hexapod in the middle but couldn’t find a png at the time.

Here are the lasercutter settings I used for a epilog 120w lasercutter to cut/engrave 3mm acrylic:
600 dpi, vector
cut: 25 speed 100 power
engrave (the words): 70 speed 30 power

The narwhal refused to cut as a vector so it’s not in the bracelet (I selected bracelet only).

cut it out of transparent acrylic (shown here with the paper covering not peeled off yet)
So actually the pointy tip snapped off when I was bending it. I made a too-tight radius so this actually helped allow the bracelet to be wearable because I can slip my wrist through the crack. The next time around, though, I made sure to start bending at the pointy end first. This step just requires patience, aim the heat gun, wait a minute, and then the acrylic should be super bendy, at which point I can move the gun up the acrylic and press down all the while to get a nice curve. And then having the patient to wait for it to cool while holding it in place.
I also learned to bend it on a clean surface as the hot acrylic picked up all the gunk on the mat.
I was also too hasty in putting this on to check whether it would go on or not and ended up with a small burn. So… be careful. Hopefully this doesn’t scar like the forging-iron-chopsticks one (which is actually pretty faded from two years ago).
I did a second one which was closer to 9” long.
This one retained the corner, but is also bent too tight. It is extremely hard to put on and actually took off skin.

I didn’t know what to put so here is a cheery message:

Ignore the black spraypaint, I was stenciling.

lasercut cards

I finished up my lasercut birthday gift to cathy wu after two weeks -__-;;; with a lasercut card. She likes giraffes so I borrowed an image from the internet (see image below for source link).
Lasercutter settings for construction paper: 600dpi vector, 100 speed 5 power (120w epilog).
materials used:
about that awesome spray-on adhesive, yea fail, I used too much and then placed it incorrectly so had to redo
I ended up using which has a free version.
some finishing touches with a razor were required, and I used tape to pick up the stencils which you can see didn’t all come out cleanly:
I think it turned out well. @__@ I hope +Cathy Wu likes it.

red bull competition

I’m probably not entering, but they sent me free LED stuff to play with. I thought their theme was micro or nano or something so I was excited, because I thought they would send me something related to diy nano but I guess not.
Interesting box design (this came inside an actual shipping box):
looks like they contracted out to a company that makes lasercut things, and that this is meant to be wall-hang-able:

projects-in-progress snapshot

  1. hexacon
    Hexapod conference funded by deFlorez humor fund! Been doing a lot of work refining the vision of the conference/convention and how to make it humorous and yet useful to attend at the same time.

    It will be like academic conference – hexapod dance off – giant hexapods – poster session and the humor will come out of the contrast.


  2. servo arm drawbot for starttroll project / graduation cap
    Delta robot face drawing:

    The lifecycle goes like this:
    – Pick a picture from the Android photo album
    – Run a Canny edge-finder on it to get to a black bitmap with white lines on the edges of the original picture. I used a splendid implementation by Tom Gibara– Run a vectoriser on that, to generate vectors along those lines. I couldn’t find one I liked, so I write one, which was easier that I expected.
    – Simplify the vectors – discard very short vectors, and replace straightish bits with straight lines. The Arduino can only store 300 points, so we have a strong incentive to optimise the vectors to within an inch of their lives.
    – Package the vectors up and send them over Bluetooth to the Arduino
    – Wait for the drawing ! 

    For speed, I’m working with very low-resolution bitmaps – 128 pixels square by default.
    vectorizing linked to in
    Actual vectoriser code used in sketchy is in TODO: read over and understand this code.

    canny edge detection implementation in processing

  3. scooter: CAD and order parts. have: shady chinese ebay controller, melon motor, brakes. need: battery pack, trigger, front lights
  4. POV yoyo: 
    1. 3d print prototype, etch out circuitboard and populate, begin programming anew
    2. CAD and masterCAM the injection-molded yoyo files
    3. spec out parts list cost for 50
  5. EL wire choreography arts proposal: only missing a budget
  6. MITERS door open trigger: awaiting parts from atw
    • post MITERS flyers in pappalardo!
  7. jewelry
  8. pika housing application
    • perhaps visit pika for dinner
  9. documentary
  10. feelers about filming (hey, 10k is enough to sustain my startproject for a while… apparently it is good publicity too)
  11. hexapod
    give it an new body, make it dance, …
    hexarideablepod is on permanent hiatus (how to dispose of it? I need to fix it up a bit before disposing of it, I feel)
  12. 2.007
    document hall sensor with circuit picture
    lasercutter pdf
    intro to arduino pdf (where to find resources)

MIT student discounts, things to do around boston, braindump

As MIT college students we can get a $5 college card for the boston symphony and get into concerts for no additional cost.

These cards are for from September to May 4th  (and May 2, May 3 are blackout days so literally until May 1st).
and the performances list:
  1. go to copytech in building 11, show them student ID, pay $5 for college card
  2. go to boston symphony orchestra ticket office, right down mass ave @ 301 mass ave, show them college card and student id and get ticket
  3. go to concert
    and then a whole list of inexpensive things to do here:
    * Fells, USS constitution, coit observatory, freedom trail (3 hrs).

    the Arnold Arboretum is very pleasant and can be accessed by T.
    And the Mount Auburn Cemetary is about a half hour walk from Harvard, but certainly worth it.  
    As MIT students we also get student discounts to the MFA and the institute for contemporary art, the Isabella Garden (probably a spring/summer thing?) and I think to the museum of science.
    Other student discounts:
    There’s also lots of events at MIT


    according to a professor on the airplane from ATL to BOS, things to do for free or close to free:
    Hatched eggshell concerts, Wednesdays
    Boston Harbor Hotel movies, Thursdays (buy a drink something to sit there)
    North End will close streets and have festival Fridays in August
    Museum of Fine Arts is free on Wednesdays

    less free –v
    Harbor Island Beach recommended (to see Boston from another view)
    go to wonderland, get fried clams and people watch
    fly kites at reviere beach
    go to concord, ma via commuter rail and visit walden pond
    boston public library at lunchtime — there are sometimes famous poets/musicians in the courtyard
    food trucks at south station are the best after a bike ride there

    gamibots, pager motors, soccerballcopters, things from ebay / china

    been spending money lately
    mixed feelings ’bout my consumerism of things i feel like i might only use once or twice but i tell myself it’s research πŸ˜›


    based on
    these are super cool because you use a business card instead of a toothbrush, i have twenty extra business cards but not twenty toothbrushes and it’d be a shame to buy new toothbrushes just to chop off their heads

    all it needs is a business card, tape, a pager motor, and a battery πŸ™‚ so cute.
    pager motor placement affect movement a lot, e.g. I changed the placement a bit and this one moves faster and more forwards than sideways

    anyway, to start this story off, i am co-teaching a few lessons in 4th grade for my d-lab education class. and last year when we went to China+Cathy Wu bought a bunch of pager motors in preparation for making swarmbots. I then bought a couple dozen off of her this year in preparation for bristlebots but then realized I needed to solder leads to them. The type she bought is to the right in this picture:

    I tried soldering wires onto the tiny motors (they are about 1cm long) and promptly desoldered the metal leads from motor. Well, crap.

    Anyway, I ordered some pager motors off of ebay for 84 cents each and they arrived eight days from ordering from China. I expected it to take three weeks so it was a pleasant surprise. (Well, I bought from two sellers and the other packaged arrived in 10 days).

    that’s a bag of 30 motors! i could fit them in wallet. they come with pre-formatted messages. I wonder if these two are actually the same seller.
    From two different ebay sellers:
    “10pcs Pager and Cell Phone Vibrating Micro Motor 2.5V-4.0VDC With Two Leads s883”
    x3 = 23.63 for 30, or 0.79 each. Arrived in 10 days
    x1 = 8.36 for 10, or 0.84 each. Arrived in 8 days.
    I emailed them to check there were two wires coming off of them and got a pretty prompt response.
    and i get reimbursed for these, so yay ^__^
    Note in particular that these are from Shanghai and not Shenzhen. According to Amy, who travels to China for work a lot, and Star

    I found better “hard hardware” streets in Shanghai TBH, & don’t remember seeing tons of motors in SZ.

    Yup, I think you are right. SEG looks like the place to go for electronics, but Shanghai had way more mechanical stuff. It was a fun visit, though!


    In other news I am playing poking at copters a bit for the lulz. (I have been spending more money ever since making decent money at fitbit last summer… no regrets! i think)

    “Pro 6042 Flying Ball Scientific 3CH R/C UFO Remote Control Gyro LED Helicopter”
    22.91 + 1.6 shipping
    bought 3/26 arrived 4/4 (nine days)

    all that it needed was 6 AA batteries and it even comes with two props. super cute. fits in palm.
    and it flies!
    uhm, I thought this would be totally harmless because it is so tiny. and it pretty much is, but i was surprised because it has a decent bite just crashing into you (i thought the soccerball shape would protect me from the props)

    things from ebay/china

    in another post some day, crazy cheap and awesome robots (even hexapods!) from taobao, the swarmbot entry for $10 robot competition, and cost reduction due to scaling analysis.

    Also, can we just take a moment and reflect how amazing it is that I can get a functioning flying thing complete with wireless control shipping to be from China for a total of $25 USD? That’s like 1.5 arduinos without batteries or anything at all. Mass manufacturing is awesome.

    servo arm now drawing things with inverse kinematics

    you can see some of the error modes i was encountering in the ^ shaped “straight line” where theta1 was clipping out because I was feeding it negative values based on my inverse kinematics calculated angles

    i blame servo jitter for how shaky the lines are πŸ™‚

    this took forever and a heaping bowlful of confusion to get to where i am. actually i’m still confused. but basically i spent all day sunday working on this, emailed out to MITERS, and finally a hallmate, pranjal, helped me out ( today and fixed where I was stuck at in an hour or two.

    essentially he rewrote the code in python (I was actually starting to do this) to graph and understand what was going on. For instance, the bottom-most image is the working envelope of the robot arm;

    Isn’t that fascinating? It’s like a  yin yang. If you play around with the servo arm this sort of working envelope makes sense.

    So turns out my code was decently fine, the negative values just meant I was giving it bad inputs that it physically couldn’t reach given the arm link lengths I’d given it.

    We initially tried to wrap the negative values around by doing mod180 ‘ing it,
     theta1 = ((int)theta1+180)%180
    but this gives the sort of trajectory shown in the upper image
    (I think… it may also be that elbowup needs to be false to generate that sort of trajectory)

    setting elbowup to be true fixed a lot of issues to (which makes sense physically as more x,y coordinates can be reached if the elbow is up rather than down, it’s  easy to see if you play around with it … see the inverse kinematics chapter on if this elbowup/down stuff is coming out of nowhere — basically there are two combinations of theta 1 and theta 2 that will work for any given x,y coordinate and you just pick whether you want the elbow up or down solution)

    and finally the working enveloped helped me pick correct x,y values to feed it. Initially I was just basing my x,y values off of the instructables but scaled down 1/3, which was just a guess of mine based on my servo joint limitations versus her motor joint limitations

    it is also surprisingly close to the dimensions in mm I give it, eg.

    double highY = 80; // line drawing targets in mm

    double lowY = 20;

    double staticX = 20;

    will give me a line about 60 mm long (I put the link lengths in as mm), which is exciting.

    I’m still not sure what’s going on with why the straight line up and down is at a 45degree angle, but that’s probably a constant offset problem. Fixable either in code or if I set the initial conditions on the angle the links are mounted on the servos better.

    Next: faces?

    eyeglasses fixed with composites

    earlier I posted about broken eyeglass frames (and was investigating TIG welding titanium).
    they are fixed now, yay! courtesy of nick, some [edit 4/1/13 actually it is brown cotton thread], and some superglue (yay composites)
    the secret is I actually have broken two pairs of glasses this term. @__@ these broke…well were the tiny screws are normally

    the excellent thing about this is that it’s barely visible from the front.

    i still intend to fix the other frame, but now it’s super low on the priority list so…

    you know, I think I have a more hesitant attitude toward the word startup (at least, as applied to my own project) than even general MITERS. I can’t figure it out, except that for some reason I want to prove that I am being semi-realistic and not embellishing. It’s not so much an allergic reaction to the idea of people working on something they have a crazy vision about as a hesitancy, especially after my experience with the concept to company IAP accelerator by startlabs, to label myself as working on a startup until I’ve reached some degree of success.