\section{Foundations}
We adopt here the formulation presented by~\cite{Belbute-Peres2017}, and we extend it to include frictional forces between a pushed object and a support surface. 
The transition function is given as $x_{t+1} = x_t + v_{t} dt$ where $dt$ is the duration of a constant short time-step. Velocity $v_{t}$ is a function of pushing force $\mu_t$ and mechanical parameters $\theta$. 
To find $v_{t+dt}$, we solve the system of equations of motion given in Figure~\ref{equation_motion}, where $x_t$ and $v_{t}$ are given as inputs, $[a,\rho,\xi]$ are slack variables, $[v_{t+dt},\lambda_e,\lambda_c,\lambda_f,\eta]$ are unknowns, and
$[\mathcal{M}, \mu_f] \stackrel{def}{=} \theta$ are the mechanical properties of the manipulated object  that are hypothesized. $\mathcal{M}$ is a diagonal mass matrix, where the diagonal is given as $[\mathcal{I}_1,\mathcal{M}_1,\mathcal{M}_1,\mathcal{I}_2,\mathcal{M}_2,\mathcal{M}_2,\dots, \mathcal{I}_k,\mathcal{M}_k,\mathcal{M}_k]$, where $\mathcal{I}_i$ is the moment of inertia of the $i^{th}$ cell of the object, and $\mathcal{M}_i$ is its mass. $\mu_F$ is a diagonal matrix containing the magnitudes of the frictional forces exerted on each cell of the pushed object in the direction opposite to its motion.

$\mathcal{J}_e (x_t)$ is a global Jacobian matrix listing all constraints related to the joints of the object. These constraints ensure that the different cells of the object move together with the same velocity, since the object is assumed to be rigid. $\mathcal{J}_c (x_t)$ is a matrix containing constraints related to contacts between the cells of the object. These constraints enforce that rigid cells of the object do not interpenetrate. $c$ is a vector that depends on the velocities at the contact points and on the combined restitution parameter of the cells. More detailed descriptions of $\mathcal{J}_e (x_t)$ and $\mathcal{J}_c (x_t)$ can be found in the supplementary material of~\cite{Belbute-Peres:2018:EDP:3327757.3327820}.

$\mathcal{J}_f$ is a Jacobian matrix related to the frictional forces, and it is particularly important for the objectives of this work. We will return to $\mathcal{J}_f$ in Section~\ref{friction}.
To present the solution more concisely, the following terms are introduced.
\begin{eqnarray*}
\alpha=-v_{t+dt}, \beta = \lambda_e, A = \mathcal{J}_e(x_t) , q = -\mathcal{M}v_t - dt \mu_t\\
\gamma =\begin{bmatrix} \lambda_c \\ \lambda_f \\ \eta \end{bmatrix}, 
s = \begin{bmatrix} a \\ \rho \\ \xi \end{bmatrix}, 
m = \begin{bmatrix} c \\ 0 \\ 0 \end{bmatrix}, 
s = \begin{bmatrix} a \\ \rho \\ \xi \end{bmatrix}, 
G = \begin{bmatrix} \mathcal{J}_e(x_t) & 0 \\ \mathcal{J}_f & 0 \\ 0 & 0 \end{bmatrix},
\mathcal{F} = \begin{bmatrix} 0 & 0 & 0 \\ 0 & 0 & E \\ \mu_f & -E^T & 0 \end{bmatrix}
\end{eqnarray*}
The linear complementary problem (LCP) becomes
\begin{eqnarray}
\begin{bmatrix} 
0  \\
s \\ 
0 
\end{bmatrix}
+
\begin{bmatrix} 
\mathcal{M} & G^T & A^T \\
G & \mathcal{F} & 0 \\ 
A & 0 & 0
\end{bmatrix}
\begin{bmatrix} 
\alpha  \\
\beta \\ 
\gamma 
\end{bmatrix}
=
\begin{bmatrix} 
-q  \\
m \\ 
0 
\end{bmatrix}
\label{lcp}
\end{eqnarray}
subject to $s\geq \mathbf{0}, \gamma \geq \mathbf{0}, s^T\gamma = 0$. 
\begin{figure}
{\scriptsize
\begin{equation*}
\boxed{
\begin{bmatrix} 0 \\ 0 \\ a  \\ \rho \\ \xi \end{bmatrix}
- \begin{bmatrix} \mathcal{M} & -\mathcal{J}_e(x_t) & -\mathcal{J}_c(x_t)  & -\mathcal{J}_f & 0 \\ 
\mathcal{J}_e(x_t) & 0 & 0 & 0 & 0\\ 
\mathcal{J}_c(x_t) & 0 & 0& 0 & 0 \\ 
\mathcal{J}_f & 0 & 0 & 0 & E \\ 
0 & 0 & \mu_{f} & -E^T & 0\end{bmatrix}
\begin{bmatrix} v_{t+dt} \\ \lambda_e \\ \lambda_c  \\ \lambda_f \\ \eta \end{bmatrix}
=
\begin{bmatrix} \mathcal{M}v_{t}+dt \mu_t \\ 0 \\ c  \\ 0 \\ 0 \end{bmatrix}
\textrm{s.t.}
\begin{bmatrix} a \\ \rho \\ \xi  \end{bmatrix} \geq 0,
\begin{bmatrix} \lambda_c \\ \lambda_f \\ \eta  \end{bmatrix} \geq 0,
\begin{bmatrix} a \\ \rho \\ \psi  \end{bmatrix} \begin{bmatrix} \lambda_c \\ \lambda_f \\ \eta  \end{bmatrix} = 0
}
\end{equation*}
}
\vspace{-0.5cm}
\caption{Equations of Motion}
\label{equation_motion}
\end{figure}


The solution is obtained, after an initialization step, by iteratively minimizing the residuals from the equation above through variables $\alpha,\beta,\gamma$ and $s$. The solution is obtained by utilizing the convex optimizer of~\cite{MattingleySB12}. 




\subsection{Baselines}
The compared baselines are \emph{ random search}, \emph{finite differences gradient}, \emph{automatic differentiation with Autograd}, and \emph{weighted sampling}. The weighted sampling search generates random values uniformly in the first iteration, and then iteratively generates normally distributed random values around the best parameter obtained in the previous iteration.
The standard deviation of the random values is gradually reduced over time, to focus the search on the most promising region.



\begin{figure}[t]
    \centering
    \begin{tabular}{cc}
    
 		\includegraphics[width=0.49\textwidth]{./figures/res/quan/real_aver_sims_vs_cell.png} &
 	
 		\includegraphics[width=0.49\textwidth]{./figures/res/quan/real_aver_time_vs_cell.png}\\
 	
    \end{tabular}
   
    \vspace{-0.5cm}
    \caption{Average predicted cell position error (in meters) over all objects and cells for each object as a function of the number of simulations (left) and the computation time (right).}
    \label{fig:quan_aver}
    \vspace{-0.8cm}
\end{figure}
\vspace{-0.2cm}
\subsection{Experimental Setup}
The experiments are performed on both simulated and real robot and objects. A rigid object is set on a table-top.
The robot's end effector is moved randomly to collide with the object and push it forward. The initial and final poses of the object are recorded.
The methods discussed above are used to estimate the object's mass and frictional forces that are distributed over its cells.
Since the ground-truth values of mass and friction are unknown, the identified models are evaluated in terms of the accuracy in the predicted pose of each cell, using a set of test data.
Five different objects are used in our experiments: a hammer, a ranch, a crimp, a toolbox, and a book.
A hammer has an unbalanced mass distribution because the iron head is much heavier than the wooden handle.
A crimp has high frictional forces on its heavy iron head and stiff handle.
A ranch is composed of the same material, however, its handle in the middle (main body) floats and does not touch the table, because of the elevated height of its side parts. Therefore, there are zero frictional forces on the handle. Finally, an open book that has a different number of pages on the left and right sides also has an unbalanced mass-friction distribution, resulting in rotations when pushed.
A toolbox also can have a various mass distribution depending on how the tools are arranged inside.

Note that our method does not assume that the full shape of the object is known, it uses only the observed top part and projects it down on the table to build a complete 3D geometric model. The geometric model is generally wrong because the object is seldom flat, but the parts that do not actually touch the table end up having nearly zero frictions in the identified model. Thus, identified low friction forces compensate for wrongly presumed surfaces in the occluded bottom part of the object, and the predicted motion of the object is accurate despite using inaccurate geometries.

In the simulation experiments, we simulated four random actions on each of the following objects for collecting training data: hammer, crimp, and ranch. We use the physics engine \textit{Bullet} for that purpose. The results are averaged over ten independent experiments, with a different ground-truth model of the object used in each experiment to generate data. The identified mass and friction models are evaluated by measuring the accuracy of the predicted motions on a test set of $12$ different random pushing actions.
In the real robot setup, we used a Kuka robotic arm and Robotiq 3-finger hand to apply the pushing actions, and recorded the initial and final object poses using a depth-sensing camera, as shown as Figure \ref{fig:robot}. The training data set contains only two random pushing actions, while the test data set contains five random pushing actions. The goal is to show how the robot can identify models of objects with a very small number of manipulation actions. The number of cells per object varies from $70$ to $100$ depending on the size of the object.


\iffalse
\begin{wrapfigure}{r}{*}
    \centering
    \begin{tabular}{cc}
       
       
       
        \includegraphics[width=0.2\textwidth]{./figures/res/qual/obj_box.png} & 
       
       
       
        \includegraphics[width=0.18\textwidth,trim={4cm 7cm 4cm 7cm},clip]{./figures/res/qual/massmap_box_3.png}
        \\
        \includegraphics[width=0.2\textwidth]{./figures/res/qual/obj_hammer.png} &  
       
       
       
        \includegraphics[width=0.18\textwidth,trim={4cm 7cm 1cm 6cm},clip]{./figures/res/qual/massmap_hammer_4.png}
        \\
        \includegraphics[width=0.2\textwidth]{./figures/res/qual/obj_book.png} & 
       
       
       
        \includegraphics[width=0.18\textwidth,trim={4cm 6cm 4cm 6cm},clip]{./figures/res/qual/massmap_book_3.png}
        \\
        \includegraphics[width=0.2\textwidth,trim={0 5cm 0 5cm},clip]{./figures/res/qual/crimp_color.png} & 
       
       
       
        \includegraphics[width=0.18\textwidth,trim={3cm 6cm 3cm 6cm},clip]{./figures/res/qual/massmap_crimp_3.png}
        \\
        \includegraphics[width=0.2\textwidth,trim={0 5cm 0 5cm},clip]{./figures/res/qual/ranch_color.png} & 
       
       
       
        \includegraphics[width=0.18\textwidth,trim={3cm 6cm 3cm 6cm},clip]{./figures/res/qual/massmap_ranch_4.png}
    \end{tabular}
   
    \caption{Learned friction$\times$mass distributions. Red color means higher mass$\times$friction value while blue color means lower mass$\times$friction value.}
    \label{fig:qual_heatmap}
\end{wrapfigure}
\begin{wrapfigure}{r}{*}
    \centering
    \begin{tabular}{cc}
	    \begin{tabular}{c}
		     \includegraphics[width=0.4\textwidth]{./figures/res/quan/sim_ntrain_sims_vs_cell.png}\\
		    
		\end{tabular}
         \\
    \end{tabular}
   
   
    \caption{Predicted cell position error with different numbers of training examples.}
    \vspace{-1cm}
    \label{fig:quan_ntrain}
