{'fraction_non_alphanumeric': 0.029349604581401692, 'fraction_numerical': 0.008828742841559859, 'mean_word_length': 4.819678635191431, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Adaptive Meta-Learning for Identification of Rover-Terrain Dynamics

Rovers require knowledge of terrain to plan trajectories that maximize safety and efficiency. Terrain type classification relies on input from human operators or machine learning-based image classification algorithms. However, high level terrain classification is typically not sufficient to prevent incidents such as rovers becoming unexpectedly stuck in a sand trap; in these situations, online rover-terrain interaction data can be leveraged to accurately predict future dynamics and prevent further damage to the rover. This paper presents a meta-learning-based approach to adapt probabilistic predictions of rover dynamics by augmenting a nominal model affine in parameters with a Bayesian regression algorithm (P-ALPaCA). A regularization scheme is introduced to encourage orthogonality of nominal and learned features, leading to interpretable probabilistic estimates of terrain parameters in varying terrain conditions.


INTRODUCTION
Extraterrestrial rovers must traverse terrain that is often rugged and uncertain in order to achieve mission goals. To ensure a high degree of safety and maximize efficiency, it is crucial for the rover to be equipped with as much knowledge as possible about the terrain it will traverse. In modern rover systems, sources of information include terrain type classification, hazard detection, and excessive slip detection. Terrain type classification relies on input from human operators or machine learning-based image classification algorithms [1], [2], as well as proposed approaches to classify terrain using vibration measurements [3]. However, terrain classifications are not sufficient to guarantee safety for path selection. Discrete categories of terrain mask the complexity of vehicle-terrain interactions that are unique to individual vehicles and different environmental conditions. To truly avoid incidents like NASA's Spirit rover becoming stuck in a sand trap [4], and Curiosity's wheels being damaged by sharp rocks [5], wheel-terrain dynamics must be considered. Using proprioceptive or visual measurements, unexpected wheel-terrain interaction effects such as excessive slip or sinkage can sometimes be detected as they occur [6,7,8,9] but in order to predict and prevent such undesirable wheel-terrain interactions, it is crucial to maintain an adaptive model of the terrain parameters that govern wheel-terrain interaction. Having an estimate of terrain parameters allows the rover to adapt its control and planning strategy to a given terrain [10], accurately predict the traversability of neighboring terrain regions [11], and prevent further damage to the rover.
Related Work. Analytical models governing wheelterrain interaction were first introduced by Bekker, Wong, and Reece [12,13,14] and have since been expanded to incorporate multiple physical effects [15]. However, these models are complex, so efforts to estimate terrain parameters with the limited hardware on-board a rover have motivated approaches using linear-least squares regression [16] or a Newton-Raphson method [17] on simplified terramechanics models. These approaches require access to sensor information about the rover's forward velocity from an IMU or visual odometry, wheel angular velocity from tachometers, sinkage from camera measurements, and a method for measuring or computing the vertical load and torques on the wheels [16]. These methods provide good online estimates of terrain parameters on a variety of soils, but cannot model non-linear interactions, and moreover, they do not provide any measure of uncertainty for their estimates.
Since wheel-terrain interaction models have multiple sources of uncertainty, efforts to validate these models against experimental data have relied on fitting stochastic semi-empirical models [18], [19] which benefit from a measurement of uncertainty for terrain parameter estimates. Such measures of uncertainty can be obtained by modeling the wheel-terrain interactions as a Gaussian Process (GP) [19] but GPs are limited in their ability to incorporate physical priors, and have high computational cost. Instead, Bayesian neural network models such as ALPaCA [20] have been shown to be successful in modeling uncertain dynamics for safety critical systems while remaining computationally efficient [21,22]. ALPaCA performs Bayesian linear regression on neural network features that are learned via meta-learning (or learning-to-learn). By training on a variety of physically plausible simulations, the ALPaCA model is capable of learning expressive features capturing behavior that may be difficult to represent analytically. In this work, we develop a nominal model that relates the dynamics of the rover to the terrain parameters. This model is based on work by Iagnemma et al. [16] and is linear in terrain parameters. Next, we augment the nominal model with an ALPaCA model [20], to produce a model that yields accurate predictions as well as Bayesian posteriors reflecting prediction uncertainty. A similar approach is employed in [23,24,25] of relating the pose error to slip estimates, with the differences being that our model estimates terrain parameters instead of slip directly, providing an understanding of the terrain, and our model yields not only predictions but also probabilistic estimates to charac-terize uncertainty in our predictions.
Problem Formulation. We are focused on developing a model to learn, adapt, and predict a rover's dynamics on unknown terrain and provide online estimates of the physical parameters that govern wheel-terrain interactions. The two key parameters of interest are cohesion c and internal friction angle φ that determine the maximum terrain shear strength [16] and therefore, a rover's ability to safely traverse the terrain. Since rovers will be encountering novel and unmodeled terrain, it is crucial for safety that our model provide probabilistic predictions and adapt online.
We assume that the sensor suite on-board the rover, including wheel encoders, IMU, and vision system, gives us information about the rover's current position, velocity, slip, and sinkage, though we hope to relax the requirement on knowledge of slip and sinkage in future work.

Contributions.
The key contributions of this paper are as follows. We develop a framework for wheel-terrain dynamics modeling that is capable of rapid adaptation, by first developing a nominal model that is linear in parameters. In order to capture the non-linear interactions between the rover dynamics and terrain parameters, we augment the linear model with new more complex meta-learned neural network features using a Bayesian regression algorithm (ALPaCA). We present an alternative form of the ALPaCA model, which we name P-ALPaCA, which enables joint inference of the parameters of the ALPaCA model and of the nominal model. We introduce a new regularization scheme to promote orthogonality between the nominal model features and the meta-learned features, providing interpretable terrain parameter estimates. Lastly, we demonstrate our framework on simulations of rocker-bogie dynamics on varying terrains.

BACKGROUND
The dynamics of a rover are different on different terrains. Therefore, predicting rover dynamics is, in its most general form, a system identification problem, where Bayesian regression can be leveraged to produce probabilistic predictions that adapt online. Approaches using Gaussian Process regression have been used for model identification [19] but are computationally inefficient for large numbers of samples and cannot easily incorporate prior knowledge from the existing models of rover dynamics and wheel-terrain interaction that we discuss in sections 2.2 and 2.3. Both these problems are addressed by using a Bayesian metalearning algorithm, ALPaCA [20], that we discuss in section 2.1 which allows for efficient regression while incorporating prior knowledge.

System Identification via Meta-Learned Neural Network
Our system identification approach builds upon ALPaCA [20], a Bayesian meta-learning algorithm. This approach separates the online adaptation process-a convex optimization problem that can be solved analytically-from the offline non-convex feature learning process.
The basis of this method is meta-learning, in which it is assumed there exists a distribution over "tasks". For example, in system identification, these tasks may correspond to different system dynamics. Meta-learning aims to use data collected from several tasks to improve the efficiency and accuracy of learning in a new task sampled from the same distribution.
We will write the system dynamics as where θ ∼ p(θ) corresponds to the task and may be seen as parameters of the environment, and is zero-mean Gaussian noise, uncorrelated in time, with covariance Σ . We write x and u to denote state and action respectively. We assume episodic interaction with the system, where θ is sampled at the beginning of the episode, and held fixed throughout. While this is a somewhat unrealistic assumption in the context of online terramechanics modeling, we will discuss relaxations of this assumption in Section 5. Moreover, several works have addressed extensions beyond this assumption that may be applied on top of the methods developed herein [26,27]. We assume θ is not directly observed, and we do not know f (·, ·; ·). Our goal in the meta-learning problem setting is to learn some approximation of (1) that is capable of being adapted online. As transitions are observed in an episode, we wish to use experience within an episode to infer θ and improve subsequent predictions.
The approach of ALPaCA is to perform Bayesian linear regression on learned neural network features. The predictive model takes the form where φ(·, ·; ·) is a neural network with weights w, and K ∈ R n x ×n φ is a matrix. We writex + to denote the predicted next state. The matrix K may be seen as the last linear layer of the neural network. Critically, the ALPaCA model maintains a distribution over K reflecting the epistemic uncertainty-uncertainty that can be reduced with more data collection. Thus, the ALPaCA model returns a predictive distribution forx + as opposed to a point prediction. The central idea of ALPaCA models lies in updating the last layer of the network online. This update may be performed by recursive least squares, similar to the Kalman filter. This form of updating is not novel in system identification; indeed, recursive least squares updating on neural network basis functions has been a common approach in nonlinear identification since the 1980s [28]. Where ALPaCA varies from these classical approaches is to train the neural network by backpropagating the training loss through the model update, to ensure the features are broadly useful across multiple tasks and across time.
As such, ALPaCA combines ideas from classical adaptive control with ideas from recurrent neural networks. Fundamentally, in the ALPaCA model, the matrix K serves to summarize all information within one episode and account for variations between tasks, whereas the neural network features are learned to be useful across all tasks and are not updated online.
We will now make concrete the above (informal) discussion. We assume access to operational data in a variety of environments, obtained via previous experience or simulation. ALPaCA fixes a matrix normal prior on K, which we write whereK 0 denotes the prior mean and Λ 0 is a prior precision (inverse of covariance) matrix. Note that the matrix normal distribution over the matrix K is a normal distribution over the vectorized matrix, with a particular covariance structure. We refer the reader to [20] for more details. Let τ=0 denote the state/action data observed within an episode at time t. Given this data, the posterior over K is whereK t , Λ −1 t may be computed via recursive least squares through update rules . Given this posterior, the posterior predictive distribution may be computed, yielding Given this posterior predictive distribution, we can evaluate the likelihood of the remaining data in the episode (that has not been conditioned upon) to update the neural network weights and the prior. The prior for the model relies on existing physics models of the rover dynamics and wheelterrain interactions, which we discuss next.

Rover Dynamics and Kinematics
In order to develop a model for rover dynamics on different terrains, we require knowledge of the kinematics of the rover. Though our approach would work on any configuration of the rover, in this work we consider laterally symmetric rocker-bogie motion, i.e. right and left wheels have identical motion and driving torques. This is a justified assumption for low-acceleration motion in a straight-line or very large radius turns. With knowledge of the rover kinematics and terrain geometry, the forward net force F x (see Fig. 1) can be related to the normal N i and tractive T i ground reaction forces through where c i = cos α i and s i = sin α i [29].

Wheel-Terrain Interactions
In this section, we describe how the ground reaction forces can be related to the terrain parameters. Fig. 2 shows a free body diagram of a rigid wheel travelling on deformable terrain. For simplicity, the wheel is assumed to be rigid and moving quasi-statically with low acceleration. The interaction model for a rigid wheel traversing deformable terrain is obtained by considering the force and moment balance [16] where W is vertical load applied to the wheel, DP is drawbar pull applied to the wheel from a suspension system, M is wheel drive torque produced by an actuator, θ is the arbitrary angular location of wheel-terrain contact measured from a vertical axis, θ 1 is the angle at which the wheel first makes contact with the terrain, θ 2 is the angle at which the wheel loses contact with the terrain, σ is radial stress normal to the wheel-terrain contact, τ is shear stress tangent to the wheel-terrain contact, r is wheel radius, and b is wheel width.
In quasi-static equilibrium, the normal force N equals the weight W and the traction force T counteracts the drawbar pull DP, henceforth N and T will be used in place of W and DP. By considering linear approximations of the shear and normal stress, Iagnemma et al. [16] find analytical expressions of these forces where σ m , τ m are the maximum radial and shear stresses, f 0−4 are all functions of θ 1 and θ m which is the angle at which maximum stress occurs, which are given by The radial and shear stresses themselves are functions of the wheel radius r, wheel width b, slip i, sinkage z, the terrain parameters of interest -cohesion c and angle of internal friction φ -as well as other terrain parameters (k c , k φ , n, k) via The model exhibits low sensitivity to the other terrain parameters (k c , k φ , n, k) and these are replaced with representative values [14]. The sinkage is determined from the angle of initial contact between the wheel and the terrain θ 1 through wheel geometry. The angle of maximum stress θ m = (c 1 + ic 2 )θ 1 (15) is related to the angle of initial contact θ 1 using terrain parameters c 1 , c 2 . Leveraging these relationships, the forces from Eqs. 11 are expressed as functions of wheel geometry, slip i, sinkage z, the terrain parameters of interestcohesion c and angle of internal friction φ -as well as other terrain parameters. Therefore, with knowledge of the vertical force N, torque M, sinkage z, and slip i, the terrain parameters for cohesion c and angle of internal friction φ are estimated via a least squares regression where K 1 , K 2 are functions of N, M, i, z [16]. We build upon this regression model to relate the rover dynamics directly to the terrain parameters for cohesion c and angle of internal friction φ in the following section.

TECHNICAL APPROACH
In this section, we build a nominal linear model relating the rover dynamics and terrain parameters. We then incorporate this model in to an ALPaCA-based learning framework. To allow for adaptation of the terrain parameters in the nominal model, we propose an extension to ALPaCA in section 3.2 that incorporates models with unknown parameters and performs joint inference on these parameters. In section 3.3, a regularization scheme is introduced to reduce correlation between nominal model features and meta-learned features, thereby maintaining the interpretability of the terrain parameters.

Linear Model Relating Terrain Parameters and Dynamics
We continue to assume that noisy measurements of slip i and sinkage z are available to the rover, but we relax the requirement in [16] of measuring the vertical force N and torque M through a force sensor or of computing them onboard. Since force sensors may not be available, and the computation adds overhead, we instead relate the terrain parameter estimates directly to the dynamics of the rover. Assuming the same linear stress distribution as in Section 2.3, we can find the ground normal forces N i and traction forces T i (for i = {1, 2, 3}) as linear in parameters c and tan φ where Q and R are 3x3 matrices with non-linear functions of slip i and sinkage z. These can then be used to find the forward force using (9), This enables us to use rover dynamics to estimate the terrain parameters or, conversely, to use terrain parameters to predict rover dynamics via Euler numerical integration is used to yield discrete time dynamics with a chosen time step size of 0.1 seconds that is sufficiently accurate for the low velocities of the rover. This linear model relating dynamics and terrain parameters is used as a prior for the ALPaCA model described next.

P-ALPaCA: Extending ALPaCA with a Parameterized Prior Model
We now extend the previously proposed ALPaCA model to handle linearly parameterized nominal models. We use the term nominal to refer to a model obtained outside of the meta-learning framework. In this paper, we will consider models derived via simplified dynamics equations, as discussed in the previous subsection. Previous work [22,30] has incorporated prior knowledge into ALPaCA models in the form of a fixed (non-parameterized) nominal model. In particular, previous work has considered system dynamics x + = f (x, u; θ) + = g(x, u) + h(x, u; θ) + , (20) where g(·, ·) is the nominal model, capturing prior knowledge of system dynamics, and h(·, ·; θ) is the unknown component of the dynamics that we wish to learn, which varies across episodes/tasks. Previous work has taken g(·, ·) as fixed, and parameterized h(·, ·; ·) with an ALPaCA model where K ∈ R n x ×n φ .
In this work, we investigate integrating nominal models with unknown parameters into the previously developed ALPaCA modeling approach. We investigate models of the form where θ nom denotes parameters of the nominal model and θ net denotes (online adapted) parameters of the neural network. This formulation will enable joint inference of unknown parameters from a physical model (e.g. masses) and parameters of the neural network model, which can capture features not appearing in the nominal, simplified physical model. Importantly, joint inference of these parameters is non-trivial, and represents the core machine learning contribution of this paper.
We will work with a discrete-time nominal model that is affine in the parameters [31], of the form where Φ nom (x, u) is a n x × n nom matrix of basis functions, φ nom (x, u) is a constant (in the parameters) vector of length n x , and k nom ∈ R n nom is a set of nominal parameters. To fit with this model, we introduce an alternate version of the ALPaCA model of the form h(x, u; k net ) = Φ net (x, u)k net (24) with k net ∈ R n net . This yields the dynamics model , u)]. This approach, critically, results in parameters that are shared for each output dimension. Note that k ∈ R n nom +n net ; we write n φ = n nom + n net . In the nominal ALPaCA model, each output dimension is determined by a shared set of basis functions and a unique (for each output dimension) set of parameters. In this model, the parameters are shared for all output dimensions, and each dimension has unique neural network features. Due to the reduced use of adaptive parameters, we refer to this model as Parsimonious ALPaCA, or P-ALPaCA.
Bayesian inference in this model closely follows from stan-dard results for linear-Gaussian systems (see, e.g., the discussion of Bayesian linear regression in [32]). We fix a prior k 0 ∼ N(k 0 , Λ −1 0 ). Then, the mean and precision (inverse of the covariance) are updated as where Φ t = Φ(x t−1 , u t−1 ) and φ t = φ nom (x t−1 , u t−1 ). In the standard ALPaCA formulation the Woodbury identity is applied to yield an efficient update rule. Applying the same approach here does not yield computational efficiency improvements, as we do not avoid a matrix inverse in the update. Thus, we maintain the natural parameters of the multivariate Gaussian during updating via and the precision update (26). To perform prediction, we may computek t = Λ −1 t q t . Then, the posterior predictive distribution is which may be derived based on the standard equations for mean and variance of a random variable under linear transformations. Given this posterior predictive, the likelihood may be computed as in the standard ALPaCA metalearning algorithm, and used to train the neural network features as well as the prior over k. Due to space constraints we do not outline the full training algorithm in this paper; we refer to [20] for more details.

Interpretability via Feature Orthogonality
We have so far presented an approach to combine a "greybox" nominal system model, derived via simplified physics of the rover system, with an entirely black-box neural network model without physical interpretation. If our only objective is accurate state prediction, then our approach so far is sufficient. More likely, however, the physical parameters of the grey-box model provide information that is of use to system operators, scientists, or elsewhere in the planning and control architecture. For example, inferred terramechanics properties may be critical to identify regions as safe or unsafe for traversal. Thus, it is necessary that our added black-box model not result in poor estimates of the physical parameters in the grey-box model. Such an outcome is not guaranteed; collinearity between features in linear regression results in weights that are highly unstable under minor perturbations [33]. This collinearity may result in the parameters of the neural network model being highly correlated with the grey-box model, resulting in misleading estimates of the physical parameters. To reduce this collinearity, we add a regularization term to the loss function to promote feature orthogonality.
Let φ T i,t denote the i'th row of Φ t 1 . Our orthogonality regu- where · F denotes the Frobenius norm and T is the length of the episode. There are several things to note about the above. The norm of the innermost sum over time is a Monte Carlo approximation of the constraint where π is the controller used for data collection and µ is the occupancy measure (i.e. the probability distribution over states) induced by the system dynamics and the controller. Thus, the addition of this regularizer may be interpreted as a Lagrangian relaxation of the neural network training loss with a constraint requiring the basis functions to be orthogonal, as where φ i j denotes the j'th entry of φ i . As orthogonality of features implies no multicollinearity, this regularization term will minimize the effect and thus improve interpretability of the model.

EXPERIMENTS
Simulations were conducted of a rover in rocker-bogie configuration traveling over two types of terrain -compact sand and loose sand -using equations for the wheel-terrain interaction and terrain parameters from Wong et al. [14]. For a given rover body position, the rover dynamics were simulated by computing the ground reaction forces for each wheel from applied torques and matching against the integrals from Wong's model which were solved using Simpson's rule. The ground reaction forces were then used to calculate the slip and sinkage for each wheel, which, along with rover position and velocity, were the inputs to the models. Rover kinematics was used to compute the net forward force and resultant change in rover velocity. The purpose of the simulations was to compare the performance of the nominal linear model against the model augmented with P-ALPaCA features and analyze the effect of enforcing feature orthogonality.
The simulation 2 was written in Python and the machine learning models were implemented using the PyTorch library [34]. Each of the models consisted of two hidden layers of size 128 and were trained for 1000 iterations in batches of 20 sampled dynamics transitions each to minimize the negative log likelihood of the posterior predictive distributions. The first model was P-ALPaCA without any added features, the second model was P-ALPaCA with two added nominal features corresponding to the linear model features for velocity from Eq. 19, and the third model was P-ALPaCA with two added nominal features as well as an additional regularization term to promote orthogonality between features as discussed in Section 3.3. The P-ALPaCA models with nominal features had an additional loss term to encourage the parameters associated with cohesion and internal friction angles to be positive.
The state consisted of velocities between 0 to 1 m/s and the

