# A Method of Offline Reinforcement Learning Virtual Reality Satellite Attitude Control Based on Generative Adversarial Network

Authors: Jian Zhang; Fengge Wu
Journal: Wireless Communications and Mobile Computing
 (2021)

---

## Abstract

Virtual reality satellites give people an immersive experience of exploring space. The intelligent attitude control method using reinforcement learning to achieve multiaxis synchronous control is one of the important tasks of virtual reality satellites. In real-world systems, methods based on reinforcement learning face safety issues during exploration, unknown actuator delays, and noise in the raw sensor data. To improve the sample efficiency and avoid safety issues during exploration, this paper proposes a new offline reinforcement learning method to make full use of samples. This method learns a policy set with imitation learning and a policy selector using a generative adversarial network (GAN). The performance of the proposed method was verified in a real-world system (reaction-wheel-based inverted pendulum). The results showed that the agent trained with our method reached and maintained a stable goal state in 10,000 steps, whereas the behavior cloning method only remained stable for 500 steps.


---

## Body

## 1. Introduction

Virtual reality satellites enable people to explore space using any mobile, desktop, or virtual reality device. Traditional attitude control methods require single-axis alternate control. In order to track all kinds of observed celestial bodies in real time, efficient attitude control methods need to be studied. The attitude control method based on reinforcement learning gives a feasible path to achieve efficient three-axis synchronous control.Reaction momentum wheels are widely used in modern satellites as executive mechanisms that can redistribute momentum between the satellite body and the momentum wheel. Studies on the attitude control algorithms for this kind of actuator have focused on how to control the attitude of the satellite body by adjusting the momentum. Methods based on classical control theory, such as proportional–integral–derivative (PID), linear–quadratic regulator (LQR), and iterative linear–quadratic regulator (LQR), are widely used in this field, and these methods rely on an analytical model of the satellite’s rigid body dynamics. The design stage requires sufficient system knowledge, manual parameter adjustment, and multiple experiments. The control algorithm in an experiment may fail due to unreasonable parameter selection (such asP, I, and D parameters). The reinforcement learning paradigm provides a powerful framework for problem solving and has proven to be a promising and nonintuitive problem-solving technology in many challenging environments, such as MuZero [1], Atari games [2], Go [3], and GYM [4]. However, the application of reinforcement learning in real-world systems has just started, mainly for the following reasons:
(1)
In a real-world environment, sample acquisition costs are high, and the incentive function cannot be accurately described since the function is typically a multiobjective function and the objectives are related to each other(2)
The system sensor contains noise(3)
The actuator control frequency has a limiting value(4)
Due to security issues, the system cannot be explored at will(5)
It is impossible to effectively reset the system to the initial state at the end of each training sessionAdditional issues can arise in real-world systems. Applying reinforcement learning to satellite attitude control faces the challenges described above. In this study, we construct a physical system to introduce the characteristics of the real-world system.Based on whether historical data is used to establish the environmental model transfer function explicitly, reinforcement learning methods can be divided into two broad categories: model-free and model-based methods. Model-free methods require continuous interactions with the environment during the learning process. To improve the performance of the policy during the training iterations, model-free methods often require a large number of samples to learn and are prone to problems of high collection times and costs caused by the low sampling efficiency. However, once a method converges, it can often obtain a policy with a better performance.Depending on whether the policy for interacting with the environment is consistent with the policy that is required to improve performance and whether the collected samples can be reused, model-free methods can further be divided into two categories: on-policy and off-policy methods. On-policy methods use the same policy to interact with the environment. After the policy is updated, the data sampled by the current policy needs to be used to estimate theQ-value function or A-value function to ensure the correctness of the estimate. The samples collected in each iteration need to be discarded. Representatives of these methods include state–action–reward–state–action (SARSA) [5], policy gradient, trust region policy optimization (TRPO) [6], and proximal policy optimization (PPO) [7]. Off-policy methods allow the use of policies different from those that need to be updated to interact with the environment. Samples collected during each interaction can be collected and used in the next policy update. These methods are represented by Q-learning [8], deep deterministic policy gradient (DDPG) [9], twin delayed DDPG (TD3) [10], and soft actor–critic (SAC) [11].Applying on-policy methods directly to a real system will amplify the many problems caused by the low utilization rate of the samples. Therefore, the application of this type of method is mainly in simulation environments. Elkins et al. [12, 13] trained a satellite attitude stabilization controller in a simulation environment. In comparison, off-policy methods alleviate the problem of sample utilization. In recent years, they have been applied in real-world systems. For example, Haarnoja et al. [14] used the improved SAC algorithm to directly train Minitaur quadruped robots, achieving gait control for a variety of sports.Model-based reinforcement learning methods use historical data to explicitly learn environmental dynamics models and return functions, to learn policies, to evaluate actions, and to formulate plans using the learned models. This type of method is mainly concerned with two factors: the accuracy of the learning dynamics model and how to use the model effectively. In improving the accuracy of the environmental dynamics model predictions, challenges such as randomness and uncertainty must be addressed. For low-dimensional problems, Bayesian parameter-free models such as Gaussian processes have become an effective choice. Parameter-based neural networks have become a popular research topic in recent years, and a probabilistic ensemble (PE) dynamic model has been proposed and achieved state-of-the-art results.In terms of how to effectively use the model, the first type of method does not consider the cumulative error. It only selects one action, such as random shot, model predictive control (MPC), or cross entropy method (CEM), and selects the current optimal action by simulating multiple paths in the learned environment. This type of method often requires powerful computing resources. The second type of method begins from the perspective of learning policies in the environment, makes the most efficient use of the dynamic models, represented by model-based policy planning (POPLIN) [15], stochastic lower bound optimization (SLBO) [16], and model-based policy optimization (MBPO) [17], and draws upon theories to determine how to correctly make choices in the interaction between the real environment and the model.The above methods can be effectively applied to real-world systems, and they are mainly bridged in two ways. One is to build a simulation environment close to the real-world system and deploy the policies obtained after training in the simulation environment to the real system. The second is to learn the environmental model based on historical data and use mixed training in the environmental dynamics model and the real system to obtain the final deployment policy. In the scenario considered in this study, the following facts make it difficult to use existing methods directly: (1) it is impossible to accurately construct a scenario similar to the real world (such as an on-orbit environment in outer space), (2) it is impossible to interact with the real-world system during the training phase, and (3) real-time simulations are not supported.Our method trains the policy set at different stages through the historical state-action trajectory data and takes the global data to train the discriminator. In the actual operation, the method relies on the discriminator to determine the action proposed by the policy set to select the optimal action and to reduce the upper bound of error that is proportional to the square of the number of steps with behavior cloning. The innovations of this paper are as follows. (1) This paper proposes a new imitation learning method to solve the continuous control problem. (2) Through training, a low-level control policy for a real system with a reverse momentum wheel as the actuator was obtained. (3) By only using the onboard original sensor information to achieve the end-to-end control of the multimotor pulse width modulation (PWM) signals, the control task of balancing on a corner was completed.


