
R2D2
Spain
Asked
— Edited
You can pause a script and then unpause?
I'm trying to run my personal radar control and I have a script that moves the servo ping sensor, but I would like to pause the movement when turning to avoid obstacle and then unpause to move forward.
I have proven this if successful:
CC ("Script Manager" ScriptPauseOn, "radar")
Not if it is misspelled or does not exist the command "PauseOn" for Script Manager
I have also proven with the command PauseMS but seems not to work.
Thanks in advance for your answers
Try PauseOn rather than ScriptPauseOn. I don't know if it'll work, I am guessing based on the documentation for EZ-Script. All I have personally used are ScriptStart and ScriptStop.
Could you not add in an IF to the script to only execute the commands IF($direction = "forward")?
I can only say one thing: you're a genius Rich, PauseOn not work but if you have had success: IF ($ direction = "forward") at the top of the script of radar, and Endif below. I'm getting closer to my personal radar, just polish some details, Thank you!
Now is also the script ping servo motion:
Only not really pause the program, rather what for and when you run it again it does in the last position that was left, but starts from the beginning. This makes the robot in a loop between senseless and not be able to exit a corner quickly. I'll try to add up the total travel time of the radar (1360ms) in a complete cycle, and set the time and time reverse rotation of the robot to match the 1360ms, so maybe the ping sensor servo Start from the last position that was left.
I'm sure we can fix it starting from the beginning too, I'm just short on time at the moment but will look when I get home later
OK, so from what I understand you want the the servo to pan left and right while moving forwards and pause while turning or not moving? And then to continue from where it left off after pausing.
This one is pretty straight forward as it's going to need to move to one of 3 positions. Either 25, 52 or 77. The part to think about is the direction in which it needs to move when it hits the middle location, so a variable can be used to store the previous position.
First start with the label and goto;
Now add in the code to only work while it is moving forwards using the $direction variable;
Now we need to make the new variable for the previous position;
Next we want to tell it where to go based on current position and previous position
You will also need to add in a starting position for the servo to move to on first run;
Due to position 52 requiring to know a previous position it's easier not to start at position 52 however adding in the $previousposition variable before the loop label avoids this complication.
And finally to let it sleep between moving, add in the comments if you like to and we have the final script that should only work when moving forwards, pause when stopped, turning left, turning right or reversing and then continue from where it left off when it resumes it's forward movement.
This will initially set the servo to position 52 and tell it that the previous position was 25. When movement forwards begins it will look up the servo position, check it and see it's 52. It will then check the $previousposition and see it is 25 therefore moving D14 to position 77.
From there it will check again, see that D14 is in position 77 and move to position 52.
Then it will check again, see D14 in position 52 and the previous position is 77 so will execute the command to move the servo to position 25.
And so on
Fantastic answer, I will try to assimilate the program and prove it tomorrow, anyway I'll have to integrate the scripts which takes a turn when the ping sensor provides a reading of less than 10 inches (for example), I have a script for the center , another dash to the left and one for the right script, plus I have another script to move the ping sensor servo Then I have another script that activates all scripts and another script that paralyzes all Will attach the file so that you can visualize. And thank you very much for the research and development work
The file will summarize best what google translator and I want to say
MINIROBOTPERSONALRADAR(forRich).EZB
I will check it out later. And no thanks are necessary, I find scripting very enjoyable and soothing :-)