
ezrobot3
Singapore
Asked
— Edited

Hi Everyone,
I would like to enquire if the EZ-Script is able to program the robot in such a way that..
- Detect red/green object
- Move towards the object
- Stop before the object (Around 3-5cm where it will be able to grab hold of the object)
Is it possible? I would have to use the multi-color detection for detecting both colors (Red and Green).
Thanks and would really hope to receive a reply soon.
Yes, it is possible. Also, it may work better if you use a sharp IR detector at close range.
my 2 cents.
This is very easy and no problem for the EZB and camera.... Dj's Wall-e video demonstrates it quite well
You'll want to use the Camera enable movement tracking
ChaseandGripGreen.EZB
Attached is an ezb file I made to use the camera with a script to track the color of green object and my robot RedBender's gripper grabs it once it is reached. Obviously change the ports values to match your robot's configuration.
For my usage it stops when the object is in range of the gripper and the gripper closes. For a more specific range you'd want to integrate sonar distance sensor. Because the camera can (to my knowledge) only be used to sense when an object is in a certain grid, but not give a distance.
This would wait to take action until the ping shows a distance lower than 5. Again, chance d8 and d9 to reflect your port values.
Hi, Thanks all for the replies! Appreciate it much!
@JustinRatliff May I ask what does this sentence of code means? If ($CameraVerticalQuadrant = "Middle")
$CameraVerticalQuadrant is the variable for the camera which states which section of the image the object is within. By using the "Middle" it is checking if the vertical position on the camera is in the middle vertically.
@Rich but what will be the purpose of this line of code when using camera to track the object? Pardon me for my slow understanding.
If the script goes line by line, does this mean that the servo D2 will be position at position 70 first before enabling the camera movement track. Next, it will be a loop for which, it will be tracking until the object is in the middle of the camera and that when the camera movement will be disable and the servo D2 will be lower to position 40 to pick the object up?
PS. If I got this wrongly.
Following that code snippet it would;
Move the servo connected to D2 into position 70 Enable the movement tracking of the camera Check for where the movement is detected If it is the middle vertically it will disable the movement tracking then move the servo connected to D2 into position 40 Wait for 9 seconds and then loop back If it isn't vertically it will just loop back It will then repeat the IF nest.
However, if the condition is met the tracking is disabled, it will then constantly loop checking for the position on a disabled camera. There is no escape routine from that loop.