\end{wrapfigure}
\fi
\begin{figure}[h]
    \centering
    \begin{tabular}{cc}
		\includegraphics[height=5.5cm]{./figures/res/qual.png}	         &
         \includegraphics[width=0.5\textwidth]{./figures/res/quan/sim_ntrain_sims_vs_cell.png}
		\\
		(a) & (b)
    \end{tabular}
    \vspace{-0.3cm}
    \caption{(a) Learned friction$\times$mass distributions. Red color means higher mass$\times$friction value while blue color means lower mass$\times$friction value. (b) Predicted cell position error with different numbers of training examples and simulations (gradient-descent steps).}
    \vspace{-0.8cm}
    \label{fig:quan_ntrain}
\end{figure}

\vspace{-0.2cm}
\subsection{Results}
Figure \ref{fig:quan_ntrain} (a) shows identified mass-friction distributions, given as the product of the mass and the friction coefficients of each cell. The mass-friction distributions of the first three objects are estimated in the real robot setup, and the last two are estimated in the simulation setup.
The toolbox contains heavy tools on the left side (ranches, bolts and nuts), while relatively light tools like plastic screw drivers and cramps are placed on the right side.
The proposed method was able to predict the unbalanced mass distribution of the box while it was covered. Likewise, the heavier iron head of the hammer and its light wooden handle are successfully estimated as well as the thicker and thinner sides of the book.
The proposed method successfully estimated the heavier part of the crimp, and the floating part of the ranch was simulated by much lighter friction values in the middle.

\iffalse
Figure \ref{fig:qual_move} shows how the estimated mass distribution is matched to their true behaviors reacting to a various actions. 
For example, although we push the objects while contacting a certain side, the objects are supposed to move straight if it is the center of the mass.
Using the proposed method, we can predict the movement of the objects with other pushing actions.
\begin{figure}[h]
    \centering
    \begin{tabular}{c}
        \includegraphics[width=0.18\textwidth,trim={3cm 3cm 3cm 4cm},clip]{./figures/res/qual/move_box_1.png}
        \includegraphics[width=0.18\textwidth,trim={2cm 1cm 2cm 4cm},clip]{./figures/res/qual/move_hammer_0.png}
        \includegraphics[width=0.18\textwidth,trim={4cm 4.5cm 3cm 3.5cm},clip]{./figures/res/qual/move_book_1.png}
        \includegraphics[width=0.18\textwidth,trim={2cm 3cm 2cm 3cm},clip]{./figures/res/qual/move_crimp_0.png}
        \includegraphics[width=0.18\textwidth,trim={2cm 3cm 2cm 4cm},clip]{./figures/res/qual/move_ranch_1.png}
        \\
        \includegraphics[width=0.18\textwidth,trim={3cm 3cm 3cm 4cm},clip]{./figures/res/qual/move_box_2.png}
        \includegraphics[width=0.18\textwidth,trim={2cm 1cm 2cm 4cm},clip]{./figures/res/qual/move_hammer_1.png}
        \includegraphics[width=0.18\textwidth,trim={4cm 4cm 3cm 3.8cm},clip]{./figures/res/qual/move_book_2.png}
        \includegraphics[width=0.18\textwidth,trim={2cm 3cm 2cm 3cm},clip]{./figures/res/qual/move_crimp_1.png}
        \includegraphics[width=0.18\textwidth,trim={2cm 3cm 2cm 4cm},clip]{./figures/res/qual/move_ranch_2.png}
        \\
        \includegraphics[width=0.18\textwidth,trim={3cm 3cm 3cm 4cm},clip]{./figures/res/qual/move_box_3.png}
        \includegraphics[width=0.18\textwidth,trim={2cm 1cm 2cm 4cm},clip]{./figures/res/qual/move_hammer_2.png}
        \includegraphics[width=0.18\textwidth,trim={4cm 2.8cm 3cm 4.8cm},clip]{./figures/res/qual/move_book_3.png}
        \includegraphics[width=0.18\textwidth,trim={2cm 3cm 2cm 3cm},clip]{./figures/res/qual/move_crimp_2.png}
        \includegraphics[width=0.18\textwidth,trim={2cm 3cm 2cm 4cm},clip]{./figures/res/qual/move_ranch_3.png}
        \\
        \includegraphics[width=0.18\textwidth,trim={3cm 3cm 3cm 4cm},clip]{./figures/res/qual/move_box_4.png}
        \includegraphics[width=0.18\textwidth,trim={2cm 1cm 2cm 4cm},clip]{./figures/res/qual/move_hammer_3.png}
        \includegraphics[width=0.18\textwidth,trim={4cm 3cm 3cm 4.8cm},clip]{./figures/res/qual/move_book_4.png}
        \includegraphics[width=0.18\textwidth,trim={2cm 3cm 2cm 3cm},clip]{./figures/res/qual/move_crimp_3.png}
        \includegraphics[width=0.18\textwidth,trim={2cm 3cm 2cm 4cm},clip]{./figures/res/qual/move_ranch_4.png}
    \end{tabular}
    \caption{Qualitative results of simulated actions. The yellow cubes indicate the movement of the robot finger, the gray is the initial pose, the green is the true object pose, and the heat-map is the estimated mass distribution with the simulated object pose.}
    \label{fig:qual_move}
