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?
Otherwise, check the EZ-Cloud, I've added a few files with ping object avoidance scripts.
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.
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
"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
Full is 255, so 3/4 is 191.25 (I'll skip the maths). So make it 191 since it needs to be an integer really.
Code:
If it needs to be greater than or equal to then change the = for >=
Code:
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...
Code:
Code:
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.
Code:
is this good?
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...
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.
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.
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;
Code:
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)
EDIT: so what tells ARC to play a certain track?
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?
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
Code: