Gravity compensation and optimal control of actuated multibody system dynamics
Abstract
This work investigates the gravity compensation topic, from a control perspective. The gravity could be levelled by a compensating mechanical system or in the control law, such as proportional derivative (PD) plus gravity, sliding mode control, or computed torque method. The gravity compensation term is missing in linear and nonlinear optimal control, in both continuous- and discrete-time domains. The equilibrium point of the control system is usually zero and this makes it impossible to perform regulation when the desired condition is not set at origin or in other cases, where the gravity vector is not zero at the equilibrium point. The system needs a steady-state input signal to compensate for the gravity in those conditions. The stability proof of the gravity compensated control law based on nonlinear optimal control and the corresponding deviation from optimality, with proof, are introduced in this work. The same concept exists in discrete-time control since it uses analog to digital conversion of the system and that includes the gravity vector of the system. The simulation results highlight two important cases, a robotic manipulator and a tilted-rotor hexacopter, as an application to the claimed theoretical statements.
1 INTRODUCTION
This paper declares that gravity compensation is necessary for continuous- and discrete-time optimal control. The common form of optimal control design considers the total system dynamics information for constructing the control law, Figure 1a. This generates a problem for regulation to desired conditions rather than equilibrium points or systems with non-zero gravity at the equilibrium point. We propose the gravity compensation in control law, Figure 1b, and prove that the stability of the system will be guaranteed for the total system using a common form of Lyapunov function, where is the optimal gain of the Riccati equation. Then we show the cost of this compensation and its deviation from optimality.

Gravity compensation is an important subject in robotics and multibody system dynamics, addressed by case-dependent novel mechanical designs; or controller-based mechanisms in the literature [1, 2]. It is usually difficult to compensate for the exact force [3]. The compensating mechanical design increases the total weight of the system though the actuation efficiency balances the cost-effectiveness of this point of view. The compensation mechanism was applied to counterbalance the constant weight of the system; however, for practical use, a mechanism for weight variation is necessary since the moving mechanism changes the centre-of-mass (CoM) of different parts [4]. Nakamoto and Matsuhira presented a collaborative manipulator with a gravity compensation mechanism compatible with the variation of load [5]. The idea was to use joint driving motors as counterweights in a compact design. The use of the gravity compensating mechanisms is quite diverse such as machining with manipulators [6], cooperative dual-arm robot [7], deployable mesh antenna [8] etc. Yun et al. researched the compensation mechanism for a dual-arm cooperative manipulator which was subjected to variable weight due to the change of the waist of the robot, or in other words, the CoM of the system [7]. Ugartemendia et al. investigated gravity compensation in rehabilitation robotics [9]. It was concluded that it is a mandatory feature in mechatronics systems for rehabilitations to present a neutral motion feeling for the people subjected to treatment.
On the one hand, it is not always possible to compensate the gravity with a mechanical mechanism due to space limitation, increase in the weight of the total system, cost-effectiveness of the design etc. On the other hand, some systems need gravity compensation, that is, unmanned aerial vehicles (UAVs), helicopters, autonomous underwater vehicles (AUVs) etc. For the later systems, gravity cannot be compensated mechanically; it needs additional thrust, force, or input signal. So, the gravity compensation is studied here, as a control point of view in the optimal input law. The proportional derivative (PD) control is a well-established method for independent control of the actuators, as a non-model-based approach. The structure is also simple, and the constant control gains are responsible for the tuning of the system in question. Appling a PD for systems working under gravity effect, that is, a spatial manipulator, requires high gains for achieving the regulation or trajectory tracking [10]. The classical nonlinear method, PD plus gravity is a good solution to address this problem, avoiding high gain selection [11]. Sliding mode control (SMC) [12], and feedback linearization (FL) [13, 14], are nonlinear controllers with gravity compensation mechanisms, naturally embedded inside the control law; though particular methods were introduced to study this subject as well. De Luca and Panzieri presented an iterative scheme for compensation of the gravity for flexible link manipulators [15]. The learning part found a feedforward term (a signal for gravity compensation) for cases that the modelling was not precise and the load at the end-effector was unknown. The same approach was extended under the input saturation constraint [16]. Bembli et al. applied terminal sliding mode control on a two-DoF exoskeleton limb to gain robust characteristics in gravity compensation [17].
Optimal control usually considers zero equilibrium point and constructs Hamiltonian function and applies a cost function to reach optimal control law. The control law is unified and includes all the system dynamics. On the contrary to PD plus gravity, FL and SMC, in optimal control policies, the gravity is inside the gain and re-scaled (enhanced or weakened). Razmi and Macnab presented a neural network near-optimal control with compensated gravity [18]. The performance was shown by comparison with a linear quadratic regulator (LQR), in which better results were gained after 400 learning iterations.
Adding feedforward gravity compensator to state-dependent Riccati equation (SDRE) controller was reported [19-21]; however, the stability proof only concerned the pure optimal control part (without feedforward gravity). This made the stability discussion vulnerable to severe criticism and also deviated from the results from optimality. So, the works [19-21], were not considered gravity in the stability proof. Here in this work, the stability proof and optimality analysis are addressed with the gravity compensation mechanism. The same subject is open in discrete-time control laws which include the gravity in the system in analog to digital (A/D) conversion of the system matrices. More clarification and the main contribution of this work will be presented in Section 2.
Section 2 expresses the problem statements. Section 3 reports the SDRE controller with stability and optimality analysis. Section 4 presents the same topic for the discrete-time domain. Simulation results for continuous- and discrete-time domains were shown in Section 5. Concluding results are summarized in Section 6.
2 THE DEFINITION OF THE SYSTEM AND MOTIVATION
Remark 1.It is common to assume that the equilibrium point of the system (2) is considered zero . This condition shows that i.e. an elevator mechanism (without physical weight compensation) is at an equilibrium point when all the coordinates are zero that results , which is on the ground. For other cases such as a multirotor drone, there is always a constant gravity force applying on the system which violates the equilibrium condition , see Figure 2. For a robotic manipulator, a configuration represents the equilibrium point in which the same condition holds, zero gravity, although the home position is usually a different configuration, see Figure 3. Note that gravity vector in robotic manipulators is not usually zero even at the equilibrium point, , due to existence of trigonometric functions such as cosine function, . So, there exist systems that correspond to .
Remark 2.The regulation between two arbitrary points in the workspace, not necessarily regulation to the equilibrium point, results in , and consequently where index “des” represents the desired condition.


