# Role of Uncertainty in Anticipatory Trajectory Prediction for a Ping-Pong
Playing Robot

Nima Rahmanian
University of California, Berkeley
<EMAIL_ADDRESS>Michael Gupta
University of California, Berkeley
<EMAIL_ADDRESS>Renzo Soatto
University of California, Berkeley
<EMAIL_ADDRESS>Srisai Nachuri
University of California, Berkeley
<EMAIL_ADDRESS>Michael Psenka
University of California, Berkeley
<EMAIL_ADDRESS>Yi Ma
University of California, Berkeley
<EMAIL_ADDRESS>S. Shankar Sastry
University of California, Berkeley
<EMAIL_ADDRESS>
###### Abstract

Robotic interaction in fast-paced environments presents a substantial
challenge, particularly in tasks requiring the prediction of dynamic, non-
stationary objects for timely and accurate responses. An example of such a
task is ping-pong, where the physical limitations of a robot may prevent it
from reaching its goal in the time it takes the ball to cross the table. The
scene of a ping-pong match contains rich visual information of a player’s
movement that can allow future game state prediction, with varying degrees of
uncertainty. To this aim, we present a visual modeling, prediction, and
control system to inform a ping-pong playing robot utilizing visual model
uncertainty to allow earlier motion of the robot throughout the game. We
present demonstrations and metrics in simulation to show the benefit of
incorporating model uncertainty, the limitations of current standard model
uncertainty estimators, and the need for more verifiable model uncertainty
estimation. Our code is publicly available.

##  1 Introduction

Ping-pong robotics offers a rich testbed for algorithmic strategies in highly
dynamical games with competitive adversaries. Ping-pong has been a challenging
domain of AI and robotics for almost half a century [2], as we still do not
have robots able to beat ping-pong masters like we have for board games such
as Chess or Go [19]. There are many visual aspects of the ping-pong setting –
an indoor setting played by two players who occupy non-overlapping regions of
space with sharp colors contrasting different objects – which allows for
easier visual analysis. However, visual modeling and control remains a
difficult challenge due to the highly dynamic game state and fine visual
details that determine the outcome of a player’s hit. As a result, many of
recent advancements in ping-pong robotics have been reinforcement or deep
learning focused [11, 17, 9, 7, 22]. These techniques enable robots to improve
their skills through practice, much like a human player. However, despite
these technological strides, ping-pong robots still face notable limitations,
particularly when playing against human opponents who employ diverse and
adversarial strategies. Winning a point in ping-pong is not just about
reacting to the ball; it involves strategic planning throughout the full game,
adapting to the opponent’s play style, and exploiting their weaknesses. While
work has been done on anticipatory planning before the robot’s opponent hits
the ball [21], such work and frameworks currently do not return confidence
measures to inform a controller how much it should rely on a prediction.

Uncertainty estimation of neural models is a widely studied area [10], and
reliable uncertainty estimation is a cornerstone of neuro-symbolic computing
and interpretable deep learning [18, 20]. Uncertainty estimation is
practically crucial for advancing high-speed robotics, where computations and
predictions must be made as early and frequently as possible in order to give
a robotic controller enough time to reach the intended target. Scaling
controller speed based on predicted uncertainty of the visual model then gives
a concrete, measurable way to determine the effectiveness of an uncertainty
estimation method. Further, we see from results presented in this paper that
_reliable_ model uncertainty estimation is crucial to see true performance
improvement, as many standard model uncertainty estimators over-estimate
uncertainty and thus over-restrict controller movement. Using ping-pong
controller performance as a concrete measure for model uncertainty estimation
performance, we demonstrate that common state of the art uncertainty
quantification methods fail to capture the true uncertainties in ping-pong
ball trajectory prediction.

We begin by highlighting related work, both in ping-pong robotics and
uncertainty estimation of deep neural networks. We then introduce our
perception system and testing framework in a ping-pong playing environment,
and present results and ablations of the performance of various uncertainty
estimators in this environment.

###  1.1 Related work

We now give an overview of previous work in ping-pong robotics and model
uncertainty estimation. While ping-pong robotics has a long history [2], there
has been a more recent surge in data-driven methods for controlling a ping-
pong robot [11, 17, 9, 7]. Below, we cover explored methodologies in recent
years, which emphasize data-driven methods.

End to end learning. A number of works have implemented a model-free
reinforcement learning approach to ping-pong robotics, using very little
domain knowledge of the game of ping-pong itself [9, 5, 23, 7]. While such
approaches have seen much modern success, they typically incur a trade-off in
data and sample efficiency.

Trajectory prediction. A common use of domain information for ping-pong is
through trajectory prediction [22, 21]. Even after the opponent hits the ball,
ping-pong ball trajectories have irregularities due to spin, the Magnus
effect, and air friction, requiring more sophisticated methods than a simple
quadratic extrapolation. Thus, data-driven models have been used to fit such
trajectories [12]. However, the current body of work is restricted to specific
settings, and uncertainties in prediction are not integrated into a control
scheme.

Uncertainty estimation (or _uncertainty quantification_). Uncertainty
estimation of neural network outputs has been a long-standing problem spanning
various domains [10, 1, 13]. A number of challenges with uncertainty
quantification, including sensitivity to domain shifts and routinely over-
estimating certainty, along with several methods to overcome these challenges,
are outlined in [10]. Two dominant methodologies are _ensembling methods_ [15,
8, 20], where a collection of models is trained and uncertainty is computed
between the separate models, and _conformal prediction_ [16, 3], where a
series of statistical tests are performed on a model as a “black box” (only
input to output behavior is analyzed). However, uncertainty quantification is
relatively unexplored in ping-pong robotics, which offers a concrete,
measurable environment to develop, test, and utilize various uncertainty
quantification methods.

##  2 Data-Driven anticipatory prediction

We now describe the framework and evaluation procedure for our uncertainty-
aware ping-pong controller. For all later discussions, we adopt the following
naming conventions: the opponent is centered on the positive $y$-axis side of
the table, the _pre-hit_ and _post-hit_ time intervals refer to the time
before and after the opponent hits the ball. The post-hit time interval is
further split into the _pre-bounce_ and _post-bounce_ time intervals, and the
_strike point_ $s$ is defined as the $x$ and $z$ coordinates of the ball when
it crosses the back of the table at $y=-140$ cm. Our ping-pong table has
dimensions (152.5 x 274) cm, and we center the spatial frame on the table as
shown in Figure 2 with the $x$-axis along the width of the table (blue), the
$y$-axis along the length (green).

The framework uses significant prior information of ping-pong, as we describe
further below, in order to allow meaningful and more interpretable results in
a lower data regime.

###  2.1 Problem formulation and Background

Figure 1: 3D output of pose and ball triangulation.

We cast the anticipatory prediction problem as a classical supervised learning
task. We predict the ball’s post-hit trajectory using a time series of states
leading up to the hit, which includes the concatenation of $1)$ the opponent’s
$3$-dimensional, $8$-joint human pose skeleton, $2)$ the paddle’s pose in
$SE(3)$, and $3)$ the ball’s $3$-dimensional position, all stacked in a
$\mathbb{R}^{39}$ vector. This is visualized in Figure 1. We make the first
anticipatory prediction $100$ms before the ball is hit, and we continue to
update predictions until the ball is hit by the player. Our model learns to
anticipate the player’s intent and inform a controller sufficiently before the
ball it hit to enhance the robot’s game playing capabilities. A reliable
anticipatory post-hit trajectory estimate enables the robot to build momentum
towards the strike point and later hands controls off to a downstream
algorithm, such as a visual servoing algorithm, to steer the end effector
after the ball is hit using trajectory updates.

Figure 2: Spatial frame defined at the table center.

###  2.2 Anticipatory model objective

Any given call of the anticipatory model takes a time series of $L$ states
$\mathbf{X}\in\mathbb{R}^{L\times 39}$ as input.

Since we need to pass the final strike point to the controller, the obvious
solution is to predict $s$ from $\mathbf{X}$. However, this is a difficult
task because of the long prediction horizon: given a set of states, the model
needs to predict the ball position for a state many frames in the future. In
order to reduce the horizon, we instead predict a parametrization of the
ball’s post-hit trajectory, starting _immediately_ after the contact. We
observed that modeling the post-hit trajectory as two distinct, connected
curves better captures complex post-bounce ball trajectories which arise due
to spin. To simplify our anticipatory prediction problem, we elect not to
model $z$ behavior, instead focusing on the ball’s piecewise linear trajectory
on the $xy$ plane: since the space of strike points vary far more in the $x$
direction than the $z$ direction, manipulator arms are better off prioritizing
strike point extremities on the $x$-axis rather than $z$-axis.

As such, the ball’s path over the $x$ axis as a function of $y$ can be
parametrized with $3$ parameters: pre-bounce and post-bounce slopes $a_{1}$
and $a_{2}$ and an intercept term $b$, as follows:

$\displaystyle x_{\text{pre}}(y)$ $\displaystyle=a_{1}y+b\text{ for }y>=0,$
(1) $\displaystyle x_{\text{post}}(y)$ $\displaystyle=a_{2}y+b\text{ for
}y<0.$ (2)

We train several recurrent neural network structures on the following loss:

$\displaystyle\begin{split}L(a_{1},a_{2},b;w)&=\sum_{y\in\\{140,\ldots,-10\\}}|x_{pre}(y)-\hat{x}_{pre}(y;w)|\\\
&+\sum_{y\in\\{-70,\ldots,-140\\}}|x_{post}(y)-\hat{x}_{post}(y;w)|,\end{split}$
(3)

where the parameters of $\hat{x}_{pre}$ and $\hat{x}_{post}$ are jointly
learned by a recurrent neural network with weights $w$. The pre-bounce term
helps with the reduction of the prediction horizon, while the post-bounce term
encourages our model to make better longer-horizon predictions. The ranges
were chosen by observing that most bounces occur for $y\in[-70,-10]$. This
loss term offers a simple discretized estimate of the total area between the
ground truth and estimated linear trajectories on the $xy$ plane.

###  2.3 Model outputs with uncertainty for control

Though incorporating anticipatory prediction alone to controllers is
beneficial in high speed robotics, both demonstrated in previous work [21] and
Table 3, past work notably lacks uncertainty quantification associated with
the anticipatory prediction, an addition that improves both interpretability
and performance.

Exploration of uncertainty/confidence quantification is still an open problem,
with many proposed solutions that work to varying degrees. To maximize
compatibility, we utilize confidence (higher is better) proxies associated
with anticipatory model predictions by enforcing that, when travelling towards
the predicted strike point, the arm moves at a maximum velocity proportional
to the associated confidence.

In an attempt to determine confidences per model output, we explored two of
the most prominent techniques used for uncertainty quantification: observing
the variance of an ensemble of models, and computing confidence intervals
using conformal prediction. As a baseline, we trained a k-NN [6] model to
predict mean strike point errors as a function of the inputs.

