std::numeric_limits::min() vs. std::numeric_limits::lowest()

While this is quite a technical blog post it took me a little while to fully understand the implications on my code and I therefore would like to share this insight with my readers. This article applies to everyone who likes to use software constructs like the following one:

Looks reasonable, doesn't it? However, the tricky bit is that min() does return the minimum representable finite POSITVE value of the type provided as template argument (in this case float). If x and some_other_value are always positive, this is not a problem. If some_other_value can also be negative, above statement will not work as intented.

What is the correct solution? Use std::numeric_limtis<T>::lowest() (Only available from C++11 on!). If I print the concrete values of min(), max() and lowest() on my dev system I do get the following results:

The correct code sequence should therefore be:

This stumbling block is especially heinous because the following software construct works as desired in every case:


Erase the complete flash memory on a STM32 with OpenOCD

Lately I had the pleasure of working with Frank Voorburg on integrating his OpenBLT bootloader in a STM32F4 (precisely a STM32F405RG) based project. As a means to debug the microcontroller OpenOCD in combination with an Olimex ARM-USB-TINY-H JTAG adapter was used. For those not familiar with openocd, you can simply install it via

OpenOCD can be started via

However, it is necessary to have a openocd.cfg file present in the directory where openocd is invoked which defines the used microcontroller as well the used JTAG adapter. In our case openocd.cfg looked like that:

At one point of our integration effort it was necessary to erase the complete flash memory of the target microcontroller. Since the information on how to do it was not so easy to find I decided to document it here. First thing to do is to establish a telnet connection to the OpenOCD driver:

Than the execution of commands within the microcontroller needs to be stopped:

With the next command one can obtain various information about the flash present at the microcontroller:

The important thing here is that the STM32F4x uses the same flash model as the STM32F2x. This is important because the flash type 'stm32f2x' is used as a part of the next command to completely erase the flash:

Done 🙂 You have completely erased the flash of your STM32F4x microcontroller 🙂


Featherweight Schnauzer Part 20

Since the work on all the mechanical components of Schnauzer is complete the focus now shifts on the completion of the electrical parts. Since the ESCs and the power wiring is already installed the next step is the integration of the batteries into the system. Two 2-cell LiPo batteries with a capacity of 1800 mAh each are used. Those two batteries are connected in serial providing one 4-cell LiPo battery for the ESCs.

Because of the tight space situation in the robot the battery cables need to be shortened down a bit. This is done by cutting off the power cables and soldering a new EC3 female power plug to the cable. Attention: If you ever work with LiPo batteries make sure that the bared red cable touches the black cable at no point during your soldering process - otherwise sparks (in the best case) and an explosion (in the worst case) will ensue. At least one of the two cables needs to be fully insulated.

The next step was to manufacture an adapter which allows to create a single 4-cell battery from two 2-cell batteries. Such an adapter can be seen in the picture below and consists of two EC3 male power plugs. Those plugs are connected with the two batteries while the other end of the cable if connected to Schnauzer's power distribution system.

Since the frame of the robot is made out of Hardox (which makes it really tough to drill holes into it) I had to think of a new method to mount the batteries to the frame. Luckily I do have some spare strong neodymium magnets lying around from the beetleweight arena build.

Two of those neodymium magnets are placed on a rectangular piece of foam material (to provide some sort of cushioning from hard hits against the robots frame). Good old duct tape is used to mount everything together.

The next pictures shows the assembled battery completely covered in duct tape.

In the next picture you can see the two batteries mounted at the rear end of Schnauzer. Since each magnet has a holding forvce of ~ 110 N the batteries are held firmly against the Hardox frame. I am confident that they shall not come loose during a robot battle.

Last but not least a close up shot from the adapter which creates a single 4-cell battery out of the two 2-cell batteries. Also to be seen: The 80 A fuse 😉

Schnauzer is now ready to go 😉 Well nearly, I am still working on a last electronic component which should provide Schnauzer with an edge in the arena ... more details after the event 😉 Speaking of an event: The German Roboteers Assocation is holding a full contact featherweight competition on April 8th, 2017. More details here.


Featherweight Schnauzer Part 19

Although the last update on Schnauzer has been posted just a little while ago I am happy to announce yet another update about Schnauzer's progress. Some free days due to the public holiday on 8th of December (Immaculate Conception) have provided me with a much needed break which in turn allowed me to finalize the top plate including the device toothed belt tightening device. For reference the next picture displays Schnauzer before the start of the operation.

As one can see from the next picture, the toothed belt on the right side is very loose and can be pressed down by applying a little force with the trigger finger.

Since I can not keep my finger there while running the bot (what a silly idea indeed 🙂 ) the toothed belt must be tightened in another way. Here the toothed belt tightener described in the last blog post appears on the scene. On the next picture you can already see the tightener mounted to the top plate.

After mounting the top plate to the robot it can be seen that the tooth belt tightener fulfils its purpose and creates the necessary tension which prevents the toothed belt from getting loose from the cogged-belt pulleys in case of rapid load changes.

Here you can see a picture of the whole robot with the top plate mounted. Currently only battery and receiver are missing, otherwise the robot is fully functional. (About time - Redesign/Repairs are going on since the last Mad-Metal-Machines Event in Fall 2015).

A glance at the undercarriage of Schnauzer reveals that all screws are countersunk. This is a lesson learned from the very first version of Schnauzer where the screw heads kept getting stuck in small gaps between two consecutive arena floor sheets.

Next steps are finalizing the robot by selecting and purchasing a suitable battery and installing remote control equipment. Stay tuned 🙂

Page 2 of 38 12345...»