Figure 4 Prediction error for velocity
control actions were applied wheel torques between 0 and 5 Nm, wheel slips between 0 and 1, as well as sinkage between 0 and 0.1 m. The rover mass was 10 kg, the wheel radius was 0.4 m, and wheel width was 0.1 m. During training, the parameter for cohesion was randomly selected for each batch between 0.5 and 5 kPa, except the band between 0.7 and 1.3 kPa which are the typical values of cohesion for loose and compact sand [14] and were reserved for testing. The internal friction angle was randomly selected from the range 0 to 60 degrees, excluding the range from 20 to 45 degrees for testing. The other terrain parameters were held fixed at the values for loose sand (n = 1.1, k c = 0.9 kPa, k φ = 1523.4 kPa, k = 0.025, c 1 = 0.18, c 2 = 0.32) and compact sand (n = 0.47, k c = 0.9 kPa, k φ = 1523.4 kPa, k = 0.038, c 1 = 0.43, c 2 = 0.32) [14] during training and perturbed by 5% during testing to ensure robustness.
First, we compare the ability of the models to predict the dynamics of the rover given an estimate of the terrain parameters. As shown in Fig. 4, the linear model as well as all the P-ALPaCA models have low prediction error for velocity of the rover, with the largest being the error for the linear model on loose sand, which is less than 5%.
Second, we compare the terrain parameter estimates provided by the models using the dynamics of the rover, as well as the estimates provided from Iagnemma et al.'s model [16]. The ground truth of vertical load and wheel torques are passed from the simulator to Iagnemma's model, while the other models utilize the position and velocity of the rover directly to make predictions. As seen in Fig. 3, both the linear model and Iagnemma's model provide good estimates for cohesion and angle of internal friction. The higher error for Iagnemma's model on loose sand is due to their assumption that the angle of maximum shear stress is located halfway from the angle of initial contact, which becomes a looser assumption for higher cohesion terrains. While both P-ALPaCA models augmented with the linear model provide uncertainty estimates, the terrain parameter estimate shows better convergence when orthogonality of the features is enforced explicitly through the regularization term discussed in Section 3.3.
The addition of the regularization scheme results in interpretability of the meta-learned features. P-ALPaCA with orthogonal regularization not only provides dynamics predictions but also an estimate of the terrain parameters used in the model, aiding in interpretability of the model. Models with orthogonal regularization produce lower parameter estimation error than models without the regularization and lower dynamics prediction error than the nominal linear model. Increasing the orthogonal regularization strength, i.e. increasing the weight on the orthogonal loss, results in a trade-off between lower parameter estimation error and higher dynamics prediction error, as seen in Fig. 5.

DISCUSSION AND CONCLUSIONS
Our approach of augmenting a nominal model affine in parameters with meta-learned neural network features from ALPaCA leverages Bayesian regression to adapt to rover dynamics. We maintain interpretability of the predictions by encouraging orthogonality of the nominal model features and the meta-learned features, resulting in good terrain parameter estimates. Our experimental results demonstrate that the combination of the grey-box nominal model with a properly regularized black-box neural network model results in achieving the best of predictive accuracy and accuracy in parameter inference. Thus, our proposed approach is a highly flexible and performant system identification framework that is capable of application to many systems.