  Planetary rovers can use onboard data analysis to adapt their measurement
plan on the fly, improving the science value of data collected between commands
from Earth. This paper describes the implementation of an adaptive sampling
algorithm used by PIXL, the X-ray fluorescence spectrometer of the Mars 2020
Perseverance rover. PIXL is deployed using the rover arm to measure X-ray
spectra of rocks with a scan density of several thousand points over an area of
typically 5 x 7 mm. The adaptive sampling algorithm is programmed to recognize
points of interest and to increase the signal-to-noise ratio at those locations
by performing longer integrations. Two approaches are used to formulate the
sampling rules based on past quantification data: 1) Expressions that isolate
particular regions within a ternary compositional diagram, and 2) Machine
learning rules that threshold for a high weight percent of particular
compounds. The design of the rulesets are outlined and the performance of the
algorithm is quantified using measurements from the surface of Mars. To our
knowledge, PIXL's adaptive sampling represents the first autonomous
decision-making based on real-time compositional analysis by a spacecraft on
the surface of another planet.
