Any idea if I can get an ultrasonic distance sensor working with a Pi?
You can yes.
But it is not consistent due to the Pi not being real time and sometimes the distance is reported greater than it should be. To get round this you have to average readings. Some libraries do this automatically. I wrote a beginners article on how to do this in The MagPi Magazine No. 46 June 2016 - free download.