Modelling Generalized Forces with Reinforcement Learning for Sim-to-Real Transfer

10/21/2019 ∙ by Rae Jeong, et al. ∙ 0

Learning robotic control policies in the real world gives rise to challenges in data efficiency, safety, and controlling the initial condition of the system. On the other hand, simulations are a useful alternative as they provide an abundant source of data without the restrictions of the real world. Unfortunately, simulations often fail to accurately model complex real-world phenomena. Traditional system identification techniques are limited in expressiveness by the analytical model parameters, and usually are not sufficient to capture such phenomena. In this paper we propose a general framework for improving the analytical model by optimizing state dependent generalized forces. State dependent generalized forces are expressive enough to model constraints in the equations of motion, while maintaining a clear physical meaning and intuition. We use reinforcement learning to efficiently optimize the mapping from states to generalized forces over a discounted infinite horizon. We show that using only minutes of real world data improves the sim-to-real control policy transfer. We demonstrate the feasibility of our approach by validating it on a nonprehensile manipulation task on the Sawyer robot.

READ FULL TEXT VIEW PDF
POST COMMENT

Comments

There are no comments yet.

Authors

page 1

page 3

page 4

page 5

This week in AI

Get the week's most popular data science and artificial intelligence research sent straight to your inbox every Saturday.

I Introduction

Reinforcement learning (RL) [1] algorithms have demonstrated potential in many simulated robotics domains such as locomotion [2], manipulation [3] and navigation [4]. Yet these algorithms still require large amounts of data, making learning from scratch on real robots challenging [5, 6, 7]. Recently, there have been many successes using simulation to speed up robot learning [8, 9, 10, 11]. Recent works have demonstrated that with enough domain randomization [8], zero-shot transfer of sim-to-real policies are feasible, even in contact-rich, hybrid discrete-continuous dynamical systems [8, 10].

A successful sim-to-real transfer method balances the expensive real-world data and inexpensive simulated data to yield sample-efficient performance in the real world. Dynamics randomization [8] can yield successful policy transfer, but relies on manual selection of simulation parameters to randomize and does not incorporate real-world data in the learning process. Model-based RL methods learn the dynamics model from data and tend to be more sample efficient than model-free RL methods, but learning a model still requires high number of real world samples [12, 13], and may be prohibitive for complex dynamics. Adversarial domain adaptation methods have the potential to improve the simulation, but have only been demonstrated for adaptation of observations, rather than direct adaptation the system dynamics [14]. Classical system identification methods provide a sample efficient way to improve the model, but are limited in expressiveness by the model parameters exposed from the analytical models or simulators [15].

Fig. 1: Manipulation task setup, on the real robot and in simulation. Top row: 3D position matching task (green dot is the target position). Bottom row: 6D pose matching task (translucent target is the target 6D pose).

Nonprehensile robotic manipulation has been studied previously in the form of planar pushing with dynamics randomization and zero-shot sim-to-real transfer [8]. Policies trained with dynamics randomization has been shown to produce robust policies which can successfully perform real-world nonprehensile robotic manipulation tasks. However, zero-shot sim-to-real transfer using dynamics randomization does not use any real world data to improve the simulator and requires manual tuning of the choices and ranges of the physical parameters to vary in simulation. The chosen parameters are often very conservative, resulting in a policy that trades robustness to large variation of the model parameters at the expense of overall performance.

Alternatively, the simulated model can be improved to resemble the real world more closely. System identification techniques have been applied to nonprehensile manipulation through joint system identification and state estimation procedure that accurately models the contact dynamics

[15]. However, system identification methods require the true system dynamics to be in the realm of expressiveness of the analytical model. To get around this, others modelled the complex dynamics of planar pushing by combining both the learned and analytical models [16].

Modelling complex dynamics is important for nonprehensile manipulation but is also critical for locomotion. Recent work performed sim-to-real transfer of locomotion tasks by improving the simulation fidelity through system identification, modelling the actuators and latency of the system, which was then used in conjunction with dynamics randomization to train a robust policy for better sim-to-real transfer [10]. The idea of using both the learned and the analytical model has also been applied to locomotion where the complex actuator dynamics were learned for a quadruped robot [17].

