Need advice on Lego NXT Ultrasonic sensor use.

22 views
Skip to first unread message

Jim DiNunzio

unread,
Jan 19, 2026, 2:31:34 PMJan 19
to RSSC-List, hbrob...@googlegroups.com

I’m getting my bot ready for our RSSC’s contest, the Can-Do Challenge on Feb 14 (https://www.rssc.org/can-do-challenge.html), and need some advice on use of the Ultrasonic sensor use.

Ā 

I’ve attached two pictures of my bot. I’ve used this sensor before successfully for at least 2ft in contests a long time ago where I mounted it horizontally. However, in this design I thought vertical would be better to detect a can. I tried horizontal first, but it didn’t work any better.

Ā 

https://www.youtube.com/watch?v=dNbv3ONI3cU&list=PLmb0WjGtyZZS9qjUYhY4bdeh4ZQYx7BYS

Each tile has 12in (30cm) sides

Ā 

I can reliably get good distance measurements when a can is within 1-2 feet (30-61cm), but I need a 3 feet (91cm) range for the contest.

The sonar seems to be very sensitive to its pitch and if pitched a small angle too low it strangely sticks to reading 23cm, some point on the floor. If it is slightly too high then it misses the can entirely. The further away the target is the smaller the sweet spot angle.

Ā 

But keeping it exactly level on a moving platform is challenging. I’ve tried adjusting its pitch very slightly but it has not resulted in an improvement. My earlier bot design was a little more stable and maybe kept the sensor more level?

Ā 

I do have a second ultrasonic sensor and am wondering if I should mount it as well. Both units behave the same when mounted in the position shown.

Ā 

Thanks,

Jim

Ā 

WIN_20260119_10_51_57_Pro.jpg
WIN_20260119_10_55_12_Pro.jpg

camp .

unread,
Jan 19, 2026, 4:29:33 PMĀ (14 days ago)Ā Jan 19
to RSSC-List, hbrob...@googlegroups.com, j...@dinunzio.com
Ā Ā Ā Ā It could be worse. At least you're trying to find something cylindrical. With the TABLEBot Challenge, I've taken to using a 3.5" tube as my "block" because ultrasonic waves spang off flat surfaces, never returning to the receiving transponder.

Enjoy,
Camp

--
You received this message because you are subscribed to the Google Groups "RSSC-List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rssc-list+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/rssc-list/011e01dc897a%243400b7f0%249c0227d0%24%40gmail.com.

John Davis

unread,
Jan 20, 2026, 12:00:01 AMĀ (14 days ago)Ā Jan 20
to RSSC-List, hbrob...@googlegroups.com
My suggestion is foam-tape off a lower section of the transmitting sensor and aim slightly below the optimum. That way, if the robot tilts upward it may still see the can but the nearby floor will not be illuminated. If it tilts downward, the floor reflection may still be reduced sufficiently while the normal cone still strikes and reflects from the can. I think the lower 'eye' is the transmitter on your robot.

John F. Davis
(310) 961-2196 (cell)

--

Bob Huss

unread,
Jan 21, 2026, 11:01:45 AMĀ (12 days ago)Ā Jan 21
to John Davis, RSSC-List, hbrob...@googlegroups.com
What I found onĀ  NXT was to test the edges of the claw to be wide enough to not be seen by the U.S. sensor.Ā  Then I would search only left direction for the edge of the can, on several trial runs. Then I add several milliseconds to center the claw on can.Ā  If I remember right, the left part of the sensor is transmit, so I am guessing that the horizontal mounting position might be better if sideways movement is quick.
Good luck.
Bob Huss

jimdi...@gmail.com

unread,
Jan 21, 2026, 10:28:52 PMĀ (12 days ago)Ā Jan 21
to Bob Huss, John Davis, RSSC-List, hbrob...@googlegroups.com

Thanks for the advice. After some tests I decided on a rear of robot, centered, and horizontal orientation for the U.S. sensor because I can reliably rotate close to 180 degrees with my odometry based localization and even have an IMU mounted if necessary to use. Even with this the range that the can is visible seems to be maxing out significantly less than 90cm. I’ll try different floors like cement vs. my shiny marble tiles and try the foam tape trick on the lower half of the transmitter.

Ā 

Jim

WIN_20260121_19_16_41_Pro.jpg

John Davis

unread,
Jan 23, 2026, 1:26:16 AMĀ (11 days ago)Ā Jan 23
to Bob Huss, jimdi...@gmail.com, RSSC-List, hbrob...@googlegroups.com
I was playing with an NXT ultrasound with a 40 kHz sensor taped onto it. (I like to see the actual chirp and echoes on a scope.) It occurred to me that driving over a smooth floor is just like driving along a wall; at certain distances from the wall the echo returned (when the side lobe of the chirp hits the wall) can be strong enough and at an angle to be seen as a target closer than the actual object.
One way to eliminate that might be a front-mounted ultrasonic close to the ground; any possible reflection will come from a nearby more perpendicular angle and thus be too close in time to be detected. (For ground further away the transmission angle will be too shallow to reflect back into the receiver.)

John F. Davis
(310) 961-2196 (cell)

Chris Albertson

unread,
Jan 23, 2026, 1:34:19 PMĀ (10 days ago)Ā Jan 23
to John Davis, Bob Huss, Jim DiNunzio, RSSC-List, hbrob...@googlegroups.com
I tried to solve thisĀ and some other problems with ultrasound by taking advantage of the fact that the robot is moving.

For example, if you. If you get a false positive ā€œhitā€ or the sensor fails to notice an object, the results will likely be different after the robot has moved, even just a little. Ā  Ā  So I used a simple algorithm. Ā  ā€œAn obstacle is only 'real' after it has been detected N times with M pings.ā€ Ā  But this means you have to have at least decent localization. Ā The sensor gives only a distance and a crude angle, and you have to convert them to real-world coordinates. Ā  Then, when you see an object at the same location N times, it is real. Conversely, if none of these objects are on the path, the pathĀ is really clear.

I think all sensors are like this; they become MUCH better if you take advantage of the fact that the robot is moving. Ā Especially cameras. Ā  I run some video data through YOLO’s object recognition. Ā  Yolo gives you a bounding box and a label, and what is neat is that it takes 30 frames per second. Ā  Ā This means you don’t wait long to get 10 or 15 samples. Ā With that many, Yolo is near perfectly accurate. If you say ā€œobject must be recognized 7 times in 10 frames at the same real-world location,ā€

All that said, ultrasound never did give good results; the angular resolution is too poor. Ā  I tried to make it better with another trick: Ā I used multiple sensors with overlapping fields of view. Ā  Then, if sensors A and B both saw the object, I knew it was in the angle where the views overlap. Ā But still, the robot was confused by chair legs under a dining table, and it could not tell a doorframe from a continuous wall until it was very close. Ā 

Jim DiNunzio

unread,
Jan 25, 2026, 2:41:15 PMĀ (8 days ago)Ā Jan 25
to Chris Albertson, John Davis, Bob Huss, RSSC-List, hbrob...@googlegroups.com

Thanks for the pointers to all.

Ā 

Here’s a milestone in my progress:

https://youtube.com/shorts/2u_xTZ9i4l8?feature=share

Ā 

Now I’ll try to extend the range capability and improve the success rate!

Ā 

Re the comments, I do like to take many measurements while the robot is moving or scanning completely past the detected, in range target in this case to find the minimal distance and optimal angle to the target. Because this is for a constrained contest and arena (https://www.rssc.org/can-do-challenge.html), then I don’t need to engineer it beyond those requirements.

Ā 

Personally, if I were building a modern robot for this contest, I would not use an Ultrasonic sensor, but instead a ToF infrared sensor module like the VL53L7CX which is available in ready to use boards in the market for a range of prices. I have bought DFRobot’s RP2040 uC based board (https://www.dfrobot.com/product-2999.html) available for under $22

Ā 

For my YOLO object detection implementation on Big Orange I’ve been using basically the same algorithm Chris describes below for several years, calling it computePersistance(). It works quite well.

Ā 

Jim

Ā 

Ā 

From: Chris Albertson <alberts...@gmail.com>
Sent: Friday, January 23, 2026 10:34 AM
To: John Davis <jfd...@sbcglobal.net>
Cc: Bob Huss <boba...@gmail.com>; Jim DiNunzio <jimdi...@gmail.com>; RSSC-List <rssc...@googlegroups.com>; hbrob...@googlegroups.com
Subject: Re: [RSSC-List] Need advice on Lego NXT Ultrasonic sensor use.

Ā 

I tried to solve thisĀ and some other problems with ultrasound by taking advantage of the fact that the robot is moving.

Carl

unread,
Jan 26, 2026, 4:56:30 PMĀ (7 days ago)Ā Jan 26
to RSSC-List
Returning the can is nice - not required, though, right?

I am using the VL53LOX TOF sensor, and I had a similar issue when switching from tests on a wood floor to a rough folding table top.Ā  I my case, I just tilted the sensor up a bit, but the TOF sensors have a fairly tight FOV as you have noted.

Jim DiNunzio

unread,
Jan 26, 2026, 10:32:59 PMĀ (7 days ago)Ā Jan 26
to Carl, RSSC-List

No, return is not required. The essential capability was already in my old code, and I thought it would be cool to keep doing it. 😊

Ā 

BTW, I changed the mount of the sonar to add a tilt axis (it’s fun figuring that out in LEGO parts…) and adjusted it to maximize the distance it will detect the can from. For 2/3 cans I am using it maxes out at 75cm beyond which tilting up or down yields only unknown measurement. But with one red coke can in one area of the same marble tile floor, it is able to see it the full 91cm I need. So go figure with ultrasonic. I ordered a marked up ToF IR for LEGO NXT so I’ll have another I would hope is a more reliable option.

Ā 

Jim

--
You received this message because you are subscribed to the Google Groups "RSSC-List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rssc-list+...@googlegroups.com.

Carl

unread,
Jan 27, 2026, 2:36:34 PMĀ (6 days ago)Ā Jan 27
to RSSC-List
FWIW, I was testing this AM, and found the known issue with TOF sensors that they get false readings in sunlight.Ā  I added a low pass filter, similar to what you discussed with YOLO, but it's still too chaotic.Ā  I don't think sunlight will be too much of an issue at the contest.Ā  One advantage of an ultrasonic sensor!
Reply all
Reply to author
Forward
0 new messages