Jack rosvo
Posts: 1
Joined: Wed Jun 02, 2021 3:11 pm

Mapping using ultrasonic

Wed Jun 02, 2021 3:20 pm

I have three ultrasonic sensor and I want to draw the surrounding environment, I need help and some advice.

User avatar
neilgl
Posts: 3359
Joined: Sun Jan 26, 2014 8:36 pm
Location: Near The National Museum of Computing

Re: Mapping using ultrasonic

Thu Jun 03, 2021 4:40 pm

You may try to move each sensor in small steps along the X, Y and Z axis, recording its distance measurement as you go.
Then plot that data on a 3D graph.

User avatar
B.Goode
Posts: 12286
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: Mapping using ultrasonic

Thu Jun 03, 2021 5:23 pm

Jack rosvo wrote:
Wed Jun 02, 2021 3:20 pm
I have three ultrasonic sensor and I want to draw the surrounding environment, I need help and some advice.

Since you are posting in a Raspberry Pi forum, can we assume that as a starting point you have some model of Raspberry Pi board and that it is running an Operating System such as the recommended Raspberry Pi Buster [32] Operating System?

The gpiozero Pythonlibrary has built-in support for the common model of ultrasonic sensor. https://gpiozero.readthedocs.io/en/stab ... nce-sensor

Good luck with your assignment.

Forris
Raspberry Pi Certified Educator
Raspberry Pi Certified Educator
Posts: 321
Joined: Fri Jan 06, 2012 7:46 pm

Re: Mapping using ultrasonic

Sat Jun 05, 2021 6:08 am

If you're using the cheap HR-04 sensors, it's worth remembering that they are not particularly accurate and can give lots of spurious readings. With this in mind, make sure you take a number of readings for each data point, discard any that are obviously wrong, and use an average of the remaining results, This should give your results some consistency.

And maybe something mathplotlib could hep with visualising your data.

Good luck.

jayben
Posts: 305
Joined: Mon Aug 19, 2019 9:56 pm

Re: Mapping using ultrasonic

Sat Jun 05, 2021 9:54 am

Also bear in mind that many everyday objects don't return a convenient echo back to the sensor. For example, if the transducer is aimed at a smooth wall that is angled at 45 degrees, you won't get a direct echo; the ultrasonic pulse will be deflected, and carry on travelling until it reaches something that can reflect back to the transducer.

So you'll often see incorrect echos that are much further away than they should be, due to the extended journey of the ultrasonic pulse. The best way to get good echos is to create an artificial environment.

amcdonley
Posts: 202
Joined: Mon Jan 26, 2015 5:56 pm
Location: Florida, USA

Re: Mapping using ultrasonic

Thu Jun 24, 2021 12:59 am

You are going to either have to rotate by the FOV width of the US sensor, or put one of the sensors on a pan servo.

What you are wanting to do is called an occupancy grid and it is a bit complex, believe me.

Here is some software that I adapted for my sensor - a Time Of Flight Distance Sensor showing what you can do if you invest the time and effort. I actually lost interest before getting it all correct.

Here is the code: https://github.com/slowrunner/Carl/tree ... s/OccuGrid

Return to “Automation, sensing and robotics”