## 2. Methodology

Figure1 shows the overall idea of the method in this paper. The method uses historical data to train the policy set and policy selector in the training stage. In the actual utilization stage, it applies the policy set to calculate the candidate action set based on the current state. Based on the current state and candidate action set, it then relies on the policy selector to calculate the final action submitted to the actual system for execution. As shown in the left part of Figure 1, each policy in the policy set uses part of the data for training, which is called local training, where the data used is marked in different colors. The selector uses global data. Training is called global training, and only one selector is marked with a unique color. Sections 2.1 and 2.2 describe the details of the policy set training and policy selector design, respectively.Figure 1
The overall idea of the method.


### 2.1. Policy Set Training

Behavior cloning transforms the learning problem into a supervised learning problem of fitting expert demonstration behavior. That is, given expert state-action pair trajectory data, the deterministic policy function receives a state as an input and then outputs an action that should be close to the expert’s action in the historical data. For a random policy function, it outputs the distribution of actions in the current state. Under this distribution, the expert’s actions in the current state should have a high probability value. When using a neural network to characterize a policy function,π, the policy function is typically determined by the neural network architecture and parameters θ, so it can be written as πθ. The policy network training task is to adjust θ and find θ∗ to minimize the loss function. The task and the loss function are expressed as follows:
(1)θ∗=argminθLθ,Lθ=Es,a~D12πθ∙∣s−a2,where E denote the expectation and s,a~D denote the state, action pair sampled from the data D to estimate the expectation.Ross et al. presented the following conclusion. The policy (s) is obtained by supervising training with a labeled training set. When the action at given in the state s and the optimal action a∗ are evaluated with a 0-1 loss, Lπ=Eτ~π∑0t=H1at≠a∗ (τ is the trajectory collected by policy π) will be within the upper bound given as follows.
(2)Lπ≤C+H2ϵ,where ϵ is the generalization error in the distribution s~dπs and C is constant. This means that when the time length is H, the deviation of the error will grow as the square of H, which will cause to deviate significantly from the expert policy. Thus, the state distribution dπs obtained by executing the policy π is far away from the state distribution dEs obtained by using the expert policy.To address this issue, the collected expert trajectories are segmented, and policies of different stages are trained for different state sets. This allows the policy selector to control the length of time used by each policy and to reduce the overall accumulated error, as shown in Figure2. Rectangles of one color represent the training data used in one policy. The overlapping area is set in the segmented data of the interval. Given the training set τ1,τ2,⋯,τN, the trajectory length is H, and the policy set is π1,π2,⋯,πK, the width of the data used to train each policy is W, and the width of the overlapping area is S. The following relationship W∗K−S∗K−1=H must be satisfied. For the i-th policy in the policy set πθi during training, minimize the following loss function:
(3)Lθi=Eτ~π∑W∗i−1−S∗i−1t=W∗i−S∗i−112πθi∙∣st−at2.Figure 2
An example of policy set training.


