Visualizing SGVHAK Rover Chassis Calculations
When we were putting together code to calculate Ackermann steering angles for SGVHAK rover's wheels, initial testing was done via Python command line using some fixed test values to match against results pre-calculated by hand. Once we built some confidence our math was on the right track, it was time to start testing against more varied inputs.
There was just one minor problem - at this point in rover development, our software is a tiny bit ahead of the hardware which means we can't test on hardware that hasn't yet been assembled. Even if we could, it wouldn't be a great idea to jump from a small fixed set of test values to actual hardware. As an intermediate step, we created a bit of code to visualize results of roverchass.py calculations: the "Chassis Configuration" screen will show what our control code thinks all six wheels should be doing. (This shows the intent, which is different from hardware telemetry of what's actually happening.)
Each of the six wheels got its own blue box, laid out roughly analogous to their physical position on the rover chassis. Originally wheel steering & speed was displayed as text: number of degrees a wheel should be steered, and a second number reflecting the intended velocity for each wheel. This was accurate information but it took some effort to interpret. To make this information easier to understand, numerical text was changed to a visual representation.
By using HTML's <canvas>
element, we could draw some simple graphics. Each wheel is represented by a black rectangular outline. A wheel's steering angle is now represented by tilting its rectangle to that angle. Inside a wheel's rectangle is a green fill representing desired velocity. When a wheel is supposed to be stopped, there is no green fill and its black rectangle is empty. When a wheel is supposed to be rolling forward, green rectangle fills from the middle upwards. Faster velocity is represented by more green in the upper half. For a wheel that should be rolling backwards, green fills downwards instead.
This visualization of roverchassis.py calculation results were far easier for humans to understand. This made it very quick to validate that roverchassis is behaving roughly correctly. There's a place for precise engineering calculations, but there's also place for a quick glance to check "yeah, that looks about right."