Case 2: In discrete-time control, the -transform is done based on the linearized system (5) for the entire time of simulation or nonlinear SDC representation of the system (6) at each time step of simulation during the regulation. In the discrete case, the gravity vector is also inside the system matrices or and the control law possesses the digital version of input law (3).
In both cases 1 and 2, it is clear that the regulation to an arbitrary point, except to equilibrium point, results in zero error and therefore, zero control signal. So, how the system should compensate for the gravity to keep the system there. For the sake of brevity, the general nonlinear form will be presented that includes the linear case as well.
- - Could we exclude the gravity from the system and then compensate it in control law, similar to Equation (4), in continuous optimal control? How does it violate stability or optimality?
- - In discrete-time control, could we do the same gravity compensation? How should we manage it since the -transformed matrices are on the digital scale and the gravity vector is in the continuous-time domain?
In Section 3, the stability proof and optimality discussion for a control law in the type of (4) are provided and Section 4 presents the discrete version and its solution method.
3 THE CONTINUOUS-TIME SDRE CONTROLLER
Remark 3.The general form of gravity compensated control (10) is:
where ; similar to Equation (10) when ; so, for the sake of simplicity in the derivation process, we consider control law (10) in the derivation. Considering Remark 1, for manipulators with , and cases in which the desired condition is shifted from zero to another position, the application of the proposed control law (10) preserves the generic view of the approach.
Remark 4.The gravity compensation was used in the literature, that is, Refs. [19, 21], however, the stability/optimality proof for the new form (10) was not presented. Theorem 1 and 2 are addressing the proofs.
Theorem 1.(Stability) The nonlinear system (7), considering Assumptions 1 and 2 and quadratic cost function (8), can be controlled by the gravity-compensated input law (10) in which is the symmetric positive definite solution to SDDRE (15) in finite time , subjected to boundary condition .
Proof.A Lyapunov candidate is used, , concerning , to prove the stability by computing the first derivative and following condition :
Remark 5.The effect of gravity compensation on stability was checked in Theorem 1 and proved that the gravity compensated control law (10) guarantees stability similar to the case when the gravity is inside matrix. The new form answers the main intention of this work, to provide the signal after reaching the desired condition , which was not possible in previous versions. The use of gravity compensation was reported though the stability was not discussed with input law (10) substituted into the Lyapunov function.
The next subject is that how much we deviate from the optimality. The linearized system , , and constant weighting matrices and provide the optimal control for the algebraic matrix Riccati equation at equilibrium point with the constant gain . The solution to the SDDRE tends to the optimal value near the equilibrium point wherein a sufficiently small neighborhood we are close to optimality [31]. Assumption 3 is an extended form which was previously stated in Ref. [31], without the excluded gravity vector . Theorem 2 is also an extended representation of asymptotically optimal results, presented for the systems without gravity compensation [28].
Assumption 3.The matrices , , , , and and their gradients , , , are bounded in a neighborhood around the equilibrium point.
Theorem 2.(Optimality). Considering Assumption 3 and guaranteed gravity-compensated control law (10), for the system (7), limited to cases with and constant , the necessary condition for optimality is asymptotically satisfied near the equilibrium point when , with a quadratic rate with respect to .
Proof.To prove the optimality, the three conditions, obtained from Pontryagin's minimum principle, must be held. Considering Hamiltonian function (9), the first necessary condition for optimality results in:
Since we solve the SDDRE (15) to obtain the symmetric positive definite gain , turns into Equation (14).
-
, when includes direct position coordinate or function which results in , since . In this case, the optimality discussion is straightforward and is based on the presented proof.
-
, when includes i.e. function (robotic manipulators). Since , the gravity parameterized matrix tends to infinity , for the system with , the necessary condition for optimality, Equation (20), is not satisfied and , so we cannot find a upper-bounded matrix for the case of .
-
Optimality for a special case, flying objects. Theorem 2 stated that if , the necessary condition for optimality is not satisfied; however, there is a special case for systems with constant where we have the optimality. For that case, we consider constant gravity and put the derivatives equal to zero, then Equation (20) turns into:
(22)
The conclusion is that optimality, based on Theorem 2, is satisfied for systems with and systems with the constant gravity vector. However, stability is guaranteed for all systems and since the control law and Lyapunov function use without factorization. That concludes the optimality proof. The deviation from optimality for case (a) is defined by Equation (20) and for case (c) is computed by Equation (23). It is clear that .
For linear systems, the LQR problem, the optimality is completely satisfied since the gradient terms in Assumption 3 are zero. For the SDRE problem, considering the differential form of the Riccati equation, the deviation from optimality is found in the optimality proof, a negligible value; however, this value avoids naming the SDRE as an optimal controller. For that, the SDRE/SDDRE controller has been referred to as a suboptimal controller in the literature [21, 26, 31–33].
4 THE DISCRETE-TIME SDRE CONTROLLER
To present the discrete-time-control design, system (7) must be transformed into discrete-time domain by the -transform algorithm and a sampling time . Simple systems could be transformed analytically nevertheless complex ones could be transformed at each sample time after updating with measured feedback. Similar to Section 3, putting gravity inside the system matrices and imposes a glitch in implementation on systems with gravity or at arbitrary desired conditions, . So, the discretization is done on system (7).
Assumption 4.(Controllability Condition, discrete-time domain). The pair of is a completely controllable parameterization of the system (24).
Assumption 5.(Observability Condition, discrete-time domain). The pair of is a completely observable parameterization of the system (24).
Considering backward counting of in Equations (32) and (33), the current loop is and gain is updated by the solution, in the loop where counts from to .
Remark 6.Control law (32) must be used in the backward solution to find the gain over discrete steps, , that covers the time span . After completing the backward solution, the control law for the forward (main) control loop is Equation (32); however, counts forward from to .
Remark 7.The system Equation (24), for the backward solution, is changed to:
where counts backward from to 1.
Implementation.It is necessary to use a digital to analog (D/A) converter to bring back the input Equation (32) to the scale of the continuous-time domain (a continuous step-like signal using, i.e. zero-order hold) and send the signal to the actuators [36]. Revisiting the main objective of this work, Equation (32) does not provide the necessary input for the system at the steady-state position or arbitrary desired condition, rather than .
5 SIMULATIONS
5.1 Continuous-time control, robotic manipulator
Consider a 3-DoF articulated-joint manipulator [37], see Figure 3 for a schematic view of the system. The second and third links of the manipulator are subjected to gravity. The home position of the robot requires a steady-state input for maintaining the robot in that position. The length of the links are , and with respect. The mass of the links and load are and ; gravity constant is ; the friction terms in the joints are presented by ; the moment of inertia of the links are , and with respect. The complete dynamic equation could be derived by general codes, presented in Appendix of Ref. [20].
The control parameters were chosen as , and . An increase in increases the precision and reduction in also enhances the amplitude of the input signal [21, 38]; an increase in provides more accuracy in regulation near the final time. The configuration of the system and the trajectory are presented in Figure 4, successfully regulated to the desired condition, and , with end-effector error. The input torque signals to the system are presented in Figure 5. The steady-state value of the first input was gained zero since it was not subjected to gravity based on the configuration though the other two links need gravity compensation. The norm of the input and gravity vector are illustrated in Figure 6. It is clear that without gravity compensation, the system would fail to stay at desired condition since it needs to hold the weight of the second and third links in addition to the weight of load at the end-effector.