We also introduce a simple, time-of-inference based confidence measure. Based
on the hypothesis that predicting results earlier in a longer time horizon
results in less confident predictions, combined with empirical observations
that error scales linearly with time-to-hit, we assign a confidence inversely
proportional to the time-to-hit.

###  2.4 Simulation for evaluation

Standard evaluation metrics seen in other literature [12] that evaluate the
mean squared trajectory prediction error, though useful, present an incomplete
picture of the effectiveness of our anticipatory prediction model, which is
designed to enhance a robot’s ability to play high-speed ping-pong.

For example, for a ground truth strike position $x_{strike}=25$, predicting
$x_{strike}=-25$ is far worse than predicting $x_{strike}=75$. The former case
directs the robot’s momentum in the wrong direction, whereas the latter case
builds the robot’s momentum in the correct direction.

Instead, we introduce an end-to-end simulation with an LBR iiwa 14 R820 KUKA
robot mounted on top of an omnidirectional Ridgeback. This configuration
utilizes seven revolute joints from KUKA, two prismatic joints from the
Ridgeback, and a paddle mounted on the KUKA’s end effector. In an attempt to
model real-world hardware limitations, the simulator imposes operational
position, velocity, and acceleration limits for all joints as well as a 100ms
communication latency with the hardware. Introducing inertia into the robot
model ensures that our simulation penalizes an agent that incorrectly
anticipates the initial movement direction. We restrict the end-effector’s
reachable workspace to the $xz$ plane centered at $y=-140$ with the paddle’s
normal vector pointing towards the opponent side.

Our simulation operates in the same discrete timesteps as the pre-recorded
ping-pong segments (recorded at 100hz). To simplify further discussion, we
define $t$ as the timestep in a single pre-recorded ping-pong segment. The
opponent strikes the ball at $t=0$, negative $t$ corresponds to pre-hit
timesteps, and positive $t$ corresponds to post-hit timesteps. To simulate a
discretized continuous jointspace controller and to account for communication
latencies, the robot is limited to updating its goal configurations once every
ten timesteps (10Hz).

In the absence of an anticipatory prediction model, the robot solely estimates
the strike point using direct trajectory estimation, a post-hit ball
trajectory estimation method which fits curves to observed ball positions. In
this case, the robot first estimates the strike point at timestep $t=10$ and
passes this information to the visual servoing controller. In contrast, an
anticipatory prediction model provides the robot with strike point estimations
as early as timestep $t=-10$ (before the ball is hit). We demonstrate that
informing the controller with such pre-hit estimates offers significant
advantages in high-speed games. In this case, once the game state reaches 10
timesteps post-hit, the controller switches to direct trajectory estimation to
guide the visual servoing algorithm. Details on the control law can be found
in Appendix B.

##  3 Experiments and results

We now detail the paper’s main results. We certify both that our trained model
can reliably predict ball trajectories from various points back in time, with
varying degrees of uncertainty, and that current model uncertainty estimators
do not accurately estimate the model’s true expected error.

###  3.1 Experimental Setup

Data collection:  We have extracted over 2000 hits from four hours of ping-
pong-playing footage filmed on four RGB cameras sampling at 100Hz and eight
OptiTrack InfraRed (IR) Cameras sampling at or above 120Hz. Ball positions in
each RGB image were determined using standard color-based segmentation
(algorithm details in Appendix A), and player joint positions were determined
using OpenPose [14]. Both were then embedded in 3D space using standard
calibration and triangulation tools from Multiview Geometry [4]. The paddle
pose was identified using IR balls attached to the paddles, which we found
resulted in higher fidelity measurements than using planar homography with the
RGB images, which was much more volatile and sensitive to motion blurring. We
utilized the OptiTrack software’s automatic calibration and triangulation
software, both of which depend on similar Multiview Geometry machinery as our
RGB camera calibration and triangulation.

We also extensively filtered and curated our hits to yield our final dataset.
We remove any invalid hits, including but not limited to segments where balls
don’t properly land on the other side of the table (e.g. hitting the net,
double bounces, etc.). To counteract the effect of noisy measurements, we also
low-pass filter the ball position and human pose signals, which we found
greatly improved ground truth curve fitting. It is important to mention that
our dataset contains an uneven distribution of hits towards the left, center,
and right sides of the table due our group’s playing habits.

Anticipatory model training and architecture:  We train on an 80-20 train-test
split. More details of our training can be found in Appendix C. Our
experimental network uses an RNN block whose outputs are fed into an MLP; The
RNN hidden size is 100, we use 3 layers, and dropout probability $p_{dropout}$
= 0.15. The MLP has 1 hidden layer with size 600. The final output size of our
network is $\mathbf{Y}\in\mathbb{R}^{30\times 3}$, where the $i$-th row in
$\mathbf{Y}$ represents a prediction of the aforementioned 3 trajectory
parameters in Section 2.2 at $i$ frames before the ball is hit. In this way,
predictions can be generated for any timestep between 30 frames before the
ball is hit and 0 frames before the ball is hit.

###  3.2 Uncertainty estimation

Our exploration of uncertainty estimation methods indicated that accurately
quantifying confidence of our anticipatory prediction method for each
prediction is a very difficult task that the most common existing measures do
not solve. A good confidence measure should have a strong correlation with the
residual of its corresponding prediction, a trend that is notably absent
across our k-NN error predictions (Fig 3a), ensemble standard deviations (Fig
3b), and the width of the conformal prediction confidence intervals (Fig 3c).
An interesting observation is that our k-NN error predictions and our ensemble
standard deviations are clustered around $25$, which is approximately equal to
the average strike point error of our model. Conformal prediction, on the
other hand, is vastly over-conservative, due to its mathematical guarantees.
Given our table’s width is around $150$cm, confidence intervals roughly of
width $130$cm are not informative.

Given that predicting uncertainty on a per-hit basis seems infeasible, another
option is predicting uncertainty as a function of the time-to-hit. This is
quite trivial, since the relationship between the time-to-hit and the strike
point error is almost perfectly linear (Fig 3d). As we make anticipatory
predictions at various points in time, this time-to-hit is still more useful
than simply quantifying the overall uncertainty of the model.

Figure 3: a, b, c: Samples of model error versus estimated model uncertainty
for predictions made at $t=0$. For a verifiable or predictive measure of model
uncertainty, there should be a strong direct correlation between the two. d:
Median prediction error as a function of prehit timestep.

###  3.3 Results on Simulation

Frame | 10 | 1
---|---|---
Right | 38.15 | 28.12
Center | 30.62 | 18.21
Left | 18.73 | 13.01
All | 26.27 | 16.65
Table 1: Median strike point error reduction over frames before the hit (in centimeters). | Total | # hit | End dist. to goal
---|---|---|---
Right | 101 | 60 | 10.13 $\pm$ 4.38 (cm)
Center | 81 | 60 | 6.26 $\pm$ 1.93 (cm)
Left | 41 | 24 | 12.82 $\pm$ 7.31 (cm)
All | 223 | 144 | 9.22 $\pm$ 4.615 (cm)
Table 2: $\alpha_{1}=0.0,\alpha_{2}=0.0$: Performance of baseline visual servoing controller. End distance to goal reported as mean $\pm$ 0.5 standard deviations.  | Total | # hit | End dist. to goal
---|---|---|---
Right | 101 | 67 | 8.33 $\pm$ 3.85 (cm)
Center | 81 | 59 | 5.9 $\pm$ 1.87 (cm)
Left | 41 | 20 | 13.63 $\pm$ 7.41 (cm)
All | 223 | 146 | 8.42 $\pm$ 4.46 (cm)
Table 3: $\alpha_{1}=1.0,\alpha_{2}=1.0$: Performance of basic anticipatory controller. End distance to goal reported as mean $\pm$ 0.5 standard deviations.  | Total | # hit | End dist. to goal
---|---|---|---
Right | 101 | 70 | 8.35 $\pm$ 3.72 (cm)
Center | 81 | 59 | 5.84 $\pm$ 1.78 (cm)
Left | 41 | 22 | 12.5 $\pm$ 7.18 (cm)
All | 223 | 151 | 8.2 $\pm$ 4.27 (cm)
Table 4: $\alpha_{1}=0.6,\alpha_{2}=1.0$: Performance of uncertainty-aware
anticipatory controller. End distance to goal reported as mean $\pm$ 0.5
standard deviations.

While our recorded hits are sampled from both sides of the table, for
simplicity, we arrange all hits such that the strike points are on the
$-y$-axis side of the table. We define the ping-pong table’s left, center, and
right regions as all points with $x\in[-\infty,-25]$, $x\in[-25,25]$, and
$x\in[25,\infty]$, respectively. We define $\alpha_{1},\alpha_{2}\in[0,1]$ as
the ratio of the commanded end effector velocity over the maximum allowable
end effector velocity of the robot for predictions made at $t=-10$ and $t=0$,
respectively. As a sanity check, we computed the RMSE in strike point (Table
1) and verified that predictions made closer to the time the player hits the
ball have a smaller median strike point error. Though these values inform us
about the model’s predictive capabilities, the anticipatory planner relies
most on the model’s ability to guide the robot arm in the correct general
direction.

We provide two main metrics, one of which is the number of successful hits by
the paddle surface at the strike point. We define _end distance to goal_ as
the distance from the center of the paddle to ball when the ball crosses the
strike point. By this definition, a successful hit may still have a nonzero
_end distance to goal_. Comparing the change in performance from the visual
servoing baseline and the basic anticipatory controller in Table 2 and Table
3, we observe that while the average and standard deviation of _end distance
to goal_ decreases for center and right hits, these metrics _increase_ for
left hits. In these cases, we observed that the model incorrectly predicted
the goal to have a positive $x$ value that lands in the center region. This
suggests that when the model is uncertain about the post-hit trajectory, it
predicts strike points towards the center-right table region (likely due to
the right skew in the overall dataset). This in turn prompts the robot to
build momentum to the _right_. We also observed that the model generally
predicts the correct side of the table when its strike point predictions lie
in the left or right regions. With these observations in mind, we designed our
uncertainty-aware controller to only make anticipatory movements when the
strike point predictions lie outside of the center region.

We determined the value of $\alpha_{1}$ and $\alpha_{2}$ by running a
hyperparameter sweep over a calibration set and optimizing for number of
successful hits. As seen in the performance increases from Table 3 to Table 4,
this uncertainty-aware design choice boosted the controller’s ability to
return all types of hits. While the shown improvement is marginal, the
reported improvement given even such a simplistic uncertainty estimator
highlights the value of reliable uncertainty estimators in their direct role
on enhancing ping-pong playing ability.

##  4 Discussion

The most notable reported result is the lack of informative uncertainty
prediction for standard model uncertainty estimators like variance of ensemble
predictions and conformal prediction. We firstly discuss the reliability of
these results, which is dependent on the trained model itself. While our model
has not been engineered to a state-of-the-art performance level compared to
heavily trained models on large datasets, our model fits match expected trends
in uncertainty well enough (e.g. uncertainty increases as prediction inputs
move farther back in time) that the lack of correlation presented in Figure 3
is significant.

