  Encoding logical qubits in bosonic modes provides a potentially
hardware-efficient implementation of fault-tolerant quantum information
processing. Recent advancements in trapped ions and superconducting microwave
cavities have led to experimental realizations of high-quality bosonic states
and demonstrations of error-corrected logical qubits encoded in bosonic modes.
However, current protocols for preparing bosonic code words lack robustness to
common noise sources and can be experimentally challenging to implement,
limiting the quality and breadth of codes that have been realized to date.
Here, we combine concepts of error suppression via robust control with quantum
error correction encoding and experimentally demonstrate high-fidelity,
deterministic preparation of highly non-classical target bosonic states in the
mechanical motion of a trapped ion. Our approach implements numerically
optimized dynamical modulation of laser-driven spin-motion interactions to
generate the target state in a single step. The optimized control pulses are
tailored towards experimental constraints and are designed to be robust against
the dominant source of error. Using these protocols, we demonstrate logical
fidelities for the Gottesman-Kitaev-Preskill (GKP) state as high as
$\bar{\mathcal{F}}=0.940(8)$, achieve the first realization of a distance-3
binomial logical state with an average fidelity of $\mathcal{F}=0.807(7)$, and
demonstrate a 12.91(5) dB squeezed vacuum state.
