I minted an NFT and put it up for sale

The internet's going crazy about NFTs (non-fungible tokens) right now, so I wanted to see what all the fuss was about. In a nutshell, NFTs are bits of information that are stored on a public blockchain, which are provably 'owned' by a particular blockchain address. Anyone can see it, but only the owner of the address can prove ownership of the NFT, and transfer it to others, since the owner is the only one who is in possession of the private key required to do those things. From a technical point of view it's not very novel at all, it just seems like a logical evoluation of the presence of public blockchains, yet the internet has become infatuated with it recently, with some artwork selling for utterly insane amounts.

The world of cryptocoins has progressed a lot since I first wrote about it. It's incredibly easy these days to just download a mobile crypto wallet, transfer in some money (either crypto or fiat) and then use that wallet to trade. The intended user experience is fantastic, but in practice.. we're not quite there yet. In order to link your wallet to an auction site like rarible.com you have to connect your wallet via a QR code, and in theory the site will then ask your wallet for confirmation for the actions required to mint an NFT and put it up for sale. In practice there's 4 different wallet connection protocols and dozens of wallets that implement them, and your experience will vary greatly depending on which protocol and wallet you use.

MY first attempt at minting an NFT on rarible was to use WalletConnect to connect to crypto.com's mobile wallet app, and it was nothing but pain. Confirmation requests never arrived, or after confirming nothing happened on the auction site. Even transferring money in and out seems near-impossible sometimes. But then I switched to using the Coinbase wallet app and protocol and things were just smooth. It took only a couple of minutes to mint a new NFT and put it up for sale.

So what piece of 'art' did I put up for sale? Given the internet hype around this whole thing I thought it the most appropriate to mint a screenshot of the very first blogpost I wrote about Bitcoin in 2011: Resources are being utterly and completely wasted on mining Bitcoins. You can find the NFT for sale here on rarible.com. This post was written way back in the day when I was GPU mining at home. In those days, even without being part of a mining pool you'd occassionally find the winning hash and get the full 50 BTC. 50 BTC is worth $3,000,000 today..

Looking back on that post, I wish I had been a bit more prescient about the price of Bitcoin rather than the resource usage.. While it's true that Bitcoin's energy usage has ballooned (apparently more energy is spent on mining Bitcoins than is used by entire countries), which I predicted back then, I did not predict that the price would go from $9 to $59000. If I had predicted the price right I'm sure I would at this point be able to buy a news company to write this article for me. Oh well. You win some, you lose a lot.

Posted in Tech | Tagged , ,

Legobot + Base Station 1.0

It's been a while since I wrote about my ongoing hobby project of building a Lego Raspberry Pi tracked vehicle. I've been working on it on and off since the last post, so here's a bunch of updates.

I finally made the plunge and bought a Raspberry Pi UPS Hat (note: does not come with batteries). The reason I held off for so long was mainly for two reasons: the capacity is lower than a separate USB power bank, and I didn't want to faff about with custom wiring and having to worry about short-circuiting things. I ended up caving in because the UPS hat just wasn't that expensive, and faffing about with custom wiring means the end product can be a lot smaller.The big gain you get from a UPS hat is that actually unintterrupted. With every single USB power bank I tried there was always a blip in voltage when plugging the power bank in to mains power that caused the Raspberry Pi to reset itself. No such issue exists when you're using a UPS Hat, and the 2.5A output is more than enough to power two Lego Power Functions XL motors at 8.4V.

Things worked out really well with the UPS hat. Previously I had a separate converter that stepped up the external power bank's 5V USB Power to 9 or 12 volts, which then went into the ThunderBorg motor controller. I found that with the UPS Hat I can pipe the 8.2V input power straight into the ThunderBorg and it's more than enough to drive the two tracks. I ended up having to add an additional switch, because hooking it up to the input power means there's no real way to turn off the power at all, since the ThunderBorg ends up powering the Pi if the UPS hat power switch is turned off. A bit weird, but all in all a lot more compact than my previous solution.

With things getting closer to a finished product I also shortened the Lego power cables, which I had kept intact so far, and was hooking into them with awkward DuPont cables that took up a lot of space. I also made the camera mount more compact by removing the ability to rotate horizontally.