We argue that these results call for more reliable uncertainty awareness in
_both directions_ : the uncertainty measure should both be high enough when
the model is uncertain, but low enough when the model is confident. Such
accuracy, we argue, requires further interpretability and knowledge about a
model’s interaction with data. In exploring such interpretable uncertainty
quantification measures, the relative simplicity of our model (simple RNN,
using interpretable representations of the ping-pong game state) becomes an
asset for reliably determining factors and potential avenues for the
development of accurate and reliable uncertainty estimators.

##  5 Conclusion and future work

Ping pong robotics remains an interesting application for modern visual
models, as the high speed of the game requires inferences to be made well in
advance, using more general cues like human pose motion, before the state of
the ball is well defined. Additionally, due to the high speed of the game,
reliable uncertainty prediction becomes crucial in order to inform how slow or
fast a downstream controller should move, and the performance of this
controller becomes a concrete metric for evaluating the reliability of the
model uncertainty estimator. In the particular case of modeling the trajectory
of the ping-pong ball using human pose motion, we find that standard model
uncertainty quantification methods fail to reliably predict the true
uncertainty of the prediction model, rendering them unhelpful to a robotic
controller.

We believe that performance metrics for high-speed uncertain robotics
applications, such as ping-pong, offer an interesting benchmark for future
work in model uncertainty quantification for visual models. As the game has
been heavily studied both in the context of classical fully model-based
robotics and modern model-free reinforcement learning, ping-pong proves to be
an excellent environment to explore model uncertainty quantification in a more
interpretable manner, hopefully leading to more reliable and accurate model
uncertainty estimators for more general applications.

## References

  * Abdar et al. [2021] Moloud Abdar, Farhad Pourpanah, Sadiq Hussain, Dana Rezazadegan, Li Liu, Mohammad Ghavamzadeh, Paul Fieguth, Xiaochun Cao, Abbas Khosravi, U Rajendra Acharya, et al.  A review of uncertainty quantification in deep learning: Techniques, applications and challenges.  _Information fusion_ , 76:243–297, 2021.
  * Anderson [1988] Russell L Anderson.  _A robot ping-pong player: experiment in real-time intelligent control_.  MIT press, 1988.
  * Angelopoulos et al. [2020] Anastasios Angelopoulos, Stephen Bates, Jitendra Malik, and Michael I Jordan.  Uncertainty sets for image classifiers using conformal prediction.  _arXiv preprint arXiv:2009.14193_ , 2020.
  * Bradski [2000] Gary Bradski.  The opencv library.  _Dr. Dobb’s Journal: Software Tools for the Professional Programmer_ , 25(11):120–123, 2000.
  * Büchler et al. [2022] Dieter Büchler, Simon Guist, Roberto Calandra, Vincent Berenz, Bernhard Schölkopf, and Jan Peters.  Learning to play table tennis from scratch using muscular robots.  _IEEE Transactions on Robotics_ , 38(6):3850–3860, 2022.
  * Cover and Hart [1967] Thomas Cover and Peter Hart.  Nearest neighbor pattern classification.  _IEEE transactions on information theory_ , 13(1):21–27, 1967.
  * Ding et al. [2022] Tianli Ding, Laura Graesser, Saminda Wishwajith Abeyruwan, David B D’Ambrosio, Anish Shankar, Pierre Sermanet, Pannag Raghunath Sanketi, and Corey Harrison Lynch.  Goalseye: Learning high speed precision table tennis on a physical robot.  2022\.
  * Dolezal et al. [2022] James M Dolezal, Andrew Srisuwananukorn, Dmitry Karpeyev, Siddhi Ramesh, Sara Kochanny, Brittany Cody, Aaron S Mansfield, Sagar Rakshit, Radhika Bansal, Melanie C Bois, et al.  Uncertainty-informed deep learning models enable high-confidence predictions for digital histopathology.  _Nature communications_ , 13(1):6572, 2022.
  * Gao et al. [2020] Wenbo Gao, Laura Graesser, Krzysztof Choromanski, Xingyou Song, Nevena Lazic, Pannag Sanketi, Vikas Sindhwani, and Navdeep Jaitly.  Robotic table tennis with model-free reinforcement learning.  In _2020 IEEE/RSJ International Conference on Intelligent Robots and Systems (IROS)_ , pages 5556–5563. IEEE, 2020.
  * Gawlikowski et al. [2023] Jakob Gawlikowski, Cedrique Rovile Njieutcheu Tassi, Mohsin Ali, Jongseok Lee, Matthias Humt, Jianxiang Feng, Anna Kruspe, Rudolph Triebel, Peter Jung, Ribana Roscher, et al.  A survey of uncertainty in deep neural networks.  _Artificial Intelligence Review_ , pages 1–77, 2023.
  * Huang et al. [2015] Yanlong Huang, Bernhard Schölkopf, and Jan Peters.  Learning optimal striking points for a ping-pong playing robot.  In _2015 IEEE/RSJ International Conference on Intelligent Robots and Systems (IROS)_ , pages 4587–4592. IEEE, 2015.
  * Lin et al. [2020] Hsien-I Lin, Zhangguo Yu, and Yi-Chen Huang.  Ball tracking and trajectory prediction for table-tennis robots.  _Sensors_ , 20(2):333, 2020.
  * Mena et al. [2021] José Mena, Oriol Pujol, and Jordi Vitria.  A survey on uncertainty estimation in deep learning classification systems from a bayesian perspective.  _ACM Computing Surveys (CSUR)_ , 54(9):1–35, 2021.
  * Osokin [2018] Daniil Osokin.  Real-time 2d multi-person pose estimation on cpu: Lightweight openpose.  _arXiv preprint arXiv:1811.12004_ , 2018.
  * Rahaman et al. [2021] Rahul Rahaman et al.  Uncertainty quantification and deep ensembles.  _Advances in Neural Information Processing Systems_ , 34:20063–20075, 2021.
  * Romano et al. [2020] Yaniv Romano, Matteo Sesia, and Emmanuel Candes.  Classification with valid and adaptive coverage.  _Advances in Neural Information Processing Systems_ , 33:3581–3591, 2020.
  * Ruggiero et al. [2018] Fabio Ruggiero, Vincenzo Lippiello, and Bruno Siciliano.  Nonprehensile dynamic manipulation: A survey.  _IEEE Robotics and Automation Letters_ , 3(3):1711–1718, 2018.
  * Seshia et al. [2022] Sanjit A Seshia, Dorsa Sadigh, and S Shankar Sastry.  Toward verified artificial intelligence.  _Communications of the ACM_ , 65(7):46–55, 2022.
  * Silver et al. [2017] David Silver, Julian Schrittwieser, Karen Simonyan, Ioannis Antonoglou, Aja Huang, Arthur Guez, Thomas Hubert, Lucas Baker, Matthew Lai, Adrian Bolton, et al.  Mastering the game of go without human knowledge.  _nature_ , 550(7676):354–359, 2017.
  * Torfah et al. [2023] Hazem Torfah, Aniruddha Joshi, Shetal Shah, S Akshay, Supratik Chakraborty, and Sanjit A Seshia.  Learning monitor ensembles for operational design domains.  In _International Conference on Runtime Verification_ , pages 271–290. Springer, 2023.
  * Wang et al. [2017] Zhikun Wang, Abdeslam Boularias, Katharina Mülling, Bernhard Schölkopf, and Jan Peters.  Anticipatory action selection for human–robot table tennis.  _Artificial Intelligence_ , 247:399–414, 2017.
  * Wu and Koike [2020] Erwin Wu and Hideki Koike.  Futurepong: Real-time table tennis trajectory forecasting using pose prediction network.  In _Extended Abstracts of the 2020 CHI Conference on Human Factors in Computing Systems_ , pages 1–8, 2020.
  * Zhu et al. [2018] Yifeng Zhu, Yongsheng Zhao, Lisen Jin, Jun Wu, and Rong Xiong.  Towards high level skill learning: Learn to return table tennis ball using monte-carlo based policy gradient method.  In _2018 IEEE international conference on real-time computing and robotics (RCAR)_ , pages 34–41. IEEE, 2018.

##  Appendix A Lab Setup

###  A.1 Hardware

Our sensor suite includes four RGB Daheng Imaging MER2 - 160-227U3C cameras
(100hz) and eight OptiTrack cameras coordinated with motion capture software
(at or above 120hz). We use green screen backdrops to remove orange-like
objects in the background from the RGB video feed. Figure 4 illustrates the
infrared marker placement, used by the OptiTrack motion capture system, to
capture the poses of the two ping-pong paddles.

Figure 4: Infrared marker placement on ping-pong paddle.

###  A.2 Triangulation

3D locations for both ball and joint locations are found using a standard
direct linear transformation triangulation technique. For each camera
correspondence (at least two needed), we set up the equation $U=\alpha PX$
where $U$ is the 2D pixel coordinate, $\alpha$ is a normalizing constant for
defining the world scale, $P$ is the camera’s corresponding projection matrix,
and $X$ is the unknown 3D spatial coordinate. We stack the equations and solve
for $X$ using the Direct Linear Transformation.

###  A.3 Ball Detection

Ball detection from video frames is achieved through a series of masks that
isolate the unique orange color of the ping-pong ball. This masking can be
done especially reliably and quickly if a ball is detected in a previous
frame; In this case, we only sample in the 200 pixels surrounding that
previous position. With this mask, we generate contours, and find the center
of the largest contour. A visualization of our ball detection technique is
shown in Figure 5. An example of a full trajectory found with the ball
detection and triangulation systems is shown in Figure 6.

Figure 5: Isolation of ping-pong ball in 2D using color filtering. The blue
circle represents the search area based on the last ball position, and the red
circle represents the contour found through masking. Figure 6: Example
trajectory found through color filtering and triangulation. The ball is going
away from the perspective of the viewer.

###  A.4 Human and Paddle Pose Estimation

For pose estimation, we use OpenPose with no modifications [14]. With one
Nvidia GeForce RTX 4090 GPU, it is capable of real time (60Hz) pose
estimation. An example 2D pose estimation using this software is shown in Fig.
7.

Figure 7: 2D output of Openpose.

Given two or more views of 2D human poses and ping-pong ball positions, we
calculate the 3D human poses and ball positions using the aforementioned
triangulation system. The OptiTrack motion capture system provides us with the
$SE(3)$ paddle poses. The 3D positions of the ball, bodies, and the paddle
orientations constitute one frame of input in our dataset. A visual of this
fully triangulated frame is shown in Figure 1.

###  A.5 Segmentation Process

We define a _segment_ as the series of frames starting when the ball crosses
the net towards one player and ending when the other player strikes the ball.
A segment encapsulates a player’s response to the incoming ball and the
associated response. We exclude segments with the following properties in our
dataset:

  1. 1.

Sufficiently many frames with undetected or misdetected human joints in the
pre-hit segment.

  2. 2.

Sufficiently many frames with undetected paddle poses in the pre-hit segment.

  3. 3.

The post-hit ball trajectory does not bounce on the correct side of the table.

For segments which do enter the dataset, the ball trajectory and human pose
estimate signals are low-pass filtered. We compiled a dataset of 2,226
segments.

##  Appendix B Simulation

###  B.1 Robot Mechanical Design

To provide the clearest picture of the effectiveness our model, we base our
simulation on the realistic setup of an LBR iiwa 14 R820 KUKA robot mounted on
top of an omnidirectional Ridgeback. The KUKA, in accordance with real model
specifications 111https://www.reeco.co.uk/wp-content/uploads/2020/05/KUKA-LBR-
iiwa-technical-data.pdf, is represented as 7 revolute joints. The
omnidirectional Ridgeback 222https://clearpathrobotics.com/ridgeback-indoor-
robot-platform/, as an appropriate simplication of planar motion, is
represented by 2 prismatic joints along the $xy$ plane. We enforce physical
constraints provided by the robot technical specifications for joint position,
velocity, and torque.

We denote the 7 revolute joints of the KUKA ordered $A1-A7$ and the 2
prismatic joints of the Ridgeback as $X1$ and $Y1$. Range of motion (ROM),
torque, and velocity constraints are provided for the KUKA while only velocity
constraints are provided for the Ridgeback.

Axis | ROM | Max Torque | Max Velocity
---|---|---|---
X1 | — | — | 1.1 $m/s$
Y1 | — | — | 1.1 $m/s$
A1 | $\pm 170\degree$ | 320 $Nm$ | $85\degree/s$
A2 | $\pm 120\degree$ | 320 $Nm$ | $85\degree/s$
A3 | $\pm 170\degree$ | 176 $Nm$ | $100\degree/s$
A4 | $\pm 120\degree$ | 176 $Nm$ | $75\degree/s$
A5 | $\pm 170\degree$ | 110 $Nm$ | $130\degree/s$
A6 | $\pm 120\degree$ | 40 $Nm$ | $135\degree/s$
A7 | $\pm 175\degree$ | 40 $Nm$ | $135\degree/s$
Table 5: Provided joint limits of KUKA and Ridgeback

For workspace controllability, we impose additional constraints on the
Ridgeback and extrapolate acceleration constraints for the KUKA from torque.
The Ridgeback is constrainted to move along the plane within a square of area
$4\text{ }m^{2}$, and capped at a maximum acceleration of $15\text{ }m/s^{2}$.
This acceleration was chosen empirically through documentation of other
similar planar robots.

KUKA acceleration constraints are derived from torque constraints by
considering the mass distribution of the 8 effective links separated by 7
joints and gravitational torque resisting desired angular acceleration
direction. Since both link mass distribution and gravitational torque vary
based on the instantaneous configurations of the joints, we limit acceleration
by the worst case scenario, in which mass is distributed furthest from the
axis of rotation and the gravitational torque opposing desired angular
acceleration is of its highest magnitude. For instance, a joint rotating along
the y-axis, would accelerate the slowest when its target links are all
orientated perpendicular to the z-axis and parallel to the x-axis. This
acceleration can be reasonably applied with the max torque available for all
configurations, and a controller can realistically command joint velocities to
obey these limits. Acceleration constraints are applied equally for all
velocity changes including braking and reversing direction.

Table 6 showcases the effective ROM, acceleration, and velocity constraints of
the KUKA-Ridgeback setup. Note that while effective accelerations for joints
are high, low velocity limits do not allow a sustained acceleration over a
long time frame.

Axis | ROM | Max Acceleration | Max Velocity
---|---|---|---
X1 |  $\pm 1$ $m$ | 15 $m/s^{2}$ | 1.1 $m/s$
Y1 |  $\pm 1$ $m$ | 15 $m/s^{2}$ | 1.1 $m/s$
A1 | $\pm 170\degree$ |  $3.69\mathrm{e}{3}$ $\degree/s^{2}$ | $85\degree/s$
A2 | $\pm 120\degree$ |  $3.47\mathrm{e}{3}$ $\degree/s^{2}$ | $85\degree/s$
A3 | $\pm 170\degree$ |  $7.42\mathrm{e}{3}$ $\degree/s^{2}$ | $100\degree/s$
A4 | $\pm 120\degree$ |  $1.37\mathrm{e}{4}$ $\degree/s^{2}$ | $75\degree/s$
A5 | $\pm 170\degree$ |  $3.79\mathrm{e}{4}$ $\degree/s^{2}$ | $130\degree/s$
A6 | $\pm 120\degree$ |  $3.81\mathrm{e}{5}$ $\degree/s^{2}$ | $135\degree/s$
A7 | $\pm 175\degree$ |  $5.72\mathrm{e}{5}$ $\degree/s^{2}$ | $135\degree/s$
Table 6: Effective joint limits of KUKA and Ridgeback

###  B.2 Workspace Controller

We model our simulated paddle as a 8 centimeter-radius circular plane
positioned at the KUKA end effector, with the paddle plane facing the
opponent. We control the paddle as programmed velocities and goal positions
over discrete timesteps, and thus our robot controller translates the desired
workspace velocity into jointspace velocities of the KUKA and Ridgeback joints
with the appropriate joint constraints applied while also incorporating
feedback of the error in position.

####  B.2.1 Workspace Control Law

First, we define our controller that maps joint velocities from paddle
velocity. Using the error in the positional configuration of the end effector
(paddle) and the desired workspace velocity, our controller implements a
closed-loop Cartesian control law in Section 1.2.3 333https://ucb-
ee106.github.io/106b-sp23site/assets/proj/proj1b.pdf. Incorporating feedback,
we aim for a workspace end effector velocity of $U^{s}$. As specified in the
aforementioned material, we use the spatial Jacobian of the current robot
configuration, $J(\theta)$ to find the minimum norm solution for joint
velocities, $\dot{\theta}$, through the following equation:

$\dot{\theta}=J^{\dagger}(\theta)U^{s},$ (4)

where $J^{\dagger}$ is the Moore-Penrose inverse of $J$. In order to account
for the discretization of workspace velocity control and to approximate signal
latency, we perform control steps in increments of 0.1 $s$. The joint
positions are discretely updated through the following equation:

$\theta_{t+1}=\theta_{t}+0.1\times\dot{\theta_{t}}.$ (5)

####  B.2.2 Trajectory and Enforcement of Joint Limits

We modify our joint position update law based on two criteria. First, we
enforce acceleration, velocity, and position constraints of the robot. Second,
we follow a naive linear trajectory and desire to move the robot by a
proportion $\alpha$, where $0\leq\alpha\leq 1.0$, of the maximum possible
joint speed. This second criterion allows for controllability in
correspondence with uncertainty.

First we enforce robot constraints. Given our control law computed
$\dot{\theta}_{t}$, we consider previous joint velocities, maximum joint
accelerations, and maximum joint speeds to find a $\beta$ where
$-1\leq\beta\leq 1$, such that $\dot{\theta}^{*}_{t}=\beta\dot{\theta}_{t}$
obeys velocity and acceleration constraints and scales the joint velocity to
still allow the end effector to move in the correct direction at maximum
possible joint speeds. To enforce positional constraints, we simply bound our
computed $\theta_{t+1}$ by the maximum and minimum positions, $\theta_{max}$
and $\theta_{min}$.

Given our maximal speed joint velocities $\dot{\theta}^{*}_{t}$, we further
scale this entity by $\alpha$, which is the desired proportion of the maximum
joint speed we want the robot to move with. The positional update law is thus
given by the following:

$\theta_{t+1}=\min\\{\max\\{\theta_{t}+0.1\times\alpha\beta\dot{\theta_{t}},\theta_{min}\\},\theta_{max}\\}.$
(6)

Figure 8: Animation of a frame during simulation. The ball trajectory observed
is in blue, and the forecasted trajectory is in green. Skeletons of the KUKA
(blue) and opponent (red) in their current positions are also represented.

###  B.3 Visual Servoing Algorithm and Goal State Updates

We control the robot end effector by estimating the strike point in its
trajectory in the $xz$ plane centered at $y$ = -140 with the paddle facing the
opponent side. We set the goal state to be the updated strike point, which
means the desired velocity vector points from the paddle’s current position
towards the goal state, and we define an $\alpha$ that represents the
proportion of the maximum joint speed at which the robot tracks the desired.
This $\alpha$ is always $1.0$ for visual servoing and varies for our different
pre-hit inference models.

We use the same visual servoing model for all experiments, and it always
starts at the same timestep after the hit regardless of pre-hit inference
models. We implement a simple visual servoing algorithm that estimates the
ball trajectory by interpolating 2 quadratic trajectories, a pre-bounce curve
and a post-bounce curve, from observed ball positions in real time. For
estimating post-bounce curves prior to any observed post-bounce ball
positions, we estimate the curve assuming an elastic collision upon bounce. In
correspondence with the 0.1 $s$ update frequency of the robot, given our ball
is tracked at 100 $hz$, we update the goal position of the ball every 10
frames.

##  Appendix C Model Selection, Hyperparameters, and Training

###  C.1 Model and Hyperparameter Selection

We considered standard Recurrent Neural Networks (RNNs), Long Short-term
Memory networks (LSTM), and Gated Recurrent Unit (GRU) networks. We chose
these recurrent-based architectures because they are capable of processing
variable length time series and can also output intermediate predictions at
any given point in the time series. For all three architectures, our model
included the recurrent network, followed by an MLP on the final hidden state.
Intermediate predictions are computed by applying the trained MLP on
intermediate hidden states.

For each architecture, we performed the following grid search over all
combinations of hyperparameters, evaluated using 5-fold cross validation. We
chose the model that performed best on average across the 5 folds,
irrespective of base model architecture.

Parameter | Values
---|---
Learning Rate | 1e-02, 1e-03, 1e-04
Hidden Size in Each Recurrent Layer | 100, 200, 400
Hidden Size in MLP | 400, 600, 800, 1200
Percent Dropout | 0.05, 0.1, 0.15
Number of Recurrent Layers | 2, 4, 8
Number of Hidden Layers in MLP | 3, 4, 5
Table 7: Hyperparameters in Grid Search

###  C.2 Training

We trained all networks using the Adam optimizer with weight decay with a
batch size of 500. We used all default AdamW hyperparameters from the built in
PyTorch library, except for learning rate, which we included in the
hyperparameter sweep. All models were trained for a maximum of 200 epochs,
with early stopping if the minimum validation loss did not decrease by more
than $0.01$ for $30$ epochs. The GPU used to train was an Nvidia GeForce GTX
$3090$ ($24$GB VRAM).

##  Appendix D Acknowledgements

