Sonar sensors not functioning

I made another clean image and noticed that when i execute these set of commands

the sonars in rostopic list and rosnode list disappear.

ubuntu@testbot:~$ grep -i sonar /home/ubuntu/.ros/log/latest/master.log
[rosmaster.master][INFO] 2021-01-26 13:16:12,899: +PUB [/rosout] /pi_sonar http://testbot.local:39081/
[rosmaster.master][INFO] 2021-01-26 13:16:12,903: +SERVICE [/pi_sonar/get_loggers] /pi_sonar http://testbot.local:39081/
[rosmaster.master][INFO] 2021-01-26 13:16:12,907: +SERVICE [/pi_sonar/set_logger_level] /pi_sonar http://testbot.local:39081/
[rosmaster.master][INFO] 2021-01-26 13:16:12,921: +PUB [/sonars] /pi_sonar http://testbot.local:39081/
[rosmaster.master][INFO] 2021-01-26 13:16:12,925: +PUB [/pi_sonar/sonar_0] /pi_sonar http://testbot.local:39081/
[rosmaster.master][INFO] 2021-01-26 13:16:12,928: +PUB [/pi_sonar/sonar_1] /pi_sonar http://testbot.local:39081/
[rosmaster.master][INFO] 2021-01-26 13:16:12,930: +PUB [/pi_sonar/sonar_2] /pi_sonar http://testbot.local:39081/
[rosmaster.master][INFO] 2021-01-26 13:16:12,934: +PUB [/pi_sonar/sonar_3] /pi_sonar http://testbot.local:39081/
[rosmaster.master][INFO] 2021-01-26 13:16:12,940: +PUB [/pi_sonar/sonar_4] /pi_sonar http://testbot.local:39081/
[rosmaster.master][INFO] 2021-01-26 13:16:12,944: -PUB [/sonars] /pi_sonar http://testbot.local:39081/
[rosmaster.master][INFO] 2021-01-26 13:16:13,015: -PUB [/pi_sonar/sonar_0] /pi_sonar http://testbot.local:39081/
[rosmaster.master][INFO] 2021-01-26 13:16:13,021: -PUB [/pi_sonar/sonar_1] /pi_sonar http://testbot.local:39081/
[rosmaster.master][INFO] 2021-01-26 13:16:13,034: -PUB [/pi_sonar/sonar_2] /pi_sonar http://testbot.local:39081/
[rosmaster.master][INFO] 2021-01-26 13:16:13,066: -PUB [/pi_sonar/sonar_3] /pi_sonar http://testbot.local:39081/
[rosmaster.master][INFO] 2021-01-26 13:16:13,074: -PUB [/pi_sonar/sonar_4] /pi_sonar http://testbot.local:39081/
[rosmaster.master][INFO] 2021-01-26 13:16:13,084: -SERVICE [/pi_sonar/get_loggers] /pi_sonar rosrpc://testbot.local:57485
[rosmaster.master][INFO] 2021-01-26 13:16:13,100: -SERVICE [/pi_sonar/set_logger_level] /pi_sonar rosrpc://testbot.local:57485
[rosmaster.master][INFO] 2021-01-26 13:16:13,266: -PUB [/rosout] /pi_sonar http://testbot.local:39081/

Ok, thanks for doing that. I too have burned fresh image and done the required subset (recall I said the wget part was not required).

it does look like something BESIDES this formula is wrong on your system so I’m going to try to guess and make my system do all the exits (shown with - signs). I think node pi_sonar ran into trouble and gave up.

Lets consider this the set of commands required with fresh image (but I think what you did is ok too but if there is a next time so simplification below).

Start with Pi4 and the 2020-11-07 image freshly burned.
sudo systemctl stop magni-base

cd catkin_ws/src
git clone https://github.com/UbiquityRobotics/pi_sonar
cd pi_sonar
git checkout daemon_pigpio
cd ~/catkin_ws
catkin_make

sudo systemctl enable pigpiod

Use sudo vi /etc/ubiquity/robot.yaml and make the file like this. Never any tabs, only spaces.

Robot Configuration

raspicam: {‘position’ : ‘upward’}

sonars: ‘pi_sonar_v1’ # Use this to enable sonars

Then reboot: sudo shutdown -r now

When it comes up you should see a rate on any given sonar topic such as this command:
ubuntu@ubiquityrobot:~$ rostopic hz /pi_sonar/sonar_3
subscribed to [/pi_sonar/sonar_3]
average rate: 3.967
min: 0.240s max: 0.260s std dev: 0.00843s window: 4
average rate: 3.941
min: 0.240s max: 0.261s std dev: 0.00868s window: 8