### 2.2. Design of Policy Selector Based on Generative Adversarial Network

The generative adversarial network (GAN) was first proposed by Goodfellow [18]. It is a generative model that uses deep neural networks. The generative adversarial network consists of two components: a generative model and a discriminator model. The generative model is used to generate new samples, and the discriminator model distinguishes the generated samples from the real samples. In the training, the training goal of the generative model is to make the generated samples for the discriminator to recognize its real samples, and the training goal of the discriminator is to correctly distinguish between true and false samples. The two models improve performance in adversarial mode so that the generative model can converge to generate data that is similar to the distribution represented by the real sample data. Meanwhile, the discriminator model has a high accuracy rate that can distinguish between true and false samples.As shown in Figure3, a policy selector architecture is proposed based on a GAN. A discriminator is trained to distinguish whether a given state-action pair is an expert demonstration. The fake data used for training consists of two parts. The first is the state-action pair (<s,a>) formed by inputting random noise Z (sampled from a normal distribution) and state S (sampled from real historical data) to the generator GS,Z to obtain the current action a. The second is the data obtained by the action of both the selector and the policy set (trained by the method described in Section 2.1). A state S (sampled from real historical data), it corresponds to the policy set π1,π2,⋯,πK, which is used to form the output action vector A=a1,a2,⋯,aK, where aii=1,2,⋯,K corresponds to the action proposal given by the i-th policy, and the policy selector takes s,a1,s,a2,⋯,s,aK as inputs to obtain the scoring vector to judge whether each action pair is an expert behavior V=Ds,a1,Ds,a2,⋯,Ds,aK. The final action can be calculated as follows:
(4)action=A·V∑i=1KeDs,ai.Figure 3
The architecture of policy selector based on GAN.The resulting action pair<s,a> is used as a sample of the fake dataset. The real data comes from the demonstration of expert data.The training objective of the discriminator is the maximization of equation (5), the training objective of the generator is the maximization of equation (6), and the parameter update process is marked by the dotted line in Figure 3.
(5)LD=Es,a~FakeDatalog1−Ds,a+Es,a~RealDatalogDs,a,(6)LG=Es~historystatessetDs,Gs,z.


### 2.3. Summary of Algorithm

