Raspberry Pi controlled Lego car part 1

So, I have a fair bit of Lego lying around from my childhood days. Not a lot of technical parts, but enough to have some fun with. I also have a Raspberry Pi lying around after a failed experiment where I tried to use it as a security camera. Why not combine the two? I figured I could build a Lego car that I can control remotely via a little server on the Raspberry Pi, which would also stream its camera feed. It seemed easy enough, especially after discovering a page that explained exactly how to make the hardware part of it work. Never did I imagine it would take this much work to get it up and running..

This post will detail the hardware iterations and setbacks I faced. The next post will go into detail about the software side of things.

So, before starting on this project, here is the list of things I thought I'd need to make this work:

  • Bunch of Lego: wheels, gears, other technic parts and some generic bricks to connect it all up. (already owned)
  • Raspberry Pi plus camera module. (already owned)
  • A USB battery pack (already owned)
  • Two Lego power functions motors.
  • A 9 volt battery.
  • A motor controller.
  • Some Dupont wires to connect it all up.

Version 1

I bought the M motor starter kit and a separate M motor for my first iteration. I built a very nifty motor assembly and a very strong shell structure to house the components. Here's how it looked like:

v1.0

It is thus that I found out that I should never overengineer before testing. While building the thing I discovered that I didn't have the parts required to drive all six wheels, so I chose to just drive the middle wheels instead. I figured that by gearing down a bit it should be fine. Much nope. The M motors were way too weak to power the construction, which was already quite heavy from the USB battery pack, but weighed down even more because of its overengineered sturdiness. Having just the center wheels powered was also a terrible decision. Fail.

Version 2

v2.0

I built this is a test version to experiment with gear ratios and to see if in a lighter version the M motors would have enough power to drive the car. Answer: not really. I got it to go forward and backward pretty decently, but I still didn't have the parts required to power all the wheels, so the motors were not strong enough to turn the whole thing without a steering assembly. Fail again.

So I had two options at this point. Option one was to build a rack-and-pinion steering assembly, for which I had the parts available and did end up experiment with, but in the end I wasn't happy with its turning radius and how I'd either have to buy a servo motor or have an 'unclean' solution with a clutch gear to handle the stopping at the end of the wheel turning axis.

Instead, I went with option two: throw more money at it. I bought two XL motors and a crapload of caterpillar tracks. That'll give me the power and the grip I need to build something really nice.

Version 3

..or not. It does look impressive though. Here's a test build with the power functions battery box instead of the external 9 volt battery.

v3.0-test

At this point I was still powering the motors via a separate 9 volt battery. I figured that, since my USB battery had two USB connectors, I could use it to power the motors as well, so I ordered a USB-to-9-volt cable from Amazon. That should help me save some weight by not having to put in two batteries. Sadly, this did not go well.

USB batteries are pretty smart. So smart in fact, that they only output power if they think something's plugged in. The USB-to-9-volt cable worked fine on a powered usb hub, but every time I'd try to hook it up between the battery and the motor controller it would simply not turn on. Crap.

I found another USB battery, which is actually a battery used for starting cars that happens to have a USB port on it. This one did always keep the power on if I plugged in the USB-to-9V cable. Good! Except it only had one USB port, so I couldn't also power the Raspberry Pi from it. So I ended up with two USB batteries and over double the original weight..

v3.0-final

The big green thing is the car-charging battery. Even without the second battery the 3:1 gearing wasn't quite powerful enough to rotate this monstrosity when on certain surfaces, such as medium-thick carpet. Once again, fail. And once again, I spent way too much time overengineering the construction without testing it first with its full weight.

Version 3.5

I figured I'd try to keep the next version as small and light as possible and worry about motor powering and recharging issues later. I managed to build a pretty small prototype.

v3.5-test

Now, I had one option left to avoid the use of two batteries. The big green car charger battery did, in addition to its one USB port, come with a 12V output. It's not the 9 volts that the Lego motors need, but I did find at least one link claiming that the motors should run fine on 12 volts as well. I had previously done this as a child when connecting an old technic 9V motor to my 12V Lego train controller, which gave it quite a nice speed boost as well. I figured this would be an acceptable trick. I butchered an old power supply, cut off it's circular connector and used it to connect up the green battery's 12V port up to the motor connector.

To avoid any more gearing issues I added another axis, bringing the final ratio down to 9:1. The build ended up much larger than I had intended, but still smaller than v3.0. With better gear ratios and a higher voltage to the motors.

v3.5-final

You may notice the second battery sticking out at the end of this bulky thing, despite the fact that the green battery has a free USB port thanks to the makeshift 12V connector. This is because the stupid battery doesn't let you use both outputs at once. It just turns off one or the other. Not ideal!

I'm still annoyed at this but don't have an immediate solution. The reason I spent so much effort trying to get everything onto one battery was because I intended to build a little wall charging station, so I can drive the robot into the charging station, which will connect the charging port of the USB battery onto a USB wall socket. I gave this a try with the double-ported battery while the Raspberry Pi was connected, and sadly it resets the Pi as soon as the charging connector is plugged in. Crap times two. I haven't tried this trick with the green battery, but that's pointless anyway since it only lets you use one device at a time. Looks like I won't be able to charge the thing remotely while it's running.

V3.5 still has a whole bunch of issues. It works great in terms of motor and track performance though. It moves and turns fantastically. even loaded with two bulky batteries. The motor placement isn't great though; they're way too close to the ground. I need to fix that in the next version. It's also longer and wider than it needs to be. Once I get a solution to the two-batteries issue I'll decide on how large the next version will be. I'm also thinking about buying the servo motor and using it to power a small gearbox, but I'd also need to buy more technic gears and axles for that, and I've kind of already spent way more on this project than I thought I would spend..

For now though, I'll stick with this hardware design and focus on getting the software up and running. More on that next time.

 

Posted in Tech | Tagged ,

New hobby project

Turns out it's really easy to control Lego power functions motors via a Raspberry Pi. I found myself a new hobby project :)

2017-01-08 20.24.33

Posted in Tech | Tagged ,

London Overground's biggest problem

Nearly every working day I take the London Overground to work. I am quite lucky: my working hours are flexible so I can avoid rush hour. The stations I get on and off are near the first stop and the very last stop on the line, so I am pretty much guaranteed a seat every time. The trains are airconditioned in summer and nicely heated in winter, which is a fantastic improvement on the Bakerloo line, whose trains may be the draftiest place in the UK. There's just one thing that bothers me a lot about the overground, and it's not even the delays. But I can't talk about my gripe with the overground without talking about the delays.

There's always been delays on the overground, ever since I came here 3-4 years ago. Sometimes there's this sign in the carriage telling you that x% of the overground trains ran on time in the last quarter. I've occasionally snapped pictures of those signs because I never once got the impression that things were getting better. TFL is pretty good in providing statistics on their website about their service, and I've done the math once to check if it actually was getting worse. Turns out I was wrong on that one. But things aren't getting much better either, and I can see those numbers just as easily go down again in the near future. There's nothing that inspired confidence in me to believe that there's an ever-decreasing amount of delays.

This leads me to the reason I hate the overground: the utter lack of accurate real-time reporting. The most common occurrence is a delay of under ten minutes. TFL's strategy of dealing with this is by not dealing with this. Every TFL employee just stays absolutely silent and hopes nobody notices. They certainly won't be updating the arrival times on the signs until well after it's too late. This is not a hard problem! Unless the staff are utterly and disastrously incompetent they would be immediately aware of the delay. They've got a website that everyone in London uses to check the delays which they could update immediately, but TFL deliberately chooses to take no action whatsoever whenever this happens, I guess in the hopes that the problem will magically go away?

Small delays don't always stay small delays, though. Sometimes a train needs to be taken out of service, or is delayed even further to even out gaps in the service, or any other reason really. That's perfectly fine. Once something's bad happened it of course make sense to return to normal service by whatever means necessary. But you need to report that to your customers, dammit! If I'm standing there at the bloody station for a train that's already ten minutes delayed without receiving any information at all about the state of the service, of course I am going to be even more annoyed if I suddenly hear that the next train is cancelled and I have to wait the better part of an hour for my next service. Whereas if TFL had reported immediately on the initial delay I would have stayed home just a little longer, checked the situation from their website and would have been much better off in the end. I wouldn't even have thought worse on TFL in that case, but if they make me walk to the station and make me wait in the winter cold when they could have told me already that there were delays, that's what really pisses me off. The problem is not the delays, it's TFL's lack of reporting on it which causes annoyance.

I realize that this is not a world-ending issue. No one will die from this problem, nor does it seriously affect the days of anyone involved. I can work from home, others may take taxis or busses, and in the end everything ends up just fine. But what really bothers me about this is that it's completely preventable. There is absolutely zero need for me or any other passengers to get annoyed at TFL for the delays if they just improved their reporting. There's staff at every station on my overground line, which is great, but they're all doing fuck-all whenever there's a delay when in fact they could be reporting the delay immediately so the TFL site can update. Not reporting on a delay until X minutes have passed is a terrible idea because it's not at all uncommon for smaller delays to snowball and become something worse.

Rant over. I am working from home today.

Posted in Daily Life , UK | Tagged , , ,

Kata Tjuta

img_1713ps

 

img_1756ps

Uluru was beautiful, but Kata Tjuta truly amazed me.

Posted in Photography , Travel | Tagged ,

Year-end-cap

Observations:

  • I got married!
  • I question whether this blog adds value to my real life any more.
  • Compared to 2015 I am cycling more and am fitter.
  • Being fitter has helped me keep my peace of mind during stressful situations at work.
  • Schelling points and fences are fascinating.
  • Next year I wish to speak my mind more freely among my friends.
  • I increasingly want to be part of a community again.
  • I actually typed a really long post for the end-of-year event but decided not to post it.
Prep work is done. Time to make a move.

Posted in Thoughts

Going home

