Number Crunching

Neuronal Networks need compute power. You can buy cloud time, but that’s rather expensive. So we need a hardware update.

Our only desktop computer is old and was never intended to be a good in floating point simulations. Ever with the limited CAD work I do, you feel it’s age. A new one should be good for single thread applications, and machine learning supported by a GPU.

And it will run on Linux!

Setup

  • CPU: Intel Core i9 7900x
    Machine Learning doesn’t require a very fast CPU, but some of the other, single threaded Linux applications do.
  • Motherboard: ASRock Fatal1ty X299 Gaming K6
    That was a tough one. The fast boards, with a reasonable price and the support for multiple GPUs are the gamer boards. But I don’t need fancy lighting. And I don’t need Wifi, we have wired Ethernet. And it has to support Linux only.
  • RAM: 4 x 8 GByte
    I don’t need 32 GByte for a start, but I wanted to use all 4 memory banks for speed.
  • Disk: 1TByte SSD
  • GPU: Nvidia GeForce GTX 1080 Ti or RTX 2080 Ti
    It has to be Nvidia because of the CUDA support. I was targeting the GTX 1080, but just now Nvidia has announced the RTX 2080. I will wait a month to see what the reviewers say, and how the price of the GTX 1080 Ti develops. For now I have bought a cheap Nvidia to set up the system.
  • CPU Cooler: Noctua NH D15
  • Power Supply: BeQuiet 700 W ATX
  • Casing: tbd, I’d like to get another LIAN LI casing, they are nice.

Past and Future

After a break of 20 years doing something completely different, I have decided to check out Machine Learning (ML) again. Back then I worked in research of biological neuronal networks.

Now I am interest in the technical networks. With the progress of computing hardware complex applications are possible. Nowadays it is rather easy to get information on this area, the Internet provides access to training and documentation. It is no longer necessary to spend days in the library.

I am starting with the Google Machine Learning Crash Course (MLCC). It is a great refresher. It also is an introduction to TensorFlow, a Python framework for machine learning. And you get access to a platform to run the programming exercises, no need to buy a fast computer.

I am positively surprised that I can still remember the basics, after 20 years.

Retrospect

Three weeks of vacation are over. What exiting things did we do?

  • Grind the old color of six more windows and doors and paint them.urlaub15-IMG_6619
  • Replace the leaking roof of the shed and replace it with a new one.urlaub15-IMG_6612
  • Cut the bigger openings for the four new skylights, seal three of them.
  • Make the wiring for the three electric ones.
  • Build two of the four new reveals. The old ones don’t fit for the new windows.urlaub15-IMG_6617urlaub15-IMG_6615

That doesn’t sound much, but it kept us busy for three weeks. There is still plenty of work to do at the house. Two more reveals need to be made and installed.

After that I am done with construction work. I want to get back working on the Walker.

Communication

Bread-board with 2 Arduinos

During the last months you didn’t hear much about the Walker. Well, during New Year vacation I was much occupied with family and 31C3. But development did proceed. After sorting out servos and basic Inverse Kinematic I am now focusing on setting up the full framework of components communication between them.

I wanted to have the framework in place before getting deeper into motion control and sensor reading because:

  • I want to avoid heavy porting from a test environment.
  • I want to make sure the design fits to an environment with multiple modules.
  • I want to experience any issues because of delayed communication as early as possible.
  • I want to develop a framework that allows tracking of joint and sensor values in real time. I’ll have to develop some test functions at all, so make sure to keep them for testing in later stages.

communication_sketch

The walker has a core module connecting to sensors and controlling body and  movement. Each pair of legs is controlled by it’s own segment module. It controls the leg servos, the tilt servo and reads the contact sensors in the leg tips. Core and segments communicate through serial lines, with the core as master.

On the Mac runs a control application written in Java. It provides a graphical interface for debugging and controlling the Walker. The link between the Mac and the Walker uses Bluetooth. That was the easiest one, the Mac already provides Bluetooth, for the Walker I use a HC-05 Bluetooth module. It provides a standard serial profile and is rather  simple to use. It is connected to the core module over a serial line.

I had much fun with Java on Unix talking asynchronously with device files, or rather not. I also did test HC-04 BT Slave modules, but they don’t talk with Macs, which I found out after many futile tries.

This draft document describes the protocols, control lines and message formats.

The frame-work is working, next steps will be a little bit of fine tuning, adding the touch down sensor electronics. The modules are still Arduino based, but the Eagle drawings are already under progress.

Double vs Integer

I have spent a few days to sort out the Inverse Kinematics formulas. My mathematics skills have been much better in the old days. As I am using an AVR ATmega2560 I did the implementation in fixed point integers. As everyone knows float calculations are much too slow.

It took me days to get atanacos and sqrt functions working. I need reasonable resolution (<1°) and reasonable sized lookup tables. But generally flash isn’t an issue, the ATmega2560 has 128 kByte of it.

For the automated testing, that I always implement, I did check my integer functions against their double precision counterparts. And as the AVR has timers, I also tracked the execution times. I was surprised.

 int16double
min / avg / max
in [us]
min / avg / max
in [us]
sqrt24 / 38 / 5628 / 31 / 36
acos48 / 49 / 52128 / 160 / 176
atan140 / 152 / 160168 / 184 / 204
inverse kinematics544 / 559 / 580829 / 926 / 976

Ok, double is slower than 16 bit integer. But, the overall difference is only 70%, but accuracy is much higher. The inverse kinematics results calculated with integers differ by 5° maximum, the double results are better than 0.1°. Writing the fixed point functions took about 4 days, the double version 30 minutes. The planning of accuracy and operand length for fixed point integer is a pain.

What do I take from this:

  • Never optimize before I have the proof that I need to.
  • Double isn’t as bad as I thought. And much much easier to handle.
  • I’ll use double for the project. As I am planning to split the control to leg and body control to multiple processors, I should have enough resources to get a reasonable cycle time.
  • If not, I can optimize later.

Boojum is Another Word for Buffer-Overflow

After some debugging here, cutting away code here and there, recovering from frustration, and some other magical moves, I found … a buffer-overflow of an itoa(). I love it. It did garble the stack, resulting in a restart loop. Pure magic, dark magic. I hoped for something honorable, like a compiler bug.

One of my favorite from http://natashenka.ca/posters/ seen at 30c3. There are more!

Hunting the Snark

boot-loopMicrocontroller code is simple. No memory allocation, very few pointers, simple structure. Ok, there are interrupts, but they can be managed.

But why does it always end up in hunting strange bugs? A few weeks ago I started writing the code for a smooth linear motion. I thought that would be a good exercise for more complex motion code I’d begin with soon. Then I also wrote a test for this function. I am now always developing formal tests. The time you spend on the tests is much less then hunting the bugs in the production framework. For the microcontroller I am using AceUnit.

Now a few weeks passed by and I still didn’t get much further. The test produced garbled output and did restart in a never ending loop. Strange. Luckily, that happened with a rather simple test case. I did strip it down. The output did change unpredictably. I stripped it down further, and found a few bugs in the serial output code. I use the serial output for debugging, unfortunately the Arduino doesn’t support the standard connectors for an Atmel debug device. I fixed the code, not understanding why it could have lead to a restart loop, but in good hope. After restoring the test framework, I ran the test case again, and it still looped forever. At least the output looks nicer now. It is a Boojum, for sure.

snark-its-a-boojumBy the way, ‘The Hunting of the Snark’ by Lewis Carroll is a wonderful poem, worth to read. With brilliant ideas, as you would expect from him. I have a reprint with the original steel engravings, like the one on the left.

Travel

gdlorlrst14-IMG_0767

Guadalajara

I have been on a business trip for almost 2 weeks – Guadalajara, Orlando, Reston. Audits, audits, audits. It’s not relaxing and there isn’t much site-seeing, but meeting so many nice colleagues around the world gives me a huge push. You are aways welcome, get help and have a chance to peek inside the live in their countries. That’s very different to just an touristic holiday trip. And after you have met someone in person it is so much easier to communicate later on phone.

gdlorlrst14-IMG_0773

Installation in front of the Instituto Cultural Cabañas

I had a weekend to spend and decided to take the Saturday in Guadalajara and fly to Orlando on Sunday. A workmate showed me the town center and we did visit two museums, a historical and one with modern art. Great. Guadalajara is a nice and vivid town with plenty of public art. The Mexicans seem to love this. And the food, and the jugos, I love fresh juices.

Now most of the year’s travel is done, only a short trip to Bucharest left in October.