【米尔-TIAM62开发板-接替335x-试用评测】(一)ROS2交叉编译
1. 前言
该测试报告详细介绍了TIAM62开发板的交叉编译环境、ROS2编译的步骤以及遇到的问题和解决方案、简单的测试程序编写和编译移植以及在板上的测试效果
2. 交叉编译环境搭建
(1) 下载米尔开发板的交叉编译链
搭建交叉编译环境需要米尔提供的编译链,可以在下面的网址中中进行下载,会得到一个名为arago-2023.04-toolchain-2023.04.sh的编译链
d.myirtech.com/MYD-YM62X
(2) 创建一个docker交叉编译环境
要进行TIAM62开发板的开发需要Ubuntu环境的支持,这里我们需要一个安装了Ubuntu系统的虚拟机,Ubuntu的版本是20.04。为了不让检查编译环境影响到Ubuntu虚拟机的环境,这里采用了创建docker的方式来创建一个TIAM62开发板的交叉编译环境。
首先是在Ubuntu系统中安装docker软件,通过以下的方式进行
a. 更新软件包
在Ubuntu终端执行
sudo apt-get update
b. 安装docker依赖
通过以下命令安装docker的依赖包
sudo apt-get install ca-certificates curl gnupg lsb-release
c. 添加docker官方密钥
curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
d. 添加docker镜像源
sudo add-apt-repository "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
之后更新软件源
sudo apt-get update
e. 安装docker
sudo apt-get install docker-ce docker-ce-cli containerd.io
f. 配置用户组(可选)
可以将当前用户添加到docker组,避免每次试用docker都要使用root权限
sudo usermod -aG docker $USER
之后进行重启使修改生效
sudo reboot
g. 运行docker
systemctl start docker
安装完docker之后,可以创建一个docker镜像为后续的交叉编译环境搭建做准备,首先需要编写一个dockerfile
cd ~ & mkdir docker & cd docker
vim dockerfile
FROM ubuntu:20.04
MAINTAINER Docker Newbee <newbee@docker.com>
RUN apt-get -qq update
RUN apt-get -qqy install ruby ruby-dev
RUN gem install sinatra
编写完dockerfile后,执行以下命令创建docker环境
docker build -f dockerfile -t myir-env .
这样会生成一个myir-env的docker镜像,使用以下命令查看docker镜像的id
docker images
之后运行docker镜像
docker run -itd 41f916f6b5c0
运行
docker ps
得到容器信息
然后运行以下命令启动容器
docker exec -it -u root 7db6ef1e7917 bash
进入容器后先修改sources.list,将sources.list修改成以下内容
deb https:
deb https:
deb https:
deb http:
deb [arch=amd64] https:
deb [arch=amd64] http:
更新软件源
sudo apt-get update
更新过程中会出现缺失密钥的错误情况,需要添加密钥,通过以下命令解决
sudo apt-key adv
编译ROS2源码需要colcon工具,通过以下命令进行安装
apt-get install python3-colcon-common-extensions ros-foxy-rosidl-generator-c
安装编译链需要安装一些依赖包,通过以下命令进行安装
apt-get -f -y install git build-essential diffstat texinfo gawk chrpath socat doxygen dos2unix python3 bison flex libssl-dev u-boot-tools mono-devel mono-complete curl lrzsz lzop python3-distutils pseudo python3-sphinx g++-multilib bc python3-pip libc6-dev-i386 jq git-lfs pigz zstd liblz4-tool cpio file autoconf automake xinetd tftpd nfs-kernel-server minicom libncurses5-dev dos2unix screen zstd lz4 python3-pyelftools python3-setuptools swig repo
pip3 install jsonschema pyelftools
然后将之前的arago-2023.04-toolchain-2023.04.sh复制到容器中
docker cp {本地文件夹}/arago-2023.04-toolchain-2023.04.sh 7db6ef1e7917:/home
进入容器后安装编译链
docker exec -it -u root 7db6ef1e7917 bash
cd home
./arago-2023.04-toolchain-2023.04.sh
安装过程中直接两次回车,默认安装在/opt/arago-2023.04/文件夹下。等待一段时间后,在/opt/arago-2023.04/下会出现下图的文件
运行. /opt/arago-2023.04/environment-setup-aarch64-oe-linux
修改环境变量,将编译器换成交叉编译工具。之后运行$CC -v
查看结果
3. ROS2交叉编译
(1) 准备工作
首先使要将ros2的源码赋值到docker中,这里下载的ros2源码是foxy版本
docker cp {本地文件夹}/ros2_foxy /opt/arago-2023.04/sysroots/aarch64-oe-linux/
这里最好是将ros2_foxy的源码赋值到/opt/arago-2023.04/sysroots/文件夹下。如果是复制到其他文件夹,总是会出现找不到ament_cmake相关包的位置,即使source也没有作用。
前面运行arago-2023.04-toolchain-2023.04.sh后,在/opt/arago-2023.04/sysroots/aarch64-oe-linux/usr/bin下安装了python3,但是没有pip工具。这里需要aarch64架构的pip工具下载python依赖包,但是docker环境下通过apt下载的pip包是x86架构的,因此必须通过源码安装pip,通过以下步骤进行下载
cd /home
wget https://files.pythonhosted.org/packages/ef/cc/93f7213b2ab5ed383f98ce8020e632ef256b406b8569606c3f160ed8e1c9/setuptools-68.2.2.tar.gz
wget https://files.pythonhosted.org/packages/1f/7f/4da15e07ccd11c84c1ccc8f6e24288d5e76c99441bf80e315b33542db951/pip-23.3.1.tar.gz
安装pip需要先安装setuptools,首先先解压这两个压缩包
tar zxvf setuptools-68.2.2.tar.gz
tar zxvf pip-23.3.1.tar.gz
进入setuptools-68.2.2文件夹,执行以下命令
cd setuptools-68.2.2
/opt/arago-2023.04/sysroots/aarch64-oe-lin
ux/usr/bin/python3 setup.py install
注意,这里需要用/opt/arago-2023.04/sysroots/aarch64-oe-linux/usr/bin/的python3来安装
然后进入pip-23.3.1文件夹
cd pip-23.3.1
/opt/arago-2023.04/sysroots/aarch64-oe-linux/usr/bin/python3 setup.py install
之后在/opt/arago-2023.04/sysroots/x86_64-arago-linux/usr/bin/可以找到pip3工具
使用pip3工作下载numpy,lark
/opt/arago-2023.04/sysroots/x86_64-arago-linux/usr/bin/pip3 install lark numpy em
在编译rcl_logging包时需要log4cxx的支持,log4cxx包需要apr,apt-util和log4cxx这三个源码包,通过以下命令进行安装
wget https://mirrors.aliyun.com/apache/apr/apr-1.6.5.tar.gz?spm=a2c6h.25603864.0.0.10e67c9c9Hurqo
wget https://mirrors.aliyun.com/apache/apr/apr-util-1.6.3.tar.gz?spm=a2c6h.25603864.0.0.10e67c9cW8n0RQ
wget https://archive.apache.org/dist/logging/log4cxx/0.10.0/apache-log4cxx-0.10.0.tar.gz
解压三个压缩包
tar zxvf apr-1.6.5.tar.gz
tar zxvf apr-util-1.6.3.tar.gz
tar zxvf apache-log4cxx-0.10.0.tar.gz
首先编译安装apr,注意编译前一定要运行. /opt/arago-2023.04/environment-setup-aarch64-oe-linux
cd apr-1.6.5
./configure --host=aarch64-oe-linux --prefix=/opt/arago-2023.04/sysroots/aarch64-oe-linux/usr/local/apr
编译过程中会出现./include/apr_want.h:94:8: error: redefinition of 'struct iovec'
的错误,解决方法是修改include/apr_want.h
#ifndef APR_IOVEC_DEFINED
#define APR_IOVEC_DEFINED
struct iovec
{
void *iov_base;
size_t iov_len;
};
#endif
改为
#if 0
struct iovec
{
void *iov_base;
size_t iov_len;
};
#endif
之后还会报出encoding/apr_escape.c:79:33: error: 'test_char_table' undeclared
的错误,原因是交叉编译出来的tools/gen_test_char在x86架构的主机上没办法运行,因此可以先退出docker在进入,在没有运行. /opt/arago-2023.04/environment-setup-aarch64-oe-linux
的情况下先运行configure
并make
,生成可以在x86架构主机上运行的gen_test_char工具,再运行. /opt/arago-2023.04/environment-setup-aarch64-oe-linux
,再重新编译,具体如下
./configure
make
cp -a tools/gen_test_char ..
make clean
. /opt/arago-2023.04/environment-setup-aarch64-oe-linux
cp -a ../gen_test_char tools/
vim Makefile
line 134:
OBJECTS_gen_test_char = tools/gen_test_char.lo $(LOCAL_LIBS)
屏蔽
#OBJECTS_gen_test_char = tools/gen_test_char.lo $(LOCAL_LIBS)
目的是不生成新的gen_test_char文件
./configure --host=aarch64-oe-linux --prefix=/opt/arago-2023.04/sysroots/aarch64-oe-linux/usr/local/apr
make
make install
之后在/opt/arago-2023.04/sysroots/aarch64-oe-linux/usr/local/apr会看到include和lib文件夹
然后进入apr-util-1.6.3文件夹,执行
cd apr-util-1.6.3
./configure --host=aarch64-oe-linux --prefix=/opt/arago-2023.04/sysroots/aarch64-oe-linux/usr/local/apr-util --with-apr=/opt/arago-2023.04/sysroots/aarch64-oe-linux/usr/local/apr
进入log4cxx文件夹,首先修改几处地方,如下所示
vim src/examples/cpp/console.cpp 在这个文件里添加
#include <stdio.h>
#include <string.h>
vim src/main/cpp/socketoutputstream.cpp 在这个文件里添加
#include <string.h>
vim src/main/cpp/inputstreamreader.cpp 在这个文件里添加
#include <string.h>
然后执行
cd apache-log4cxx-0.10.0
./configure --host=arm --prefix=/opt/arago-2023.04/sysroots/aarch64-oe-linux/usr/local/log4cxx --with-apr=/opt/arago-2023.04/sysroots/aarch64-oe-linux/usr/local/apr -with-apr-util=/opt/arago-2023.04/sysroots/aarch64-oe-linux/usr/local/apr-util
--enable-shared
编译ros2还需要Asio和tinyxml2库的支持,这两个库的源码下载如下
wget https://zenlayer.dl.sourceforge.net/project/asio/asio/1.28.0%20%28Stable%29/asio-1.28.0.tar.gz
git clone https://gitee.com/mirrors/tinyxml2.git
解压asio源码: tar zxvf asio-1.28.0.tar.gz & cd asio-1.28.0
然后执行
./configure --host=aarch64 --prefix=/opt/arago-2023.04/sysroots/aarch64-oe-linux/usr/local/asio
然后编译tinyxml2,执行
cd tinyxml2
mkdir build & cd build
cmake .. -DCMAKE_INSTALL_LIBDIR=/opt/arago-2023.04/sysroots/aarch64-oe-linux/usr/lib/ -DCMAKE_INSTALL_INCLUDEDIR=/opt/arago-2023.04/sysroots/aarch64-oe-linux/usr/include/ -Dtinyxml2_INSTALL_CMAKEDIR=/opt/arago-2023.04/sysroots/aarch64-oe-linux/usr/lib/cmake/ -Dtinyxml2_INSTALL_PKGCONFIGDIR=/opt/arago-2023.04/sysroots/aarch64-oe-linux/usr/lib/pkgconfig/
make
make install
以上是一些依赖包的安装和编译方法。除此之外,ros2在编译过程中可能会通过git下载一些文件,由于网络原因可能会导致git失败,可以通过在外部下载并修改CMakeLists文件避开直接git clone导致的下载失败,这里有几个包需要先在外面下载
foonathan_memory_vendor:
cd /opt/arago-2023.04/sysroots/aarch64-oe-linux/ros2_foxy/src/eProsima/foonathan_memory_vendor
git clone https:
修改foonathan_memory_vendor的CMakeLists.txt如下
cd /opt/arago-2023.04/sysroots/aarch64-oe-linux/ros2_foxy/src/ament/uncrustify_vendor
wget https://github.com/uncrustify/uncrustify/files/13413294/uncrustify-0.78.1.tar.gz
tar zxvf uncrustify-0.78.1.tar.gz
修改uncrustify_vendor的CMakeLists.txt如下
spdlog_vendor:
cd /opt/arago-2023.04/sysroots/aarch64-oe-linux/ros2_foxy/src/ros2/spdlog_vendor
wget https://github.com/gabime/spdlog/archive/v1.5.0.tar.gz
tar zxvf spdlog-v1.5.0.tar.gz
修改spdlog_vendor的CMakeLists.txt如下
cd /opt/arago-2023.04/sysroots/aarch64-oe-linux/ros2_foxy/src/ros2/libyaml_vendor
https:
unzip libyaml-master.zip
修改libyaml_vendor的CMakeLists.txt如下
至此完成编译前的准备工作,开始进入ros2的交叉编译阶段
(2) 交叉编译过程中出现的错误和解决方法
本文并没有将ros2源码的所有包进行编译,只需要编译ros2run包,并能在开发板上成功运行起来即可。因此这里只阐述编译ros2run的过程中所发生的步骤以及错误的解决方法
在docker中首先要确保. /opt/arago-2023.04/environment-setup-aarch64-oe-linux
有运行,然后才能进行ros2的编译
编译ros2的包的基本命令如下
colcon build --packages-select {包名} --install-base /opt/arago-2023.04/sysroots/aarch64-oe-linux/ros/foxy/ --merge-install
编译ros2run之前需要先编译以下的几个package
ament_lint ament_package cyclonedds fastcdr gtest_vendor ament_cmake_core ament_flake8 gmock_vendor ament_cmake_export_definitions ament_cmake_export_include_directories ament_cmake_export_libraries ament_cmake_export_link_flags ament_cmake_include_directories ament_cmake_libraries ament_cmake_python ament_cmake_version ament_pep257 ament_cmake_export_dependencies ament_cmake_export_interfaces ament_cmake_export_targets ament_cmake_target_dependencies ament_cmake_test ament_copyright ament_cmake ament_cmake_gtest ament_cmake_pytest ament_index_python ament_xmllint domain_coordinator ament_cmake_gmock rpyutils foonathan_memory_vendor ament_cmake_ros connext_cmake_module fastrtps fastrtps_cmake_module python_cmake_module rmw_implementation_cmake rosidl_adapter rosidl_typesupport_interface spdlog_vendor rosidl_parser rosidl_runtime_cpp tracetools rcutils rosidl_cmake rcl_logging_log4cxx rcl_logging_noop rcpputils rosidl_generator_dds_idl rosidl_runtime_c libyaml_vendor rcl_logging_spdlog rmw rosidl_generator_c rosidl_typesupport_introspection_c rcl_yaml_param_parser rmw_connext_shared_cpp rosidl_typesupport_connext_cpp rosidl_typesupport_fastrtps_cpp rosidl_typesupport_introspection_cpp rosidl_typesupport_connext_c rosidl_typesupport_fastrtps_c rmw_connext_cpp rosidl_typesupport_c rosidl_generator_py rosidl_typesupport_cpp rosidl_default_runtime builtin_interfaces rmw_dds_common unique_identifier_msgs action_msgs rcl_interfaces rmw_cyclonedds_cpp rmw_fastrtps_shared_cpp rosgraph_msgs rmw_fastrtps_cpp rmw_fastrtps_dynamic_cpp rmw_implementation rcl rcl_action rclpy ros2cli ros2pkg ament_cppcheck ament_cpplint ament_lint_auto ament_lint_cmake ament_cmake_lint_cmake uncrustify_vendor ament_cmake_copyright ament_uncrustify ament_cmake_cppcheck ament_cmake_cpplint ament_cmake_flake8 ament_cmake_pep257 ament_cmake_uncrustify ament_cmake_xmllint ament_lint_common google_benchmark_vendor osrf_testing_tools_cpp ament_cmake_google_benchmark performance_test_fixture osrf_pycommon launch launch_testing mimick_vendor launch_testing_ament_cmake test_interface_files rosidl_generator_cpp rosidl_default_generators test_msgs rosidl_typesupport_cpp lifecycle_msgs std_msgs composition_interfaces launch_ros launch_testing_ros ros2test ros_testing rclcpp
上述的所有包编译完成后,执行colcon build --packages-select ros2run --install-base /opt/arago-2023.04/sysroots/aarch64-oe-linux/ros/foxy/ --merge-install
,完成ros2run编译
这里对几个会出现的错误进行说明
(1) 指令长度
编译的时候需要用到/opt/arago-2023.04/sysroots/aarch64-oe-linux/usr/include/bits/wordsize.h这个文件,在这个文件中当__aarch64__和__LP64__被定义时,会有__WORDSIZE被定为64,这样编译时会按照64位来进行编译,而在编译过程中由于__LP64__没有被定义,会被当做32位进行编译导致错误,这里进行了如下更改来解决错误
(2) google_benchmark_vendor
错误:
/opt/arago-2023.04/sysroots/aarch64-oe-linux/ros2_foxy/build/google_benchmark_vendor/benchmark-1.5.1-prefix/src/benchmark-1.5.1/src/benchmark_register.h:41:21: error: ‘numeric_limits’ is not a member of ‘std’
41 | CHECK_GT(hi, std::numeric_limits::min());
解决方法: 在/opt/arago-2023.04/sysroots/aarch64-oe-linux/ros2_foxy/build/google_benchmark_vendor/benchmark-1.5.1-prefix/src/benchmark-1.5.1/src/benchmark_register.h
中添加#include <limits>
(3) mimick_vendor
错误: CMake Error at CMakeLists.txt:93 (message):
Architecture 'aarch64-oe' is not supported.
解决方法: 如下
vim ros2/mimick_vendor/mimick-f171450b5ebaa3d2538c762a059dfc6ab7a01039/CMakeLists.txt
elseif (_ARCH MATCHES "aarch64-oe")
set (MMK_ARCH "aarch64")
set (MMK_ABI "aarch64")
set (MMK_BITS 64)
set (MMK_ARCH_ARM64 1)
这里需要先下载mimick-f171450b5ebaa3d2538c762a059dfc6ab7a01039,下载地址在ros2/mimick_vendor/CMakeLists.txt
中
(4) rcutils
错误:
/opt/arago-2023.04/sysroots/aarch64-oe-linux/ros2_foxy/src/ros2/rcutils/test/./mocking_utils/filesystem.hpp:101:41: error: using invalid field ‘mocking_utils::filesystem::FileSystem::_xstat_mock’
解决方法: 将rcutils先单独编译,如下
colcon build --packages-select rcutils --cmake-args "-DBUILD_TESTING=0"
(5) foonathan_memory_vendor
错误: /opt/arago-2023.04/sysroots/x86_64-arago-linux/usr/libexec/aarch64-oe-linux/gcc/aarch64-oe-linux/11.3.0/ld: cannot find -lstdc++: No such file or directory
/opt/arago-2023.04/sysroots/x86_64-arago-linux/usr/libexec/aarch64-oe-linux/gcc/aarch64-oe-linux/11.3.0/ld: cannot find -lm: No such file or directory
/opt/arago-2023.04/sysroots/x86_64-arago-linux/usr/libexec/aarch64-oe-linux/gcc/aarch64-oe-linux/11.3.0/ld: cannot find -lc: No such file or directory
解决方案: 如下
vim ros2_foxy/src/eProsima/foonathan_memory_vendor/CMakeLists.txt
#修改20行
options(BUILD_MEMORY_TOOLS "Build memory tools" OFF)
#修改90行,添加
-DCMAKE_CXX_FLAGS=-fPIC
-DCMAKE_CXX_COMPILER=aarch64-oe-linux-g++
-DCMAKE_C_COMPILER=aarch64-oe-linux-gcc
(6) uncrustify_vendor
错误: make[2]: *** [CMakeFiles/uncrustify-0.68.1.dir/build.make:120: uncrustify-0.68.1-prefix/src/uncrustify-0.68.1-stamp/uncrustify-0.68.1-patch] Error 1
make[1]: *** [CMakeFiles/Makefile2:137: CMakeFiles/uncrustify-0.68.1.dir/all] Error 2
make: *** [Makefile:146: all] Error 2
解决方法: 错误发生的原因是src/ament/uncrustify_vendor/install-patch.diff
打补丁到build/uncrustify_vendor/uncrustify-0.68.1-prefix/src/uncrustify-0.68.1/CMakeLists.txt
时,出现1 out of 1 hunk FAILED
的错误,将install-patch.diff的补丁内容复制到build/uncrustify_vendor/uncrustify-0.68.1-prefix/src/uncrustify-0.68.1/CMakeLists.txt
中即可在重新编译,并且注释掉src/ament/uncrustify_vendor/CMakeLists.txt
第55行的
PATCH_COMMAND
${Patch_EXECUTABLE} -p1 -N < ${CMAKE_CURRENT_SOURCE_DIR}/install-patch.diff
(7) rcl
错误: libddsc.so.0, needed by /opt/arago-2023.04/sysroots/aarch64-oe-linux/ros2_foxy/install/rmw_cyclonedds_cpp/lib/librmw_cyclonedds_cpp.so, not found
解决方法: 如下
vim src/ros2/rcl/rcl/CMakeLists.txt
# 修改69行,添加
target_link_libraries(${PROJECT_NAME} "/opt/arago-2023.04/sysroots/aarch64-oe-linux/ros/foxy/lib/libddsc.so.0.7.0")
解决掉上述错误后,就能顺利编译ros2run这个包,所有包的可执行文件、动态库、头文件都被保存在/opt/arago-2023.04/sysroots/aarch64-oe-linux/ros/foxy/
文件夹下面,最后将以下文件传送到开发板上即可
/opt/arago-2023.04/sysroots/aarch64-oe-linux/ros/
libtinyxml2.so
4. 发布者和订阅者简单程序和编译
为了验证板子能不能跑ros的相关程序,现在虚拟机下编写简单的程序,然后交叉编译后移植到开发板上,这里编译一个发布者和订阅者的程序如下
#include "rclcpp/rclcpp.hpp"
#include "interfaces/msg/param.hpp"
class CSubscriber : public rclcpp::Node
{
public:
CSubscriber() : Node("simple_subscriber")
{
m_poSubscriber = this->create_subscription<interfaces::msg::Param>(
"publish_topic",
10,
std::bind(&CSubscriber::SubscribeCallback, this, std::placeholders::_1)
);
}
virtual ~CSubscriber()
{
}
void SubscribeCallback(const interfaces::msg::Param::SharedPtr msg)
{
RCLCPP_INFO(this->get_logger(), "Subscribe: %s, %s", msg->name.c_str(), msg->value.c_str());
}
private:
rclcpp::Subscription<interfaces::msg::Param>::SharedPtr m_poSubscriber;
};
#include "rclcpp/rclcpp.hpp"
#include "interfaces/msg/param.hpp"
class CPublisher : public rclcpp::Node
{
public:
CPublisher() : Node("simple_publisher"), m_nCount(0)
{
m_poPublisher = this->create_publisher<interfaces::msg::Param>(
"publish_topic",
10
);
m_poTimer = this->create_wall_timer(
std::chrono::seconds(2),
std::bind(&CPublisher::TimerCallback, this)
);
}
virtual ~CPublisher()
{
}
void TimerCallback()
{
auto msg = interfaces::msg::Param();
msg.name = "Hello World";
msg.value = std::to_string(m_nCount);
m_nCount++;
m_poPublisher->publish(msg);
RCLCPP_INFO(this->get_logger(), "Publish: %s, %s", msg.name.c_str(), msg.value.c_str());
}
private:
rclcpp::Publisher<interfaces::msg::Param>::SharedPtr m_poPublisher;
rclcpp::TimerBase::SharedPtr m_poTimer;
uint32_t m_nCount;
};
#include "test/publish.hpp"
int main(int argc, char ** argv)
{
rclcpp::init(argc, argv);
auto poPublisher = std::make_shared<CPublisher>();
auto poSubscriber = std::make_shared<CSubscriber>();
rclcpp::executer::SingleThreadExecutor executor;
executor.add_node(poPublisher);
executor.add_node(subscriber);
executor.spin();
rclcpp::shutdown();
return 0;
}
执行如下命令将程序移植到docker上进行编译
docker cp ros2_ws 7db6ef1e7917:/opt/arago-2023.04/sysroots/aarch64-oe-linux/
docker exec -it -u root 7db6ef1e7917 bash
cd /opt/arago-2023.04/sysroots/aarch64-oe-linux/ros2_ws/
colcon build
之后将编译生成的install文件夹传输到开发板上
4. 板上测验
首先在开发板上执行如下命令
source /opt/ros/foxy/setup.bash
source install/setup.bash
然后执行ros2 run test cpp_pubsub
最后的测试效果如下