ezrobot3
Singapore
Asked
— Edited
Resolved by Rich!
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.
@Justin, couldn't load chaseandgrip.
It wouldn't load or you couldn't download it?
There is a problem with the link but it should be available here (took a bit of finding since the user details pages are also slightly broken too - a bug that has been reported previously).
@Rich Does this script work this way?
Move the servo connected to D2 into position 70 [D2 is the left arm] Camera will start
It will enable the movement tracking if the camera is tracking. THEN :loop will be the start of the loop
If the image is vertical in the middle, the movement tracking will be disable, and the multicolor tracking will be enable.
(Ps because I do not have the camera rolling yet, so the name 'Custom Color' is Red) If the object is red, the servo D9 and D12 will be moved forward and stop before the object after which, it will then open D4 (which is the gripper) to position 150 then Move the servo connected to D2 into position 40 (to lower from position 70), D4 will then be close back to position 30.
Same for the green object, however, left arm will be used to pick up red object and right arm will be used to pick up green object.
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.
Ps. Is my EZ-Script correct? The flow I wanted was to: Use the camera to track the environment and then detect the object. Next, move towards the object then pick up using either left or right arm depending on whether it is red or green in color.
Thank you very much.
I only had chance to quickly scan over it but I think you've got the main idea.
One thing I noticed though,
This will not do anything, well, not for very long anyway. Almost immediately after moving the servos forwards it stops them. I didn't have chance to see what you are attempting to achieve so can't advise too well but either a sleep() to let it move forward for a set time or a WaitForChange() (or similar) to let it move until an event happens between the forward and stop commands should work.
When I get home I'll look properly. To be honest I don't think EZ-Script is needed since there are built in controls that may do it all for you, or at least the main parts. But I'll have a look later and post some more advice etc.
@Rich Thanks for the reply! Roughly what I want to do is that, the robot will be able to detect the red/green object, and move towards that and after which pick the object up depending on which color. (left hand pick red object, right hand pick green object)
Looking forward to your guidance!
Thank you! (:
Sorry, I haven't forgotten this I just haven't had chance to sit down with ARC and check it out properly - I will.