According to the description above, the algorithm is summarized as shown in Algorithm1. After the training, the algorithm outputs the discriminator Dw∗ and the policy set π1∗,π2∗,⋯,πK∗. In actual use, at every moment t, the state s is obtained from the real system, and the action candidate set A=a1∗,a2∗,⋯,aK∗ is obtained after the policy set is processed. The discriminator Dw∗ is used as a selector to obtain the score vector, V=Dw∗s,a1∗,Dw∗s,a2∗,⋯,Dw∗s,aK∗, and output action, action=A·eV/∑i=1KeDw∗s,ai∗. These are submitted to the real system for execution, and closed-loop control is formed over and over again. The process is shown in Figure 1.Algorithm 1: GAN-based offline reinforcement learning method.
Input: expert state-action trajectories τ1,τ2,⋯,τN, and the ith trajectory τi=s0i,a0i,s1i,a1i,⋯,sHi,aHi’s length is H.Initialize policy setπ1,π2,⋯,πK which size is K, and the ith policy’s parameter is θi.Training set’s width isW, and the overlap size between two adjacent training sets is S.Initialize generator’s parameterϕ and discriminator parameter wOutput: trained discriminator Dw∗ and policy set π1∗,π2∗,⋯,πK∗1:fori=1 to Kdo2: Initialize training setDi3:forj=1 to Ndo4:  Collect state-action pairs from trajectoryτj=sW∗i−1−D∗i−1j,aW∗i−1−D∗i−1j,⋯,sW∗i−D∗i−1j,aW∗i−D∗i−1j, and save into training set Di.5:end for6: Train policyπi with gradient descent to minimize the loss Lθi=−Es,a∼Dilogπθias7:end for8:fork=1 to MAXdo9:fori=1 to Mdo10:  Sample state-action pairssi,ai from expert state-action data, and save into real data set R11:  Sample statessi from expert data, input the state into policy set, and get action vector A=a1i,a2i,⋯,aKi12:  Calculate the score vectorV=Dwisi,a1i,Dwisi,a2i,⋯,Dwisi,aKi13:  Calculate the action withafake=A⋅eV/∑i=1KeVi14:  Savesi,afake into fake data set F15:  Save the actionagenerated generated from generator si,agenerated into fake data set F16:end for17: Update the discriminator parameters with gradient ascent to maximize the functionEs,a∼RlogDwis,a+Es,a∼Flog1−Dwis,a’s value18: Update the generator parameters with gradient ascent to maximize the functionLϕ=Es∼τlogDwis,Gϕs,z19:end for


## 2.1. Policy Set Training

Behavior cloning transforms the learning problem into a supervised learning problem of fitting expert demonstration behavior. That is, given expert state-action pair trajectory data, the deterministic policy function receives a state as an input and then outputs an action that should be close to the expert’s action in the historical data. For a random policy function, it outputs the distribution of actions in the current state. Under this distribution, the expert’s actions in the current state should have a high probability value. When using a neural network to characterize a policy function,π, the policy function is typically determined by the neural network architecture and parameters θ, so it can be written as πθ. The policy network training task is to adjust θ and find θ∗ to minimize the loss function. The task and the loss function are expressed as follows:
(1)θ∗=argminθLθ,Lθ=Es,a~D12πθ∙∣s−a2,where E denote the expectation and s,a~D denote the state, action pair sampled from the data D to estimate the expectation.Ross et al. presented the following conclusion. The policy (s) is obtained by supervising training with a labeled training set. When the action at given in the state s and the optimal action a∗ are evaluated with a 0-1 loss, Lπ=Eτ~π∑0t=H1at≠a∗ (τ is the trajectory collected by policy π) will be within the upper bound given as follows.
(2)Lπ≤C+H2ϵ,where ϵ is the generalization error in the distribution s~dπs and C is constant. This means that when the time length is H, the deviation of the error will grow as the square of H, which will cause to deviate significantly from the expert policy. Thus, the state distribution dπs obtained by executing the policy π is far away from the state distribution dEs obtained by using the expert policy.To address this issue, the collected expert trajectories are segmented, and policies of different stages are trained for different state sets. This allows the policy selector to control the length of time used by each policy and to reduce the overall accumulated error, as shown in Figure2. Rectangles of one color represent the training data used in one policy. The overlapping area is set in the segmented data of the interval. Given the training set τ1,τ2,⋯,τN, the trajectory length is H, and the policy set is π1,π2,⋯,πK, the width of the data used to train each policy is W, and the width of the overlapping area is S. The following relationship W∗K−S∗K−1=H must be satisfied. For the i-th policy in the policy set πθi during training, minimize the following loss function:
(3)Lθi=Eτ~π∑W∗i−1−S∗i−1t=W∗i−S∗i−112πθi∙∣st−at2.Figure 2
An example of policy set training.


## 2.2. Design of Policy Selector Based on Generative Adversarial Network