We would like to express sincere gratitude to Gaurav Bhatnagar, (Chris) Wei
Xun Lai, Andrew Zhang, and Andrew Shen for their contributions to the ball
detector, OptiTrack system setup, data segmentation software, and learning
experiments, respectively. Their improvements to the data collection and
analysis pipeline were invaluable to the successful completion of this
research.


# Josephson diode effect in a ballistic single-channel nanowire

Julia S. Meyer  Manuel Houzet<EMAIL_ADDRESS>Univ.
Grenoble Alpes, CEA, Grenoble INP, IRIG, PHELIQS, 38000 Grenoble, France

###### Abstract

When time-reversal and inversion symmetry are broken, superconducting circuits
may exhibit a so-called diode effect, where the critical currents for opposite
directions of the current flow differ. In recent years, this effect has been
observed in a multitude of systems and the different physical ingredients that
may yield such an effect are well understood. On a microscopic level, the
interplay between spin-orbit coupling and a Zeeman field may give rise to a
diode effect in a single Josephson junction. However, so far there is no
analytical description of the effect within a simple model. Here we study a
single channel nanowire with Rashba spin-orbit coupling and subject to a
Zeeman field. We show that the different Fermi velocities and spin projections
of the two pseudo-spin bands lead to a diode effect. Simple analytical
expressions for the efficiency can be obtained in limiting cases.

††preprint: AIP/123-QED

> The so-called superconducting diode effect has attracted a lot of attention
> recently review ; review2 . In systems breaking inversion and time-reversal
> symmetry, the critical currents in opposite directions may be different.
> Experimentally this has been observed in a variety of bulk superconductors
> exp-bulk ; bulk_p1 ; bulk_p2 ; bulk_p3 ; bulk_p4 , as well as in circuits
> containing Josephson junctions exp-old ; exp-JJ1 ; exp-JJ2 ; JJ_p1 ; JJ_p2 ;
> JJ_p3 ; JJ_p4 ; sergey . One of the possible origins of the diode effect in
> Josephson junctions is the interplay between Rashba spin-orbit coupling and
> an external magnetic field multichannel1 ; multichannel2 . The diode effect
> is then linked to the so-called $\phi_{0}$-junction behavior JA1 ; JA2 ; JA3
> ; multichannel1 , where the current phase-relation acquires a field-tunable
> phase shift and an anomalous supercurrent flows in the absence of a phase
> bias. The simplest current-phase relation yielding these effects is
> $I=I_{c1}\sin(\phi-\phi_{01})$. By contrast, the diode effect requires a
> current-phase relation with more than one harmonic. The simplest case is
> provided by the presence of a second harmonic,
> $I_{c2}\sin(2\phi-\phi_{02})$, with a phase shift $\phi_{02}\neq
> 2\phi_{01}$. While such a phenomenological current-phase relation has been
> used in the literature exp-JJ2 ; Hu ; etamax , a microscopic derivation has
> been missing. Here we show that, in ballistic single-channel Josephson
> junctions, such a current-phase relation can indeed be realized, both in
> short and long junctions at finite temperature, thus allowing one to
> characterize their diode efficiency. In this paper, we will concentrate on
> the cases where analytical results are available.

Figure 1:  Linearized band structure in the vicinity of the Fermi level. The
$j=+$ band shown in blue and the $j=-$ band shown in red have different Fermi
velocities as well as different spin projections.

We consider a simple 2D model of a nanowire with Rashba spin-orbit coupling
NW-1 ; NW-last  in the presence of an external magnetic field. Due to the
Rashba spin-orbit coupling, an electric field perpendicular to the plane
generates an effective spin-orbit magnetic field in the plane and
perpendicular to the nanowire. A diode effect may arise if the external
magnetic field is aligned with the spin-orbit field.

A single channel with different Fermi velocities, $v_{j}=\bar{v}+j\delta v/2$,
and Zeeman energies, $h_{j}=\bar{h}+j\delta h/2$, resulting from different
spin projections, for the two pseudo-spin bands $j=\pm$, see Fig. 1, requires
at least one of two ingredients (see Appendix A): a finite transverse width
such that the spin-orbit coupling associated with the transverse motion comes
into play or a magnetic field $\vec{h}_{\perp}$ transverse to the spin-orbit
field. In the former case, $\delta v/\bar{v}\sim\sqrt{E_{so}/\omega_{0}}$,
whereas $\delta h/\bar{h}\sim E_{so}^{3/2}\sqrt{\bar{\mu}}/\omega_{0}^{2}$,
where $\omega_{0}$ is the energy scale associated with the transverse
confining potential, is typically smaller. In the latter case, the difference
in Fermi velocities and effective fields is determined by $\delta
v/\bar{v},\delta h/\bar{h}\sim h_{\perp}^{2}/(\sqrt{E_{so}}\bar{\mu}^{3/2})$,
where $E_{so}=m\alpha^{2}/2$ is the spin-orbit energy associated with the
Rashba coupling $\alpha$ and $\bar{\mu}$ is an effective chemical potential.
The field $\vec{h}_{\perp}$ may be chosen along the nanowire, which is the
direction considered in order to realize topological superconductivity with
Majorana end modes in proximitized nanowires majorana1 ; majorana2 . When
superconductivity is induced, $h_{\perp}$ also modifies the induced gaps
$\Delta_{j}=\bar{\Delta}+j\delta\Delta/2$ in such a way that
$\Delta_{-}/\Delta_{+}=h_{-}/h_{+}$ nesterov .

Linearizing the spectrum close to the Fermi level, one thus obtains an
effective Hamiltonian

$\displaystyle H_{\rm eff}^{\rm
N}=\sum_{j=\pm}(jv_{j}p_{x}-h_{j})\sigma_{z}-\bar{\mu},$ (1)

where $p_{x}$ is the longitudinal momentum and $\sigma_{z}$ is a Pauli matrix
in pseudo-spin space. Adding superconductivity to describe a Josephson
junction, such that the normal part of the junction extends from $-L/2$ to
$L/2$, one finds

$\displaystyle H_{\rm
eff}=\sum_{j}\left[(jv_{j}p_{x}\sigma_{z}-\mu)\tau_{z}-h_{j}\sigma_{z}+\Delta_{j}\tau_{+}+\Delta_{j}^{*}\tau_{-}\right],$
(2)

where $\tau_{i}$ ($i=x,y,z$) are Pauli matrices in particle-hole space and
$\tau_{\pm}=\tau_{x}\pm i\tau_{y}$. The spatial dependence of the Zeeman field
and order parameter are given as $h_{j}(x)=h_{j}^{\rm
N}\theta(L/2-|x|)+h_{j}^{\rm S}\theta(|x|-L/2)$ and
$\Delta_{j}(x)=\Delta_{j}\exp[{\rm sign}(x)\phi/2]\theta(|x|-L/2)$, where
$\Delta_{j}$ and $\phi$ are the superconducting gaps of the two pseudo-spin
bands and phase difference, respectively. footnote-gaps  Here the magnetic
field $h_{j}^{\rm N}$ in the junction and the magnetic field $h_{j}^{\rm S}$
in the superconducting leads may be different due to magnetic screening. We
use units where $\hbar=k_{B}=1$. Note that an homogeneous version of Eq. (2)
may be used to analyze the “bulk”diode efficiency associated with the
asymmetry of depairing currents in a 1D model of bulk superconductorbulk-theo
; vs-Dolcini .)

Both fields $h_{j}^{\rm N}$ and $h_{j}^{\rm S}$ contribute to the Josephson
diode effect. We obtain the supercurrent using Eq. (3) in Ref. dolcini,  for a
ballistic Josephson junction and summing over both pseudo-spin bands:

$\displaystyle I_{J}$ $\displaystyle=$
$\displaystyle-4eT\frac{d}{d\phi}\Re\\!\\!\\!\sum_{j=\pm;\nu\geq
0}\\!\\!\\!\ln\left[1\\!+\\!a_{j}^{2}(\omega_{\nu})e^{-2\omega_{\nu}/E_{Lj}}e^{i(\phi+j\phi_{j})}\right],$

where $E_{Lj}=v_{j}/L$ and $\phi_{j}=2h_{j}^{\rm N}/E_{Lj}$ are Thouless
energies and phase shifts associated with electron propagation in the normal
region. Furthermore, $a_{\pm}(\omega_{\nu})=(\omega_{\nu}\mp ih_{\pm}^{\rm
S})/\Delta_{\pm}-[{(\omega_{\nu}\mp ih_{\pm}^{\rm
S})^{2}/\Delta_{\pm}^{2}+1}]^{1/2}$ with the fermionic Matsubara frequencies
$\omega_{\nu}=2\pi T(\nu+1/2)$ at temperature $T$ accounts for scattering at
the normal/superconductor interfaces.

The critical currents for opposite current directions are defined as
$I_{c}^{>}={\rm max}_{\phi}I_{J}(\phi)$ and $I_{c}^{<}=-{\rm
min}_{\phi}I_{J}(\phi)$. Then Eq. (LABEL:eq-current-general) allows one to
obtain the diode efficiency $\eta=(I_{c}^{>}-I_{c}^{<})(I_{c}^{>}+I_{c}^{<})$
for arbitrary fields, length of the junction, and temperature.

It turns out the diode effect due to the field in the junction behaves quite
differently than the one due to the field in the leads. We will start by
discussing the effect of the field in the junction only. To do so, we will
assume that the magnetic field is confined to the junction. Then Eq.
(LABEL:eq-current-general) simplifies to

$\displaystyle I_{J}$ $\displaystyle=$
$\displaystyle\sum_{j=\pm;k>0}I_{kj}\sin(k(\phi+j\phi_{j}))$ (4)

with

$I_{kj}=-4eT\sum_{\nu\geq
0}(-1)^{k}ka^{2k}(\omega_{v})e^{-2k\omega_{\nu}/E_{Lj}},$ (5)

Here
$a(\omega_{\nu})=\omega_{\nu}/\Delta-[{\omega_{\nu}^{2}/\Delta^{2}+1}]^{1/2}$,
where $\Delta$ is the common gap for both pseudo-spin bands.

In general, all harmonics contribute to the current-phase relation of a
ballistic Josephson junction. Typically, the higher the harmonics, the
stronger their suppression with temperature. When the two first harmonics
dominate over the other ones, the current-phase relation (4) can be rewritten
in the formfootnote-squid

$\displaystyle
I_{J}=I_{c1}\sin(\phi-\phi_{0})+I_{c2}\sin(2(\phi-\phi_{0})+\delta_{12})$ (6)

with

$\displaystyle I_{ck}$ $\displaystyle=$
$\displaystyle\sqrt{{I_{k+}}^{2}+{I_{k-}}^{2}+2{I_{k+}}{I_{k-}}\cos(k(\phi_{+}+\phi_{-}))},$
(7) $\displaystyle\phi_{0k}$ $\displaystyle=$
$\displaystyle-\arctan\frac{I_{k+}\sin(k\phi_{+})-I_{k-}\sin(k\phi_{-})}{I_{k+}\cos(k\phi_{+})+I_{k-}\cos(k\phi_{-})},$
(8)