Changing the country you live in has introduced a very particular anxiety inside me; an anxiety that I feel I've finally overcome. I've moved countries twice now, and both times I've had a strong sense of loss associated with the country I was leaving. I was afraid that everything I knew in there would disappear, and that it would no longer be 'mine'. Every time I'd go back to those countries I'd revisit all the places I had my best memories at, trying to document as much as I could of how I wanted to remember everything.

Years pass, and hardly a year goes by where I don't at least make a quick visit to either Japan or the Netherlands. The first going-back trips were only mildly memorable, with the memory of how I used to live in that country still fresh in my mind, and my mind uncertain about where I would be staying. But as I started to accept that, first, I wouldn't be returning to the Netherlands to live, and then, that I wouldn't be coming back to Japan any time soon, those trips became more nostalgic. Melancholic, even. Not overtly. Not obviously. But the feeling was always there at the back of my mind.

I've finally out-nostalgia'd myself. I've gone back to the Netherlands and to Japan so many times now that the going-back trip has become a steady, recurring, theme that I can rely on to keep occurring. No mad catastrophic event will suddenly wipe either country off the planet. Life moves on in all places. Nostalgia has been a warm and cozy side effect whenever I went back, but lately I am focusing more and more on the new things, on the way forward. Rather than seeing my experiences as a past that is over, I am starting to see it as a stable foundation that I can build something new on. It expands my options. The more I think about it this way, the more I am able to come to terms with my nostalgia. And finally, after ten years, I think I am at peace with having lived in multiple countries.

The past is dealt with. The future is being built.

Posted in Thoughts | Tagged

The right moment

There is a right moment to get out of the shower. There is a right moment for returning home after a nice walk. There is a right moment for everything. Your brain will tell you. If you overstay, you'll know. If you're early, you'll know.

This is the right moment to finish this blogpost.

Posted in Thoughts

Be direct

People are too polite. Politeness causes misunderstanding, especially across cultures or across nationalities, but even within the same culture it can be a problem. British people are sometimes ridiculously polite and indirect to the point where it serves no logical purpose and only slows down social progression.

Example: two people are getting to know each other and want to be better friends, but neither is sure about the other whether they want to improve their relationship or not. They are not sure because, at the end of their meeting, they repeat set phrases such as "That was fun, let's do it again some time". Then, when setting up the next meetup, quite often the tone of the next message is something like "Hey, last time was kind of fun. Do you maybe kind of perhaps in the future want to do something similar again? Only if you have time though. I wouldn't want to impose on you or anything.." - Totally British tsundere.

Don't fucking do this. There is absolutely no need to make communication this complicated. Just say "Last time was fun. I want to do X with you again. Do you have time Monday?" It really is that simple. There is no need to beat around the bush. Just say what you think. No one will think worse of you, or if they do, you are not a good match and there's no point in hanging out anyway. Be direct.

I see this kind of behaviour a lot more when interacting with native English speakers, or in a group that is largely composed of people that are very adept at speaking English even if it isn't their first language. The more adept you get, the more subtle the language becomes. This is not a good thing. At least not in this context. When it comes to social situations it is very important to be completely unambiguous. I've noticed this in Japan a lot while hanging out with people from various countries at the same time: eventually people realize nobody gets the cultural subtleties that they put in their speech, or they just don't translate well to English, so after a while people tend to become more direct with each other. This is a great thing because it saves time for everyone.

Playing with language subtleties is fun when you're having pub banter or lifelong friends or just two native speakers with an interest in language, but as soon as you're not 100% sure that the other party will interpret your signals correctly, be direct. Use more easily understandable phrasing. Don't leave things to be misinterpreted.

That's for the sending end. As for the receiving end, I'm very comfortable with taking people at face value and not spending ages trying to analyze what they're trying to say. I do find myself occasionally encountering people who throw linguistic subtleties at me. I take "That was fun, let's meet up again" to mean "That was fun, let's meet up again". Even if I usually get that there is (or might be) a deeper meaning behind something, I am very comfortable pretending not to understand it. As a result people have become more direct with me and life is simpler for both me and the person I'm interacting with. It saves me a lot of mental processing power to spend instead on things that I enjoy. Miscommunication is not a thing that I enjoy.

Keep it simple. Baka.

Posted in Daily Life , Thoughts , UK | Tagged ,

Still going

img_0226ps

There's something utterly fantastic about finishing up all your chores ('adulting'...) on a Saturday and then going cycling on a Sunday. Today was just perfect to pick up cycling again after a short break, and I definitely felt the cycler's high upon returning home. I've been keeping cycling on the exercise bike indoors. I was expecting myself to be weaker than I actually was today, so I was pleasantly surprised when I found myself actually overtaking some people on an uphill. Keeping in shape for the next trip. Still not sure when, but I'm already looking forward to it.

Posted in Cycling

Volcanific

What is it with volcanic islands? I just can't help but end up on a volcanic island every once in a while. This one was particularly nice though. Tenerife was quite amazing.

img_0994ps

 

img_0585ps

 

img_0802

 

img_1041pssml

Posted in Photography | Tagged