With so much space saved, I managed to add in an additional motor to the front of the vehicle. This motor doesn't connect to anything when the vehicle is driving around. When docked into the base station, this motor can drive any kind of functionality supported by the base station. As you can see from the video below, the base station I built has a retractable ramp which is powered by this custom front motor. Another idea I have is to build a lift for it so I can make the bot look out the window.

I had originally planned to have a worm gear somewhere in the base station winch assembly, but then I figured that the motor resistance is easily enough to hold up the ramp when docked. Plus, as you can see from the second half of the video, you get this cool rapid ramp drop effect just by driving the bot backwards out of the docking station without having to lower the ramp through the winch motor.

The UI shows the video feed and various control buttons for all the motors and lights. It's not clear from the video, but the status bar shows information about battery charge, wifi signal, current wattage, motor voltage and so on. The UPS hat came with a Python library to read the charge percentage, but it did not compensate for the nonlinear dropoff of Li-ion cells, so I had to write a layer on top of that to get a somewhat predictable battery percentage out of it. It's not perfect, but good enough.

Software-wise it's all quite messy. I've been meaning to publish the finished product on github, but the last time I seriously looked at the code was a couple of years ago. The video streaming solution was very unprofessional and optimized to work for the first Raspberry Pi. It definitely needs some polish before I can publish it. But once the software has been published I think I can officially consider this project done. I can't believe I've been at this for several years now. I'll have to find a new hobby..

Posted in Tech | Tagged , ,

Comments

My self-hosted blogging woes continue..

It'd be an understatement to say that I'm not a big fan of Facebook. Facebook has been banning a lot of groups and accounts lately, seemingly algorithmically. That's kind of evil. I was seriously considering buying an Oculus headset until they started requiring that you sign in to it with your Facebook account; an utterly unnecessary step from a user point of view, only done so they can make more money and steal more of your information. Facebook sucks.

That got me thinking about how to completely distance myself from Facebook. I've still got a profile there that I regularly sign in to. Facebook is the only social network that a lot of my family and friends are on. There's just no alternative for chatting with groups of people that I know, because those people are only on Facebook, and so far this has stopped me from completely deleting my Facebook account. Today I thought I would finally remedy that, but before doing that I wanted to provide people with an alternative way to keep track of what I'm up to. My blog is where I would want to shift my activity to, but it currently does not allow people to comment, which is a big part of what makes a blog a blog, so that's really a must-have before I start pointing people to this site again.

There's two ways to add comments to a static blog: either you self-host the serverside part that stores the comments, or you use an online service like Disqus to do it for you. But don't use Disqus. The interface is utterly hideous and the free plan won't let you disable ads. Disqus also makes you jump through several unnecessary hoops to post anonymous comments, which was just clean and simple with native Wordpress. I would not recommend Disqus to anyone. Unfortunately none of the serverless alternatives offered a free plan for personal websites, so I'm out of luck there as well.

Then there's the self-hosted option. There's a few serverside packages that will deal with storing the comments for you if you don't mind spinning up a server. Some of them will even deal with span and email notifications. But for me this would mean 1. yet another piece of code that I have to maintain, and 2. cloud server resources that I have to pay for, especially if someone decides to do a spam attack on me. I have better things to do with my life than deal with that.

Sadly, this is the state of the internet right now. I want to get away from services I don't like, but the only way to do that is to invest time or money. It has never been harder than now to have a self-managed personal blog on the internet. Tim Berners-Lee's Solid project might be the best hope for a future internet, but I'm not holding my breath about it catching on any time soon. For now this blog will stay comment-less, and I will not delete my Facebook account yet..

Posted in Tech | Tagged , ,

The End is Near

Mortgage, marriage, pandemic. Boom, now you're old. I'll be brief, because we're not quite there yet.

In my entire life there has never been a year like this. I am no longer young, but I don't feel old yet either. Many bad things have happened to the people around me this year. Nothing is quite the same as it was before. Nevertheless, the pandemic brings perspective.

Gradually, my priorities shift. Goals get closer to fulfilment. Some things were not possible this year, but other things came along to replace them. Less travel, more at-home activities. Less human interaction, more peace of mind. Less commuting, more cycling.

There is "pre-pandemic" and "post-pandemic". Let's hope 2021 will be "post-pandemic". Getting older. Getting better.

Long ways to go yet. (Smeagol will show the way)

Posted in Thoughts | Tagged ,

Life in the UK: Quarantine and Cycling

It's been a month now since I came back to the UK after my holiday in Egypt. As soon as I got home I received a phone call from my boss emphatically telling me, in case I hadn't checked my work email yet, not to come to work. I've been working from home for a month now, and it has been utterly fantastic. I'm definitely lucky and privileged here. Others will prefer more face-to-face human interaction, or have jobs or even lives that are at risk because of this. On a societal level this crisis is a terrible thing. But if I'm being perfectly honest: my quality of life has only improved since we went into quarantine.

The main thing I have gained is time. No more 1.5-hour commutes. That's 3 hours of my time back every day. Being able to spend that freely on things that I enjoy doing has made me feel so much better about myself. No more becoming frustrated at train delays or overcrowded and overheated train carriages. I just get to relax and enjoy the things I would do anyway even if there wasn't any lockdown. I'm actually getting a decent amount of sleep lately, and I feel like a different person because of it.

The lockdown in the UK means that everyone is supposed to only go out a maximum of one time a day, and only for buying essentials or for daily exercise. Based on what I've seen, that lockdown is only mildly enforced at the moment. Public places like parks are being locked down for cars, but there's still people who can walk or cycle there. I've seen footage of beaches being quiet as well, though I've not been there myself because lockdown. There's definitely more police patrols on the streets than usual, but I haven't seen any blatant disregard for the social distancing rules in my area (yet).

The most change in behavior I've seen is in supermarkets. There are now long queueing areas in front of the entrance, with a security guard waving people through one by one so as not to ever get too many people inside at the same time. And because of the social distancing the space between people in queues is massive, so the queues go on forever. People have been very civilized in respecting those rules, so far. I guess if the alternative is that you have to elbow your way in and risk getting too close to someone who might have 'the disease' (omg), that kind of helps in getting people to have. It's been a most civilized crisis so far.

About two weeks ago I went to the local (smaller) supermarket to pick up some things and happened to see a pack of toilet paper, which I took. My wife and I joked about the whole 'toilet paper shortage' meme after we got it, but I've not seen any toilet paper since. Though apparently it's available for ordering for online delivery. It's incredibly hard to get a delivery slot though. I managed to get one for a date two weeks from now, but online delivery opportunties are definitely scarce.

So there is that: a mild anxiety about availability of daily life products. Not having toilet paper I can live with, but I do feel that it's good to have some small supply of food. You never know if an event will occur that will cause society's infrastructure to have a hickup. Depending on the length of that hickup it might be nice to be able to bridge that gap by having a few weeks worth of food at home. It's very far from being an existential risk though, since there's still plenty of food in the shops. There is absolutely no reason to panic-buy.

Since the quarantine began I've been cycling almost every other day. It's starting to feel good again. I've been very out of shape. I just have trouble motivating myself to do any form of exercise after I finally make it home after a long working day. I'm not the type to go a gym either, so I've been very happy with the great weather we've been having lately, which has allowed me to cycle outside a lot. I'm starting to remember that feeling of not constantly feeling like you're dying at every hill. I think in time I'll be able to enjoy it again.

Cycling in the UK, or rather, in Hertfordshire has honestly not been good, comparing it to the other two countries I have cycled a lot in: Japan and the Netherlands. The Netherlands is a hard standard to beat given how much it caters to cyclists, but Japan also felt a lot nicer and safer. That probably has something to do with the area I lived in as well: in Japan I lived in a very flat area near the seaside and next to mountains, whereas Hertfordshire in the UK is just hilly everywhere. I've seen plenty of areas in Japan where they just blasted a hill to make a relatively flat road, and there were lots of tunnels, but that's not really a thing that Hertfordshire does. It's just up and down and up and down. Fine if you're fit, not fine if you're me.

People here are not used to cyclists. Pedestrians will happily cross a road without looking if they don't hear a car coming. And on paths that are supposedly cycling paths, like this path called Ebury Way near where I live, it's just uncomfortable. It's a dirt road with lots of bumps and ups and downs, with pedestrians everywhere, often walking side-by-side, oblivious to cyclists until you're right on top of them. There's a lot of people who walk their dog without a leash. The dogs don't quite get that it might not be the smartest thing to stand still in the middle of the path when they hear a bicycle approaching. I've had a bunch of near-misses with dogs on that path throughout the years, so all of that kind of means that I prefer the regular roads for cycling (at least when I'm back to my before-level of fitness). The only disadvantage about the regular roads is that they can get narrow and tend to be even more of a constant uphill/downhill. I definitely miss cycling in Japan and the Netherlands. It's just not the same in the UK.

Anyway, rant over, and it's a minor one. It's still great to be able to go out on my bicycle (while avoiding other people and not stopping at parks of course - respect the social isolation!) and be able to go wherever I want. Nature is beautiful this time of year, and there's hardly any cars on the road because of the quarantine, which makes this a perfect time to cycle. Time to get fit again!

There are certain aspects of life that are obviously better during this quarantine. I hope we can keep some of those aspects once this is all over.

Posted in Cycling , Daily Life , UK | Tagged ,

The cycle of change

I've done quite a few cycling trips, but three clearly stand out as the major ones: Tokyo to the southernmost point of Kyushu, Tokyo to the northernmost point of Hokkaido, and Kyushu back to Tokyo. As far as the Japanese coast line goes, the last bit that I haven't done yet is from the northernmost point of Hokkaido back to Tokyo via the east coast.

Next year is the ten year anniversary of that first trip, the one from Tokyo to Kyushu all by myself. Inevitably, I find myself thinking about my life in terms of "before the trip" and "after the trip", about what kind of person I was before, and what kind of person I was about to become. That first trip is the marker for the biggest change in my life. I moved back from Japan to Europe. One life ended, and another one began. I was young and naive and full of a hope and a freedom that I will never ever regain. The term 'cycling trip', to me, is about that feeling of youth and freedom. But it's a feeling I've gradually lost over time.

Europe taught me some harsh lessons about what it's like to actually be an adult. I really had just been playing around in Japan, and I was not quick to change my ways after moving to the UK. I landed a job with a lot of freedoms, and I used it to become the most physically fit that I ever was. By the time I took three months off for the second cycling trip, I was in my prime. I challenged myself by cycling routes that I'd never even have consided before. The second trip to the North of Hokkaido was definitely my best physical achievement. I was never 'not fat', but I was definitely fit.

Between the second and the third trip something changed. I started becoming a different person again. It became hard to think of cycling in the same way as before. After the first trip I had never experienced life in that way before, and there was nothing better to me. The second trip continued on that feeling, but at the same time my life back in the UK was starting to come together.

My moment of 'cracking' came during a smaller trip, a few years after the big trip north. I had taken a two-week holiday from my job to do a shorter cycle from Hiroshima to Kyushu, to repeat a few of my favorite bits from past cycling trips, and to fill in a bit of coastline I hadn't cycled yet. I was cycling along the coastline with a perfect blue sky, not too warm, not too cold. It was a nice, wide, road, with a cycling area to the side and not too much traffic. Mountains on one side, and some small islands visible along the Japanese inland sea. It should have been perfect. I should have been enjoying myself beyond belief. But all I could think of was: "Why am I not enjoying this?"

I didn't understand the feeling, or where it came from. I stopped by a convenience store, bought some food and sat on a seawall for quite some time, feeling unhappy and trying to make sense of my emotions. Whenever I think about my trips nowadays, it is that moment that stands out for me as the turning point, the point where I realized I was becoming someone else. I didn't understand or accept it at the time, and it vexed me for years. It kind of still does. I still want to be the person I was back when I undertook that first cycling trip, but I can't. I can never go back to that. My life experience won't let me.

That trip was in Autumn. The next spring, I quit my job and went cycling again, to do it properly this time. I figured that the previous trip left a bad feeling because I had a job to get back to. It's hard to reproduce the feeling of freedom if you're only on a two-week break, so so I thought at the time. The third 'I quit my job and I'm going cycling' trip went from Kyushu back to Tokyo. It started at the point where I left with a bad feeling the previous autumn, and I felt vindicated when I made it back to Tokyo along the northern coast. I still had it.