The generative adversarial network (GAN) was first proposed by Goodfellow [18]. It is a generative model that uses deep neural networks. The generative adversarial network consists of two components: a generative model and a discriminator model. The generative model is used to generate new samples, and the discriminator model distinguishes the generated samples from the real samples. In the training, the training goal of the generative model is to make the generated samples for the discriminator to recognize its real samples, and the training goal of the discriminator is to correctly distinguish between true and false samples. The two models improve performance in adversarial mode so that the generative model can converge to generate data that is similar to the distribution represented by the real sample data. Meanwhile, the discriminator model has a high accuracy rate that can distinguish between true and false samples.As shown in Figure3, a policy selector architecture is proposed based on a GAN. A discriminator is trained to distinguish whether a given state-action pair is an expert demonstration. The fake data used for training consists of two parts. The first is the state-action pair (<s,a>) formed by inputting random noise Z (sampled from a normal distribution) and state S (sampled from real historical data) to the generator GS,Z to obtain the current action a. The second is the data obtained by the action of both the selector and the policy set (trained by the method described in Section 2.1). A state S (sampled from real historical data), it corresponds to the policy set π1,π2,⋯,πK, which is used to form the output action vector A=a1,a2,⋯,aK, where aii=1,2,⋯,K corresponds to the action proposal given by the i-th policy, and the policy selector takes s,a1,s,a2,⋯,s,aK as inputs to obtain the scoring vector to judge whether each action pair is an expert behavior V=Ds,a1,Ds,a2,⋯,Ds,aK. The final action can be calculated as follows:
(4)action=A·V∑i=1KeDs,ai.Figure 3
The architecture of policy selector based on GAN.The resulting action pair<s,a> is used as a sample of the fake dataset. The real data comes from the demonstration of expert data.The training objective of the discriminator is the maximization of equation (5), the training objective of the generator is the maximization of equation (6), and the parameter update process is marked by the dotted line in Figure 3.
(5)LD=Es,a~FakeDatalog1−Ds,a+Es,a~RealDatalogDs,a,(6)LG=Es~historystatessetDs,Gs,z.


## 2.3. Summary of Algorithm

According to the description above, the algorithm is summarized as shown in Algorithm1. After the training, the algorithm outputs the discriminator Dw∗ and the policy set π1∗,π2∗,⋯,πK∗. In actual use, at every moment t, the state s is obtained from the real system, and the action candidate set A=a1∗,a2∗,⋯,aK∗ is obtained after the policy set is processed. The discriminator Dw∗ is used as a selector to obtain the score vector, V=Dw∗s,a1∗,Dw∗s,a2∗,⋯,Dw∗s,aK∗, and output action, action=A·eV/∑i=1KeDw∗s,ai∗. These are submitted to the real system for execution, and closed-loop control is formed over and over again. The process is shown in Figure 1.Algorithm 1: GAN-based offline reinforcement learning method.
Input: expert state-action trajectories τ1,τ2,⋯,τN, and the ith trajectory τi=s0i,a0i,s1i,a1i,⋯,sHi,aHi’s length is H.Initialize policy setπ1,π2,⋯,πK which size is K, and the ith policy’s parameter is θi.Training set’s width isW, and the overlap size between two adjacent training sets is S.Initialize generator’s parameterϕ and discriminator parameter wOutput: trained discriminator Dw∗ and policy set π1∗,π2∗,⋯,πK∗1:fori=1 to Kdo2: Initialize training setDi3:forj=1 to Ndo4:  Collect state-action pairs from trajectoryτj=sW∗i−1−D∗i−1j,aW∗i−1−D∗i−1j,⋯,sW∗i−D∗i−1j,aW∗i−D∗i−1j, and save into training set Di.5:end for6: Train policyπi with gradient descent to minimize the loss Lθi=−Es,a∼Dilogπθias7:end for8:fork=1 to MAXdo9:fori=1 to Mdo10:  Sample state-action pairssi,ai from expert state-action data, and save into real data set R11:  Sample statessi from expert data, input the state into policy set, and get action vector A=a1i,a2i,⋯,aKi12:  Calculate the score vectorV=Dwisi,a1i,Dwisi,a2i,⋯,Dwisi,aKi13:  Calculate the action withafake=A⋅eV/∑i=1KeVi14:  Savesi,afake into fake data set F15:  Save the actionagenerated generated from generator si,agenerated into fake data set F16:end for17: Update the discriminator parameters with gradient ascent to maximize the functionEs,a∼RlogDwis,a+Es,a∼Flog1−Dwis,a’s value18: Update the generator parameters with gradient ascent to maximize the functionLϕ=Es∼τlogDwis,Gϕs,z19:end for