such that $\phi_{0}=\phi_{01}$ and $\delta_{12}=2\phi_{01}-\phi_{02}$. The
diode efficiency is non-vanishing unless $I_{c1}=0$ or $I_{c2}=0$ or
$\delta_{12}=0\,{\rm mod}\,\pi$. The maximal diode efficiency etamax
$\eta_{\rm max}=1/3$ is achieved at $I_{c2}=I_{c1}/2$ and
$\delta_{12}=\pi/2\,{\rm mod}\,\pi$.

Typically $I_{c2}\ll I_{c1}$. Then the diode efficiency takes the simple form

$\displaystyle\eta\approx-\frac{I_{c2}}{I_{c1}}\sin\delta_{12}.$ (9)

The result can be further simplified introducing $I_{kj}=\bar{I}_{k}+j\delta
I_{k}/2$ and $\phi_{j}=\bar{\phi}+j\delta\phi/2$. At weak spin-orbit coupling,
$\delta v/\bar{v},\delta h/\bar{h}\ll 1$ yields $\delta I_{k}\ll\bar{I}_{k}$
and $\delta\phi\ll\bar{\phi}$, such that $I_{ck}\approx
2\bar{I}_{k}\left|\cos(k\bar{\phi})\right|$ and

$\phi_{0k}\approx-\left(\frac{k\delta\phi}{2}+\frac{\delta
I_{k}}{2\bar{I}_{k}}\tan(k\bar{\phi})\right).$ (10)

Note that $\bar{\phi}=2\bar{h}/\bar{E}_{L}$ with $\bar{E}_{L}=\bar{v}/L$ and
$\delta\phi=(\delta h/\bar{h}-\delta v/\bar{v})\bar{\phi}/2$. If
$\bar{\phi}\ll 1$, the diode efficiency is linear in the magnetic field and
given as

$\displaystyle\eta\approx\frac{\bar{I}_{2}}{\bar{I}_{1}}\left(\frac{\delta
I_{1}}{\bar{I}_{1}}-\frac{\delta I_{2}}{\bar{I}_{2}}\right)\bar{\phi}.$ (11)

If $\delta I_{2}/\bar{I}_{2}=\delta I_{1}/\bar{I}_{1}$, a residual effect
$\propto\bar{h}^{3}$ remains, namely $\eta\approx(\delta
I_{1}/\bar{I}_{1})\bar{\phi}^{3}$. As $\delta_{12}$ increases with $\bar{h}$,
the diode efficiency changes sign at larger fields, when $\delta_{12}$ exceeds
$\pi$, according to Eq. (9).

As we discuss below, a current-phase relation with essentially two harmonics
may be realized in a junction with arbitrary length at $T_{c}-T\ll T_{c}$,
where $T_{c}$ is the critical temperature of the leads. In a long junction,
lower temperatures $E_{Lj}\ll T\ll T_{c}$ are sufficient.

Near $T_{c}$, the gap $\Delta$ vanishes. Thus $\Delta\ll\omega_{\nu}$, such
that $a(\omega_{\nu})\approx-\Delta/(2\omega_{\nu})$. As a consequence,
$I_{kj}\propto\Delta^{2k}$ and we may keep $k=1,2$ in Eq. (4) only with

$\displaystyle
I_{kj}=-4eT_{c}(-1)^{k}k\sum_{\nu}(\Delta/2\omega_{\nu})^{2k}e^{-2k\omega_{\nu}/E_{Lj}}.$
(12)

In the limit $L\to 0$ or $E_{Lj}\to\infty$, both pseudo-spin bands yield
supercurrents of the same magnitude, i.e., $\delta I_{k}=0$. Thus, the finite
length has to be taken into account in order to obtain a diode effect. In a
short junction, with logarithmic accuracy, this yields

$\displaystyle I_{1j}$ $\displaystyle\approx$
$\displaystyle\frac{\pi^{2}}{2}eT_{c}\left(\frac{\Delta}{2\pi
T_{c}}\right)^{2}\left(1-\frac{4}{\pi^{2}}\frac{2\pi
T_{c}}{E_{Lj}}\ln\frac{E_{Lj}}{2\pi T_{c}}\right),$ (13) $\displaystyle
I_{2j}$ $\displaystyle\approx$
$\displaystyle-\frac{\pi^{2}}{24}eT_{c}\left(\frac{\Delta}{2\pi
T_{c}}\right)^{4}.$ (14)

Thus $I_{c2}/I_{c1}\approx-\left(\Delta/2\pi T_{c}\right)^{2}/12$ and

$\displaystyle\delta_{12}\approx-\frac{4}{\pi^{2}}\frac{2\pi
T_{c}}{\bar{E}_{L}}\ln\left(\frac{\bar{E}_{L}}{2\pi T_{c}}\right)\frac{\delta
v}{\bar{v}}\frac{\bar{h}}{\bar{E}_{L}}\ll 1.$ (15)

The diode efficiency $\eta_{\rm short}$ is then given by Eq. (9).

In a long junction, the contributions from Matsubara frequencies
$\omega_{\nu>0}$ are suppressed when $E_{Lj}\ll T\ll T_{c}$ and we may
approximate $a(\omega_{0})\approx-1$. As a consequence,
$I_{kj}\propto\exp[-k2\pi T/E_{Lj}]$ and we may keep $k=1,2$ in Eq. (4) only
with

$\displaystyle I_{kj}$ $\displaystyle\approx$
$\displaystyle-4eT(-1)^{k}ke^{-k2\pi T/E_{Lj}}.$ (16)

At small $\bar{h}$, this yields

$\delta_{12}\approx\left(\tanh\frac{2\pi T\delta
v}{\bar{E}_{L}\bar{v}}-\tanh\frac{\pi T\delta
v}{\bar{E}_{L}\bar{v}}\right)\frac{2\bar{h}}{\bar{E}_{L}}.$ (17)

At $\delta v/\bar{v}\ll\bar{E}_{L}/T$, the result simplifies to
$\delta_{12}\approx-2\pi(T\bar{h}/\bar{E}_{L}^{2})\delta v/\bar{v}\ll 1$. The
corresponding diode efficiency is exponentially suppressed, $\eta_{\rm
long}\propto\exp[-2\pi T/\bar{E}_{L}]$.

Though the current-phase relation of a ballistic Josephson junction at $T=0$
contains many harmonics and displays jumps, analytical results can be obtained
both for short and long junctions.

(a) (b)

Figure 2:  The diode efficiency at $T=0$ due to the magnetic field in the
junction as a function of the phase shift $\bar{\phi}\propto\bar{h}$ for (a) a
short junction and (b) a long junction. In the latter case, the width of the
phase interval around $\pi/2$ where $\eta$ decreases with $\bar{\phi}$ is set
by $\delta v/\bar{v}$.

To obtain a diode effect in a short junction, we need to keep both the phase
acquired in the junction ($\propto h_{j}L$) and the leading correction in
$\Delta/E_{Lj}\ll 1$. While the main contribution to the Josephson current is
carried by Andreev bound states with energy $E_{{\rm
A}j}=\Delta\cos((\phi+j\phi_{j})/2)$, the correction comes from the continuum
Levchenko2006 , which carries a current in the opposite direction. With
logarithmic accuracy, one finds

$\displaystyle I_{J}$ $\displaystyle=$
$\displaystyle\frac{e\Delta}{2}\sum_{j=\pm}\sin\frac{\phi+j\phi_{j}}{2}{\rm
sign}\left(\cos\frac{\phi+j\phi_{j}}{2}\right)\quad$ (18)
$\displaystyle\qquad\times\left[1-\frac{4}{\pi}\left(\frac{\Delta}{E_{Lj}}\ln\frac{E_{Lj}}{\Delta}\right)\left|\cos\frac{\phi+j\phi_{j}}{2}\right|\right].$

Thus, we find an average critical current
$\bar{I}_{c}=(e\Delta/2)\left(1+\left|\cos\bar{\phi}\right|\right)$ and a
diode efficiency

$\displaystyle\eta_{0\,{\rm short}}$ $\displaystyle=$
$\displaystyle\frac{2}{\pi}\left(\frac{\Delta}{\bar{E}_{L}}\ln\frac{\bar{E}_{L}}{\Delta}\right)\frac{\delta
v}{\bar{v}}\frac{\sin(2\bar{\phi})}{1+|\cos\bar{\phi}|}.$ (19)

The maximal diode efficiency is $\eta_{0\,{\rm short}}^{\rm
max}=\sqrt{10\sqrt{5}-22}\,(2\Delta\delta
v/\pi\bar{E}_{L}\bar{v})\ln(\bar{E}_{L}/\Delta)$. The dependence on
$\bar{\phi}$ is shown in Fig. 2(a).

In a long Josephson junction, the current-phase relation at $T=0$ of each
pseudo-spin band has a sawtooth shape Ishii1970 . The total current reads

$I_{J}=\sum_{j=\pm}eE_{Lj}\Bigg{[}\frac{\phi+j\phi_{j}}{2\pi}-{\rm
Int}\left(\frac{\phi+j\phi_{j}+\pi\,{\rm
sign}(\phi+j\phi_{j})}{2\pi}\right)\Bigg{]}.\;$ (20)

Defining $x=\bar{\phi}/\pi-{\rm Int}(\bar{\phi}/\pi)$, this yields an average
critical current

$\displaystyle\bar{I}_{c}=e\bar{E}_{L}\begin{cases}1-x,&x<\frac{1}{2}({1-\frac{\delta
v}{2\bar{v}}}),\\\ \frac{1}{2}({1+\frac{\delta
v}{2\bar{v}}}),&\frac{1}{2}({1-\frac{\delta
v}{2\bar{v}}})<x<\frac{1}{2}({1+\frac{\delta v}{2\bar{v}}}),\\\
x,&\frac{1}{2}({1+\frac{\delta v}{2\bar{v}}})<x,\\\ \end{cases}$ (21)

and a diode efficiency

$\displaystyle\eta_{0\,{\rm long}}$ $\displaystyle\approx$
$\displaystyle\begin{cases}\frac{\delta
v}{2\bar{v}}\frac{x}{1-x},&x<\frac{1}{2}({1-\frac{\delta v}{2\bar{v}}}),\\\
1-2x,&\frac{1}{2}({1-\frac{\delta v}{2\bar{v}}})<x<\frac{1}{2}({1+\frac{\delta
v}{2\bar{v}}}),\\\ -\frac{\delta
v}{2\bar{v}}\frac{1-x}{x},&\frac{1}{2}({1+\frac{\delta v}{2\bar{v}}})<x.\\\
\end{cases}$ (22)

The maximal diode efficiency is $\eta_{0\,{\rm long}}^{\rm max}=\delta
v/(2\bar{v})\gg\eta_{0\,{\rm short}}^{\rm max}$. I.e., the diode efficiency is
enhanced in a long junction. The dependence on $\bar{\phi}$ is shown in Fig.
2(b).