But my exit from my job was a soft exit, with the opportunity to come back, which I did. Soon I was living the same life as before the cycling trip, which is why in the long term I think about this third trip differently than the previous two. Every cycling trip I see my options in life decreasing. Every trip I get older, more settled down. And that's not a bad thing at all. I'm quite happy with the direction my life is going. I'm creating options in one area, but as a consequence, options in another area are disappearing. Cycling trips remind me of a freedom I can't ever have back, and that's why I started feeling bad when I think about cycling trips. More and more it feels like escaping from life rather than creating opportunities in life.

There's one more trip left before I can finally say that I've cycled all of the coast of Japan, and I'm dreading it more and more every year. I've chosen my life in the UK, so I won't get the sense of freedom I got from the first trip. I'm getting older every year, and I'm definitely past my physical prime, though I reckon I'll have no real trouble as long as I don't injure myself. I'm pretty good at not injuring myself. Lastly, the bit of the coast I didn't do yet is the coldest, longest, most desolate, un-Japanese part of all of Japan: the east and north coasts of Hokkaido. Long stretches of nothingness with cold temperatures and strong winds. None of it is what I like about Japan, and it feels like a chore to do it at this point.

2020 seemed like the perfect 'I quit my job and I'm going cycling' year. Exactly ten years after the first trip. A perfect opportunity to evaluate what I was then and what I am now. But the truth is: I do that all the time. It's not like I turn my brain off for ten years and then wake up and wonder where I am. I chose to come here and I was conscious for all of it, no excuses. I'm no longer the same person I was ten years ago, and the person I am now has different priorities. I wouldn't have grown as a person if that statement turned out not to be true.

The legendary fourth trip will have to wait a little longer. I've not given up, but I need to create the right opportunity for it. Life goals allowing, I intend to make this happen in the next five years.

Let's see what will happen in the next decade. 2020, bring it on.

Posted in Cycling , Thoughts

Ears, motherboards and DACs

I love listening to music at home. My preferred place to do that is usually at my desk, where I play it through my PC. I've been using a Beyer Dynamic DT770 for about 10 years now. I'm on my second pair. I've gone through a lot of peripherals in-between; I used to hook up the headphones to whatever pair of crappy PC speakers I had at the time, but a few years ago I bought a small headphone amp and after that I had been using a small mixpanel. Neither of those were strictly necessary, but they provided easily accessible volume controls and were able to drive my headphones at higher volumes than the motherboard could (I have the 250 ohm version). This all worked great, up until the end of last year, when I convinced myself I was going deaf.

From January onwards, for some reason, music started sounding.. 'duller', to my ears. I really don't know how to describe it accurately. I didn't even realize that something was 'wrong' until weeks or months later. It just seemed like I didn't get my usual enjoyment from listening to music, and I couldn't figure out why. For a while I just thought it was my ears, accepted it, and thought I'd lost one of the things in life that I really enjoyed. For a while. And then I started experimenting.

I thought that maybe it was my headphones. So I tried some other (pretty decent) headphones we had lying around the house and hooked those up to my PC for a while, but all I could tell was that the audio quality was worse, not better. There was nothing wrong with the headphones.

My next suspicion was the speakers. I had been using the cheapest Logitech speakers in the past, but because they did not allow me to control the headphone output's volume with the volume control knob, I always had the headphones plugged in separately via a mixpanel. Last December I bought a new PC with new speakers: they were the second-cheapest Logitech speakers, which did allow headphone volume control using the volume know. So I ditched the mixpanel and connected my headphones up to the new speakers directly. But could that be the difference?

In order to find out I enlisted the help of my wife to do a blind test (or should it be a deaf test in this case?). I hooked up both the speakers and the mixpanel to the PC, normalized the audio, and got my wife to swap the outputs while music was playing, while I tried to guess which one was which. I had tried doing this just by myself without the blind part of the test, but I wasn't confident that it made a difference. But the blind test proved fairly conclusively that there was a difference, and that we both preferred the sound through the mixpanel, albeit only very slightly.

