This is a neat little project to approach micro-ROS and the possibilities it opens. You may be surprised by its accuracy, I know I was. Take a measuring tape and compare the reported distance to the measured one, Moving an obstacle back and forth in front of it. ![]() Bip bip bipĪssuming compiling and flashing went all fine,Īll we have to do is to plug the board to our computer and launch the micro-ROS agent. You can find its definition and a breakdown of its field online in the ROS2 API documentation.Īll there is to do now is to compile the code,įlash the resulting ‘.uf2’ file and start the micro-ROS agent. Note that we are using the standard sensor_msgs/msgs/Range message. Setting up the micro-ROS node, publisher, timer and executor, The rest of the code is mostly boilerplate, The GPIO pins to which the sonar is wired This setup is depicted in the figure below. connect Pico’s pin 10 (GPIO 7) to the sonar’s ‘Trig’.connect Pico’s pin 9 (GPIO 6) to the sonar’s ‘Echo’.connect Pico’s pin 38 (GND) to the sonar’s ‘Gnd’.connect Pico’s pin 36 (3V3 OUT) to the sonar’s ‘Vcc’.While ‘Trig’ is used to trigger the sensor and ‘Echo’ reports the reception of the echo (the reception of the sound wave that bounced off of an obstacle).įrom there, and referring to the Pi Pico pinout, The ‘HC-SR04P’ board comes with four pins labelledĪs you’ve already guessed, the Vcc and Gnd pins are for the 3.3V line and the ground respectively, That’s a lot of sensing for the price! Wiring up the sonar to the Pi Pico In case you are using a 5V package, make sure to adapt the wiring described below or else you are risking damages to your Pi Pico!įor reference, I ordered a lot of 5 units for less than 10$ including shipping. Given its very small power consumption, it can be powered up directly from the Pi Pico and thus the whole setup can simply be powered from the USB cable. It is this model (the ‘HC-SR04P’) I will be using in this post. I’d recommend you use the ‘HC-SR04P’ model which is the 3.3V variant of the immensely popular ‘HC-SR04’ (5V). Head on over to your favorite electronics supplier and you’re sure to find them for sale. There exists plenty different models of sonars,įortunately most of them works the same way.įurthermore they can be found for a few bucks per unit on the internet. I’ll redirect you to your favorite web search engine as it is a little out of the scope of this post. If this is still unclear or you want to know more about it, Or if it is absorbed by some sound dampening material. Or if it is reverberated back to the sensor by two obstacles at different distances, The sound wave is reverberated away from the sensor, This technology can suffer from all kind of issues if, for example, One can easily calculate the distance travelled by the sound wave and thus the distance to the obstacle that reverberated the sound. Measuring the time difference between the signal emission and reception, Which will bounce off of facing obstacles, I obviously meant the same way as bats perceive the world.Ī sonar is composed of an emitter and a receiver. ![]() ![]() Nah they don’t fly, hunting bugs at dawn So, what’s a sonar, how does it work, which one should I pick? “I’m Bat(sensor)”Ī sonar is an echolocation sensor which allows for measuring distances. It is no mystery why they are so incredibly popular. Sonars are used to measure distances and can therefore be used to detect and locate obstacles so that one can make sure its robot does not run into nearby things. These sensors are cheap, fairly simple to use and surprisingly precise under favorable circumstances. In this tutorial, we will make use of one of the most common sensors in robotics, a sonar. This builds upon the previous post ‘Getting started with micro-ROS on the Pi Pico’,Īs such I’d encourage you to read it first if you are not already familiar with the topic. In this post we will see how to wire up an HC-SR04 range sensor to the Raspberry Pi Pico and publish its readings to the ROS 2 graph using micro-ROS.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |