Well, the DDS tutorial you want | FastDDS first experience - source code compilation & installation & testing

Hello everyone, I'm Xiaoyu. Yesterday, I was urged by friends in the group in the DDS-related article. I said that the source code is good to experience DDS. Xiaoyu can no longer coo, so I will share it today, FastDDS installation and experience.

1. On the three ways to open FastDDS

Like ordinary ROS packages, FastDDS has three installation methods: binary installation, source code compilation, and Docker.

Because the official put the binary and Docker on the official website. . And you need to fill in your personal information to download. . And the download speed is super super slow. . And it is not convenient to observe the source code. . So Xiaoyu takes you to install from source code.

Originally wanted to make a one-click installation, save everyone typing the script! !

Love a person must not be accustomed to him, so is fish meal, in order to make everyone think more when copying and pasting (actually, to make up the number of words in the article), Xiaoyu will take everyone to install and compile the source code step by step.

However, the source code installation is also very simple, don't be afraid. .

Because DDS is related to ROS2, we can also use colcon to compile without cmake (if you need cmake, you can find it on the official website)

2. Compile and install FastDDS from source code

Downloading and compiling DDS is divided into three steps. The first step can be skipped if you have already installed ROS2. .

1. Installation tool

sudo apt install python3-colcon-common-extensions python3-vcstool zip openjdk-8-jdk  -y

2. Create a directory and download the warehouse

mkdir -p fastdds_ws/src 
cd fastdds_ws && wget https://downloads.gradle-dn.com/distributions/gradle-6.4-bin.zip && unzip gradle-6.4-bin.zip 
wget http://fishros.com/tools/files/fastrtps.repos && vcs import src < fastrtps.repos

3. Compile

colcon buildcd src/fastddsgen/ &&  gradle assemble

Final Step: Configure Environment Variables

xxx is your directory prefix

echo 'source xxx/fastdds_ws/install/setup.bash' >> ~/.bashrcecho 'export PATH=$PATH:xxx/fastdds_ws/gradle-6.4/bin/' >> ~/.bashrcecho 'export DDSGEN=xxx/fastdds_ws/src/fastddsgen/scripts' >> ~/.bashrc

3. HelloFish routine

The RTPS used by DDS is the Real-Time Publish Subscribe protocol. In fact, it feels the same as the publish and subscribe in ROS and ROS2, so we run a routine to send and receive messages, and the message content is calledHelloFish

The program written by Xiaoyu is ready and put on github. You can download it directly to compile and test it~

download code

git clone https://github.com/fishros/dds_tutorial.git

Compile routines​​​​​​​

cd dds_tutorial/examples/01-hellofishrosmkdir build && cd buildcmake .. make

execute routine

open a terminal

./DDSHelloFishRosPublisher

open another terminal

./DDSHelloFishRosSubscribe

View Results

The correct result is like the following, which has proved that everything is OK~

DDS pubsub test

4. Summary

Isn’t it amazing to see the familiar publish and subscribe? The bottom layer of FASTDDS uses a variety of protocols for data transmission, including the unreliable but really fast UDP, the reliable but not very fast TCP, and the unreliable but not very fast transmission. Swap Memory (SHM).

In order to show you what is called low yield (lazy), Xiaoyu decided to explain the code to you tomorrow~

The above content was written by Xiaoyu after staying up late and stepping on the pit. If you read it carefully, it is equivalent to staying up late for free~

Guess you like

Origin blog.csdn.net/qq_27865227/article/details/122922272