一文搞定FastDDs的安装(ubuntu22.04+humble)

本篇文章介绍FastDDs的安装。实测有效。

1、依赖安装

sudo apt install cmake g++ python3-pip wget git

sudo apt install libasio-dev libtinyxml2-dev

sudo apt install libssl-dev

sudo apt install libp11-dev

sudo apt install softhsm2

sudo apt install libengine-pkcs11-openssl

pip3 install -U colcon-common-extensions vcstool

sudo apt install swig

sudo apt install libpython3-dev

2、clocon构建

mkdir ~/Fast-DDS
cd ~/Fast-DDS
wget https://raw.githubusercontent.com/eProsima/Fast-DDS/master/fastdds.repos
mkdir src
vcs import src < fastdds.repos
colcon build --packages-up-to fastdds
source ~/Fast-DDS/install/setup.bash

  echo 'source ~/Fast-DDS/install/setup.bash' >> ~/.bashrc

3、FastDDs-Gen的安装

sudo apt install openjdk-11-jdk

mkdir -p ~/Fast-DDS/src
cd ~/Fast-DDS/src
git clone --recursive https://github.com/eProsima/Fast-DDS-Gen.git fastddsgen
cd fastddsgen
./gradlew assemble

如果存在网络问题,运行以下内容:

nano gradle/wrapper/gradle-wrapper.properties

#修改对应的distributionUrl

distributionUrl=https\://mirrors.huaweicloud.com/gradle/gradle-7.6-bin.zip

mkdir -p ~/.gradle
nano ~/.gradle/init.gradle

#写入如下内容

allprojects {
    repositories {
        maven { url 'https://maven.aliyun.com/repository/public/' }
        maven { url 'https://maven.aliyun.com/repository/google/' }
        maven { url 'https://maven.aliyun.com/repository/gradle-plugin/' }
        maven { url 'https://mirrors.tuna.tsinghua.edu.cn/nexus/content/groups/public/' }
    }
}

ok,安装完成。笔者尝试了多种安装方法,这一套主要的问题点在于FastDDs-Gen安装时的网络问题,按照上述进行配置后,FastDDs就安装完成了。

更简单的请看之前的关于FastDDs的容器安装的文章。

附上FastDDs的官网地址:

https://fast-dds.docs.eprosima.com/en/latest/installation/sources/sources_linux.html

Ubuntu 22.04 + ROS 2 Humble 中,`cartographer_node` 报错 `'Key 'rangefinder_sampling_ratio' not in dictionary'` 通常是因为配置文件中缺少 `rangefinder_sampling_ratio` 参数。以下是具体的解决方案: ### 检查并添加参数到配置文件 需要保证在使用的 `.lua` 配置文件中包含 `rangefinder_sampling_ratio` 参数。该参数一般位于传感器采样配置部分。以下是 2D 和 3D 配置的示例: #### 2D 配置示例 ```lua TRAJECTORY_BUILDER_2D = { -- 其他参数... rangefinder_sampling_ratio = 0.4, -- 其他参数... } ``` #### 3D 配置示例 ```lua TRAJECTORY_BUILDER_3D = { -- 其他参数... rangefinder_sampling_ratio = 0.4, -- 其他参数... } ``` 将 `0.4` 替换为合适的值,该值的范围是 0 到 1,代表测距传感器数据的采样比例。 ### 确认配置文件路径 要确保在启动 `cartographer_node` 时使用的是包含 `rangefinder_sampling_ratio` 参数的正确配置文件。例如,在 ROS 中启动 `cartographer_node` 时,通常会指定配置文件路径: ```bash ros2 run cartographer_ros cartographer_node -configuration_directory /path/to/your/configuration_files -configuration_basename your_config_file.lua ``` 要保证 `your_config_file.lua` 包含所需的参数。 ### 检查环境变量 有时候环境变量可能会影响配置文件的加载。确保没有环境变量覆盖了正确的配置文件路径。 ### 检查代码版本 确认使用的 Cartographer 代码版本与配置文件兼容。不同版本的 Cartographer 可能对配置文件有不同的要求。 ### 完整 2D 配置文件示例 以下是一个完整的 2D 配置文件示例,包含 `rangefinder_sampling_ratio` 参数: ```lua -- 2D Trajectory builder configuration TRAJECTORY_BUILDER_2D = { use_imu_data = false, min_range = 0., max_range = 30., min_z = -0.8, max_z = 2., missing_data_ray_length = 5., num_accumulated_range_data = 1, voxel_filter_size = 0.025, adaptive_voxel_filter = { max_length = 0.5, min_num_points = 200, max_range = 50., }, loop_closure_adaptive_voxel_filter = { max_length = 0.9, min_num_points = 100, max_range = 50., }, use_online_correlative_scan_matching = true, real_time_correlative_scan_matcher = { linear_search_window = 0.1, angular_search_window = math.rad(20.), translation_delta_cost_weight = 1e-1, rotation_delta_cost_weight = 1e-1, }, ceres_scan_matcher = { occupied_space_weight = 1., translation_weight = 10., rotation_weight = 40., ceres_solver_options = { use_nonmonotonic_steps = false, max_num_iterations = 20, num_threads = 1, }, }, motion_filter = { max_time_seconds = 5., max_distance_meters = 0.2, max_angle_radians = math.rad(1.), }, imu_gravity_time_constant = 10., rangefinder_sampling_ratio = 0.4, odometry_sampling_ratio = 1., fixed_frame_pose_sampling_ratio = 1., imu_sampling_ratio = 1., } ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值