So I need to find objects in an enclosed area, I have access to the standard set of NXT sensors, i.e. ultrasonic/light.

However, the ultrasonic sensors seem to be very unreliable and erratic, in regards to finding objects accurately.

I cannot pre-program the path to the objects, so I'm trying to work out how is the best way to go about locating these objects? The objects are small, and on the floor.

I was thinking a sort of swivel motion at the start, to find any objects using the ultrasonic, and then just moving a small distance at a time, then swivelling again etc. Are there any other better ideas?

Also, there is a wall enclosing the area, would there be a way of programming the NXT to avoid it?

I'll be programming the NXT in NXC. Can't afford LIDAR :(

  • 1
    In my sensor tests today I found that the ultrasonic sensor just returns 255 if there is no value to return (cable unplugged, or just no answer ready yet). So just filter those out – while ((i = SensorUS(IN_1)) == 255) {} should do the trick. Maybe that helps increasing reliability?
    – mirabilos
    Commented Mar 8, 2014 at 22:46
  • Oh I didn't know that! Thanks for sharing!
    – user3089
    Commented Mar 9, 2014 at 11:24

1 Answer 1


If the ultrasonic cannot echo-locate the objects because they're too small, even with the sensor suspended very close to the floor, I suggest using a very sensitive feeler out front. It can be sticking forward like a jousting lance, and your robot can swivel back & forth while traveling to scan.

The trick to making it very sensitive is to: (1) make it pivot at its base on the front of the robot with a smooth pin, (2) make it long and lightweight (use long axles), (3) mount two opposed touch sensors as close to the pivot point as possible, and (4) pre-load the touch sensors such that minimal travel is necessary to trigger each one.

The same techniques can be applied with a large diameter roller out front (like a steam roller) to detect any bumps on the floor (if the objects are kind of flat).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.