\end{figure}
\fi

Figure \ref{fig:quan_aver} shows the difference between the predicted cell positions and the ground truth as a function of the number simulations used in the parameter estimations. The results first demonstrate that global optimization methods (random and weighted sampling) suffer from the curse of dimensionality due to the combinatorial explosion in the number of possible parameters for all cells. 
The results also demonstrate that the proposed method can estimate the parameters within a small number of simulations and a short computation time. The proposed algorithm was able to estimate the parameters with under $1.5cm$ average cell position error within $30$ seconds.
Surprisingly, the differential physics engine with \textit{Autograd} requires a significantly longer computation time as the number of cells increases, which is a critical in practice. The finite differences approach also failed to converge to an accurate model due to the high computational cost of the gradient computation, as well as the sensitivity of the computed gradients to the choice the grid size. 

Finally, Figure \ref{fig:quan_ntrain} (b) shows how the number of training actions improves the accuracy of the learned model. Increasing the number of training actions allows the robot to uncover properties of different parts of the object more accurately.
Using a larger number of training actions slows down the convergence of the gradient-descent algorithm, but improves the accuracy of the learned model.
\vspace{-0.7cm}

\section{Introduction}
\input{introduction.tex}

\section{Related Work}
\input{related_work.tex}

\section{Problem Setup and Notation}
\input{problem_setup.tex}
\input{differentiable_physics.tex}

\vspace{-1cm}
\input{proposed_algorithm.tex}

\section{Evaluation}
\input{experiments.tex}
\vspace{-0.25cm}
\section{Conclusion}
\vspace{-0.1cm}
To identify friction and mass distributions of unknown objects pushed by a robot, we proposed a new method that consists in dividing an object into a large number of connected cells, with each cell having different mechanical properties. We adopted a differentiable physics engine that was recently proposed to simulate contact interactions between 2-dimensional objects, and we extended it to deal with frictional forces occurring on table-top 3D objects. In addition to the automatic derivation of the engine, based on {\it Autograd}, we presented a simple gradient-descent algorithm that exploits weak assumptions about the object and the collision to simplify the form of the gradient of reality-gap loss function with respect to the object's parameters. The proposed algorithm was tested in simulation and with real objects, and shown to be efficient in identifying models of objects with non-uniform mass-friction distributions.

\noindent\textbf{Acknowledgments}{~This work was supported by NSF awards 1734492, 1723869 and 1846043.}

\bibliographystyle{abbrv}


