Skip to content

Commit

Permalink
Merge branch 'humble' into francocipollone/rosbag_launch_file
Browse files Browse the repository at this point in the history
  • Loading branch information
francocipollone authored Sep 4, 2023
2 parents ed24275 + d90723a commit 74115a9
Show file tree
Hide file tree
Showing 5 changed files with 137 additions and 1 deletion.
1 change: 1 addition & 0 deletions andino_bringup/launch/andino_robot.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)
Expand Down
1 change: 1 addition & 0 deletions andino_bringup/launch/rplidar.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down
2 changes: 1 addition & 1 deletion andino_description/urdf/include/andino_control.urdf.xacro
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<!-- TODO(francocipollone): Parameters like loop_rate, device, baud_rate, etc should be loaded from a file or passed via the launch file as xacro args -->
<param name="left_wheel_name">left_wheel_joint</param>
<param name="right_wheel_name">right_wheel_joint</param>
<param name="serial_device">/dev/ttyUSB0</param>
<param name="serial_device">/dev/ttyUSB_ARDUINO</param>
<param name="baud_rate">57600</param>
<param name="timeout">1000</param>
<param name="enc_ticks_per_rev">585</param>
Expand Down
85 changes: 85 additions & 0 deletions andino_hardware/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<number_of_device>`

### 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.
Expand Down
49 changes: 49 additions & 0 deletions andino_slam/launch/rviz.launch.py
Original file line number Diff line number Diff line change
@@ -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,
])

0 comments on commit 74115a9

Please sign in to comment.