legorovers / pirover_simulator

A python based simulator for the 4tronix Inition and Pi2Go robots.
GNU General Public License v3.0
8 stars 39 forks source link

Improve the fidelity of the sensors #18

Open louiseadennis opened 2 months ago

louiseadennis commented 2 months ago

All the sensors on the real robots are noisy while in the simulator they return an exact number based on information in the simulator.

In particular the ultrasonic distance sensor also has effects when the sounds bounces off a surface at an angle that aren't represented in the simulator.

dwoodv2 commented 2 months ago

I am willing to have a try at this!

I had a look at the code and I'm not sure if the binary occupancy grid based method could simulate a sound wave bouncing in the corner for example.

I think a ray tracing method could simulate this but I'm not really sure if this is the best approach or not, I know ray tracing can be very computationally expensive so I am willing to experiment with ray tracing.

louiseadennis commented 2 months ago

Happy to assign it to you, and you can see if a ray tracing approach is feasible.

dwoodv2 commented 1 month ago

I have made a rough implementation of this, checkout https://github.com/dwoodv2/pirover_simulator/tree/raytrace

louiseadennis commented 1 month ago

Do you have any kind test set - or even just a testing walkthrough I can try?

dwoodv2 commented 1 month ago

At the moment I just have print statements that tell you the angle and intensity of each ray, at the moment I am trying to iron out the bug where the ray never reaches the sensor, I probably did something stupid so once that works I'll figure out how to draw the rays

dwoodv2 commented 1 month ago

Only problem is that I don't really know how to draw lines while the game is running so if someone can tell me how to do that, that would be great 👍

dwoodv2 commented 1 month ago

My ray tracing implementation is now working properly! Just run SonarAvoider.py and the pysim.py and you can see the robot path finding correctly. The only thing I need to do now is to tweak the absorption coefficients and the other stuff listed in the TODO of sonar.py

suzanneEmbury commented 1 month ago

This sounds great @dwoodv2 . Are you ready to submit a PR now, so @louiseadennis can try the code out?