## 3. Experiments and Results

Cubli is a15cm×15cm×15cm cube. Momentum wheels are arranged on the three planes of the cube. It is a typical nonlinear, unstable, and multidegree-of-freedom control system. The rotation of the motor drives the flywheel to produce momentum changes. Momentum is transferred between the flywheel and the body to control the posture. Cubli is shown in Figure 4.Figure 4
Cubli and its structure.Inverted pendulum has been used to verify control theory for a long time [19, 20]. Chaturvedi et al. [21] pointed out that the three-dimensional inverted pendulum can be used as a simplified aircraft version to study control theory. As a reaction-wheel-based inverted pendulum, Cubli has the similar structure as a satellite and be used to verify the method proposed in the study.Cubli is mainly composed of three brushless motors with encoders, three sets of brake devices, an MPU6050 digital motion processor, a main control chip STM32F103RCT6, and Raspberry Pi 4B. The STM32 and the Raspberry Pi were connected through a serial port. The onboard data was collected by STM32 through MPU6050 and submitted to the Raspberry Pi for processing through the serial port. The communication protocol sent by Cubli to the Raspberry Pi was floating-point data of the Euler angles (roll, yaw, and pitch), angular velocities (rotation rates around thex, y, and z axes), motor speeds (one for each of the three motors), and motor PWM values (one for each of the three motors). The first two data entries were read from the MPU6050 DMP register. As the calculation unit and control unit, the Raspberry Pi calculated the current actions (the PWM target values of the three motors) to be performed after obtaining the current Cubli status information, which was sent to the Cubli main control chip and was executed by the motor after it was written into the register. The on-board data sampling interval time was 5 ms. The time to calculate the action through the Raspberry Pi was about 3 ms, and the time from acquiring the status to executing the action was about 8 ms, that is, the control frequency was 125 Hz.The environment constructed in this paper was mainly used to achieve point balance on a corner, as shown in Figure5. After turning Cubli to the side balancing state, the momentum exchange between the body and the flywheel was implemented by controlling the rotation of the three flywheels to achieve the attitude movement. In the vicinity of the balance point, the angular momentum of the body was again reduced to close to 0 to implement the point balance control.Figure 5
Schematic diagram of spot balance task.The current state of Cubli is represented asst=ϕ,θ,φ,ẋ,ẏ,ż,Encoder_A,Encoder_B,Encoder_CT, where ϕ, θ, and φ represent roll, pitch, and yaw, respectively; ẋ, ẏ, and ż represent the angular velocities around the x, y, and z axes, respectively; and Encoder_A, Encoder_B, and Encoder_C represent the speed data of the devices on the three plane flywheels. The action is expressed as at=a1,a2,a3, where a1, a2, and a3 correspond to the PWM values of the three motor voltage signals that control the rotation of the motor.The Euler angles and triaxial angular velocities in each state were directly measured by the onboard MPU6050 six-axis inertial measurement unit. Encoder_A, Encoder_B, and Encoder_C were written into the main control chip by the encoder of the motor. The state was standardized, and the cosine and sine function values were used instead of the Euler angles. For the shaft angular velocity and motor speed, the measured data was obtained from the board and divided by the maximum value for normalization so that each state component was limited to the value range of−1,1. Therefore, the actual state of use is expressed as follows:
(7)st=cosϕ,sinϕ,cosθ,sinθ,cosφ,sinφxMAX_Ẋ,yMAX_Ẏ,zMAX_Ż,Encoder_AMAX_ENCODER,Encoder_BMAX_ENCODER,Encoder_CMAX_ENCODER,T.A fully connected neural network was used to represent the policy model. The neural network had three hidden layers, each with 128 neurons, initialized with random values for each parameter. A three-layer, fully connected neural network was used to represent the generative model and discrimination model in the policy selector. The specific neural network architecture, initialization parameters, learning method, sample batch number, and learning rate are shown in Table1.Table 1
Parameter settings of policy, policy set, and policy selector.
Behavioral cloningPolicy setPolicy selector (discriminator)GeneratorNumber of input layer units12121512Number of output layer units3313Means of parameter initializationCensored normal distribution randomly generatedCensored normal distribution randomly generatedCensored normal distribution randomly generatedCensored normal distribution randomly generatedNumber of hidden layer units128128256256Hidden layers3333Optimization algorithm and learning rateAdam/0.003Adam/0.003Adam/0.003Adam/0.003Number of batch samples2566425664At the beginning of the experiment, the expert policy was deployed on Cubli and used to collect data for simulating to get control data on orbit, and 200 expert state-action pair trajectory data were collected, with 2000 steps per trajectory. This dataset was used to train the policy through behavior cloning, and the same dataset was used to train the policy set and policy selector of the method proposed in this paper. The behavioral cloning method used 400,000 entries of the sample data of the entire training set for training a single policy, and the number of sample batches for each training process was 256. The training was performed in 1,562,500 times with the 400,000 samples. A policy set with a set number of seven was used, the 2000-step data of each trajectory was divided into seven training sets, and the number of steps in each training set was 290 steps. The number of overlapping steps in the training set used by the interval policy was five.After the training,πBC and πOUR_METHOD were deployed in the same real system to verify the effects of the two policies. Figure 6 shows that the policy trained using the behavioral cloning method could adjust Cubli to the equilibrium point at the beginning of the experiment so that the Cubli Euler angle was close to 0. The three-axis angular velocities were nearly 0, which means a balance was maintained in the experiment of nearly 500 steps. However, after 500 steps, it gradually deviated from the balance point, which caused errors to accumulate and eventually resulted in the loss of balance.Figure 6
Experiment results: BC method was used. (a) Euler angles, (b) gyro value, (c) PWM value, and (d) encoder value.
(a)(b)(c)(d)The experimental results verify Ross’s conclusion that the accumulation of errors is proportional to the square of the number of steps. The test results using the method in this paper are shown in Figure7. To better display the data, the entire record is not presented; only the first 10,000 steps in the trajectory are shown. This is sufficient to demonstrate the performance of the proposed method. The data of 10,000 steps shows the system adjusted from the initial state to the equilibrium point (the Euler angle error and angular velocity were close to 0), and the system remained near the equilibrium point. The PWM and flywheel speed values showed that Cubli was always relatively stable during operation, and the adjustment was maintained within a small range, achieving better performance.Figure 7
Experiment results: our method. (a) Euler angles, (b) gyro value, (c) PWM value, and (d) encoder value.
(a)(b)(c)(d)Analysis of the results showed that the reason the proposed method achieved a better performance was that by dividing the expert trajectories, each policy in the policy set was trained for a different initial state set. Moreover, in actual use, the policy that is suitable for the current state is selected through the policy selector. Consequently, the probability of the same policy being used continuously is significantly reduced compared to the behavioral cloning method with only one policy, thereby reducing the cumulative error caused by using only one policy.


