feat(gemini2): add OrbbecSDK_ROS2/
This commit is contained in:
@@ -0,0 +1,108 @@
|
||||
## Using Multiple Cameras with the Orbbec ROS 2 Package
|
||||
|
||||
This section describes how to configure and use multiple Orbbec cameras simultaneously in a ROS 2 environment.
|
||||
|
||||
### Identifying Camera USB Ports
|
||||
|
||||
#### Script to List Connected Cameras
|
||||
|
||||
To determine which USB ports the cameras are connected to, you can use the following bash script. This script lists all Orbbec devices attached to the system along with their USB port and serial number.
|
||||
|
||||
```bash
|
||||
#!/bin/bash
|
||||
|
||||
VID="2bc5"
|
||||
|
||||
for dev in /sys/bus/usb/devices/*; do
|
||||
if [ -e "$dev/idVendor" ]; then
|
||||
vid=$(cat "$dev/idVendor")
|
||||
if [ "$vid" == "${VID}" ]; then
|
||||
port=$(basename $dev)
|
||||
product=$(cat "$dev/product" 2>/dev/null) # product name
|
||||
serial=$(cat "$dev/serial" 2>/dev/null) # serial number
|
||||
echo "Found Orbbec device $product, usb port $port, serial number $serial"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
```
|
||||
|
||||
Save this script to a file and execute it in your terminal to output a list of connected cameras.
|
||||
|
||||
### Launching Multiple Cameras
|
||||
|
||||
#### Setup for Multiple Camera Launch
|
||||
|
||||
You can launch multiple cameras by specifying different USB ports for each camera. Below is an example Python script that uses the ROS 2 launch system to start two cameras with individual configurations.
|
||||
|
||||
```python
|
||||
from launch import LaunchDescription
|
||||
from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription, GroupAction, ExecuteProcess
|
||||
from launch.launch_description_sources from ament_index_python.packages import get_package_share_directory
|
||||
import os
|
||||
|
||||
def generate_launch_description():
|
||||
package_dir = get_package_share_directory('orbbec_camera')
|
||||
launch_file_dir = os.path.join(package_dir, 'launch')
|
||||
|
||||
launch1_include = IncludeLaunchDescription(
|
||||
PythonLaunchDescriptionSource(os.path.join(launch_file_dir, 'gemini_330_series.launch.py')),
|
||||
launch_arguments={'camera_name': 'camera_01', 'usb_port': '2-3.4.4.4.1', 'device_num': '2', 'sync_mode': 'free_run'}.items()
|
||||
)
|
||||
|
||||
launch2_include = IncludeLaunchDescription(
|
||||
PythonLaunchDescriptionSource(os.path.join(launch_file_dir, 'gemini_330_series.launch.py')),
|
||||
launch_arguments={'camera_name': 'camera_02', 'usb_port': '2-3.4.4.4.3', 'device_num': '2', 'sync_mode': 'free_run'}.items()
|
||||
)
|
||||
|
||||
ld = LaunchDescription([
|
||||
GroupAction([launch1_include]),
|
||||
GroupAction([launch2_include])
|
||||
])
|
||||
|
||||
return ld
|
||||
```
|
||||
|
||||
#### Running the Launch File
|
||||
|
||||
To execute the launch configuration for multiple cameras, use the command:
|
||||
|
||||
```bash
|
||||
ros2 launch orbbec_camera multi_camera.launch.py
|
||||
```
|
||||
|
||||
### Configuring the TF Tree for Multiple Cameras
|
||||
|
||||
#### Example TF Configuration for Two Cameras
|
||||
|
||||
When using multiple cameras, it's essential to calibrate them and publish a static TF tree for each camera. The following Python script configures the TF tree based on your calibration results:
|
||||
|
||||
```python
|
||||
from launch import LaunchDescription
|
||||
from launch_ros.actions import Node
|
||||
|
||||
def generate_launch_description():
|
||||
ld = LaunchDescription([
|
||||
Node(
|
||||
package='tf2_ros',
|
||||
executable='static_transform_publisher',
|
||||
name='camera_01_tf',
|
||||
arguments=['0', '0', '0', '0', '0', '0', 'base_link', 'camera_01_link'],
|
||||
output='screen'
|
||||
),
|
||||
Node(
|
||||
package='tf2_ros',
|
||||
executable='static_transform_publisher',
|
||||
name='camera_02_tf',
|
||||
arguments=['0', '0', '0', '0', '0', '0', 'base_link', 'camera_02_link'],
|
||||
output='screen'
|
||||
)
|
||||
])
|
||||
|
||||
return ld
|
||||
```
|
||||
|
||||
Save this configuration as `multi_camera_tf.launch.py` in the launch directory of the Orbbec camera package. To run it, use:
|
||||
|
||||
```bash
|
||||
ros2 launch orbbec_camera multi_camera_tf.launch.py
|
||||
```
|
||||
Reference in New Issue
Block a user