We finally turn to the effect of the magnetic field in the leads. As shown in
Ref. dolcini, , the magnetic field $h_{j}^{\rm S}$ yields a diode effect in a
topological junction where only one pseudo-spin band is present. It is due to
the fact that the magnetic field induces a current in the leads, which are
formed of helical edges “proximitized” by a conventional superconductor.
Indeed, if superconductivity in the edges were intrinsic, the field would
induce a spatially modulated order parameter corresponding to a zero-current
state. By contrast, the uniform order parameter imposed by the conventional
superconductor covering the edges forces a current along the edges and, thus,
across the junction. In the short junction limit, $L\to 0$, and $h\equiv
h_{j}^{\rm S}<\Delta$, the current-phase relation of a single pseudo-spin band
at $T=0$ reads dolcini ; footnote-fu

$I_{j}(\phi)=\frac{eh}{\pi}+\frac{e\Delta}{2}\sin\frac{\phi}{2}{\rm
sign}\left(\cos\frac{\phi+j\phi_{j}}{2}\right),$ (23)

where $\phi_{j}=2\arcsin(h_{j}^{\rm S}/\Delta)$. The diode efficiency is given
as

$\eta_{\rm topo}^{\rm
S}=\frac{{4h}/{\pi\Delta}-1+\sqrt{1-{h^{2}}/{\Delta^{2}}}}{1+\sqrt{1-{h^{2}}/{\Delta^{2}}}}.$
(24)

Its maximum value $\eta_{\rm topo}^{\rm max}=4/\pi^{2}$ is achieved at
$h/\Delta=4\pi/(\pi^{2}+4)$. In the presence of both pseudo-spin bands, there
is a partial cancellation between the bands as the currents they carry in the
leads are opposed nesterov . The residual diode efficiency is given as
footnote-topo

$\eta^{\rm S}=\begin{cases}\frac{\frac{2\delta
h}{\pi\bar{\Delta}}-\sqrt{1-{h_{-}^{2}}/{\Delta_{-}^{2}}}+\sqrt{1-{h_{+}^{2}}/{\Delta_{+}^{2}}}}{\sqrt{1-{h_{-}^{2}}/{\Delta_{-}^{2}}}+\sqrt{1-{h_{+}^{2}}/{\Delta_{+}^{2}}}}&\frac{h_{-}}{\Delta_{-}}<\sqrt{1-\frac{\delta\Delta^{2}}{4\bar{\Delta}^{2}}}\\\
\frac{\frac{2\delta
h}{\pi\bar{\Delta}}-\delta\Delta/(2\bar{\Delta})+\sqrt{1-{h_{+}^{2}}/{\Delta_{+}^{2}}}}{\delta\Delta/(2\bar{\Delta})+\sqrt{1-{h_{+}^{2}}/{\Delta_{+}^{2}}}}&\sqrt{1-\frac{\delta\Delta^{2}}{4\bar{\Delta}^{2}}}<\frac{h_{-}}{\Delta_{-}}<1\end{cases}$
(25)

Using $h_{+}/\Delta_{+}=h_{-}/\Delta_{-}\equiv h/\Delta$, we find a maximal
diode efficiency $\eta^{\rm S}_{\rm
max}=(2/\pi)\sqrt{1-{\delta\Delta^{2}}/({4\bar{\Delta}^{2}})}$ at
$h/\Delta=\sqrt{1-{\delta\Delta^{2}}/({4\bar{\Delta}^{2}})}$.

A finite length of the junction or finite temperature both suppress the diode
efficiency as can be checked numerically using Eq. (LABEL:eq-current-general).

In conclusion, we presented a simple model for a Josephson diode effect in a
single-channel ballistic nanowire with Rashba spin-orbit coupling and subject
to a Zeeman field. The diode effect arises due to the interplay between the
Andreev bound states forming within the two pseudo-spin bands. We derived
microscopically the current-phase relation that was used phenomenologically in
previous works. We showed that the diode effect induced by the magnetic field
has two different contributions. One contribution is due to the field in the
junction; it increases with the length of the junction. Another contribution
is due to the field in the leads; it is maximal in a short junction when only
one pseudo-spin band is present. The same physical ingredients also yield an
anomalous Josephson current JA1 ; JA2 ; JA3 ; multichannel1 . We discuss
connections and differences between the two effects in Appendix B. The
experimental challenge is to separate the diode effect due to the interplay
between spin-orbit coupling and a Zeeman field from other origins. The
predictions given in this work can serve as a guide for assessing the
microscopic origin of the diode effect in a concrete setup.

###### Acknowledgements.

We thank Liang Fu and Jean-Damien Pillet for interesting exchanges. We wish to
acknowledge funding from the French Agence Nationale de la Recherche through
Grants No. ANR-17-PIRE-0001 (HYBRID) and ANR-21-CE30-0035 (TRIPRES).

##  Appendix A 2D harmonic nanowire with Rashba spin-orbit coupling

Here we provide a simple twodimensional model of a nanowire with Rashba spin-
orbit coupling NW-1 ; NW-last . The confining potential along the
$y$-direction is considered harmonic with frequency $\omega_{0}$,
$V(y)=m\omega_{0}^{2}y^{2}/2$, where $m$ is the effective electron mass.
Furthermore, we include an in-plane magnetic field
$\vec{h}=h_{x}\vec{u}_{x}+h_{y}\vec{u}_{y}$. The Hamiltonian takes the form

$\displaystyle
H=\frac{\vec{p}^{2}}{2m}+\frac{1}{2}m\omega_{0}^{2}y^{2}-\alpha(\vec{p}\times\vec{\sigma})\cdot\vec{u}_{z}+\vec{h}\cdot\vec{\sigma},$
(26)

where $\vec{p}=(p_{x},p_{y})$ is the in-plane momentum, $\alpha$ is the
strength of the Rashba spin-orbit coupling, $\sigma_{i}$ ($i=x,y,z$) are Pauli
matrices in spin space, and $\vec{u}_{z}$ is a unit vector perpendicular to
the plane.

We will consider the transverse spin-orbit coupling ($\sim\alpha p_{y}$) as
well as the field along the wire ($h_{x}$) as perturbations, namely we will
assume $\alpha p_{y},h_{x}\ll\omega_{0}$. The Hamiltonian

$\displaystyle
H_{0}=\frac{\vec{p}^{2}}{2m}+\frac{1}{2}m\omega_{0}^{2}y^{2}-\alpha
p_{x}\sigma_{y}+h_{y}\sigma_{y}$ (27)

can be easily diagonalized. The eigenfunctions take the form

$\displaystyle\psi_{k_{x},n,\pm}(x,y)=e^{ik_{x}x}\chi_{n}(y)\frac{1}{\sqrt{2}}\begin{pmatrix}1\\\
\pm i\end{pmatrix},$ (28)

where $\chi_{n}(y)$ are the harmonic oscillator eigenfunctions, with
eigenenergies

$\displaystyle
E_{n\pm}(k_{x})=\frac{k_{x}^{2}}{2m}+\omega_{0}(n+\frac{1}{2})-\mu\mp(\alpha
k_{x}-h_{y}).$ (29)

Note that the spin states within a subband have the same velocity at a given
energy. Band crossings between the two spin states in the first subband take
place at $k_{x}=h_{y}/\alpha$. Band crossings between opposite spin states in
the first and second subband take place at
$k_{x}=\mp\omega_{0}/(2\alpha)+h_{y}/\alpha$. The transverse spin-orbit
coupling and the longitudinal magnetic field open gaps at these crossings and
thus modify the velocities of the different bands and change the spin-
projection of the eigenstates. For sufficiently low chemical potential, we may
write an effective Hamiltonian in the space spanned by
$\psi_{k_{x},0,+},\psi_{k_{x},0,-},\psi_{k_{x},1,+},\psi_{k_{x},1,-}$, namely

$\displaystyle\tilde{H}$ $\displaystyle=$
$\displaystyle\frac{k_{x}^{2}}{2m}-(\alpha
k_{x}-h_{y})\sigma_{z}-\omega_{0}(1-\frac{1}{2}\eta_{z})$ (30)
$\displaystyle+\eta\sigma_{y}\eta_{y}+h_{x}\sigma_{y}-\mu$

with $\eta=\alpha\sqrt{m\omega_{0}/2}\equiv\sqrt{E_{so}\omega_{0}}$. The
spectrum is given as

$\displaystyle
E_{s_{1}s_{2}}=\frac{k_{x}^{2}}{2m}+\omega_{0}-\mu+s_{1}\sqrt{(\alpha
k_{x}-h_{y})^{2}+h_{x}^{2}+\frac{\omega_{0}^{2}}{4}+\eta^{2}+s_{2}\sqrt{(\alpha
k_{x}-h_{y})^{2}\omega_{0}^{2}+4h_{x}^{2}(\frac{\omega_{0}^{2}}{4}+\eta^{2})}}.$
(31)

Unless the chemical potential is close to an avoided crossing, we may
approximate the two lowest bands as

$\displaystyle E_{\pm}$ $\displaystyle\approx$ $\displaystyle\frac{(k_{x}\mp
m\alpha)^{2}}{2m}+\frac{\omega_{0}}{2}-\mu-\frac{m\alpha^{2}}{2}\mp\left(\frac{h_{x}^{2}}{2\alpha
k_{x}}+\frac{\eta^{2}}{2\alpha k_{x}\pm\omega_{0}}\right)\mp
h_{y}\left(1-\frac{h_{x}^{2}}{2\alpha^{2}k_{x}^{2}}-\frac{\eta^{2}}{(2\alpha
k_{x}\pm\omega_{0})^{2}}\right).$ (32)

This yields Fermi momenta $k_{F}^{\pm}\approx\bar{k}_{F}\mp m\alpha$ with
$\bar{k}_{F}=\sqrt{2m(\mu-\frac{\omega_{0}}{2}+\frac{m\alpha^{2}}{2})}$.
Reinjecting the Fermi momenta into Eq. (32), one find the Fermi velocities and
effective fields

$\displaystyle v_{\pm}$ $\displaystyle\approx$
$\displaystyle\frac{\bar{k}_{F}}{m}\pm\left(\frac{h_{x}^{2}}{2\alpha}\frac{\bar{k}_{F}^{2}+m^{2}\alpha^{2}}{(\bar{k}_{F}^{2}-m^{2}\alpha^{2})^{2}}+\frac{\alpha\eta^{2}}{2}\frac{\alpha^{2}\bar{k}_{F}^{2}+(m\alpha^{2}+\frac{\omega_{0}}{2})^{2}}{(\alpha^{2}\bar{k}_{F}^{2}-(m\alpha^{2}+\frac{\omega_{0}}{2})^{2})^{2}}\right)\equiv\bar{v}\pm\frac{\delta
v}{2},$ (33) $\displaystyle h_{\pm}$ $\displaystyle\approx$ $\displaystyle
h_{y}\left[1\pm\left(\frac{h_{x}^{2}}{\alpha}\frac{m\bar{k}_{F}}{(\bar{k}_{F}^{2}-m^{2}\alpha^{2})^{2}}+\alpha\eta^{2}\frac{\alpha\bar{k}_{F}(m\alpha^{2}+\frac{\omega_{0}}{2})}{(\alpha^{2}\bar{k}_{F}^{2}-(m\alpha^{2}+\frac{\omega_{0}}{2})^{2})^{2}}\right)\right]\equiv\bar{h}\pm\frac{\delta
h}{2}.$ (34)

