From 0603af2e8cbd2d8fbe0024f0776b6b725a9a41cd Mon Sep 17 00:00:00 2001 From: Franco Cipollone <53065142+francocipollone@users.noreply.github.com> Date: Sun, 3 Sep 2023 19:32:15 -0300 Subject: [PATCH 1/2] Adds convenient launch file for rviz in andino_slam package. (#145) Signed-off-by: Franco Cipollone --- andino_slam/launch/rviz.launch.py | 49 +++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 andino_slam/launch/rviz.launch.py diff --git a/andino_slam/launch/rviz.launch.py b/andino_slam/launch/rviz.launch.py new file mode 100644 index 00000000..4379fca5 --- /dev/null +++ b/andino_slam/launch/rviz.launch.py @@ -0,0 +1,49 @@ +# BSD 3-Clause License + +# Copyright (c) 2023, Ekumen Inc. +# All rights reserved. + +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: + +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. + +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. + +# 3. Neither the name of the copyright holder nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. + +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import os + +from ament_index_python.packages import get_package_share_directory +from launch import LaunchDescription +from launch_ros.actions import Node + +def generate_launch_description(): + pkg_andino_slam = get_package_share_directory('andino_slam') + + # RViz + rviz = Node( + package='rviz2', + executable='rviz2', + arguments=['-d', os.path.join(pkg_andino_slam, 'rviz', 'andino_slam.rviz')], + ) + + return LaunchDescription([ + rviz, + ]) From d90723ac07834e9ecac0626617e9d3c64a424dfc Mon Sep 17 00:00:00 2001 From: Franco Cipollone <53065142+francocipollone@users.noreply.github.com> Date: Sun, 3 Sep 2023 19:32:34 -0300 Subject: [PATCH 2/2] Fixes USB port names (#143) Signed-off-by: Franco Cipollone --- andino_bringup/launch/andino_robot.launch.py | 1 + andino_bringup/launch/rplidar.launch.py | 1 + .../urdf/include/andino_control.urdf.xacro | 2 +- andino_hardware/README.md | 85 +++++++++++++++++++ 4 files changed, 88 insertions(+), 1 deletion(-) diff --git a/andino_bringup/launch/andino_robot.launch.py b/andino_bringup/launch/andino_robot.launch.py index 2bd267a7..f04317dd 100644 --- a/andino_bringup/launch/andino_robot.launch.py +++ b/andino_bringup/launch/andino_robot.launch.py @@ -81,6 +81,7 @@ def generate_launch_description(): os.path.join(pkg_andino_bringup, 'launch', 'rplidar.launch.py'), ), launch_arguments={ + "serial_port": '/dev/ttyUSB_LIDAR', }.items(), condition=IfCondition(rplidar) ) diff --git a/andino_bringup/launch/rplidar.launch.py b/andino_bringup/launch/rplidar.launch.py index 40a774f4..563eaa22 100644 --- a/andino_bringup/launch/rplidar.launch.py +++ b/andino_bringup/launch/rplidar.launch.py @@ -133,6 +133,7 @@ def generate_launch_description(): get_package_share_directory("andino_bringup"), "config", "laser_range_filter.yaml", ])], + output='screen', remappings=[ ('scan', 'scan_raw'), ('scan_filtered', 'scan'), diff --git a/andino_description/urdf/include/andino_control.urdf.xacro b/andino_description/urdf/include/andino_control.urdf.xacro index 3f9064e8..8dc8949a 100644 --- a/andino_description/urdf/include/andino_control.urdf.xacro +++ b/andino_description/urdf/include/andino_control.urdf.xacro @@ -8,7 +8,7 @@ left_wheel_joint right_wheel_joint - /dev/ttyUSB0 + /dev/ttyUSB_ARDUINO 57600 1000 585 diff --git a/andino_hardware/README.md b/andino_hardware/README.md index 5ff173da..1d6013b1 100644 --- a/andino_hardware/README.md +++ b/andino_hardware/README.md @@ -154,6 +154,91 @@ For now, after connecting it to the usb port: - `ls -l /dev |grep ttyUSB` - Add extra bits by doing `sudo chmod 666 /dev/ttyUSB` +### USB Port name configuration + +#### Fixed USB port names + +As having multiple USB devices connected to the USB ports of the Raspberry Pi, the automatically assigned USB port numbers could unexpectedly change after a reboot. +To avoid assigning your device to a `tty_USBX` number that isn't the correct onew we should assign fixed USB port name for each connected device. + +The idea is to be able to generate a link between the real `ttyUSBX` port and an invented one. For this we will need to create rules, that every time the Raspberry Pi boots are executed, and therefore we +always point to the correct port name. + +In order to create fixed names for the USB devices follow the instructions: + +1. Check the devices you have connected: + ``` + sudo dmesg | grep ttyUSB + ``` + + ``` + [ 10.016170] usb 1-1.2: ch341-uart converter now attached to ttyUSB0 + [ 309.186487] usb 1-1.1: cp210x converter now attached to ttyUSB1 + ``` + In the setup where this was tested we have: + -> Arduino Microcontroller -> _usb 1-1.2: ch341-uart converter now attached to ttyUSB0_ + -> A1M8 Lidar Scanner -> _usb 1-1.1: cp210x converter now attached to ttyUSB1_ + + _Note: If you don't know how to identify each one you can simply connect them one by one and check this output._ + +2. Look for attributes for each device that we will use to anchor a particular device with a name. + We will use the `idProduct` and `idVendor` of each device. + - Arduino Microcontroller: + ``` + udevadm info --name=/dev/ttyUSB0 --attribute-walk + ``` + You should look for the `idProduct` and `idVendor` under the category that matches the usb number(1-1.X): + In this case the `ttyUSB0` was referenced to the `usb 1-1.2`, so go to that section and find the ids: + ``` + ATTRS{idProduct}=="7523" + ATTRS{idVendor}=="1a86" + ``` + - Lidar Scanner + ``` + udevadm info --name=/dev/ttyUSB1 --attribute-walk + ``` + In this case the `ttyUSB0` was referenced to the `usb 1-1.1`, so go to that section and find the ids: + ``` + ATTRS{idProduct}=="ea60" + ATTRS{idVendor}=="10c4" + ``` + +3. Create the rules: + + Open the file: + ``` + sudo nano /etc/udev/rules.d/10-usb-serial.rules + ``` + + Add the following: + + ``` + SUBSYSTEM=="tty", ATTRS{idProduct}=="7523", ATTRS{idVendor}=="1a86", SYMLINK+="ttyUSB_ARDUINO" + SUBSYSTEM=="tty", ATTRS{idProduct}=="ea60", ATTRS{idVendor}=="10c4", SYMLINK+="ttyUSB_LIDAR" + ``` + Note that in the `symlink` field a fixed name is indicated. + +4. Re-trigger the device manager: + ``` + sudo udevadm trigger + ``` + +5. Verify + ``` + ls -l /dev/ttyUSB* + ``` + ``` + crw-rw---- 1 root dialout 188, 0 Sep 2 15:09 /dev/ttyUSB0 + crw-rw---- 1 root dialout 188, 1 Sep 2 15:09 /dev/ttyUSB1 + lrwxrwxrwx 1 root root 7 Sep 2 15:09 /dev/ttyUSB_ARDUINO -> ttyUSB0 + lrwxrwxrwx 1 root root 7 Sep 2 15:09 /dev/ttyUSB_LIDAR -> ttyUSB1 + ``` + +Done! You can always use your devices by the fixed names without using the port number. +Here, `ttyUSB_ARDUINO` and `ttyUSB_LIDAR` are fixed names for the Arduino Microcontroller and the Lidar Scanner respectively. + +For more information you can take a look at this external tutorial: [Here](https://www.freva.com/assign-fixed-usb-port-names-to-your-raspberry-pi/) + ### Create robot workspace Let's create our workspace and build from source this repository.