Sonar Sensor, Line Follower, or Light Sensor for detecting balls?

My team is trying to decide what sensor would be the most effective at detecting when balls are “loaded” into our intake. The sensor would be could pretty close to the balls resting place when loaded. We have used touch sensors such as limit switches in other spots on our intake but due to clearance issues and weird angles sensors that do not need to make contact seem like the best option for us at this point. The overall goal is to just detect when a ball is loaded so during auton we know when to stop running our intake and run our linear slip gear puncher. Due to lack of experience with such sensors, we are wondering what sensor would give us the most accurate and consistent values. Any advice or opinions is appreciated, thanks.

Vision sensor or ultrasonic range finder.


I don’t know which one is best would recommend using some combo of multiple sensors to get the most reliable sensing possible.

Very good point, thanks!

We have personally been using the line trackers and have had a lot of success with them. We use thresholds to determine if a ball is in front of it or not, values of which we determined experimentally. We specifically like them because they are contactless, and for the reason they can detect the ball within a pretty broad area (however can be tuned if you are looking for precision). We haven’t had any issues with false positives.

Ultrasonics would likely also work just as well, however take two ports (of 8 3-wire ports on v5) and are a lot bigger, which may be an issue based on your situation. Vision sensors would also likely work, but are probably over complicated for the purpose of detecting a ball in a certain spot inside the robot.

Thank you for your response! Its great to hear that line followers work well because if functionally they are the same as the other sensors, they seem to be the easiest to use because of their small size. And like you said, the vision sensor is quite overkill for such a simple task. Once again, thanks for the info, will be putting it to use soon.

+1 I would use line followers (same thing as line trackers) to do this as well.

Awesome to hear we agree, thanks.

I don’t know why the Vision Sensor would be “overkill” for this. It would work great and it is simple to program. I can see why it might be too big for the space or too expensive, though, but I would at least consider it. I’ve been very impressed with the Vision Sensor.

We use V5 and the line follower works well for us

I do not disagree that it would work perfectly, but I feel that using it for a somewhat basic task that could be done just as well by another sensor if a waste of its vast capabilities. I meant to say if we are going to use a vision sensor, we would likely use it for something much more advanced such as aiming the robot at the flags or tracking balls rolling on the floor.

Good to hear that this sensor works from multiple teams, thanks.

@seanmac0230 If budget is no issue, you could fill every port with cameras.

Haha no way. (as funny as that would be) We’ve got 7 teams and we’re still waiting on 2 V5 bundles.
(and budget is an issue, seeing that some of our teams have… difficulty in what they want to get enough of in terms of parts)

An ultrasonic has the benefit of working in different lighting conditions compared to both other options. It is a lot slower of a sensor though. You should get new readings from analog sensors at full rate 100 hz on V5 and >1khz on cortex, and ultrasonic sensors are probably only 20hz(best case).

Oh, I didnt think about that, thanks. Ill keep it in mind.

All of this is true, but I still think the line follower (tracker) is the best choice due to its size. In the past, I’ve tested the same code in a variety of lighting. It works pretty much the same. You just need to find the threshold of when a ball is loaded vs when it’s not. Those should be two completely separate ranges. I tested mine once with all of the lights in the room on, and once with minimal light (CURSED SHADES) entering the room. The values were each in their own ranges.

It sounds like you have already decided, but I’ll throw it out there.

I mainly just gave a good thing about each. Personally I have used line followers for this in the past because it was easier to justify 1 of the analog ports on cortex robot. Ultrasonic sensor are also a lot bigger and space constraints might be an issue.

Just a lot of factors to keep in mind.

Yes, I didn’t mean to attack your assertions on sonar :slight_smile: