Asked
— Edited
I'm going to make my rc car robot autonomous.
theres just one problem... It's an rc car! it has custom turn and drive scripts!
does anyone have an idea or example on how to make a script for radar? one that I can modify to accomidate my custom movements?
Radar should work with the custom movement panel.
Otherwise, check the EZ-Cloud, I've added a few files with ping object avoidance scripts.
I don't have a custom movement panel. I used the Movement Panel to set up the sabertooth. Now I have scripts and key control. I need a basic radar script that checks left, Checks right, and reverses and goes the open way.
SendSerial will probably work then, which means you could set up a custom Movement Panel rather than the sabertooth movement panel. You would need to find the serial commands for the sabertooth though, then add the scripts in for the directions on the custom movement panel.
Custom radar style script can be found here which is discussed here. I'm currently working on a more advanced avoidance/detection for this script which checks for being boxed in, increased number of positions and basing movements on the sensor readings, speed control based on surroundings and a bunch of other stuff. It does and will continue to use the Movement Panel Forward, Left, Right, Reverse and Stop though so a custom Movement Panel will be required.
Or the Introduction To Scripting covers some Ping/IR sensor reactions.
heres my setup. RcSabertoothcarcontrols.EZB
experiment using the "Radar (custom)" script.
we both can try to create a radar script that could work with this setup.
the key controls are: w forward s reverse a left forward d right forward z left reverse x right reverse
how would you say "if the ping sensor value=(3 quarters of the full value), move servo full left. if value is below (3 quarters of the full value), start "left" script for 1500 milliseconds if value is above (3 quarters of full value) move servo full right. if value is below (3 quarters of full value), start "right" script for 1500 milliseconds if value is still above(3 quarters of full value), start "reverse" script for 1500 milliseconds then check again. turn towards lower value then start over
If it needs to be greater than or equal to then change the = for >=
You cannot ControlCommand to run a script for a time period, that would need to be part of the script itself.
Use a label (i.e. :loop) and a goto to loop around. Add in a Sleep to avoid saturating the communications and bogging down ARC. Sleep(50) or Sleep(100) is usually all that's needed.
To turn towards the lower value you would need to use an if...
is there a command to stop scripts?
oh and I was playing with your ping avoidance script and changed a couple things. i'll post the code so you can proof read.
You can use ControlCommand() to stop scripts, so use to to start, sleep for however long then stop script.
so like controlcommand("left", scriptstop)?
In EZ-Script on the right you can click on the tap for controls and it lists them all, click on the right one and it instantly pastes it in the script.
Depending on if it's a script on it's own or part of script manager will depend on the command. But the easiest way is to do as I described above.
heres the script updated.
is this good?
Upon a quick scan through that looks like it'll work.
One thing you could do though since your movement differs to the normal and you will have different factors which determine turning. How about adding in some code so left and right are based on previous travel direction?
For instance, if the car is moving forwards then a left turn would be forward and left or right would be forward and right. But, if the sensor reading is very close to an object then make it back up and turn a little, then forwards and turn.
Excuse the crude sketch but something like this...
ok so make it back up then turn if value is 220-255(very close)?
very close on a ping sensor is the lower end. so 1 to 15 or so... I think it measures inches but not 100% sure since I use IR (which are the other way around)
However, it should never get to a distance where it needs to back up since the further distance of forward turning will happen first, unless it turns into a wall. But you could have other variables and sensors etc. set up to have it decide what action to take.
ok. i'll look into it. will probably post it tomorrow. maybe tonight.
just started working on a siren script that will use motion tracking and a soundboard.
I need a way to say: start motion tracking(with horizontal servo moving back and forth slowly) if motion detected start siren(track 1) wait 5 seconds. if no motion detected go back to motion tracking.
ControlCommands will start those, check the control section of EZ-Script for the commands.
You will need to create a loop so it goes for 5 seconds, with sleeps and a sound the correct length or have the sound 5 seconds long since soundboard doesn't loop the sound.
To loop for 5 seconds you'll need a counter and an if;
Depending on the sound, you may need to increase the condition of the if and reduce the sleep, say if $x <= 50 and sleep(100)
ok Ill look into it. EDIT: so what tells ARC to play a certain track?
Hi guys sorry to butt in but I have a question. I'm not very familiar with ARCs code yet but I do know programming in general so I have to ask, I see you declare $onlyforward as 0 and check it to see if it's 1 but I don't see where it ever gets set to 1. Is it being set in one of the scripts you're calling?
It's a good question. I'm twelve so I don't have very much programing knowledge.
If your saying that you declare $onlyforward as 0 and it changes to 1, that could be caused by another script. just my guess. also, it would be better to make a new post for your question because it doesn't directly relate to what me and rich are talking about.
Rich should be able to answer that
At the top of the script in the config area. There are options for everything. Setting this to 1 here before running the script will make it check for forward movement before doing anything.
My question was about your code specifically. For some reason I was thinking that $onlyforward was saying to go only forward, not trigger the script only if it is moving forward. I was reading it wrong. Thanks for you answers. I'll let you guys get back to it. I hope you get it all worked out. :-)
is this right? i'm working on my ar drone and I made this script to warn me when the battery is at minimum point.