Xuven
USA
Asked
— Edited
Resolved by Rich!
Looking for some help / sample of a script combining the 2 for navigation. This is on a omnibot 5402. I have the IR sensor mounted above his speaker. The ultra sonic is on a sweeping servo right above the IR sensor. I tried playing with Richs ping roam script and he just spins in circles. I would be grateful for any help with this.
The thing to remember is ultrasonic measures how far away something is (i.e. the greater the distance the larger the result) and IR measures how close something is (i.e. the closer the object the higher the number).
To get the IR data from the sensor, assuming it's connected to ADC0, you would use a GetACD() command i.e.
To get the ping you use
Then use those within an if i.e.
@ Rich how would I intergrate this into your ping roam script?
Edit the "GetPing" script in the script manager so it also fetches the IR reading, so adding in something like this;
where the comment about adding in extra sensor code is.
The editing the "Detection" script (as indicated in bold);
It would require a new variable for $maxirdistance to be added to the "Start" script so it knows what the maximum/minimum distance for the IR should be for the above IF nest.
More work would be required for the turning as the latest PingRoam had smart turning which basically let the ping sensor determine when it was OK to stop turning. Using both ping and ir you would need to alter this from using a PingWait() command, most likely by using a new script which checks both the ping and the adc and when one or the other says it is OK to move then stop turning.
It would be quite a big edit to the script but it shouldn't be too difficult. It is something I have been trying to get on to for a while since Melvin also uses both ping and IR sensors but I haven't had time to touch it yet.
I would say the Richard Nailed it. Please, Don't forget the Thank him and close the thread.
Thanks rich just the info I was looking for