Ground Action Transformation (GAT) [18] is a more general method which modifies the actions from the policy trained in simulation. The modified actions are chosen such that, when applied in simulation, the resulting next state matches the next state observed on the real robot. Our proposed approach can be seen as a generalization of the Ground Action Transformation method. We introduce additive generalized forces to the environment instead of modifying the agent’s actions. The optimization of GAT and our method is also different, in that GAT learns an inverse dynamics model in both simulation and the real robot to compute the action transformation, while our method optimizes the objective directly over a discounted infinite horizon through the use of reinforcement learning.

This paper focuses on sim-to-real transfer of robotic manipulation by efficiently utilizing a small amount of real world data to improve the simulation. Our contribution is twofold. First, we provide a novel sim-to-real method which learns a state dependent generalized force model using neural networks as expressive function approximators to model the constraint forces of a dynamical system. Second, we efficiently optimize the state-dependent generalized force model over a discounted infinite horizon through the use of RL. We validate the proposed approach on a nonprehensile robotic manipulation task on the Saywer robot.

This paper is organized as follows. Section II introduces the mathematical background on mechanical systems and reinforcement learning problems. Section III describes how modelling the generalized forces can be used to improve sim-to-real transfer and how these forces can be learned efficiently using reinforcement learning. Finally, Section IV discusses the experimental validation of the proposed approach. Conclusions and perspectives conclude the paper.

Ii Background

Ii-a Mechanical Systems and Equations of Motion

In classical mechanics, any rigid body system subject to external forces can be described with the following equations of motion [19, Ch. 13.5]:

(1)

where and are the system configuration and velocity respectively. is the mass matrix, represents the bias forces, including Coriolis, centrifugal, joint friction and gravitational forces. denotes the internal, actuation, torques, and

is a vector of size

of zeros denoting the unactuated variables. External 6D forces are mapped to generalized forces by the corresponding contact Jacobian .

Note that Eq. (1) is quite general. Depending on the definition of the state variables and , it can be used to represent an articulated system, e.g. a robot arm, a generic free floating object, or both systems. If the systems are interacting with each other or with the environment, Eq. (1) needs to be complemented with additional equations describing the contact constraints. Without making any assumption on the kind of contacts, we can express these constraints as a generic function of the state of the involved systems:

(2)

Note that, in the case of rigid contacts, (2) is greatly simplified, but in the following we will consider its most general form.

Fig. 2: Description of the proposed method steps. 1) Train an agent in simulation with the original model parameters. 2) Use the agent trained in step 1 to collect real world data. 3) Learn the generalized force model (GFM): initialize the simulation to the initial state of a real world trajectory and simulate forward, choosing the same actions taken on the real robot. The GFM injects generalized forces into the simulation with the objective of minimizing the difference between the real world and simulation states. 4) Retrain the agent for solving the task of interest using the updated hybrid model.

Ii-B Reinforcement Learning

We consider the reinforcement learning setting with a discounted infinite horizon Markov Decision Process (MDP). An MDP consists of the tuple

: the set of valid states, set of valid actions, the reward function, transition dynamics and the initial state distribution. Let denote the reward obtained in state of an MDP when executing action . The reinforcement learning objective is to find the optimal policy such that:

(3)

where is the discount factor and is the set of all possible policies and the expectation with respect to is , and the states follow the system dynamics of the MDP, i.e. we have where

denotes the transition probability.

With this notation in place, we can define the action-value function, which evaluates the expected sum of rewards for a policy with a one-step Bellman equation of :

(4)

The action-value function is learned for off-policy reinforcement learning during the policy evaluation step to evaluate the policy. The policy itself is improved using the result of policy evaluation in the policy improvement step. Iteratively applying these two steps is referred to as policy iteration [1].

Iii Modelling Generalized Forces with RL

Our method uses a hybrid approach: the analytical model of a mechanical system is supplemented with a parametric function representing additional generalized forces that are learned using real world data. Consider the dynamics equation in Eq. (1). In addition to the actuation and external forces, we add a state-dependent generalized force term, i.e.

(5)

We represent the contact-aware system dynamics in Eqs. (5) and (2) as a hybrid discrete dynamics model , parameterized by vector , which takes as input the current state and action and outputs the prediction of the next state . We want to find the parameter vector that minimizes the dynamics gap along a horizon , that is:

