Ultrasonic sensor readings always zero
Hello there,
I'm following this link https://github.com/ROBOTIS-GIT/emanua... to add an Ultrasonic sensor HC-SR04 to my turtlebot3, burger model.
I installed the sensor, supplying it from the RaspberryPi 5V DCout and the Trigger and Echo pins respectively on the #3 and #4 OpenCR pins.
I'm using ROS melodic distribution: Ubuntu 19.04 in my machine, and Ubuntu 18.04 in the burger bot.
I'm using the following steps to launch the robot sonar example:
On the robot: roslaunch turtlebot3_bringup turtlebot3_robot.launch to initialize the robot;
On the robot: roslaunch turtlebot3_example turtlebot3_sonar.launch to initialize the sonar node.
When I get to "rostopic echo /sensor_state", all the measures from the Sonar sensor are bringing the zero value. I've already checked the pins and ports, and tested the sensor using an Arduino, so it's not broken.
Output from the rostopic echo:
header:
seq: 17497
stamp:
secs: 1583759548
nsecs: 226024932
frame_id: ''
bumper: 2
cliff: 92.0
sonar: 0.0
illumination: 642.0
led: 0
button: 0
torque: True
left_encoder: 3392
right_encoder: 1328
battery: 12.1099996567
---
header:
seq: 17498
stamp:
secs: 1583759548
nsecs: 258024932
frame_id: ''
bumper: 2
cliff: 92.0
sonar: 0.0
illumination: 620.0
led: 0
button: 0
torque: True
left_encoder: 3392
right_encoder: 1328
battery: 12.1499996185
Although Cliff and Ilumination values are non-zero, I'm not using any of these sensors.
How can I properly read the Ultrasonic sensor? I'm first trying to run the turtlebot3_sonar script, which only publishes a movement command to the robot if the distance measured is above certain valor, but unable to make it move due to the readings always being 0.
These are my ROS environment variables:
ROS_VERSION=1
ROS_PYTHON_VERSION=2
ROS_PACKAGE_PATH= omitted due to being too large :P
ROSLISP_PACKAGE_DIRECTORIES= same as above
ROS_ETC_DIR=/home/myuser/ros_catkin_ws/devel_isolated/ros_environment/etc/ros
ROSCONSOLE_CONFIG_FILE=/home/myuser/ros_catkin_ws/src/rosconsole/config/rosconsole.config
ROS_MASTER_URI=http://myrobot:11311
ROS_HOSTNAME=myrobot
ROS_ROOT=/home/myuser/ros_catkin_ws/src/ros/rosbuild
ROS_DISTRO=melodic
Thanks!