Noticing Figure 6 brings up this question that optimizing the gain for gravity is necessary or not. Considering a system with precise modelling and lack of disturbance, one knows the value of gravity in a trajectory. The necessary input for compensation of the gravity should be the closest value. Enhanced gain provides excessive use of energy and smaller gains reduce the performance. The proposed gravity compensated control law balances the known gravity value and presents an optimal control policy.
5.2 Discrete-time control, hexacopter with tilted rotors
Multirotor unmanned aerial vehicles with fixed vertical rotors can generate a total thrust parallel to the axis of the rotor. The total thrust on the body frame can be projected to the global frame providing three components, though the system is under-actuated. Cascade design is a common way to solve the under-actuation problem for multirotor UAVs [39]. The method benefits from a virtual constraint to define the desired orientation of the system for translation control. Rotating the rotor axis around the connecting rod between the motor and the centre of mass (CoM) of the UAV generates thrust in all three axes , rather than only , for parallel rotors. This new configuration allowed full-actuation for multirotor UAVs [40]. The schematic view of a multirotor copter with fixed titled rotors is presented in Figure 7.

In hovering condition, Equation (39), is almost an identity matrix satisfying the proposed SDC structure.
The control law is designed based on generalized force and moments in global coordinates . To define the local force vector for applying force limitation, the following relation is used .
Mixer matrix and actuator limit: The ultimate control inputs of the multirotor UAV are the voltage signals to the motors, attached to the propellers. The input voltage signals define the angular velocity of the rotors. The relation between the input force/moment vector and the angular velocities of the motor is indicated by a linear map, a mixer matrix. The mixer matrix for common quadrotors is straightforward and could be calculated easily. The mixer matrix for fixed tilted rotors, specifically with two rotations, is more complex.

