Zehl.com NXT Segway
There are two versions of a NXT Segway on this page. Both versions are based on a PID controller. (PID is named after its three correcting terms, whose sum constitutes the output of the PID controller: proportional – to handle the immediate error, the error is multiplied by a constant kp (for “proportional”), integral – to learn from the past, the error is integrated and multiplied by a constant ki, derivative – to anticipate the future, the first derivative of the error over time is calculated and multiplied by another constant kd).The first version is based on Philippe Hurbain’s NXTway NBC code. The second is an attempt to design this in Mindstorms NXT-G, which I gave up, because missing floating point (FP) functionality in the NXT and the lack of computing power to emulate the FP maths by a large multiplier in the realtime control loop lead to rough movements. I put the zipped .rbt file below, if you find better kp, ki, kd values (or bugs ;-), please make them available!