(6)

where represents the resulting next state in the real system. In contrast to other hybrid modelling approaches that learn the residual state difference, we choose to model the gap with generalized forces. This choice has two benefits: i) generalized forces are applied directly to the dynamics equation, that is, the next state resulting from the application of Eqs. (5), (2) is a physically consistent state; ii) it is easier to impose constraints on the learned generalized forces as they have a physical correspondence.

It is worth noting that the resulting hybrid model is non-differentiable, as Eq. (2) is in general non-differentiable. By consequence, the function is not differentiable with respect to its arguments and the optimal generalized forces are not trivial to obtain using classical methods. However, the formulation of optimizing a state-dependent model interacting with a non-differentiable component over a horizon strongly resembles the reinforcement learning objective in Equation 3. We therefore reformulate the original problem of optimizing the objective in Equation 6 as a reinforcement learning problem.

Define a trajectory consisting of a sequence of states and actions collected on the real system, and the corresponding dataset of all the acquired real world trajectories. Let us define the following reward function:

(7)

with a suitable distance function for measuring the distance between and . At the beginning of each training episode, we randomly sample an initial state , and we initialize the internal dynamics model to . The sum of the rewards in Equation 7 is maximized with the RL objective in Equation 3, resulting in the following objective:

(8)

where

is the transition probability distribution of the unmodified dynamic model given in Eqs. (

1),(2).

The resulting generalized force model (GFM), , is then used as the transition model for the hybrid model (5) and (2). We then train the policy for a control task of interest using the hybrid model with the transition probability distribution , resulting in the following reinforcement learning objective:

(9)

To optimize both Equation 8 and 9, we chose the policy iteration algorithm called Maximum a Posteriori Policy Optimization (MPO) [20]

, which uses an expectation maximization style

policy improvement with an approximate off-policy policy evaluation algorithm Retrace [21] which estimates the action-value function given in Equation 4.

Fig. 2 shows the proposed method, highlighting the different steps from the first policy training in the unmodified simulator (, step 1) to the final policy trained on the updated simulator model (, step 4).

Fig. 3: Joint position control experiment. Pictured are the position setpoint reference trajectory for the base joint of the arm, the position of the real robot after following the command, the prediction from the model with default parameters, after system identification and from the hybrid model.

Iv Experimental Results and Discussion

In this section we present the results of the experiments we performed to validate the proposed sim-to-real transfer method. The experiments have been devised to answer to the following questions. i) Does the use of the GFM improve the modelling capacity with respect to an analytical model with parameters obtained from system identification? ii) How does the training of GFMs scale with an increase in real world data? iii) What is the impact of GFMs on policy training in simulation? iv) Does the use of GFMs improve sim-to-real transfer for nonprehensile robotic manipulation tasks?

Referring to Eq. (5), the configuration of our experimental system is with the velocity . The actuated torques are with the learned generalized forces .

The position and velocity of the robot joints are obtained by using the local robot sensors, i.e. the joint encoders. The object is tracked by using a fiduciary marker system based on AR tags, see Fig. 4. We track the object independently with three cameras and then merge the information into a single 6D estimation value. To obtain the velocity, we perform a finite differentiation of the estimated position. The robot is controlled at while the simulation is integrated every .

With reference to the algorithm outlined in Sect. III, we define the distance function as follows:

(10)
Fig. 4: Top row: object and plate end effector for the 3D position matching task. Bottom row: object and ball end effector for the 6D pose matching task. Objects 6D poses are tracked using the AR tags on the sides of the object.

Iv-a Experimental Setup

Fig. 1

shows the real and simulated setup used in our experiments. The platform is a 7 degrees of freedom (DoF) Rethink Robotics Sawyer robotic arm. A basket, where the objects lie and move, is placed in front of the robot. Depending on the specific experiment, the object and the end effector of the robot can change. The full hardware setup, i.e. robot, basket and objects, are modelled in simulation using the MuJoCo simulator

[22] where we represented the orientation component by using unitary quaternions, is the quaternion product and denotes the complex conjugate of the quaternion. We define the following limits for the learned generalized forces:

  • for the forces acting on the robot joints,

  • for the forces acting on the translational part of the object and

  • for the forces acting on the rotational part of the object.