\section{Friction Model}
\label{friction}
We describe the Jacobian matrix $\mathcal{J}_f$ related to the Coulomb frictional forces between the object's cells and the support surface, and the corresponding constraints. This model is based on the one derived in~\cite{cline}. 
\vspace{-0.15cm}
\begin{eqnarray*}
\small 
\mathcal{D} = 
\begin{bmatrix} 
0 & 1 & 0 \\
0 & -1 & 0 \\
0 & 0 & 1 \\
0 & 0 & -1 
\end{bmatrix} , 
\mathcal{J}_f = 
\begin{bmatrix} 
\mathcal{D} & 0 & \dots & 0\\
0 & \mathcal{D} & \dots & 0\\
\vdots & \vdots & \dots & 0 \\
0 & 0 & \dots & \mathcal{D}
\end{bmatrix} ,
\mu_f = 
\begin{bmatrix} 
\mu_{f_1} & 0 & \dots & 0\\
0 & \mu_{f_2} & \dots & 0\\
\vdots & \vdots & \dots & \vdots \\
0 & 0 & \dots & \mu_{f_k}
\end{bmatrix} ,
E = 
\begin{bmatrix} 
\zeta & 0 & \dots & 0\\
0 & \zeta & \dots & 0\\
\vdots & \vdots & \dots & \vdots \\
0 & 0 & \dots & \zeta
\end{bmatrix}
\end{eqnarray*}
\vspace{-0.15cm}
$\zeta = [1,1,1,1]^T$, $\mathcal{J}_f$ and $E$ are both a $k\times(4k)$ matrix where $k$ is the number of cells in the object. $\mu_{f_i}$ is the unknow friction coefficient of cell $i$ with the support surface. In the original model of~\cite{cline}, matrix $\mathcal D$ was defined as 
$
\mathcal{D} = 
\begin{bmatrix} 
(p_{contact} \times d) &  d \\
(p_{contact} \times -d) &  -d 
\end{bmatrix},
$
where $d$ is a vector pointing to the tangential to a contact, and $-d$ is a vector pointing to the opposite direction. $p_{contact}$ is the contact point on the object. In our model, we consider only pushing actions that slide objects forward without rolling them over. We thus eliminate the first column of $\mathcal{D}$ which are multiplied by the angular velocities and replace it with a zero column.
The friction terms have complementary constraints that are related to the contact points. We will omit the derivations here (see~\cite{cline}), but interactions between the objects and the support surface give rise to the following constraints,
$\mu_f -E^T \lambda_f \geq 0, \mathcal{J}_f v_{t+dt} + \gamma E \geq 0, \rho^T \lambda_f = 0, \xi^T \eta = 0.$




\section{Proposed Algorithm}

To obtain parameters $\theta^* = [\mathcal{M}^*,\mu_{f}^*]$, a gradient descent on loss function in Equation~\ref{simulationError} is performed, wherein the gradients are computed analytically. A first approach to compute the gradient is to use the {\it Autograd} library for automatic derivation in Python. We propose here a second simpler and faster approach that exploits three mild assumptions: 1) the manipulated object is rigid, 2) the contact point between the robot's end-effector and the object remains constant during the pushing action, and 3) collision between the robot's end-effector and the object is perfectly inelastic with a zero restitution coefficient. That is, the end-effector remains in contact with the object during the pushing action. The relatively low velocity of the end-effector (around 0.2 m/s) ensures the inelastic nature of the collision. The equation of motion can be written as:
\vspace{-0.1cm}
\begin{eqnarray}
 \mathcal{M} v_{t+dt}  -\mathcal{J}_e(x_t) \lambda_{e} -\mathcal{J}_c(x_t) \lambda_{c}  - \mu_{f} \lambda_c= \mathcal{M}v_{t}+dt \mu_t.
