Robotic Vectorial Field Alignment for Spin‐Based Quantum Sensors

Abstract Developing practical quantum technologies will require the exquisite manipulation of fragile systems in a robust and repeatable way. As quantum technologies move toward real world applications, from biological sensing to communication in space, increasing experimental complexity introduces constraints that can be alleviated by the introduction of new technologies. Robotics has shown tremendous progress in realizing increasingly smart, autonomous, and highly dexterous machines. Here, a robotic arm equipped with a magnet is demonstrated to sensitize an NV center quantum magnetometer in challenging conditions unachievable with standard techniques. Vector magnetic fields are generated with 1° angular and 0.1 mT amplitude accuracy and determine the orientation of a single stochastically‐aligned spin‐based sensor in a constrained physical environment. This work opens up the prospect of integrating robotics across many quantum degrees of freedom in constrained settings, allowing for increased prototyping speed, control, and robustness in quantum technology applications.

Experiments designed to exploit quantum technologies for applications can be extremely challenging.Fragile quantum states must be delicately manipulated, whilst minimising sources of decoherence, in order to preserve a quantum advantage.This often necessitates cuttingedge experimental physics, including precise and complex optical assemblies 1,2 , strong vector magnetic fields 3 , high-speed microwave delivery 4 , and compatibility with extremely low temperature environments 5 .Emerging quantum technologies based on hybrid quantum systems 6 combine research from two or more experimental settings: such as coupling spins in silicon to superconducting resonators and qubits 7,8 , interfacing remote NV centres in diamond with photonic qubits 9 , and using nanomechanics to interface with spins 10 or superconducting qubits 11 .
As these proof-of-principle devices become more sophisticated and start to scale in size and complexity, established lab infrastructure such as translation stages and solenoid coils will no longer provide the flexibility, speed, and precision to meet these constrained 12 and sometimes competing experimental requirements.In contrast, the field of robotics has long adapted to operate robots in challenging conditions, such as at the microscale 13 or in very low temperature environments 14 .Robotics can provide more flexible and adaptable approaches than traditional methods, that would speed up the deployment of quantum technology across applications.With sophisticated software stacks and well-developed open-source hardware, the deployment of robotics in a diverse range of experimental settings in the chemical and biological sciences has become increasingly feasible 15,16 .
Here, we introduce and validate the idea of a robotassisted quantum technology.Specifically, we employ the use of a robotic arm to hold a strong permanent magnet for meeting a requirement in spin-based sensing: aligning an external magnetic field along the magnetic dipole axis of an arbitrarily oriented spin system (Fig. 1A).We demonstrate that this method has significant advantages where traditional techniques for generating vector fields, such as mounting the magnet on a fixed axis translation stage, or using a 3-axis Helmholtz coil, are infeasible owing to the tight physical constraints of the surrounding optomechanical apparatus.While this work focuses on a specific use case for robotics in quantum technology, the methods developed here can be easily adapted and extended to other experimental settings.Problem statement and requirements Spin-based magnetometers operate by mapping local perturbations in their environment to shifts in the transition (magnetic resonance absorption) frequency of the spin system 17 .The NV centre in diamond is the prototypical solid state quantum sensor on account of its optically accessible spin state which allows optical manipulation and readout of its spin state at room temperature (Optically Detected Magnetic Resonance or ODMR).NV centre magnetometers have rapidly advanced over the past decade and have reached maturity as a quantum magnetometer, with nanotesla (nT) sensitivities at nanoscale resolutions 18,19 .As magnetic dipole-dipole interactions are weak and confined to the near field, near-surface NV centres are required to image fields from individual spins 20 .Nanoscale inclusions of diamond, or nanodiamond, are used to host the spin-probe in hot and wet biochemical surroundings in applications such as protein 21,22 or cell detection 23,24 .Nanodiamonds typically contribute an additional energy term Π to the NV centre Hamiltonian H, from lattice strain and local charges 25,26 : lattice.In Fig. 1B, the energy term Π leads to a frequency splitting of size 2Π (shown in grey), making the NV centre transition frequencies robust to magnetic field fluctuations to first order.A bias field B z is thus required bring to the NV centre into the regime (B z ≫ Π/γ) where the transitions are linearly dependent on the magnetic field, which corresponds to the highest sensitivity.Given nanodiamonds typically display Π ∼ 10 MHz 27 , this requires a moderate B z magnetic field of 5 mT aligned to the NV axis.A misaligned magnetic field (with a residual B x or B y component) would lead to a mixing of the energy eigenstates, which would result in a reduction of both the fluorescence and contrast (SNR) of the spin-dependent optical readout 28 .Magnetic fields of 5 mT significantly degrade the spin coherence time (T 2 ) of the NV centre when misaligned by 5 • as they cause nearby nuclear spins to precess 29,30 .
To date, the established method to align a static magnetic field to an arbitrarily oriented spin is using three perpendicular wire coils [31][32][33] or sets of coils in the Helmholtz configuration 27,34,35 .To produce appreciable field strengths (≈ 10 mT), coils comprise of hundreds of wire turns.The wire gauge is chosen to balance wire packing and current density.Coils operate hot, which has adverse implications for sensitive samples, such as in biosensing 36 .The configuration is convenient for producing vector magnetic fields, after calibration, as the current in each coil can be ratioed to produce a desired orientation.The constraint of requiring coils at three axes around the sample severely restricts optical or mechanical degrees of freedom.An alternative method is to place and orient a strong neodymium permanent magnet (NdFeB) in the vicinity of the sample.The advantage here is that the small magnet can produce much larger field strengths than the coil.It is less restrictive in physical footprint so can be combined with optical assemblies and cryogenics.The magnets are aligned using linear [37][38][39] or rotational translation stages 40,41 .The physical limitations of these stages preclude certain orientation NV centres from being aligned 41 .Typically, the magnet is positioned once and is aligned along a set diamond crystalline axis because the calibration process is cumbersome.This precludes the use of nanodiamonds where each site may have a random dipole orientation 42 , eliminating important applications that involve inspecting spatially separated regions or tracking dynamic events in liquid environments.
We propose to combine the convenience and control of coils with the small footprint and strength of a permanent magnet in developing a robotically controlled vectorial field alignment system.Our approach has the following advantages: (1) Increased precision and control.The robot manipulates the magnet with a high degree of accuracy, ensuring precise alignment of the generated magnetic field.For our application, this means better than 5 • accuracy 29 .(2) Fast alignment: by employing a robot to move and position the magnet across optimal trajectories, alignment should be more efficient than manual techniques.(3) Long-term stability: employing closed-loop feedback with sufficient torque against gravity will maintain position securely for extended periods, ensuring stable alignment during experiments.(4) Enhanced reproducibility: A robust algorithm can align and realign the magnet between sample exchange or across multiple sites of interrogation.The robot consistently produces a given orientation field for different sample geometries.( 5) Scalability: the robot has an adaptable routine that is able to suit a wide range of experimental configurations and constraints.One can also easily extend to scenarios where two fields with specific orientations need to be simultaneously applied, for instance an in-plane and out-of-plane field.
For positioning of a magnet at a desired location in 3D space with respect to a point of interest, and allowing for rotation about two axes to achieve magnetic field orientation, we require a robot with at least five degrees of freedom.The robot must be capable of handling a moderate payload in order to carry enough magnet mass to produce an appreciable field (10 mT) at a distance.It should also be readily available, with a well developed software interface and be economical to meet the requirements of use outside the robotics community.In the following section we will evaluate this robot for the described task.

I. Results
Workspace analysis Workspace analysis is essential for robot control and application, as it evaluates the space the robot can access and manipulate with its endeffector, constrained by the robot's kinematic configuration.This analysis helps to identify the robot's suitability for specific tasks and environments.Key aspects include the reachable workspace volume (total 3D space the robot's end-effector can reach), workspace boundaries (limits of reachable space) and dexterity within this workspace (ability to precisely orient the end-effector) 43 .In this section, we perform workspace analysis on a magnet carrying robotic arm to evaluate its performance in generating vector magnetic fields.
The robotic arm consists of a set of rigid bodies called links, connected by joints, with each joint driven by a motor actuator.An end-effector, in this case a permanent magnet, is attached to the end link.The arm is an open chain robot, with the position and orientation of the end-effector uniquely determined from the joint positions.The common configuration comprises of six joints, providing six Degrees of Freedom (DoF).For our experiments, we use a Niryo NED 2 robot owing to its well-documented open source stack, and ready availability.The arm has a moderate payload of 300 g, and is thus capable of lifting 40 cm 3 NdFeB, which can generate a surface magnetic field of ≈ 800 mT (see Supplementary Fig. 1).For ease of adoption, we select a cylindrical magnetic source with a radial hole, through which it can be fixed by a screw to the tool shaft.Shown in Fig. 1C, the robot is first set up by translating the Tool Center Point (TCP) along the x-axis of its end-effector, coaxial with the magnetisation axis of the magnet (Fig. 1A).This translation sets the distance, and hence strength, of the magnet, from the point of interrogation.
To create a set vector field, the robot uses the Robot Operating System (ROS) kinematic processor 44 to position its joints, in order to compute a desired pose.The robot pose comprises the location and orientation of the TCP relative to a global coordinate frame.Rigid robots possess six state variables (x, y, z, α x , α y , α z ), where the latter three coordinates are angles of rotation about the x, y and z axis respectively.The inverse kinematics problem is to find the joint position given a desired pose.In Supplementary Table 1, we give the Denavit-Hartenberg (D-H) representation for the kinematics of this robot.In principle, by fixing x, y, and z at the NV centre location, the vector orientation of an applied magnetic field can be modified by varying α y and α z of the pose.In our scheme, the cylindrical magnet is symmetric about α x , so this degree of freedom is left unused.In Fig. 1C, we simulate in RViz, a visualization software for ROS, that the robot is sufficiently dexterous in positioning its joints to achieve a range of orientations, whereby the magnet is rotated around a stationary point with varying α y and α z .In Supplementary Fig. 2, we calculate the full workspace volume and dexterity within this volume.
in a meander, alternating +z, −z, and artefacts of this is seen through scan lines in the measured data.Overall, we measure high angular accuracy with a mean error of 2.9 • and mode error of 2.3 • and confirm that the robotic arm is able to produce desired field orientations with a high accuracy.
Field amplitude control For a set vector orientation and magnet mass, some ODMR applications require tuning of the magnetic field amplitude, for instance so that the spin resonance frequency matches a microwave resonator 46,47 .The field amplitude can be controlled by tuning the distance between the magnet and the sample position.However, the magnetic field fall-off with r distance is highly non-linear, characterised by the Biot-Savart 1/r 3 relation.In addition, the robotic arm performs non-linear displacement, requiring dual movement of two rotational joints per linear step of the end effector.We observe in Fig. 2C that the displacement of the magnet away from the Hall sensor is sufficiently linear to produce a 1/x 3 response in B x .Because the magnetic field generated by the permanent magnet is large, it can be positioned sufficiently far away from the sensor so that the 10 mm 1/r 3 trajectory can be subsampled within the 0.5 mm resolution of the robot (lines shown in the top panel) to create a desired response B(r).In the middle panel we observe that we can create a linear field response between 0 and 10 mT through this method.In the bottom panel, we observe the error in this sampling technique is typically lower than 0.1 mT.However, as expected, this error increases for close distances to the sensor, as the available resolution to subsample the 1/r 3 field diminishes.
Collision-free motion planning With operation validated in an unconstrained environment, we move to navigating the robot around complicated lab infrastructure.By evaluating intersections with its environment, the robot is able to compute collisions in the ROS simulation using LBKPiece from the Open Motion Planning Library to traverse a tree of possible trajectories to achieve a given pose goal 48 .
We take two experimental setups in our lab, a cryostat with an optical window and a scanning stage confocal microscope (see Fig. 3A), and add their spatial meshes in simulation to the robot environment.For these complex geometries, it would not be possible to position 3-axis Helmholtz coils for magnetic field alignment due to the competing requirements for optical access to the sample and the need to move the sample in three dimensions.Single microcoils or a permanent magnet mounted on a stage would have limitations in terms of achievable proximity to the sample.
With the available kinematics of the 6 DoF robotic arm, the position of the magnet with respect to the sample is far less constrained.In Fig. 3A, using LB-KPiece, we simulate that a chosen subset of poses can be traversed with access to the top and back side of the cryostat, oriented around the TCP located at the sample mount, generating a −B x , +B y , −B z sphere segment (one-eighth) without collisions.However, we observe that for the scanning stage confocal microscope, only a subset of any sphere segment is achievable.Poses that cannot be accessed without collision are shown with red dots and form a significant part of the subset.From this simulation, it is evident that there would limited success of the robot in the magnetisation-axis-aligned configuration described in Fig. 1C.
Designing collision-free field vectors An important consideration at this point is that the set of poses in this configuration only make a small subset of the possible joint configurations of the robot, and therefore possible magnetic field vectors.By moving the TCP defined in Fig. 1C from the NV centre to the magnet, we give free control on its orientation and position, with access to the fringing fields of the magnetic source.Our hypothesis is that there exists a set of collision-free poses that would produce a full set of magnetic vectors.This idea makes uses of the magnetic inverse problem in field sensing: even if a pose cannot be reached, the desired field can be obtained because there is non-unique mapping between the field and the pose 49 .Our algorithm is laid out along Fig. 2B.Firstly, the unreachable set of poses in the constrained environment are found.For each such pose (Fig. 2B(i)), the TCP is translated along x to the magnet centre and the magnet is then linearly translated in either y or z to a new reachable pose (Fig. 2B(ii)).Next, the new pose is rotated in α y or α z to obtain the same vector field orientation as the original pose (Fig. 2B(iii)).Finally, the magnet is translated in x to recover the original magnitude (Fig. 2B(iv)).
To calculate the vector rotation in Fig. 2B(iii), we can approximate the magnet with a dipole, for which the inverse magnetostatic expression is known 49 .For a powerful permanent magnet, the arm can be withdrawn to sufficient distances so that this dipole approximation becomes valid.The orientation of a unit dipole ⃗ m at a vector ⃗ r to create a field at the sensor location ⃗ B is given by: , where µ 0 is the vacuum permeability.In Fig. 3C, we model the z displaced magnet and find the field observed at the sample location (green dot) has a significantly modified orientation (first panel).We can use Eq.2 to calculate the dipole orientation ⃗ m to find ⃗ B (middle panel).We then rotate the magnet to be coaxial with the calculated dipole orientation and recover the desired field vector ⃗ B with high accuracy, minimising B y and B z (last panel).In Fig. 3D, we show that in the We model two experimental settings, a cryostat with optical access and a confocal microscope.Plotted are the simulated collisions with the robot (in red) and avoided collisions (in blue) over the fixed position varied (αy, αz) poses.For the confocal, we observe a limited reachable workspace subset.B. We develop an algorithm to replace these unreachable poses with collision-free poses.The procedure follows: (i) a desired field vector is measured in a forbidden position, (ii) displacement puts the magnet in an allowed position, (iii) angular orientation sets the correct field vector, (iv) a further displacement corrects the field magnitude.C. Using a dipole source to calculate the rotation, we can deterministically rotate the magnet and recover the B vector (title bar) at the observer (green dot).D. The designed rotation matches experimentally in minimising the transverse field at 26 • .E. Measuring with the 3D Hall sensor at each stage following panels in B, the final vector well matches the initial vector (quantified by similarity function S defined in the text).
physical experiment, the off-axial field component is indeed minimised when set to the calculated 26 • angle, and that this algorithm succeeds within the pose resolution limit of the robot.
As well as correcting orientation, for some applications it is important to maintain the field amplitude.This final step in Fig. 3B(iv) is achieved by using the known 1/r 3 Biot-Savart relation of Fig. 2C to scale the amplitude, translating the magnet in x.To capture both the orientation and amplitude, we define a Gaussian kernel similarity function between the target field vector B 1 and the replacement vector B 2 , as this is well bounded between 0 (least similar) and 1 (most similar): with d = 3.We experimentally implement each step of the algorithm in Fig. 3E, and see that the final vector achieves a high similarity to the target vector with S = 0.95.This can also be seen by comparing the histograms of the measured field components in Fig. 3E(i) and Fig. 3E(iv).Here, the final amplitude correcting step maintains the desired field orientation.We have evidenced that by using this algorithm, it is possible to systematically replace unreachable poses with reachable poses with the same field vector.The full dexterity offered by the robotic links combined with the inverse problem of magnetostatics make this system a powerful tool for setting arbitrary strength magnetic field vectors in highly constrained environments.
Experimental setting of an NV centre confocal microscope Following validation with the Hall sensor, we now move to a full experimental setting in order to evaluate the performance of the robot for aligning a spin based quantum sensor.We see in Fig. 4A and Fig. 4B that this requires navigating a highly complex environment with many sensitive optical and mechanical instruments.
In the technique described in the previous section, the collision-free positions found in simulation can be downloaded to the physical robot.This requires a fine alignment between the simulation and the real world performance which could be achieved using the approache described in Fig. 2A.In a highly constrained environment, we find sensor-driven fine angular alignment is difficult to achieve as the initial calibration trajectories contain poses that cannot be verified as collision-free until this alignment has succeeded.
A fast and pragmatic approach in an experimental setting is to teach the robot a set of collision-free poses.We do this by switching the torque to each motor off momentarily, allowing the joints to move freely.Now, the operator can grasp the magnet, and guide the robotic arm to a desired location within the geometry, avoiding collision.Whilst doing this, the user can monitor the magnetic field produced at the sample location with the Hall sensor.When a desired field is registered, the torque and closed loop feedback can be switched on, locking the magnet at its set position.The corresponding coordinates (either the pose or the joint angles) can be registered along with the measured magnetic field.Through this method, the user can hunt and find locations where, for instance, z is the dominant field component.These poses can be used to gather information to calibrate the source to its experimental surroundings.We can both compare the taught poses with the simulation to calculate collisions and, with the dipole field model, we can locally modify the taught position to achieve desired magnetic field vectors.
As a proof-of-principle experiment, we teach the robot a trajectory across the confocal microscope shown in Fig. 4A.We can then demonstrate that traversing this trajectory repeatably affects the NV centre spin based sensor.In Fig. 4C, we use the confocal microscope to locate a collection of milled solid immersion lenses in a polycrystalline diamond sample 50 , observing a bright NV centre in the central lens (Fig. 4D).With the robot arm at its home position, 10 cm away from the sample, we perform ODMR on this NV centre (see methods for experimental details).As defined in Eq. 1, we observe a small 3.7030 MHz splitting due to an intrinsic Π = 1.8515MHz, about the central D = 2.8704 GHz, shown in Fig 4E .In moving the TCP near to the NV centre site, with the robot end effector in the vicinity of the experimental setup, we observe a large 100 MHz splitting in the ODMR spectra (green plot) from the presence of the permanent magnet.Typically, the NV centre must be optically aligned to the photon detector within 500 nm using a piezo stage and the ability to engage and disengage the robot whilst performing ODMR indicates it is suitable to use in this highly sensitive experiment.
Robotic vectorial field alignment of a single spin sensor In Fig. 4F, we repeat the ODMR for a set of robot poses along a collision-free trajectory with α y = 20 • at 5 • increments in α z (Trajectory 1).Each data point was averaged over five minutes.The peak resonances show a smooth increase in splitting from D as the magnet is moved in front of the objective.The same path is traversed at 2 • increments in α z (Trajectory 2) and resonance data shows the same splitting trend, indicating that the trajectory-induced splitting is reproducible.The fitted resonances can be used to extract the polar angle between the NV axis and the magnetic field of interrogation, from the zero-field parameters D and Π (see Methods for details) 51 .This gives a value of 61.0 ± 0.3 • for Trajectory 1 and 61.8 ± 0.2 • for Trajectory 2 51 .This small polar angle change over the 25 • range in α z indicates that the NV centre is near aligned with the world coordinate z-axis.
In Fig. 4G, replacing the diamond sample with the Hall sensor, and focussing the objective at the centre of the sensor area, we can map the field components generated by the trajectory.We see that the B x and B y components cross, as expected for varying α z .We find the Hall field amplitude |B| in excellent agreement with the ODMR sensed field amplitude (see Supplementary Fig. 3).For the trajectory chosen, the robot TCP is not yet fully aligned with the NV or Hall sensor area.We see that in contrast to Fig. 2B, the trajectory does not conserve |B|, with a large increasing B z component, and this is the main contribution to the increased splitting between the two resonances in Fig. 4F.
Using the amplitude data, we can normalise each splitting to isolate the field component ratios (see methods).In Fig. 4G, this normalisation results in the appearance of a dip from both trajectories, with the phase and contrast of the dip giving an estimation of the NV's orientation.The low contrast, non-zero minima in α z indicates the NV centre is near aligned with the world coordinate z-axis as previously discussed.We find that both datasets can be well fitted with the characteristic equation 33 to find α z = 64.1 ± 0.4 • , α y = 97.6 ± 0.7 • for Trajectory 1 and α z = 62.9±0.8 • , α y = 97.9±1.4 • for Trajectory 2. In this, we have shown that vectorial field alignment can be achieved with robotic trajectories of as little as six steps.This is especially useful for ODMR where collecting each spectra takes on the order of minutes.

II. Discussion
Our results show that an industrially designed robotic arm can be adapted to operate around sensitive optomechanical samples and setups.The presented modality produces stable and controllable magnetic fields that are capable of manipulating and aligning a single solid state quantum spin sensor.This an important step in the use of robotics to replace axial stages and bulky field coils for experimental physics and in developing quantum technologies, where we have evidenced the benefit of the innate flexibility and configurability of robotics arms in highly constrained environments.The next step for this work is to generate on-demand magnetic fields using a sophisticated algorithm that maps the traversable space given geometrical parameters, making use of the collision-free techniques described.With this, a set of control points can be found, considering application-specific criteria such as the field magnitude, linearisation, or the time taken to move between points.
Robotics, unlike solenoid coils, produce minimal local heat.This makes them suited for sensitive samples and algorithms could be designed for tracking quantum sensors in motion under cell uptake, a difficult task where the spin sensor orientation changes over time 52,53 .For further flexibility, the cylindrical magnet could be replaced with a rectangular magnet fixed perpendicular to its magnetic axis, with the unused roll degree of freedom in the robotic wrist providing rapid field orientation.
Beyond an off-the-shelf design, an application-specific robot could further maximise efficiency, precision, and control.This could have a larger payload whilst having a smaller form factor, for instance.We can extend this to the use of multiple robots to generate gradient magnetic fields.As well as a range of solid-state sensors, the alignment of atoms and ions in cold and vacuum environments can be explored with these form factors.
In addition, the robot-driven orientation presented can be extended to aligning quantum objects with a range of parameters including electric and lights fields.Here, the end effector would be an electrode, or in optics, a laser or mirror surface.Following this proof-ofprinciple work, the adaptability of robots in combination with sophisticated software could provide ruggedness for alignment in demanding real-world environments where quantum technologies are emerging such as point to point Quantum Key Distribution (QKD) 54 and quantum rangefinding 55 .

III. Methods
Magnetic field modelling Magnetic field calculations in this work are performed using the closed form expressions presented in the Magpylib package 45 .The hollow cylindrical magnet is modelled by subtracting an inner cylindrical magnetic source of opposite magnetisation from the outer cylindrical magnet source.

Robotic modelling
The Niryo NED 2 robot geometry is specified in the Unified Robot Description Format (URDF).Here, the end-effector geometry file specified in the URDF is replaced with a geometry of the magnet tool.For the collision-free motion path finding, the experimental setups are modelled in FreeCad and replace the geometry file of the robot base.The robot is simulated in a ROS environment, and controlled using the python wrapper PyNiryo2.

Experimental setup
The magnetic field measurements in this work is made using the Infineon TLE493D-P2B6MS2GO 3D Magnetic Sensor fitted on a compact platform mount or in the described confocal microscope.
For the ODMR measurements, the NV centre is excited by a CW 532 nm laser (gem 532; Laser Quantum).A confocal microscope is used to image the collected count rate.Using a 0.9 NA microscope objective, the excitation beam is highly focused on the sample producing a nearly diffraction-limited spot (< 1 µm diameter).The NV centre PL is collected through the same lens and separated from the excitation path by the use of a dichroic mirror before detection by single photon avalanche diodes (SPADs)(SPCM-AQRH-12-FC; PerkinElmer).By scanning the position of the sample, a map of detected count rate is generated by which the position of the NV centre and its maximum count rate can be found.ODMR was performed under CW excitation using a Rohde and Schwarz SMB100A microwave source driving a custom loop antenna PCB on which the sample is mounted.

Spin sensor modelling
The spin transitions presented in Fig. 1B are calculated solving the Hamiltonian eigenstates in QuTiP 56 .Other calculations use the NV spin energies characteristic polynomial presented in Balasubramanian et al., whereas the polar angle θ between the field and the NV centre is found using the solution given in that work 51 .The polynomial can be solved and least-squared fitted to the experimental data to find the NV orientation (α NV y , α NV z ): 33 , where γ = arccos cos α B z − α NV z cos α B y − α NV y with a known α B y and α B z set by the robot, D and Π fitted from the zero-field data, and β = γ e |B| where γ e is the gyromagnetic ratio and |B| is the external magnetic field amplitude.In the trajectories presented, and the separation between resonances ν(i), |B| is not conserved.For this fit, we must obtain a constant |B| so first normalise using the field magnitude data.For this, we sub-sample the higher resolution Hall data to reduce noise (see Supplementary Fig. 3) and obtain normalised splittings ν n (i) for each measurement point i where: and leave the non-physical B in the characteristic equation as the third free parameter in the fit to this data.

Figure 1 .
Figure1.Experimental setup and working principles.A. Placing a permanent magnet near the NV centre magnetometer produces a magnetic field of a known orientation, defined along its axis (field lines in white).B. One use case here is to change the spin resonance of the magnetometer, to operate at its most sensitive regime (linear with respect to detected field) away from the zero-field splitting (marked in grey).As observed, field along the NV centre Bz affects this response, whereas transverse components only contribute unwanted performance degradation.The field Bext should therefore be approximately aligned to the NV centre magnetic dipole orientation Bz. C. The 6 DoF robot is used to orient the magnet in complex surroundings.The robot base is located at the world origin (x-axis indicated in red, y-axis indicated in green, z-axis in blue).The Tool Centre Point (TCP axis marked) is translated along the x-axis of the end effector axis (marked) to set the required field strength.The TCP coordinate (x, y, z, αy, αz) is then set to the NV centre position and rotated around the y and z axis, i.e. varying αy and αz of the TCP, to form a defined vector from the end effector to the TCP (shown in yellow).The robot position at a range of different (αy, αz) are shown in the inset diagrams.Through this method the highly-dexterous robot can create fields with arbitrary field strengths and orientations, and align the TCP axis with the NV axis to produce the desired Bz.

Figure 2 .
Figure 2. Robot arm generates arbitrary vector magnetic fields.A. A permanent magnet of varying mass is placed in the tool (left panel).A Hall sensor measures the x − z trajectory of the field produced by the arm (right panel).The trajectory is well-fitted using a model of the field generated by the cylindrical magnet, noting a 15 • offset in the x-z crossing from the expect 45 • (shown with dotted line) and a varying non-zero offset in y, with this offset resulting in a non-linear trend in field registered with increasing magnetic mass.This initial measurement and model can be used for fine alignment calibration.B. The arm can create a field over the full x − y − z sphere segment (one-eighth) with 3 • accuracy.White pixels in the image plots (circled in red) indicate the few unreachable positions.C. The distance r from the end effector to the Tool Center Point (TCP) produces a field strength fall off in Bx proportional to 1/r 3 (top panel), from which points (shown by vertical lines) can be then sampled (middle panel) to create a linear field response with high accuracy (bottom panel).

Figure 3 .
Figure 3. Motion planning in experimental settings A. We model two experimental settings, a cryostat with optical access and a confocal microscope.Plotted are the simulated collisions with the robot (in red) and avoided collisions (in blue) over the fixed position varied (αy, αz) poses.For the confocal, we observe a limited reachable workspace subset.B. We develop an algorithm to replace these unreachable poses with collision-free poses.The procedure follows: (i) a desired field vector is measured in a forbidden position, (ii) displacement puts the magnet in an allowed position, (iii) angular orientation sets the correct field vector, (iv) a further displacement corrects the field magnitude.C. Using a dipole source to calculate the rotation, we can deterministically rotate the magnet and recover the B vector (title bar) at the observer (green dot).D. The designed rotation matches experimentally in minimising the transverse field at 26 • .E. Measuring with the 3D Hall sensor at each stage following panels in B, the final vector well matches the initial vector (quantified by similarity function S defined in the text).

FittedFigure 4 .
Figure 4. Robot-assisted magnetometry: A. Image of confocal microscope setup showing robotic arm in position.B. Optically accessed cryostat with robotic arm in position C. Confocal image of NV centre located in diamond lens (mounted in setup shown in A) D. Photoluminescence scan in z of above.E. Optically Detected Magnetic Resonance (ODMR) showing zero-field magnetic field splitting of associated spin in blue when robot arm is approximately 10 cm from sensor, and strong 100 MHz splitting in green when robot arm is proximal to the spin sensor.F. Fitted peak resonance for robot trajectory in 5 • increments (large circles) and 2 • increments (small circles) indicating movement is stable and repeatable.G. Hall sensor data shows the Bx, By crossover in trajectory.Normalising splitting between resonances by B magnitude reveals σz dependence in Trajectory 1 (black) and Trajectory 2 (blue), indicative of angular alignment.