I ran with this for a while, but ultimately still felt like I was missing something. I really ran out of ideas for what could be causing my lack of enjoyment of music, other than my own ears.. but there was one other variable that I had changed and not tested yet: the PC. With the PC came a new motherboard: the MSI B450M Mortar, with an on-board sound card, as all motherboards have these days. I've been using on-board audio for years and never had issues with the audio experience, so it seemed very unlikely to me that the motherboard could be causing this. But it was the last thing I hadn't tested yet.

One other thing that made me wonder if it was the motherboard is that I sometimes play racing games with a separate app playing music in the background. My old motherboard used to mix these just fine, but after switching PCs the new one always seemed to cut out the volume of one app or the other at certain input levels, which sounded extremely frustrating. For a long time I suspected Windows 10 of causing this (antoher variable change: my old PC ran Windows 7), with it's "mute background apps" functionality, but I had made very sure that that was turned off.

In order to test if the motherboard audio made a difference, I bought an external DAC: the Sabaj Da2 USB DAC. It's an external USB digital-to-analog converter, which turned out to be easily powerful enough to drive my 250 ohm headphones without an amplifier in-between.

Before buying the Sabaj Da2 I had been planning to set up another blind listening test, but it took me less than an hour of using it to realize that I wouldn't have to. The sound is subtly but unmistakeably better than the motherboard audio I had been putting up with for so long. It's hard for me to articulate exactly what makes it better though. It's as if I am much better able to focus on the smaller, subtler aspects of the music, rather than just being bombarded with just the main instruments. The music seems fuller, I guess. It's a small difference, but it's impossible to not notice once you've spotted it. and then you'll never want to go back. I now wish I had tried this a lot sooner..

The Sabaj also solved the issue I was having with music not being played at equal volumes when I have more than one app playing sound at the same time. I don't know if that's just crappy drivers or crappy hardware on the motherboard, but I don't care. I'll stick to dedicated hardware for audio from now on. Side note: the Sabaj gets really hot, I'm tempted to slap a small heatsink on it.

