All what Andrew wrote is true!!
When I looked around for the best way to do this kind of thing with the
Raspberry Pi, I came across a close cousin of the HC-SR04, the US-100.
That seems to be able to all the measurements internally (in one of it's
modes) and talk 9600 baud serial to the 'computer'. That would probably
be a much better way to handle this with a Pi alone;-)
https://www.adafruit.com/product/4019
Does somebody have experience with that sensor [in serial mode]?
Thanks,
-- Marco
> sr04/ <
https://tutorials-raspberrypi.com/raspberry-pi-ultrasonic-
> sensor-hc-sr04/>
> Writing-A-Simple-Py-Publisher-And-Subscriber.html <https://
>
docs.ros.org/en/jazzy/Tutorials/Beginner-Client-Libraries/Writing-A-
> Simple-Py-Publisher-And-Subscriber.html>
>
> First, connect the Raspberry Pi and HC-SR04 distance sensor
> according to the Python-based ultrasonic sensor program above,
> ensuring it works in Python before converting it into a ROS2 topic.
>
> Next, create the "simple publisher" (and subscriber) as
> instructed on the Pi and ensure it works. That is, you type "ros2
> run py_pubsub talker" and it says, "hello world." Then, in another
> terminal window, type "ros2 run py_pubsub listener"; it should hear
> the text, "hello world."
>
> Finally, replace "publisher_member_function.py" and
> "ultrasonic_distance.py" with the modified contents from this GitHub:
>
> cpeavy2/Smarty_Head
>
https://github.com/cpeavy2/Smarty_Head <
https://github.com/cpeavy2/
> Smarty_Head>
>
> "ultrasonic_distance.py" needs to be in the same directory as
> "publisher_member_function.py."
>
> You'll need to compile (colcon build).
>
> Launch "talker" and then "ROS2 topic echo /distance." You
> should then see the ultrasonic distance expressed as the topic "/
> distance."
>
> What we've observed is that when no obstacles are detected, the
> Python program displays a solid 12-meter reading. In contrast, when
> viewed through the "ROS2 topic echo /distance," the value appears to
> fluctuate erratically, ranging from 1 to 12. When an obstacle is
> detected, the reading is solid.
>
> The hypothesis is that the different timing of the Python
> program and the Simple Publisher causes this volatility.
>
> Thanks,
> Camp
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "HomeBrew Robotics Club" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to
hbrobotics+...@googlegroups.com
> <mailto:
hbrobotics+...@googlegroups.com>.
> To view this discussion visit
https://groups.google.com/d/msgid/
> hbrobotics/bfa20158-3b5d-41c0-bb5f-fa7c930ee455n%
40googlegroups.com
> <
https://groups.google.com/d/msgid/hbrobotics/bfa20158-3b5d-41c0-bb5f-
> fa7c930ee455n%
40googlegroups.com?utm_medium=email&utm_source=footer>.