November 1 update: IT WORKS!!!

It's a day late, but it works! I couldn't be happier!!!

Fixing that integer overflow bug did the trick!

I still need some tuning before I can call it reliable or smooth. But oh my gosh, it works!

Halloween night update

I had a hunch at 3pm today, quickly confirmed the hunch, and was able to quickly fix the central controller crash. It wasn't a crash at all, but rather getting stuck in an infinite loop when the radio received an unexpected packet (this is the 2.4GHz ISM band, so that packet could have come from anywhere). This was an easy fix, and after a few minutes of steady operation in the garage I decided to give it a shot.

I shifted into high gear and contacted my neighbors, asking if I could still use their roof. Amazingly, they both said yes (they are very patient with me!) but I didn't have a ladder tall enough to reach one of their rooftops, and not enough time to borrow the ladder from another friend, so I had to use the highest point on the neighborhood playground instead. I was literally running all over the street with a ladder, clamps, power cords, and motor assemblies. I was sweating bullets.

I hooked up the ghost to perform initialization. The moment of truth. Everything seemed to go smoothly with the procedure! Initialization finished and it told me the distance between houses was...negative?

In a scramble, I wasn't thinking clearly and just overrode the value to the absolute value that I was given. I tried moving the ghost to a point and the motors were fighting one another. The position numbers didn't make sense.

I did some last minute hacking and debugging on the controller. I rebooted it so many times, my phone decided it just wasn't gonna talk to the ESP32 on the network any more, so I was typing commands on my desktop and running outside to see if it worked.

Nothing. Made. Sense.

As trick-or-treaters started walking down the street, I let out a giant sigh. So close!

I left the ghost hanging in mid-air with its red eyes  (flashing LEDs) turned on for a "normal" over-the-top Halloween decoration. Really, how many people string up a ghost from the rooftop of houses across the street?

Halloween night was still fun and chaotic. Lots of kids came, and we had friends over. Everyone enjoyed my Halloween props that I had made last year, including an automated coffin that opens with a skeleton that pops out and screams and sings, and some hidden spiders on stepper motors that drop from the ceiling of my porch. Some kids noticed and pointed at the ghost with flashing red eyes hanging way overhead.

But my mind was going a million miles an hour the whole time thinking what went wrong. I suspected integer overflow in the encoder counter, and snuck away from the chaos for a few seconds here or there to check various points in my code. Best I could tell, the encoder counter shouldn't overflow until it reached 214 meters, and the houses were much closer than that. Once the data was in the central controller, everything was in floating point, so an integer overflow wasn't possible there.

The chaos ended. Halloween was over. I sat down at my computer for 30 seconds of uninterrupted debugging and almost immediately found the bug.

int16_t sum = model.motor(motor_a_id).status.position + model.motor(motor_b_id).status.position;
float distance = sum * 1e-3f;

That int16_t should be int32_t, as that's what the position fields are. This number represents the distance in millimeters between motors, so anything over 32.767 meters would be problematic. This is effectively the first step after receiving a packet in the central controller, as it is being converted to floating point.

Being on the central controller, this would have been fixable.

I just needed 30 seconds more...

UGH!!!

Next year there will be a flying ghost on my street.

October...

Read more »