Note that we neglected the suppression of $\bar{h}$. Taking it into account,
one recovers $h_{\pm}\leq h_{y}$.

At weak spin-orbit coupling, $\alpha\ll\bar{v}$, these expressions reduce to

$\displaystyle v_{\pm}$ $\displaystyle\approx$
$\displaystyle\bar{v}\left[1\pm\frac{\alpha}{2\bar{v}}\left(\frac{h_{x}^{2}}{(\alpha\bar{k}_{F})^{2}}+\frac{\eta^{2}}{(\omega_{0}/2)^{2}}\right)\right],$
(35) $\displaystyle h_{\pm}$ $\displaystyle\approx$ $\displaystyle
h_{y}\left[1\pm\frac{\alpha}{\bar{v}}\left(\frac{h_{x}^{2}}{(\alpha\bar{k}_{F})^{2}}+2\frac{\bar{\mu}\eta^{2}}{(\omega_{0}/2)^{3}}\right)\right],$
(36)

where $\bar{\mu}=\bar{k}_{F}^{2}/2m$.

##  Appendix B Anomalous Josephson effect

The so-called anomalous Josephson effect, i.e., the presence of Josephson
current in the absence of an applied phase difference ($\phi=0$), arises from
the same interplay between spin-orbit coupling and an external magnetic field.
In contrast to the diode effect, a current-phase relation with a single
harmonic is sufficient to obtain an anomalous Josephson current. The anomalous
Josephson effect due to the magnetic field in the leads has been studied in
detail in Refs. dolcini, ; nesterov, . Here we provide results for the
anomalous Josephson current due to the field within the junction. For a
current-phase relation dominated by the first harmonic, it is given as $I_{\rm
an}\approx-I_{c1}\sin(\phi_{01})$, except for phases $\phi_{01}\approx n\pi$,
where the higher harmonics come into play. At small fields, the anomalous
current is linear in $\bar{h}$ and given as

$I_{\rm an}\approx\bar{I}_{1}\delta\phi+\delta I_{1}\bar{\phi}.$ (37)

With this, we can compute the anomalous current for a short junction close to
$T_{c}$. It is dominated by the first term in Eq. (37) yielding

$I_{\rm an}^{\rm
short}\approx\frac{e\Delta^{2}}{8T_{c}}\frac{\bar{h}}{\bar{E}_{L}}\left(\frac{\delta
h}{\bar{h}}-\frac{\delta v}{\bar{v}}\right).$ (38)

Eq. (37) also gives the anomalous Josephson current in a long junction at
$T\gg\bar{E}_{L}$, namely

$I_{\rm an}^{\rm long}\approx 4eTe^{-2\pi
T/\bar{E}_{L}}\\!\left(\delta\phi\cosh\frac{\pi T\delta
v}{\bar{E}_{L}\bar{v}}\\!+\\!\bar{\phi}\sinh\frac{\pi T\delta
v}{\bar{E}_{L}\bar{v}}\right).\\!\\!$ (39)

We note that in both cases $|I_{\rm
an}|\gg|I_{c}^{>}-I_{c}^{<}|\propto\bar{I}_{2}$.

At $T=0$, the situation is a little more subtle. The anomalous current of a
short junction is given as

$\displaystyle I_{\rm an}^{0\,{\rm short}}$ $\displaystyle\approx$
$\displaystyle-\frac{e\Delta}{2}\sum_{j=\pm}j\sin\frac{\phi_{j}}{2}{\rm
sign}\left[\cos\frac{\phi_{j}}{2}\right].$ (40)

To lowest order in field, one obtains $I_{\rm an}\approx-e\Delta\delta\phi/4$.
In the narrow interval
$\bar{\phi}-\delta\phi/2<(2n+1)\pi<\bar{\phi}-\delta\phi/2$, the anomalous
current is strongly enhanced reaching values comparable to the critical
current, $I_{\rm an}\sim e\Delta$. In a long junction, he anomalous current to
lowest order in the field is given as

$\displaystyle I_{\rm an}^{0\,{\rm long}}$ $\displaystyle=$
$\displaystyle-e\bar{E}_{L}\left(\frac{\delta\phi}{2\pi}+\frac{\delta
v}{\bar{v}}\frac{\bar{\phi}}{2\pi}\right).$ (41)

As in the short junction case, in the narrow interval
$\bar{\phi}-\delta\phi/2<(2n+1)\pi<\bar{\phi}-\delta\phi/2$, the anomalous
current is strongly enhanced reaching values comparable to the critical
current, $I_{\rm an}\sim e\bar{E}_{L}$.

## References

  * (1) M. Nadeem, M.S. Fuhrer, and X. Wang, Nature Reviews Physics 5, 558 (2023).
  * (2) N. Nagaosa, and Y. Yanase, Annual Review of Condensed Matter Physics 15, 63 (2024).
  * (3) F. Ando, Y. Miyasaka, T. Li et al., Nature 584, 373 (2020).
  * (4) L. Bauriedl, C. Bäuml, L. Fuchs et al., Nat Commun 13, 4266 (2022).
  * (5) J.X. Lin, P. Siriviboon, H.D. Scammell et al., Nat. Phys. 18, 1221 (2022).
  * (6) N. Satchell, P.M. Shepley, M.C. Rosamond, and G. Burnell, Journal of Applied Physics 133, 203901 (2023).
  * (7) Y. Hou, F. Nichele, H. Chi et al., Phys. Rev. Lett. 131, 027001 (2023).
  * (8) C. Baumgartner, L. Fuchs, A. Costa et al., Nat. Nanotechnol. 17, 39 (2022).
  * (9) B. Pal, A. Chakraborty, P.K. Sivakumar et al., Nat. Phys. 18, 1228 (2022).
  * (10) T.A. Fulton, L. N. Dunkleberger, and R.C. Dynes, Phys. Rev. B 6, 855 (1972).
  * (11) H. Wu, Y. Wang, Y. Xu et al., Nature 604, 653 (2022).
  * (12) J. Díez-Mérida,A. Díez-Carlón, S.Y. Yang et al., Nat Commun 14, 2396 (2023).
  * (13) M. Trahms, L. Melischek, J.F. Steiner et al., Nature 615, 628 (2023).
  * (14) J. Chiles, E.G. Arnault, C.-C. Chen et al., Nano Lett. 23, 5257 (2023).
  * (15) B. Zhang, Z. Li, V. Aguilar et al., preprint arXiv:2212.00199.
  * (16) A. A. Reynoso, G. Usaj, C. A. Balseiro, D. Feinberg, and M. Avignon, Phys. Rev. Lett. 101, 107001 (2008).
  * (17) T. Yokoyama, M. Eto, and Y.V. Nazarov, Phys. Rev. B 89, 195407 (2014).
  * (18) V.B. Geshkenbein and A.I. Larkin, Pis’ma Zh. Eksp. Teor. Fiz. 43, 306 (1986) [JETP Lett. 43, 395 (1986)].
  * (19) I.V. Krive, L.Y. Gorelik, R.I. Shekhter, and M. Jonson, Fiz. Nizk. Temp. 30, 535 (2004) [Low Temp. Phys. 30, 398 (2004)].
  * (20) A.I. Buzdin, Phys. Rev. Lett. 101, 107005 (2008).
  * (21) Jin-Xin Hu, Zi-Ting Sun, Ying-Ming Xie, K. T. Law, Phys. Rev. Lett. 130, 266003 (2023).
  * (22) P.A. Volkov, E. Lantagne-Hurtubise, T. Tummuru, S. Plugge, J.H. Pixley, and M. Franz, preprint arXiv.2307.01261.
  * (23) M. Governale and U. Zülicke, Phys. Rev. B 66, 073311 (2002).
  * (24) S. Park and A. L. Yeyati, Phys. Rev. B 96, 125416 (2017).
  * (25) R.M. Lutchyn, J.D. Sau, and S. Das Sarma, Phys. Rev. Lett. 105, 077001 (2010).
  * (26) Y. Oreg, G. Refael, and F. von Oppen, Phys. Rev. Lett. 105, 177002 (2010).
  * (27) K.N. Nesterov, M. Houzet, and J.S. Meyer, Phys. Rev. B 93, 174502 (2016).
  * (28) The magnetic field in the leads may also affect the induced superconductivity, leading to different gaps $\Delta_{\pm}$ in the two pseudo-spin bands. Here we neglect this effect.
  * (29) T. de Picoli, Z. Blood, Y. Lyanda-Geller, and J.I. Väyrynen Phys. Rev. B 107, 224518 (2023).
  * (30) S.J. De, U. Khanna, S. Rao, and S. Das, Phys. Rev. B 108, L161403(2023)
  * (31) F. Dolcini, M. Houzet, and J.S. Meyer, Phys. Rev. B 92, 035428 (2015).
  * (32) Note that the same equations may also be used to describe an asymmetric SQUID squid1 ; squid2 , where the subscript $j$ labels the two Josephson junctions in the SQUID loop and $\phi_{j}=j\Phi/(2\Phi_{0})$ with $\Phi$ the flux through the loop and $\Phi_{0}$ the flux quantum.
  * (33) Ya.V. Fominov and D.S. Mikhailov, Phys. Rev. B 106, 134514 (2022).
  * (34) R.S. Souto, M. Leijnse, and C. Schrade, Phys. Rev. Lett. 129, 267702 (2022).
  * (35) A. Levchenko, A. Kamenev, and L.I. Glazman, Phys. Rev. B 74, 212509 (2006).
  * (36) C. Ishii, Prog. Theor. Physics 44, 1525 (1970).
  * (37) One obtains the same current-phase relation when finite-momentum pairing is realized in the conventional superconducting leads fu-diode ; zazunov-diode .
  * (38) A. Zazunov, J. Rech, T. Jonckheere, B. Grémaud, T. Martin, and R. Egger, Phys. Rev. B 109, 024504 (2024).
  * (39) M. Davydova, S. Prembabu, and L. Fu, Science Advances 8, eabo0309 (2022).
  * (40) Similar results for the case $\Delta_{+}=\Delta_{-}$ were obtained in Ref. topo, .
  * (41) P.-H. Fu, Y. Xu, S.A. Yang, C.H. Lee, Y.S. Ang, and J.-F. Li, preprint arXiv:2212.01980.