Adam's Blog
×

myo.js Explorations

Sunday November 20, 2016
Category: uncategorized

In the past I have endeavored to work with things that I like. Right now my two favourites are flocking.js, MYO. In particular, I have been very happy to get back into node.js and taking a look at the myo.js bindings.

The basic demos work well but I have two myos, so it would be great to address each separately. The API provides a Myo object that keeps an array of all of the myos connected at the time. Most of the demo code uses the Myo.on('connect, function(){}; to check the array and then keep track of the left and right arm (which is how I want to use them and how I expect most people to use them too).

The problem is that when you check the myo objects once they have connected a lot of their parameters are not set:

 [ { macAddress: 'f3-c6-21-d0-98-b3',
name: 'Adam Tindale\'s Myo',
connectIndex: 0,
locked: true,
connected: true,
synced: false,
batteryLevel: 0,
lastIMU: undefined,
arm: undefined,
direction: undefined,
warmupState: undefined,
orientationOffset: { x: 0, y: 0, z: 0, w: 1 },
events: [],
connectVersion: '1.5.1970.2' } ]

In order to get these parameters I waited for the unlock event and then checked the calling object for its arm parameter. I have two references for specific myos leftMyo and rightMyo that I check to see if they are undefined. If they aren't then I check the calling object using this in order find its arm parameter. I assign the object to my references and then inititialize the listeners at that point. If you do it before you define the objects then javascript rightly complains that you are trying to put listeners on undefined objects (because they obviously aren't yet defined).

Here is an example I whipped up of a basic two handed myo.js that sends OSC messages using osc.js.

Tour de Terra Cotta 2015

Monday August 03, 2015
Category: Uncategorized

This week has been a bit funny on the bike. Flats, flats, and more flats. I woke up this morning and got ready but when I went to load my bike the rear tire was deflated. I pumped up the tire and heard the dreaded hiss. I changed the tire and the tube and got it installed. We piled into the car to head out a bit late. About half way to the race I realized that I had forgotten my water bottle on the counter. I had a gel, but no water, so I drank a bit of water in the car and prepared to be a little dry. I figured it was a shorter race, so I should be ok. Katherine suggested I just look around to buy a water bottle. I was going to get there just in time to register and make a quick trip around.

We got to the grounds and I found a Skratch Labs tent. I explained my sob story and they gave me a bottle with the mix I had planned to be drinking. I joked that if I won I'd let them know... I knew that I wanted to win but bike races are prickly things. I got out to find the start and hopefully get a few minutes of warmup in the legs. Luckily I had gotten the start time wrong, I had an extra half hour. Phew! I found a little stretch and started removing the bricks from my legs. I was not feeling good at first but it started to clear up. I figured it was not my day, so I may as well just enjoy it. I detected some rubbing of the wheel and got the wheel re-aligned. Things might be ok.

I got to the start line and took stock. I lined up close to the front and took a comment from someone who thought it was a queue and that I should be at the back of the line. Team Kurzawinski was out in force. I found one Morning Glory and made eye contact. I was glad to have a potential friend around.

The race was off and up the first hill I was not positioned too well but as we went up I wasn't pushing overly hard and yet I was moving up - Morning Glory workouts paying off. Kurzawinski had two front groups pulling on either side of the road. They weren't moving too quickly and were not very well organized. This was great for me, but I knew that there would be some plan coming up. I'd seen some videos of previous races and the last time up the hill there had been a small breakaway, so I assumed that was the grand tactic. I planned to be in that final break and go from there.

A single rider broke from the pack at the third cornr. Kurzawinski did not chase. I was a bit nervous to see the race move away from me already but figured we had time. At the second hill we caught him and I gave him a "Great Break" as we went past. He gave me a tired reply and were up the hill. The field was getting smaller and I was trying to stay as close to the front as I could. I had moved from 20th to about 6th and was trying to stay there. Morning Glory friend was there, so I shared my plan and told him we should go together. He agreed.

We got around to Old School Road and then the leader started zig zagging across the road. The first time we were nearly moved into the gutter and it happended a few more times. I detected the problem and became angry. I yelled "Taking Your Fucking Turn Pulling Through, and Keep Your Line Straight!" I moved to the front and looked at the offenders in the face and said very loudly "ENOUGH"

I started my pull. I did my turn, flicked my elbow. Nothing. "Pull Through!" from me. Morning Glory friend was there. We had some nice words about keeping it fast and safe. Things were looking up. We came to the downhill an had a laugh at people racing to a downhill, the race is on the uphill!

