  The Wheeled Inverted Pendulum (WIP) is a nonholonomic, underactuated
mechanical system, and has been popularized commercially as the {\it Segway}.
Designing optimal control laws for point-to-point state-transfer for this
autonomous mechanical system, while respecting momentum and torque constraints
as well as the underlying manifold, continues to pose challenging problems. In
this article we present a successful effort in this direction: We employ
geometric mechanics to obtain a discrete-time model of the system, followed by
the synthesis of an energy-optimal control based on a discrete-time maximum
principle applicable to mechanical systems whose configuration manifold is a
Lie group. Moreover, we incorporate state and momentum constraints into the
discrete-time control directly at the synthesis stage. The control is
implemented on a WIP with parameters obtained from an existing prototype; the
results are highly encouraging, as demonstrated by numerical experiments.
