## Contact-conditioned learning of multi-gait locomotion policies

Michal Ciebielski 1 , Federico Burgio , Majid Khadiv 2 1

Abstract -In this paper, we examine the effects of goal representation on the performance and generalization in multigait policy learning settings for legged robots. To study this problem in isolation, we cast the policy learning problem as imitating model predictive controllers that can generate multiple gaits. We hypothesize that conditioning a learned policy on future contact switches is a suitable goal representation for learning a single policy that can generate a variety of gaits. Our rationale is that policies conditioned on contact information can leverage the shared structure between different gaits. Our extensive simulation results demonstrate the validity of our hypothesis for learning multiple gaits on a bipedal and a quadrupedal robot. Most interestingly, our results show that contact-conditioned policies generalize much better than other common goal representations in the literature, when the robot is tested outside the distribution of the training data.

shared part of the neural network among all gaits. However, both of these approaches are constrained by a limited number of gaits and they cannot scale to the case of generating a wide range of cyclic and acyclic behaviors.

## I. INTRODUCTION

The dominant approaches to controlling legged robots are model-based control, in particular (nonlinear) model predictive control (MPC) [1], [2], [3], and learning-based control, especially (deep) reinforcement learning (RL) [4], [5], [6], [7]. Each of these approaches presents different strengths and weaknesses. MPC techniques are notably versatile, meaning that given adequate perception and task information, they can easily adapt to new tasks and environments. Furthermore, they can take the constraints of the robot and environment into account to generate safe behaviors. However, they are sensitive to unexpected contact events and tend to be computationally expensive at run-time. These difficulties have caused a major shift towards learningbased policy optimization techniques and sim-to-real transfer. By directly optimizing the parameters of a feedback policy (usually a neural network), the run-time computation in these approaches is at a minimum. Furthermore, by randomizing the uncertain aspects of the problem during training using domain randomization [8], the resulting policy is robust and can be directly transferred to real robots.

Despite these advances, learning multi-gait control policies remains a challenging problem. Notable efforts to generate such policies include [9], which leverages an offline dataset of demonstrations to enable a single, skill-conditioned generative policy to perform five different gaits. In [10], a quadruped robot learns multiple gaits through a mixture-ofexperts policy network, where each expert specializes in a single gait. The interesting feature of this framework is that it can leverage the shared structure between the gaits through a

- 1 Munich Institute of Robotics and Machine Intelligence, Technical University of Munich, Germany. michal.ciebielski@tum.de, majid.khadiv@tum.de
- 2 Department of Industrial Engineering, University of Trento, Italy. federico.burgio@studenti.unitn.it

One key aspect when learning multiple skills is to have a goal representation that not only encompasses all possible locomotion behaviors, but it also encodes the shared structure between different behaviors. However, the common choice in the literature is to condition locomotion policies on an average horizontal velocity that fails to address both of these aspects. Firstly, a robot can achieve similar average velocities with many different cyclic or acyclic behaviors. Hence, conditioning on the desired velocity does not distinguish between different ways a robot can move. Secondly, conditioning on the desired velocity (and skill) fails in capturing the similarities between different skills.

Since making and breaking contact is essential in realizing any interesting locomotion behavior, we hypothesize that a goal representation based on the properties of contact switches can be an excellent candidate.

Goal representations based on contact have been used in policy learning in [11] and [12]. However, in both works, this information is used to learn single skill policies. In contrast, we hypothesize that the contact goal representation is particularly useful in case of multi-gait learning.

Hence, in this paper, we present contact-conditioned policies that can be used with any high-level contact planners and benchmark their performance against commonly used goal-conditioning based on velocity and gait. Specifically, we train multi-gait contact-conditioned policies via behavior cloning on an expert MPC. The main contributions of the paper are as follows:

- · We propose a general goal representation based on contact information that in principle can learn any cyclic and acyclic behaviors and can be coupled with any contact planner.
- · We benchmark the performance and robustness of a multi-gait contact-conditioned policy against gait and velocity-conditioned policies typically found in the literature. Our systematic comparison on two different legged systems, a biped and a quadruped, shows that policies conditioned on contact information consistently outperform those based on velocity and gait, both within and outside the training distribution. Overall, we show that not only does the contact-conditioned policy enhance single-gait performance, it also boosts multi-gait learning, achieves the best results in our most challenging tests and exhibits superior out-ofdistribution generalization.

The remainder of the paper is structured as follows: Section II overviews the required fundamentals to start with the new approach. Section III gives a detailed description of the proposed approach and implementation details. Section IV presents the results on the comparison between the contact mode goal representation and the gait and velocity goal representation. Finally, Section V summarizes our findings and proposes several directions for future works.

## II. PRELIMINARIES

In this section, we give an overview of the preliminaries which are necessary to perform behavior cloning from MPC. The reason behind this choice is to focus on the effects of policy representation, without dealing with exploration nuances in DRL frameworks. To make the paper self-contained, in the following we explain the framework used in this paper. However, our results are independent of the choice of the expert controller.

We first describe contact explicit MPC, which is the expert demonstrator in our framework. Then we describe how to generate a diverse set of initial conditions for a given contact sequence. Finally, we present the general behavior cloning from MPC algorithm.

## A. Contact Explicit MPC

MPC solves a receding horizon optimal control problem by optimizing a sequence of future control actions subject to dynamics and path constraints. In contact-explicit formulation, to avoid solving a nonsmooth optimization, the contact sequence is planned first using a given contact planner and then an MPC controller solves a smooth optimal control problem:

$$\text{problem} \colon & \min _ { x, u, t _ { 1 \colon k - 1 } } \sum _ { t = 0 } ^ { N - 1 } \phi _ { t } ( x _ { t }, u _ { t } ) + \phi _ { T } ( x _ { T } ) & \begin{array} { c } 8 \colon \\ 9 \colon \\ 5. \end{array} \\ \text{s.t. } & x _ { t + 1 } = f _ { m } ( x _ { t }, u _ { t } ), & \begin{array} { c } 1 \colon \\ h _ { m } ( x _ { t }, u _ { t } ) \leq 0, \quad \forall t \in [ t _ { m - 1 }, t _ { m } ), \ m = 1,.., k, \\ h ( x _ { t }, u _ { t } ) \leq 0, \quad t = 0, 1 \dots, N - 1 & \\ x _ { 0 } = x _ { i n i t } & \begin{array} { c } 1 \colon \\ 0 \colon \\ 1 \colon \end{array} \\ \dots \dots \dots \dots \dots \dots \dots \dots \dots \dots \dots \dots \dots \dots \dots \dots \dots \dots \dots \dots \dots \dots \dots \dots \dots \dots \dots \dots \dots \dots \dots \dots \dots \dots \dots \dots \dots \dots \dots \dots \dots \dots \dots \dots \dots \dots \dots \dots \dots \dots \dots \dots \dots \dots \dots \dots \dots \dots \dots \dots \dots \dots \dots \dots \dots \dots \dots \end{array}$$

(1)

where x and u represent the state and control trajectories. f m is the dynamics of the system which changes depending on the mode m = 1 , .., k . In addition to global path constraints h such as torque and joint limits, there are also mode dependent constraints h m such as contact constraints. MPC solves the multi-stage optimal control problem in (1), starting from the measured state x init .

## B. Generating Diverse Initial Conditions

A key ingredient in imitation learning is generating a diverse dataset. When cloning MPC, it is important to consider a diverse distribution of x init from which the MPC is rolled out. To do so, we first generate one rollout of the MPC in simulation and consider that as a nominal trajectory, then perturb the robot around this trajectory and roll out the MPC from the resulting x init . However, naively perturbing the initial condition does not respect the contact constraints and may even result in ground penetration which is an infeasible initial condition for (1). To achieve contact-consistent perturbations, we follow the method in [13]. Namely, we first sample an unconstrained perturbation from a normal distribution δ q , δ v ∼ N ( µ, σ 2 ) , where q and v are the generalized coordinates and velocities of the robot. Then, we project this perturbation in the nullspace of the contact constraints:

$$\begin{bmatrix} \delta \mathbf q _ { c } \\ \delta \mathbf v _ { c } \end{bmatrix} = \left ( I - A _ { c } ^ { \dagger } A _ { c } \right ) \begin{bmatrix} \delta \mathbf q \\ \delta \mathbf v \end{bmatrix}, \quad \quad \ \ ( 2 )$$

where matrix A c is constructed as

$$A _ { c } = \begin{bmatrix} J _ { c } & 0 \\ \dot { J } _ { c } & J _ { c } \end{bmatrix}.$$

In these equations, I is the identity matrix and J c is the concatenation of the jacobians of the active contact points at the current time. The projected perturbations are added to the initial state of the robot q ⊕ δ q c and v + δ v c and constitute x init in (1).

## Algorithm 1 Behavior cloning from MPC

- 1: Given initial conditions X , number of rollouts N , failed states S failed and contact plans G 1: N .
- 2: for i = 1 , . . . , N do

3:

s

0

∼ X

4:

5:

6:

7:

8:

9:

10:

11:

12:

13:

14:

15:

16:

t

= 0

u

, . . . , T

t

s

= arg min

t

+1

if

▷

Sample initial condition: eq. 2

do s,u

C s ,

=

f

sim

(

s , u

s

t

(

t

G

i

)

▷

Solve optim. 1

t

)

▷

Roll out MPC in sim.

t

+1

∈ S

failed then

return infeasible and break end if

Add sample:

end for if

feasible then

Add feasible rollout to the dataset: D s,a ←D i s,a end if

end for

: π θ = arg max π θ E D s,a [log π θ ( a s | )]

- ▷ Perform supervised learning

## C. Behavior Cloning from MPC

To perform behavior cloning from MPC under a fixed contact sequence, Algorithm 1 is used. First, contact-consistent perturbations are performed to sample feasible initial conditions. Then, the contact-explicit MPC (1) is rolled out in simulation for a given contact plan G i . If the robot does not fail, the data from the episode is added to a dataset D comprised of observed states s and expert actions a . This offline-collected data is treated as if they were independent and identically distributed (i.i.d) and supervised learning is carried out to approximate a policy π that replicates the action of the expert at any given state. The training objective is minimizing the errors in mimicking an expert's actions

D

i

s,a

←{

s , a

t

t

}

for

π = argmax π E D [log π a ( | s )] , simply minimizing the empirical risk as in supervised learning.

Remark While one can use some variation of online algorithms such as DAGGER [14] to avoid distribution shift and better sample-complexity [15], here, we intentionally limit ourself to the BC formulation to have a static dataset and study the goal representation learning problem in isolation.

## III. METHOD

In this section, first we present our proposed conditioning on the next contact modes and switch timings. Then, we outline the details of how we implemented the general BC from MPC algorithm 1.

## A. Goal Representation

We define C as the contact status of all E end-effectors of a legged robot (we omit sliding and only consider breaking and sticking contact):

$$\mathcal { C } = \left ( c _ { 1 }, c _ { 2 }, \dots, c _ { E } \right ), \ \ c _ { i } \in \{ 0, 1 \}, \quad \ \left ( 4 \right ) _ { n _ { 1 } \ n. }$$

where c i = 1 specifies that the i th end-effector is in contact with the environment.

Fig. 1: Example contact sequence captured on the biped Bolt. The left panel represents the current state of the robot and the following three panels depict two contact switches.

![image](https://ac.marcodsn.me/arxiv-markdown-images/2408.00776v2-figure-e58fd71e-d8e6-47e4-bbbe-bfc88aa25ecd.jpg)

A contact goal sequence G K is defined as a sequence of K desired contact modes, end effector positions and their corresponding switching timings:

$$\mathcal { G } ^ { K } = \{ ( \mathcal { C } ^ { 1 }, \, ^ { B } p _ { 1 \colon N } ^ { 1 }, t ^ { 1 } ), \dots, ( \mathcal { C } ^ { K }, \, ^ { B } p _ { 1 \colon N } ^ { K }, t ^ { K } ) \}, \quad ( 5 ) \quad \text{any of}$$

where each C k is the desired contact mode at the k -th switching event, B k p i is the desired position for the i -th end-effector in the base frame and t k is the time at which the switch occurs. For an end effector in breaking contact B k p ee = 0 3 . In our setting it was sufficient to provide information on one mode switch into the future and its corresponding positions and timing, i.e. G 1 = ( C 1 , B p 1 1: N , t 1 ) . However, one could potentially increase the number of contact switches into the future for motions on more complex environments. This representation is general and encompasses both cyclic and acyclic behaviors. Figure 1 visualizes an example of such representation on the biped robot Bolt.

We benchmark the contact mode goal representation g con against the standard desired velocity goals g vel := [ v des , b, ϕ ] . The variables in this representation are the desired velocity v des ∈ R 3 , the type of gait ( b ∈ { walk, run } for the biped, and b ∈ { trot, jump } for the quadruped) and a phase variable ϕ that goes from 0 to 1 for the duration of the gait cycle. In addition to comparing the contact-conditioned

TABLE I: Goal Representations for Trained Policies

| Policy                                  | Goal Representation                                                                                 |
|-----------------------------------------|-----------------------------------------------------------------------------------------------------|
| Con. Vel.+Gait Vel.+Gait+Con. Con.+Gait | g con := G 1 g vel := [ v des , b, ϕ ] g vel+con := [ v des , b, ϕ, G 1 ] g con+gait := [ G 1 , b ] |

policy Con. and the velocity-conditioned policy Vel.+Gait , we also perform two ablations. Vel.+Gait+Con. combines g vel and g con and Con.+Gait combines the gait type b to the contact mode goal g con . All considered goal representations are summarized in Table I. A visual depiction of the policy structure of the velocity and contact-conditioned policies is shown in Fig. 2.

## B. Implementation

In this section, we give an overview of our implementation specifications.

1) Expert controllers: To control the biped Bolt (Fig. 1) we used the MPC formulation in [16] that extends the formulation in [17], [18] to a unified framework for walking and running of bipedal robots. The software is also opensource and available on Github. Due to its simplicity of formulation, the MPC can solve for both the step location and timing of the next step at 1 KHz. This makes the MPC highly reactive to external disturbances and changes of commands (desired gait and motion), which are the main requirements for learning a policy in this work.

To control the quadruped Go2 we used the MPC formulation in [1] which, given a desired contact sequence and switch timings, uses an iterative kino-dynamic solver to generate whole body trajectories in a receding horizon fashion. It is also open-source and available on Github. We would like to again emphasize that our results in this paper are independent of the choice of the MPC and are valid for any other expert controller.

2) Data Collection: Data for the behavior cloning was collected by rolling out simulations for both the biped and quadruped with the expert controllers. One rollout of the simulation is defined as a sequence of desired velocities, durations, and gaits which are sampled for both robots with the values shown in Table II. The velocities v x , v y and time durations T dur are sampled from a uniform distribution U . The gaits are sampled from an equal categorical distribution.

TABLE II: Rollout parameter definitions.

| Robot           | v x                                       | v y                        | T dur               | Gaits b                      |
|-----------------|-------------------------------------------|----------------------------|---------------------|------------------------------|
| Biped Quadruped | U ( - 1 . 0 , 1 . 2) U ( - 0 . 1 , 0 . 5) | 0 . 0 U ( - 0 . 3 , 0 . 3) | U (1 , 3) U (1 , 3) | { walk, run } { trot, jump } |

We define a rollout for the biped to be a sequence of 5 sampled tuples ( v x × v y × T dur × b ) whereas for the quadruped a rollout is defined as one tuple:

$$& R _ { \text{biped} } = ( v _ { x } \times v _ { y } \times T _ { d u r } \times b ) _ { 1 \colon 5 } \,, \quad & ( 6 ) \quad \exp \quad \\ & R _ { \text{quadred} } = ( v _ { x } \times v _ { y } \times T _ { d u r } \times b ) \quad & \quad & \quad \text{the s}$$

We define rollouts for the biped to have a sequence of sampled values in order to record expert demonstrations of gait switching behavior. Conversely, we do not record gait switching behavior for the quadruped because the rollouts only consist of one tuple of sampled values. This implies that gait switching is in-distribution for the biped but not the quadruped and we will leverage this later in the discussion of our results.

Fig. 2: Policy structure for the velocity-conditioned policy and the contact-conditioned policy.

![image](https://ac.marcodsn.me/arxiv-markdown-images/2408.00776v2-figure-ef1a0010-2dfb-41c5-8504-e6d743d1706d.jpg)

3) Policy Parametrization: All policies are parameterized as three-layer fully connected perceptrons with Relu activation functions. Hyperparameters are kept constant between the different policies that were compared. The four policies π g 1:4 that are compared are each defined by their goal representation which is presented in Table I. In addition to the goal representation, the inputs to each policy also contain the current state of the robot which is the same across all policies.

## IV. RESULTS

In this section, we present the results of the experiments comparing our contact-conditioned policy Con. to the standard velocity-conditioned policy Vel.+Gait . We also perform two ablations Vel.+Gait+Con. and Con.+Gait (see Table I for goal definitions). In particular, we trained the four policies to control the biped Bolt and the quadruped Go2. In the following we detail the setup for each case:

- 1) Biped : the training data consisted of rollouts with walking, running and gait switching. We only collected locomotion data of the robot in the saggital direction in order to test the ability of the different policies to generalize to unseen velocities in the lateral direction.
- 2) Quadruped : the training data included both sagittal as well as lateral velocities, however, this time we did not include episodes with gait switching. Including both sagittal and lateral velocities helps to see if the observations from the biped translate to more general cases. Furthermore, not including gait switching in the training data allows us to see if the policies are able to effectively transition between the different skills.

Details on the episode sampling parameters are summarized in Table II. All policies were trained with the same expert demonstrations, with fixed hyperparameters, and for the same number of epochs. Our goal in this section is to answer the following question: Which goal contains a richer representation for multi-gait policy learning?

Remark : The policies encode multiple gaits in one neural network. All policies except the contact-conditioned policy ( Con. ) receive information about which gait should be executed. The contact-conditioned policy can only infer the gait information from the contact goals.

## A. Evaluation Metrics

To compare the policies we will use two metrics, the first one is total survived time T surv in an evaluation episode rollout. An episode terminates either at 10 seconds or earlier if any of the following conditions are violated:

- · Base height: 0 1 . &lt; h base &lt; 1 [m]
- · Base Pitch: | pitch | ≥ 30 ◦
- · Base Roll: | roll | ≥ 45 ◦

Furthermore to evaluate the performance of the policy we use the following scaled error ϵ :

$$\epsilon = \frac { \| \bar { v } _ { \text{expert} } - \bar { v } _ { \text{policy} } \| } { \max { ( T _ { \text{surv} } / T _ { \max }, \delta ) } }, \text{where } \delta = 0. 1. \quad ( 7 )$$

The velocity error is scaled inversely with the survived percentage, ensuring that a balance between survived time and velocity error is captured.

## 1. Biped Experiments

The biped was first evaluated in-distribution of its training data on a uniform grid of samples with saggital velocities v x ∈ [ -1 0 . , 1 2] . . 100 episodes spanning this range were rolled out for walking, running and gait switching with a maximum duration of 10 seconds.

The scaled error (7) and survival time (the time before failure) for in-distribution tests are plotted in Fig. 3. As all walking policies saturated to the performance of the expert controller, we removed walking from this figure and only look at the more challenging cases of running and gait switching. As we can clearly see in Fig. 3, the Con. policy substantially outperform other representations, replicating the expert behavior with less failures.

Next we performed an experiment testing the policies' ability to execute velocities not seen during training. This experiment consisted of the biped commanded to walk at 0.5 m/s in a dense grid of planar directions, namely at every 10 degrees of the unit circle while the robot was trained only on forward and backward motions. These results are visualized in Fig. 4, where the rays represent the velocity aligned with the lateral plane of the robot. The green color denotes the nominal commanded lateral velocity, hence the closer the results are to the green the better the performance. As it can be seen in Fig. 4, the contact-conditioned (blue) policy was able to most closely follow the desired lateral velocity (green) while the Vel.+Con. (Yellow) and Con.+Gait (orange) policies showed moderate ability. As expected,

Fig. 3: Biped in-distribution evaluations. Top: scaled error (7), bottom: time survived in evaluation rollout, max 10 seconds. As we can see in the plots, Con. policy has substantially smaller error and larger survival time compared to the other representations.

![image](https://ac.marcodsn.me/arxiv-markdown-images/2408.00776v2-figure-4fff9255-98e0-4084-b460-acfa84319a00.jpg)

Fig. 4: Biped out-of-distribution evaluations. The robot was commanded to walk at 0.5 m/s in a dense grid of planar directions, while it was trained only on forward and backward motions. The rays represent the velocity aligned with the lateral plane of the robot. The green color denotes the nominal commanded lateral velocity. The con. policy clearly outperforms other representations in tracking the nominal behavior in all directions.

![image](https://ac.marcodsn.me/arxiv-markdown-images/2408.00776v2-figure-004a9ac9-a37c-4a99-8bce-f06bc07e5e79.jpg)

the velocity-conditioned (red) policy was not able to track velocities not seen in training, demonstrating how overfitting to high-level skills can hamper generalization. Basically policies containing contact information were able to execute velocities in the lateral direction, which supports the hypothesis that conditioning on contact information improves outof-distribution generalization.

v x ∈ [ -0 4 . , 1 2] . , v y ∈ [ -0 6 . , 0 6] . . The scaled error (7) and survival time in this case are visualized in Fig. 5. The upper plot for each gait shows via the blue-green heatmaps the scaled error ϵ with a high number (green) implying worse performance. The purple-yellow heatmaps show the survivability T surv with yellow implying long survivability and purple representing early termination. Furthermore, the cells within the red boxes represent the velocity range present in the training data. As we can see in these plots, inside the distribution of the training data in the red boxes, the results are very similar (slightly better for the contact-conditioned policies). This is in contrast to the biped case, where even inside the distribution of the training data there were stark differences. We believe that this is likely due to the fact that the quadrupeds are much more stable than bipeds and the motions are less sensitive to the errors the control policy makes. However, when looking at the results outside of the red boxes, namely the out of distribution data, it can clearly be seen in Fig. 5 that the survivability regions of the Con. and Con.+Gait policies are larger compared to the Vel.+Gait and Vel.+Gait+Con. policies. This result is consistent with the result of the biped and further strengthens our claim that the contact goal representation captures an invariant representation of the locomotion behavior, allowing it to follow velocities it was not trained on. Interestingly, the Vel.+Gait+Con. policy performs the worst outside of the distribution of the training data. This is an interesting observation as it shows that providing more information to the policy does not necessarily improve the performance and might lead to overfitting to the redundant information.

## 2. Quadruped Experiments

Similar to the biped case, we evaluated the quadruped experiments both in distribution as well as out of distribution of its training data. To do so, we tested policies on a uniform grid of 221 episodes for the trotting and the jumping gait separately and with velocities in the range

In the final experiment, we test the gait switching capability in episodes with randomized switching times and randomized gaits. The results are illustrated in Fig. 6, for both inside (left) and outside (right) of the distribution of the training velocities. It is important to note that the policies in this case were not trained on gait switching data, therefore we consider this as out-of-distribution. Surprisingly, the Vel.+Gait+Con. performed the best gait switching alongside Con. on the indistribution velocities. This was unexpected, because in the other experiments Vel.+Gait+Con. performed poorly. Perhaps we overestimated the difficulty of gait switching while

Fig. 5: Quadruped velocity tracking evaluations. Policies were tested on a dense grid of x and y velocities for jump (top) and trot (bottom). Inside the red box is the velocity range present in the training data. Top(blue-green): scaled error (7). Bottom(yellow-purple): time survived in evaluation rollout, max 10 seconds. While all policies perform similarly inside the range of velocities they trained on, contact-conditioned policy outperforms others for the out-of-distribution velocities.

![image](https://ac.marcodsn.me/arxiv-markdown-images/2408.00776v2-figure-d4e25c1f-303a-4c60-ae08-943374f19e55.jpg)

Fig. 6: Quadruped gait switching evaluations. y-axis: percent of time survived in evaluation rollout. Left: in-distribution velocities. Right: out-of-distribution velocities. While vel.+con+gait shows competitive results compared to con. inside the training distribution, its performance drops outside of the training distribution and the con. policy shows the best survivability.

![image](https://ac.marcodsn.me/arxiv-markdown-images/2408.00776v2-figure-92ba563b-2ce6-418d-beb5-b1f8855bde46.jpg)

executing in-distribution velocities, however when looking at the results for the out-of-distribution velocities on the right hand side of Fig. 6, we see that these results align with our previous experiments. We can see an extreme drop in survivability for the Vel.+Gait+Con. , mirroring its out-ofdistribution performance in the previous experiment.

In contrast to overfitting and similarly to the previous experiments, the Con. followed by the Con.+Gait policies show the best out-of-distribution results for the gait switching on the quadruped platform, further reinforcing our claim that the contact-conditioned Con. policy is a suitable goal representation for a multi-gait policy.

traditional conditioning on the desired average velocity, we proposed to represent the goal as a set of desired future contact switches. Through an extensive set of simulation experiments on the walking and running of a biped robot as well as trotting and jumping of a quadruped, we have shown that representing desired behavior as a set of next contact switches can improve the performance and robustness in both in-distribution and out-of-distribution scenarios. In particular, our results showed the promise of contact-conditioned policies for out-of-distribution generalization.

## V. CONCLUSION

In this paper, we evaluated the contact mode goal representation for multi-gait legged locomotion. Contrary to

In the future, we plan to go beyond cyclic gaits and train a generalist policy that can realize any desired contact sequences from a contact planner. Furthermore, we are interested in testing the hypothesis on manipulation and locomanipulation tasks, as contact is central for both locomotion and object manipulation problems. Finally, real-world experiments are foreseeable in the near future.

## REFERENCES

- [1] A. Meduri, P. Shah, J. Viereck, M. Khadiv, I. Havoutis, and L. Righetti, 'Biconmp: A nonlinear model predictive control framework for whole body motion planning,' IEEE Transactions on Robotics , 2023.
- [2] J.-P. Sleiman, F. Farshidian, and M. Hutter, 'Versatile multicontact planning and control for legged loco-manipulation,' Science Robotics , vol. 8, no. 81, p. eadg5014, 2023.
- [3] C. Mastalli, W. Merkt, G. Xin, J. Shim, M. Mistry, I. Havoutis, and S. Vijayakumar, 'Agile maneuvers in legged robots: a predictive control approach,' IEEE Transactions on Robotics , 2023.
- [4] J. Tan, T. Zhang, E. Coumans, A. Iscen, Y. Bai, D. Hafner, S. Bohez, and V. Vanhoucke, 'Sim-to-real: Learning agile locomotion for quadruped robots,' arXiv preprint arXiv:1804.10332 , 2018.
- [5] J. Hwangbo, J. Lee, A. Dosovitskiy, D. Bellicoso, V. Tsounis, V. Koltun, and M. Hutter, 'Learning agile and dynamic motor skills for legged robots,' Science Robotics , vol. 4, no. 26, p. eaau5872, 2019.
- [6] Z. Xie, P. Clary, J. Dao, P. Morais, J. Hurst, and M. Panne, 'Learning locomotion skills for cassie: Iterative design and sim-to-real,' in Conference on Robot Learning , pp. 317-329, PMLR, 2020.
- [7] J. Siekmann, K. Green, J. Warila, A. Fern, and J. Hurst, 'Blind bipedal stair traversal via sim-to-real reinforcement learning,' in Robotics: Science and Systems , 7 2021.
- [8] J. Tobin, R. Fong, A. Ray, J. Schneider, W. Zaremba, and P. Abbeel, 'Domain randomization for transferring deep neural networks from simulation to the real world,' in 2017 IEEE/RSJ international conference on intelligent robots and systems (IROS) , pp. 23-30, IEEE, 2017.
- [9] X. Huang, Y. Chi, R. Wang, Z. Li, X. B. Peng, S. Shao, B. Nikolic, and K. Sreenath, 'Diffuseloco: Real-time legged locomotion control with diffusion from offline datasets,' arXiv preprint arXiv:2404.19264 , 2024.
- [10] A. Reske, J. Carius, Y. Ma, F. Farshidian, and M. Hutter, 'Imitation learning from mpc for quadrupedal multi-gait control,' in 2021 IEEE International Conference on Robotics and Automation (ICRA) , pp. 5014-5020, IEEE, 2021.
- [11] X. B. Peng, G. Berseth, K. Yin, and M. Van De Panne, 'Deeploco: Dynamic locomotion skills using hierarchical deep reinforcement learning,' Acm transactions on graphics (tog) , vol. 36, no. 4, pp. 1-13, 2017.
- [12] C. Zhang, W. Xiao, T. He, and G. Shi, 'Wococo: Learning wholebody humanoid control with sequential contacts,' arXiv preprint arXiv:2406.06005 , 2024.
- [13] M. Khadiv, A. Meduri, H. Zhu, L. Righetti, and B. Sch¨ olkopf, 'Learning locomotion skills from mpc in sensor space,' in Learning for Dynamics and Control Conference , PMLR, 2023.
- [14] S. Ross, G. Gordon, and D. Bagnell, 'A reduction of imitation learning and structured prediction to no-regret online learning,' in Proceedings of the fourteenth international conference on artificial intelligence and statistics , pp. 627-635, JMLR Workshop and Conference Proceedings, 2011.
- [15] X. Pua and M. Khadiv, 'Safe learning of locomotion skills from mpc,' in 2024 IEEE-RAS 23rd International Conference on Humanoid Robots (Humanoids) , pp. 459-466, IEEE, 2024.
- [16] M. G. Boroujeni, E. Daneshmand, L. Righetti, and M. Khadiv, 'A unified framework for walking and running of bipedal robots,' in 2021 20th International Conference on Advanced Robotics (ICAR) , pp. 396403, IEEE, 2021.
- [17] E. Daneshmand, M. Khadiv, F. Grimminger, and L. Righetti, 'Variable horizon mpc with swing foot dynamics for bipedal walking control,' IEEE Robotics and Automation Letters , vol. 6, no. 2, pp. 2349-2356, 2021.
- [18] M. Khadiv, A. Herzog, S. A. Moosavian, and L. Righetti, 'Walking control based on step timing adaptation,' IEEE Transactions on Robotics , vol. 36, no. 3, pp. 629-643, 2020.
Michal Ciebielski Federico Burgio Majid Khadiv
Contact-conditioned learning of multi-gait locomotion policies
In this paper, we examine the effects of goal representation on the
performance and generalization in multi-gait policy learning settings for
legged robots. To study this problem in isolation, we cast the policy learning
problem as imitating model predictive controllers that can generate multiple
gaits. We hypothesize that conditioning a learned policy on future contact
switches is a suitable goal representation for learning a single policy that
can generate a variety of gaits. Our rationale is that policies conditioned on
contact information can leverage the shared structure between different gaits.
Our extensive simulation results demonstrate the validity of our hypothesis for
learning multiple gaits on a bipedal and a quadrupedal robot. Most
interestingly, our results show that contact-conditioned policies generalize
much better than other common goal representations in the literature, when the
robot is tested outside the distribution of the training data.