Diego
USA
Asked
— Edited
i was watching some videos and i came across this robot called the dog robot. using some ultrasonic beacon's to know were to go here is the link to know how to make them.
so i had this question, can this be attached to and EZ-B?
sorry i confused the link of the video... the vid is this one
still no go.
Here you go...
I would think so. the Hasbro r2d2 has this same feature. he will follow you around.
-with the ezb you can use the ping radar to scan for you -as you move away the reading will drop -you can write a script for the robot to move forward when the variable drops.
off the top of my head
if(adc, 1 < 50) forward 100 if(adc, 1 > 50) stop() or something super easy like that to start off.
Slight corrections... based on the ping sensor that comes with the EZ-Kit
Ping will increase as you get further away Ping is on 2 digital ports and used GetPing()
Very quickly before I head off to get some sleep (something I should have done 45 minutes ago!)
There's probably a better way for the script but you get the idea
You would also want it to turn to find you if you moved to the side, otherwise it would continue forwards until it got close to something else. But the answer is yes it can be done.
Rich, wouldn't that cause the robot to stop once and then get stuck in a stop loop? This is what I got from the script(my own words):
If ping sensor reads less than 50 Go forward
Loop point
If ping sensor reads more than 50 Stop Else Goto the loop point
The script will move the bot forward, but as soon as the robot gets close, it will stop, and then will keep looping around if ping equals more than 50 stop. It will never engage forward again.
Oh and just noticed, shouldn't it be if it equals more than 50 go forward and less than backward?
It would be part of a much larger script, but yes, on it's own it would move forwards until it found something then stop, once stopped it will break free from the loop and just end the script.
and what about the more than less than being switched?
You're right, slight typo on my part
So when the distance is increased, the ping is increased, check that against a pre-determined number and move accordingly. However, turning to find the direction would also be required, a simple If loop to turn, check distance and stop the routine when found should do - much like the escape routine in my Ping Roam 1.1.2 script but the other way around (look for an obstacle rather than no obstacle).
Really, if you split it down in to sections it would be a pretty simple script to write. And because I want other people to learn stuff and get good at scripting etc. I'm not going to write it, I'm going to try and get others to write it (with help where needed though)
i think the Code will be:
If(GetPing(D0,D1) > 50) Forward() :loop If(GetPing(D0,D1) < 50) Stop() Else Goto(loop)
diego that will cause a stop loop. youll stop once and then never move again. it should really be:
:loop If(GetPing(D0,D1) > 50) Forward() If(GetPing(D0,D1) < 50) Stop() Else Goto(loop)
And then with what rich said you'll need a turn section. I think using motion tracking with the camera might work better. then use Cheat Sheet to to add it to your script.
@diego Almost. @Technopro so close but not quite.
All IF conditions must end with an EndIf. There is also an ElseIf command which could be used. ElseIf is checked only if the first (and any previous ElseIfs in the tree) is not met. i.e.
The IF will only meet one of the conditions and run the commands between it's condition and the next one, then move on to whatever is after the EndIf (if anything) or halt (if nothing).
This alone will only have the robot run to get to 50 units from an object in front of it, it will not look left and right for an object and it will not back away from an object.
A good start for this small project would be to look at the Ping Roam script, it's pretty much the same but backwards. The ping roam script is commented in detail so should be pretty easy to follow and understand. Also my An Introduction to Scripting may be of use too, the example does the opposite and runs away from anything that gets close. However, the syntax may have now changed due to recent EZ-Script improvements.
However, before any coding is done you should be thinking about how you want it to react and to what. Once you know what you want it to do in specific circumstances you can then tackle each part and slowly put together a complex script to do what you need it to do.
I'll update this with links to the posts and projects when I have more time.