Very nice code and demo, thanks for your contribution.
BTW, what the X/Y/Z offset and P/T/R offset does? how
to get those value?

Thanks again.