Sonar sensors not functioning

Hi,

When trying to test the sonar sensors using rostopic echo /sonars, the command seems to return no information. Because of this the cones for the sonar sensors do not display in Rviz. I have tested the board to see that 5V is across each sensor and I’ve disconnected the centre standoff so that only the four on the sides are there.

When i execute the command rostopic list the following topics do appear:

/pi_sonar/sonar_0
/pi_sonar/sonar_1
/pi_sonar/sonar_2
/pi_sonar/sonar_3
/pi_sonar/sonar_4

And when i enter the command rosnode list, the following appears:

/pi_sonar

We have enabled the sonars in sudo nano etc/ubiquity/robot.yaml as mentioned on the website.

Thanks in advance.

In addition to this I followed the readme file to build the pi_sonar as shown:

Sonar Sensor Handling based on pigpio library.

To build:

cd ~/catkin_ws/src
git clone https://github.com/UbiquityRobotics/pi_sonar.git
cd ..
catkin_make
source devel/setup.bash

The node needs to access the pigpio daemon, hence the following steps to have it run at startup (if it does not do so already):

wget https://raw.githubusercontent.com/joan2937/pigpio/master/util/pigpiod.service
sudo cp pigpiod.service /etc/systemd/system
sudo systemctl enable pigpiod.service
sudo systemctl start pigpiod.service ******(THIS LINE)******

And encountered the following error:

Job for pigpiod.service failed because the control process exited with error code. See “systemctl status pigpiod.service” and “journalctl -xe” for details.

After looking at “systemctl status pigpiod.service” i got the following:

~/catkin_ws$ systemctl status pigpiod.service
● pigpiod.service - Pigpio daemon
Loaded: loaded (/etc/systemd/system/pigpiod.service; enabled; vendor preset:
Active: failed (Result: exit-code) since Thu 2021-01-21 16:06:04 SAST; 23s ag
Process: 27129 ExecStart=/usr/bin/pigpiod (code=exited, status=203/EXEC)

Jan 21 16:06:04 ubuntu-VirtualBox systemd[1]: Starting Pigpio daemon…
Jan 21 16:06:04 ubuntu-VirtualBox systemd[1]: pigpiod.service: Control process e
Jan 21 16:06:04 ubuntu-VirtualBox systemd[1]: Failed to start Pigpio daemon.
Jan 21 16:06:04 ubuntu-VirtualBox systemd[1]: pigpiod.service: Unit entered fail
Jan 21 16:06:04 ubuntu-VirtualBox systemd[1]: pigpiod.service: Failed with resul

Im not sure if this is the cause of my issue. Also I am unsure whether this must be executed in the catkin_ws or not.

Hello,
There is something wrong, I agree. Lets debug it.

Please tell me if you are running a Pi4 or a Pi3 host processor.
Use this command: sudo cat /proc/cpuinfo
Paste the very last line back to here because there is a Rev 1.1 and a rev 1.2 for the Pi4.

The line will be something like this:
Model : Raspberry Pi 4 Model B Rev 1.1

If it is a Pi4 then only the most recent image will properly run the sonar board.
Our images are here: https://downloads.ubiquityrobotics.com/pi.html use the 2020-11-07 for Pi4

For a normal magni the ros log will at an early point say this ‘Pi Sonar node ready’
Obviously you will not see this. Please when the robot is running edit from /home/ubuntu the current ros log which is .ros/log/latest/rosout.log Then search for ‘pi_sonar’ or even ‘sonar’. Use case insensitive search just so nothing is missed.

Report back any sort of sonar lines which if not saying the node is up it is debug info.

Mark

1 Like

Hello Mark,

Thanks for the quick reply. Im using a Raspberry Pi 4 and here is the last line of command sudo cat/proc/cpuinfo:

Model : Raspberry Pi 4 Model B Rev 1.2

I am really new to ROS so am struggling to access the Log files you are refering to. Please could you let me kno how to do so.

Also when I launch the sonar s using roslaunch pi_sonar ubiquity_sonar.launch command it gives me an error saying:

[ERROR] [1611318330.853668047]: Cannot initalize gpio
[pi_sonar-1] process has died [pid 2276, exit code 1, cmd /opt/ros/kinetic/lib/pi_sonar/pi_sonar __name:=pi_sonar __log:=/home/ubuntu/.ros/log/c06a6b86-5c99-11eb-9aa1-6953dc341d3b/pi_sonar-1.log].
log file: /home/ubuntu/.ros/log/c06a6b86-5c99-11eb-9aa1-6953dc341d3b/pi_sonar-1*.log

This could be due to sudo systemctl start pigpiod.service command failing.

1 Like

Whenever you start ROS a new set of logs get generated in home folder under .ros/log
The directory names are long unique strings so there is a shortcut setup for current log.

This folder holds the latest or current logs on magni: /home/ubuntu/.ros/log

Instead of editing just now lets just search the main log called rosout.log for sonar info:
grep -i sonar /home/ubuntu/.ros/log/latest/rosout.log

For the ros log you can edit it I will use vi below but you may replace ‘vi’ with nano if you like that more.

vi /home/ubuntu/.ros/log/latest/rosout.log

I’m going to try to setup a system like you are running and use the 2020-11-07 for Pi4 image.
I do recall some issues with Sonar and Pi4 that had to do with GPIO but I was not doing that work so I do not recall what the resolution was on all that. There is some sort of forum thread that is sort of long that was all about that.

I am contacting the expert on that issue to find out and post back to here.

It may have been that to get it all going you may have had to do the full ‘sudo apt-get upgrade’
So if you want to give that a go or wait, it is your option.

WARNING the process to follow is a couple lines and is here:

Also that upgrade can reset your settings that you may have made in such files as base.yaml

So suggest take out sd micro card you have now and get new and clean image of the 2020-11-07 image. Them bring it up and do the full updating on above web page of our ‘learn’ doc site.

1 Like

For those who wish to verify for me this is how I have fixed this.
I do not claim to be ‘expert’ but everything I do below seems ‘reasonable to me’ and fixes sonars.
I cannot vouch for if it breaks some other GPIO related things so that will await more tests.

Start with a CLEAN burned version of our 2020-11-07 image. Don’t try to do this on some image
you have been messing with to try to get sonars to work.

You of course must enable sonars in /etc/ubiquity/robot.yaml since it is new image.

So as a ‘beta fix’ for experimentation do these thing all from perhaps /home/ubuntu

sudo systemctl stop magni-base
wget https://github.com/joan2937/pigpio/archive/master.zip
unzip master.zip
cd pigpio-master
make
sudo make install

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
sudo shutdown -r now

Let me know how it goes, I am going to look for things it may or may not have broken because remember this is messing with GPIO and that can be used in many ways.

May the Gpio Be With You,
Mark

1 Like

UPDATE:
I have found that the semi-complex step pulling master.zip is not required so that helps.

Thus just do the pull of pi_sonar to the branch specified and the enable of pigpiod and that may be all there is to it.

Again, I am calling on interested parties to try to test and help prove this and we will all get to the end goal of sonars all ok on Pi4 faster. Thank you for any assists.

1 Like

Hi Mark,

When using grep -i sonar /home/ubuntu/.ros/log/latest/rosout.log command to search the log files for sonars, it returns nothing.

When I get the opportunity I will try using a clean burned version of the 2020-11-07 image and the commands you suggested. Will report back to you when if it works or not.

The cmd rostopic echo /sonars now works.
The cmd rostopic echo /pi_sonar/sonar_3 is working.

After making the suggested change:
cd catkin_ws/src
git clone GitHub - UbiquityRobotics/pi_sonar: Package that provides a ROS interface for the sonar array in UbiquityRobotics robots
cd pi_sonar
git checkout daemon_pigpio
cd ~/catkin_ws
catkin_make

sudo systemctl enable pigpiod
sudo shutdown -r now

I have used a new SD card and followed the steps outlined in the above in order to enable the pigpio.

sudo systemctl stop magni-base
wget https://github.com/joan2937/pigpio/archive/master.zip
unzip master.zip
cd pigpio-master
make
sudo make install

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
sudo shutdown -r now

This has still not worked.

Regards,
Ivano Rech

When typing in the command sudo systemctl enable pigpiod into Magni’s terminal i get the error of:

Failed to execute operation: File exists

So im thinking this is not my problem?

Hi,

Could it be that one of the components on the sonar board have shorted due to the centre standoff having been there when the magni initially started up? even though the Voltage across the sonars is 5V?

UPDATE:
now when I type rostopic list the following no longer appears

Ivano: Just to be complete I am wondering if after you came up on the new image with all the changes that you can check these things:

  1. /etc/ubiquity/robot.yaml no longer has the line that says ‘sonars: None’ and that it does have a line that says: sonars: ‘pi_sonar_v1’
    There must be a simple space (not a tab) between the word sonars: and the single quoted rest of the line.

  2. Given above is true type this line so we can verify the pigpiod service is running:
    ps -ef | grep pigpiod
    There should be 2 lines. One shows the grep command in progress but the other line must be present to show that pigpiod is in fact running. If you don’t see pigpiod running

You had a question on the File exists message and I do not know why that is happening. Part of the start command creates a symbolic link so I was thinking doing it a second time may lead to above error but my system does not do that so I don’t have an answer.

I did a reboot after all that stuff because a few of those things like the service would not start till next reboot.

Notice I did an ‘update’ stating the first set of steps involving the ‘wget’ and make and install do not appear to be required for our 2020-11-07 image although that was the formula I used.

Do start whatever you do for these updates with the ‘sudo systemctl stop magni-base’
and then when done a reboot (shutdown -r now) is required.

ubuntu@Devbot2:~$ ps -ef | grep pigpiod
root 541 1 6 09:25 ? 00:00:51 /usr/bin/pigpiod
ubuntu 2233 1791 0 09:37 pts/0 00:00:00 grep --color=auto pigpiod

Also $rosnode list returns nothing about sonars

So if robot.yaml enables it then this seems like we are back to this command because now it is clear the daemon for pigpiod is running.

There is always the chance that this has always been an issue but first we had to get the node to even try to run.

grep -i sonar /home/ubuntu/.ros/log/latest/rosout.log

You also discuss that the standoff was present at an earlier time. That situation is know to lead to damage. So I am now on the path of deciding if the sonar board or the gpio pins leading to it from the Pi4 have been damaged.

does not return anything

How about grep -i sonar /home/ubuntu/.ros/log/latest/master.log

Returns:

[rosmaster.master][INFO] 2021-01-26 11:14:27,471: +SUB [/sonars] /move_basic http://Devbot2.local:46351/
[rosmaster.master][INFO] 2021-01-26 11:15:06,461: +PUB [/rosout] /pi_sonar http://Devbot2.local:37599/
[rosmaster.master][INFO] 2021-01-26 11:15:06,463: +SERVICE [/pi_sonar/get_loggers] /pi_sonar http://Devbot2.local:37599/
[rosmaster.master][INFO] 2021-01-26 11:15:06,468: +SERVICE [/pi_sonar/set_logger_level] /pi_sonar http://Devbot2.local:37599/
[rosmaster.master][INFO] 2021-01-26 11:15:06,490: +PUB [/sonars] /pi_sonar http://Devbot2.local:37599/
[rosmaster.master][INFO] 2021-01-26 11:15:06,497: +PUB [/pi_sonar/sonar_0] /pi_sonar http://Devbot2.local:37599/
[rosmaster.master][INFO] 2021-01-26 11:15:06,503: +PUB [/pi_sonar/sonar_1] /pi_sonar http://Devbot2.local:37599/
[rosmaster.master][INFO] 2021-01-26 11:15:06,509: +PUB [/pi_sonar/sonar_2] /pi_sonar http://Devbot2.local:37599/
[rosmaster.master][INFO] 2021-01-26 11:15:06,516: +PUB [/pi_sonar/sonar_3] /pi_sonar http://Devbot2.local:37599/
[rosmaster.master][INFO] 2021-01-26 11:15:06,522: publisherUpdate[/sonars] → http://Devbot2.local:46351/ [‘http://Devbot2.local:37599/’]
[rosmaster.master][INFO] 2021-01-26 11:15:06,528: publisherUpdate[/sonars] → http://Devbot2.local:46351/ [‘http://Devbot2.local:37599/’]: sec=0.01, result=[1, ‘’, 0]
[rosmaster.master][INFO] 2021-01-26 11:15:06,532: +PUB [/pi_sonar/sonar_4] /pi_sonar http://Devbot2.local:37599/
[rosmaster.master][INFO] 2021-01-26 11:15:06,542: -PUB [/sonars] /pi_sonar http://Devbot2.local:37599/
[rosmaster.master][INFO] 2021-01-26 11:15:06,581: publisherUpdate[/sonars] → http://Devbot2.local:46351/
[rosmaster.master][INFO] 2021-01-26 11:15:06,585: -PUB [/pi_sonar/sonar_0] /pi_sonar http://Devbot2.local:37599/
[rosmaster.master][INFO] 2021-01-26 11:15:06,594: -PUB [/pi_sonar/sonar_1] /pi_sonar http://Devbot2.local:37599/
[rosmaster.master][INFO] 2021-01-26 11:15:06,603: -PUB [/pi_sonar/sonar_2] /pi_sonar http://Devbot2.local:37599/
[rosmaster.master][INFO] 2021-01-26 11:15:06,611: -PUB [/pi_sonar/sonar_3] /pi_sonar http://Devbot2.local:37599/
[rosmaster.master][INFO] 2021-01-26 11:15:06,604: publisherUpdate[/sonars] → http://Devbot2.local:46351/ : sec=0.02, result=[1, ‘’, 0]
[rosmaster.master][INFO] 2021-01-26 11:15:06,620: -PUB [/pi_sonar/sonar_4] /pi_sonar http://Devbot2.local:37599/
[rosmaster.master][INFO] 2021-01-26 11:15:06,652: -SERVICE [/pi_sonar/get_loggers] /pi_sonar rosrpc://Devbot2.local:37467
[rosmaster.master][INFO] 2021-01-26 11:15:06,658: -SERVICE [/pi_sonar/set_logger_level] /pi_sonar rosrpc://Devbot2.local:37467
[rosmaster.master][INFO] 2021-01-26 11:15:06,752: -PUB [/rosout] /pi_sonar http://Devbot2.local:37599/

I wish to simplify this situation. You appear to be showing me output with a lot of things going on that are not part of the standard basic just after boot configuration. I see move_basic for example and some sonar topic remaps.

Can you please not launch your own files and then show me the output from the grep of master.log?

It should look simplier like this:
[rosmaster.master][INFO] 2021-01-26 09:38:40,171: +PUB [/rosout] /pi_sonar http://ubiquityrobot.local:35891/
[rosmaster.master][INFO] 2021-01-26 09:38:40,176: +SERVICE [/pi_sonar/get_loggers] /pi_sonar http://ubiquityrobot.local:35891/
[rosmaster.master][INFO] 2021-01-26 09:38:40,189: +SERVICE [/pi_sonar/set_logger_level] /pi_sonar http://ubiquityrobot.local:35891/
[rosmaster.master][INFO] 2021-01-26 09:38:40,232: +PUB [/sonars] /pi_sonar http://ubiquityrobot.local:35891/
[rosmaster.master][INFO] 2021-01-26 09:38:40,240: +PUB [/pi_sonar/sonar_0] /pi_sonar http://ubiquityrobot.local:35891/
[rosmaster.master][INFO] 2021-01-26 09:38:40,255: +PUB [/diagnostics] /pi_sonar http://ubiquityrobot.local:35891/
[rosmaster.master][INFO] 2021-01-26 09:38:40,281: +PUB [/pi_sonar/sonar_1] /pi_sonar http://ubiquityrobot.local:35891/
[rosmaster.master][INFO] 2021-01-26 09:38:40,304: +PUB [/pi_sonar/sonar_2] /pi_sonar http://ubiquityrobot.local:35891/
[rosmaster.master][INFO] 2021-01-26 09:38:40,315: +PUB [/pi_sonar/sonar_3] /pi_sonar http://ubiquityrobot.local:35891/
[rosmaster.master][INFO] 2021-01-26 09:38:40,336: +PUB [/pi_sonar/sonar_4] /pi_sonar http://ubiquityrobot.local:35891/