At the bottom the Kurzawinski team made a duo move. I was too far back and was not happy again. Luckily the move lasted about 500 meters. Great. The hill. I gunned it. There was an independent in the lead and I was on his wheel. As we crested the hill he started to recover, I yelled "Don't slow down" and pulled through. I looked back and he was gone and the peleton was a good deal behind. I was feeling good and confident. My speed was good, keep it up. My family was cheering half way through this straight and I could feel the excitement from them as I went past solo in the lead.

I got around the next corner and into the headwind. I knew I was going to slow down and hoped that the peleton was going to continue not working well together. They didn't. Even better, my Morning Glory friend later told me that he moved to the front of the group and sat up to give me some more space. I needed it. I was starting to doubt. I started to think about all of the people who had gotten me this far: Morning Glory, riding friends, family, friends. I had to keep it up. Once I wasn't caught along this stretch I figured that if I got to the top of the last hill and pedalled down it then I should have all but won. It was true. I got around the last corner, continued to pedal with what I had left and at 500 meters I could sit up and enjoy the moment.

My Morning Glory friend, NAME HERE, finished first in his age category depite helping me. It was a good day. My family arrived in time for the podium ceremony and I even lucked out and won a door prize of a Pedro's Chain Pig.

Overall, I really enjoyed the event. I caught up with the swerver and it turned out to be his first group ride. I wondered if the event might provide the beginners with a set of links to videos and writings about how to organize in a group. It is a beginner race and it seemed that there were even greener riders than me. Nobody crashed, but there were certainly some moments that made me uncomfortable that could have been avoided.

Untitled Untitled Untitled Tour de Terra Cotta 2015 065

July 11, 2015

Sunday July 12, 2015
Category: Uncategorized

July 11, 2015 is a piece made while on vacation with my family in Victoria, BC, Canada at our friends Wayne and Penny's place. Made over a few days as a first experiment with the Ableton Push.

The session file and goodies are all here:

Tour de Waterloo 2015

Wednesday June 24, 2015
Category: Uncategorized

This year I revisited the Tour de Waterloo 76km Gran Fondo. Last year when I rode this event it was my first organized race. At the time I was hoping to finish with a speed over 32km/h average. I met that goal and broke away from my group with about 5 km to go to move up a few places, finishing 85th out of 205. I've had a great year on the bike so I was hoping for more.

The punchline: I was 24th out of 220 and I finished in under two hours. The process was interesting (at least for me). I woke up at my friend's house, ate, prepped, and rolled out at 7am in order to make it to registration. I got to ride through the stretch where I had made my move last year and familiarize myself with the last roads. I felt much faster and stronger as I did it and was feeling good going into the day. Strava told me that my comfortable warm-up was actually faster than my race effort from last year (I had a feeling about this but didn't get it confirmed until later). I rode past the final corner, which was covered in gravel and realized that the end of the race was going to be hairy. It seemed as though they moved the starting line too. Surely they wouldn't have moved the finish line, that was a highlight.

The morning glory team was registered almost entirely in the 133km edition. I found a few of them at the registration area and hung out until race time. We did a bit of warming up and rode past the final corner together and commiserated about the impending crashes. I got some advice to Kim about what I should do, and it lined up with my intuitions. There are two big teams here: one wants to do a leadout train like they did last year, and the other team was going to try and create a breakaway. The plan was to try and figure out which team would win and ride their coattails, but without spending any energy. I can wheelsuck with the best of them, so I was feeling good. By the time we got to the starting line my race was lined up so I tried to move my way to the front group. First mistake. I should have been there earlier. As it was I got up to about 70th or 80th before people would stop letting me though. I ended up starting with a friendly face, Katrina King. Excellent.

The race started and the neutral start meant we had an opportunity to move up through the group into the front pack. It took a bit more work than I had intended but once we were onto the first real road I was up with what I thought was going to be the front pack. So, now I sat in and waited for the pace to turn up. There was a lot of nervous shuffling and braking. We approached the first corner and caught sight of a breakaway forming. People started talking but none of the teams felt like chasing. It was about this time that I noticed that there was a really strong youth team and another team that I didn't know. Now there were four teams and a few individuals in the front pack.

There was a lot of push and pull and the breakaway team (Speed River) had a go off the front. I was well sheltered in the pack but it meant that I had to be careful to pick wheels that were riding strong and not about to go off the back. I was noticing that from my position I couldn't get involved in moves. I had missed the Speed River break, though I wasn't quite sure that they had the numbers to last, though they were moving away from us quickly. Until... they missed a turn. They quickly recovered and caught up to the pack and almost effortlessly moved back to the front. I was not moving well through the pack. I could move up a few positions on the hills but I wasn't aggressive enough to keep those spots through the straights.

