  In this paper, we use a nonlinear hierarchical model predictive control (MPC)
to stabilize the Segway robot. We also use hardware in the loop (HIL)
simulation in order to model the delay response of the wheels' motor and verify
the control algorithm. In Two-Wheeled Personal Transportation Robots (TWPTR),
changing the center of mass location and value, the nonlinearity of the
equations, and the dynamics of the system are topics complicating the control
problem. A nonlinear MPC predicts the dynamics of the system and solves the
control problem efficiently, but requires the exact information of the system
models. Since model uncertainties are unavoidable, the time-delay control (TDC)
method is used to cancel the unknown dynamics and unexpected disturbances. When
the TDC method is applied, the results show that the maximum required torque
for engines is reduced by 7%. And the maximum displacement of the robot has
dropped by 44% around the balance axis. In other words, robot stability has
increased by 78%. Due to the cost of implementing control in practice, this
research runs the HIL simulation for the first time. The use of this simulation
helps in implementing the control algorithms without approximation, and also
the system response can be discussed in a more realistic way.