(Disclaimer: I did not get paid to write this article. I haven't tried any other USB DACs so I don't know how the Sabaj compares with similar DACs. All I know is that it's detectably better than motherboard audio.)

Posted in Tech | Tagged , , , ,

Grown-up life and blogs don't mix

In the recent years I've begun to think very differently about the 'free' time I have available to me. Back in my mid-twenties my free time was truly free. My commute was short, my responsibilities were little, my social life was not very active, so I ended up having more than enough time to spend on all the things that interested me at the time. Now, ten years later, my social life is still not very active, but everything else has gotten a lot more busy. I lose two to three hours every day in my commute. I am fortunate enough to be able to worry about what the most efficient way is to mortgage our apartment, how to invest our savings, and so on. Once those things enter your life you have to prioritize them accordingly. Just keeping up with this took some adjusting for me. And I don't even have kids! I can only imagine how busy people are when they have kids to take care of. The free time in my life has gone from 'mostly unplanned' to 'fully planned', with almost no exception. I probably first had this thought years ago. I just didn't have time to blog about it.

What does "I don't have time" even mean? In this context it doesn't mean that I am so busy 24/7 with things that utterly vital to my life that I don't have time for anything else. I still spend lots of time playing games, watching movies, cycling, editing photos, and so on. What it means is that, after I'm done with the things that are vital to my life (social obligations, researching decisions that will affect me for the next decades, daily-life churn like laundry, dishes, commutes) I end up with very little time and 'active brain time' left, that I choose to spend it on other (less creative) activities.

Today is an exception, though. Today is the first day in months in which my to-do list has finally shrunk enough for me to feel like devoting some time to blogging. In retrospect I think it was probably a mistake to switch away from Wordpress those few years ago. Yes, my blog is now statically hosted, way faster, and fully managed by me, but the scope creep in getting the little features that I need in means it ends up taking literally years before I have something that even does the bare-minimum that Wordpress does. If I had to make this decision again, I probably would've stayed with Wordpress and moved to more expensive hosting. It's a wonderfully hands-off ecosystem. The reason I wrote my own static blog system and did not use an off-the-shelf solution is because I believe I would be locked in to someone else's solution if I used an off-the-shelf library or framework. My own system minimizes dependencies and lines of code. The actual meat of the system (template rendering, page generation, publishing) is less than 600 lines of code. Sadly, the Django app that I'm writing this in is proof that I still have dependencies and need to write hundreds more lines of code before I actually have something I can use from any random device or location. I think this solution is the right solution for someone who has the time to work on it. What I should have done is just buy more expensive Wordpress hosting, which would've gotten me a lot more happiness, time-savings and features.

One thought keeps popping back into my head over the past few months: "Efficiency/Productivity is the enemy of Creativity". That's one way to phrase it. Another way would be "Efficiency and Creativity are two sides of the same coin". The more efficient I work, the less creative I am. The most efficient people I know are people I would not rank very highly on creativity, and the opposite seems to hold true as well. I find the consequences of this interesting for someone (like me) whose professional role is "web developer". The 'developer' part is something you can improve by being more efficient/productive, but the 'web' part has a very strong element of creativity in it that is sometimes overlooked. Trying to satisfy both elements is an interesting challenge. Building my own blog is something I thought would be helpful for creativity, but in my attempts to keep the amount of work to a minimum I think it ended up being an exercise in productivity rather than creativity. Building things is not fun if you don't enjoy doing it. And (at least in the case of hobbies) if you don't have joy in what you do, why are you doing it?

Use it or lose it.

Posted in Daily Life , Thoughts | Tagged

A modern-day Dokkōdō

Prioritize mental, physical and financial health.

Use all of the day. Don't spend all your time in virtual worlds.

Accept inconvenience. Don't complain.

Think about what, ten years from now, you will wish you had gotten out of life now.

Spend some time in the sun every day.

Eat in moderation. Don't eat bad things.

Throw away things you don't need.

Meditate every day.

(Inspired by the original Dokkōdō).

Posted in Daily Life , Thoughts | Tagged

Raspberry Pi powered Legobot: latency

I've blogged before about my neverending attempts to build the perfect robot to drive around my apartment remotely. I've gone through a lot of mechanical designs, and had a lot of failures. Eventually I settled on something that was very much simplified compared to my initial ambitions, but it works alright now. It's been serving as my remote camera every time we go on holiday, so it's doing its job. Here's a writeup on the software latencies involved.

At the core of this contraption is a Raspberry Pi that controls a whole bunch of Lego motors, and one set of lights. I wrote my own Python+Django web app to control access to the device from the internet. It uses Django Channels to send the user input to the server-side, where the web app controls the Raspberry Pi's GPIO ports directly. This means it's not very thread-safe, but then it was never really meant to be controlled by more than one user at a time anyway.

For the video stream, I tried a lot of different solutions, but all of them had terrible latency. The problem is that the Raspberry Pi just does not have enough CPU power to encode the video into a stream and send it over a websocket. However, after a long search, I did eventually find a solution someone else developed that's pretty nifty: it uses the native Raspberry Pi video tool to stream the raw (H264-encoded) camera stream directly to a websocket, hosted by a Node.js webserver. This means that the video stream has to be decoded client-side, in the javascript executed by the client's browser, using a nifty js library. (I'll eventually get around to placing links to these libraries, once I remember where I got them from). Turns out this works pretty well!

Here's a really terrible video that shows the latency of the controller software, as served from a web page on my mobile phone, over the phone's 4G connection, so not on the wifi.

This video was taken on my old Canon S110 camera, which has a super slow-mo mode which records at 240 frames per second. So, counting the frames between events, I get these results (averaged over a couple of different videos):

  • Time between pushing the 'lights on' button in the mobile phone browser and the UI registering the event (client-side-only lag): ~31 frames = ~129ms.
  • Time between the button being pushed, and the lights turning on in the video: ~12 frames = ~5ms. I'm guessing this is very short because the actual action is being sent to the Raspberry Pi well before the UI update begins, so it'll overlap with the first action. Time between finger push and real-life consequence: about 135ms.
  • Time until the mobile phone video stream shows the lights being turned on (since the lights actually turned on): ~55 frames = ~229ms.

All in all it's close to half a second between requesting the action, and actually seeing confirmation of the action on-screen. And that's on a fairly reliably mobile connection close to my home. It's a different story altogether on crappy hotel wifi halfway across the world, although I've also been to some amazing hotels in Japan where the speed was very similar to the speeds in this test.

Still to do: open-source the Raspberry Pi software I wrote for this. More to come!

Posted in Tech | Tagged ,