Magflow: Differentiable Simulation of Industrial-Grade 6D Magnetic Levitation
Analyze & explore related research in Conceptio
Connect this record directly into your research workflow or AI agent. Explore citations across open repositories, query full text, and export structured proof bundles.
IEEE ROBOTICS AND AUTOMATION LETTERS. PREPRINT VERSION. ACCEPTED NOVEMBER, 2026
1
Magflow: Differentiable Simulation of Industrial-Grade 6D Magnetic Levitation
arXiv:2611.23050v1 [cs.RO] 17 Nov 2026
Philipp Hartmann, Jannick Stranghöner, and Klaus Neumann
Abstract—Magnetic levitation with six-degrees-of-freedom enables frictionless transport and micrometer-scale positioning in principle, but low-level control is inherently challenging due to its complex and unstable dynamics. Industrial systems typically rely on deep hardware–software co-design, where mover and stator geometries are jointly designed to enable a compact, hand-crafted approximation of the electromagnetic force computation, thereby keeping control computationally tractable at kilohertz rates. However, this approach imposes overly conservative constraints on the operating workspace and the range of supported mover topologies. Instead of reducing the underlying physics to a hand-crafted approximation, we compute the physics directly. We introduce Magflow, a fully differentiable, GPUparallel simulator for 6D magnetic levitation. It is used to train the first neural controller for an industrial-grade 6D magnetic levitation system that is learned purely from simulated physics. We show that the learned neural controller transfers zero-shot from simulation to real hardware while satisfying hard real-time constraints at 4 kHz. The learned controller achieves qualitatively new behaviors and even levitates a mover topology for which no hand-crafted solution exists. These results demonstrate that co-design is not a physical necessity for 6D magnetic levitation control. More broadly, control learning from simulated physics can find solutions beyond the reach of control engineering in demanding industrial domains. Source code and demonstration videos are publicly available at https://sites.google.com/view/magflow. Index Terms—Machine Learning for Robot Control, Neural and Fuzzy Control, Magnetic Levitation, Differentiable Simulation
I. I NTRODUCTION
M
AGNETIC levitation (MagLev) with six-degrees-offreedom (6D) enables frictionless transport, precise manipulation [1], and flexible product routing with no mechanical wear. These properties make MagLev systems attractive for semiconductor manufacturing, pharmaceutical filling, electronics assembly, and many other industrial applications [2]–[4]. Today, these systems achieve micrometer-scale positioning [5], but this precision took decades of research. In such systems, a mover with embedded permanent magnets levitates above planar stator tiles. The controller estimates its pose from magnetic field sensors and computes the currents of their coils to stabilize the inherently unstable mover in 6D. Manuscript received: July 16, 2026; Revised October 7, 2026; Accepted November 4, 2026. This paper was recommended for publication by Editor Sehoon Ha upon evaluation of the Associate Editor and Reviewers’ comments. This work was supported by the Fraunhofer Internal Programs under Grant No. SME 4009551. (Corresponding author: Philipp Hartmann.) Philipp Hartmann, Jannick Stranghöner, and Klaus Neumann are with CITEC, Faculty of Technology, Bielefeld University, 33615 Bielefeld, Germany (e-mail: philipp.hartmann@uni-bielefeld.de). Klaus Neumann is also with Fraunhofer IOSB-INA, 32657 Lemgo, Germany.
ℒ tracking
∇ℒ ∇ℒ
Dynamics Integrator mover pose
Sensor Simulation
∇ℒ
Mover
wrench
readings
currents
observations
actions
Neural Controller reference
Wrench Coil
∇ℒ
Lorentz Force
4 khz
Magflow - Differentiable Simulator
∇ℒ
Hall Sensor
Tile
Real System
zero-shot
Fig. 1. Magflow is the first differentiable simulator for 6D magnetic levitation, fusing the electromagnetic physics and the neural controller into a single GPU computational graph. Backpropagation through time trains the controller endto-end, purely from physics. The trained controller then transfers zero-shot to the real hardware running at 4 kHz.
The reason these systems work is their deep hardware-software co-design. In industrial systems, mover and stator geometries are typically jointly designed so that the forces between coils and magnets admit compact analytical expressions [2], [6]– [8], enabling hard real-time control at kilohertz rates [9], [10]. Alternatively, the forces can be precomputed numerically for a given geometry and interpolated online [9], [11], [12]. Either way, the resulting pipeline is a chain of engineered modules, from pose estimation and commutation to feedback control and calibration [6]–[8], [13], each built on geometry-specific assumptions and carefully tuned to reduce error compounding across the control chain. Our approach is to move approximations out of the real-time control loop and into offline training, where its cost no longer matters. To this end, we introduce Magflow (see Fig. 1), a fully differentiable, GPU-parallel electromagnetic simulator that models the Lorentz interactions between stator coils and mover magnets, the dynamics of the mover, and the Hall sensor measurements. Implemented entirely in JAX, Magflow compiles the physics, the neural controller, and the full closedloop rollout into a single GPU computational graph, enabling backpropagation through time across parallel simulated worlds. Using Magflow, we train the first neural controller for 6D MagLev learned purely from simulated physics and transfer it zero-shot to the real hardware at 4 kHz. Because Magflow does not rely on hand-crafted approximations, the learned neural controller is not bound by their validity region and extends the yaw range of the industrial system beyond its engineered limit. In addition, we levitate a plain bar magnet, which does not meet the co-design assumptions and for which no engineered controller exists on this platform. While single
This article has been accepted for publication in IEEE Robotics and Automation Letters. © 2026 IEEE. Personal use of this material is permitted. Permission from IEEE must be obtained for all other uses, in any current or future media, including reprinting/republishing this material for advertising or promotional purposes, creating new collective works, for resale or redistribution to servers or lists, or reuse of any copyrighted component of this work in other works.
2
IEEE ROBOTICS AND AUTOMATION LETTERS. PREPRINT VERSION. ACCEPTED NOVEMBER, 2026
Fig. 2. Overview of the MagLev system [25], [26] used in this work. (left) APS4322 stator tile with 24 stator units arranged in horizontal and vertical layers and the 50 embedded triaxial HES. (middle) Bottom view of the APM4330 mover with four five-magnet Halbach arrays, where red and blue indicate north and south pole. (right) Cross-section of a vertical stator unit beneath an aligned vertical Halbach array, showing the three-phase conductors, the HES plane, and the resulting magnetic flux. Fz and Fx indicate lift and lateral thrust.
disc magnets are limited to 5D control by their rotational symmetry [14], [15], the bar magnet is controlled in full 6D, even through a continuous 360◦ rotation about a horizontal axis, which to our knowledge has not been shown for any single permanent magnet on a planar MagLev system. II. R ELATED W ORK a) Low-level control of 6D MagLev: One of the main challenges in 6D MagLev is to compute the currents which apply a desired wrench to the mover. The idea is to reduce the Lorentz-force integral to a compact model. For a 1D Halbach array, the force decouples into vertical lift and lateral thrust [6]. This model was extended to full 6D wrenches for 2D orthogonal Halbach layouts [7], to model-based commutation for long-stroke actuators [8], and to multi-meter travel with linearly scaling coil counts [2]. Later work refined this model with yaw-dependent wrenches, unified wrench models, and predictor-based control [13], [16]–[19]. Others reduced the remaining model errors with compensation models [20], [21] or by redesigning the magnet topology with gap or staggered Halbach arrays [22], [23]. Such compensation can substantially improve accuracy, for instance by roughly 50% in force and 70% in torque over a harmonic model [24]. Alternatively, forces can be precomputed offline and stored in lookup tables, whose size grows exponentially with the pose dimensions, so they are kept tractable by exploiting the symmetry of the magnet array [9]. Research systems levitate disc magnets above cylindrical coils, whose radial symmetry reduces such tables to a single magnet–coil pair, using optical tracking and PD control [11], [12], [14], [15]. A single disc magnet receives no torque about its symmetry axis, limiting it to 5D [14], [15], and even a vertical orientation is only marginally feasible without overheating the coils [14]. Platforms of two discs control all 6D, but coil heating limits their tilt to ±40◦ [11], while unlimited rotation required a body of six magnets, arranged such that the required coil currents remain bounded in every orientation, levitated at a fixed height with optical tracking [27]. All share one structure: an engineered actuation model, made tractable by co-design or symmetry, with software tuned and calibrated around it. In contrast, we rotate a single bar magnet, sensed only by the Hall
sensors embedded in an industrial MagLev system. As neither the bar nor the planar rectangular coils have a continuous rotational symmetry, such a table needs more pose dimensions and becomes substantially larger, possibly intractable for realtime control [9]. Recent research replaced an engineered controller with a single end-to-end neural controller learned via behavior-cloning from interaction data of the proprietary controller [28]. This proved feasibility, but only because a working engineered controller already existed to imitate. The neural controller could not surpass its teacher and inherited the conservative workspace of the engineered system. We instead learn control directly from physics, with no commutation model and no expert to imitate. b) Neural control of unstable, high-rate systems: Neural networks can learn control directly from data, performing well in domains that share MagLev’s traits: open-loop instability, high actuation rates, and tight sensor–actuator coupling. Neural controllers have been trained for quadrotor flight [29], [30] and for electromagnetic systems such as electric motors and tokamak plasma control [31], [32]. They also outperform modular pipelines in manipulation, musculoskeletal control, and industrial assembly [33]–[35]. However, none meets MagLev’s full combination at once: six unstable degrees of freedom, 72 coupled actuator commands, 150 raw magneticfield observations with no direct state signal, 4 kHz hard realtime control, and micrometer-scale precision. c) Differentiable simulation and BPTT: Differentiable simulation enables gradient-based optimization of system dynamics, allowing a controller to be trained via backpropagation through time (BPTT) across the rollout [36], [37]. GPUparallel differentiable simulators enable large-batch policy optimization for locomotion [38] and most prominently for agile flight [39]–[41], although stiffness or discontinuities may compromise the efficacy of first-order gradient estimates [42]. Controllers trained this way already fly real quadrotors [39], [41] and can outperform engineered adaptive control [41]. However, these works differentiate through rigid-body dynamics at a few hundred Hz, whereas 6D MagLev requires differentiating through far more complex electromagnetic interactions between coils, mover magnets, and Hall sensors at kilohertz rates. Magflow is the first simulator to achieve this.
HARTMANN et al.: MAGFLOW: DIFFERENTIABLE SIMULATION OF INDUSTRIAL-GRADE 6D MAGNETIC LEVITATION
d) Sim-to-real transfer: Domain randomization is the standard method to tackle the sim2real gap between simulation and hardware. Here, training across a distribution of physical parameters yields controllers that transfer zero-shot to the real world [43]. It bridges simulation and reality in many domains such as dexterous in-hand manipulation [44], locomotion across morphologies [45], and end-to-end nanoquadcopter control [46]. In each case it covers the real system’s unknown physical parameters with a distribution in simulation. Our system has many such uncertainty sources, discussed in Sec. IV-B. Aligning with previous work, we also address these uncertainties using domain randomization. III. S YSTEM P LATFORM AND E NGINEERING A. Hardware Platform In this work, we consider a single-tile, single-mover configuration. The hardware platform is a Beckhoff XPlanar system comprising an active tile (APS4322-0000-0000, 240 × 240 mm) and a passive mover (APM4330-0000-0000, 155 × 155 mm) (see Fig. 2). For implicit state feedback, an embedded array of 50 triaxial Hall-effect sensors (HES) provides 150 raw magnetic field values per control cycle [5], [26]. Depending on the mover pose, these readings empirically range from −2000 to 2000 raw sensor counts (±0.1 T) with an inherent noise standard deviation of approximately 4 leastsignificant bits. For actuation, the tile contains 24 PCB stator units arranged as 12 horizontal and 12 vertical units across multiple copper layers [25]. Each unit consists of three phase coils whose active conductors follow the A+ B − C + A− B + C − order [25] shown in Fig. 2 (right), and is driven via fieldoriented control using a distinct control triplet of direct current dj , quadrature current qj , and electrical angle ϕj . To minimize bus payload, currents are quantized as 16-bit signed integers and electrical angles as 16-bit unsigned integers, yielding 72 actuator commands per control step for a single tile. The passive mover (see Fig. 2) comprises four orthogonal fivemagnet Halbach arrays, each spanning approximately 80 × 40 mm [26], [47]. Full 360◦ yaw rotation is only supported at specific symmetric positions centered on one, two, or four tiles [4], [48]. Outside these defined points, maximum yaw is generally restricted to ±5◦ [5]. The XPlanar system is constrained to a control cycle of 4 kHz [49], executed within a single TwinCAT 3.1 real-time task, so any controller must compute its actuator commands within 250 µs. To ensure deterministic execution times without hardware acceleration, all computation is restricted to one CPU core of an industrial PC (C6030, Intel i9-9900K) running in kernel mode independently of the host operating system.
3
The electromagnetic force of one magnet is obtained from the Lorentz integral over the stator conductor volume Vc , Z F(p) = J(r) × B(r; p) d3 r, (1) Vc
with point r in Vc , stator current density J, and mover field B. Evaluating this integral accurately online is computationally too expensive for real-time control [9]. To enable realtime control, industrial MagLev typically exploits hardware– software co-design. Mover and stator are designed such that this integral is well approximated by an analytical harmonic commutation model [2], [6]–[8]. The harmonic commutation model assumes that each stator unit interacts only with the Halbach array of matching orientation, so it is sufficient to consider one such pair. For an infinite and isolated Halbach array with ideal magnetic field [51], it retains only the first harmonic of the field and of the stator current distribution and assumes aligned full-period coverage, Bx = B̂1 e−kz sin η, Bz = B̂1 e−kz cos η, Jy = Jˆ1 (d sin η − q cos η),
(2)
in stator coordinates x, y, z of a vertical stator unit with conductors along y and aligned array wave direction x (see Fig. 2), with pole pitch τ , wavenumber k = 2π/τ , air gap z, array offset x0 , electrical coordinate η = k(x − x0 ), and amplitudes B̂1 , Jˆ1 . The rectangular magnets and discrete conductor segments introduce odd higher harmonics, which this model neglects. Combining these terms in the Lorentz integral (1) gives the levitation and thrust forces of the harmonic commutation Fz (p) = αd, Fx (p) = αq, α = π B̂1 e−kz Jˆ1 , (3) under which d-currents map purely to levitation forces and qcurrents purely to lateral thrusts. The two vertical and two horizontal arrays of the mover thus yield local force pairs (Fz , Fx ) and (Fz , Fy ), stacked into f ∈ R8 . Each pair acts at a fixed position relative to the mover center of mass, so a pose-independent matrix G maps f to the wrench w⋆ = G f . A stator unit j overlapped by a Halbach array inherits its (dj , qj ) current command, while units with no overlap receive (dj , qj ) = (0, 0). With the electrical angle ϕj (p) = k (xj −x0 ) at stator unit position xj , the hardware internally computes the currents Ijs of the three phase coils s ∈ {A, B, C} of each stator unit by Ijs = dj sin(ϕj − δs ) + qj cos(ϕj − δs ),
(4)
with coil offsets δA = 0, δB = −2π/3, and δC = 2π/3. This compact commutation step can be evaluated in hard real-time.
C. Model Mismatch and Engineering Limits B. How Harmonic Commutation Enables Real-Time Control MagLev controllers usually consist of manually engineered modules like pose estimation, feedback control, and commutation, all of which must be evaluated within a single 250 µs control cycle (Sec. III-A). The pose estimation module infers the 6D mover pose p from the HES readings [50]. The feedback controller then computes a 6D wrench w⋆ , which must be realized as current commands for all stator units.
Control engineering exploits Eq. (3) by assuming firstharmonics and aligned full-period coverage. However, the true wrench deviates due to many neglected effects: higher harmonics, finite-array and end fields, neighboring-array coupling, nonzero across-field components, discrete-conductor layout, and manufacturing tolerances. Together, these errors appear as force ripple, gain errors, and pose-dependent cross-coupling. Thus, d-current also produces thrust and q-current lift.
4
IEEE ROBOTICS AND AUTOMATION LETTERS. PREPRINT VERSION. ACCEPTED NOVEMBER, 2026
In addition, manually engineered controllers are highly geometry-specific. Co-design of stator units and Halbach arrays assumes that the wave direction of each Halbach array stays aligned with the conductor direction of its stator unit, which holds only at small yaw. For a mover rotated by yaw ψ, with array offset (x0 , y0 ), the electrical coordinate η = k (x − x0 ) cos ψ + (y − y0 ) sin ψ varies along each conductor, and the in-plane array field along x is scaled by cos ψ. Integrating along the conductor length under the array, about one period τ for the APM4330, turns Eq. (3) into Fz = αd cos ψ sinc(π sin ψ),
Fx = αq sinc(π sin ψ), (5)
with sinc(u) = sin u/u. At ψ = 5◦ , the lift of the aligned units is still 98 % of its nominal value, but at 30◦ only 55 %, and at 45◦ only 25 %. The commutation model thus allocates current less efficiently at larger yaw angles, and more current is needed for the same force. This is tractable, but it requires additional model structure, calibration, or compensation (Sec. II). However, each such addition is another module whose own mismatch can contaminate the control pipeline. Therefore, the yaw angle is usually constrained (Sec. III-A). A plain bar magnet does not meet these co-design assumptions, as it has no Halbach structure from which a harmonic commutation model could be derived, and it lacks the continuous rotational symmetry that keeps lookup tables tractable (Sec. II). Therefore, no engineered controller exists for such a ”mover” on this platform, which makes it a direct test of whether control can be achieved without an engineered actuation model. Both limitations, the constrained yaw range and the restriction to co-designed topologies, are therefore not directly physical constraints of the mover but rather consequences of the engineered actuation model that makes the software real-time capable. IV. M AGFLOW Data-driven learning removes the reliance on real-timetractable approximations and hand-engineered models. Instead, a differentiable physics simulator computes the full electromagnetic physics offline, where real-time capability no longer matters, and provides gradients for the controller’s actions. However, no such simulator exists for 6D MagLev. We therefore introduce Magflow, implemented entirely in JAX to exploit its automatic differentiation and just-in-time GPU compilation. This lets Magflow compile the full closed-loop rollout (physics and neural controller) into a single GPU computational graph, running many environments in parallel. In each rollout, given the controller’s prediction, Magflow computes the full Lorentz force, integrates the mover dynamics, and samples the Hall sensors that form the controller’s next input (see Fig. 1). Differentiating through the rollout trains the neural controller by backpropagation through time (BPTT). A. Differentiable Electromagnetic Simulation Overview. Magflow computes the field at the Hall sensors, observed by the controller, and the force and torque on the mover, which drive its dynamics. Both arise from two superimposable, differentiable field sources, the mover’s permanent magnets and the stator’s coils.
Frames. Positions r are expressed in a world frame with origin at the center of the tile surface and z pointing upward. The mover pose pt = (st , Rt ) places the mover frame at the center of the mover’s bottom face st with orientation Rt ∈ SO(3). Mover field. The mover holds M magnets m = 1, . . . , M (M = 20 for the APM4330, M = 1 for the bar magnet). Each is a uniformly magnetized cuboid with center ρm , side lengths 2am × 2bm × 2cm along the mover axes, and magnetization Mm , all in mover coordinates (remanence Br ≈ 1.3626 T for the APM4330, Br ≈ 1.395 T for the bar magnet). At a point r̃ relative to its center, a cuboid with half sizes a, b, c and magnetization M generates the closed-form Akoun– Yonnet field [52]. With the corner signs σ = (σx , σy , σz ) ∈ {−1, +1}3 and the corner vectors uσ = r̃ + σ ⊙ (a, b, c), it is 1 X σx σy σz β(uσ ; M) (6) bcub (r̃) = 4π σ where β is the Akoun–Yonnet primitive. Writing bm for the field of Eq. (6) with the parameters of magnet m, transforming a world point into mover coordinates, and rotating the sum back gives the mover field Bmover (r) ∈ R3 , t Bmover (r) = Rt t
M X
bm R⊤ t (r − st ) − ρm .
(7)
m=1
Stator field. Each phase coil consists of rectangular conductor tracks stacked across multiple copper layers. To resemble the coils closely, we represent the PCB coils by four layers and the width of each track by five parallel thin wires, each divided into straight segments of 3 mm. Compared with 20 wires and 1 mm segments, this changes the wrench by about 1 %, and the number of layers matters more than the number of wires. Segment ℓ belongs to stator unit j and phase s and runs from + + − s r− ℓ to rℓ along its current Ij of Eq. (4), with ∆lℓ = rℓ − rℓ . ± With d± = r − rℓ , the Biot–Savart law gives its field [53] − µ0 Ijs ∆lℓ × d− d d+ bℓ (r) = ∆lℓ · − , (8) 4π ∥∆lℓ × d− ∥2 ∥d− ∥ ∥d+ ∥ where µ0 is the vacuum permeability. Since coils and sensors are fixed to the tile and the field is linear in the current, we precompute it once at the 50 triaxial HES as a sensitivity matrix S ∈ R150×72 . With the 72 phase currents Ijs stacked into it ∈ R72 , the stator field at the HES is Bstator (it ) = S it . t
(9)
Sensor model. The HES sense the superposition of both fields. Evaluating Eq. (7) at the set rHES of the 50 sensor positions and stacking the results gives Bmover (rHES ) ∈ R150 , so the t observation is ot = csens Bmover (rHES ) + Bstator (it ) + η t , (10) t t with sensor scaling csens and additive noise η t . Forces and Torques. We compute the electromagnetic force on each stator wire segment defined in Eq. (8), then map it to the force and torque on the mover by Newton’s third law [6]–[8]. The mover field at each segment midpoint + rℓ = 12 (r− ℓ + rℓ ) gives the force on segment ℓ stator fℓ,t = Ijs ∆lℓ × Bmover (rℓ ), t
(11)
where Ijs is the current of Eq. (4) assigned to segment ℓ, and
HARTMANN et al.: MAGFLOW: DIFFERENTIABLE SIMULATION OF INDUSTRIAL-GRADE 6D MAGNETIC LEVITATION
ℓ
τ mover =− t
X
rℓ − sCoM t
stator × fℓ,t + τ ext t ,
1000
0
(13) −500
ℓ
sCoM t
(17)
where vt , ω t are the mover’s linear and angular velocity, = ω t ×(Iw ω t ) is the gyroscopic term from the Newton– τ gyro t Euler equations [55], and [ω]× ∈ R3×3 is the skew-symmetric matrix built from ω, satisfying [ω]× a = ω × a for any vector a. Updating the rotation matrix R via the exponential map is a Lie group integration method that keeps the orientation on the SO(3) manifold without periodic re-normalization [56]. Using the updated velocity vt+1 for the position step improves numerical stability over explicit Euler [54], [56]. For contact handling, only mover–tile contact is considered, using the lowest point of the mover zmin = sz,t+1 − |R31 |hx − |R32 |hy − (|R33 | − R33 ) hz , (18) with R3j the third row of Rt+1 and hx , hy , hz half the mover’s side lengths. On contact, the mover is lifted onto the tile and damped. Training integrates the translation at st , while rollouts (Sec. V) use the center of mass and frictional contact. B. Training of Neural Controller Inputs and reference. Aligning to prior work [28], the neural controller is a recurrent map from raw HES readings and the reference pose to actuator commands. The reference is encoded as p̃t ∈ R8 , stacking the position (x, y, z), the mover surface normal (R13 , R23 , R33 ), and the yaw angle ψ as (cos nψ, sin nψ). Neglecting manufacturing uncertainties, the
20
By [mT]
10
0
−10
500
Bz [mT]
where is the center-of-mass position of the mover, mmover is the mass of the mover, g is gravity, and ftext , τ ext optional external disturbances. Since Eq. (11) is linear in t current, the electromagnetic wrench can be rephrased as At it , with the current-to-wrench matrix At ∈ R6×72 reassembled at the mover pose at each time step t. The current command thus enters only through At , so its gradient is exactly At and never backpropagates through the per-segment field summation. For efficiency, At is held fixed over four control cycles, which we found to be the best trade-off between computation time and accuracy. On the training references, this speeds up training 3.5 times at relative force and torque errors of 0.5 % and 0.8 %. Dynamics. The forces and torques from Eq. (12) and Eq. (13) are applied over one control cycle ∆t = 250 µs using semi-implicit Euler integration [54]. Let mmover denote the mover mass, Imover its constant body-frame inertia tensor, and Iw = Rt Imover R⊤ t the corresponding world-frame inertia tensor. With diagonal linear and angular damping matrices Dv , Dω ∈ R3×3 , the mover state updates as Fmover − Dv vt ∆t, (14) vt+1 = vt + t mmover st+1 = st + vt+1 ∆t, (15) gyro −1 mover ω t+1 = ω t + Iw τ t − τt − Dω ω t ∆t, (16) Rt+1 = e[ωt+1 ]× ∆t Rt ,
measurement magflow harmonic commutation
500
Bx [mT]
∆lℓ its directed segment vector. By Newton’s third law, the mover experiences the opposite reaction, so at time step t the total mover force Fmover and torque τ mover are t t X mover stator ext Ft =− fℓ,t + mmover g + ft , (12)
5
y = 40 mm
0
−500
−80
−60
−40
−20
0
20
40
60
mover-local x [mm] at y = 40 mm Fig. 3. Magnetic field components of the mover along a cut at moverlocal y = 40 mm, z = −1 mm, comparing measurements (black), the Magflow simulation (blue), and the harmonic commutation model (red). The first-harmonic model deviates systematically from the measurements, while Magflow matches them.
APM4330 mover has 90◦ yaw symmetry, so n = 4 distinct yaw angles per full rotation are physically indistinguishable configurations (n = 2 for the bar magnet). Encoding yaw this way makes the reference invariant to this symmetry, which we exploit to make learning more efficient. Therefore, full 360◦ yaw rotation is only realizable by continuously tracking through the repeated encoding over time. With HES readings ot ∈ R150 and hidden state ht , the recurrent map is at , ht+1 = πMF (ot , p̃t , ht ).
(19)
Action encoding. Each stator unit is driven by field-oriented control (Sec. III-A) from a triplet (dj , qj , ϕj ). For each of the 24 stator units j, the neural controller πMF predicts a stationary-frame (Clarke) current pair (uj , vj ), stacked into the 48-dimensional action at . To convert this into the fieldoriented control required by the hardware interface, we compute dj = ∥(uj , vj )∥2 and ϕj = atan2(vj , uj ) with qj = 0. This vector maps bijectively to the coil currents, unlike the (d, q, sin ϕ, cos ϕ) output of prior work [28]. A controller trained from scratch has no canonical choice and can change between equivalent representations along a BPTT rollout, leading to gradient spikes. The new encoding avoids this. Architecture and objective. The architecture is a 4-layer gated recurrent unit (GRU) with 256 hidden units per layer, the same as the behavior-cloning proof of concept [28], whose
IEEE ROBOTICS AND AUTOMATION LETTERS. PREPRINT VERSION. ACCEPTED NOVEMBER, 2026
180
yaw [◦ ]
reference πMF (sim) πBC (sim) πMF πBC
360
360
roll [◦ ]
360
180
180 0
15
15
5
−15 15 0 −15
0 −15 15
y [mm]
0
x [mm]
0
x [mm]
0
y [mm]
y [mm]
x [mm]
yaw [◦ ]
6
0 −15
0 −5 5 0 −5
2
loss of control
0
z [mm]
z [mm]
z [mm]
6 4
4 2 0
0
1
2
3
4
5
4 2 0
0
time [s]
1
2
time [s]
0
5
10
15
time [s]
Fig. 4. Neural controllers trained end-to-end in Magflow (πMF , blue) and deployed zero-shot achieve novel capabilities. Closed-loop rollouts of the deployed controllers in Magflow on the same references are shown in green (πMF ) and brown (πBC ). (left) Full 360◦ yaw rotation of the APM4330 mover away from the tile center. The behavior-cloned baseline πBC (orange) directly loses control. (middle) A neural controller retrained in Magflow for a plain bar magnet, a topology with no harmonic commutation model, levitates it stably and tracks a full 360◦ yaw rotation away from the tile center. (right) Continuous 360◦ rotation of the bar magnet about a horizontal axis, to our knowledge not shown before for a single magnet on a planar MagLev system.
implementation optimized for Advanced Vector Extensions 2 (AVX2) has a worst-case inference latency of 242 µs, satisfying the 250 µs hard real-time constraint. Training uses truncated BPTT through the closed loop at the hardware control rate to match deployment. We use BPTT, since the smooth electromagnetic physics provide analytic gradients, whereas reinforcement learning would have to explore 48 continuous actions of an unstable system, where random actions quickly crash the mover, and assign credit over transients spanning hundreds of steps at 4 kHz. A controller trained at a lower rate would not match the fixed deployment cycle. Gradients flow over windows of K = 500 steps before each optimizer step (AdamW, learning rate 5×10−5 , gradient clipping at 100), then the rollout continues from the carried hidden and physical state to the horizon H. A curriculum grows H from 100 steps by 1.25× once 80% of the worlds do not crash. Rollouts run in parallel across 16 randomized worlds, half tracking a hover with a discontinuous reference pose step and half a smooth random 6D trajectory over the whole tile. In each world, a random external 6D wrench, a per-world constant bias plus an Ornstein–Uhlenbeck process, acts on the mover to make the learned neural controller πMF robust against external disturbances. Training takes five days, as the full interaction of the 20 magnets of the APM4330 with 130 368 coil segments (∥∆lℓ ∥ = 3 mm, Eq. (11)) is recomputed every four cycles. This fully utilizes an NVIDIA A40 at 3 ms per step including the backward pass. The objective over the network parameters θ sums per-step tracking, safety, and smoothness costs, H X L(θ) = E Ltrack + Lsafe + Lsmooth , (20) t=0
where Ltrack = λpos ∥st − s⋆t ∥22 + λrot d2SO(3) (Rt , R⋆t ) with λpos = λrot = 1 penalizes position (mm) and geodesic orientation (◦ ) error. The safety term Lsafe combines four penalties. To avoid collisions, a sigmoid barrier λz sigmoid (zc − zmin )/Tz with λz = 10 rises as the mover’s lowest point zmin approaches the threshold zc = 0.5 mm, with temperature Tz = 0.2 mm. To protect the coils, λc relu(dj − Imax )2 with λc = 500 bounds the current of each unit to Imax = 33 A. It acts only above Imax , as a general current penalty would trade off against tracking, in particular against lift in z. Below Imax , the currents of coil units not covered by the mover remain unconstrained, as they barely affect the mover and thus P no loss term2 depends on them. The−5locality penalty over the set Ut j∈Ut (λ1 dj +λ2 dj ) with λ1 = λ2 = 5×10 of these uncovered units therefore drives their currents to zero. The power supply empirically permits 140 W continuously and up to 240 W for short periods, with the available limit Ptlim decreasing as a time-to-shutdown budget reported by the hardware. If the commanded p power Pt exceeds it, all currents are derated by γt = Ptlim /Pt as on the hardware, and λP relu(1 − γt )2 with λP = 500 penalizes this derating. Finally, Lsmooth = λ∆i ∥∆2 it ∥22 + λ∆w ∥∆2 (At it )∥22 with λ∆i = 1 and λ∆w = 10 penalizes the curvature of the commanded phase currents and of the realized wrench. Domain randomization. Real movers and tiles are subject to manufacturing tolerances, and the real system’s true parameters are unknown and vary from unit to unit. To make the neural controller πMF robust against these uncertainties, we follow related works [43]–[46] and apply domain randomization by sampling new physical parameters for every world and rollout. We randomize the mover (magnet remanence, per-magnet
HARTMANN et al.: MAGFLOW: DIFFERENTIABLE SIMULATION OF INDUSTRIAL-GRADE 6D MAGNETIC LEVITATION
7
TABLE I RMS TRACKING ERROR ON A RANDOM TRAJECTORY MEASURED BY MOTION CAPTURE . S IM ROWS ARE CLOSED - LOOP Magflow ROLLOUTS . Orientation [◦ ]
Position [mm] Controller
x
y
z
roll
pitch
yaw
πPC πBC πMF
0.09 0.15 0.34
0.07 0.14 0.30
0.06 0.09 0.14
0.10 0.12 0.24
0.07 0.11 0.25
0.05 0.10 0.26
πBC (sim) πMF (sim)
0.16 0.31
0.18 0.24
0.08 0.15
0.10 0.19
0.10 0.21
0.24 0.22
position and orientation, mass, inertia, and center of mass), the sensing (per-HES position and measurement noise), and the actuation (per-coil current gain and the current lag time), together with the per-rollout external wrench disturbance. The exact ranges are in the released code. V. E XPERIMENTAL E VALUATION Our evaluation consists of three parts. We first compare the physics behind the two control paradigms. Engineered controllers compute currents from the reduced first-harmonic model, while Magflow trains the neural controller πMF using a magnetic field simulation. We then deploy the three neural controllers trained in Magflow on the real hardware, show qualitatively new motions never before demonstrated on this MagLev system, and evaluate their accuracy within the engineered range and their robustness to payload. A. First-Harmonic Model vs. Magflow We compare the first-harmonic model of Eq. (2) and the Magflow field of Eq. (7) against measurements of the real APM4330 mover. Fig. 3 shows the magnetic field along a cut below the mover. The first-harmonic model deviates systematically for the reasons discussed in Sec. III-C. Magflow matches the measurements closely along the entire cut. The neural controller is therefore trained against a field model that reproduces the hardware, instead of the approximated model that hand-crafted controllers use.
Fig. 5. The neural controller πMF hovers the APM4330 mover stably under a tested payload of 1.3 kg.
Bar magnet topology. We retarget training to a plain bar magnet (100 × 30 × 10 mm, neodymium N48) by replacing the mover model in Magflow and retraining. For this topology the co-design assumptions do not hold and no engineered controller exists (Sec. III-C). The retrained controller levitates the bar magnet and tracks a full 360◦ yaw rotation while tracking a circle in xy with 15 mm radius. Unlike a disc magnet, the bar magnet is controlled in 6D, including yaw. Rotation about a horizontal axis. The neural controller further rotates the levitating bar magnet 360◦ about a horizontal axis. During this rotation, the bar magnet occasionally touches the tile. Unlimited rotation was previously only shown for a co-designed body of six magnets with optical tracking [27]. To our knowledge, this is the first continuous 360◦ rotation of a single magnet about a horizontal axis on a planar MagLev system, with pose sensing only by the embedded HES. Accuracy within the engineered range. Table I compares all controllers on a smooth random 60 s trajectory, measured with a Vicon motion capture system. It moves continuously within the workspace of πPC and πBC at a median speed of 33 mm s−1 , whereas πMF is trained for full 360◦ yaw. πPC is the proprietary controller, engineered and tuned over decades, and πBC imitates it [28]. πMF is less precise than both, but learns purely from simulated physics without any engineered module or teacher. Its closed-loop rollouts in Magflow match the real position errors within 0.06 mm, a gap far smaller than the gap to πPC . Precision is therefore limited by the neural controller rather than by Magflow. C. Robustness to Payload
B. Zero-Shot Capabilities Beyond Engineered Control We train three neural controllers πMF exclusively in Magflow, each for five days on a single NVIDIA A40 GPU, and deploy them zero-shot on the real system at 4 kHz. The first controls the APM4330 with full 360◦ yaw over the whole tile, the second the bar magnet with full 360◦ yaw, and the third the bar magnet with full 360◦ yaw and roll. Aligning to prior work [28], reported poses are HES-based estimates, except for Table I, which uses VICON-based motion capture. Fig. 4 shows three experiments, each demonstrating a capability that no previous controller of this platform has shown, together with Magflow closed-loop simulations of the deployed controllers on the same references. Yaw beyond engineered limits. We command a full 360◦ yaw rotation of the APM4330 mover while tracking a circle in xy with 15 mm radius. πMF tracks the full rotation without loss of control. The behavior-cloned controller πBC [28] inherits the workspace of its teacher and immediately loses control.
The random 6D wrench disturbance (ftext , τ ext t ) of Eqs. (12) and (13) and the randomized mover mass (Sec. IV-B) make πMF robust against external disturbances. Fig. 5 shows that this robustness extends to real payloads, with the APM4330 mover hovering stably under a tested payload of 1.3 kg. VI. C ONCLUSION AND F UTURE W ORK Magflow moves the electromagnetic computation of 6D MagLev control out of the real-time loop and into offline training. The resulting neural controllers transfer zero-shot to industrial hardware and achieve capabilities that no prior controller of the utilized MagLev system has shown. Future work can extend Magflow in several directions. Scaling to multi-tiles can exploit the symmetries of sensing and actuation across tiles, but requires handling movers that cross tile boundaries. Multi-movers are even more demanding, as nearby movers potentially share coils and Hall sensors. Closing the precision gap to engineered control, which our results attribute to the
8
IEEE ROBOTICS AND AUTOMATION LETTERS. PREPRINT VERSION. ACCEPTED NOVEMBER, 2026
neural controller rather than to Magflow, calls for larger or more expressive neural controllers, enabled by faster inference hardware within the 250 µs cycle. However, quantifying such improvements at the micrometer scale may require precise external measurements like laser interferometry. Magflow also approximates the physics. It models coils as thin wires and magnets as ideal, uniformly magnetized cuboids, neglects ferromagnetic material and demagnetization, and treats the mover as a rigid body. Calibrating sensors and magnets with real data, or learning a residual correction of the simulation [41], could further reduce the gap between simulation and reality. As a GPU-parallel simulator, Magflow equally supports other learning schemes such as reinforcement learning, which could be compared with or combined with BPTT. Finally, predicting action chunks or refining the simulation frequency as a curriculum could reduce inference and training cost. R EFERENCES [1] L. Bergmann, N. Greis, and K. Neumann, “From transportation to manipulation: Transforming magnetic levitation to magnetic robotics,” 2026. [2] X. Lu and I.-u.-r. Usman, “6D direct-drive technology for planar motion stages,” CIRP Ann., 2012. [3] L. Zhou and J. Wu, “Magnetic levitation technology for precision motion systems: A review and future perspectives,” IJAT, 2022. [4] Beckhoff Automation, “XPlanar — planar motor system,” 2026. [5] Beckhoff Automation, “APS4322-0000-0000 — XPlanar tile,” 2026. [6] W.-j. Kim, D. L. Trumper, and J. H. Lang, “Modeling and vector control of planar magnetic levitator,” IEEE Trans. Ind. Applicat., 1998. [7] J. W. Jansen, et al., “Magnetically levitated planar actuator with moving magnets,” IEEE Trans. Ind. Applicat., 2008. [8] C. M. M. van Lierop, et al., “Model-based commutation of a long-stroke magnetically levitated linear actuator,” IEEE Trans. Ind. Applicat., 2009. [9] J. de Boeij and E. Lomonova, “Experimental verification of look-up table based real-time commutation of 6-DOF planar actuators,” J. Syst. Des. Dyn., 2009. [10] J. de Boeij, M. Steinbuch, and H. Gutierrez, “Real-time control of the 3-DOF sled dynamics of a null-flux maglev system with a passive sled,” IEEE Trans. Magn., 2006. [11] P. Berkelman and M. Dzadovsky, “Magnetic levitation over large translation and rotation ranges in all directions,” IEEE/ASME Trans. Mechatronics, 2013. [12] P. Berkelman and Y.-H. Lu, “Long range six degree-of-freedom magnetic levitation using low cost sensing and control,” J. Robot. Mechatronics, 2020. [13] F. Xu, et al., “Motion control of a magnetic levitation actuator based on a wrench model considering yaw angle,” IEEE Trans. Ind. Electron., 2020. [14] P. Berkelman and M. Dzadovsky, “Novel design, characterization, and control method for large motion range magnetic levitation,” IEEE Magn. Lett., 2010. [15] P. Berkelman, S. Kang, and S. Trafford, “Online self calibration for a long motion range multiple coil magnetic levitation system to improve vertical positioning accuracy,” in Proc. AIM, 2026. [16] H. Zhu, T. J. Teo, and C. K. Pang, “Design and modeling of a sixdegree-of-freedom magnetically levitated positioner using square coils and 1-D Halbach arrays,” IEEE Trans. Ind. Electron., 2017. [17] F. Xu, X. Xu, and M. Chen, “Unified wrench model of an ironless permanent magnet planar motor with 2D periodic magnetic field,” IET Electr. Power Appl., 2018. [18] F. Xu et al., “A 6-DOF extended unified wrench model for maglev planar motor,” IEEE/ASME Trans. Mechatron., 2024. [19] Z. Xu, et al., “Predictor-based model predictive control for maglev planar motor with a 2D Halbach array mover,” Control Eng. Pract., 2023. [20] I.-u.-r. Usman and X. Lu, “Force ripple attenuation of 6-DOF direct drive permanent magnet planar levitating synchronous motors,” IEEE Trans. Magn., 2015. [21] F. Xu et al., “Real-time data-driven force and torque modeling on a 2-D Halbach array by a symmetric coil considering end effect,” IEEE Trans. Magn., 2022.
[22] H. Zhu, T. J. Teo, and C. K. Pang, “Analysis of force harmonics and eddy current damping for 2 DOF moving magnet linear motor,” in Proc. IECON, 2015. [23] Y. Wang, et al., “Analysis and optimization of a novel 2-D magnet array with gaps and staggers for a moving-magnet planar motor,” Sensors, 2018. [24] M. Zou, et al., “Force and torque model of magnetically levitated system with 2D Halbach array and printed circuit board coils,” Sensors, 2023. [25] Beckhoff Automation, “Stator module and planar drive system,” US Patent US11437902B2, 2022. [26] Beckhoff Automation, “Planar-drive system, stator module and sensor module,” US Patent US11437893B2, 2022. [27] M. Miyasaka and P. Berkelman, “Magnetic levitation with unlimited omnidirectional rotation range,” Mechatronics, 2014. [28] P. Hartmann, J. Stranghöner, and K. Neumann, “End-to-end low-level neural control of an industrial-grade 6D magnetic levitation system,” in Proc. ICRA, 2026. [29] N. Lambert, et al., “Low-level control of a quadrotor with deep modelbased reinforcement learning,” IEEE Robot. Autom. Lett., 2019. [30] R. Ferede, et al., “End-to-end neural network based optimal quadcopter control,” Robot. Auton. Syst., 2024. [31] M. Schenke and O. Wallscheid, “A deep q-learning direct torque controller for permanent magnet synchronous motors,” IEEE Open J. Ind. Electron. Soc., 2021. [32] J. Degrave, et al., “Magnetic control of tokamak plasmas through deep reinforcement learning,” Nature, 2022. [33] J. Stranghöner, et al., “SHaRe-RL: Structured, interactive reinforcement learning for contact-rich industrial assembly tasks,” in Proc. ICRA, 2026. [34] S. Levine, et al., “End-to-end training of deep visuomotor policies,” J. Mach. Learn. Res., 2016. [35] D. Driess, et al., “Learning to control redundant musculoskeletal systems with neural networks and SQP: Exploiting muscle properties,” in Proc. ICRA, 2018. [36] P. J. Werbos, “Backpropagation through time: what it does and how to do it,” Proc. IEEE, 1990. [37] F. d. A. Belbute-Peres, et al., “End-to-end differentiable physics for learning and control,” in Proc. NeurIPS, 2018. [38] C. D. Freeman, et al., “Brax — A differentiable physics engine for large scale rigid body simulation,” in Proc. NeurIPS, 2021. [39] M. Schuck, et al., “Crazyflow: An accurate, GPU-accelerated, differentiable drone simulator in JAX,” 2026. [40] F. Heeg et al., “Learning quadrotor control from visual features using differentiable simulation,” in Proc. ICRA, 2025. [41] J. Pan, et al., “Learning on the fly: Rapid policy adaptation via differentiable simulation,” 2026. [42] H. J. T. Suh, et al., “Do differentiable simulators give better policy gradients?” in Proc. ICML, 2022. [43] J. Tobin, et al., “Domain randomization for transferring deep neural networks from simulation to the real world,” in Proc. IROS, 2017. [44] M. Andrychowicz et al., “Learning dexterous in-hand manipulation,” Int. J. Robot. Res., 2020. [45] X. B. Peng, et al., “Sim-to-real transfer of robotic control with dynamics randomization,” in Proc. ICRA, 2018. [46] A. Gräfe, et al., “How to model your Crazyflie brushless,” in Proc. ICRA, 2026. [47] Beckhoff Automation, “APM4330-0000-0000 XPlanar mover,” 2026. [48] Beckhoff Automation, “Load capacity reduction during rotation,” 2026. [49] Beckhoff Automation, “TF5890 TwinCAT 3 XPlanar: Add task,” 2026. [50] F. Schulte, “Das Planarmotorantriebssystem XPlanar,” in Getriebetagung 2022. Logos Verlag Berlin, 2022. [51] P. Jin, et al., “General Analytical Method for Magnetic Field Analysis of Halbach Magnet Arrays Based on Magnetic Scalar Potential,” J. Magn., 2013. [52] G. Akoun and J.-P. Yonnet, “3D analytical calculation of the forces exerted between two cuboidal magnets,” IEEE Trans. Magn., 1984. [53] D. J. Griffiths, Introduction to Electrodynamics, 4th ed. Cambridge Univ. Press, 2017. [54] J.-S. Lee, et al., “A linear-time variational integrator for multibody systems,” IEEE Robot. Autom. Lett., 2020. [55] S. Holzinger, M. Arnold, and J. Gerstmayr, “Evaluation and implementation of lie group integration methods for rigid multibody systems,” Multibody Syst. Dyn., 2024. [56] O. Brüls and A. Cardona, “On the use of lie group time integrators in multibody dynamics,” Multibody Syst. Dyn., 2010.
Related documents
- Magflow: Differentiable Simulation of Industrial-Grade 6D Magnetic Levitation#1699524
- Magpie: A Graphical Magnon Software#1327040
- Reinventing Gravity#1315991
- Fast realistic modeling in bioelectromagnetism using lead‐field interpolation#175723
- MAGNETIC TUNNEL JUNCTION-BASED STOCHASTIC HARDWARE FOR NEURAL AND ARTIFICIAL INTELLIGENCE SYSTEMS#254783
Retrieved via Conceptio: every document is proof-bundled with source, license, and retrieval metadata.
Read the Docs → · View CLI source on GitHub · Conceptio Open Knowledge Archive