Integrating SDL…easy as child’s play!

Children are a fountain of great ideas. They have yet to hardwire the preconceived views of the world that constrain most adult thinking. If you are ever stuck for an idea or solution, set up a fun brainstorming session with your kid and then LISTEN. You just might be amazed at what you uncover if you try to have a mind as open as theirs.

Many of us in the developer world try to hold on to this openness and unconstrained thinking. Artboards and IDEs are blank cavasses beckoning an entire universe of ideas and innovation. Alas, as adults, many times our own belief in the parameters of the software or code language are applied FRST in our minds…and then we work our way backwards to a safe, well-known place in which to work.

Screw that! Let’s pull out the LEGOS, paint the entire wall with whiteboard paint, order a box of Raspberry Pis and build ourselves massive sandboxes-maybe even the kind with REAL sand. Innovation is the lifeblood of developer communities and content ecosystems and is, honestly, the most exciting part of my job and my entire career.

Our FordDev team ran across this video from Alexandr and his daughter (and just had to share it. This is the reason we launched the Ford Developer Program in 2013; to provide resources and tools which enable everyone to innovate.  I asked Alexandr to share his experience with us. Enjoy!

 

Hi Alexandr, tell us a little about yourself and your development background?

 

Technically the first line of code I put about 22 years ago when I was twelve (or 11?). It was Basic at that time and for me, it was the best discovery I ever made. All my early learning was happening in isolation, no resources were available. I was staring into screens of HEX codes and guessing how people are writing those programs, are they so crazy to write all those numbers manually? But I knew that there is some meaning behind this.

Some time passed and I'd got access to the Internet which delivered an enormous amount of languages in my head, but the only language that is obvious for me is Assembly, possibly because underneath it is still the same HEX numbers that appeared first in my life 😊 Nowadays I mostly work in .NET and TypeScript environment.

 

What do you enjoy about being a developer?

 

I guess I enjoy all the projects where I need to do some reverse engineering, like when I was 4 I disassembled my brothers toy car to understand how it works and never were able to assemble it back... not sure why, perhaps a hammer wasn't quite a right tool for splitting it apart. When I was 19, I tried to repair (reverse engineer) the engine of my real car with, fortunately, better luck.

I like those products which allow me to look inside and understand what is under the hood, like SDL which allowed me to look at my car from a different angle. I love software engineering and very happy that it is what allows me to pay for food for more than 15 years already 😊

 

What made you think of connecting SDL with the LEGO Technic Hubs? 

 

Hm, I think (or my wife does) 😊 that I'm still a child at heart...

I like toys, had plenty of LEGO and was forced to give it away when I married. But soon I've got a baby, and this changed my life completely and... gave me an opportunity to buy new LEGO sets! Although I’ve got some, never properly enjoyed assembling them according to the manuals, always tried to do some interesting experiments, like an automatic gearbox or some custom vehicles.

This is one part of the story, the second one is about personal development projects. They never go okay for me, always hard to finish them as motivation runs away pretty quickly. So, I thought that should I merge all my passions to my toys (cars, LEGO and code) I can finally make it end-to-end. I just needed to wait till LEGO released the new hubs and Ford did a car with SDL which I can buy (how people can buy cars that have no open source components?), simple. And it worked!

 

Have you done other fun integrations like this?

 

Should we count the integration of my first car into an open sewage hole on a road? I don't think I ever made something similar before, all my integrations always stayed within the software engineering scope.

                As long as it wasn’t a Ford, we’ll count it 😉            

 

Tell us about the experience building the dashboard with your daughter?

 

Unfortunately, the development process wasn't enjoyable for my daughter, maybe because it took a lot of time without a visible outcome. She joined the LEGO building process and did some drawings for our gearbox indicator. The color picking process for PRNDL took a while. She likes drawing, writing stories and testing things, so she was my QA engineer and video director, wrote the whole script on sticky notes. Maybe software development is not for her, I do not want to force her to choose my path. I want to see where she wants to go and assist her as much as I can.

Speaking about overall development experience I want to say that as with any integrations, things looked very easy at the beginning. Like I had obvious documentation about SDL, about Lego, about Bluetooth... but make these things working together was not very easy.

I started with SDL. On the one hand, you guys really impressed me at that stage. I never could even guess that I can write a simple email to a car manufacturer and they give me access keys (at least some of those) to my car software/hardware. So simple, so nice... no words like "using this will void your car warranty". Isn't how this world should look like?

On the other hand, I had some negative experience as well, like the absence of the list of cars and the supported SDL features on those. It is maybe lack of skills, but I was not able to make my car move a seat for me for example. At the same time the biggest issue with it that Android Auto always takes and advantage and disables SDL on my device, I want to use both or be able to simply switch without turning off one or the other, why should I sacrifice maps or SDL functionality? Simple task manager functionality is missing, unfortunately.

                You will definitely want to check out our updates coming in a few weeks introducing SYNC capabilities including co-existence for SDL and Android Auto along with custom controls for cabin modules such as climate, seats, or audio!

Another story is about LEGO hubs and Bluetooth LE. They all good, unless you start sending too many commands. My daughter plays with LEGO Boost, enjoying building and programming the cat from that set. I play with more, let's believe more adult sets like LEGO Technic.

I managed to make the steering wheel quickly, but only if I turn it in any one direction. In case I send the other direction while the wheel is still in the process of spinning it starts to spin infinitely :( So default GoToAngle action basically didn't work for me and I spent almost all the time developing an algorithm for tracking the current LEGO motor position. It resulted in sending too many commands and often some combinations switch the motor into the uncontrolled spin again. Such a pain. I ended up writing error protection and analysis code to monitor motor behaviour. It worked well and I was happy... for some time.

When I got 6 motors, Bluetooth integration gave me some surprises, some commands never were delivered to either side. It resulted in adding some additional error correction algorithm. In the end, I modified some hardware for software 😊 Changed gear ratios. This was an incredible experience! Never had something like this. Was happy to have analog experience (signal interference and losses) in my digital software development world. It is like having bugs in CPU!

When the dashboard was ready, my daughter asked me where I took the manual to build this thing. It was a very nice question, and I hope I answered it correctly. I was a bit ambitious and hoped to show her an example of going outside of documented limitations and add some creativity to this world. When she came up with the script, I finally understood that she already knows it. We do not use the built device; I don't feel like it is safe for my kid if I will be driving on busy roads having this in front of her. I simply need to do some research about how far her face can go in case of an accident, can she bump into the LEGO steering wheel if I brake suddenly? Maybe I need to fix it in between the seats.

 

How long did the process take?

 

While the project took only about 30-40 hours of actual work, the process took about 8-9 months. It is hard to find time for personal projects and sometimes I switched and worked on my other projects, like trying to integrate Sonos speaker with a music service that doesn't support it.

 

Have you continued any work on this project…added any new features?

 

No, it is covered in dust. I wanted to. When I did the project, I found ways to register the rotation angles of the motors and I thought about adding a dial to change something in my car, like adjust my seat or volume. Not sure if the car allows/supports it but saw it in SDL docs. Do you have a list of supported features per model and software versions?

                We have a bunch of new features launching in SYNC 4. Documentation will be available soon. 

     

Did this project help you understand SDL?

 

Yep, it did. It is always better to do a project using the tech rather reading about it. You did a good job, I wish to have .NET SDK as well, maybe one day I can reverse engineer it and do a small .NET repo with it like for Xamarin, want to learn it as well, so it may be a nice opportunity to cove two hit two birds with one stone.

 

Any future plans to build an SDL app?

 

I think I want to try more things, something simple like projecting my current speed to the windscreen by sticking my phone to the top of the dashboard. Not sure how will it work with GMaps though, maybe there is a possibility to project directions... We do not have many apps for SDL here in Australia, it is a bit of an issue for me as well. Also keeping an eye on OpenXC, want to order the OBDII device one day and use my Raspberry Pi with it.

 

Finally…is the plural of LEGO LEGOS or LEGO? 

 

It depends on what type of variable you are naming with it. I'd use `LEGOS` for an array or list, but `LEGO` for an object of structure.

                Thanks for your time, Alexandr. We look forward to someday having an app submitted by your daughter and she can say, “Remember the story in 2021…that was me!”