Rod and cylinder sensor