It was about this time when I realized I wasn't having much fun. I didn't have any teammates to scheme with or to protect. I didn't have much to do except bide my time and watch the others fall away. A bigger breakaway escaped with enough representation that the pack sat up. We slowed down for awhile and then when the terrain got interesting we'd rip through a straight, shell a few more riders, catch a glimpse of the break and the lead riders would sit up. While I totally understood the tactic, it was a frustrating ride.

The break was eventually caught and we approached the finish with the sketchy corner. The penultimate straight was where I had planned to move up, so I did. There wasn't a lot of space and riders were crossing the yellow line for position. I wasn't willing to do this. It became clear to me that I don't have the nerve or aggression to win, though I have the drive. Maybe I should start time trialling? We got to the second last corner where last year the sprint train started. The rider in front of me took a terrible line and cut me off. Karma kicked in and they dropped their chain, but I had lost some momentum and I asked if they were OK (hoping to further up my own karma, not that I believe in it). The pace kicked up and I was steadily moving up. Not to the front but a few positions.

The corner. It was clear. No crashes. Now I had to sprint. Not my forte. I gave it everything and caught two or three more places to finish 24th, averaging over 38km/h and in the top pack. I was disappointed and embarrassed. I was 4th in my age category and mostly unhappy. I didn't finish as high as I wanted. I rode with people who didn't have each other's safety as their primary objective and although I did follow through the plan fairly well, it meant that I hadn't done any real work, so I didn't get much of a workout that day. I ended up wishing that I had just done a good old Sunday ride with the club.

I abstained from alcohol for a few weeks prior to the race. No snacks. Eating clean, enough to annoy my wife and to make my friends think I was a party poop. In the end it didn't really matter and wasn't really worth it. I'm not done with road racing but the sprint finish races will never be mine. Next year I'll enter the 133km version and ride with the team. This year I'll try the tour de terra cotta, which features a big hill in the middle of the loop that should play a bit better to my strengths, or the least of my weaknesses.

Here's the results from this year. All tolled, it is a huge improvement in just one year. I learned a lot. Hopefully I can learn to put it to use.

Website Overhaul Update

Friday July 01, 2011
Category: Uncategorized

I am trying to overhaul the website. I have been spending a lot of time researching what system I should use and how I should do things.

I have settled on Hyde. It is a python based engine that utilizes Jinja2 tempates, which are very close to Django. Right now I use 2 different content management systems that dynamically load and have different logins and passwords and I really don't need it. I love Hyde's idea of having static pages. There is nothing to login to on the net. No access points for hackers or spambots or script kiddies. I like that.

The downsides of Hyde is that it is quite big and flexible and requires some learning if you want to do something other than a boilerplate site. Currently the documentation isn't great but sufficient to get going. What Hyde really has is a few people who have open sourced their code to generate their sites (!!). I stumbled across James Clarke's site today and found it super useful.

With a templating system that allows for some real power under the hood I will be able to keep the look and feel of the site much more consistent and make a global change by only shifting a template. Right now I have some old youtube links on the site that use the <object> tag instead of the new <iframe> tag. They both work but I had to do a little massaging on each to get them to sit in. I have written a macro for Jinja that allows for a very simple way to integrate youtube links. If I change this macro then all youtube links will be updated across the whole site (once I recompile, of course).

After lots of sitting by a tree I came to the realization that I had places and media to put on the site. Also, that I felt that academic items were media items, just like pictures or other traditional media assets. So, I came up with this layout idea for all of my project pages.

Project Page

This can be handled nicely by Hyde. I would also like to be able to tag a project page as old and have it not included in my current list of projects but have it grouped in old projects, as I have now. No problem with Hyde's categories.

The major bonus of this system for me is git. I can make a git project out of this and everything gets stored in a format that both get and I can read. With Wordpress, indexhibit, or other mysql based sites only machines or super database wizards can read the files created and do anything with them. With Hyde and some careful planning, all of the content is a simple text file (or image file).

I am still a little dubious about comments on the site. I have received 1 non-spam comment in two years. So, I am looking into disqus to handle comments. The nice thing is that I can add them after I get the skeleton up and running.

There are some dirty Hyde details that I will start blogging about as I get my feet wet. Until then, any thoughts or links I might need please email me or put something in the comments here.

Happy Canada Day!


older   →