Ball in double hoop: demonstration model for numerical optimal control
Martin Gurtner, Ji\v{r}\'i Zem\'anek

TL;DR
This paper extends the classic ball and hoop system to include multiple modes and demonstrates how it can be used for advanced control techniques like trajectory generation and stabilization, with experimental validation.
Contribution
It introduces a comprehensive hybrid model with multiple modes and demonstrates its use for complex control tasks, expanding educational tools for control systems.
Findings
Successful trajectory generation and stabilization for complex modes
Experimental validation of the control approach
Enhanced model for educational demonstration of advanced control
Abstract
Ball and hoop system is a well-known model for the education of linear control systems. In this paper, we have a look at this system from another perspective and show that it is also suitable for demonstration of more advanced control techniques. In contrast to the standard use, we describe the dynamics of the system at full length; in addition to the mode where the ball rolls on the (outer) hoop we also consider the mode where the ball drops out of the hoop and enters a free-fall mode. Furthermore, we add another (inner) hoop in the center upon which the ball can land from the free-fall mode. This constitutes another mode of the hybrid description of the system. We present two challenging tasks for this model and show how they can be solved by trajectory generation and stabilization. We also describe how such a model can be built and experimentally verify the validity of our approach…
| Description | Parameter | Value | Unit |
|---|---|---|---|
| Radius of the outer hoop | 95.8 | ||
| Radius of the inner hoop | 43.8 | ||
| Radius of the ball | 7.7 | ||
| Inertia of the ball | |||
| Mass of the ball | 0.032 | ||
| Friction of the ball | |||
| Gravitational constant |
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Taxonomy
TopicsControl and Stability of Dynamical Systems · Control and Dynamics of Mobile Robots · Robotic Mechanisms and Dynamics
Ball in double hoop: demonstration model for numerical optimal control
Martin Gurtner
Jiří Zemánek
Faculty of Electrical Engineering
Czech Technical University in Prague
Technicka 2, 166 27 Praha 6, Czech Republic
{martin.gurtner,jiri.zemanek}@fel.cvut.cz
Abstract
Ball and hoop system is a well-known model for the education of linear control systems. In this paper, we have a look at this system from another perspective and show that it is also suitable for demonstration of more advanced control techniques. In contrast to the standard use, we describe the dynamics of the system at full length; in addition to the mode where the ball rolls on the (outer) hoop we also consider the mode where the ball drops out of the hoop and enters a free-fall mode. Furthermore, we add another (inner) hoop in the center upon which the ball can land from the free-fall mode. This constitutes another mode of the hybrid description of the system. We present two challenging tasks for this model and show how they can be solved by trajectory generation and stabilization. We also describe how such a model can be built and experimentally verify the validity of our approach solving the proposed tasks.111All codes and drawings are available at http://github.com/aa4cc/flying-ball-in-hoop
keywords:
Trajectory planning; Optimal control; System modeling; Hybrid systems; Control education; Mechatronic systems
††thanks: This work was supported by the Grant Agency of the Czech Technical University in Prague, grant No. SGS16/232/OHK3/3T/13, and partially by the Czech Science Foundation within the project P206/12/G014.
1 Introduction
Ball and hoop system is well-established among laboratory models used in teaching control. Its origin dates back to Wellstead (1980, 1983) who introduced it as a simple model having qualitatively the same dynamics as the liquid slop problem; in addition, Wellstead (1980, 1983) and Fabregas et al. (2011) also described how this model can be used in teaching of linear control theory. More specifically, the model was used in a regime where the ball is close to the stable position on the hoop and where a linear approximation of motion dynamics is valid.
In contrast, we consider full repertoire of motions the system offers. We describe the system as a hybrid model with a mode where the ball rolls on the outer hoop and with a mode where the ball has dropped out and entered a free-fall mode. This description enables us to generate dynamically richer trajectories (for instance, the ball can go through the top of the hoop or even fly in free fall); nevertheless, such trajectories also require more advanced control techniques. First, one needs to find a way to generate such trajectories. Second, the trajectories have to be stabilized; in other words, one cannot simply take the controls corresponding to a desired trajectory, apply it to the system and expect to observe the desired trajectory. This model is ideal for a demonstration of how these techniques, trajectory generation and stabilization, can be applied because it is relatively simple and allows one to pose tasks which are rather difficult to solve by other means. We propose and solve two such tasks. Specifically, we formulate each task as an Optimal Control Problem (OCP) with nonlinear dynamics and limited control input. We solve the OCPs and show how to stabilize the obtained trajectories.
In addition, we added another hoop inside the outer one. This further extends the variety of tasks that can be solved on this system; one can, for example, swing up the ball on the outer hoop, let it fall and stabilize it on the inner hoop. It is worthy of note that the stabilization of the ball on the inner hoop can be viewed as stabilization of a disk on a disk; that itself is an interesting problem (for references, see Ryu et al. (2013)).
This paper is organized as follows. In Section 2, we derive a mathematical model of the system. In the following section, we present two examples of interesting and challenging tasks for this system and propose an approach solving them. In Section 4, we describe hardware setup of the system and verify the viability of the proposed approach solving the tasks.
2 Modeling
The system is cartooned in Fig. 1 and the modes of the hybrid description are displayed in Fig. 2. The hybrid description has three modes: the ball rolls on the outer hoop (S1), the ball is in free fall (S2), and the ball rolls on the inner hoop (S3).
Before we delve into the derivation of equations of motion for each mode, let us devote a few words to coordinate systems in which we will describe the motion of the ball. Due to the rotational symmetry, polar coordinates are a natural choice for modes S1 and S3. In contrast, Cartesian coordinates are more suitable for the free-fall mode (S2) because then the equations of motion are linear. In fact, it turns out that the description of motion in S2 in polar coordinates is strongly nonlinear. Thus, from the implementation point of view (i.e. to increase numerical stability), one should use polar coordinates for modes S1 and S3 and Cartesian coordinates for S2. Nevertheless, transformations of the coordinates would make equations in this paper unnecessarily complicated, and thus we stick to polar coordinates for all three modes.
For simplicity, we will not state the time dependence explicitly. At first, we derive equations of motion for each mode and after that, we describe guards and reset maps for transitions between the modes.
2.1 Outer hoop (S1)
A model of a ball rolling in a hoop was derived by Wellstead (1983). For reader’s convenience—and because Wellstead made a small mistake in the derivation of the model—we rederive the model.
We use Euler-Lagrange equation to derive the model. Let us choose angles and (see Fig. 1) as the generalized coordinates. We assume that the ball rolls without slipping. In addition, we do not consider the dynamics of the hoop as we assume that we can directly command the angular acceleration of the hoop . In fact, the acceleration will be our input to the model and it constitutes a rheonomic (time-varying) constraint. This constraint reduces the number of independent coordinates to one.
The kinetic co-energy of the ball is
[TABLE]
where is the mass of the ball, is the moment of inertia of the ball and . The translational velocity and the angular velocity of the ball can be expressed as follows
[TABLE]
Thus, the kinetic energy expressed in the generalized coordinates is
[TABLE]
Potential energy of the ball is given by
[TABLE]
and the system content modeling friction of the ball is
[TABLE]
Defining the Lagrangian , an equation of motion of the ball can be computed by Euler-Lagrange equation as
[TABLE]
which results in the following differential equation
[TABLE]
with coefficients
[TABLE]
2.2 Free fall (S2)
The motion of the center of the ball in free fall can be easily described in Cartesian coordinates because the only force acting on the ball is the gravitational force. Considering the Cartesian coordinate system shown in Fig. 1, we have
[TABLE]
In order to get equations of motion in polar coordinates (see Fig. 1), we only need to transform the coordinates by relations and . This way, we get
[TABLE]
To fully describe the state of the system during free fall of the ball we also need to describe evolution of ; we assume that the angular velocity is constant during the free fall.
2.3 Inner hoop (S3)
A sketch of the ball rolling on the inner hoop is shown in Fig. 3. The equations of motion for the ball rolling on the inner hoop can be derived along similar lines as for the ball on the outer hoop. The only difference is that the effective rolling radius is instead of and angle has the opposite orientation. Therefore, we skip the derivation and state directly the resulting equations of motion:
[TABLE]
where
[TABLE]
2.4 Transition between modes
2.4.1 Transition from S1 to S2
Mode S1 (outer hoop) is valid as long as the centripetal force acting on the ball is larger then the normal component of the gravitational force with respect to the hoop. Mathematically, it is valid if
[TABLE]
If this condition does not hold, the ball drops of the hoop. It readily follows from (13) that the guard for transition from S1 to S2 is
[TABLE]
The reset map for states , , and is
[TABLE]
The first three relations are apparent. The last one is derived from the inertial angular velocity of the ball and (2b). The remaining states transit to the mode S2 without any change, that is , , and .
2.4.2 Transition from S2 to S1
This transition occurs when the ball hits the outer hoop. Thus the guard is
[TABLE]
and the corresponding reset map for is
[TABLE]
where is derived from the angular velocity of the ball and can be computed from (2b):
[TABLE]
The remaining states transit unchanged, that is , and .
2.4.3 Transition from S2 to S3
Analogously to the previous case, the transit occurs when the ball hits the inner hoop and the guard is
[TABLE]
The reset map is also almost the same; the only difference is that the angular velocity here is computed as follows
[TABLE]
2.4.4 Transition from S3 to S2
Similarly to the transition from the outer hoop to free fall, the transition from the inner hoop to free fall occurs when the centripetal force becomes larger then the normal component of the gravitational force with respect to the hoop, that is
[TABLE]
and analogously to (15), the reset map is
[TABLE]
with the remaining states , , and transiting unchanged.
3 Examples of interesting tasks
The hybrid description of the system allows us to pose visually appealing and from control perspective challenging tasks. In this section, we show two such tasks and describe control algorithms solving them.
Task 1: Roll the ball around the outer hoop
This task is sketched in Fig. 4 on the left side. In the beginning, the ball is in the steady position on the outer hoop and the goal is to roll it around the hoop and get it back to the steady position. One might roughly imagine this task as the famous Loop-the-Loop stunt where a car rides around a vertical circle.
Naturally, this task is an instance of an Optimal Control Problem (OCP). The ball is supposed to stay on the outer hoop and thus the hybrid model remains in the mode S1. To simplify the notation, let us define a state vector as
[TABLE]
and the state-space description corresponding to the mode S1 as
[TABLE]
where and
[TABLE]
Now, we formulate the task as an OCP. In the initial time , everything is steady and thus the initial condition is . In a final time , we require that the ball has rolled around the hoop, is back in the steady state and the hoop does not move; that imposes conditions , and . Furthermore, to ensure that the ball does not drop out of the hoop, we require that the guard is inactive during the whole trajectory. Instead of specifying the final time, we leave it as an optimization variable; we only require that the final time is smaller than a certain value . We also put bounds on the control . Finally, the objective is to minimize the control . Altogether, the OCP is
[TABLE]
To solve this OCP we use direct collocation (Hargraves and Paris (1987)) to discretize it to equidistantly distributed knots in time and formulate it as a nonlinear programming problem (NLP). This simplification, however, comes at a cost. NLP solvers usually does not guarantee optimality and provide only suboptimal solutions. Let us denote a (possibly suboptimal) solution provided by a NLP solver by , and .
By solving the NLP, we obtain a discrete trajectory of the system evaluated at certain time instants separated by sampling time . Ideally, if the model captures the real system well enough and the sampling time is short enough (say, a few milliseconds), an application of the control input results in the desired state trajectory . Nevertheless, short sampling periods imply large number of knots and thus make the NLP larger and possibly intractable. Furthermore, the model usually mismatches the real system to some extent. Therefore, we need to stabilize the trajectory; we need to keep the system as close as possible to the desired trajectory.
3.0.1 Trajectory stabilization
To stabilize the trajectory, we invoke the powerful framework of Linear Quadratic Regulators (LQR) and neighboring extremals (Bryson and Ho (1975)). We linearize the model around the trajectory and thus obtain a linear time-varying deviation model
[TABLE]
where and . The time-varying matrices are
[TABLE]
Now we design an LQR stabilizing the deviation model hence keeping small and the system close to . We stick to a common notation and denote the state and input weight matrices by and , respectively. The control law of the LQR is
[TABLE]
where matrix is given by the solution of the differential Riccati equation
[TABLE]
with final time condition .
Finally, the applied control to the system is given by a sum of the nominal input and the trajectory stabilizing term :
[TABLE]
Task 2: Get the ball on the inner hoop
The second task we would like to solve is to get the ball from the steady position on the outer hoop to the top of inner hoop and stabilize it there. This task is sketched in Fig. 4 on the right side. Once again, we formulate this problem as an OCP, find a trajectory solving the problem and design a regulator stabilizing this trajectory.
Apparently, the trajectory we are looking for starts and ends in different modes of the hybrid model. This poses especially difficult problem to the trajectory generation because in the discretization of the corresponding OCP, one does not know how many knots should be assigned to each mode. Fortunately, the requirement that the ball ends up on the inner hoop can be reformulated to a requirement that the ball ends up on the outer hoop at specific angle with specific angular velocity . This is due to the fact that the free-fall mode is uncontrolled and thus the state of the system leaving the free-fall mode is fully determined by the state of the system entering the free-fall mode. Therefore, we can find a trajectory solving Task 2 by the same approach as we used for Task 1.
In addition to and , we also require that the hoop has specific angular velocity at the moment when the ball drops out of it. That is because by reset map (15d), determines during the free fall and thus by reset map (20) also just after the ball lands on the inner hoop. Therefore, we compute so that after the impact is minimized.
The OCP for Task 2 has exactly the same form as (25); the only difference here is that the conditions for the final states are
[TABLE]
The remaining steps to solve this task are almost the same as with the previous one. The only additional step is to design a regulator stabilizing the ball on the inner hoop. After the ball lands, we hand over the control to a stationary LQR designed for this purpose.
4 Experimental verification
To verify the validity of our approach, we implemented the proposed control algorithm and tested it on a real hardware setup.
4.1 Construction of the model
The hardware setup used for the verification is displayed in Fig 5. Parameters of the setup are summarized in Table 1. The hoop is 3D-printed222The drawings and codes are available at http://github.com/aa4cc/flying-ball-in-hoop and it has imbedded rubber o-rings serving as high-friction rails for a metal ball. The hoop is attached to a BLDC motor driven by a PearControl ESC3 regulator enabling us to control the motor in a speed and current mode. To simplify the control algorithm, we let the current control to the motor regulator and used the speed mode to set directly a desired angular velocity . Nevertheless, in Section 2 we considered to be the control input to the model, thus also the output of the regulator. Therefore, to get , we numerically integrate the output of the regulator . Judging from the experiments, the control system performs surprisingly well in spite of this simplification.
4.2 Implementation
The control law was discretized by sampling of (31) and it was implemented in Simulink. We used Support Package for Raspberry Pi Hardware to generate code, compile it, and run it on Raspberry Pi 3. Raspberry Pi 3 has sufficient computational power that it also allows us to measure the position of the ball by processing images from Raspberry Pi camera module. The image-processing algorithm was implemented in Python and OpenCV. Both, the image processing and control algorithm run at .
The trajectory stabilizing regulator, as a state regulator, needs to know values of all states. States and do not need to be measured because they are given by integration of the input . Angle of the ball is measured by a camera and image processing. Nevertheless, the angular velocity is rather difficult to measure directly and thus has to be estimated. For this purpose, we used a discrete Extended Kalman Filter (EKF) in the standard setting.
Beside the model mismatch and state estimation, in the reality, one also usually has to deal with a latency in the measurement. In our hardware setup, we measured the latency of the measurement of to be approximately two control periods (). Thus, at control period , we at first estimate the state by EKF based on the previous estimate , and and then compensate for the delay by two-step prediction:
[TABLE]
where is the control period and it equals to .
4.3 Verification
Regarding Task 1, a reference trajectory obtained by the solution of (25) together with a trajectory measured on the real hardware setup are shown in Fig. 6. Apparently, the validity of the control algorithm is verified; it is able to follow the desired trajectory to such an extent that the ball ends up in the desired position and does not drop out of the hoop. We have not yet implemented the solution of Task 2 on the real hardware setup. Nevertheless, the proposed solution works very nicely in simulations as Fig. 7 shows. Solutions of both tasks are also presented in a video clip available at http://youtu.be/GBKhRHtjpvQ.
5 Conclusion
We showed that the well-known ball and hoop system can be used not only to demonstrate some aspects of linear control theory but also to demonstrate strengths of numerical optimal control. We extended the ball and hoop system by another hoop and described this extended system by a hybrid model. We presented two tasks for the extended system that are ideal for a demonstration of trajectory generation and stabilization and solve them. As the model of the extended system is simple, one can also use it for a demonstration of control techniques that are based on Sum-Of-Squares programming. For instance, our proposed solution of the presented tasks can be extended by LQR trees (Tedrake et al. (2010)) to work also for varying initial conditions. Furthermore, the inner hoop can be replaced by something else. For example, one can replace it by a beam and modify the Task 2 to “get the ball on a beam and stabilize it there”. Or, the inner hoop can be replaced by a figure-eight shaped rails and the “butterfly” task can be solved on the system (Cefalo et al. (2006)).
The reference list from the paper itself. Each links out to its DOI / PubMed record.
- 1Bryson and Ho (1975) Bryson, J.A.E. and Ho, Y.C. (1975). Applied Optimal Control: Optimization, Estimation and Control . CRC Press.
- 2Cefalo et al. (2006) Cefalo, M., Lanari, L., and Oriolo, G. (2006). Energy-based control of the butterfly robot. IFAC Proceedings Volumes , 39(15), 1–6.
- 3Fabregas et al. (2011) Fabregas, E., Farias, G., Dormido-Canto, S., Dormido, S., and Esquembre, F. (2011). Developing a remote laboratory for engineering education. Computers & Education , 57(2), 1686–1697.
- 4Hargraves and Paris (1987) Hargraves, C.R. and Paris, S.W. (1987). Direct trajectory optimization using nonlinear programming and collocation. Journal of Guidance, Control, and Dynamics , 10(4), 338–342.
- 5Ryu et al. (2013) Ryu, J.C., Ruggiero, F., and Lynch, K.M. (2013). Control of nonprehensile rolling manipulation: Balancing a disk on a disk. IEEE Transactions on Robotics , 29(5), 1152–1161.
- 6Tedrake et al. (2010) Tedrake, R., Manchester, I.R., Tobenkin, M., and Roberts, J.W. (2010). Lqr-trees: Feedback motion planning via sums-of-squares verification. The International Journal of Robotics Research , 29(8), 1038–1052.
- 7Wellstead (1980) Wellstead, P.E. (1980). Scale models in control systems engineering. Transactions of the Institute of Measurement and Control , 2(3), 137–155.
- 8Wellstead (1983) Wellstead, P.E. (1983). The ball and hoop system. Automatica , 19(4), 401–406.