## 4. Conclusion

In this paper, a data-driven offline reinforcement learning method is proposed that can learn effective control policies in an attitude control system that uses momentum exchange as the actuator. The method learns a single policy from different stages by dividing the trajectories of experts, making it possible to select policies with fewer accumulated errors from the policy set based on the state. The method also adopts global data to train the policy selector. When deployed in the actual system, an effective policy is selected through the evaluation of the policy selector based on the current state. This yields a good performance for control over long time periods. Unlike previous works that verified algorithms in a simulation environment, the physical system constructed in this study was closer to a satellite attitude control system with momentum wheels as the actuators. The method also avoids issues such as the safety of on-orbit training and real-time control, and thus, it is more suitable for actual application scenarios. The effectiveness of this method was verified in a real physical system. The offline reinforcement learning method proposed in the paper can use on-orbit data to improve the performance of the attitude control algorithm, while achieving three-axis synchronous control to meet the real-time requirements of attitude control for virtual reality satellite.Despite the positive results of this study, the method proposed in this paper has the following problems that will be solved in future work. (1) Although the method achieves multiple-degree-of-freedom attitude synchronization control from the initial state to the equilibrium state on a real physical system, Cubli, because the Cubli physical system is affected by gravity, the selection of the target posture is relatively limited (close to the equilibrium point). In future work, it is necessary to combine Cubli and an air-floating platform to counteract the gravity to achieve a more gravity-free experimental environment on the ground. (2) The Cubli system in this study used a “single side–single flywheel–single motor” in the actuator. In future work, it is necessary to expand the actuator to “single-side–multiple flywheels–multiple motors” to meet the new requirements of software-defined satellites for redundant actuators.



---

*Source: 4238125-2021-08-01.xml*