Another healthy sign is after bootup and when you can see topics about sonars and
this command: rosnode info /pi_sonar shows publications to sonar topics then this grep of both logs should show as follows: (it ends in 'Sonar node ready)

ubuntu@ubiquityrobot:~$ grep -i sonar .ros/log/latest/*.log
.ros/log/latest/master.log:[rosmaster.master][INFO] 2021-01-27 01:15:02,834: +PUB [/rosout] /pi_sonar http://ubiquityrobot.local:35619/
.ros/log/latest/master.log:[rosmaster.master][INFO] 2021-01-27 01:15:02,837: +SERVICE [/pi_sonar/get_loggers] /pi_sonar http://ubiquityrobot.local:35619/
.ros/log/latest/master.log:[rosmaster.master][INFO] 2021-01-27 01:15:02,842: +SERVICE [/pi_sonar/set_logger_level] /pi_sonar http://ubiquityrobot.local:35619/
.ros/log/latest/master.log:[rosmaster.master][INFO] 2021-01-27 01:15:02,862: +PUB [/sonars] /pi_sonar http://ubiquityrobot.local:35619/
.ros/log/latest/master.log:[rosmaster.master][INFO] 2021-01-27 01:15:02,869: +PUB [/pi_sonar/sonar_0] /pi_sonar http://ubiquityrobot.local:35619/
.ros/log/latest/master.log:[rosmaster.master][INFO] 2021-01-27 01:15:02,884: +PUB [/diagnostics] /pi_sonar http://ubiquityrobot.local:35619/
.ros/log/latest/master.log:[rosmaster.master][INFO] 2021-01-27 01:15:02,913: +PUB [/pi_sonar/sonar_1] /pi_sonar http://ubiquityrobot.local:35619/
.ros/log/latest/master.log:[rosmaster.master][INFO] 2021-01-27 01:15:02,927: +PUB [/pi_sonar/sonar_2] /pi_sonar http://ubiquityrobot.local:35619/
.ros/log/latest/master.log:[rosmaster.master][INFO] 2021-01-27 01:15:02,948: +PUB [/pi_sonar/sonar_3] /pi_sonar http://ubiquityrobot.local:35619/
.ros/log/latest/master.log:[rosmaster.master][INFO] 2021-01-27 01:15:02,960: +PUB [/pi_sonar/sonar_4] /pi_sonar http://ubiquityrobot.local:35619/

.ros/log/latest/rosout.log:1611710102.969983029 INFO [/home/ubuntu/catkin_ws/src/pi_sonar/src/pi_sonar.cpp:220(main) [topics: /rosout, /sonars, /pi_sonar/sonar_0, /diagnostics, /pi_sonar/sonar_1, /pi_sonar/sonar_2, /pi_sonar/sonar_3, /pi_sonar/sonar_4] Pi Sonar node ready

I will try some things like these:

  1. A defective sonar board where a couple sonars are broken
  2. A disconnected cable to sonar board (SUPER easy to have cable not fully pushed in very tight).

Mark

Just to be sure

These two commands are done in the robots terminal and

these commands are done in the workstation?

Sorry to ask something so basic its just Im considering everything to try get it fixed.

After completing this step I can now confirm that it removes anything to do with sonars from rostopic list and rosnode list after rebooting.

This command

returns:

WARNING: topic [/pi_sonar/sonar_3] does not appear to be published yet

initially and then:

subscribed to [/pi_sonar/sonar_3]
no new messages
no new messages
no new messages
^Cno new messages

once i do it again.

this returns:

.ros/log/latest/master.log:[rosmaster.master][INFO] 2021-01-27 05:30:33,761: +PUB [/rosout] /pi_sonar http://testbot.local:33165/
.ros/log/latest/master.log:[rosmaster.master][INFO] 2021-01-27 05:30:33,766: +SERVICE [/pi_sonar/get_loggers] /pi_sonar http://testbot.local:33165/
.ros/log/latest/master.log:[rosmaster.master][INFO] 2021-01-27 05:30:33,769: +SERVICE [/pi_sonar/set_logger_level] /pi_sonar http://testbot.local:33165/
.ros/log/latest/master.log:[rosmaster.master][INFO] 2021-01-27 05:30:33,782: +PUB [/sonars] /pi_sonar http://testbot.local:33165/
.ros/log/latest/master.log:[rosmaster.master][INFO] 2021-01-27 05:30:33,785: +PUB [/pi_sonar/sonar_0] /pi_sonar http://testbot.local:33165/
.ros/log/latest/master.log:[rosmaster.master][INFO] 2021-01-27 05:30:33,788: +PUB [/pi_sonar/sonar_1] /pi_sonar http://testbot.local:33165/
.ros/log/latest/master.log:[rosmaster.master][INFO] 2021-01-27 05:30:33,791: +PUB [/pi_sonar/sonar_2] /pi_sonar http://testbot.local:33165/
.ros/log/latest/master.log:[rosmaster.master][INFO] 2021-01-27 05:30:33,794: +PUB [/pi_sonar/sonar_3] /pi_sonar http://testbot.local:33165/
.ros/log/latest/master.log:[rosmaster.master][INFO] 2021-01-27 05:30:33,797: +PUB [/pi_sonar/sonar_4] /pi_sonar http://testbot.local:33165/
.ros/log/latest/master.log:[rosmaster.master][INFO] 2021-01-27 05:30:33,802: -PUB [/sonars] /pi_sonar http://testbot.local:33165/
.ros/log/latest/master.log:[rosmaster.master][INFO] 2021-01-27 05:30:33,877: -PUB [/pi_sonar/sonar_0] /pi_sonar http://testbot.local:33165/
.ros/log/latest/master.log:[rosmaster.master][INFO] 2021-01-27 05:30:33,882: -PUB [/pi_sonar/sonar_1] /pi_sonar http://testbot.local:33165/
.ros/log/latest/master.log:[rosmaster.master][INFO] 2021-01-27 05:30:33,890: -PUB [/pi_sonar/sonar_2] /pi_sonar http://testbot.local:33165/
.ros/log/latest/master.log:[rosmaster.master][INFO] 2021-01-27 05:30:33,897: -PUB [/pi_sonar/sonar_3] /pi_sonar http://testbot.local:33165/
.ros/log/latest/master.log:[rosmaster.master][INFO] 2021-01-27 05:30:33,903: -PUB [/pi_sonar/sonar_4] /pi_sonar http://testbot.local:33165/
.ros/log/latest/master.log:[rosmaster.master][INFO] 2021-01-27 05:30:33,911: -SERVICE [/pi_sonar/get_loggers] /pi_sonar rosrpc://testbot.local:36755
.ros/log/latest/master.log:[rosmaster.master][INFO] 2021-01-27 05:30:33,917: -SERVICE [/pi_sonar/set_logger_level] /pi_sonar rosrpc://testbot.local:36755
.ros/log/latest/master.log:[rosmaster.master][INFO] 2021-01-27 05:30:34,071: -PUB [/rosout] /pi_sonar http://testbot.local:33165/
.ros/log/latest/master.log:[rosmaster.master][INFO] 2021-01-27 05:31:36,498: +SUB [/pi_sonar/sonar_3] /rostopic_1852_1611725496247 http://testbot.local:41301/
.ros/log/latest/master.log:[rosmaster.master][INFO] 2021-01-27 05:31:42,599: -SUB [/pi_sonar/sonar_3] /rostopic_1852_1611725496247 http://testbot.local:41301/

Sorry for the long post, and thanks again for giving your time to me.

UPDATE:

I fiddled with the sonars themselves and saw that they where pretty bent backwards. Ive bent them back and it seems to be showing up on Rviz, Rostopic echo /sonars and rostopic hz /sonars

Will let you know if I run into anymore problems but it seems to have been a hardware issue.

Kind regards,
Ivano Rech

UPDATE:

All sonars are working besides the front sonar (sonar_3). This means it does not work well with collision detection in move_basic no matter what I make the forwardObstacleThreshold in move_basic.cpp

ALL the commands I have discussed MUST be done completely on the Raspberry Pi SSH itself.
We are installing and enabling code to run on the Magni for all of this.

The workstation is basically a way to view topics and use RViz and so on but has zero impact on any sonar code or other motor control code. Everything I have said is for the Pi4 itself.

Ok, glad things have been sorted out.

I suggest to avoid confusion that if you have questions on range and angle of detection of the sonar units please start a new topic on the forum. This thread is for totally non-working sonar issues. Thanks.

move_basic I think by default ONLY looks at sensor 3 which is the straight ahead one.
Note that the ‘cone’ for these sensors is rather narrow at 50 or so degrees total so for the object to be ‘seen’ the object must be just about directly in front of the Magni if close and can be a bit off to the sides if farther away.

In an unrelated demo I setup you can see a picture that fairly well shows the detection range of each sonar. The robot is looking ‘up’ in this picture that is close to the bottom of this page: https://learn.ubiquityrobotics.com/lidar_navigation

@mjstn2011 I have attempted to replace the sonar_3 (forward facing) by switching it with another sonar (sonar_0) to see whether it was the sonars or the board itself that is faulty. However, now sonar_3 and sonar_0 are not working.

Would it be possible to get a replacement sonar board and could you let me know how I could go about doing so?

Regards,
Ivano

Ivano: You have mentioned the problem earlier about center standoff shorting. I will go with the benefit of the doubt and assume that led to failure of center sonar.
It is tricky to move one sonar to another location because they are hard to unsolder so I understand. Thank you for trying that on your own first.

Can you look at the traces on the PC board with a magnifying glass just to check if one is broken due to the rework? There may still be hope to get your board working for front sonar which is only one used by Move Basic by default.

Can you please tell me just your approximate location such as country and if in USA what state? Don’t post your address, just approximate location at this time please.

I have checked the traces on the pcb but non seem to be damaged. So I am unsure as to what exactly the problem is. The sonar that I replaced (the original one that was not working) gives no voltage difference across the pins now. So it could be the soldering on that sonar that is not right.

I stay near Cape Town, South Africa :south_africa:

Ok, this makes it more complicated, I will check with some folks on how to get something to you.