We need access permission of the ttyUSB
port to communicate with the sensor. To check whether we have the access, run the following command
groups | grep tty
If we can see tty
in red, we can proceed to the next step. Otherwise, add the current user to the tty group.
sudo usermod -a -G tty $USER
Log out and log back in to verify whether we are in the tty
group now.
bluerobotics-ping
requires Python3. We create the ROS Noetic
virtual environment in Conda so that this package can be used on Ubuntu 16.04/18.04 as well.
- Install
Miniconda
: https://docs.conda.io/en/latest/miniconda.html - Follow https://github.com/RoboStack/ros-noetic to create a
ROS Noetic
virtual environment calledros
- Create a catkin workspace if necessary
mkdir -p ~/sonar_ws/src
- Clone this repo
cd ~/sonar_ws/src
git clone https://github.com/Weizhe-Chen/single_beam_sonar.git
- Install
ping-python
to read the sonar data
conda activate ros
pip install bluerobotics-ping
- Build the package
cd ~/sonar_ws/
catkin build
. devel/setup.bash
- Launch the driver
roslaunch single_beam_sonar driver.launch
- Check the published data
rqt_console
- Alternatively, we can run the node directly rather than doing step 5 and 6
# In another terminal
roscore
# In the terminal with conda virtualenv and ~/sonar_ws/devel/setup.sh sourced
rosrun single_beam_sonar driver.py
-
Check rostopic
rostopic info /sonar rostopic echo /sonar
-
(Optional) I've added the following lines in the
~/.bashrc
file of the on-board computer to activate theNoetic
virtual environment and catkin workspace whenever we open a terminal# vim ~/.bashrc conda activate ros source ~/sonar_ws/devel/setup.bash