  Based on a first-principles based multiscale approach, we study the polarity
(P) of ferroelastic twin walls in SrTiO$_3$. In addition to flexoelectricity,
which was pointed out before, we identify two new mechanisms that crucially
contribute to P: a direct "rotopolar" coupling to the gradients of the
antiferrodistortive (AFD) oxygen tilts, and a trilinear coupling that is
mediated by the antiferroelectric displacement of the Ti atoms. Remarkably, the
rotopolar coupling presents a strong analogy to the mechanism that generates a
spontaneous polarization in cycloidal magnets. We show how this similarity
allows for a breakdown of macroscopic inversion symmetry (and therefore, a
macroscopic polarization) in a periodic sequence of parallel twins. These
results open new avenues towards engineering pyroelectricity or
piezoelectricity in nominally nonpolar ferroic materials.
