Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
jian-dong committed Jul 19, 2024
1 parent 99816bc commit 6f54d51
Show file tree
Hide file tree
Showing 2 changed files with 178 additions and 9 deletions.
28 changes: 19 additions & 9 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ supports ROS 2 Foxy, Humble, and Jazzy distributions.
* [Product support](#product-support)
* [DDS Tuning](#dds-tuning)
* [Frequently Asked Questions](#frequently-asked-questions)
* [No Data Stream from Multiple Cameras](#no-data-stream-from-multiple-cameras)
* [Why Are There So Many Launch Files Here?](#why-are-there-so-many-launch-files-here)
* [Other useful links](#other-useful-links)
* [License](#license)
<!-- TOC -->
Expand Down Expand Up @@ -631,21 +633,29 @@ net.core.rmem_max=2147483647
net.core.rmem_default=2147483647
```

If you use Fast DDS, you can refer to the [Fast DDS Configuration](./docs/fastdds_tuning.md) file.

## Frequently Asked Questions

No Picture from Multiple Cameras
### No Data Stream from Multiple Cameras

- it's possible that the power supply is insufficient.
To avoid this, do not connect all cameras to the same hub and use a powered hub instead.
**Insufficient Power Supply**:
- Ensure that all cameras are not connected to the same hub.
- Use a powered hub to provide sufficient power to each camera.
**High Resolution**:
- Try lowering the resolution to resolve data stream issues.

- It's also possible that the resolution is too high.
To resolve this, try lowering the resolution.
**Increase usbfs_memory_mb Value**:
- Increase the `usbfs_memory_mb` value to 128MB by running the following command:
```bash
echo 128 | sudo tee /sys/module/usbcore/parameters/usbfs_memory_mb
```
- For making this change permanent, check [this link](https://github.com/OpenKinect/libfreenect2/issues/807).

Why are there so many launch files here
### Why Are There So Many Launch Files Here?

- The reason for the presence of multiple launch
files is due to the fact that the default resolutions and image formats of different cameras vary.
To make it easier to use, the launch files have been separated for each camera.
- Multiple launch files exist because different cameras have varying default resolutions and image formats.
- To simplify usage, each camera has its own launch file.

## Other useful links

Expand Down
159 changes: 159 additions & 0 deletions docs/fastdds_tuning.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
Here's a professional, English version of the document you provided for your client regarding tuning Fast DDS for Orbbec
camera usage with ROS2:

---

# Fast DDS Optimization for Orbbec Camera with ROS2

When operating with the default configuration, Fast DDS exhibits suboptimal transmission efficiency, resulting in
significant image transmission delays when used with the Orbbec camera in ROS2. This document provides guidance on
optimizing Fast DDS to enhance image transfer efficiency.

## 1. Adjusting System Parameters

### IP Fragmentation Time

- **Path**: `/proc/sys/net/ipv4/ipfrag_time` (default: 30 seconds)
- **Purpose**: Defines the duration that IP fragments are kept in memory.
- **Adjustment**: Decrease this value to reduce the time window where no fragments are received, which can help reduce
delays. Consider the specific needs of your environment as this setting affects all incoming fragments.

**Example**: Set to 3 seconds.

```bash
sudo sysctl net.ipv4.ipfrag_time=3
```

### IP Fragmentation Memory Threshold

- **Path**: `/proc/sys/net/ipv4/ipfrag_high_thresh` (default: 262144 bytes)
- **Purpose**: Sets the maximum memory used to reassemble IP fragments.
- **Adjustment**: Increase this value to allow more memory for fragment reassembly, which can improve handling of larger
data packets.

**Example**: Increase to 128 MB.

```bash
sudo sysctl net.ipv4.ipfrag_high_thresh=134217728
```

### Maximum Buffer Sizes

- **Purpose**: Configures the maximum buffer sizes for receiving and sending data, which is critical for high-throughput
data transmission.
- **Adjustment**: Set the maximum buffer sizes for both receiving and sending operations.

**Commands**:

```bash
sudo sysctl -w net.core.rmem_max=2147483647
sudo sysctl -w net.core.rmem_default=2147483647
sudo sysctl -w net.core.wmem_max=2147483647
sudo sysctl -w net.core.wmem_default=2147483647
```

Alternatively, make these settings permanent by adding them to the `/etc/sysctl.d/10-fastrtps-max.conf` file.

```bash
sudo gedit /etc/sysctl.d/10-fastrtps-max.conf
```

add blow lines to the file:

```bash
net.core.rmem_max=2147483647
net.core.rmem_default=2147483647
net.core.wmem_max=2147483647
net.core.wmem_default=2147483647
```

then save and exit the file. run `sudo sysctl -p` to apply the changes.

For detailed guidance, refer
to [ROS 2 DDS Tuning Documentation](https://docs.ros.org/en/foxy/How-To-Guides/DDS-tuning.html).

## 2. Fast DDS Configuration

Below is an example of a Fast DDS configuration file optimized for ROS2 usage with the Orbbec camera. This configuration
enhances the overall data transmission by adjusting buffer sizes and transport settings.

### Configuration File: `shm_fastdds.xml`

Place this file in the `$HOME` directory.

```xml
<?xml version="1.0" encoding="UTF-8"?>
<profiles xmlns="http://www.eprosima.com/XMLSchemas/fastRTPS_Profiles">
<transport_descriptors>
<transport_descriptor>
<transport_id>UDP_transport</transport_id>
<type>UDPv4</type>
<maxInitialPeersRange>10</maxInitialPeersRange>
<maxMessageSize>65000</maxMessageSize>
<sendBufferSize>1048576</sendBufferSize>
<receiveBufferSize>1048576</receiveBufferSize>
</transport_descriptor>
</transport_descriptors>
<participant profile_name="participant_profile_ros2" is_default_profile="true">
<rtps>
<name>profile_for_ros2_context</name>
<userTransports>
<transport_id>UDP_transport</transport_id>
</userTransports>
<useBuiltinTransports>false</useBuiltinTransports>
<sendSocketBufferSize>1048576</sendSocketBufferSize>
<listenSocketBufferSize>1048576</listenSocketBufferSize>
<builtin>
<initialPeersList>
<locator>
<udpv4>
<address>127.0.0.1</address>
</udpv4>
</locator>
</initialPeersList>
</builtin>
</rtps>
</participant>
<data_writer profile_name="default publisher profile" is_default_profile="true">
<qos>
<publishMode>
<kind>ASYNCHRONOUS</kind>
</publishMode>
<latencyBudget>
<duration>
<sec>0</sec>
<nanosec>1000000</nanosec>
</duration>
</latencyBudget>
</qos>
<historyMemoryPolicy>PREALLOCATED_WITH_REALLOC</historyMemoryPolicy>
</data_writer>
<data_reader profile_name="default subscription profile" is_default_profile="true">
<qos>
<data_sharing>
<kind>AUTOMATIC</kind>
</data_sharing>
<latencyBudget>
<duration>
<sec>0</sec>
<nanosec>1000000</nanosec>
</duration>
</latencyBudget>
</qos>
<historyMemoryPolicy>PREALLOCATED_WITH_REALLOC</historyMemoryPolicy>
</data_reader>
</profiles>
```

### Environment Variables

Set the following environment variables to use the custom Fast DDS profile:

```bash
export RMW_IMPLEMENTATION=rmw_fastrtps_cpp
export FASTRTPS_DEFAULT_PROFILES_FILE=$HOME/shm_fastdds.xml
export RMW_FASTRTPS_USE_QOS_FROM_XML=1
```

This configuration aims to optimize the data flow and reduce transmission delays, improving the responsiveness and
reliability of the Orbbec camera system in a ROS2 environment.

0 comments on commit 6f54d51

Please sign in to comment.