The third column of is named .
The parameters of the hexacopter are presented in Table 1. The initial condition of the UAV was set on zero condition, the equilibrium point, and the desired position was defined as . The simulation time was 10 seconds and the weighting matrices were chosen as , , , , , in which and . Considering the number of discretisation , the error of the regulation was found . The configuration and trajectory of the UAV are depicted in Figure 9. The position states of the hexacopter are demonstrated in Figure 10. The translation forces of the system are presented in Figure 11. Since the desired orientation of the UAV is not zero, the translation forces are not zero in directions. The mixer matrix defines the angular velocities of the system, Figure 12, and reduces to the steady-state values. The steady-state values of the rotors’ angular velocities are not similar since we have the desired pose.
Par. | Values | Units | Definition |
---|---|---|---|
L | 0.2 | m | Dist. motor & CoM |
R | 0.125 | m | radius of the propeller |
k | lift constant - thrust factor | ||
drag constant | |||
moment of inertia X axis | |||
moment of inertia Y axis | |||
moment of inertia Z axis | |||
m | 1.2 | kg | mass of the quadrotor |
kg/s | drag matrix | ||
282.83 | rad/s | Max. Ang. Vel. of rotors | |
α | π/6 | rad | rotation around axis |
β | π/6 | rad | rotation around axis |




The angular velocities of the rotors, presented in Figure 12, are limited between two positive bounds, . If the gravity is not compensated by the control law and one gets zero error and the end of the simulation, therefore, zero inputs, Equation (43) fails to deliver a solution. The reason is that all the control signals tend to zero (without gravity compensation) and the angular velocities of the rotors will be found around zero after a couple of oscillations. The second reason for failure without gravity compensation is that Equation (43) does not release negative values because of the square root. So, the steady-state shift in thrust input is necessary for the successful simulation. Optimal control without gravity compensation is not able to deliver a solution in a unified manner. In other words, the drone needs around for hovering in the desired condition steadily.
6 CONCLUSION
Gravity compensation in the framework of the optimal control was investigated to check the effect of the modified control law plus gravity on the stability and the deviation from the optimality. The stability proof was guaranteed using the Lyapunov method and the optimality was analysed by the implementation of Pontryagin's Minimum Principle. The simulation results confirmed the proposed structure and showed successful results for the continuous- and discrete-time control domain. In brief, we presented a new optimal control that optimized the control signal around the steady-state value of the gravity vector (see the introduced cost function (8)) whether it is zero or not. The stability proof for this special presentation of the systems was presented for the first time and the deviation from optimality was shown.
For the systems with the state and input constraint, the stability and optimality proof, presented in this work, are held. The state constraint is applied by modification of the weighting matrix , preserving the symmetric positive definite form and observability condition [43]. The input constraint is applied externally on the input signal [19]; hence, the derivation and stability/optimality analysis are valid. An example for the input constraint has been considered in simulation, Section 5, see Equation (43).
ACKNOWLEDGEMENT
This work is supported by the ERC as part of GRIFFIN advanced Grant 2017, Action 788247, and by the EU H2020 under AERIAL-CORE project contract 871479, and HYFLIERS project 779411.
CONFLICT OF INTEREST
The authors declare no conflict of interests.
Open Research
DATA AVAILABILITY STATEMENT
Data sharing not applicable – no new data generated.
REFERENCES
- 1 In cost function and derivation of the control, should not be confused with .