
NYP.Shank_95
India
Asked
— Edited

I want to make my robot do a function in such a way that for example, when it detects a red colour object, the robot responses as "I see a red colour object" and it does the same thing for blue or green object.
# Search for color tag containing QR code to help find destination
# set Color tracking ex:red
# start scanning for red card
# move to an open space ( adjust distance sensors to a larger detection area)
# if not found move to next open space
# on tracking result successful move toward it
# set QR code tracking on
# read code and move according to the code
$target=0
if ($destination = 1)
$target= ("Office")
ElseIf ($destination = 2)
$target= ("bedroom")
ElseIf ($destination = 3)
$target= ("lodge")
ElseIf ($destination = 4)
$target= ("workshop")
EndIf
If ($destination > 0)
ControlCommand("Camera", CameraColorTracking, "red") Enable red detection
Say("Scanning around to find red tag showing direction to the"+ $target)
# scan with head and/or body to detect color tag
# If no success move to an open space
endif
$CameraVerticalQuadrant= "Unknown" # reset variable for subsequent reading
RepeatUntil ($CameraVerticalQuadrant="Middle") # Variable switching state when red color is detected
Sleep(500)
EndRepeatUntil
$CameraVerticalQuadrant= "Unknown" # reset variable
Say("found red tag")
Here's a script that does what you want. You have to calibrate your colors in the "Multi Color" tab in the Camera control.
Code:
You can put in whatever you want the robot to do after it detects the color. I have it just saying the color it sees.
Edit: It says the last color detect over and over again until it sees a different color. I'm working on that, if anyone has any suggestions, let me know
please look at this forum ..there is a video and some code. Please let me know if you need any other help.
look in the cloud storage for a Script Example Project called "JD vision"
Quick link to files
http://www.ez-robot.com/Community/EZCloud/RobotApps.aspx
this could all be in the same script so it will look as if the robot is looking for all three and will give you the same results.
Define each multi color. Then edit the "tracking start" script. Add an IF condition for each color that you are looking to detect. There is a variable that holds the current multi color detected :). It was quoted earlier in this thread.
This is my coding:
Code:
Using Color Detection often gives unstable results depending of the light condition or object in the same nuance.
Example in my environment if I want to detect red, the camera will see my skin, my cabinet and other objects.
I am not telling it wont work, but you will need to select an object with a bright color and adjust "Min Object Size" and "Object Brightness"until you have stable result.
Personally I prefer using the Multi-Color tracking function. It gives you more set-up to play with.
as you can see, in multi color tracking mode the camera will detect strictly these colors.
you may also try this short script to experiment with it:
ControlCommand("Camera", CameraStart)
$CameraObjectColor = ("Unknown") # define variable
ControlCommand("Camera", CameraMultiColorTrackingEnable) # activate multi-color-tracking
:loop
$CameraObjectColor = ("Unknown") # clear variable at begining of the loop
SayWait("let me look")
IF ($CameraObjectColor = "Unknown") # if no detection of color define
SayWait(" No I do not see these color")
ENDIF
IF ($CameraObjectColor != "Unknown") # when variable is different than "Unknown"
SayWait(" Yes, yes I see" + $CameraObjectColor)
SayWait("the object is in" +$CameraVerticalQuadrant +"and" + $CameraHorizontalQuadrant) # tell localisation of color
ENDIF
goto (loop)
Here is the STL file
Multi-ColorTest.EZB