RobotGuide
Deliberate practice/Handwritten Implementations

Practice 4 / 4

Handwritten Implementations

12 whiteboard problems with interfaces and grading points

Handwriting is not about memorizing code; it exposes the places where you only think you know. Every problem lists grading points — exactly what the interviewer looks at, not whether your code runs.

12 problems in total. Say it yourself before opening any answer.

Geometry and State Estimation 4

Implement the inverse of a 4×4 transform (rotation + translation).

Grading: use Rᵀ and −Rᵀt, not general Gaussian elimination; first assert that the rotation block is orthonormal.

Implement a scalar Kalman filter.

Grading: clear predict / update steps; K = P/(P+R); covariance update with (1−K)P rather than P−KRK.

Implement quaternion normalization and slerp.

Grading: negate the quaternion when the dot product is negative (shortest path); fall back to linear interpolation when the angle is near zero to avoid division by zero.

Implement 2-link inverse kinematics (including elbow-up / elbow-down).

Grading: return both solutions; clamp the arccos input to its domain; state that the singular (straightened) case has no solution or is not unique.

Control and Filtering 3

Implement PID (with anti-windup and derivative on measurement).

Grading: output clamping + integral clamping; derivative acts on the measurement, not the setpoint; explain why.

Implement a fixed-period timer thread.

Grading: absolute time (clock_nanosleep TIMER_ABSTIME); compensate after overrun instead of accumulating drift; explain priority and memory preallocation.

Implement a moving average and a first-order low-pass, and compare them.

Grading: explain the phase-lag versus noise-suppression trade-off; give the relation between cutoff frequency and α.

Embedded and Buses 3

Implement CAN frame parsing (ID filtering + signal bitfield extraction).

Grading: bitfields spanning bytes, endianness, signed extension; handling of out-of-range values and timeouts.

Implement a complete I2C register read.

Grading: start → address+W → register → repeated start → address+R → data → NACK → stop; every step has a timeout and error return.

Implement a single-producer single-consumer lock-free ring buffer.

Grading: atomic indices, correct memory ordering, full-vs-empty disambiguation (keep one slot free or use a separate count).

Planning and Architecture 2

Implement A* (or Dijkstra) on a grid.

Grading: an admissible (non-overestimating) heuristic; compare g values when nodes re-enter the queue; explain why A* beats Dijkstra.

Implement a system state machine (boot / ready / running / fault / reset).

Grading: illegal transitions are rejected, not silently ignored; fault latching requires an explicit reset; timeout protection exists.