While learning the GFMs, we also provide as observation to the RL algorithm the 5 previous states of the dynamics simulation.

Both the GFM and the control policy are feed-forward neural networks with two layers, each with a size of 200. The neural network outputs a Gaussian distribution with the mean

and diagonal Cholesky factors , such that . The diagonal factor has positive diagonal elements enforced by the softplus transform to ensure positive definiteness of the diagonal covariance matrix.

Iv-B Joint Position Control

To examine the GFM’s modelling capabilities, we collect trajectories of the robot controlled in position mode, following a pre-defined waypoint-based trajectory. No interactions with the object or the basket took place in this experiment. MuJoCo by default exposes two parameters for modelling the actuator, namely the actuator gain and damping. We identify these parameters by using SciPy [23] Sequential Least Squares Programming. We then train our proposed hybrid model using the approach described Sect. III.

We report the comparison of the trajectories resulting from the different models in Fig. 3. We can notice that both the GFM and the parameters-identified model improve upon the default simulation model. However, the GFM hybrid model is able to capture the complexity of the real data better than the simulator’s simplified actuator model alone. This also demonstrates the generality of our GFM hybrid model approach, as no specific knowledge about actuator dynamics are needed for training the GFM. However, it is worth noting that the GFM hybrid model is a local approximation around the real data used for training.

Fig. 5: The 10 target positions for the position matching task are shown as the green triangles.

Iv-C Position Matching Task

To validate and assess quality of the proposed method, we use a position matching task for the free-moving object. The goal of this task is to move the object to a specific target location. The robotic arm is equipped with an acrylic plate as its end effector as can be seen in Fig. 4.

We provide the state of the robot, the pose of the object, and the target position of the brick as observations to the agent, as described in Sect. IV-A. We provide a history of observations by providing to the agent the last , including the current, observations. Each episode is composed of a maximum of transitions (corresponding to ). The episode is terminated, and considered a failure, if the end-effector of the robot leaves its workspace.

The agent’s actions consist of joint velocities, representing reference setpoints for the robot’s low-level joint velocity controller. We decided to limit the maximum joints velocity to 5 percent of the allowed range of velocities. Two reasons motivated this choice: i) lower velocity implies safer action from the robot while interacting with the object and the environment, and, ii)

lower velocity for the object whilst under interaction with the robot allows better pose estimation from the AR tags system.

We evaluate the agent’s performance on the task with a binary success-failure criterion for 5 trials. An episode is a success if the error between the object’s position and the target is less than for consecutive time steps, i.e. . Each trial consists of 10 target positions, making the total number of target positions attempted for each policy to . The initial pose of the object is reset to the center of the basket at the beginning of every attempt. The target locations are fixed and are radially positioned around the center of the basket – See Figure 5.

Fig. 6: Average return when learning the position matching task with and without the use of curriculum and GFM. The use of curriculum results in a non-monotonic learning curves, because throughout the course of training the control authority of the policy is reduced.

Iv-D Ensemble of Hybrid Models

We first examine how the training of GFMs scales with the increase in real world data.

We train a policy for the position matching task using the default simulator model as shown in step 1 of Fig. 2, and we use this policy to collect a dataset of trajectories on the real robot.

We then train two GFMs using different amounts of real world trajectories. The first one uses 5 trajectories, while the second one uses all 10 trajectories. The second GFM faces a more challenging modelling problem as it has to learn to fit more data points from the real world. In our GFM training, using 5 trajectories on average resulted in around 10% higher average return when compared to the GFM that used 10 trajectories.

In practice, given that we would like to use more than 5 real world trajectories to improve the dynamic model, we decide to employ an ensemble of GFMs instead of increasing the number of trajectories used during the GFM learning. All the following experiments are trained with the fixed number of 5 trajectories per model.

Iv-E Training Policies on Hybrid Models