\end{eqnarray}
Thus, $V(\hat{x}_{t},\hat{v}_{t}, u_t, \theta) = v_{t+dt}   = \mathcal{M}^{-1} \big( \mathcal{J}_e(x_t) \lambda_{e} + \mathcal{J}_c(x_t) \lambda_{c}  +\mu_{f} \lambda_c + \mathcal{M}v_{t}+dt \mu_t \big).
$
Inverse mass matrix $ \mathcal{M}^{-1}$ exists because $\mathcal{M}$ is a diagonal full-rank matrix. The gradients of predicted velocity with respect to $\mu_f$ is give as:
$
\nabla_{\mu_f} V(\hat{x}_{t},\hat{v}_{t}, u_t, \theta) = \mathcal{M}^{-1} \lambda_c,
$
because $\nabla_{\mu_f} \mathcal{J}_e(x_t) \lambda_{e} = \nabla_{\mu_f} \mathcal{J}_c(x_t) \lambda_{c} = 0$ from assumptions 1-3.
The gradient of the loss in Equation~\ref{simulationError} is given by 
$\nabla_{\mu_f} loss(\theta) = \sum_{t=0}^{T-2} \nabla_{\mu_f} \|x_{t+2} - \big(\hat{x}_{t+1} +  V(\hat{x}_{t},\hat{v}_{t}, u_t, \theta)dt \big) \|_2 
= \sum_{t=0}^{T-2} \Big( x_{t+2} - \big(\hat{x}_{t+1} +  V(\hat{x}_{t},\hat{v}_{t}, u_t, \theta)dt \big)\Big) \mathcal{M}^{-1} \lambda_c dt = C_f \sum_{t=0}^{T-2} \Big( x_{t+2} - \big(\hat{x}_{t+1} +  \underbrace{V(\hat{x}_{t},\hat{v}_{t}, u_t, \theta)}_{\textrm{forward simulation}}\Big)$
where $C_f$ is a constant diagonal matrix. The real value of $C_f$ is of little importance as it will be absorbed by the learning rate of the gradient descent algorithm. A similar derivation for $\mathcal M$ gives $\nabla_{\mathcal M} loss(\theta) = C_m \sum_{t=0}^{T-2} \Big( x_{t+2} - \big(\hat{x}_{t+1} +V(\hat{x}_{t},\hat{v}_{t}, u_t, \theta)\Big)$,
\RestyleAlgo{boxruled}
with $C_M = \alpha C_f^{-\frac{1}{2}}$ and $\alpha$ is a constant factor. Thus, we use update rates $\alpha_{\textrm{rate}}$ and $\sqrt{\alpha_{\textrm{rate}}}$ for frictional forces magnitudes and mass matrix respectively, as as shown in Algorithm~\ref{algo}.
  \begin{algorithm}[h]
\KwIn{Real-world trajectory data $\tau^* = \{(x_{t},\mu_{t}, x_{t+1})\}$ for $t=0, \dots,T-1$, wherein  $x_t$ is a vector in $[SE(2)]^k$ corresponding to translation and rotation in the plane for each of the $k$ cells of a pushed unknown object, and $\mu_{t}$ is a force described by the contact point between the end-effector and one of the object's cells in addition to the pushing direction.
Predefined learning rate $\alpha_{\textrm{rate}}$, and loss threshold $\epsilon$.}
\KwOut{Parameters vector $\theta  = [\mathcal{M}, \mu_f]$}
Initialize $\mu_{f}$ randomly;

\Repeat{$loss \leq \epsilon$}{
$loss \leftarrow0$;

\For{$t\in\{0,T-2\}$}{
   Simulate $\{(\hat{x}_{t+1},\mu_{t+1})\}$ by solving the LCP in Equation~\ref{lcp} with parameters $\theta$ (or by using an off-the shelf physics engine) and get the predicted next state $\hat{x}_{t+2} = \hat{x}_{t+1} + V(\hat{x}_{t},\hat{v}_{t}, u_t, \theta)$;
   
   $loss \leftarrow loss + \|\hat{x}_{t+2} - x_{t+2}\|_2$;
   
   $\mu_{f} \leftarrow \mu_{f} + \alpha_{\textrm{rate}} (\hat{x}_{t+2} - x_{t+2});$
   
  $\mathcal{M} \leftarrow \mathcal{M} + \sqrt{\alpha_{\textrm{rate}}} (\hat{x}_{t+2} - x_{t+2});$

}
}
\caption{Learning Mechanical Models with Differentiable Physics Simulations}
\label{algo}
\end{algorithm}
\vspace{-0.5cm}
