\documentclass{article}
\begin{document}
As variable \textit{sensor.linear_acceleration} is a matrix,
\end{document}
will result in multiple error messages upon trying to compile such as:
! Missing $ inserted
and Extra }, or forgotten $.
Also the corresponding entry in the .log file explicitly warns:
I've inserted a begin-math/end-math symbol since I think you left one
out. Proceed, with fingers crossed.
As soon as you recieve any error message, do not look at the pdf at all, but try to fix the errors first. Even if you get something that on first glance resembles a pdf file, there can still be issues with it. After an error, TeX only tries to recover enough to syntax check more of the file, it does not try to make sensible output after an error. Once your document compiles successfully (does not generate a single error message), you can have a look at the pdf and see if the output suits your needs.
How to correct the above code entirely depends on the expected output. If you want the _
to be printed as it is, use \_
instead. If you want the following text following the _ to appear as a subcscript, use \textsubscript
instead:
\documentclass{article}
\begin{document}
As variable \textit{sensor.linear\_acceleration} is a matrix,
As variable \textit{sensor.linear\textsubscript{acceleration}} is a matrix,
\end{document}
\verb| ...|
you won't need to modify the variable names, but be aware that this is special command that cannot be used anywhere (for instance, as part of a macro definition or a macro argument).