Asked — Edited

Color Tracking And Sonar

Hi all, I'm making a small robot to run a maze and find a small red ball. I have sonar and the camera mounted next to it. The sonar works fine, but the color tracking does not seem to work. The camera is not mounted to a servo, as you can see in the picture. I have the camera config set for movement tracking, forward, left and right turning. It seems like the sonar overrides the tracking. Also, is there a way to get the robot to stop in front of the object?

There are 4 of us at work that are using different systems, E-Z Robot (me), 2 Raspberry Pi users and and an Arduino.

User-inserted image


ARC Pro

Upgrade to ARC Pro

ARC Pro is more than a tool; it's a creative playground for robot enthusiasts, where you can turn your wildest ideas into reality.

PRO
Synthiam
#2  

You can't go forward and turn left and stop at the same time. So the question you have to ask yourself is what control takes precedence? Both controls (Camera and Radar) are attempting to move the robot in different directions.

And, unless the red ball is always in front of the robot camera, having the the Movement Tracking enabled will only make the robot follow the ball. So the ball has to be in front of the camera. If the ball isn't in front of the camera, it can't see it, so how can it track it? It can't.

Lastly, what sonar control are you using for navigation? Use the Ultrasonic Radar Control.

It is incredibly easy to achieve what you're wanting to do - however, the blue question marks were not used to read what the options do before enabling them. Such as, the Movement Tracking.

I would recommend a few things - which would be super super super super easy to achieve your goal.

  1. Use the Ultrasonic Radar Control so the robot will begin navigating the maze. Once you have the Ultrasonic Radar Control working, and the robot is indeed navigating correctly, move to the next step.

  2. Add the camera control. Do not enable movement tracking, because you're not following anything. Instead, switch to the SCRIPTS tab and edit the "Tracking Start" script.. User-inserted image

User-inserted image

Press the EDIT button on that script and put create some easy code that does something like


SayEZBWait("I found the ball, therefore I win!")
ControlCommand("Ultrasonic Radar Scan", PauseOn)
Stop()

Or use blockly... User-inserted image

  1. Save the script, save the configuration and return to the Camera Control and set the Tracking Type to Color User-inserted image

  2. Fine tune the color brightness so it detects the redness of the ball and nothing else. You will know because the robot will speak when it sees the ball. Also the bottom of the camera control shows TRACKING in red when it detects the object User-inserted image

  3. Set your robot mouse loose and you win

The entire project is super easy and should look like this when it is done... User-inserted image

#3  

Hmmm, you can't have two devices (camera and ping sonar) giving the robot contradictory movement instructions at the same time... Either or as it were... either the ping or the camera has to be the master controlling navigating (not both)... Here is how I would approach this... For instance your robot could start off using the ping to navigate the maze while the camera is running background just checking for the colour red (not paying an active role in navigating.. yet). Once the camera sees red it swaps places with the ping as the navigator (Movement tracking will be enabled) while the ping now takes a background role at measuring distances... Once the robot is close enough to the ball (measured by the ping) the robot will be told to stop...

@DJ beat me to it... :)

PRO
Synthiam
#5  

Ah, i see what @richard is suggesting as well. That you can enable movement tracking on the camera when the ball is in site. That ensures the robot will move toward the ball rather than accidentally turn down a path.

You could very well do that, by simply putting this in your Tracking Start script in the camera config


# Stop the radar scanner
ControlCommand("Ultrasonic Radar Scan", PauseOn)

# Stop the robot from moving for good measure before we enable movement tracking
Stop()

# Tell the camera to enable movement tracking and the robot will now head toward the ball
ControlCommand("Camera", CameraMovementTrackEnable)

# show off
SayEZBWait("I found the ball, therefore I win!")

Start Exploring script can begin the whole process like this. Which enables the red color tracking, unpauses the sonar sensor and begins moving at a slow speed. User-inserted image

PRO
Synthiam
#6  

Here's an updated project that disables the sonar and lets the camera take over when the ball is in sight.

mazeexplore.EZB

#7  

Thanks DJ and Richard, I forgot to mention that I was using the Ultrasonic Radar control, that works great for collision avoidance. Just couldn't figure out how to over ride it with the color tracking. (Put in a late night with it last night.)

Thanks again, the community here is the best.

#8  

Hi guys, This thread is great as it gives us "newbees" an example tutorial about a real time situation solution. My Roli has the camera and sonar devices on front also. I am primarily still in the scratch stage, but have a basic knowledge of blocky, so that is next.

PRO
Synthiam
#9  

Great to hear, eagle! Thanks for letting me know