The additional complexity introduced by the hybrid model has an impact in the learning performance of the final policy. Fig. 6 shows that the additional term significantly slows down training when compared to the original unmodified model. This is expected, as GFM essentially injects force perturbations which makes the task harder to solve. To reliably obtain the optimal policy when training with the hybrid model, we employ a simple curriculum learning strategy. At the beginning of the training, we allow higher control authority to facilitate exploration and task completion, while progressively lowering it towards the end. We implemented the curriculum by introducing an additional multiplicative gain to the controlled joint velocities. We started with a gain of , progressively reducing it to by unitary steps every episodes. Fig. 6 shows the training curves for policy learning on both the unmodified dynamic model and the hybrid model when using the curriculum strategy. We can clearly see that the curriculum improves the speed and the final performance of the policy.

Models Task Success Std. Dev.
Original model 38% 3.4
Original model with Curriculum 62% 3.4
Random Force Perturbations 70% 3.2
Hybrid Model (1 model in ensemble) 58% 3.5
Hybrid Model (3 models in ensemble) 84% 2.6
Hybrid Model (5 models in ensemble) 74% 3.1
TABLE I: Position Matching Task Evaluation

Iv-F Position Matching Task: Experimental Results

This section reports the results of the sim-to-real policy transfer for the nonprehensile position matching task when using both the model ensemble and curriculum learning strategy discussed in the previous sections.

Table I

summarizes the results, reporting the average success percentage and the standard deviation. We compare our method to 3 baseline methods which are

i) policy trained with the original dynamic model, ii) policy trained with the original model and using curriculum learning and, iii) policy trained with random perturbations of generalized forces and using curriculum learning. As expected, the policy trained with the original model performs poorly due to the dynamics gap resulting in 38% success. However, the default simulation trained with our curriculum learning performs significantly better with 62% success. Given that the curriculum learning induces time-varying actuator gains, this has a similar effect to applying domain randomization. Lastly, the addition of random generalized force perturbations on top of our curriculum learning results in 70% success.

The lower part of Table I reports the performance of transferred policies trained with the hybrid model for a different number of model ensembles (in parentheses). While the use of one GFM leads to an improvement over the original model, it does not perform better than the other two baselines. Given that a single GFM only uses 5 real world trajectories, it is plausible that the hybrid model is over-fitting to those particular trajectories. The use of 3 GFMs significantly improves the sim-to-real transfer and results in 84% success. Using 5 GFMs still outperforms all of the baselines but results in a degradation of performance when compared to using only 3 GFMs. Indeed, while using more GFMs allows us to utilize more real world data, it also makes the task more challenging, even compared to the real world. This results in a more conservative controller which is not as optimal as when we have the right balance of GFMs to model the real world.

Models Task Success Std. Dev.
Original model 18% 2.7
Hybrid Model (3 models in ensemble) 44% 3.5
TABLE II: Pose Matching Task Evaluation

Iv-G 6D Pose Matching Task

Finally, we provide the results for sim-to-real policy transfer for a much more challenging nonprehensile manipulation task. The task is similar to the one described in Sect. IV-C, but this time we consider also the orientation of the object. The task and learning setup is exactly the same as the one described in Sect. IV-C, except for the following changes. The episode duration is transitions, i.e. . During the evaluation procedure we consider an attempt as successful if the position error is less than and the orientation error around the vertical axis is less than degrees.

Table II presents the results of the sim-to-real transfer for the 6D pose matching task. As for the previous experiment, our method is able to significantly improve over the baseline of 18% to 44% success. The success rate is lower when compared to the previous experiment, but this applies to both the policy learned on the original model and on the hybrid model, showing the complexity of the task.

V Conclusions

In this work we presented a novel sim-to-real method that aims to close the sim-to-real gap by modelling and learning the state dependent generalized forces that capture this discrepancy. We validated the proposed approach by performing sim-to-real transfer for nonprehensile robotic manipulation tasks. We showed that our method improves the performance of sim-to-real transfer for 3D position matching and 6D pose matching task of different objects. While the results reported in Sect. IV-G on 6D pose matching showed that our approach yields a considerable improvement with respect to the default model, there are still rooms for improvements. We thus want to analyze and improve on this task further.

When controlling interaction forces, it is common to choose torque control as the low level controller. Despite this classic choice, the use of torque control is not common in reinforcement learning. Future work could investigate if the use of our proposed generalized force model helps in learning an interaction task while controlling the robot by using torque control.

References