diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 1dffd57..0000000 --- a/.gitignore +++ /dev/null @@ -1,12 +0,0 @@ -# Build artifacts -build - -# Install artifacts -install - -# Log artifacts -log - -# VSCode database -.vscode/browse.vc.db* - diff --git a/.vscode/browse.vc.db-shm b/.vscode/browse.vc.db-shm deleted file mode 100644 index 2d36fff..0000000 Binary files a/.vscode/browse.vc.db-shm and /dev/null differ diff --git a/.vscode/browse.vc.db-wal b/.vscode/browse.vc.db-wal deleted file mode 100644 index e69de29..0000000 diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json deleted file mode 100644 index 753ea31..0000000 --- a/.vscode/c_cpp_properties.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "configurations": [ - { - "browse": { - "databaseFilename": "${workspaceFolder}/.vscode/browse.vc.db", - "limitSymbolsToIncludedHeaders": false - }, - "includePath": [ - "/home/sunrise/yiliao_ws/install/origincar_base/include/**", - "/home/sunrise/yiliao_ws/install/origincar_msg/include/**", - "/home/sunrise/yiliao_ws/install/lslidar_msgs/include/**", - "/opt/ros/humble/include/**", - "/home/sunrise/yiliao_ws/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/include/**", - "/home/sunrise/yiliao_ws/src/ground_slam/include/**", - "/home/sunrise/yiliao_ws/src/origincar_base/include/**", - "/usr/include/**" - ], - "name": "ros2", - "intelliSenseMode": "gcc-arm64", - "compilerPath": "/usr/bin/gcc", - "cStandard": "gnu11", - "cppStandard": "c++17" - } - ], - "version": 4 -} \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index 7f63e8f..0000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - // 使用 IntelliSense 了解相关属性。 - // 悬停以查看现有属性的描述。 - // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "name": "ROS2 C++ Debug", - "request": "launch", - "type": "cppdbg", - "MIMode": "gdb", - "cwd": "${workspaceFolder}", - "program": "${workspaceFolder}/install/xxx" - }, - { - "name": "ROS2: Launch grab_service", - "request": "launch", - "target": "${workspaceFolder}/install/xxx", - "launch": ["rviz", "gz", "gzserver", "gzclient"], - "type": "ros2" - }, - { - "name": "ROS: Attach", - "request": "attach", - "type": "ros2" - } - ] -} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 1124fb9..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "yaml.schemas": { - "https://www.schemastore.org/package.json": "file:///home/guoch/test_ws/src/gc_navigation2_slamtoolbox/config/mapper_params_localization.yaml" - }, - "ROS2.distro": "humble", - "python.autoComplete.extraPaths": [ - "/home/sunrise/yiliao_ws/install/origincar_base/local/lib/python3.10/dist-packages", - "/home/sunrise/yiliao_ws/install/origincar_msg/local/lib/python3.10/dist-packages", - "/home/sunrise/yiliao_ws/install/lslidar_msgs/local/lib/python3.10/dist-packages", - "/opt/ros/humble/lib/python3.10/site-packages", - "/opt/ros/humble/local/lib/python3.10/dist-packages" - ], - "python.analysis.extraPaths": [ - "/home/sunrise/yiliao_ws/install/origincar_base/local/lib/python3.10/dist-packages", - "/home/sunrise/yiliao_ws/install/origincar_msg/local/lib/python3.10/dist-packages", - "/home/sunrise/yiliao_ws/install/lslidar_msgs/local/lib/python3.10/dist-packages", - "/opt/ros/humble/lib/python3.10/site-packages", - "/opt/ros/humble/local/lib/python3.10/dist-packages" - ] -} \ No newline at end of file diff --git a/CLAUDE.md b/CLAUDE.md deleted file mode 100644 index eab6c1c..0000000 --- a/CLAUDE.md +++ /dev/null @@ -1,165 +0,0 @@ -# CLAUDE.md - -## 项目概述 - -这是一个 ROS 2 Humble 工作空间,用于 Ackermann 转向小车的 Gazebo 仿真、SLAM 建图和 Nav2 导航。同时支持实车部署(无 Gazebo)。 - -## 工作空间结构 - -``` -test_ws/ -├── src/ -│ ├── gc_navigation2_slamtoolbox/ # 仿真版:导航+SLAM 启动文件和配置 -│ │ ├── launch/ # Python launch 文件 -│ │ ├── config/ # slam_toolbox 参数 -│ │ ├── params/ # Nav2 参数 -│ │ ├── maps/ # 地图文件 (.pgm, .yaml, .posegraph) -│ │ └── world/ # Gazebo 模型 (zhihui/) -│ ├── gc_navigation2_real/ # 实车版:导航+SLAM 启动文件和配置(无 Gazebo) -│ │ ├── launch/ # Python launch 文件 -│ │ ├── config/ # slam_toolbox 参数(实车调优) -│ │ ├── params/ # Nav2 参数(use_sim_time=false) -│ │ ├── maps/ # 实车地图存放目录 -│ │ └── behavior_tree/ # 阿克曼自定义行为树 -│ ├── origincar_description/ # 机器人 URDF 和 Gazebo world -│ │ ├── urdf/ # origincar.urdf -│ │ ├── world/ # .world 文件 -│ │ ├── meshes/ # 3D 模型 -│ │ ├── launch/ # display.launch.py -│ │ └── rviz/ # RViz 配置 -│ ├── origincar_base/ # 实车底盘驱动(串口通信+EKF+IMU融合) -│ │ ├── src/ # C++ 源码(origincar_base.cpp) -│ │ ├── scripts/ # cmd_vel_to_ackermann_drive.py -│ │ ├── launch/ # origincar_bringup / base_serial / ekf -│ │ └── config/ # ekf.yaml / imu.yaml -│ ├── origincar_msg/ # 自定义 ROS 2 消息 -│ │ └── msg/ # Data.msg / Sign.msg -│ └── LSLIDAR_X_ROS2-20240228/ # 镭神激光雷达 ROS 2 驱动 -│ └── src/ -│ ├── lslidar_driver/ # 雷达驱动核心 -│ └── lslidar_msgs/ # 雷达消息定义 -├── build/ # colcon build 输出 -├── install/ # colcon install 输出 (含符号链接) -└── log/ # 构建日志 -``` - -## 构建命令 - -```bash -cd /home/guoch/test_ws -source /opt/ros/humble/setup.bash -colcon build --symlink-install -source install/setup.bash -``` - -## 常用 Launch 文件 - -### 仿真版 (gc_navigation2_slamtoolbox) - -| 文件 | 功能 | -|------|------| -| `gc_slam_mapping.launch.py` | Gazebo + SLAM 建图模式 | -| `gc_nav2_with_slam_online.launch.py` | 已知地图 + SLAM 在线更新 + Nav2 导航 | -| `gc_nav2_with_slam.launch.py` | 已知地图 + SLAM 定位 + Nav2 导航 | -| `gc_nav2_with_amcl.launch.py` | AMCL 定位 + Nav2 导航 | - -### 实车版 (gc_navigation2_real) - -| 文件 | 功能 | -|------|------| -| `real_bringup.launch.py` | 基础 bringup(底盘驱动+雷达+TF,无导航) | -| `real_slam_mapping.launch.py` | 实车 SLAM 建图模式 | -| `real_nav2_slam.launch.py` | 已知地图 + SLAM 定位 + Nav2 导航 | -| `real_nav2_slam_online.launch.py` | 已知地图 + SLAM 在线更新 + Nav2 导航 | - -## 机器人参数 (origincar) - -- **类型**: Ackermann 转向小车 -- **尺寸**: 0.276 × 0.214 × 0.211 m (长×宽×高) -- **轴距**: 0.143 m(URDF 中前轮 x=0.0715,后轮 x=-0.0715),**轮距**: 0.189 m -- **轮子**: 半径 0.03 m,厚 0.025 m -- **激光雷达**: 360°, 0.12~3.5 m, 5 Hz(仿真); 镭神 N10 0.15~12m(实车) -- **IMU**: 100 Hz, 含高斯噪声 -- **Gazebo 插件**: `gazebo_ros_ackermann_drive`, `gazebo_ros_ray_sensor`, `gazebo_ros_imu_sensor` - -## 实车 TF 树 - -``` -map ──→ odom_combined ──→ base_footprint ──→ base_link ──→ laser - ↑ ↑ ↑ ↑ -slam_toolbox EKF static TF URDF/static -(定位) (融合odom+IMU) (origincar_bringup) -``` - -- slam_toolbox 发布 `map → odom_combined` -- EKF 发布 `odom_combined → base_footprint` -- origincar_bringup 发布 `base_footprint → base_link`(z=0)、`base_link → laser` -- robot_state_publisher 发布 URDF 各连杆 TF - -### 仿真 vs 实车关键差异 - -| 方面 | 仿真版 | 实车版 | -|------|--------|--------| -| use_sim_time | `true` | `false` | -| odom_frame | `odom` | `odom_combined`(EKF 融合后) | -| 底盘驱动 | Gazebo plugin | origincar_base 串口驱动 | -| 激光雷达 | Gazebo ray plugin | lslidar_driver(镭神 N10) | -| robot_state_publisher | launch 文件内启动 | origincar_bringup 已包含,勿重复启动 | -| joint_state_publisher | launch 文件内启动 | origincar_bringup 已包含,勿重复启动 | - -## 阿克曼底盘模式 - -通过 `akmcar` 参数控制,链路如下: - -``` -origincar_bringup.launch.py - └─ akmcar=LaunchConfiguration('akmcar', default='true') - └─ 传入 base_serial.launch.py - ├─ IfCondition(true) → origincar_base_node (akm_cmd_vel='ackermann_cmd') - │ + cmd_vel_to_ackermann_drive.py (Twist→Ackermann) - └─ UnlessCondition(false) → 差速模式(跳过) -``` - -数据流:`MPPI cmd_vel(Twist) → cmd_vel_to_ackermann_drive.py → ackermann_cmd(AckermannDriveStamped) → STM32` - -关键参数: -- `cmd_vel_to_ackermann_drive.py`: `wheelbase = 0.143`(与 URDF 一致) -- `akmcar=true` 时 STM32 接收 `speed + steering_angle` -- `akmcar=false` 时 STM32 接收 `vx + vy + wz`(固件自行转换) - -## 关键设计 - -1. **map_server** 提供全量静态底图(`/map`) -2. **slam_toolbox** 负责定位和增量建图,重映射 `/map` → `/slam_map` 避免冲突 -3. **Nav2** 使用 `global_costmap/static_layer ← /map` + `local_costmap/obstacle_layer ← /scan` -4. 保存地图: `ros2 service call /slam_toolbox/serialize_map ...` -5. 实车版 launch 文件**不应**自行启动 `robot_state_publisher` 和 `joint_state_publisher`,`origincar_bringup` 已包含 - -## 地图文件 - -地图放在 `src/gc_navigation2_slamtoolbox/maps/`(仿真)和 `src/gc_navigation2_real/maps/`(实车),包含: -- `xxx.pgm` — 地图图像 -- `xxx.yaml` — 地图元数据 (resolution, origin, thresholds) -- `xxx.posegraph` — 序列化的位姿图 - -## Gazebo World - -World 文件在 `src/origincar_description/world/`: -- `zhihui.world` — 智慧楼墙体环境(内联模型) -- `test.world` — 测试环境 -- `fishbot.world` / `gc_world.world` — 其他场景 - -## 实车底盘驱动包 (origincar_base) - -- `origincar_base_node`(C++): 串口读写(/dev/ttyACM0, 115200bps)、航迹推算、四元数姿态解算(Mahony AHRS) -- `cmd_vel_to_ackermann_drive.py`(Python): Twist → AckermannDriveStamped 转换,wheelbase=0.143 -- 帧协议: 24 字节收(帧头0x7B/帧尾0x7D)/ 11 字节发 -- EKF 融合: `/odom` + IMU → `/odom_combined`,`two_d_mode=true` - -## 注意事项 - -- 使用 `--symlink-install` 构建,Python launch 文件修改后无需重新编译 -- `.world` 文件不应使用 `model://` 外部引用,应将模型内联定义 -- `robot_base_frame` 在 ackermann plugin 中应设为 `base_footprint` -- 实车 `gc_navigation2_real` 的 launch 文件调用 `origincar_bringup.launch.py` 时,不再重复启动 `robot_state_publisher` 和 `joint_state_publisher` -- 轴距参数在三处需保持一致:URDF(0.143m)、`cmd_vel_to_ackermann_drive.py`(0.143m)、Nav2 planner `minimum_turning_radius`(0.40m) diff --git a/README.md b/README.md deleted file mode 100644 index 05c0b08..0000000 --- a/README.md +++ /dev/null @@ -1,110 +0,0 @@ -# 智慧医疗2026年代码仓库 - -# 一、文件夹说明 -## `dependencies` -`dependencies.txt`存储依赖名称 - -## `src` -存放源代码 - -## `bashes` -自动脚本的存放路径 - ---- -

-# 二、关于雷达驱动自动配置脚本的说明 -## 1. 配置说明:在设备上配置开机自启动(仅使用雷达的情况直接看第二点) -1. 放到固定位置并授权 - ```bash - sudo cp 你的脚本路径 /usr/local/bin/radar-driver-switch.sh - sudo chmod +x /usr/local/bin/radar-driver-switch.sh - sudo chown root:root /usr/local/bin/radar-driver-switch.sh - ``` -2. 创建 systemd 服务文件 - ```bash - sudo vim /etc/systemd/system/radar-driver-switch.service - ``` - 编辑内容: - ```ini - [Unit] - Description=雷达驱动自动切换程序 - After=sysfs.target udev.target systemd-udevd.service - Before=multi-user.target - - [Service] - Type=oneshot - ExecStart=/usr/local/bin/radar-driver-switch.sh - User=root - Group=root - StandardOutput=journal+console - StandardError=journal+console - - [Install] - WantedBy=multi-user.target - ``` -3. 应用开机自启 - ```bash - sudo systemctl daemon-reload - sudo systemctl enable radar-driver-switch.service - ``` -4. 测试与debug - - 测试一次 - ```bash - sudo systemctl start radar-driver-switch.service - ``` - - 查看状态 / 日志(排查必用) - ```bash - sudo systemctl status radar-driver-switch.service - ``` - - 看 dmesg 日志 - ```bash - dmesg | grep 雷达驱动自动切换程序 - ``` ---- -### 特别说明 -1. 关于退出码对应的情况,详见sh文件开头 -2. 日志输出在`/dev/kmsg`文件中,使用`dmesg | grep 雷达驱动自动切换程序`命令即可查看 - -## 2. 使用说明: -1. 设备开机自动启动脚本连接雷达。若开机时雷达与设备没有物理连接,则需要手动启动脚本连接雷达 -2. 查看雷达是否物理连接 - ```bash - lsusb - ``` - 返回的数据中,如果有` ID 1a86:55d4 QinHeng Electronics USB Single Serial`,则物理连接成功。 -3. 查看是否成功驱动雷达 - ```bash - ls /dev/tty* - ``` - 看返回数据,默认串口连接设备为`ttyACM*`,名为`ttyACM0`的设备是IMU,如果存在`ttyACM1`,则雷达连接失败; - - 如果出现`ttyCH340`,则说明雷达设备驱动成功 - ---- -

-<<<<<<< HEAD -# 三、其它说明 -======= - -# 三、指令 -启动雷达: -`ros2 launch lslidar_driver lsn10_launch.py ` -open new terminal -```bash -ros2 topic pub -1 /lslidar_order std_msgs/msg/Int8 data:\ 1\ # (open radar) -ros2 topic pub -1 /lslidar_order std_msgs/msg/Int8 data:\ 0\ # (close radar) -``` - -# 四、其它说明 ->>>>>>> mo_new -我设置了一些自定义指令,方便终端调试: -```bash -rosbuild # 编译指定包 -build_debug # 以调试模式编译指定包 -foxglove # 启动foxbridge -``` - -<<<<<<< HEAD -======= -# 五、日志 ->>>>>>> mo_new diff --git a/bashes/README.md b/bashes/README.md deleted file mode 100644 index 42b9182..0000000 --- a/bashes/README.md +++ /dev/null @@ -1,52 +0,0 @@ -## 关于雷达驱动自动配置脚本的说明 -### 在设备上配置开机自启动 -1. 放到固定位置并授权 - ```bash - sudo cp 你的脚本路径 /usr/local/bin/radar-driver-switch.sh - sudo chmod +x /usr/local/bin/radar-driver-switch.sh - sudo chown root:root /usr/local/bin/radar-driver-switch.sh - ``` -2. 创建 systemd 服务文件 - ```bash - sudo vim /etc/systemd/system/radar-driver-switch.service - ``` - 编辑内容: - ```ini - [Unit] - Description=雷达驱动自动切换程序 - After=sysfs.target udev.target systemd-udevd.service - Before=multi-user.target - - [Service] - Type=oneshot - ExecStart=/usr/local/bin/radar-driver-switch.sh - User=root - Group=root - StandardOutput=journal+console - StandardError=journal+console - - [Install] - WantedBy=multi-user.target - ``` -3. 应用开机自启 - ```bash - sudo systemctl daemon-reload - sudo systemctl enable radar-driver-switch.service - ``` -4. 测试与debug - - 测试一次 - ```bash - sudo systemctl start radar-driver-switch.service - ``` - - 查看状态 / 日志(排查必用) - ```bash - sudo systemctl status radar-driver-switch.service - ``` - - 看 dmesg 日志 - ```bash - dmesg | grep 雷达驱动自动切换程序 - ``` ---- -### 特别说明 -1. 关于退出码对应的情况,详见sh文件开头 -2. 日志输出在`/dev/kmsg`文件中,使用`dmesg | grep 雷达驱动自动切换程序`命令即可查看 \ No newline at end of file diff --git a/bashes/radar-driver-switch.sh b/bashes/radar-driver-switch.sh deleted file mode 100644 index c64b9ce..0000000 --- a/bashes/radar-driver-switch.sh +++ /dev/null @@ -1,101 +0,0 @@ -#!/bin/bash - -# 退出码说明 -# 0 - 成功 -# 1 - 错误:等待TTY设备就绪超时 -# 2 - 错误:未找到CH343驱动 -# 3 - 错误:雷达端口上未找到CH34x设备 -# 4 - 错误:未从cdc_acm找到雷达接口 -# 5 - 错误:解绑cdc_acm驱动失败 -# 6 - 错误:绑定usb_ch343驱动失败 - -# ── 配置 ──────────────────────────────────────────── -TTY_DEVICE="/dev/ttyACM*" -CDC_ACM_PATH="/sys/bus/usb/drivers/cdc_acm" -USB_CH343_PATH="/sys/bus/usb/drivers/usb_ch343" -RADAR_USB_PORT="1-1.4" # 雷达 CH34x 的 USB 物理端口(固定不变) -CHECK_INTERVAL=1 -MAX_WAIT_SECONDS=30 - -# ── 初始化 ────────────────────────────────────────── -start_time=$(cut -d. -f1 /proc/uptime) - -# ── 1. 等待 TTY 设备就绪 ──────────────────────────── -while true; do - for dev in /dev/ttyACM*; do - [ -e "$dev" ] || continue - if [ -c "$dev" ] && [ -r "$dev" ] && [ -w "$dev" ]; then - echo "[雷达驱动自动切换程序] 设备 $dev 已就绪!" > /dev/kmsg - TTY_DEVICE="$dev" - break 2 - fi - done - - if [ ${MAX_WAIT_SECONDS} -gt 0 ]; then - current_time=$(cut -d. -f1 /proc/uptime) - elapsed_seconds=$((current_time - start_time)) - if [ ${elapsed_seconds} -ge ${MAX_WAIT_SECONDS} ]; then - echo "[雷达驱动自动切换程序] 错误:等待 ${TTY_DEVICE} 超时(${MAX_WAIT_SECONDS}秒)!" > /dev/kmsg - exit 1 - fi - echo "[雷达驱动自动切换程序] 仍在等待${TTY_DEVICE}(已等待${elapsed_seconds}秒)..." > /dev/kmsg - fi - sleep ${CHECK_INTERVAL} -done - -# ── 2. 确认 CH343 驱动已加载 ──────────────────────── -if [ -d "${USB_CH343_PATH}" ]; then - echo "[雷达驱动自动切换程序] CH343驱动已加载,继续..." > /dev/kmsg -else - echo "[雷达驱动自动切换程序] 错误:未找到CH343驱动!" > /dev/kmsg - exit 2 -fi - -# ── 3. 通过物理端口定位雷达 CH34x ─────────────────── -radar_sysfs="/sys/bus/usb/devices/${RADAR_USB_PORT}" - -if [ ! -d "${radar_sysfs}" ]; then - echo "[雷达驱动自动切换程序] 错误:端口 ${RADAR_USB_PORT} 上无设备!" > /dev/kmsg - exit 3 -fi - -vendor_id=$(cat "${radar_sysfs}/idVendor" 2>/dev/null) -product_id=$(cat "${radar_sysfs}/idProduct" 2>/dev/null) - -if [ "${vendor_id}" != "1a86" ] || [ "${product_id}" != "55d4" ]; then - echo "[雷达驱动自动切换程序] 错误:端口 ${RADAR_USB_PORT} 上 VID:PID=${vendor_id}:${product_id},非雷达CH34x!" > /dev/kmsg - exit 3 -fi - -echo "[雷达驱动自动切换程序] 雷达确认位于端口 ${RADAR_USB_PORT},VID:PID=${vendor_id}:${product_id}" > /dev/kmsg - -# ── 4. 查找 cdc_acm 下雷达的接口 ──────────────────── -cdc_acm_sub_addr=$(ls "${CDC_ACM_PATH}" 2>/dev/null | grep "^${RADAR_USB_PORT}:" | head -n 1) - -if [ -z "${cdc_acm_sub_addr}" ]; then - echo "[雷达驱动自动切换程序] 错误:cdc_acm驱动中未找到端口 ${RADAR_USB_PORT} 的接口" > /dev/kmsg - exit 4 -fi - -echo "[雷达驱动自动切换程序] 雷达 cdc_acm 接口:${cdc_acm_sub_addr}" > /dev/kmsg - -# ── 5. 解绑 cdc_acm ───────────────────────────────── -echo "${cdc_acm_sub_addr}" | sudo tee "${CDC_ACM_PATH}/unbind" > /dev/null 2>&1 -if [ $? -eq 0 ]; then - echo "[雷达驱动自动切换程序] 已解绑 cdc_acm:${cdc_acm_sub_addr}" > /dev/kmsg -else - echo "[雷达驱动自动切换程序] 错误:解绑 cdc_acm 失败" > /dev/kmsg - exit 5 -fi - -# ── 6. 绑定 ch343 ─────────────────────────────────── -echo "${cdc_acm_sub_addr}" | sudo tee "${USB_CH343_PATH}/bind" > /dev/null 2>&1 -if [ $? -eq 0 ]; then - echo "[雷达驱动自动切换程序] 已绑定 usb_ch343:${cdc_acm_sub_addr}" > /dev/kmsg -else - echo "[雷达驱动自动切换程序] 错误:绑定 usb_ch343 失败" > /dev/kmsg - exit 6 -fi - -echo "[雷达驱动自动切换程序] 雷达驱动切换完毕!" > /dev/kmsg -exit 0 diff --git a/bashes/radar-driver-switch.sh.bak b/bashes/radar-driver-switch.sh.bak deleted file mode 100644 index edf5f15..0000000 --- a/bashes/radar-driver-switch.sh.bak +++ /dev/null @@ -1,129 +0,0 @@ -#!/bin/bash - -# 退出码说明 -# 0 - 成功 -# 1 - 错误:等待TTY设备就绪超时 -# 2 - 错误:未找到CH343驱动 -# 3 - 错误:未找到含Qingheng的USB设备 -# 4 - 错误:未找到对应USB地址 -# 5 - 错误:未找到cdc_acm绑定的对应USB设备 -# 6 - 错误:解绑cdc_acm驱动失败 -# 7 - 错误:绑定usb_ch343驱动失败 - -# 变量设置 -TTY_DEVICE="/dev/ttyACM*" # 替换为你要等待的tty设备路径 -CDC_ACM_PATH="/sys/bus/usb/drivers/cdc_acm" -USB_CH343_PATH="/sys/bus/usb/drivers/usb_ch343" -CHECK_INTERVAL=1 # 检查设备就绪的时间间隔(秒) -MAX_WAIT_SECONDS=30 # 最大等待时间(秒),0表示无限等待 - -# 初始化变量 -start_time=$(cut -d. -f1 /proc/uptime) -current_time=0 -qinheng_id="" -usb_address="" -vendor_id="" -product_id="" -cdc_acm_sub_addr="" - - -# ----------------- 1. 等待TTY设备就绪 ----------------- -# 循环等待tty设备就绪(检查设备节点是否存在+是否可读写) -while true; do - for dev in /dev/ttyACM*; do - [ -e "$dev" ] || continue - if [ -c "$dev" ] && [ -r "$dev" ] && [ -w "$dev" ]; then - echo "[雷达驱动自动切换程序] 设备 $dev 已就绪!" > /dev/kmsg - TTY_DEVICE="$dev" - break 2 # 跳出两层循环 - fi - done - - if [ ${MAX_WAIT_SECONDS} -gt 0 ]; then - current_time=$(cut -d. -f1 /proc/uptime) - elapsed_seconds=$((current_time - start_time)) - if [ ${elapsed_seconds} -ge ${MAX_WAIT_SECONDS} ]; then - echo "[雷达驱动自动切换程序] 错误:等待 ${TTY_DEVICE} 超时(${MAX_WAIT_SECONDS}秒)!" > /dev/kmsg - exit 1 - fi - echo "[雷达驱动自动切换程序] 仍在等待${TTY_DEVICE}(已等待${elapsed_seconds}秒)..." > /dev/kmsg - fi - - sleep ${CHECK_INTERVAL} -done - -# ------ 2. 查看CH343是否存在 ------ -if ls /sys/bus/usb/drivers/usb_ch343 > /dev/null 2>&1; then - echo "[雷达驱动自动切换程序] 检测到CH343驱动存在,继续执行..." > /dev/kmsg -else - echo "[雷达驱动自动切换程序] 错误:未找到CH343驱动!" > /dev/kmsg - exit 2 -fi - - -# ------------- 3. 查找Qingheng对应的usb接口 ------------- -echo "[雷达驱动自动切换程序] 开始提取QinHeng设备ID..." > /dev/kmsg - -# 执行lsusb并过滤含QinHeng的行,提取ID(核心逻辑) -qinheng_id=$(lsusb | grep "QinHeng" | awk '{print $6}' | head -n 1) - -# 检查是否提取到ID -if [ -z "${qinheng_id}" ]; then - echo "[雷达驱动自动切换程序] 错误:未找到含QinHeng的USB设备!" > /dev/kmsg - exit 3 -else - echo "[雷达驱动自动切换程序] 成功提取QinHeng设备ID:${qinheng_id}" > /dev/kmsg - # 将ID拆分为vendor_id和product_id - vendor_id=$(echo "${qinheng_id}" | cut -d ':' -f 1) - product_id=$(echo "${qinheng_id}" | cut -d ':' -f 2) -fi - -# -------------------- 4. 提取USB地址 -------------------- -echo "[雷达驱动自动切换程序] 开始查找idVendor=${vendor_id},idProduct=${product_id}的USB地址..." > /dev/kmsg -# 核心命令:过滤dmesg日志,提取USB地址 -usb_address=$(dmesg | grep -E "idVendor=${vendor_id}, idProduct=${product_id}" | grep -oE "usb [0-9]+-[0-9.]+:" | awk '{print $2}' | sed 's/://' | tail -n 1) - -# 检查是否提取到USB地址 -if [ -z "${usb_address}" ]; then - echo "[雷达驱动自动切换程序] 错误:未找到对应USB地址" > /dev/kmsg - exit 4 -else - echo "[雷达驱动自动切换程序] 成功找到USB地址:${usb_address}" > /dev/kmsg -fi - -# ---- 5. 找到cdc_acm驱动对应的usb设备 ---- -echo "[雷达驱动自动切换程序] 开始从${CDC_ACM_PATH}提取${usb_address}对应的子地址..." > /dev/kmsg - -cdc_acm_sub_addr=$(ls "${CDC_ACM_PATH}" 2>/dev/null | grep "^${usb_address}:" | head -n 1) - -if [ -z "${cdc_acm_sub_addr}" ]; then - echo "[雷达驱动自动切换程序] 错误:${CDC_ACM_PATH}中未找到${usb_address}绑定的对应USB设备" > /dev/kmsg - exit 5 -else - echo "[雷达驱动自动切换程序] 成功提取cdc_acm子地址:${cdc_acm_sub_addr}" > /dev/kmsg -fi - -# 6. 切换驱动 -echo "[雷达驱动自动切换程序] 开始切换cdc_acm驱动到USB地址${usb_address}..." > /dev/kmsg - -echo "${cdc_acm_sub_addr}" | sudo tee "${CDC_ACM_PATH}/unbind" 2>/dev/null -if [ $? -eq 0 ]; then - echo "[雷达驱动自动切换程序] 成功解绑cdc_acm驱动:${cdc_acm_sub_addr}" > /dev/kmsg -else - echo "[雷达驱动自动切换程序] 错误:解绑cdc_acm驱动失败" > /dev/kmsg - exit 6 -fi - -echo "${cdc_acm_sub_addr}" | sudo tee "${USB_CH343_PATH}/bind" 2>/dev/null -if [ $? -eq 0 ]; then - echo "[雷达驱动自动切换程序] 成功绑定usb_ch343驱动:${cdc_acm_sub_addr}" > /dev/kmsg -else - echo "[雷达驱动自动切换程序] 错误:绑定usb_ch343驱动失败(检查驱动是否加载)" > /dev/kmsg - exit 7 -fi - - -# 执行完成 -echo "[雷达驱动自动切换程序] 雷达驱动自动切换完毕!" > /dev/kmsg - -exit 0 \ No newline at end of file diff --git a/dependencies/dependencies.txt b/dependencies/dependencies.txt deleted file mode 100644 index 489f65e..0000000 --- a/dependencies/dependencies.txt +++ /dev/null @@ -1,5 +0,0 @@ -ros-humble-serial-driver -ros-humble-ackermann-msgs -# 从源码编译serial库 -ros-humble-navigation2 -ros-humble-slam-toolbox \ No newline at end of file diff --git a/src/LSLIDAR_X_ROS2-20240228/src/README.md b/src/LSLIDAR_X_ROS2-20240228/src/README.md deleted file mode 100644 index 9871ecc..0000000 --- a/src/LSLIDAR_X_ROS2-20240228/src/README.md +++ /dev/null @@ -1,44 +0,0 @@ -# lslidar - -## Description -The `lslidar package is a linux ROS2 driver for lslidar M10 ,M10_GPS,M10_P,M10_PLUS and N10. -The package is tested on Ubuntu 20.04 with ROS2 indigo. - -## Compling -This is a Catkin package. Make sure the package is on `ROS_PACKAGE_PATH` after cloning the package to your workspace. And the normal procedure for compling a catkin package will work. - -``` -cd your_work_space -colcon build -source install/setup.bash -ros2 launch lslidar_driver lslidar_launch.py -``` -open new terminal -ros2 topic pub -1 /lslidar_order std_msgs/msg/Int8 data:\ 1\ (open radar) -ros2 topic pub -1 /lslidar_order std_msgs/msg/Int8 data:\ 0\ (close radar) - - - - - -ros2 launch lslidar_driver lslidar_launch.py - -``` - -Note that this launch file launches both the driver, which is the only launch file needed to be used. - - -## FAQ - - -## Bug Report - -Prefer to open an issue. You can also send an E-mail to honghangli@lslidar.com - - - - -RERTION - - - diff --git a/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/CMakeLists.txt b/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/CMakeLists.txt deleted file mode 100644 index 85e13f6..0000000 --- a/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/CMakeLists.txt +++ /dev/null @@ -1,56 +0,0 @@ -cmake_minimum_required(VERSION 3.5) -project(lslidar_driver) - -# Default to C++14 -if(NOT CMAKE_CXX_STANDARD) - set(CMAKE_CXX_STANDARD 14) -endif() - -if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") - add_compile_options(-Wall -Wextra -Wpedantic) -endif() - -set(libpcap_LIBRARIES -lpcap) - -#set(FastRTPS_INCLUDE_DIR /opt/ros/foxy/include) -#set(FastRTPS_LIBRARY_RELEASE /opt/ros/foxy/lib/libfastrtps.so) - -#find_package(Boost REQUIRED COMPONENTS ) -find_package(Boost REQUIRED thread) -find_package(rclcpp REQUIRED) -find_package(PCL REQUIRED) -find_package(diagnostic_updater REQUIRED) -find_package(lslidar_msgs REQUIRED) -find_package(std_msgs REQUIRED) -find_package(ament_cmake REQUIRED) -find_package(pluginlib REQUIRED) -find_package(rclpy REQUIRED) -find_package(pcl_conversions REQUIRED) -find_package(sensor_msgs REQUIRED) -#find_package(PCL REQUIRED COMPONENTS common io) - -include_directories( - include - ${PCL_INCLUDE_DIRS} - ${PCL_COMMON_INCLUDE_DIRS} - ${Boost_INCLUDE_DIRS} -) - -# Node -add_executable(lslidar_driver_node src/lslidar_driver_node.cc src/lslidar_driver.cc src/input.cc src/lsiosr.cpp) -target_link_libraries(lslidar_driver_node ${rclcpp_LIBRARIES} ${libpcap_LIBRARIES} ${Boost_LIBRARIES} Boost::thread) -ament_target_dependencies(lslidar_driver_node rclcpp std_msgs lslidar_msgs sensor_msgs diagnostic_updater pcl_conversions) - - -install(DIRECTORY launch params rviz - DESTINATION share/${PROJECT_NAME}) - -install(TARGETS - lslidar_driver_node - DESTINATION lib/${PROJECT_NAME} -) - -ament_export_dependencies(rclcpp pluginlib lslidar_msgs sensor_msgs pcl_conversions) -ament_export_include_directories(include ${PCL_COMMON_INCLUDE_DIRS}) - -ament_package() diff --git a/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/include/lslidar_driver/input.h b/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/include/lslidar_driver/input.h deleted file mode 100644 index 2715da4..0000000 --- a/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/include/lslidar_driver/input.h +++ /dev/null @@ -1,134 +0,0 @@ -/* - * This file is part of lslidar_ch driver. - * - * The driver is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * The driver is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with the driver. If not, see . - * - * Input -- base class used to access the data independently of - * its source - * - * InputSocket -- derived class reads live data from the device - * via a UDP socket - * - * InputPCAP -- derived class provides a similar interface from a - * PCAP dump - */ - -#ifndef __LSLIDAR_INPUT_H_ -#define __LSLIDAR_INPUT_H_ - -#include -#include -#include -#include -#include "rclcpp/rclcpp.hpp" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace lslidar_driver -{ -static uint16_t MSOP_DATA_PORT_NUMBER = 2368; // lslidar default data port on PC -/** - * 从在线的网络数据或离线的网络抓包数据(pcap文件)中提取出lidar的原始数据,即packet数据包 - * @brief The Input class, - * - * @param private_nh 一个NodeHandled,用于通过节点传递参数 - * @param port - * @returns 0 if successful, - * -1 if end of file - * >0 if incomplete packet (is this possible?) - */ -class Input -{ -public: - Input(rclcpp::Node* private_nh, uint16_t port); - - virtual ~Input() - { - } - - virtual int getPacket(lslidar_msgs::msg::LslidarPacket::UniquePtr &packet) = 0; - - int getRpm(void); - int getReturnMode(void); - bool getUpdateFlag(void); - void clearUpdateFlag(void); - void UDP_order(const std_msgs::msg::Int8 msg); - void UDP_difop(); -protected: - rclcpp::Node* private_nh_; - uint16_t port_; - std::string devip_str_; - std::string lidar_name; - int cur_rpm_; - int return_mode_; - bool npkt_update_flag_; - bool add_multicast; - std::string group_ip; - int UDP_PORT_NUMBER_DIFOP; - int socket_id_difop; - int sockfd_; - std::string devip_str_difop; -}; - -/** @brief Live lslidar input from socket. */ -class InputSocket : public Input -{ -public: - InputSocket(rclcpp::Node* private_nh, uint16_t port = MSOP_DATA_PORT_NUMBER); - - virtual ~InputSocket(); - - virtual int getPacket(lslidar_msgs::msg::LslidarPacket::UniquePtr &packet); - -private: -private: - - in_addr devip_; - in_addr devip_difop; - //struct ip_mreq group; - -}; -class InputPCAP : public Input -{ -public: - InputPCAP(rclcpp::Node* private_nh,uint16_t port = MSOP_DATA_PORT_NUMBER, double packet_rate = 0.0, - std::string filename=""); - virtual ~InputPCAP(); - virtual int getPacket(lslidar_msgs::msg::LslidarPacket::UniquePtr &pkt); -private: - - rclcpp::Rate packet_rate_; - std::string filename_; - pcap_t *pcap_; - bpf_program pcap_packet_filter_; - char errbuf_[PCAP_ERRBUF_SIZE]; - bool empty_; - bool read_once_; - bool read_fast_; - double repeat_delay_; - }; -} - -#endif // __LSLIDAR_INPUT_H diff --git a/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/include/lslidar_driver/lsiosr.h b/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/include/lslidar_driver/lsiosr.h deleted file mode 100644 index 6109497..0000000 --- a/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/include/lslidar_driver/lsiosr.h +++ /dev/null @@ -1,88 +0,0 @@ -/******************************************************* -@company: Copyright (C) 2021, Leishen Intelligent System -@product: LSM10_N10 -@filename: lsiosr.cpp -@brief: -@version: date: author: comments: -@v1.0 22-10-24 li new -*******************************************************/ -#ifndef LSIOSR_H -#define LSIOSR_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -//波特率 -#define BAUD_230400 230400 -#define BAUD_460800 460800 -#define BAUD_500000 500000 -#define BAUD_921600 921600 - -//奇偶校验位 -#define PARITY_ODD 'O' //奇数 -#define PARITY_EVEN 'E' //偶数 -#define PARITY_NONE 'N' //无奇偶校验位 - -//停止位 -#define STOP_BIT_1 1 -#define STOP_BIT_2 2 - -//数据位 -#define DATA_BIT_7 7 -#define DATA_BIT_8 8 - -namespace lslidar_driver -{ -class LSIOSR{ -public: - static LSIOSR* instance(std::string name, int speed, int fd = 0); - - ~LSIOSR(); - - /* 从串口中读取数据 */ - int read(unsigned char *buffer, int length, int timeout = 30); - - /* 向串口传数据 */ - int send(const char* buffer, int length, int timeout = 30); - - /* Empty serial port input buffer */ - void flushinput(); - - /* 串口初始化 */ - int init(); - - int close(); - - /* 获取串口号 */ - std::string getPort(); - - /* 设置串口号 */ - int setPortName(std::string name); - -private: - LSIOSR(std::string name, int speed, int fd); - - int waitWritable(int millis); - int waitReadable(int millis); - - /* 串口配置的函数 */ - int setOpt(int nBits, uint8_t nEvent, int nStop); - - std::string port_; - int baud_rate_; - - int fd_; -}; -} -#endif - diff --git a/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/include/lslidar_driver/lslidar_driver.h b/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/include/lslidar_driver/lslidar_driver.h deleted file mode 100644 index 34bb6d1..0000000 --- a/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/include/lslidar_driver/lslidar_driver.h +++ /dev/null @@ -1,159 +0,0 @@ -/* - * This file is part of lslidar driver. - * - * The driver is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * The driver is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with the driver. If not, see . - */ - -#ifndef LSLIDAR_DRIVER_H -#define LSLIDAR_DRIVER_H - -#include -#include -#include -#include - -#include -#include -#include -#include "rclcpp/rclcpp.hpp" -#include -#include "diagnostic_updater/diagnostic_updater.hpp" -#include "diagnostic_updater/publisher.hpp" -#include "lslidar_msgs/msg/lslidar_packet.hpp" -#include "std_msgs/msg/byte.hpp" - -#include "sensor_msgs/msg/point_cloud2.hpp" -#include "pcl_conversions/pcl_conversions.h" -#include "pcl/point_types.h" - -#include "time.h" -#include "input.h" -#include "lsiosr.h" -#include "sensor_msgs/msg/laser_scan.hpp" -namespace lslidar_driver { - -struct PointXYZIT { - PCL_ADD_POINT4D; - uint8_t intensity; - double timestamp; - EIGEN_MAKE_ALIGNED_OPERATOR_NEW // make sure our new allocators are aligned -} EIGEN_ALIGN16; - -typedef struct { - double degree; - double range; - double intensity; -} ScanPoint; - -class LslidarDriver: public rclcpp::Node { -public: - LslidarDriver(); - LslidarDriver(const rclcpp::NodeOptions& options); - ~LslidarDriver(); - - bool initialize(); - bool polling(); - - typedef std::shared_ptr LslidarDriverPtr; - typedef std::shared_ptr LslidarDriverConstPtr; - -private: - uint64_t get_gps_stamp(struct tm t); - uint8_t N10_CalCRC8(unsigned char * p, int len); - bool loadParameters(); - bool createRosIO(); - void open_serial(); - void lidar_difop(); - void lidar_order(const std_msgs::msg::Int8::SharedPtr msg); - void data_processing(unsigned char *packet_bytes,int len); - void data_processing_2(unsigned char *packet_bytes,int len); - void difop_processing(unsigned char *packet_bytes); - void pubScanThread(); - void recvThread_crc(int &count,int &link_time); - int receive_data(unsigned char *packet_bytes); - int getScan(std::vector &points, rclcpp::Time &scan_time, float &scan_duration); - - boost::thread *pubscan_thread_ ; - boost::shared_ptr msop_input_; - boost::mutex mutex_; - boost::mutex pubscan_mutex_; - boost::condition_variable pubscan_cond_; - int UDP_PORT_NUMBER; - int count_num; - int package_points; - int data_bits_start; - int degree_bits_start; - int end_degree_bits_start; - int rpm_bits_start; - int baud_rate_; - int points_size_; - int idx = 0; - int link_time = 0; - int fixed_array_length;//cyy_add - - bool use_gps_ts; - bool is_start; - bool high_reflection; - bool compensation; - bool first_compensation = true; - bool pubScan; - bool pubPointCloud2; - - double min_range; - double max_range; - double angle_disable_min; - double angle_disable_max; - double angle_able_min; - double angle_able_max; - double last_degree = 0.0; - double degree_compensation = 0.0; - - uint16_t PACKET_SIZE ; - uint64_t sweep_end_time_gps; - uint64_t sweep_end_time_hardware; - uint64_t sub_second; - - std::string frame_id; - std::string interface_selection; - std::string scan_topic; - std::string lidar_name; - std::string serial_port_; - std::string dump_file; - std::string pointcloud_topic; - std::string in_file_name; - - tm pTime; - rclcpp::Time pre_time_; - rclcpp::Time time_; - std::vector scan_points_; - std::vector scan_points_bak_; - // Diagnostics updater - diagnostic_updater::Updater diagnostics; - std::shared_ptr diag_topic; - double diag_min_freq; - double diag_max_freq; - rclcpp::Publisher::SharedPtr scan_pub; - rclcpp::Publisher::SharedPtr point_cloud_pub; - rclcpp::Subscription::SharedPtr difop_switch; - LSIOSR * serial_; -}; -typedef PointXYZIT VPoint; -typedef pcl::PointCloud VPointCloud; - -} // namespace lslidar_driver -POINT_CLOUD_REGISTER_POINT_STRUCT(lslidar_driver::PointXYZIT, - (float, x, x)(float, y, y)(float, z, z)( - std::uint8_t, intensity, - intensity)(double, timestamp, timestamp)) -#endif // _LSLIDAR_DRIVER_H_ diff --git a/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/launch/lslidar_double_launch.py b/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/launch/lslidar_double_launch.py deleted file mode 100644 index 40ad793..0000000 --- a/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/launch/lslidar_double_launch.py +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/python3 -from ament_index_python.packages import get_package_share_directory -from launch import LaunchDescription -from launch_ros.actions import LifecycleNode -from launch.substitutions import LaunchConfiguration -from launch_ros.actions import Node -from launch.actions import DeclareLaunchArgument - -import lifecycle_msgs.msg -import os - -def generate_launch_description(): - - driver_dir_1 = os.path.join(get_package_share_directory('lslidar_driver_n10p'), 'params', 'lsx10_1.yaml') - driver_dir_2 = os.path.join(get_package_share_directory('lslidar_driver_n10p'), 'params', 'lsx10_2.yaml') - - driver_node_1 = LifecycleNode(package='lslidar_driver_n10p', - executable='lslidar_driver_node', - name='lslidar_driver_node', #设置激光数据topic名称 - output='screen', - emulate_tty=True, - namespace='lidar_1', - parameters=[driver_dir_1], - ) - - driver_node_2 = LifecycleNode(package='lslidar_driver_n10p', - executable='lslidar_driver_node', - name='lslidar_driver_node', #设置激光数据topic名称 - output='screen', - emulate_tty=True, - namespace='lidar_2', - parameters=[driver_dir_2], - ) - - rviz_dir = os.path.join(get_package_share_directory('lslidar_driver'), 'rviz', 'lslidar.rviz') - - rviz_node = Node( - package='rviz2', - namespace='', - executable='rviz2', - name='rviz2', - arguments=['-d', rviz_dir], - output='screen') - - return LaunchDescription([ - driver_node_1, - driver_node_2, - rviz_node, - ]) - diff --git a/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/launch/lsm10_net_launch.py b/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/launch/lsm10_net_launch.py deleted file mode 100644 index 7659d3f..0000000 --- a/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/launch/lsm10_net_launch.py +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/python3 -from ament_index_python.packages import get_package_share_directory -from launch import LaunchDescription -from launch_ros.actions import LifecycleNode -from launch.substitutions import LaunchConfiguration -from launch_ros.actions import Node -from launch.actions import DeclareLaunchArgument - -import lifecycle_msgs.msg -import os - -def generate_launch_description(): - - driver_dir = os.path.join(get_package_share_directory('lslidar_driver'), 'params', 'lidar_net_ros2','lsm10_net.yaml') - - driver_node = LifecycleNode(package='lslidar_driver', - executable='lslidar_driver_node', - name='lslidar_driver_node', - output='screen', - emulate_tty=True, - namespace='', - parameters=[driver_dir], - ) - return LaunchDescription([ - driver_node, - ]) - diff --git a/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/launch/lsm10_uart_launch.py b/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/launch/lsm10_uart_launch.py deleted file mode 100644 index cd2fa16..0000000 --- a/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/launch/lsm10_uart_launch.py +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/python3 -from ament_index_python.packages import get_package_share_directory -from launch import LaunchDescription -from launch_ros.actions import LifecycleNode -from launch.substitutions import LaunchConfiguration -from launch_ros.actions import Node -from launch.actions import DeclareLaunchArgument - -import lifecycle_msgs.msg -import os - -def generate_launch_description(): - - driver_dir = os.path.join(get_package_share_directory('lslidar_driver'), 'params', 'lidar_uart_ros2','lsm10.yaml') - - driver_node = LifecycleNode(package='lslidar_driver', - executable='lslidar_driver_node', - name='lslidar_driver_node', - output='screen', - emulate_tty=True, - namespace='', - parameters=[driver_dir], - ) - return LaunchDescription([ - driver_node, - ]) - diff --git a/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/launch/lsm10p_net_launch.py b/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/launch/lsm10p_net_launch.py deleted file mode 100644 index e2468c8..0000000 --- a/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/launch/lsm10p_net_launch.py +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/python3 -from ament_index_python.packages import get_package_share_directory -from launch import LaunchDescription -from launch_ros.actions import LifecycleNode -from launch.substitutions import LaunchConfiguration -from launch_ros.actions import Node -from launch.actions import DeclareLaunchArgument - -import lifecycle_msgs.msg -import os - -def generate_launch_description(): - - driver_dir = os.path.join(get_package_share_directory('lslidar_driver'), 'params', 'lidar_net_ros2','lsm10p_net.yaml') - - driver_node = LifecycleNode(package='lslidar_driver', - executable='lslidar_driver_node', - name='lslidar_driver_node', - output='screen', - emulate_tty=True, - namespace='', - parameters=[driver_dir], - ) - return LaunchDescription([ - driver_node, - ]) - diff --git a/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/launch/lsm10p_uart_launch.py b/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/launch/lsm10p_uart_launch.py deleted file mode 100644 index 10d1763..0000000 --- a/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/launch/lsm10p_uart_launch.py +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/python3 -from ament_index_python.packages import get_package_share_directory -from launch import LaunchDescription -from launch_ros.actions import LifecycleNode -from launch.substitutions import LaunchConfiguration -from launch_ros.actions import Node -from launch.actions import DeclareLaunchArgument - -import lifecycle_msgs.msg -import os - -def generate_launch_description(): - - driver_dir = os.path.join(get_package_share_directory('lslidar_driver'), 'params', 'lidar_uart_ros2','lsm10_p.yaml') - - driver_node = LifecycleNode(package='lslidar_driver', - executable='lslidar_driver_node', - name='lslidar_driver_node', - output='screen', - emulate_tty=True, - namespace='', - parameters=[driver_dir], - ) - return LaunchDescription([ - driver_node, - ]) - diff --git a/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/launch/lsn10_launch.py b/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/launch/lsn10_launch.py deleted file mode 100644 index ae9366e..0000000 --- a/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/launch/lsn10_launch.py +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/python3 -from ament_index_python.packages import get_package_share_directory -from launch import LaunchDescription -from launch_ros.actions import LifecycleNode -from launch.substitutions import LaunchConfiguration -from launch_ros.actions import Node -from launch.actions import DeclareLaunchArgument - -import lifecycle_msgs.msg -import os - -def generate_launch_description(): - - driver_dir = os.path.join(get_package_share_directory('lslidar_driver'), 'params','lidar_uart_ros2', 'lsn10.yaml') - - driver_node = LifecycleNode(package='lslidar_driver', - executable='lslidar_driver_node', - name='lslidar_driver_node', #设置激光数据topic名称 - output='screen', - emulate_tty=True, - namespace='', - parameters=[driver_dir], - ) - - return LaunchDescription([ - driver_node, - ]) - diff --git a/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/launch/lsn10_net_launch.py b/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/launch/lsn10_net_launch.py deleted file mode 100644 index 9a6a4d8..0000000 --- a/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/launch/lsn10_net_launch.py +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/python3 -from ament_index_python.packages import get_package_share_directory -from launch import LaunchDescription -from launch_ros.actions import LifecycleNode -from launch.substitutions import LaunchConfiguration -from launch_ros.actions import Node -from launch.actions import DeclareLaunchArgument - -import lifecycle_msgs.msg -import os - -def generate_launch_description(): - - driver_dir = os.path.join(get_package_share_directory('lslidar_driver'), 'params','lidar_net_ros2', 'lsn10_net.yaml') - - driver_node = LifecycleNode(package='lslidar_driver', - executable='lslidar_driver_node', - name='lslidar_driver_node', #设置激光数据topic名称 - output='screen', - emulate_tty=True, - namespace='', - parameters=[driver_dir], - ) - - return LaunchDescription([ - driver_node, - ]) - diff --git a/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/launch/lsn10p_launch.py b/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/launch/lsn10p_launch.py deleted file mode 100644 index 758b03b..0000000 --- a/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/launch/lsn10p_launch.py +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/python3 -from ament_index_python.packages import get_package_share_directory -from launch import LaunchDescription -from launch_ros.actions import LifecycleNode -from launch.substitutions import LaunchConfiguration -from launch_ros.actions import Node -from launch.actions import DeclareLaunchArgument - -import lifecycle_msgs.msg -import os - -def generate_launch_description(): - - driver_dir = os.path.join(get_package_share_directory('lslidar_driver'), 'params','lidar_uart_ros2', 'lsn10p.yaml') - - driver_node = LifecycleNode(package='lslidar_driver', - executable='lslidar_driver_node', - name='lslidar_driver_node', #设置激光数据topic名称 - output='screen', - emulate_tty=True, - namespace='', - parameters=[driver_dir], - ) - - return LaunchDescription([ - driver_node, - ]) - diff --git a/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/launch/lsn10p_net_launch.py b/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/launch/lsn10p_net_launch.py deleted file mode 100644 index 966bda9..0000000 --- a/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/launch/lsn10p_net_launch.py +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/python3 -from ament_index_python.packages import get_package_share_directory -from launch import LaunchDescription -from launch_ros.actions import LifecycleNode -from launch.substitutions import LaunchConfiguration -from launch_ros.actions import Node -from launch.actions import DeclareLaunchArgument - -import lifecycle_msgs.msg -import os - -def generate_launch_description(): - - driver_dir = os.path.join(get_package_share_directory('lslidar_driver'), 'params','lidar_net_ros2', 'lsn10p_net.yaml') - - driver_node = LifecycleNode(package='lslidar_driver', - executable='lslidar_driver_node', - name='lslidar_driver_node', #设置激光数据topic名称 - output='screen', - emulate_tty=True, - namespace='', - parameters=[driver_dir], - ) - - return LaunchDescription([ - driver_node, - ]) - diff --git a/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/launch/viewer_scan_launch.py b/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/launch/viewer_scan_launch.py deleted file mode 100644 index c82e76d..0000000 --- a/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/launch/viewer_scan_launch.py +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/python3 -from ament_index_python.packages import get_package_share_directory -from launch import LaunchDescription -from launch_ros.actions import LifecycleNode -from launch.substitutions import LaunchConfiguration -from launch_ros.actions import Node -from launch.actions import DeclareLaunchArgument - -import lifecycle_msgs.msg -import os - -def generate_launch_description(): - - rviz2_config = os.path.join(get_package_share_directory('lslidar_driver'),'rviz','lslidar.rviz') - - rviz2_node = Node( - package='rviz2', - executable='rviz2', - name='rviz2', - arguments=['-d',rviz2_config], - output='screen') - - return LaunchDescription([ - rviz2_node, - ]) - diff --git a/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/package.xml b/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/package.xml deleted file mode 100644 index 2d88422..0000000 --- a/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/package.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - lslidar_driver - 1.2.0 - ROS device driver for Leishen lidar. - Nick Shu - Nick Shu - GNU General Public License V3.0 - - ament_cmake - - rclcpp - std_msgs - lslidar_msgs - pcl_conversions - rclpy - libpcap - libpcl-all-dev - pluginlib - sensor_msgs - - rclcpp - std_msgs - lslidar_msgs - pcl_conversions - rclpy - libpcap - libpcl-all - pluginlib - sensor_msgs - - diagnostic_updater - - ament_cmake - - diff --git a/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/params/lidar_net_ros2/lsm10_net.yaml b/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/params/lidar_net_ros2/lsm10_net.yaml deleted file mode 100644 index 6e91feb..0000000 --- a/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/params/lidar_net_ros2/lsm10_net.yaml +++ /dev/null @@ -1,22 +0,0 @@ -/lslidar_driver_node: - ros__parameters: - frame_id: laser #激光坐标 - group_ip: 224.1.1.2 - add_multicast: false - device_ip: 192.168.1.200 #雷达目的ip - device_ip_difop: 192.168.1.102 #雷达源IP - msop_port: 2368 #雷达目的端口号 - difop_port: 2369 #雷达源端口号 - lidar_name: M10 #雷达选择:M10 M10_P M10_PLUS M10_GPS N10 - ceil_increase: -1 #Lsm10*时改值应设置为-1 - angle_disable_min: 0.0 #单角度裁剪开始值 - angle_disable_max: 0.0 #单角度裁剪结束值 - truncated_mode_: 0 #多角度裁剪开关:值为0时表示不使用多角度裁剪,默认为0 - #值为1表示使用多角度裁剪,同时angle_disable_min与angle_disable_max设为 0,角度值在/lslidar_driver.cc中修改 - min_range: 0.0 #雷达接收距离最小值 - max_range: 200.0 #雷达接收距离最大值 - use_gps_ts: false #雷达是否使用GPS授时 - scan_topic: /scan #设置激光数据topic名称 - interface_selection: net #接口选择:net 为网口,serial 为串口。 - serial_port_: /dev/wheeltec_laser #串口连接时的串口号 -# pcap: /home/ls/work/2211/M10_P_gps.pcap #雷达是否使用pcap包读取功能 diff --git a/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/params/lidar_net_ros2/lsm10p_net.yaml b/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/params/lidar_net_ros2/lsm10p_net.yaml deleted file mode 100644 index a8e30ce..0000000 --- a/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/params/lidar_net_ros2/lsm10p_net.yaml +++ /dev/null @@ -1,22 +0,0 @@ -/lslidar_driver_node: - ros__parameters: - frame_id: laser #激光坐标 - group_ip: 224.1.1.2 - add_multicast: false - device_ip: 192.168.1.200 #雷达目的ip - device_ip_difop: 192.168.1.102 #雷达源IP - msop_port: 2368 #雷达目的端口号 - difop_port: 2369 #雷达源端口号 - lidar_name: M10_P #雷达选择:M10 M10_P M10_PLUS M10_GPS N10 - ceil_increase: -1 #Lsm10*时改值应设置为-1 - angle_disable_min: 0.0 #单角度裁剪开始值 - angle_disable_max: 0.0 #单角度裁剪结束值 - truncated_mode_: 0 #多角度裁剪开关:值为0时表示不使用多角度裁剪,默认为0 - #值为1表示使用多角度裁剪,同时angle_disable_min与angle_disable_max设为 0,角度值在/lslidar_driver.cc中修改 - min_range: 0.0 #雷达接收距离最小值 - max_range: 200.0 #雷达接收距离最大值 - use_gps_ts: false #雷达是否使用GPS授时 - scan_topic: /scan #设置激光数据topic名称 - interface_selection: net #接口选择:net 为网口,serial 为串口。 - serial_port_: /dev/wheeltec_laser #串口连接时的串口号 -# pcap: /home/ls/work/2211/M10_P_gps.pcap #雷达是否使用pcap包读取功能 diff --git a/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/params/lidar_net_ros2/lsn10_net.yaml b/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/params/lidar_net_ros2/lsn10_net.yaml deleted file mode 100644 index f211d48..0000000 --- a/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/params/lidar_net_ros2/lsn10_net.yaml +++ /dev/null @@ -1,25 +0,0 @@ -/lslidar_driver_node: - ros__parameters: - frame_id: laser #激光坐标 - group_ip: 224.1.1.2 - add_multicast: false - device_ip: 192.168.1.200 #雷达源IP - device_ip_difop: 192.168.1.102 #雷达目的ip - msop_port: 2368 #雷达目的端口号 - difop_port: 2369 #雷达源端口号 - lidar_name: N10 #雷达选择:M10 M10_P M10_PLUS M10_GPS N10 L10 N10_P - angle_disable_min: 0.0 #角度裁剪开始值 - angle_disable_max: 0.0 #角度裁剪结束值 - min_range: 0.2 #雷达接收距离最小值 - max_range: 200.0 #雷达接收距离最大值 - use_gps_ts: false #雷达是否使用GPS授时 - scan_topic: /scan #设置激光数据topic名称 - interface_selection: net #接口选择:net 为网口,serial 为串口。 - serial_port_: /dev/wheeltec_laser #串口连接时的串口号 - high_reflection: false #M10_P雷达需填写该值,若不确定,请联系技术支持。 - compensation: false #M10系列是否使用角度补偿功能 - pubScan: true #是否发布scan话题 - pubPointCloud2: false #是否发布pointcloud2话题 - pointcloud_topic: /lslidar_point_cloud #设置激光数据topic名称 -# pcap: /home/ls/1.pcap #雷达是否使用pcap包读取功能 -# in_file_name: /home/ls/1.txt #雷达是否使用txt文件读取功能 \ No newline at end of file diff --git a/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/params/lidar_net_ros2/lsn10p_net.yaml b/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/params/lidar_net_ros2/lsn10p_net.yaml deleted file mode 100644 index ffd83bb..0000000 --- a/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/params/lidar_net_ros2/lsn10p_net.yaml +++ /dev/null @@ -1,25 +0,0 @@ -/lslidar_driver_node: - ros__parameters: - frame_id: laser #激光坐标 - group_ip: 224.1.1.2 - add_multicast: false - device_ip: 192.168.1.200 #雷达源IP - device_ip_difop: 192.168.1.102 #雷达目的ip - msop_port: 2368 #雷达目的端口号 - difop_port: 2369 #雷达源端口号 - lidar_name: N10_P #雷达选择:M10 M10_P M10_PLUS M10_GPS N10 L10 N10_P - angle_disable_min: 120.0 #角度裁剪开始值 - angle_disable_max: 230.0 #角度裁剪结束值 - min_range: 0.2 #雷达接收距离最小值 - max_range: 200.0 #雷达接收距离最大值 - use_gps_ts: false #雷达是否使用GPS授时 - scan_topic: /scan #设置激光数据topic名称 - interface_selection: net #接口选择:net 为网口,serial 为串口。 - serial_port_: /dev/wheeltec_laser #串口连接时的串口号 - high_reflection: false #M10_P雷达需填写该值,若不确定,请联系技术支持。 - compensation: false #M10系列是否使用角度补偿功能 - pubScan: true #是否发布scan话题 - pubPointCloud2: false #是否发布pointcloud2话题 - pointcloud_topic: /lslidar_point_cloud #设置激光数据topic名称 -# pcap: /home/ls/1.pcap #雷达是否使用pcap包读取功能 -# in_file_name: /home/ls/1.txt #雷达是否使用txt文件读取功能 \ No newline at end of file diff --git a/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/params/lidar_uart_ros2/lsm10.yaml b/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/params/lidar_uart_ros2/lsm10.yaml deleted file mode 100644 index 203f6b5..0000000 --- a/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/params/lidar_uart_ros2/lsm10.yaml +++ /dev/null @@ -1,28 +0,0 @@ -/lslidar_driver_node: - ros__parameters: - frame_id: laser #激光坐标 - group_ip: 224.1.1.2 - add_multicast: false - device_ip: 192.168.1.200 #雷达目的ip - device_ip_difop: 192.168.1.102 #雷达源IP - msop_port: 2368 #雷达目的端口号 - difop_port: 2369 #雷达源端口号 - lidar_name: M10 #雷达选择:M10 M10_P M10_PLUS M10_GPS N10 - ceil_increase: -1 #Lsm10*时改值应设置为-1 - angle_disable_min: 0.0 #单角度裁剪开始值 - angle_disable_max: 0.0 #单角度裁剪结束值 - truncated_mode_: 0 #多角度裁剪开关:值为0时表示不使用多角度裁剪,默认为0 - #值为1表示使用多角度裁剪,同时angle_disable_min与angle_disable_max设为 0,角度值在/lslidar_driver.cc中修改 - min_range: 0.0 #雷达接收距离最小值 - max_range: 200.0 #雷达接收距离最大值 - use_gps_ts: false #雷达是否使用GPS授时 - scan_topic: /scan #设置激光数据topic名称 - interface_selection: serial #接口选择:net 为网口,serial 为串口。 - serial_port_: /dev/wheeltec_laser #串口连接时的串口号 - high_reflection: false #M10_P雷达需填写该值,若不确定,请联系技术支持。 - compensation: false #M10系列是否使用角度补偿功能 - pubScan: true #是否发布scan话题 - pubPointCloud2: false #是否发布pointcloud2话题 - pointcloud_topic: /lslidar_point_cloud #设置激光数据topic名称 -# pcap: /home/ls/1.pcap #雷达是否使用pcap包读取功能 -# in_file_name: /home/ls/1.txt #雷达是否使用txt文件读取功能 \ No newline at end of file diff --git a/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/params/lidar_uart_ros2/lsm10_p.yaml b/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/params/lidar_uart_ros2/lsm10_p.yaml deleted file mode 100644 index 009e5fb..0000000 --- a/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/params/lidar_uart_ros2/lsm10_p.yaml +++ /dev/null @@ -1,28 +0,0 @@ -/lslidar_driver_node: - ros__parameters: - frame_id: laser #激光坐标 - group_ip: 224.1.1.2 - add_multicast: false - device_ip: 192.168.1.200 #雷达目的ip - device_ip_difop: 192.168.1.102 #雷达源IP - msop_port: 2368 #雷达目的端口号 - difop_port: 2369 #雷达源端口号 - lidar_name: M10_P #雷达选择:M10 M10_P M10_PLUS M10_GPS N10 - ceil_increase: -1 #Lsm10*时改值应设置为-1 - angle_disable_min: 0.0 #单角度裁剪开始值 - angle_disable_max: 0.0 #单角度裁剪结束值 - truncated_mode_: 0 #多角度裁剪开关:值为0时表示不使用多角度裁剪,默认为0 - #值为1表示使用多角度裁剪,同时angle_disable_min与angle_disable_max设为 0,角度值在/lslidar_driver.cc中修改 - min_range: 0.0 #雷达接收距离最小值 - max_range: 200.0 #雷达接收距离最大值 - use_gps_ts: false #雷达是否使用GPS授时 - scan_topic: /scan #设置激光数据topic名称 - interface_selection: serial #接口选择:net 为网口,serial 为串口。 - serial_port_: /dev/wheeltec_laser #串口连接时的串口号 - high_reflection: false #M10_P雷达需填写该值,若不确定,请联系技术支持。 - compensation: false #M10系列是否使用角度补偿功能 - pubScan: true #是否发布scan话题 - pubPointCloud2: false #是否发布pointcloud2话题 - pointcloud_topic: /lslidar_point_cloud #设置激光数据topic名称 -# pcap: /home/ls/1.pcap #雷达是否使用pcap包读取功能 -# in_file_name: /home/ls/1.txt #雷达是否使用txt文件读取功能 \ No newline at end of file diff --git a/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/params/lidar_uart_ros2/lsn10.yaml b/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/params/lidar_uart_ros2/lsn10.yaml deleted file mode 100644 index ea0e78f..0000000 --- a/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/params/lidar_uart_ros2/lsn10.yaml +++ /dev/null @@ -1,26 +0,0 @@ -/lslidar_driver_node: - ros__parameters: - frame_id: laser_link #激光坐标 - group_ip: 224.1.1.2 - add_multicast: false - device_ip: 192.168.1.200 #雷达源IP - device_ip_difop: 192.168.1.102 #雷达目的ip - msop_port: 2368 #雷达目的端口号 - difop_port: 2369 #雷达源端口号 - lidar_name: N10 #雷达选择:M10 M10_P M10_PLUS M10_GPS N10 L10 N10_P - angle_disable_min: 0.0 #角度裁剪开始值 - angle_disable_max: 0.0 #角度裁剪结束值 - min_range: 0.15 #雷达接收距离最小值 - max_range: 200.0 #雷达接收距离最大值 - use_gps_ts: false #雷达是否使用GPS授时 - scan_topic: /scan #设置激光数据topic名称 - interface_selection: serial #接口选择:net 为网口,serial 为串口。 - serial_port_: /dev/ttyCH343USB0 #串口连接时的串口号 - high_reflection: false #M10_P雷达需填写该值,若不确定,请联系技术支持。 - compensation: false #M10系列是否使用角度补偿功能 - pubScan: true #是否发布scan话题 - pubPointCloud2: false #是否发布pointcloud2话题 - pointcloud_topic: /lslidar_point_cloud #设置激光数据topic名称 - fixed_array_length: 450 -# pcap: /home/ls/1.pcap #雷达是否使用pcap包读取功能 -# in_file_name: /home/ls/1.txt #雷达是否使用txt文件读取功能 \ No newline at end of file diff --git a/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/params/lidar_uart_ros2/lsn10p.yaml b/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/params/lidar_uart_ros2/lsn10p.yaml deleted file mode 100644 index 8f1c6c9..0000000 --- a/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/params/lidar_uart_ros2/lsn10p.yaml +++ /dev/null @@ -1,25 +0,0 @@ -/lslidar_driver_node: - ros__parameters: - frame_id: laser #激光坐标 - group_ip: 224.1.1.2 - add_multicast: false - device_ip: 192.168.1.200 #雷达源IP - device_ip_difop: 192.168.1.102 #雷达目的ip - msop_port: 2368 #雷达目的端口号 - difop_port: 2369 #雷达源端口号 - lidar_name: N10_P #雷达选择:M10 M10_P M10_PLUS M10_GPS N10 L10 N10_P - angle_disable_min: 120.0 #角度裁剪开始值 - angle_disable_max: 230.0 #角度裁剪结束值 - min_range: 0.2 #雷达接收距离最小值 - max_range: 200.0 #雷达接收距离最大值 - use_gps_ts: false #雷达是否使用GPS授时 - scan_topic: /scan #设置激光数据topic名称 - interface_selection: serial #接口选择:net 为网口,serial 为串口。 - serial_port_: /dev/wheeltec_laser #串口连接时的串口号 - high_reflection: false #M10_P雷达需填写该值,若不确定,请联系技术支持。 - compensation: false #M10系列是否使用角度补偿功能 - pubScan: true #是否发布scan话题 - pubPointCloud2: false #是否发布pointcloud2话题 - pointcloud_topic: /lslidar_point_cloud #设置激光数据topic名称 -# pcap: /home/ls/1.pcap #雷达是否使用pcap包读取功能 -# in_file_name: /home/ls/1.txt #雷达是否使用txt文件读取功能 \ No newline at end of file diff --git a/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/rviz/lslidar.rviz b/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/rviz/lslidar.rviz deleted file mode 100644 index 4b104c7..0000000 --- a/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/rviz/lslidar.rviz +++ /dev/null @@ -1,161 +0,0 @@ -Panels: - - Class: rviz_common/Displays - Help Height: 78 - Name: Displays - Property Tree Widget: - Expanded: - - /Global Options1 - - /Status1 - - /LaserScan1 - Splitter Ratio: 0.3441176414489746 - Tree Height: 617 - - Class: rviz_common/Selection - Name: Selection - - Class: rviz_common/Tool Properties - Expanded: - - /2D Goal Pose1 - - /Publish Point1 - Name: Tool Properties - Splitter Ratio: 0.5886790156364441 - - Class: rviz_common/Views - Expanded: - - /Current View1 - Name: Views - Splitter Ratio: 0.5 -Visualization Manager: - Class: "" - Displays: - - Alpha: 0.5 - Cell Size: 1 - Class: rviz_default_plugins/Grid - Color: 160; 160; 164 - Enabled: true - Line Style: - Line Width: 0.029999999329447746 - Value: Lines - Name: Grid - Normal Cell Count: 0 - Offset: - X: 0 - Y: 0 - Z: 0 - Plane: XY - Plane Cell Count: 10 - Reference Frame: - Value: true - - Alpha: 1 - Autocompute Intensity Bounds: true - Autocompute Value Bounds: - Max Value: 10 - Min Value: -10 - Value: true - Axis: Z - Channel Name: intensity - Class: rviz_default_plugins/LaserScan - Color: 255; 255; 255 - Color Transformer: Intensity - Decay Time: 0 - Enabled: true - Invert Rainbow: false - Max Color: 255; 255; 255 - Max Intensity: 0 - Min Color: 0; 0; 0 - Min Intensity: 0 - Name: LaserScan - Position Transformer: XYZ - Selectable: true - Size (Pixels): 3 - Size (m): 0.009999999776482582 - Style: Flat Squares - Topic: - Depth: 5 - Durability Policy: Volatile - Filter size: 10 - History Policy: Keep Last - Reliability Policy: Reliable - Value: scan - Use Fixed Frame: true - Use rainbow: true - Value: true - Enabled: true - Global Options: - Background Color: 48; 48; 48 - Fixed Frame: laser - Frame Rate: 30 - Name: root - Tools: - - Class: rviz_default_plugins/Interact - Hide Inactive Objects: true - - Class: rviz_default_plugins/MoveCamera - - Class: rviz_default_plugins/Select - - Class: rviz_default_plugins/FocusCamera - - Class: rviz_default_plugins/Measure - Line color: 128; 128; 0 - - Class: rviz_default_plugins/SetInitialPose - Covariance x: 0.25 - Covariance y: 0.25 - Covariance yaw: 0.06853891909122467 - Topic: - Depth: 5 - Durability Policy: Volatile - History Policy: Keep Last - Reliability Policy: Reliable - Value: /initialpose - - Class: rviz_default_plugins/SetGoal - Topic: - Depth: 5 - Durability Policy: Volatile - History Policy: Keep Last - Reliability Policy: Reliable - Value: /goal_pose - - Class: rviz_default_plugins/PublishPoint - Single click: true - Topic: - Depth: 5 - Durability Policy: Volatile - History Policy: Keep Last - Reliability Policy: Reliable - Value: /clicked_point - Transformation: - Current: - Class: rviz_default_plugins/TF - Value: true - Views: - Current: - Class: rviz_default_plugins/Orbit - Distance: 3.635173797607422 - Enable Stereo Rendering: - Stereo Eye Separation: 0.05999999865889549 - Stereo Focal Distance: 1 - Swap Stereo Eyes: false - Value: false - Focal Point: - X: 0 - Y: 0 - Z: 0 - Focal Shape Fixed Size: true - Focal Shape Size: 0.05000000074505806 - Invert Z Axis: false - Name: Current View - Near Clip Distance: 0.009999999776482582 - Pitch: 0.8653978705406189 - Target Frame: - Value: Orbit (rviz) - Yaw: 3.095397710800171 - Saved: ~ -Window Geometry: - Displays: - collapsed: false - Height: 846 - Hide Left Dock: false - Hide Right Dock: false - QMainWindow State: 000000ff00000000fd000000040000000000000156000002f4fc0200000008fb0000001200530065006c0065006300740069006f006e00000001e10000009b0000005c00fffffffb0000001e0054006f006f006c002000500072006f007000650072007400690065007302000001ed000001df00000185000000a3fb000000120056006900650077007300200054006f006f02000001df000002110000018500000122fb000000200054006f006f006c002000500072006f0070006500720074006900650073003203000002880000011d000002210000017afb000000100044006900730070006c006100790073010000003d000002f4000000c900fffffffb0000002000730065006c0065006300740069006f006e00200062007500660066006500720200000138000000aa0000023a00000294fb00000014005700690064006500530074006500720065006f02000000e6000000d2000003ee0000030bfb0000000c004b0069006e0065006300740200000186000001060000030c00000261000000010000010f000002f4fc0200000003fb0000001e0054006f006f006c002000500072006f00700065007200740069006500730100000041000000780000000000000000fb0000000a00560069006500770073010000003d000002f4000000a400fffffffb0000001200530065006c0065006300740069006f006e010000025a000000b200000000000000000000000200000490000000a9fc0100000001fb0000000a00560069006500770073030000004e00000080000002e10000019700000003000004420000003efc0100000002fb0000000800540069006d00650100000000000004420000000000000000fb0000000800540069006d0065010000000000000450000000000000000000000292000002f400000004000000040000000800000008fc0000000100000002000000010000000a0054006f006f006c00730100000000ffffffff0000000000000000 - Selection: - collapsed: false - Tool Properties: - collapsed: false - Views: - collapsed: false - Width: 1283 - X: 406 - Y: 152 diff --git a/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/src/input.cc b/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/src/input.cc deleted file mode 100644 index cfa40a8..0000000 --- a/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/src/input.cc +++ /dev/null @@ -1,398 +0,0 @@ -#include "lslidar_driver/input.h" - -extern volatile sig_atomic_t flag; -namespace lslidar_driver -{ - static const size_t packet_size_input = 400; - //////////////////////////////////////////////////////////////////////// - // Input base class implementation - //////////////////////////////////////////////////////////////////////// - - /** @brief constructor - * - * @param private_nh ROS private handle for calling node. - * @param port UDP port number. - */ - Input::Input(rclcpp::Node *private_nh, uint16_t port) : private_nh_(private_nh), port_(port) { - npkt_update_flag_ = false; - cur_rpm_ = 0; - return_mode_ = 1; - devip_str_difop = std::string("192.168.1.200"); - devip_str_ = std::string("192.168.1.102"); - lidar_name = std::string("M10"); - add_multicast = false; - group_ip = std::string("224.1.1.2"); - UDP_PORT_NUMBER_DIFOP = 2369; - - - private_nh->declare_parameter("device_ip","192.168.1.102"); - private_nh->declare_parameter("device_ip_difop","192.168.1.200"); - private_nh->declare_parameter("add_multicast",false); - private_nh->declare_parameter("group_ip","224.1.1.2"); - private_nh->declare_parameter("difop_port",2369); - - - private_nh->get_parameter("lidar_name", lidar_name); - private_nh->get_parameter("device_ip", devip_str_); - private_nh->get_parameter("add_multicast", add_multicast); - private_nh->get_parameter("group_ip", group_ip); - private_nh->get_parameter("difop_port", UDP_PORT_NUMBER_DIFOP); - private_nh->get_parameter("device_ip_difop", devip_str_difop); - - if (!devip_str_.empty()) - RCLCPP_INFO(private_nh->get_logger(), "[driver][input] accepting packets from IP address: %s port: %d", - devip_str_.c_str(),port); - } - - /** @brief constructor - * - * @param private_nh ROS private handle for calling node. - * @param port UDP port number - */ - InputSocket::InputSocket(rclcpp::Node *private_nh, uint16_t port) : Input(private_nh, port) { - sockfd_ = -1; - - if (!devip_str_.empty()) { - inet_aton(devip_str_.c_str(), &devip_); - inet_aton(devip_str_difop.c_str(), &devip_difop); - } - - RCLCPP_INFO(private_nh_->get_logger(), "[driver][socket] Opening UDP socket: port %d", port); - sockfd_ = socket(PF_INET, SOCK_DGRAM, 0); - if (sockfd_ == -1) { - perror("socket"); // TODO: ROS_ERROR errno - return; - } - - int opt = 1; - if (setsockopt(sockfd_, SOL_SOCKET, SO_REUSEADDR, (const void *) &opt, sizeof(opt))) { - perror("setsockopt error!\n"); - return; - } - - sockaddr_in my_addr; // my address information - memset(&my_addr, 0, sizeof(my_addr)); // initialize to zeros - my_addr.sin_family = AF_INET; // host byte order - my_addr.sin_port = htons(port); // port in network byte order - my_addr.sin_addr.s_addr = INADDR_ANY; // automatically fill in my IP - - if (bind(sockfd_, (sockaddr * ) & my_addr, sizeof(sockaddr)) == -1) { - perror("bind"); // TODO: ROS_ERROR errno - return; - } - - if (add_multicast) { - struct ip_mreq group; - group.imr_multiaddr.s_addr = inet_addr(group_ip.c_str()); - group.imr_interface.s_addr = htonl(INADDR_ANY); - - if (setsockopt(sockfd_, IPPROTO_IP, IP_ADD_MEMBERSHIP, (char *) &group, sizeof(group)) < 0) { - perror("Adding multicast group error "); - close(sockfd_); - exit(1); - } else - printf("Adding multicast group...OK.\n"); - } - if (fcntl(sockfd_, F_SETFL, O_NONBLOCK | FASYNC) < 0) { - perror("non-block"); - return; - } - } - - /** @brief destructor */ - InputSocket::~InputSocket(void) { - (void) close(sockfd_); - } - - void Input::UDP_difop() - { - sockaddr_in server_sai; - server_sai.sin_family = AF_INET; // IPV4 协议族 - server_sai.sin_port = htons(UDP_PORT_NUMBER_DIFOP); - server_sai.sin_addr.s_addr = inet_addr(devip_str_.c_str()); - for (int k = 0; k < 10; k++) - { - unsigned char data[188]= {0x00}; - data[0] = 0xA5; - data[1] = 0x5A; - data[2] = 0x55; - data[184] = 0x08; - data[185] = 0x01; - data[186] = 0xFA; - data[187] = 0xFB; - int rtn = sendto(sockfd_, data, 188, 0, (struct sockaddr *)&server_sai, sizeof(struct sockaddr)); - if (rtn < 0) printf("start scan error !\n"); - else return; - } - return; - } - - void Input::UDP_order(const std_msgs::msg::Int8 msg) - { - int i = msg.data; - sockaddr_in server_sai; - server_sai.sin_family = AF_INET; // IPV4 协议族 - server_sai.sin_port = htons(UDP_PORT_NUMBER_DIFOP); - server_sai.sin_addr.s_addr = inet_addr(devip_str_.c_str()); - int rtn = 0; - for (int k = 0; k < 10; k++) - { - unsigned char data[188]= {0x00}; - data[0] = 0xA5; - data[1] = 0x5A; - data[2] = 0x55; - data[186] = 0xFA; - data[187] = 0xFB; - if(lidar_name == "M10" || lidar_name == "M10_GPS" || lidar_name == "M10_P"){ - if (i <= 1){ //雷达启停 - data[184] = 0x01; - data[185] = char(i); - } - else if (i == 2){ //雷达点云不滤波 - data[181] = 0x0A; - data[184] = 0x06; - data[185] = 0x01; - } - else if (i == 3){ //雷达点云正常滤波 - data[181] = 0x0B; - data[184] = 0x06; - data[185] = 0x01; - } - else if (i == 4){ //雷达近距离滤波 - data[181] = 0x0C; - data[184] = 0x06; - data[185] = 0x01; - } - else if (i == 100){ //接收设备包 - data[184] = 0x08; - data[185] = 0x01; - } - else return; - } - else if (lidar_name == "M10_PLUS"){ - data[184] = 0x0A; - data[185] = 0x01; - if(i == 5) { - data[141] = 0x01; - data[142] = 0x2c; - } - else if(i == 6) { - data[141] = 0x01; - data[142] = 0x68; - } - else if(i == 8) { - data[141] = 0x01; - data[142] = 0xe0; - } - else if(i == 10) { - data[141] = 0x02; - data[142] = 0x58; - } - else if(i == 12) { - data[141] = 0x02; - data[142] = 0xd0; - } - else if(i == 15) { - data[141] = 0x03; - data[142] = 0x84; - } - else if(i == 20) { - data[141] = 0x04; - data[142] = 0xb0; - } - else if(i <= 1) { - data[184] = 0x01; - data[185] = char(i); - } - else if(i == 100) { //接收设备包 - data[184] = 0x08; - data[185] = 0x01; - } - else return; - } - else if(lidar_name == "N10"){ - if(i <= 1){ - data[185] = char(i); - data[184] = 0x01; - } - else if(i>=6 && i<=12){ - data[172] = char(i); - data[184] = 0x0a; - data[185] = 0X01; - } - else return; - } - rtn = sendto(sockfd_, data, 188, 0, (struct sockaddr *)&server_sai, sizeof(struct sockaddr)); - if (rtn < 0) - { - printf("start scan error !\n"); - } - else - { - if (i == 1) - usleep(3000000); - return; - } - } - return; - } - - - - int InputSocket::getPacket(lslidar_msgs::msg::LslidarPacket::UniquePtr &packet) - { - int q = 0; - struct pollfd fds[1]; - fds[0].fd = sockfd_; - fds[0].events = POLLIN; - static const int POLL_TIMEOUT = 2000; // one second (in msec) - - sockaddr_in sender_address{}; - socklen_t sender_address_len = sizeof(sender_address); - while (flag == 1) - { - // poll() until input available - do { - int retval = poll(fds, 1, POLL_TIMEOUT); - if (retval < 0) // poll() error? - { - if (errno != EINTR) - RCLCPP_ERROR(private_nh_->get_logger(), "[driver][socket] poll() error: %s", strerror(errno)); - return 0; - } - if (retval == 0) // poll() timeout? - { - RCLCPP_WARN(private_nh_->get_logger(), "lslidar poll() timeout, port: %d",port_); - return 0; - } - if ((fds[0].revents & POLLERR) || (fds[0].revents & POLLHUP) || (fds[0].revents & POLLNVAL)) // device error? - { - RCLCPP_ERROR(private_nh_->get_logger(),"poll() reports lslidar error"); - return 0; - } - } while ((fds[0].revents & POLLIN) == 0); - - // Receive packets that should now be available from the - // socket using a blocking read. - ssize_t nbytes = recvfrom(sockfd_, &packet->data[0], packet_size_input, 0, - (sockaddr *)&sender_address, &sender_address_len); - // ROS_DEBUG_STREAM("incomplete lslidar packet read: " - // << nbytes << " bytes"); - q = (int)nbytes; - if (nbytes < 0) - { - if (errno != EWOULDBLOCK) - { - perror("recvfail"); - RCLCPP_ERROR(private_nh_->get_logger(),"recvfail"); - return 1; - } - } - else if ((size_t)nbytes <= packet_size_input || (size_t)nbytes >= 50) - { - - // read successful, - // if packet is not from the lidar scanner we selected by IP, - // continue otherwise we are done - if (devip_str_ != "" && sender_address.sin_addr.s_addr != devip_.s_addr) - continue; - else - break; // done - } - - } - if (flag == 0) - { - abort(); - } - - return q; - } - InputPCAP::InputPCAP(rclcpp::Node *private_nh, uint16_t port, double packet_rate, std::string filename) : Input(private_nh, port), - packet_rate_(packet_rate), - filename_(filename) - { - pcap_ = NULL; - empty_ = true; - read_once_ = false; - read_fast_ = false; - repeat_delay_ = 0.0; - private_nh->get_parameter("read_once", read_once_); - private_nh->get_parameter("read_fast", read_fast_); - private_nh->get_parameter("repeat_delay", repeat_delay_); - - if (read_once_) - RCLCPP_WARN(private_nh_->get_logger(),"Read input file only once."); - if (read_fast_) - RCLCPP_WARN(private_nh_->get_logger(),"Read input file as quickly as possible."); - if (repeat_delay_ > 0.0) - RCLCPP_WARN(private_nh_->get_logger(),"Delay %.3f seconds before repeating input file.", repeat_delay_); - - RCLCPP_INFO(private_nh_->get_logger(),"Opening PCAP file %s",filename_.c_str()); - if ((pcap_ = pcap_open_offline(filename_.c_str(), errbuf_)) == NULL) - { - RCLCPP_WARN(private_nh_->get_logger(),"Error opening lslidar socket dump file."); - return; - } - std::stringstream filter; - if (devip_str_ != "") - { - filter << "src host " << devip_str_ << "&&"; - } - filter << "udp dst port " << port; - pcap_compile(pcap_, &pcap_packet_filter_, filter.str().c_str(), 1, PCAP_NETMASK_UNKNOWN); - } - - InputPCAP::~InputPCAP(void) - { - pcap_close(pcap_); - } - - int InputPCAP::getPacket(lslidar_msgs::msg::LslidarPacket::UniquePtr &pkt) - { - struct pcap_pkthdr *header; - const u_char *pkt_data; - while (flag == 1) - { - int res; - if ((res = pcap_next_ex(pcap_, &header, &pkt_data)) >= 0) - { - // skip packets not for the correct port and from the selected IP address - if (!devip_str_.empty() && (0 == pcap_offline_filter(&pcap_packet_filter_, header, pkt_data))) - continue; - - if (read_fast_ == false) - packet_rate_.sleep(); - mempcpy(&pkt->data[0], pkt_data + 42, packet_size_input); - empty_ = false; - return 0; - } - if (empty_) - { - RCLCPP_WARN(private_nh_->get_logger(),"Error %d reading lslidar packet: %s", res, pcap_geterr(pcap_)); - return -1; - } - if (read_once_) - { - RCLCPP_WARN(private_nh_->get_logger(),"end of file reached -- done reading."); - return -1; - } - if (repeat_delay_ > 0.0) - { - RCLCPP_WARN(private_nh_->get_logger(),"end of file reached -- delaying %.3f seconds.", repeat_delay_); - usleep(rint(repeat_delay_ * 1000000.0)); - } - RCLCPP_WARN(private_nh_->get_logger(),"replayding lsliar dump file"); - - pcap_close(pcap_); - pcap_ = pcap_open_offline(filename_.c_str(), errbuf_); - empty_ = true; - } - if (flag == 0) - { - abort(); - } - return 0; - } - -} // namespace diff --git a/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/src/lsiosr.cpp b/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/src/lsiosr.cpp deleted file mode 100644 index d560b12..0000000 --- a/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/src/lsiosr.cpp +++ /dev/null @@ -1,400 +0,0 @@ -/******************************************************* -@company: Copyright (C) 2022, Leishen Intelligent System -@product: LSM10 and N10 -@filename: lsiosr.cpp -@brief: -@version: date: author: comments: -@v1.0 21-2-4 yao new -*******************************************************/ -#include "lslidar_driver/lsiosr.h" - -namespace lslidar_driver { - -LSIOSR * LSIOSR::instance(std::string name, int speed, int fd) -{ - static LSIOSR obj(name, speed, fd); - return &obj; -} - -LSIOSR::LSIOSR(std::string port, int baud_rate, int fd):port_(port), baud_rate_(baud_rate), fd_(fd) -{ - printf("port = %s, baud_rate = %d\n", port.c_str(), baud_rate); -} - -LSIOSR::~LSIOSR() -{ - close(); -} -/* 串口配置的函数 */ -int LSIOSR::setOpt(int nBits, uint8_t nEvent, int nStop) -{ - struct termios newtio, oldtio; - /*保存测试现有串口参数设置,在这里如果串口号等出错,会有相关的出错信息*/ - if (tcgetattr(fd_, &oldtio) != 0) - { - perror("SetupSerial 1"); - return -1; - } - bzero(&newtio, sizeof(newtio)); - /*步骤一,设置字符大小*/ - newtio.c_cflag |= CLOCAL; //如果设置,modem 的控制线将会被忽略。如果没有设置,则 open()函数会阻塞直到载波检测线宣告 modem 处于摘机状态为止。 - newtio.c_cflag |= CREAD; //使端口能读取输入的数据 - /*设置每个数据的位数*/ - switch (nBits) - { - case 7: - newtio.c_cflag |= CS7; - break; - case 8: - newtio.c_cflag |= CS8; - break; - } - /*设置奇偶校验位*/ - switch (nEvent) - { - case 'O': //奇数 - newtio.c_iflag |= (INPCK | ISTRIP); - newtio.c_cflag |= PARENB; //使能校验,如果不设PARODD则是偶校验 - newtio.c_cflag |= PARODD; //奇校验 - break; - case 'E': //偶数 - newtio.c_iflag |= (INPCK | ISTRIP); - newtio.c_cflag |= PARENB; - newtio.c_cflag &= ~PARODD; - break; - case 'N': //无奇偶校验位 - newtio.c_cflag &= ~PARENB; - break; - } - /*设置波特率*/ - switch (baud_rate_) - { - case 230400: - cfsetispeed(&newtio, B230400); - cfsetospeed(&newtio, B230400); - break; - case 460800: - cfsetispeed(&newtio, B460800); - cfsetospeed(&newtio, B460800); - break; - case 500000: - cfsetispeed(&newtio, B500000); - cfsetospeed(&newtio, B500000); - break; - case 921600: - cfsetispeed(&newtio, B921600); - cfsetospeed(&newtio, B921600); - break; - default: - cfsetispeed(&newtio, B460800); - cfsetospeed(&newtio, B460800); - break; - } - - /* - * 设置停止位 - * 设置停止位的位数, 如果设置,则会在每帧后产生两个停止位, 如果没有设置,则产生一个 - * 停止位。一般都是使用一位停止位。需要两位停止位的设备已过时了。 - * */ - if (nStop == 1) - newtio.c_cflag &= ~CSTOPB; - else if (nStop == 2) - newtio.c_cflag |= CSTOPB; - /*设置等待时间和最小接收字符*/ - newtio.c_cc[VTIME] = 0; - newtio.c_cc[VMIN] = 0; - /*处理未接收字符*/ - tcflush(fd_, TCIFLUSH); - /*激活新配置*/ - if ((tcsetattr(fd_, TCSANOW, &newtio)) != 0) - { - perror("serial set error"); - return -1; - } - - return 0; -} - -void LSIOSR::flushinput() { - tcflush(fd_, TCIFLUSH); -} - -/* 从串口中读取数据 */ -int LSIOSR::read(unsigned char *buffer, int length, int timeout) -{ - memset(buffer, 0, length); - - int totalBytesRead = 0; - int rc; - int unlink = 0; - unsigned char* pb = buffer; - - if (timeout > 0) - { - rc = waitReadable(timeout); - if (rc <= 0) - { - return (rc == 0) ? 0 : -1; - } - - int retry = 3; - while (length > 0) - { - rc = ::read(fd_, pb, (size_t)length); - - if (rc > 0) - { - length -= rc; - pb += rc; - totalBytesRead += rc; - - if (length == 0) - { - break; - } - } - else if (rc < 0) - { - printf("error \n"); - retry--; - if (retry <= 0) - { - break; - } - } - unlink++; - rc = waitReadable(20); - if(unlink > 10) - return -1; - - if (rc <= 0) - { - break; - } - } - } - else - { - rc = ::read(fd_, pb, (size_t)length); - - if (rc > 0) - { - totalBytesRead += rc; - } - else if ((rc < 0) && (errno != EINTR) && (errno != EAGAIN)) - { - printf("read error\n"); - return -1; - } - } - - return totalBytesRead; -} - -int LSIOSR::waitReadable(int millis) -{ - if (fd_ < 0) - { - return -1; - } - int serial = fd_; - - fd_set fdset; - struct timeval tv; - int rc = 0; - - while (millis > 0) - { - if (millis < 5000) - { - tv.tv_usec = millis % 1000 * 1000; - tv.tv_sec = millis / 1000; - - millis = 0; - } - else - { - tv.tv_usec = 0; - tv.tv_sec = 5; - - millis -= 5000; - } - - FD_ZERO(&fdset); - FD_SET(serial, &fdset); - - rc = select(serial + 1, &fdset, NULL, NULL, &tv); - if (rc > 0) - { - rc = (FD_ISSET(serial, &fdset)) ? 1 : -1; - break; - } - else if (rc < 0) - { - rc = -1; - break; - } - } - - return rc; -} - - -int LSIOSR::waitWritable(int millis) -{ - if (fd_ < 0) - { - return -1; - } - int serial = fd_; - - fd_set fdset; - struct timeval tv; - int rc = 0; - - while (millis > 0) - { - if (millis < 5000) - { - tv.tv_usec = millis % 1000 * 1000; - tv.tv_sec = millis / 1000; - - millis = 0; - } - else - { - tv.tv_usec = 0; - tv.tv_sec = 5; - - millis -= 5000; - } - - FD_ZERO(&fdset); - FD_SET(serial, &fdset); - - rc = select(serial + 1, NULL, &fdset, NULL, &tv); - if (rc > 0) - { - rc = (FD_ISSET(serial, &fdset)) ? 1 : -1; - break; - } - else if (rc < 0) - { - rc = -1; - break; - } - } - - return rc; -} - -/* 向串口中发送数据 */ -int LSIOSR::send(const char* buffer, int length, int timeout) -{ - if (fd_ < 0) - { - return -1; - } - - if ((buffer == 0) || (length <= 0)) - { - return -1; - } - - int totalBytesWrite = 0; - int rc; - char* pb = (char*)buffer; - - - if (timeout > 0) - { - rc = waitWritable(timeout); - if (rc <= 0) - { - return (rc == 0) ? 0 : -1; - } - - int retry = 3; - while (length > 0) - { - rc = write(fd_, pb, (size_t)length); - if (rc > 0) - { - length -= rc; - pb += rc; - totalBytesWrite += rc; - - if (length == 0) - { - break; - } - } - else - { - retry--; - if (retry <= 0) - { - break; - } - } - - rc = waitWritable(50); - if (rc <= 0) - { - break; - } - } - } - else - { - rc = write(fd_, pb, (size_t)length); - if (rc > 0) - { - totalBytesWrite += rc; - } - else if ((rc < 0) && (errno != EINTR) && (errno != EAGAIN)) - { - return -1; - } - } - - return totalBytesWrite; -} - -int LSIOSR::init() -{ - int error_code = 0; - - fd_ = open(port_.c_str(), O_RDWR|O_NOCTTY|O_NDELAY); - if (0 < fd_) - { - error_code = 0; - setOpt(DATA_BIT_8, PARITY_NONE, STOP_BIT_1);//设置串口参数 - //printf("open_port %s OK !\n", port_.c_str()); - } - else - { - error_code = -1; - } - - return error_code; -} - -int LSIOSR::close() -{ - ::close(fd_); - return 0; -} - -std::string LSIOSR::getPort() -{ - return port_; -} - -int LSIOSR::setPortName(std::string name) -{ - port_ = name; - return 0; -} - -} diff --git a/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/src/lslidar_driver.cc b/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/src/lslidar_driver.cc deleted file mode 100644 index a141253..0000000 --- a/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/src/lslidar_driver.cc +++ /dev/null @@ -1,1423 +0,0 @@ -/* - * This file is part of lslidar driver. - * - * The driver is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * The driver is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with the driver. If not, see . - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "rclcpp/rclcpp.hpp" -#include "lslidar_driver/lslidar_driver.h" -#include - -int truncated_mode_=0; //多角度屏蔽开关:默认为0,如果需要屏蔽多个角度,则truncated_mode_赋值为1。 - -int scan_crop_min[]={0,180}; //雷达屏蔽角度,这里屏蔽角度为135°到225°, - //如果要多角度屏蔽,如10~30,50~60,改为: - //scan_angle_min[]={10,50};scan_angle_max[]={30,60}; -int scan_crop_max[]={90,270}; //修改后编译即可 - - -namespace lslidar_driver -{ - - static void my_hander(int sig) - { - printf("sig: %d", sig); - abort(); - } - LslidarDriver::LslidarDriver() : LslidarDriver(rclcpp::NodeOptions()) {} - LslidarDriver::LslidarDriver(const rclcpp::NodeOptions &options) : Node("lslidar_driver_node", options), diagnostics(this) - { - signal(SIGINT, my_hander); - - if (!this->initialize()) - RCLCPP_ERROR(this->get_logger(), "Could not initialize the driver..."); - else - RCLCPP_INFO(this->get_logger(), "Successfully initialize driver..."); - } - - LslidarDriver::~LslidarDriver() - { - return; - } - - bool LslidarDriver::loadParameters() - { - pubscan_thread_ = new boost::thread(boost::bind(&LslidarDriver::pubScanThread, this)); - interface_selection = std::string("net"); - frame_id = std::string("laser_link"); - scan_topic = std::string("/scan"); - lidar_name = std::string("M10"); - pointcloud_topic = std::string("/lslidar_point_cloud"); - is_start = true; - min_range = 0.3; - max_range = 100.0; - use_gps_ts = true; - compensation = true; - pubScan = true; - pubPointCloud2 = true; - angle_disable_min = 0.0; - angle_disable_max = 0.0; - // 添加恒定输出长度参数 - fixed_array_length = 450; //cyy_addcyy_add - this->declare_parameter("fixed_array_length", 450);//cyy_addcyy_add - - - this->declare_parameter("lidar_name", "M10"); - this->declare_parameter("frame_id", "laser_link"); - this->declare_parameter("scan_topic", "/scan"); - this->declare_parameter("pointcloud_topic", "/lslidar_point_cloud"); - this->declare_parameter("min_range", 0.3); - this->declare_parameter("max_range", 100.0); - this->declare_parameter("use_gps_ts", false); - this->declare_parameter("high_reflection", false); - this->declare_parameter("compensation", false); - this->declare_parameter("pubScan", true); - this->declare_parameter("pubPointCloud2", false); - this->declare_parameter("angle_disable_min", 0.0); - this->declare_parameter("angle_disable_max", 0.0); - this->declare_parameter("interface_selection", "net"); - - this->get_parameter("fixed_array_length", fixed_array_length);//cyy_addcyy_add - this->get_parameter("lidar_name", lidar_name); - this->get_parameter("frame_id", frame_id); - this->get_parameter("high_reflection", high_reflection); - this->get_parameter("scan_topic", scan_topic); - this->get_parameter("min_range", min_range); - this->get_parameter("max_range", max_range); - this->get_parameter("use_gps_ts", use_gps_ts); - this->get_parameter("compensation", compensation); - this->get_parameter("pointcloud_topic", pointcloud_topic); - this->get_parameter("pubScan", pubScan); - this->get_parameter("pubPointCloud2", pubPointCloud2); - this->get_parameter("angle_disable_min", angle_disable_min); - this->get_parameter("angle_disable_max", angle_disable_max); - this->get_parameter("interface_selection", interface_selection); - while (angle_disable_min < 0) - angle_disable_min += 360; - while (angle_disable_max < 0) - angle_disable_max += 360; - while (angle_disable_min > 360) - angle_disable_min -= 360; - while (angle_disable_max > 360) - angle_disable_max -= 360; - if (angle_disable_max == angle_disable_min) - { - angle_able_min = 0; - angle_able_max = 360; - } - else - { - if (angle_disable_min < angle_disable_max && angle_disable_min != 0.0) - { - angle_able_min = angle_disable_max; - angle_able_max = angle_disable_min + 360; - } - if (angle_disable_min < angle_disable_max && angle_disable_min == 0.0) - { - angle_able_min = angle_disable_max; - angle_able_max = 360; - } - if (angle_disable_min > angle_disable_max) - { - angle_able_min = angle_disable_max; - angle_able_max = angle_disable_min; - } - } - count_num = 0; - - scan_points_.resize(6000); - - if (lidar_name == "M10") - { - use_gps_ts = false; - PACKET_SIZE = 92; - package_points = 42; - data_bits_start = 6; - degree_bits_start = 2; - rpm_bits_start = 4; - baud_rate_ = 460800; - points_size_ = 1008; - } - else if (lidar_name == "M10_P") - { - PACKET_SIZE = 160; - package_points = 70; - data_bits_start = 8; - degree_bits_start = 4; - rpm_bits_start = 6; - baud_rate_ = 500000; - points_size_ = 2000; - } - else if (lidar_name == "M10_PLUS") - { - PACKET_SIZE = 104; - package_points = 41; - data_bits_start = 8; - degree_bits_start = 4; - rpm_bits_start = 6; - points_size_ = 5000; - baud_rate_ = 921600; - } - else if (lidar_name == "M10_GPS") - { - PACKET_SIZE = 102; - package_points = 42; - data_bits_start = 6; - degree_bits_start = 2; - rpm_bits_start = 4; - baud_rate_ = 460800; - points_size_ = 1008; - } - else if (lidar_name == "N10") - { - PACKET_SIZE = 58; - package_points = 16; - data_bits_start = 7; - degree_bits_start = 5; - end_degree_bits_start = 55; - baud_rate_ = 230400; - points_size_ = 2000; - use_gps_ts = false; - compensation = false; - } - else if (lidar_name == "M10_DOUBLE") - { - PACKET_SIZE = 300; - package_points = 70; - data_bits_start = 8; - degree_bits_start = 4; - rpm_bits_start = 6; - points_size_ = 3000; - baud_rate_ = 921600; - } - else if (lidar_name == "N10_P") - { - PACKET_SIZE = 108; - package_points = 16; - data_bits_start = 7; - degree_bits_start = 5; - end_degree_bits_start = 105; - baud_rate_ = 460800; - points_size_ = 2000; - use_gps_ts = false; - compensation = false; - } - else if (lidar_name == "L10") - { - PACKET_SIZE = 58; - package_points = 16; - data_bits_start = 7; - degree_bits_start = 5; - end_degree_bits_start = 55; - baud_rate_ = 230400; - points_size_ = 2000; - use_gps_ts = false; - compensation = false; - } - RCLCPP_INFO_STREAM(this->get_logger(), "Lidar is " << lidar_name.c_str()); - - if (pubScan) - scan_pub = this->create_publisher(scan_topic, 10); - if (pubPointCloud2) - point_cloud_pub = this->create_publisher(pointcloud_topic, 10); - difop_switch = this->create_subscription("lslidar_order", 1, std::bind(&LslidarDriver::lidar_order, this, std::placeholders::_1)); // 转速输入 - return true; - } - - void LslidarDriver::lidar_difop() - { - if (lidar_name == "L10" || lidar_name == "N10" || lidar_name == "N10_P") - return; - if (interface_selection == "net") - msop_input_->UDP_difop(); - else - { - for (int k = 0; k < 10; k++) - { - unsigned char data[188] = {0x00}; - data[0] = 0xA5; - data[1] = 0x5A; - data[2] = 0x55; - data[184] = 0x08; - data[185] = 0x01; - data[186] = 0xFA; - data[187] = 0xFB; - int rtn = serial_->send((const char *)data, 188); - if (rtn < 0) - printf("start scan error !\n"); - else - return; - } - } - return; - } - - void LslidarDriver::lidar_order(const std_msgs::msg::Int8::SharedPtr msg) - { - if (lidar_name == "L10") - return; - int i = msg->data; - if (i == 0) - is_start = false; - else - is_start = true; - if (interface_selection == "net") - msop_input_->UDP_order(*msg); - else - { - int i = msg->data; - for (int k = 0; k < 10; k++) - { - int rtn; - unsigned char data[188] = {0x00}; - data[0] = 0xA5; - data[1] = 0x5A; - data[2] = 0x55; - data[186] = 0xFA; - data[187] = 0xFB; - - if (lidar_name == "M10" || lidar_name == "M10_GPS" || lidar_name == "M10_P" || lidar_name == "M10_DOUBLE") - { - if (i <= 1) - { // 雷达启停 - data[184] = 0x01; - data[185] = char(i); - } - else if (i == 2) - { // 雷达点云不滤波 - data[181] = 0x0A; - data[184] = 0x06; - if (is_start) - data[185] = 0x01; - } - else if (i == 3) - { // 雷达点云正常滤波 - data[181] = 0x0B; - data[184] = 0x06; - if (is_start) - data[185] = 0x01; - } - else if (i == 4) - { // 雷达近距离滤波 - data[181] = 0x0C; - data[184] = 0x06; - if (is_start) - data[185] = 0x01; - } - else if (i == 100) - { // 接收设备包 - data[184] = 0x08; - data[185] = 0x01; - } - else - return; - } - else if (lidar_name == "M10_PLUS") - { - data[184] = 0x0A; - data[185] = 0x01; - if (i == 5) - { - data[141] = 0x01; - data[142] = 0x2c; - } - else if (i == 6) - { - data[141] = 0x01; - data[142] = 0x68; - } - else if (i == 8) - { - data[141] = 0x01; - data[142] = 0xe0; - } - else if (i == 10) - { - data[141] = 0x02; - data[142] = 0x58; - } - else if (i == 12) - { - data[141] = 0x02; - data[142] = 0xd0; - } - else if (i == 15) - { - data[141] = 0x03; - data[142] = 0x84; - } - else if (i == 20) - { - data[141] = 0x04; - data[142] = 0xb0; - } - else if (i <= 1) - { - data[184] = 0x01; - data[185] = char(i); - } - else if (i == 100) // 接收设备包 - { - data[184] = 0x08; - data[185] = 0x01; - } - else - return; - } - else if (lidar_name == "N10" || lidar_name == "N10_P") - { - if (i <= 1) - { - data[185] = char(i); - data[184] = 0x01; - } - else if (i >= 6 && i <= 12) - { - data[172] = char(i); - data[184] = 0x0a; - data[185] = 0X01; - } - else - return; - } - rtn = serial_->send((const char *)data, 188); - if (rtn < 0) - printf("start scan error !\n"); - else - { - if (i == 1) - usleep(1000000); // 1.0s - if (i == 0) - is_start = false; - if (i == 1) - is_start = true; - return; - } - } - return; - } - } - - void LslidarDriver::open_serial() - { - diagnostics.setHardwareID("Lslidar"); - int code = 0; - serial_port_ = std::string("/dev/ttyUSB0"); - this->declare_parameter("serial_port_", "/dev/ttyUSB0"); - this->get_parameter("serial_port_", serial_port_); - serial_ = LSIOSR::instance(serial_port_, baud_rate_); - code = serial_->init(); - if (code != 0) - { - printf("open_port %s ERROR !\n", serial_port_.c_str()); - rclcpp::shutdown(); - exit(0); - } - printf("open_port %s OK !\n", serial_port_.c_str()); - } - - bool LslidarDriver::createRosIO() - { - UDP_PORT_NUMBER = 2368; - this->declare_parameter("msop_port", 2368); - this->get_parameter("msop_port", UDP_PORT_NUMBER); - RCLCPP_INFO_STREAM(this->get_logger(), "Opening UDP socket: port " << UDP_PORT_NUMBER); - dump_file = std::string(""); - this->declare_parameter("pcap", ""); - this->get_parameter("pcap", dump_file); - // ROS diagnostics - diagnostics.setHardwareID("Lslidar"); - - const double diag_freq = 12 * 24; - diag_max_freq = diag_freq; - diag_min_freq = diag_freq; - RCLCPP_INFO(this->get_logger(), "expected frequency: %.3f (Hz)", diag_freq); - - using namespace diagnostic_updater; - diag_topic.reset(new TopicDiagnostic( - "lslidar_packets", diagnostics, - FrequencyStatusParam(&diag_min_freq, &diag_max_freq, 0.1, 10), - TimeStampStatusParam())); - - int hz = 10; - if (lidar_name == "M10_P") - hz = 12; - else if (lidar_name == "M10_PLUS") - hz = 20; - - double packet_rate = hz * 24; - if (dump_file != "") - { - msop_input_.reset(new lslidar_driver::InputPCAP(this, UDP_PORT_NUMBER, packet_rate, dump_file)); - } - else - { - msop_input_.reset(new lslidar_driver::InputSocket(this, UDP_PORT_NUMBER)); - } - - // Output - return true; - } - - int LslidarDriver::getScan(std::vector &points, rclcpp::Time &scan_time, float &scan_duration) - { - boost::unique_lock lock(mutex_); - points.assign(scan_points_bak_.begin(), scan_points_bak_.end()); - scan_time = pre_time_; - scan_duration = time_.seconds() - pre_time_.seconds(); - return 1; - } - - uint64_t LslidarDriver::get_gps_stamp(struct tm t) - { - - uint64_t ptime = static_cast(timegm(&t)); - return ptime; - } - - bool LslidarDriver::initialize() - { - if (!loadParameters()) - { - RCLCPP_ERROR(this->get_logger(), "Cannot load all required ROS parameters..."); - return false; - } - if (interface_selection == "net") - { - if (!createRosIO()) - { - RCLCPP_ERROR(this->get_logger(), "Cannot create all ROS IO..."); - return false; - } - } - else - { - in_file_name = std::string(""); - this->declare_parameter("in_file_name", ""); - this->get_parameter("in_file_name", in_file_name); - if (in_file_name == "") - open_serial(); - else - { - RCLCPP_INFO_STREAM(this->get_logger(), "Opening txt file " << in_file_name.c_str()); - std::ifstream file_reader(in_file_name); - if (!file_reader.is_open()) - { - RCLCPP_ERROR(this->get_logger(), "Cannot open the file"); - return false; - } - } - } - RCLCPP_INFO(this->get_logger(), "Initialised lslidar without error"); - return true; - } - - void LslidarDriver::recvThread_crc(int &count, int &link_time) - { - if (count <= 0) - link_time++; - else - link_time = 0; - - if (link_time > 150) - { - serial_->close(); - int ret = serial_->init(); - if (ret < 0) - { - RCLCPP_ERROR(this->get_logger(), "serial open fail"); - usleep(200000); - } - link_time = 0; - } - } - - int LslidarDriver::receive_data(unsigned char *packet_bytes) - { - int link_time = 0; - int len_H = 0; - int len_L = 0; - int len = 0; - int count_2 = 0; - int count = 0; - while (count <= 0) - { - count = serial_->read(packet_bytes, 1); - LslidarDriver::recvThread_crc(count, link_time); - } - if (packet_bytes[0] != 0xA5) - return 0; - - while (count_2 <= 0) - { - count_2 = serial_->read(packet_bytes + count, 1); - if (count_2 >= 0) - count += count_2; - LslidarDriver::recvThread_crc(count_2, link_time); - } - - count_2 = 0; - if (packet_bytes[1] != 0x5A) - return 0; - while (count_2 <= 0) - { - count_2 = serial_->read(packet_bytes + count, 2); - if (count_2 >= 0) - count += count_2; - LslidarDriver::recvThread_crc(count_2, link_time); - } - - count_2 = 0; - - if (lidar_name == "M10") - len = 92; - else if (lidar_name == "M10_GPS") - len = 102; - else if (lidar_name == "N10_P") - len = 108; - else if (lidar_name == "N10" || lidar_name == "L10") - len = packet_bytes[2]; - else - { - len_H = packet_bytes[2]; - len_L = packet_bytes[3]; - len = len_H * 256 + len_L; - } - if (lidar_name == "M10" || lidar_name == "M10_DOUBLE" || lidar_name == "M10_GPS" || lidar_name == "M10_P" || lidar_name == "M10_PLUS") - { - if (packet_bytes[2] == 0x55 && packet_bytes[3] == 0x00) - len = 188; - } - while (count < len) - { - count_2 = serial_->read(packet_bytes + count, len - count); - if (count_2 >= 0) - count += count_2; - LslidarDriver::recvThread_crc(count_2, link_time); - } - if (lidar_name == "N10" || lidar_name == "L10" || lidar_name == "N10_P") - { - if (packet_bytes[PACKET_SIZE - 1] != N10_CalCRC8(packet_bytes, PACKET_SIZE - 1)) - return 0; - } - return len; - } - - uint8_t LslidarDriver::N10_CalCRC8(unsigned char *p, int len) - { - uint8_t crc = 0; - int sum = 0; - - for (int i = 0; i < len; i++) - { - sum += uint8_t(p[i]); - } - crc = sum & 0xff; - return crc; - } - - void LslidarDriver::difop_processing(unsigned char *packet_bytes) // 处理设备包的数据 - { - int s = packet_bytes[173]; - int z = packet_bytes[174]; - int degree_temp = s & 0x7F; - int sign_temp = s & 0x80; - degree_compensation = double(degree_temp * 256 + z) / 100.f; - if (sign_temp) - degree_compensation = -degree_compensation; - first_compensation = false; - printf("degree_compensation = %f\n", degree_compensation); - return; - } - - void LslidarDriver::data_processing(unsigned char *packet_bytes, int len) // 处理每一包的数据 - { - double degree; - double end_degree; - double degree_interval = 15.0; - boost::posix_time::ptime t1, t2; - t1 = boost::posix_time::microsec_clock::universal_time(); - - int s = packet_bytes[degree_bits_start]; - int z = packet_bytes[degree_bits_start + 1]; - - degree = (s * 256 + z) / 100.f + degree_compensation; - degree = (degree < 0) ? degree + 360 : degree; - degree = (degree > 360) ? degree - 360 : degree; - if (lidar_name == "N10" || lidar_name == "L10") - { - int s_e = packet_bytes[end_degree_bits_start]; - int z_e = packet_bytes[end_degree_bits_start + 1]; - - end_degree = (s_e * 256 + z_e) / 100.f; - end_degree = (end_degree > 360) ? end_degree - 360 : end_degree; - - if (degree > end_degree) - degree_interval = end_degree + 360 - degree; - else - degree_interval = end_degree - degree; - } - - // boost::unique_lock lock(mutex_); - if (lidar_name == "M10_PLUS" || lidar_name == "M10_P") - { - PACKET_SIZE = len; - package_points = (PACKET_SIZE - 20) / 2; - } - int invalidValue = 0; - int point_len = 2; - if (lidar_name == "N10" || lidar_name == "L10") - point_len = 3; - - if (lidar_name == "M10_GPS" || lidar_name == "M10") - { - int err_data_84 = packet_bytes[84]; - int err_data_85 = packet_bytes[85]; - if ((err_data_84 * 256 + err_data_85) == 0xFFFF || packet_bytes[86] >= 0xF5) - { - packet_bytes[86] = 0xFF; - packet_bytes[87] = 0xFF; - } - } - - for (int num = 0; num < point_len * package_points; num += point_len) - { - int s = packet_bytes[num + data_bits_start]; - int z = packet_bytes[num + data_bits_start + 1]; - if ((s * 256 + z) == 0xFFFF) - invalidValue++; - } - - if (use_gps_ts && lidar_name != "N10") - { - pTime.tm_year = packet_bytes[PACKET_SIZE - 12] + 2000 - 1900; // x+2000 - pTime.tm_mon = packet_bytes[PACKET_SIZE - 11] - 1; // 1-12 - pTime.tm_mday = packet_bytes[PACKET_SIZE - 10]; // 1-31 - pTime.tm_hour = packet_bytes[PACKET_SIZE - 9]; // 0-23 - pTime.tm_min = packet_bytes[PACKET_SIZE - 8]; // 0-59 - pTime.tm_sec = packet_bytes[PACKET_SIZE - 7]; // 0-59 - sub_second = (packet_bytes[PACKET_SIZE - 6] * 256 + packet_bytes[PACKET_SIZE - 5]) * 1000000 + (packet_bytes[PACKET_SIZE - 4] * 256 + packet_bytes[PACKET_SIZE - 3]) * 1000; - sweep_end_time_gps = get_gps_stamp(pTime); - sweep_end_time_hardware = sub_second % 1000000000; - } - invalidValue = package_points - invalidValue; - if (lidar_name == "N10" || lidar_name == "L10") - invalidValue--; - if (invalidValue <= 1) - { - delete packet_bytes; - return; - } - - for (int num = 0; num < package_points; num++) - { - int s = packet_bytes[num * point_len + data_bits_start]; - int z = packet_bytes[num * point_len + data_bits_start + 1]; - int y = 0; - if (lidar_name == "N10" || lidar_name == "L10") - y = packet_bytes[num * point_len + data_bits_start + 2]; - int dist_temp = s & 0x7F; - int inten_temp = s & 0x80; - - if ((s * 256 + z) != 0xFFFF) - { - if (lidar_name == "N10" || lidar_name == "L10") - { - scan_points_[idx].range = double(s * 256 + (z)) / 1000.f; - scan_points_[idx].intensity = int(y); - } - else if ((lidar_name == "M10_P" || lidar_name == "M10_PLUS") && !high_reflection) - { - scan_points_[idx].range = double(s * 256 + (z)) / 1000.f; - scan_points_[idx].intensity = 0; - } - else - { - scan_points_[idx].range = double(dist_temp * 256 + (z)) / 1000.f; - if (inten_temp) - scan_points_[idx].intensity = 255; - else - scan_points_[idx].intensity = 0; - } - if ((degree + (degree_interval / invalidValue * num)) > 360) - scan_points_[idx].degree = degree + (degree_interval / invalidValue * num) - 360; - else - scan_points_[idx].degree = degree + (degree_interval / invalidValue * num); - } - else - continue; - - if ((scan_points_[idx].degree < last_degree && scan_points_[idx].degree < 5 && last_degree > 355) || idx >= points_size_) - { - last_degree = scan_points_[idx].degree; - count_num = idx; - idx = 0; - for (long unsigned int k = 0; k < scan_points_.size(); k++) - { - if (scan_points_[k].range < min_range || scan_points_[k].range > max_range) - scan_points_[k].range = 0; - } - boost::unique_lock lock(mutex_); - scan_points_bak_.resize(scan_points_.size()); - scan_points_bak_.assign(scan_points_.begin(), scan_points_.end()); - for (long unsigned int k = 0; k < scan_points_.size(); k++) - { - scan_points_[k].range = 0; - scan_points_[k].degree = 0; - scan_points_[k].intensity = 0; - } - pre_time_ = time_; - lock.unlock(); - pubscan_cond_.notify_one(); - time_ = get_clock()->now(); - } - else - { - last_degree = scan_points_[idx].degree; - idx++; - } - } - packet_bytes = {0x00}; - if (packet_bytes) - { - packet_bytes = NULL; - delete packet_bytes; - } - } - - void LslidarDriver::data_processing_2(unsigned char *packet_bytes, int len) // 处理每一包的数据 - { - double degree; - double end_degree; - double degree_interval = 15.0; - boost::posix_time::ptime t1, t2; - t1 = boost::posix_time::microsec_clock::universal_time(); - - int s = packet_bytes[degree_bits_start]; - int z = packet_bytes[degree_bits_start + 1]; - - degree = (s * 256 + z) / 100.f + degree_compensation; - degree = (degree < 0) ? degree + 360 : degree; - degree = (degree > 360) ? degree - 360 : degree; - if (lidar_name == "N10_P") - { - int s_e = packet_bytes[end_degree_bits_start]; - int z_e = packet_bytes[end_degree_bits_start + 1]; - - end_degree = (s_e * 256 + z_e) / 100.f; - end_degree = (end_degree > 360) ? end_degree - 360 : end_degree; - - if (degree > end_degree) - degree_interval = end_degree + 360 - degree; - else - degree_interval = end_degree - degree; - } - - // boost::unique_lock lock(mutex_); - if (lidar_name == "M10_DOUBLE") - { - PACKET_SIZE = len; - package_points = (PACKET_SIZE - 20) / 4; - } - int invalidValue = 0; - int point_len = 4; - if (lidar_name == "N10_P") - point_len = 6; - - for (int num = 0; num < point_len * package_points; num += point_len) - { - int s = packet_bytes[num + data_bits_start]; - int z = packet_bytes[num + data_bits_start + 1]; - if ((s * 256 + z) == 0xFFFF) - invalidValue++; - } - - if (use_gps_ts) - { - pTime.tm_year = packet_bytes[PACKET_SIZE - 12] + 2000 - 1900; // x+2000 - pTime.tm_mon = packet_bytes[PACKET_SIZE - 11] - 1; // 1-12 - pTime.tm_mday = packet_bytes[PACKET_SIZE - 10]; // 1-31 - pTime.tm_hour = packet_bytes[PACKET_SIZE - 9]; // 0-23 - pTime.tm_min = packet_bytes[PACKET_SIZE - 8]; // 0-59 - pTime.tm_sec = packet_bytes[PACKET_SIZE - 7]; // 0-59 - sub_second = (packet_bytes[PACKET_SIZE - 6] * 256 + packet_bytes[PACKET_SIZE - 5]) * 1000000 + (packet_bytes[PACKET_SIZE - 4] * 256 + packet_bytes[PACKET_SIZE - 3]) * 1000; - sweep_end_time_gps = get_gps_stamp(pTime); - sweep_end_time_hardware = sub_second % 1000000000; - } - invalidValue = package_points - invalidValue; - if (lidar_name == "N10_P") - invalidValue--; - if (invalidValue <= 1) - { - delete packet_bytes; - return; - } - - for (int num = 0; num < package_points; num++) - { - int s = packet_bytes[num * point_len + data_bits_start]; - int z = packet_bytes[num * point_len + data_bits_start + 1]; - int y = 0; - if (lidar_name == "N10_P") - y = packet_bytes[num * point_len + data_bits_start + 2]; - - if ((s * 256 + z) != 0xFFFF) - { - scan_points_[idx].range = double(s * 256 + (z)) / 1000.f; - if (lidar_name == "N10_P") - scan_points_[idx].intensity = int(y); - else - scan_points_[idx].intensity = 0; - s = packet_bytes[num * point_len + data_bits_start + point_len / 2]; - z = packet_bytes[num * point_len + data_bits_start + point_len / 2 + 1]; - if (lidar_name == "N10_P") - y = packet_bytes[num * point_len + data_bits_start + point_len / 2 + 2]; - - scan_points_[idx + 3000].range = double(s * 256 + (z)) / 1000.f; - if (lidar_name == "N10_P") - scan_points_[idx + 3000].intensity = int(y); - else - scan_points_[idx + 3000].intensity = 0; - - if ((degree + (degree_interval / invalidValue * num)) > 360) - scan_points_[idx].degree = degree + (degree_interval / invalidValue * num) - 360; - else - scan_points_[idx].degree = degree + (degree_interval / invalidValue * num); - } - else - continue; - if (((scan_points_[idx].degree < last_degree && scan_points_[idx].degree < 5 && last_degree > 355) || idx >= points_size_) && idx > 10) - { - last_degree = scan_points_[idx].degree; - count_num = idx; - idx = 0; - for (int k = 0; k < count_num; k++) - { - if (angle_able_max > 360) - { - if ((360 - scan_points_[k].degree) > (angle_able_max - 360) && (360 - scan_points_[k].degree) < angle_able_min) - { - scan_points_[k].range = 0; - scan_points_[k + 3000].range = 0; - } - } - else - { - if ((360 - scan_points_[k].degree) > angle_able_max || (360 - scan_points_[k].degree) < angle_able_min) - { - scan_points_[k].range = 0; - scan_points_[k + 3000].range = 0; - } - } - if (scan_points_[k].range < min_range || scan_points_[k].range > max_range) - scan_points_[k].range = 0; - if (scan_points_[k + 3000].range < min_range || scan_points_[k + 3000].range > max_range) - scan_points_[k + 3000].range = 0; - } - boost::unique_lock lock(mutex_); - scan_points_bak_.resize(scan_points_.size()); - scan_points_bak_.assign(scan_points_.begin(), scan_points_.end()); - for (long unsigned int k = 0; k < scan_points_.size(); k++) - { - scan_points_[k].range = 0; - scan_points_[k].degree = 0; - scan_points_[k].intensity = 0; - } - pre_time_ = time_; - lock.unlock(); - pubscan_cond_.notify_one(); - time_ = get_clock()->now(); - } - else - { - last_degree = scan_points_[idx].degree; - idx++; - } - } - packet_bytes = {0x00}; - if (packet_bytes) - { - packet_bytes = NULL; - delete packet_bytes; - } - } - - void LslidarDriver::pubScanThread() - { - bool wait_for_wake = true; - boost::unique_lock lock(pubscan_mutex_); - - while (rclcpp::ok()) - { - - while (wait_for_wake) - { - pubscan_cond_.wait(lock); - wait_for_wake = false; - } - if (lidar_name == "N10_P" || lidar_name == "M10_DOUBLE") - { - if (pubScan) - { - auto scan = sensor_msgs::msg::LaserScan::UniquePtr(new sensor_msgs::msg::LaserScan()); - ////int scan_num = count_num * 2; - int scan_num = count_num ; - - std::vector points; - rclcpp::Time start_time; - float scan_time; - this->getScan(points, start_time, scan_time); - scan->header.frame_id = frame_id; - if (use_gps_ts) - { - scan->header.stamp = rclcpp::Time(sweep_end_time_gps, sweep_end_time_hardware); - } - else - { - scan->header.stamp = this->now(); // timestamp will obtained from sweep data stamp - } - - scan->angle_min = 0; - scan->angle_max = 2 * M_PI; - scan->angle_increment = 2 * M_PI / (double)(count_num); - scan->range_min = min_range; - scan->range_max = max_range; - scan->ranges.reserve(scan_num); - scan->ranges.assign(scan_num, std::numeric_limits::infinity()); - scan->intensities.reserve(scan_num); - scan->intensities.assign(scan_num, std::numeric_limits::infinity()); - // scan->scan_time = scan_time; - // scan->time_increment = scan_time / (double)(count_num); - - for (int k = 0; k < scan_num; k++) - { - scan->ranges[k] = std::numeric_limits::infinity(); - scan->intensities[k] = 0; - } - - for (int i = 0; i < count_num; i++) - { - int point_idx = round((360 - points[i].degree) * count_num / 360); - if (points[i].range == 0.0) - { - scan->ranges[point_idx] = std::numeric_limits::infinity(); - scan->intensities[point_idx] = 0; - } - else - { - double dist = points[i].range; - scan->ranges[point_idx] = (float)dist; - scan->intensities[point_idx] = points[i].intensity; - } - - if(truncated_mode_){ - int len=sizeof(scan_crop_max) / sizeof(scan_crop_max[0]) ; - for(int j=0;j=(scan_crop_min[j]*count_num / 360)) && (point_idx<=(scan_crop_max[j]*count_num / 360))){ - scan->ranges[point_idx] = std::numeric_limits::infinity(); - scan->intensities[point_idx] = 0; - } - } - } - /* - if (points[i + 3000].range == 0.0) - { - scan->ranges[point_idx + count_num] = std::numeric_limits::infinity(); - scan->intensities[point_idx + count_num] = 0; - } - else - { - double dist = points[i+3000].range; - scan->ranges[point_idx + count_num] = (float)dist; - scan->intensities[point_idx + count_num] = points[i + 3000].intensity; - }*/ - } - scan_pub->publish(std::move(scan)); - } - if (pubPointCloud2) - { - std::vector points; - rclcpp::Time start_time; - float scan_time; - this->getScan(points, start_time, scan_time); - VPointCloud::Ptr point_cloud(new VPointCloud()); - if (use_gps_ts) - { - start_time = rclcpp::Time(sweep_end_time_gps, sweep_end_time_hardware); - } - double timestamp = start_time.seconds(); - point_cloud->header.stamp = static_cast(timestamp * 1e6); - point_cloud->header.frame_id = frame_id; - point_cloud->height = 1; - // printf("now = %f\n",timestamp); - for (uint16_t i = 0; i < count_num; i++) - { - // printf("degree = %f\n",points[i].degree); - double degree = 360.0 - points[i].degree; - bool pass_point = false; - if (angle_able_max < 360) - { - if (degree < angle_able_min || degree > angle_able_max) - pass_point = true; - } - else - { - if (degree < angle_able_min && degree > (angle_able_max - 360)) - pass_point = true; - } - if (points[i].range < 0.001) - pass_point = true; - if (!pass_point) - { - // printf("degree = %f\n",degree); - // printf("angle_able_min = %f\nangle_able_max=%f\n",angle_able_min,angle_able_max); - VPoint point; - int point_idx = round(degree * count_num / 360); - point.timestamp = timestamp - point_idx * (scan_time / count_num); - // printf("timestamp = %f\n",point.timestamp); - point.x = points[i].range * cos(M_PI / 180 * points[i].degree); - point.y = -points[i].range * sin(M_PI / 180 * points[i].degree); - point.z = 0; - point.intensity = points[i].intensity; - point_cloud->points.push_back(point); - ++point_cloud->width; - } - if (points[i + 3000].range < 0.001) - pass_point = true; - if (!pass_point) - { - // printf("degree = %f\n",degree); - // printf("angle_able_min = %f\nangle_able_max=%f\n",angle_able_min,angle_able_max); - VPoint point; - int point_idx = round(degree * count_num / 360); - point.timestamp = timestamp - point_idx * (scan_time / count_num); - // printf("timestamp = %f\n",point.timestamp); - point.x = points[i + 3000].range * cos(M_PI / 180 * points[i].degree); - point.y = -points[i + 3000].range * sin(M_PI / 180 * points[i].degree); - point.z = 0; - point.intensity = points[i + 3000].intensity; - point_cloud->points.push_back(point); - ++point_cloud->width; - } - } - sensor_msgs::msg::PointCloud2 pc_msg; - pcl::toROSMsg(*point_cloud, pc_msg); - point_cloud_pub->publish(pc_msg); - } - } - else - { - if (pubScan) - { - auto scan = sensor_msgs::msg::LaserScan::UniquePtr(new sensor_msgs::msg::LaserScan()); - //int scan_num = ceil((angle_able_max - angle_able_min) / 360 * count_num) + 1; - int scan_num = ceil((angle_able_max - angle_able_min) / 360 * count_num) + 1; - - std::vector points; - rclcpp::Time start_time; - float scan_time; - this->getScan(points, start_time, scan_time); - scan->header.frame_id = frame_id; - if (use_gps_ts) - { - scan->header.stamp = rclcpp::Time(sweep_end_time_gps, sweep_end_time_hardware); - } - else - { - scan->header.stamp = this->now(); // timestamp will obtained from sweep data stamp - } - - if (angle_able_max > 360) - { - scan->angle_min = 2 * M_PI * (angle_able_min - 360) / 360; - scan->angle_max = 2 * M_PI * (angle_able_max - 360) / 360; - } - else - { - scan->angle_min = 2 * M_PI * angle_able_min / 360; - scan->angle_max = 2 * M_PI * angle_able_max / 360; - } - scan->angle_increment = 2 * M_PI / (double)(scan_num - 1); - - scan->range_min = min_range; - scan->range_max = max_range; - scan->ranges.reserve(scan_num); - scan->ranges.assign(scan_num, std::numeric_limits::infinity()); - scan->intensities.reserve(scan_num); - scan->intensities.assign(scan_num, std::numeric_limits::infinity()); - scan->scan_time = 0.1; - scan->time_increment = 0.1 / (double)(scan_num - 1); - - int start_num = floor(angle_able_min * count_num / 360); - int end_num = floor(angle_able_max * count_num / 360); - - for (int i = 0; i < count_num; i++) - { - int point_idx = round((360 - points[i].degree) * count_num / 360); - if (point_idx < (end_num - count_num)) - point_idx += count_num; - point_idx = point_idx - start_num; - if (point_idx < 0 || point_idx >= scan_num) - continue; - if (points[i].range == 0.0) - { - scan->ranges[point_idx] = std::numeric_limits::infinity(); - } - else - { - double dist = points[i].range; - scan->ranges[point_idx] = (float)dist; - } - scan->intensities[point_idx] = points[i].intensity; - - if(truncated_mode_){ - int len=sizeof(scan_crop_max) / sizeof(scan_crop_max[0]) ; - for(int j=0;j=(scan_crop_min[j]*count_num / 360)) && (point_idx<=(scan_crop_max[j]*count_num / 360))){ - scan->ranges[point_idx] = std::numeric_limits::infinity(); - scan->intensities[point_idx] = 0; - } - } - } - } - - - scan_pub->publish(std::move(scan)); - } - if (pubPointCloud2) - { - std::vector points; - rclcpp::Time start_time; - float scan_time; - this->getScan(points, start_time, scan_time); - VPointCloud::Ptr point_cloud(new VPointCloud()); - if (use_gps_ts) - { - start_time = rclcpp::Time(sweep_end_time_gps, sweep_end_time_hardware); - } - double timestamp = start_time.seconds(); - point_cloud->header.stamp = static_cast(timestamp * 1e6); - point_cloud->header.frame_id = frame_id; - point_cloud->height = 1; - for (uint16_t i = 0; i < count_num; i++) - { - double degree = 360.0 - points[i].degree; - bool pass_point = false; - if (angle_able_max < 360) - { - if (degree < angle_able_min || degree > angle_able_max) - pass_point = true; - } - else - { - if (degree < angle_able_min && degree > (angle_able_max - 360)) - pass_point = true; - } - if (points[i].range < 0.001) - pass_point = true; - if (!pass_point) - { - // printf("degree = %f\n",degree); - // printf("angle_able_min = %f\nangle_able_max=%f\n",angle_able_min,angle_able_max); - VPoint point; - int point_idx = round(degree * count_num / 360); - point.timestamp = timestamp - point_idx * (scan_time / count_num); - // printf("timestamp = %f\n",point.timestamp); - point.x = points[i].range * cos(M_PI / 180 * points[i].degree); - point.y = -points[i].range * sin(M_PI / 180 * points[i].degree); - point.z = 0; - point.intensity = points[i].intensity; - point_cloud->points.push_back(point); - ++point_cloud->width; - } - } - sensor_msgs::msg::PointCloud2 pc_msg; - pcl::toROSMsg(*point_cloud, pc_msg); - point_cloud_pub->publish(pc_msg); - } - } - count_num = 0; - wait_for_wake = true; - if (first_compensation && compensation) - { - lidar_difop(); - } - } - } - - bool LslidarDriver::polling() - { - if (!is_start) - return true; - // Allocate a new shared pointer for zero-copy sharing with other nodelets. - unsigned char *packet_bytes = new unsigned char[500]; - int len = 0; - bool difop = false; - if (interface_selection == "net") - { - auto packet = lslidar_msgs::msg::LslidarPacket::UniquePtr( - new lslidar_msgs::msg::LslidarPacket()); - - std_msgs::msg::Byte msg; - while (true) - { - difop = false; - len = 0; - // keep reading until full packet received - len = msop_input_->getPacket(packet); - if (packet->data[0] == 0x5a) - { - if (lidar_name == "N10" || lidar_name == "L10") - len = 58; - else if (lidar_name == "M10") - len = 92; - else if (lidar_name == "N10_P") - len = 108; - else if (lidar_name == "M10_GPS") - len = 102; - else - { - int len_H = packet->data[1]; - int len_L = packet->data[2]; - len = len_H * 256 + len_L; - } - for (int i = len - 1; i > 0; i--) - packet->data[i] = packet->data[i - 1]; - packet->data[0] = 0xa5; - } - - if (lidar_name == "N10" || lidar_name == "L10") - len = 58; - else if (lidar_name == "M10") - len = 92; - else if (lidar_name == "N10_P") - len = 108; - else if (lidar_name == "M10_GPS") - len = 102; - else - { - int len_H = packet->data[2]; - int len_L = packet->data[3]; - len = len_H * 256 + len_L; - } - if ((lidar_name == "M10" || lidar_name == "M10_DOUBLE" || lidar_name == "M10_GPS" || lidar_name == "M10_P" || lidar_name == "M10_PLUS") && compensation) - { - if (packet->data[2] == 0x55 && packet->data[3] == 0x00 && packet->data[186] == 0xFA && packet->data[187] == 0xFB) - { - len = 188; - difop = true; - } - } - - if (len <= 0 || len >= 1000 || packet->data[0] != 0xa5 || packet->data[1] != 0x5a) - continue; - for (int i = 0; i < len; i++) - { - packet_bytes[i] = packet->data[i]; - } - if ((lidar_name == "N10" || lidar_name == "L10" || lidar_name == "N10_P") && packet_bytes[len - 1] != N10_CalCRC8(packet_bytes, len - 1)) - continue; - break; - } - } - else - { - if (in_file_name != "") // 读txt文件功能 - { - int usleep_time = round(1000000 / 10 / 24) - 135; - while (true) - { - std::ifstream file_reader(in_file_name); - while (file_reader.peek() != EOF) - { - std::string line; - std::getline(file_reader, line, '\n'); - for (long unsigned int i = 0; i < line.size() - 1; i++) - { - line[i] = line[i] - 48; - if (line[i] > 9) - line[i] = line[i] - 39; - } - - for (long unsigned int i = 0; i < (line.size() - 1) / 2; i++) - { - packet_bytes[i] = line[i * 2] * 16 + line[i * 2 + 1]; - } - if (lidar_name == "N10" || lidar_name == "L10") - len = 58; - else if (lidar_name == "M10") - len = 92; - else if (lidar_name == "N10_P") - len = 108; - else if (lidar_name == "M10_GPS") - len = 102; - else - { - int len_H = packet_bytes[2]; - int len_L = packet_bytes[3]; - len = len_H * 256 + len_L; - } - if (lidar_name == "N10_P" || lidar_name == "M10_DOUBLE") - LslidarDriver::data_processing_2(packet_bytes, len); - else - LslidarDriver::data_processing(packet_bytes, len); - usleep(usleep_time); - } - } - return false; - } - else - { - while (true) - { - difop = false; - len = 0; - len = LslidarDriver::receive_data(packet_bytes); - if ((lidar_name == "M10" || lidar_name == "M10_DOUBLE" || lidar_name == "M10_GPS" || lidar_name == "M10_P" || lidar_name == "M10_PLUS") && compensation) - { - if (packet_bytes[2] == 0x55 && packet_bytes[3] == 0x00 && packet_bytes[186] == 0xFA && packet_bytes[187] == 0xFB) - difop = true; - } - if (len == 0) - continue; - break; - } - } - } - if (difop) - LslidarDriver::difop_processing(packet_bytes); - else - { - if (lidar_name == "N10_P" || lidar_name == "M10_DOUBLE") - LslidarDriver::data_processing_2(packet_bytes, len); - else - LslidarDriver::data_processing(packet_bytes, len); - } - delete packet_bytes; - return true; - } - -} // namespace lslidar_driver diff --git a/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/src/lslidar_driver.cc.bak b/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/src/lslidar_driver.cc.bak deleted file mode 100644 index c22c0f7..0000000 --- a/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/src/lslidar_driver.cc.bak +++ /dev/null @@ -1,1423 +0,0 @@ -/* - * This file is part of lslidar driver. - * - * The driver is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * The driver is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with the driver. If not, see . - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "rclcpp/rclcpp.hpp" -#include "lslidar_driver/lslidar_driver.h" -#include - -int truncated_mode_=0; //多角度屏蔽开关:默认为0,如果需要屏蔽多个角度,则truncated_mode_赋值为1。 - -int scan_crop_min[]={0,180}; //雷达屏蔽角度,这里屏蔽角度为135°到225°, - //如果要多角度屏蔽,如10~30,50~60,改为: - //scan_angle_min[]={10,50};scan_angle_max[]={30,60}; -int scan_crop_max[]={90,270}; //修改后编译即可 - - -namespace lslidar_driver -{ - - static void my_hander(int sig) - { - printf("sig: %d", sig); - abort(); - } - LslidarDriver::LslidarDriver() : LslidarDriver(rclcpp::NodeOptions()) {} - LslidarDriver::LslidarDriver(const rclcpp::NodeOptions &options) : Node("lslidar_driver_node", options), diagnostics(this) - { - signal(SIGINT, my_hander); - - if (!this->initialize()) - RCLCPP_ERROR(this->get_logger(), "Could not initialize the driver..."); - else - RCLCPP_INFO(this->get_logger(), "Successfully initialize driver..."); - } - - LslidarDriver::~LslidarDriver() - { - return; - } - - bool LslidarDriver::loadParameters() - { - pubscan_thread_ = new boost::thread(boost::bind(&LslidarDriver::pubScanThread, this)); - interface_selection = std::string("net"); - frame_id = std::string("laser_link"); - scan_topic = std::string("/scan"); - lidar_name = std::string("M10"); - pointcloud_topic = std::string("/lslidar_point_cloud"); - is_start = true; - min_range = 0.3; - max_range = 100.0; - use_gps_ts = true; - compensation = true; - pubScan = true; - pubPointCloud2 = true; - angle_disable_min = 0.0; - angle_disable_max = 0.0; - // 添加恒定输出长度参数 - fixed_array_length = 450; //cyy_addcyy_add - this->declare_parameter("fixed_array_length", 450);//cyy_addcyy_add - - - this->declare_parameter("lidar_name", "M10"); - this->declare_parameter("frame_id", "laser_link"); - this->declare_parameter("scan_topic", "/scan"); - this->declare_parameter("pointcloud_topic", "/lslidar_point_cloud"); - this->declare_parameter("min_range", 0.3); - this->declare_parameter("max_range", 100.0); - this->declare_parameter("use_gps_ts", false); - this->declare_parameter("high_reflection", false); - this->declare_parameter("compensation", false); - this->declare_parameter("pubScan", true); - this->declare_parameter("pubPointCloud2", false); - this->declare_parameter("angle_disable_min", 0.0); - this->declare_parameter("angle_disable_max", 0.0); - this->declare_parameter("interface_selection", "net"); - - this->get_parameter("fixed_array_length", fixed_array_length);//cyy_addcyy_add - this->get_parameter("lidar_name", lidar_name); - this->get_parameter("frame_id", frame_id); - this->get_parameter("high_reflection", high_reflection); - this->get_parameter("scan_topic", scan_topic); - this->get_parameter("min_range", min_range); - this->get_parameter("max_range", max_range); - this->get_parameter("use_gps_ts", use_gps_ts); - this->get_parameter("compensation", compensation); - this->get_parameter("pointcloud_topic", pointcloud_topic); - this->get_parameter("pubScan", pubScan); - this->get_parameter("pubPointCloud2", pubPointCloud2); - this->get_parameter("angle_disable_min", angle_disable_min); - this->get_parameter("angle_disable_max", angle_disable_max); - this->get_parameter("interface_selection", interface_selection); - while (angle_disable_min < 0) - angle_disable_min += 360; - while (angle_disable_max < 0) - angle_disable_max += 360; - while (angle_disable_min > 360) - angle_disable_min -= 360; - while (angle_disable_max > 360) - angle_disable_max -= 360; - if (angle_disable_max == angle_disable_min) - { - angle_able_min = 0; - angle_able_max = 360; - } - else - { - if (angle_disable_min < angle_disable_max && angle_disable_min != 0.0) - { - angle_able_min = angle_disable_max; - angle_able_max = angle_disable_min + 360; - } - if (angle_disable_min < angle_disable_max && angle_disable_min == 0.0) - { - angle_able_min = angle_disable_max; - angle_able_max = 360; - } - if (angle_disable_min > angle_disable_max) - { - angle_able_min = angle_disable_max; - angle_able_max = angle_disable_min; - } - } - count_num = 0; - - scan_points_.resize(6000); - - if (lidar_name == "M10") - { - use_gps_ts = false; - PACKET_SIZE = 92; - package_points = 42; - data_bits_start = 6; - degree_bits_start = 2; - rpm_bits_start = 4; - baud_rate_ = 460800; - points_size_ = 1008; - } - else if (lidar_name == "M10_P") - { - PACKET_SIZE = 160; - package_points = 70; - data_bits_start = 8; - degree_bits_start = 4; - rpm_bits_start = 6; - baud_rate_ = 500000; - points_size_ = 2000; - } - else if (lidar_name == "M10_PLUS") - { - PACKET_SIZE = 104; - package_points = 41; - data_bits_start = 8; - degree_bits_start = 4; - rpm_bits_start = 6; - points_size_ = 5000; - baud_rate_ = 921600; - } - else if (lidar_name == "M10_GPS") - { - PACKET_SIZE = 102; - package_points = 42; - data_bits_start = 6; - degree_bits_start = 2; - rpm_bits_start = 4; - baud_rate_ = 460800; - points_size_ = 1008; - } - else if (lidar_name == "N10") - { - PACKET_SIZE = 58; - package_points = 16; - data_bits_start = 7; - degree_bits_start = 5; - end_degree_bits_start = 55; - baud_rate_ = 230400; - points_size_ = 2000; - use_gps_ts = false; - compensation = false; - } - else if (lidar_name == "M10_DOUBLE") - { - PACKET_SIZE = 300; - package_points = 70; - data_bits_start = 8; - degree_bits_start = 4; - rpm_bits_start = 6; - points_size_ = 3000; - baud_rate_ = 921600; - } - else if (lidar_name == "N10_P") - { - PACKET_SIZE = 108; - package_points = 16; - data_bits_start = 7; - degree_bits_start = 5; - end_degree_bits_start = 105; - baud_rate_ = 460800; - points_size_ = 2000; - use_gps_ts = false; - compensation = false; - } - else if (lidar_name == "L10") - { - PACKET_SIZE = 58; - package_points = 16; - data_bits_start = 7; - degree_bits_start = 5; - end_degree_bits_start = 55; - baud_rate_ = 230400; - points_size_ = 2000; - use_gps_ts = false; - compensation = false; - } - RCLCPP_INFO_STREAM(this->get_logger(), "Lidar is " << lidar_name.c_str()); - - if (pubScan) - scan_pub = this->create_publisher(scan_topic, 10); - if (pubPointCloud2) - point_cloud_pub = this->create_publisher(pointcloud_topic, 10); - difop_switch = this->create_subscription("lslidar_order", 1, std::bind(&LslidarDriver::lidar_order, this, std::placeholders::_1)); // 转速输入 - return true; - } - - void LslidarDriver::lidar_difop() - { - if (lidar_name == "L10" || lidar_name == "N10" || lidar_name == "N10_P") - return; - if (interface_selection == "net") - msop_input_->UDP_difop(); - else - { - for (int k = 0; k < 10; k++) - { - unsigned char data[188] = {0x00}; - data[0] = 0xA5; - data[1] = 0x5A; - data[2] = 0x55; - data[184] = 0x08; - data[185] = 0x01; - data[186] = 0xFA; - data[187] = 0xFB; - int rtn = serial_->send((const char *)data, 188); - if (rtn < 0) - printf("start scan error !\n"); - else - return; - } - } - return; - } - - void LslidarDriver::lidar_order(const std_msgs::msg::Int8::SharedPtr msg) - { - if (lidar_name == "L10") - return; - int i = msg->data; - if (i == 0) - is_start = false; - else - is_start = true; - if (interface_selection == "net") - msop_input_->UDP_order(*msg); - else - { - int i = msg->data; - for (int k = 0; k < 10; k++) - { - int rtn; - unsigned char data[188] = {0x00}; - data[0] = 0xA5; - data[1] = 0x5A; - data[2] = 0x55; - data[186] = 0xFA; - data[187] = 0xFB; - - if (lidar_name == "M10" || lidar_name == "M10_GPS" || lidar_name == "M10_P" || lidar_name == "M10_DOUBLE") - { - if (i <= 1) - { // 雷达启停 - data[184] = 0x01; - data[185] = char(i); - } - else if (i == 2) - { // 雷达点云不滤波 - data[181] = 0x0A; - data[184] = 0x06; - if (is_start) - data[185] = 0x01; - } - else if (i == 3) - { // 雷达点云正常滤波 - data[181] = 0x0B; - data[184] = 0x06; - if (is_start) - data[185] = 0x01; - } - else if (i == 4) - { // 雷达近距离滤波 - data[181] = 0x0C; - data[184] = 0x06; - if (is_start) - data[185] = 0x01; - } - else if (i == 100) - { // 接收设备包 - data[184] = 0x08; - data[185] = 0x01; - } - else - return; - } - else if (lidar_name == "M10_PLUS") - { - data[184] = 0x0A; - data[185] = 0x01; - if (i == 5) - { - data[141] = 0x01; - data[142] = 0x2c; - } - else if (i == 6) - { - data[141] = 0x01; - data[142] = 0x68; - } - else if (i == 8) - { - data[141] = 0x01; - data[142] = 0xe0; - } - else if (i == 10) - { - data[141] = 0x02; - data[142] = 0x58; - } - else if (i == 12) - { - data[141] = 0x02; - data[142] = 0xd0; - } - else if (i == 15) - { - data[141] = 0x03; - data[142] = 0x84; - } - else if (i == 20) - { - data[141] = 0x04; - data[142] = 0xb0; - } - else if (i <= 1) - { - data[184] = 0x01; - data[185] = char(i); - } - else if (i == 100) // 接收设备包 - { - data[184] = 0x08; - data[185] = 0x01; - } - else - return; - } - else if (lidar_name == "N10" || lidar_name == "N10_P") - { - if (i <= 1) - { - data[185] = char(i); - data[184] = 0x01; - } - else if (i >= 6 && i <= 12) - { - data[172] = char(i); - data[184] = 0x0a; - data[185] = 0X01; - } - else - return; - } - rtn = serial_->send((const char *)data, 188); - if (rtn < 0) - printf("start scan error !\n"); - else - { - if (i == 1) - usleep(1000000); // 1.0s - if (i == 0) - is_start = false; - if (i == 1) - is_start = true; - return; - } - } - return; - } - } - - void LslidarDriver::open_serial() - { - diagnostics.setHardwareID("Lslidar"); - int code = 0; - serial_port_ = std::string("/dev/ttyUSB0"); - this->declare_parameter("serial_port_", "/dev/ttyUSB0"); - this->get_parameter("serial_port_", serial_port_); - serial_ = LSIOSR::instance(serial_port_, baud_rate_); - code = serial_->init(); - if (code != 0) - { - printf("open_port %s ERROR !\n", serial_port_.c_str()); - rclcpp::shutdown(); - exit(0); - } - printf("open_port %s OK !\n", serial_port_.c_str()); - } - - bool LslidarDriver::createRosIO() - { - UDP_PORT_NUMBER = 2368; - this->declare_parameter("msop_port", 2368); - this->get_parameter("msop_port", UDP_PORT_NUMBER); - RCLCPP_INFO_STREAM(this->get_logger(), "Opening UDP socket: port " << UDP_PORT_NUMBER); - dump_file = std::string(""); - this->declare_parameter("pcap", ""); - this->get_parameter("pcap", dump_file); - // ROS diagnostics - diagnostics.setHardwareID("Lslidar"); - - const double diag_freq = 12 * 24; - diag_max_freq = diag_freq; - diag_min_freq = diag_freq; - RCLCPP_INFO(this->get_logger(), "expected frequency: %.3f (Hz)", diag_freq); - - using namespace diagnostic_updater; - diag_topic.reset(new TopicDiagnostic( - "lslidar_packets", diagnostics, - FrequencyStatusParam(&diag_min_freq, &diag_max_freq, 0.1, 10), - TimeStampStatusParam())); - - int hz = 10; - if (lidar_name == "M10_P") - hz = 12; - else if (lidar_name == "M10_PLUS") - hz = 20; - - double packet_rate = hz * 24; - if (dump_file != "") - { - msop_input_.reset(new lslidar_driver::InputPCAP(this, UDP_PORT_NUMBER, packet_rate, dump_file)); - } - else - { - msop_input_.reset(new lslidar_driver::InputSocket(this, UDP_PORT_NUMBER)); - } - - // Output - return true; - } - - int LslidarDriver::getScan(std::vector &points, rclcpp::Time &scan_time, float &scan_duration) - { - boost::unique_lock lock(mutex_); - points.assign(scan_points_bak_.begin(), scan_points_bak_.end()); - scan_time = pre_time_; - scan_duration = time_.seconds() - pre_time_.seconds(); - return 1; - } - - uint64_t LslidarDriver::get_gps_stamp(struct tm t) - { - - uint64_t ptime = static_cast(timegm(&t)); - return ptime; - } - - bool LslidarDriver::initialize() - { - if (!loadParameters()) - { - RCLCPP_ERROR(this->get_logger(), "Cannot load all required ROS parameters..."); - return false; - } - if (interface_selection == "net") - { - if (!createRosIO()) - { - RCLCPP_ERROR(this->get_logger(), "Cannot create all ROS IO..."); - return false; - } - } - else - { - in_file_name = std::string(""); - this->declare_parameter("in_file_name", ""); - this->get_parameter("in_file_name", in_file_name); - if (in_file_name == "") - open_serial(); - else - { - RCLCPP_INFO_STREAM(this->get_logger(), "Opening txt file " << in_file_name.c_str()); - std::ifstream file_reader(in_file_name); - if (!file_reader.is_open()) - { - RCLCPP_ERROR(this->get_logger(), "Cannot open the file"); - return false; - } - } - } - RCLCPP_INFO(this->get_logger(), "Initialised lslidar without error"); - return true; - } - - void LslidarDriver::recvThread_crc(int &count, int &link_time) - { - if (count <= 0) - link_time++; - else - link_time = 0; - - if (link_time > 150) - { - serial_->close(); - int ret = serial_->init(); - if (ret < 0) - { - RCLCPP_ERROR(this->get_logger(), "serial open fail"); - usleep(200000); - } - link_time = 0; - } - } - - int LslidarDriver::receive_data(unsigned char *packet_bytes) - { - int link_time = 0; - int len_H = 0; - int len_L = 0; - int len = 0; - int count_2 = 0; - int count = 0; - while (count <= 0) - { - count = serial_->read(packet_bytes, 1); - LslidarDriver::recvThread_crc(count, link_time); - } - if (packet_bytes[0] != 0xA5) - return 0; - - while (count_2 <= 0) - { - count_2 = serial_->read(packet_bytes + count, 1); - if (count_2 >= 0) - count += count_2; - LslidarDriver::recvThread_crc(count_2, link_time); - } - - count_2 = 0; - if (packet_bytes[1] != 0x5A) - return 0; - while (count_2 <= 0) - { - count_2 = serial_->read(packet_bytes + count, 2); - if (count_2 >= 0) - count += count_2; - LslidarDriver::recvThread_crc(count_2, link_time); - } - - count_2 = 0; - - if (lidar_name == "M10") - len = 92; - else if (lidar_name == "M10_GPS") - len = 102; - else if (lidar_name == "N10_P") - len = 108; - else if (lidar_name == "N10" || lidar_name == "L10") - len = packet_bytes[2]; - else - { - len_H = packet_bytes[2]; - len_L = packet_bytes[3]; - len = len_H * 256 + len_L; - } - if (lidar_name == "M10" || lidar_name == "M10_DOUBLE" || lidar_name == "M10_GPS" || lidar_name == "M10_P" || lidar_name == "M10_PLUS") - { - if (packet_bytes[2] == 0x55 && packet_bytes[3] == 0x00) - len = 188; - } - while (count < len) - { - count_2 = serial_->read(packet_bytes + count, len - count); - if (count_2 >= 0) - count += count_2; - LslidarDriver::recvThread_crc(count_2, link_time); - } - if (lidar_name == "N10" || lidar_name == "L10" || lidar_name == "N10_P") - { - if (packet_bytes[PACKET_SIZE - 1] != N10_CalCRC8(packet_bytes, PACKET_SIZE - 1)) - return 0; - } - return len; - } - - uint8_t LslidarDriver::N10_CalCRC8(unsigned char *p, int len) - { - uint8_t crc = 0; - int sum = 0; - - for (int i = 0; i < len; i++) - { - sum += uint8_t(p[i]); - } - crc = sum & 0xff; - return crc; - } - - void LslidarDriver::difop_processing(unsigned char *packet_bytes) // 处理设备包的数据 - { - int s = packet_bytes[173]; - int z = packet_bytes[174]; - int degree_temp = s & 0x7F; - int sign_temp = s & 0x80; - degree_compensation = double(degree_temp * 256 + z) / 100.f; - if (sign_temp) - degree_compensation = -degree_compensation; - first_compensation = false; - printf("degree_compensation = %f\n", degree_compensation); - return; - } - - void LslidarDriver::data_processing(unsigned char *packet_bytes, int len) // 处理每一包的数据 - { - double degree; - double end_degree; - double degree_interval = 15.0; - boost::posix_time::ptime t1, t2; - t1 = boost::posix_time::microsec_clock::universal_time(); - - int s = packet_bytes[degree_bits_start]; - int z = packet_bytes[degree_bits_start + 1]; - - degree = (s * 256 + z) / 100.f + degree_compensation; - degree = (degree < 0) ? degree + 360 : degree; - degree = (degree > 360) ? degree - 360 : degree; - if (lidar_name == "N10" || lidar_name == "L10") - { - int s_e = packet_bytes[end_degree_bits_start]; - int z_e = packet_bytes[end_degree_bits_start + 1]; - - end_degree = (s_e * 256 + z_e) / 100.f; - end_degree = (end_degree > 360) ? end_degree - 360 : end_degree; - - if (degree > end_degree) - degree_interval = end_degree + 360 - degree; - else - degree_interval = end_degree - degree; - } - - // boost::unique_lock lock(mutex_); - if (lidar_name == "M10_PLUS" || lidar_name == "M10_P") - { - PACKET_SIZE = len; - package_points = (PACKET_SIZE - 20) / 2; - } - int invalidValue = 0; - int point_len = 2; - if (lidar_name == "N10" || lidar_name == "L10") - point_len = 3; - - if (lidar_name == "M10_GPS" || lidar_name == "M10") - { - int err_data_84 = packet_bytes[84]; - int err_data_85 = packet_bytes[85]; - if ((err_data_84 * 256 + err_data_85) == 0xFFFF || packet_bytes[86] >= 0xF5) - { - packet_bytes[86] = 0xFF; - packet_bytes[87] = 0xFF; - } - } - - for (int num = 0; num < point_len * package_points; num += point_len) - { - int s = packet_bytes[num + data_bits_start]; - int z = packet_bytes[num + data_bits_start + 1]; - if ((s * 256 + z) == 0xFFFF) - invalidValue++; - } - - if (use_gps_ts && lidar_name != "N10") - { - pTime.tm_year = packet_bytes[PACKET_SIZE - 12] + 2000 - 1900; // x+2000 - pTime.tm_mon = packet_bytes[PACKET_SIZE - 11] - 1; // 1-12 - pTime.tm_mday = packet_bytes[PACKET_SIZE - 10]; // 1-31 - pTime.tm_hour = packet_bytes[PACKET_SIZE - 9]; // 0-23 - pTime.tm_min = packet_bytes[PACKET_SIZE - 8]; // 0-59 - pTime.tm_sec = packet_bytes[PACKET_SIZE - 7]; // 0-59 - sub_second = (packet_bytes[PACKET_SIZE - 6] * 256 + packet_bytes[PACKET_SIZE - 5]) * 1000000 + (packet_bytes[PACKET_SIZE - 4] * 256 + packet_bytes[PACKET_SIZE - 3]) * 1000; - sweep_end_time_gps = get_gps_stamp(pTime); - sweep_end_time_hardware = sub_second % 1000000000; - } - invalidValue = package_points - invalidValue; - if (lidar_name == "N10" || lidar_name == "L10") - invalidValue--; - if (invalidValue <= 1) - { - delete packet_bytes; - return; - } - - for (int num = 0; num < package_points; num++) - { - int s = packet_bytes[num * point_len + data_bits_start]; - int z = packet_bytes[num * point_len + data_bits_start + 1]; - int y = 0; - if (lidar_name == "N10" || lidar_name == "L10") - y = packet_bytes[num * point_len + data_bits_start + 2]; - int dist_temp = s & 0x7F; - int inten_temp = s & 0x80; - - if ((s * 256 + z) != 0xFFFF) - { - if (lidar_name == "N10" || lidar_name == "L10") - { - scan_points_[idx].range = double(s * 256 + (z)) / 1000.f; - scan_points_[idx].intensity = int(y); - } - else if ((lidar_name == "M10_P" || lidar_name == "M10_PLUS") && !high_reflection) - { - scan_points_[idx].range = double(s * 256 + (z)) / 1000.f; - scan_points_[idx].intensity = 0; - } - else - { - scan_points_[idx].range = double(dist_temp * 256 + (z)) / 1000.f; - if (inten_temp) - scan_points_[idx].intensity = 255; - else - scan_points_[idx].intensity = 0; - } - if ((degree + (degree_interval / invalidValue * num)) > 360) - scan_points_[idx].degree = degree + (degree_interval / invalidValue * num) - 360; - else - scan_points_[idx].degree = degree + (degree_interval / invalidValue * num); - } - else - continue; - - if ((scan_points_[idx].degree < last_degree && scan_points_[idx].degree < 5 && last_degree > 355) || idx >= points_size_) - { - last_degree = scan_points_[idx].degree; - count_num = idx; - idx = 0; - for (long unsigned int k = 0; k < scan_points_.size(); k++) - { - if (scan_points_[k].range < min_range || scan_points_[k].range > max_range) - scan_points_[k].range = 0; - } - boost::unique_lock lock(mutex_); - scan_points_bak_.resize(scan_points_.size()); - scan_points_bak_.assign(scan_points_.begin(), scan_points_.end()); - for (long unsigned int k = 0; k < scan_points_.size(); k++) - { - scan_points_[k].range = 0; - scan_points_[k].degree = 0; - scan_points_[k].intensity = 0; - } - pre_time_ = time_; - lock.unlock(); - pubscan_cond_.notify_one(); - time_ = get_clock()->now(); - } - else - { - last_degree = scan_points_[idx].degree; - idx++; - } - } - packet_bytes = {0x00}; - if (packet_bytes) - { - packet_bytes = NULL; - delete packet_bytes; - } - } - - void LslidarDriver::data_processing_2(unsigned char *packet_bytes, int len) // 处理每一包的数据 - { - double degree; - double end_degree; - double degree_interval = 15.0; - boost::posix_time::ptime t1, t2; - t1 = boost::posix_time::microsec_clock::universal_time(); - - int s = packet_bytes[degree_bits_start]; - int z = packet_bytes[degree_bits_start + 1]; - - degree = (s * 256 + z) / 100.f + degree_compensation; - degree = (degree < 0) ? degree + 360 : degree; - degree = (degree > 360) ? degree - 360 : degree; - if (lidar_name == "N10_P") - { - int s_e = packet_bytes[end_degree_bits_start]; - int z_e = packet_bytes[end_degree_bits_start + 1]; - - end_degree = (s_e * 256 + z_e) / 100.f; - end_degree = (end_degree > 360) ? end_degree - 360 : end_degree; - - if (degree > end_degree) - degree_interval = end_degree + 360 - degree; - else - degree_interval = end_degree - degree; - } - - // boost::unique_lock lock(mutex_); - if (lidar_name == "M10_DOUBLE") - { - PACKET_SIZE = len; - package_points = (PACKET_SIZE - 20) / 4; - } - int invalidValue = 0; - int point_len = 4; - if (lidar_name == "N10_P") - point_len = 6; - - for (int num = 0; num < point_len * package_points; num += point_len) - { - int s = packet_bytes[num + data_bits_start]; - int z = packet_bytes[num + data_bits_start + 1]; - if ((s * 256 + z) == 0xFFFF) - invalidValue++; - } - - if (use_gps_ts) - { - pTime.tm_year = packet_bytes[PACKET_SIZE - 12] + 2000 - 1900; // x+2000 - pTime.tm_mon = packet_bytes[PACKET_SIZE - 11] - 1; // 1-12 - pTime.tm_mday = packet_bytes[PACKET_SIZE - 10]; // 1-31 - pTime.tm_hour = packet_bytes[PACKET_SIZE - 9]; // 0-23 - pTime.tm_min = packet_bytes[PACKET_SIZE - 8]; // 0-59 - pTime.tm_sec = packet_bytes[PACKET_SIZE - 7]; // 0-59 - sub_second = (packet_bytes[PACKET_SIZE - 6] * 256 + packet_bytes[PACKET_SIZE - 5]) * 1000000 + (packet_bytes[PACKET_SIZE - 4] * 256 + packet_bytes[PACKET_SIZE - 3]) * 1000; - sweep_end_time_gps = get_gps_stamp(pTime); - sweep_end_time_hardware = sub_second % 1000000000; - } - invalidValue = package_points - invalidValue; - if (lidar_name == "N10_P") - invalidValue--; - if (invalidValue <= 1) - { - delete packet_bytes; - return; - } - - for (int num = 0; num < package_points; num++) - { - int s = packet_bytes[num * point_len + data_bits_start]; - int z = packet_bytes[num * point_len + data_bits_start + 1]; - int y = 0; - if (lidar_name == "N10_P") - y = packet_bytes[num * point_len + data_bits_start + 2]; - - if ((s * 256 + z) != 0xFFFF) - { - scan_points_[idx].range = double(s * 256 + (z)) / 1000.f; - if (lidar_name == "N10_P") - scan_points_[idx].intensity = int(y); - else - scan_points_[idx].intensity = 0; - s = packet_bytes[num * point_len + data_bits_start + point_len / 2]; - z = packet_bytes[num * point_len + data_bits_start + point_len / 2 + 1]; - if (lidar_name == "N10_P") - y = packet_bytes[num * point_len + data_bits_start + point_len / 2 + 2]; - - scan_points_[idx + 3000].range = double(s * 256 + (z)) / 1000.f; - if (lidar_name == "N10_P") - scan_points_[idx + 3000].intensity = int(y); - else - scan_points_[idx + 3000].intensity = 0; - - if ((degree + (degree_interval / invalidValue * num)) > 360) - scan_points_[idx].degree = degree + (degree_interval / invalidValue * num) - 360; - else - scan_points_[idx].degree = degree + (degree_interval / invalidValue * num); - } - else - continue; - if (((scan_points_[idx].degree < last_degree && scan_points_[idx].degree < 5 && last_degree > 355) || idx >= points_size_) && idx > 10) - { - last_degree = scan_points_[idx].degree; - count_num = idx; - idx = 0; - for (int k = 0; k < count_num; k++) - { - if (angle_able_max > 360) - { - if ((360 - scan_points_[k].degree) > (angle_able_max - 360) && (360 - scan_points_[k].degree) < angle_able_min) - { - scan_points_[k].range = 0; - scan_points_[k + 3000].range = 0; - } - } - else - { - if ((360 - scan_points_[k].degree) > angle_able_max || (360 - scan_points_[k].degree) < angle_able_min) - { - scan_points_[k].range = 0; - scan_points_[k + 3000].range = 0; - } - } - if (scan_points_[k].range < min_range || scan_points_[k].range > max_range) - scan_points_[k].range = 0; - if (scan_points_[k + 3000].range < min_range || scan_points_[k + 3000].range > max_range) - scan_points_[k + 3000].range = 0; - } - boost::unique_lock lock(mutex_); - scan_points_bak_.resize(scan_points_.size()); - scan_points_bak_.assign(scan_points_.begin(), scan_points_.end()); - for (long unsigned int k = 0; k < scan_points_.size(); k++) - { - scan_points_[k].range = 0; - scan_points_[k].degree = 0; - scan_points_[k].intensity = 0; - } - pre_time_ = time_; - lock.unlock(); - pubscan_cond_.notify_one(); - time_ = get_clock()->now(); - } - else - { - last_degree = scan_points_[idx].degree; - idx++; - } - } - packet_bytes = {0x00}; - if (packet_bytes) - { - packet_bytes = NULL; - delete packet_bytes; - } - } - - void LslidarDriver::pubScanThread() - { - bool wait_for_wake = true; - boost::unique_lock lock(pubscan_mutex_); - - while (rclcpp::ok()) - { - - while (wait_for_wake) - { - pubscan_cond_.wait(lock); - wait_for_wake = false; - } - if (lidar_name == "N10_P" || lidar_name == "M10_DOUBLE") - { - if (pubScan) - { - auto scan = sensor_msgs::msg::LaserScan::UniquePtr(new sensor_msgs::msg::LaserScan()); - ////int scan_num = count_num * 2; - int scan_num = count_num ; - - std::vector points; - rclcpp::Time start_time; - float scan_time; - this->getScan(points, start_time, scan_time); - scan->header.frame_id = frame_id; - if (use_gps_ts) - { - scan->header.stamp = rclcpp::Time(sweep_end_time_gps, sweep_end_time_hardware); - } - else - { - scan->header.stamp = this->now(); // timestamp will obtained from sweep data stamp - } - - scan->angle_min = 0; - scan->angle_max = 2 * M_PI; - scan->angle_increment = 2 * M_PI / (double)(count_num); - scan->range_min = min_range; - scan->range_max = max_range; - scan->ranges.reserve(scan_num); - scan->ranges.assign(scan_num, std::numeric_limits::infinity()); - scan->intensities.reserve(scan_num); - scan->intensities.assign(scan_num, std::numeric_limits::infinity()); - // scan->scan_time = scan_time; - // scan->time_increment = scan_time / (double)(count_num); - - for (int k = 0; k < scan_num; k++) - { - scan->ranges[k] = std::numeric_limits::infinity(); - scan->intensities[k] = 0; - } - - for (int i = 0; i < count_num; i++) - { - int point_idx = round((360 - points[i].degree) * count_num / 360); - if (points[i].range == 0.0) - { - scan->ranges[point_idx] = std::numeric_limits::infinity(); - scan->intensities[point_idx] = 0; - } - else - { - double dist = points[i].range; - scan->ranges[point_idx] = (float)dist; - scan->intensities[point_idx] = points[i].intensity; - } - - if(truncated_mode_){ - int len=sizeof(scan_crop_max) / sizeof(scan_crop_max[0]) ; - for(int j=0;j=(scan_crop_min[j]*count_num / 360)) && (point_idx<=(scan_crop_max[j]*count_num / 360))){ - scan->ranges[point_idx] = std::numeric_limits::infinity(); - scan->intensities[point_idx] = 0; - } - } - } - /* - if (points[i + 3000].range == 0.0) - { - scan->ranges[point_idx + count_num] = std::numeric_limits::infinity(); - scan->intensities[point_idx + count_num] = 0; - } - else - { - double dist = points[i+3000].range; - scan->ranges[point_idx + count_num] = (float)dist; - scan->intensities[point_idx + count_num] = points[i + 3000].intensity; - }*/ - } - scan_pub->publish(std::move(scan)); - } - if (pubPointCloud2) - { - std::vector points; - rclcpp::Time start_time; - float scan_time; - this->getScan(points, start_time, scan_time); - VPointCloud::Ptr point_cloud(new VPointCloud()); - if (use_gps_ts) - { - start_time = rclcpp::Time(sweep_end_time_gps, sweep_end_time_hardware); - } - double timestamp = start_time.seconds(); - point_cloud->header.stamp = static_cast(timestamp * 1e6); - point_cloud->header.frame_id = frame_id; - point_cloud->height = 1; - // printf("now = %f\n",timestamp); - for (uint16_t i = 0; i < count_num; i++) - { - // printf("degree = %f\n",points[i].degree); - double degree = 360.0 - points[i].degree; - bool pass_point = false; - if (angle_able_max < 360) - { - if (degree < angle_able_min || degree > angle_able_max) - pass_point = true; - } - else - { - if (degree < angle_able_min && degree > (angle_able_max - 360)) - pass_point = true; - } - if (points[i].range < 0.001) - pass_point = true; - if (!pass_point) - { - // printf("degree = %f\n",degree); - // printf("angle_able_min = %f\nangle_able_max=%f\n",angle_able_min,angle_able_max); - VPoint point; - int point_idx = round(degree * count_num / 360); - point.timestamp = timestamp - point_idx * (scan_time / count_num); - // printf("timestamp = %f\n",point.timestamp); - point.x = points[i].range * cos(M_PI / 180 * points[i].degree); - point.y = -points[i].range * sin(M_PI / 180 * points[i].degree); - point.z = 0; - point.intensity = points[i].intensity; - point_cloud->points.push_back(point); - ++point_cloud->width; - } - if (points[i + 3000].range < 0.001) - pass_point = true; - if (!pass_point) - { - // printf("degree = %f\n",degree); - // printf("angle_able_min = %f\nangle_able_max=%f\n",angle_able_min,angle_able_max); - VPoint point; - int point_idx = round(degree * count_num / 360); - point.timestamp = timestamp - point_idx * (scan_time / count_num); - // printf("timestamp = %f\n",point.timestamp); - point.x = points[i + 3000].range * cos(M_PI / 180 * points[i].degree); - point.y = -points[i + 3000].range * sin(M_PI / 180 * points[i].degree); - point.z = 0; - point.intensity = points[i + 3000].intensity; - point_cloud->points.push_back(point); - ++point_cloud->width; - } - } - sensor_msgs::msg::PointCloud2 pc_msg; - pcl::toROSMsg(*point_cloud, pc_msg); - point_cloud_pub->publish(pc_msg); - } - } - else - { - if (pubScan) - { - auto scan = sensor_msgs::msg::LaserScan::UniquePtr(new sensor_msgs::msg::LaserScan()); - //int scan_num = ceil((angle_able_max - angle_able_min) / 360 * count_num) + 1; - int scan_num = fixed_array_length;//cyy_addcyy_add - - std::vector points; - rclcpp::Time start_time; - float scan_time; - this->getScan(points, start_time, scan_time); - scan->header.frame_id = frame_id; - if (use_gps_ts) - { - scan->header.stamp = rclcpp::Time(sweep_end_time_gps, sweep_end_time_hardware); - } - else - { - scan->header.stamp = this->now(); // timestamp will obtained from sweep data stamp - } - - if (angle_able_max > 360) - { - scan->angle_min = 2 * M_PI * (angle_able_min - 360) / 360; - scan->angle_max = 2 * M_PI * (angle_able_max - 360) / 360; - } - else - { - scan->angle_min = 2 * M_PI * angle_able_min / 360; - scan->angle_max = 2 * M_PI * angle_able_max / 360; - } - scan->angle_increment = 2 * M_PI / (double)(fixed_array_length - 1); - - scan->range_min = min_range; - scan->range_max = max_range; - scan->ranges.reserve(scan_num); - scan->ranges.assign(scan_num, std::numeric_limits::infinity()); - scan->intensities.reserve(scan_num); - scan->intensities.assign(scan_num, std::numeric_limits::infinity()); - scan->scan_time = 0.1; - scan->time_increment = 0.1 / (double)(fixed_array_length - 1); - - int start_num = floor(angle_able_min * count_num / 360); - int end_num = floor(angle_able_max * count_num / 360); - - for (int i = 0; i < count_num; i++) - { - int point_idx = round((360 - points[i].degree) * count_num / 360); - if (point_idx < (end_num - count_num)) - point_idx += count_num; - point_idx = point_idx - start_num; - if (point_idx < 0 || point_idx >= scan_num) - continue; - if (points[i].range == 0.0) - { - scan->ranges[point_idx] = std::numeric_limits::infinity(); - } - else - { - double dist = points[i].range; - scan->ranges[point_idx] = (float)dist; - } - scan->intensities[point_idx] = points[i].intensity; - - if(truncated_mode_){ - int len=sizeof(scan_crop_max) / sizeof(scan_crop_max[0]) ; - for(int j=0;j=(scan_crop_min[j]*count_num / 360)) && (point_idx<=(scan_crop_max[j]*count_num / 360))){ - scan->ranges[point_idx] = std::numeric_limits::infinity(); - scan->intensities[point_idx] = 0; - } - } - } - } - - - scan_pub->publish(std::move(scan)); - } - if (pubPointCloud2) - { - std::vector points; - rclcpp::Time start_time; - float scan_time; - this->getScan(points, start_time, scan_time); - VPointCloud::Ptr point_cloud(new VPointCloud()); - if (use_gps_ts) - { - start_time = rclcpp::Time(sweep_end_time_gps, sweep_end_time_hardware); - } - double timestamp = start_time.seconds(); - point_cloud->header.stamp = static_cast(timestamp * 1e6); - point_cloud->header.frame_id = frame_id; - point_cloud->height = 1; - for (uint16_t i = 0; i < count_num; i++) - { - double degree = 360.0 - points[i].degree; - bool pass_point = false; - if (angle_able_max < 360) - { - if (degree < angle_able_min || degree > angle_able_max) - pass_point = true; - } - else - { - if (degree < angle_able_min && degree > (angle_able_max - 360)) - pass_point = true; - } - if (points[i].range < 0.001) - pass_point = true; - if (!pass_point) - { - // printf("degree = %f\n",degree); - // printf("angle_able_min = %f\nangle_able_max=%f\n",angle_able_min,angle_able_max); - VPoint point; - int point_idx = round(degree * count_num / 360); - point.timestamp = timestamp - point_idx * (scan_time / count_num); - // printf("timestamp = %f\n",point.timestamp); - point.x = points[i].range * cos(M_PI / 180 * points[i].degree); - point.y = -points[i].range * sin(M_PI / 180 * points[i].degree); - point.z = 0; - point.intensity = points[i].intensity; - point_cloud->points.push_back(point); - ++point_cloud->width; - } - } - sensor_msgs::msg::PointCloud2 pc_msg; - pcl::toROSMsg(*point_cloud, pc_msg); - point_cloud_pub->publish(pc_msg); - } - } - count_num = 0; - wait_for_wake = true; - if (first_compensation && compensation) - { - lidar_difop(); - } - } - } - - bool LslidarDriver::polling() - { - if (!is_start) - return true; - // Allocate a new shared pointer for zero-copy sharing with other nodelets. - unsigned char *packet_bytes = new unsigned char[500]; - int len = 0; - bool difop = false; - if (interface_selection == "net") - { - auto packet = lslidar_msgs::msg::LslidarPacket::UniquePtr( - new lslidar_msgs::msg::LslidarPacket()); - - std_msgs::msg::Byte msg; - while (true) - { - difop = false; - len = 0; - // keep reading until full packet received - len = msop_input_->getPacket(packet); - if (packet->data[0] == 0x5a) - { - if (lidar_name == "N10" || lidar_name == "L10") - len = 58; - else if (lidar_name == "M10") - len = 92; - else if (lidar_name == "N10_P") - len = 108; - else if (lidar_name == "M10_GPS") - len = 102; - else - { - int len_H = packet->data[1]; - int len_L = packet->data[2]; - len = len_H * 256 + len_L; - } - for (int i = len - 1; i > 0; i--) - packet->data[i] = packet->data[i - 1]; - packet->data[0] = 0xa5; - } - - if (lidar_name == "N10" || lidar_name == "L10") - len = 58; - else if (lidar_name == "M10") - len = 92; - else if (lidar_name == "N10_P") - len = 108; - else if (lidar_name == "M10_GPS") - len = 102; - else - { - int len_H = packet->data[2]; - int len_L = packet->data[3]; - len = len_H * 256 + len_L; - } - if ((lidar_name == "M10" || lidar_name == "M10_DOUBLE" || lidar_name == "M10_GPS" || lidar_name == "M10_P" || lidar_name == "M10_PLUS") && compensation) - { - if (packet->data[2] == 0x55 && packet->data[3] == 0x00 && packet->data[186] == 0xFA && packet->data[187] == 0xFB) - { - len = 188; - difop = true; - } - } - - if (len <= 0 || len >= 1000 || packet->data[0] != 0xa5 || packet->data[1] != 0x5a) - continue; - for (int i = 0; i < len; i++) - { - packet_bytes[i] = packet->data[i]; - } - if ((lidar_name == "N10" || lidar_name == "L10" || lidar_name == "N10_P") && packet_bytes[len - 1] != N10_CalCRC8(packet_bytes, len - 1)) - continue; - break; - } - } - else - { - if (in_file_name != "") // 读txt文件功能 - { - int usleep_time = round(1000000 / 10 / 24) - 135; - while (true) - { - std::ifstream file_reader(in_file_name); - while (file_reader.peek() != EOF) - { - std::string line; - std::getline(file_reader, line, '\n'); - for (long unsigned int i = 0; i < line.size() - 1; i++) - { - line[i] = line[i] - 48; - if (line[i] > 9) - line[i] = line[i] - 39; - } - - for (long unsigned int i = 0; i < (line.size() - 1) / 2; i++) - { - packet_bytes[i] = line[i * 2] * 16 + line[i * 2 + 1]; - } - if (lidar_name == "N10" || lidar_name == "L10") - len = 58; - else if (lidar_name == "M10") - len = 92; - else if (lidar_name == "N10_P") - len = 108; - else if (lidar_name == "M10_GPS") - len = 102; - else - { - int len_H = packet_bytes[2]; - int len_L = packet_bytes[3]; - len = len_H * 256 + len_L; - } - if (lidar_name == "N10_P" || lidar_name == "M10_DOUBLE") - LslidarDriver::data_processing_2(packet_bytes, len); - else - LslidarDriver::data_processing(packet_bytes, len); - usleep(usleep_time); - } - } - return false; - } - else - { - while (true) - { - difop = false; - len = 0; - len = LslidarDriver::receive_data(packet_bytes); - if ((lidar_name == "M10" || lidar_name == "M10_DOUBLE" || lidar_name == "M10_GPS" || lidar_name == "M10_P" || lidar_name == "M10_PLUS") && compensation) - { - if (packet_bytes[2] == 0x55 && packet_bytes[3] == 0x00 && packet_bytes[186] == 0xFA && packet_bytes[187] == 0xFB) - difop = true; - } - if (len == 0) - continue; - break; - } - } - } - if (difop) - LslidarDriver::difop_processing(packet_bytes); - else - { - if (lidar_name == "N10_P" || lidar_name == "M10_DOUBLE") - LslidarDriver::data_processing_2(packet_bytes, len); - else - LslidarDriver::data_processing(packet_bytes, len); - } - delete packet_bytes; - return true; - } - -} // namespace lslidar_driver diff --git a/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/src/lslidar_driver_node.cc b/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/src/lslidar_driver_node.cc deleted file mode 100644 index 6a89f99..0000000 --- a/src/LSLIDAR_X_ROS2-20240228/src/lslidar_driver/src/lslidar_driver_node.cc +++ /dev/null @@ -1,35 +0,0 @@ -/* - * This file is part of lslidar driver. - * - * The driver is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * The driver is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with the driver. If not, see . - */ - -#include "rclcpp/rclcpp.hpp" -#include "lslidar_driver/lslidar_driver.h" - -using namespace lslidar_driver; -volatile sig_atomic_t flag = 1; - -int main(int argc, char* argv[]) -{ - rclcpp::init(argc, argv); - auto node = std::make_shared(); - - while (rclcpp::ok() && node->polling()) { - rclcpp::spin_some(node); - } - //rclcpp::spin(node); - rclcpp::shutdown(); - return 0; -} diff --git a/src/LSLIDAR_X_ROS2-20240228/src/lslidar_msgs/CMakeLists.txt b/src/LSLIDAR_X_ROS2-20240228/src/lslidar_msgs/CMakeLists.txt deleted file mode 100644 index e6a603e..0000000 --- a/src/LSLIDAR_X_ROS2-20240228/src/lslidar_msgs/CMakeLists.txt +++ /dev/null @@ -1,39 +0,0 @@ -cmake_minimum_required(VERSION 3.5) -project(lslidar_msgs) - -# Default to C99 -if(NOT CMAKE_C_STANDARD) - set(CMAKE_C_STANDARD 99) -endif() - -# Default to C++14 -if(NOT CMAKE_CXX_STANDARD) - set(CMAKE_CXX_STANDARD 14) -endif() - -if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") - add_compile_options(-Wall -Wextra -Wpedantic) -endif() - -# find dependencies -find_package(ament_cmake REQUIRED) -find_package(std_msgs REQUIRED) -find_package(sensor_msgs REQUIRED) -find_package(builtin_interfaces REQUIRED) -find_package(rosidl_default_generators REQUIRED) - -if(BUILD_TESTING) - find_package(ament_lint_auto REQUIRED) - ament_lint_auto_find_test_dependencies() -endif() - -rosidl_generate_interfaces(lslidar_msgs - "msg/LslidarDifop.msg" - "msg/LslidarPacket.msg" - "msg/LslidarPoint.msg" - "msg/LslidarScan.msg" - "msg/LslidarSweep.msg" - DEPENDENCIES builtin_interfaces std_msgs - ) - -ament_package() diff --git a/src/LSLIDAR_X_ROS2-20240228/src/lslidar_msgs/msg/LslidarDifop.msg b/src/LSLIDAR_X_ROS2-20240228/src/lslidar_msgs/msg/LslidarDifop.msg deleted file mode 100644 index f377c75..0000000 --- a/src/LSLIDAR_X_ROS2-20240228/src/lslidar_msgs/msg/LslidarDifop.msg +++ /dev/null @@ -1,2 +0,0 @@ -int64 temperature -int64 rpm diff --git a/src/LSLIDAR_X_ROS2-20240228/src/lslidar_msgs/msg/LslidarPacket.msg b/src/LSLIDAR_X_ROS2-20240228/src/lslidar_msgs/msg/LslidarPacket.msg deleted file mode 100644 index d77ee45..0000000 --- a/src/LSLIDAR_X_ROS2-20240228/src/lslidar_msgs/msg/LslidarPacket.msg +++ /dev/null @@ -1,5 +0,0 @@ -# Raw Leishen LIDAR packet. - -builtin_interfaces/Time stamp # packet timestamp -uint8[2000] data # packet contents - diff --git a/src/LSLIDAR_X_ROS2-20240228/src/lslidar_msgs/msg/LslidarPoint.msg b/src/LSLIDAR_X_ROS2-20240228/src/lslidar_msgs/msg/LslidarPoint.msg deleted file mode 100644 index 3132167..0000000 --- a/src/LSLIDAR_X_ROS2-20240228/src/lslidar_msgs/msg/LslidarPoint.msg +++ /dev/null @@ -1,12 +0,0 @@ -# Time when the point is captured -float32 time - -# Converted distance in the sensor frame -float64 x -float64 y -float64 z - -# Raw measurement from Leishen M10 -float64 azimuth -float64 distance -float64 intensity diff --git a/src/LSLIDAR_X_ROS2-20240228/src/lslidar_msgs/msg/LslidarScan.msg b/src/LSLIDAR_X_ROS2-20240228/src/lslidar_msgs/msg/LslidarScan.msg deleted file mode 100644 index 0a3891c..0000000 --- a/src/LSLIDAR_X_ROS2-20240228/src/lslidar_msgs/msg/LslidarScan.msg +++ /dev/null @@ -1,6 +0,0 @@ -# Altitude of all the points within this scan -float64 altitude - -# The valid points in this scan sorted by azimuth -# from 0 to 359.99 -LslidarPoint[] points diff --git a/src/LSLIDAR_X_ROS2-20240228/src/lslidar_msgs/msg/LslidarSweep.msg b/src/LSLIDAR_X_ROS2-20240228/src/lslidar_msgs/msg/LslidarSweep.msg deleted file mode 100644 index 9cfe4b7..0000000 --- a/src/LSLIDAR_X_ROS2-20240228/src/lslidar_msgs/msg/LslidarSweep.msg +++ /dev/null @@ -1,4 +0,0 @@ -std_msgs/Header header - -# The 0th scan is at the bottom -LslidarScan[16] scans diff --git a/src/LSLIDAR_X_ROS2-20240228/src/lslidar_msgs/package.xml b/src/LSLIDAR_X_ROS2-20240228/src/lslidar_msgs/package.xml deleted file mode 100644 index 8001ad5..0000000 --- a/src/LSLIDAR_X_ROS2-20240228/src/lslidar_msgs/package.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - lslidar_msgs - 1.2.0 - ROS message definitions for Leishen LIDARs. - Nick Shu - Nick Shu - GNU General Public License V3.0 - - ament_cmake - rosidl_default_generators - - rosidl_default_runtime - builtin_interfaces - - std_msgs - ament_lint_auto - ament_lint_common - - rosidl_interface_packages - - - ament_cmake - - diff --git a/src/LSLIDAR_X_ROS2-20240228/src/version.txt b/src/LSLIDAR_X_ROS2-20240228/src/version.txt deleted file mode 100644 index 7a2b9d4..0000000 --- a/src/LSLIDAR_X_ROS2-20240228/src/version.txt +++ /dev/null @@ -1,20 +0,0 @@ -版本变更 -/*************************************************************** -初始版本: LSLIDAR_M10_N10_V2.5.0_221104_ROS2 -变更内容: - 1.实现M10/M10_P/M10_PLUS/N10/M10_GPS网口和串口传输数据生成点云功能 - 2.实现点云角度裁剪和距离过滤功能 - 3.可以通过lslidar_order话题控制雷达启停 - 4.支持读取pcap包 - -更改日期: 2022-11-04 -***************************************************************/ - -/*************************************************************** -初始版本: LSLIDAR_M10_N10_V2.5.0_221111_ROS2 -变更内容: - 1.针对M10和M10_GPS雷达出货后发现的点云问题进行驱动补救 - -更改日期: 2022-11-11 -***************************************************************/ - diff --git a/src/LSLIDAR_X_ROS2-20240228/src/wheeltec_udev.sh b/src/LSLIDAR_X_ROS2-20240228/src/wheeltec_udev.sh deleted file mode 100644 index 17aaa46..0000000 --- a/src/LSLIDAR_X_ROS2-20240228/src/wheeltec_udev.sh +++ /dev/null @@ -1,33 +0,0 @@ -#CP2102 串口号0002 设置别名为wheeltec_controller -echo 'KERNEL=="ttyUSB*", ATTRS{idVendor}=="10c4", ATTRS{idProduct}=="ea60",ATTRS{serial}=="0002", MODE:="0777", GROUP:="dialout", SYMLINK+="wheeltec_controller"' >/etc/udev/rules.d/wheeltec_controller.rules -#CH9102,同时系统安装了对应驱动 串口号0002 设置别名为wheeltec_controller -echo 'KERNEL=="ttyCH343USB*", ATTRS{idVendor}=="1a86", ATTRS{idProduct}=="55d4",ATTRS{serial}=="0002", MODE:="0777", GROUP:="dialout", SYMLINK+="wheeltec_controller"' >/etc/udev/rules.d/wheeltec_controller2.rules -#CH9102,同时系统没有安装对应驱动 串口号0002 设置别名为wheeltec_controller -echo 'KERNEL=="ttyACM*", ATTRS{idVendor}=="1a86", ATTRS{idProduct}=="55d4",ATTRS{serial}=="0002", MODE:="0777", GROUP:="dialout", SYMLINK+="wheeltec_controller"' >/etc/udev/rules.d/wheeltec_controller3.rules - -#CP2102 串口号0001 设置别名为wheeltec_lidar -echo 'KERNEL=="ttyUSB*", ATTRS{idVendor}=="10c4", ATTRS{idProduct}=="ea60",ATTRS{serial}=="0001", MODE:="0777", GROUP:="dialout", SYMLINK+="wheeltec_lidar"' >/etc/udev/rules.d/wheeltec_lidar.rules -#CH9102,同时系统安装了对应驱动 串口号0001 设置别名为wheeltec_lidar -echo 'KERNEL=="ttyCH343USB*", ATTRS{idVendor}=="1a86", ATTRS{idProduct}=="55d4",ATTRS{serial}=="54B8001974", MODE:="0777", GROUP:="dialout", SYMLINK+="wheeltec_lidar"' >/etc/udev/rules.d/wheeltec_lidar2.rules -#CH9102,同时系统没有安装对应驱动 串口号0001 设置别名为wheeltec_lidar -echo 'KERNEL=="ttyACM*", ATTRS{idVendor}=="1a86", ATTRS{idProduct}=="55d4",ATTRS{serial}=="0001", MODE:="0777", GROUP:="dialout", SYMLINK+="wheeltec_lidar"' >/etc/udev/rules.d/wheeltec_lidar3.rules - -#CP2102 串口号0003 设置别名为wheeltec_FDI_IMU_GNSS -echo 'KERNEL=="ttyUSB*", ATTRS{idVendor}=="10c4", ATTRS{idProduct}=="ea60",ATTRS{serial}=="0003", MODE:="0777", GROUP:="dialout", SYMLINK+="wheeltec_FDI_IMU_GNSS"' >/etc/udev/rules.d/wheeltec_fdi_imu_gnss.rules -#CH9102,同时系统安装了对应驱动 串口号0003 设置别名为wheeltec_FDI_IMU_GNSS -echo 'KERNEL=="ttyCH343USB*", ATTRS{idVendor}=="1a86", ATTRS{idProduct}=="55d4",ATTRS{serial}=="0003", MODE:="0777", GROUP:="dialout", SYMLINK+="wheeltec_FDI_IMU_GNSS"' >/etc/udev/rules.d/wheeltec_fdi_imu_gnss2.rules -#CH9102,同时系统没有安装对应驱动 串口号0003 设置别名为wheeltec_FDI_IMU_GNSS -echo 'KERNEL=="ttyACM*", ATTRS{idVendor}=="1a86", ATTRS{idProduct}=="55d4",ATTRS{serial}=="0003", MODE:="0777", GROUP:="dialout", SYMLINK+="wheeltec_FDI_IMU_GNSS"' >/etc/udev/rules.d/wheeltec_fdi_imu_gnss3.rules - -echo 'SUBSYSTEM=="video4linux",ATTR{name}=="GENERAL WEBCAM",ATTR{index}=="0",MODE:="0777",SYMLINK+="RgbCam"' >>/etc/udev/rules.d/camera.rules -echo 'SUBSYSTEM=="video4linux",ATTR{name}=="GENERAL WEBCAM: GENERAL WEBCAM",ATTR{index}=="0",MODE:="0777",SYMLINK+="RgbCam"' >>/etc/udev/rules.d/camera.rules -echo 'SUBSYSTEM=="video4linux",ATTR{name}=="Astra Pro HD Camera: Astra Pro ",ATTR{index}=="0",MODE:="0777",SYMLINK+="Astra_Pro"' >>/etc/udev/rules.d/camera.rules -echo 'SUBSYSTEM=="video4linux",ATTR{name}=="USB 2.0 Camera: USB Camera",ATTR{index}=="0",MODE:="0777",SYMLINK+="Astra_Dabai"' >>/etc/udev/rules.d/camera.rules -echo 'SUBSYSTEM=="video4linux",ATTR{name}=="USB 2.0 Camera",ATTR{index}=="0",MODE:="0777",SYMLINK+="Astra_Gemini"' >>/etc/udev/rules.d/camera.rules -echo 'SUBSYSTEM=="video4linux",ATTR{name}=="Intel(R) RealSense(TM) Depth Ca",ATTR{index}=="0",MODE:="0777",SYMLINK+="realsense"' >>/etc/udev/rules.d/camera.rules - -service udev reload -sleep 2 -service udev restart - - diff --git a/src/LSLIDAR_X_ROS2-20240228/src/镭神Lsx雷达旋转角度.png b/src/LSLIDAR_X_ROS2-20240228/src/镭神Lsx雷达旋转角度.png deleted file mode 100644 index aa24785..0000000 Binary files a/src/LSLIDAR_X_ROS2-20240228/src/镭神Lsx雷达旋转角度.png and /dev/null differ diff --git a/src/LSLIDAR_X_ROS2-20240228/wheeltec_lidar.launch.py b/src/LSLIDAR_X_ROS2-20240228/wheeltec_lidar.launch.py deleted file mode 100644 index f38b80a..0000000 --- a/src/LSLIDAR_X_ROS2-20240228/wheeltec_lidar.launch.py +++ /dev/null @@ -1,62 +0,0 @@ -import os -from pathlib import Path -import launch_ros.actions -from ament_index_python.packages import get_package_share_directory -from launch import LaunchDescription -from launch.actions import (DeclareLaunchArgument, GroupAction, - IncludeLaunchDescription, SetEnvironmentVariable) -from launch.launch_description_sources import PythonLaunchDescriptionSource - -def generate_launch_description(): - Lslidar_dir = get_package_share_directory('lslidar_driver') - Lslidar_launch_dir = os.path.join(Lslidar_dir, 'launch') - - - Ld14_dir = get_package_share_directory('ldlidar_sl_ros2') - Ld14_launch_dir = os.path.join(Ld14_dir, 'launch') - - Ld06_dir = get_package_share_directory('ldlidar_stl_ros2') - Ld06_launch_dir = os.path.join(Ld14_dir, 'launch') - - - Lsm10_m10_uart = IncludeLaunchDescription( - PythonLaunchDescriptionSource(os.path.join(Lslidar_launch_dir, 'lsm10_uart_launch.py')),) - - Lsm10_m10_net = IncludeLaunchDescription( - PythonLaunchDescriptionSource(os.path.join(Lslidar_launch_dir, 'lsm10_net_launch.py')),) - - Lsm10_m10p_uart = IncludeLaunchDescription( - PythonLaunchDescriptionSource(os.path.join(Lslidar_launch_dir, 'lsm10p_uart_launch.py')),) - - Lsm10_m10p_net = IncludeLaunchDescription( - PythonLaunchDescriptionSource(os.path.join(Lslidar_launch_dir, 'lsm10p_net_launch.py')),) - - Lsn10 = IncludeLaunchDescription( - PythonLaunchDescriptionSource(os.path.join(Lslidar_launch_dir, 'lsn10_launch.py')),) - Lsn10p = IncludeLaunchDescription( - PythonLaunchDescriptionSource(os.path.join(Lslidar_launch_dir, 'lsn10p_launch.py')),) - - Lsn10_net = IncludeLaunchDescription( - PythonLaunchDescriptionSource(os.path.join(Lslidar_launch_dir, 'lsn10_net_launch.py')),) - Lsn10p_net = IncludeLaunchDescription( - PythonLaunchDescriptionSource(os.path.join(Lslidar_launch_dir, 'lsn10p_net_launch.py')),) - - Ld14 = IncludeLaunchDescription( - PythonLaunchDescriptionSource(os.path.join(Ld14_launch_dir, 'ld14.launch.py')),) - Ld06 = IncludeLaunchDescription( - PythonLaunchDescriptionSource(os.path.join(Ld06_launch_dir, 'ld06.launch.py')),) - - # Create the launch description and populate - ld = LaunchDescription() - ''' - Please select your lidar here, options include: - Lsm10_m10p_uart、Lsm10_m10p_net、Lsm10_m10_uart、Lsm10_m10_net、Lsn10、Lsn10p,Lsn10_net、Lsn10p_net,ld14、Ld06. - 1.If you are using LS* lidar (including lsn10, lsm10*), please don't forget to - modify the tf conversion parameters of robot_mode_description.launch.py - according to the user guide file. - 2.If you are using m10 lidar, please pay attention to distinguish whether it is m10p or not. - ''' - ld.add_action(Lsn10) - - return ld - diff --git a/src/LSLIDAR_X_ROS2-20240228/wheeltec_lidar.launch.py仅在WHEELTEC镜像中使用 b/src/LSLIDAR_X_ROS2-20240228/wheeltec_lidar.launch.py仅在WHEELTEC镜像中使用 deleted file mode 100644 index e69de29..0000000 diff --git a/src/cyy_navigation2/CMakeLists.txt b/src/cyy_navigation2/CMakeLists.txt deleted file mode 100644 index 884ac6a..0000000 --- a/src/cyy_navigation2/CMakeLists.txt +++ /dev/null @@ -1,29 +0,0 @@ -cmake_minimum_required(VERSION 3.8) -project(cyy_navigation2) - -if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") - add_compile_options(-Wall -Wextra -Wpedantic) -endif() - -# find dependencies -find_package(ament_cmake REQUIRED) -find_package(nav2_bringup REQUIRED) -install( - DIRECTORY launch param maps - DESTINATION share/${PROJECT_NAME} -) - -if(BUILD_TESTING) - find_package(ament_lint_auto REQUIRED) - # the following line skips the linter which checks for copyrights - # comment the line when a copyright and license is added to all source files - set(ament_cmake_copyright_FOUND TRUE) - # the following line skips cpplint (only works in a git repo) - # comment the line when this package is in a git repo and when - # a copyright and license is added to all source files - set(ament_cmake_cpplint_FOUND TRUE) - ament_lint_auto_find_test_dependencies() -endif() - -ament_package() - diff --git a/src/cyy_navigation2/bt/follow_point.xml b/src/cyy_navigation2/bt/follow_point.xml deleted file mode 100644 index ffae8d9..0000000 --- a/src/cyy_navigation2/bt/follow_point.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/src/cyy_navigation2/bt/nav_to_pose_with_consistent_replanning_and_if_path_becomes_invalid.xml b/src/cyy_navigation2/bt/nav_to_pose_with_consistent_replanning_and_if_path_becomes_invalid.xml deleted file mode 100644 index f4ed518..0000000 --- a/src/cyy_navigation2/bt/nav_to_pose_with_consistent_replanning_and_if_path_becomes_invalid.xml +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/cyy_navigation2/bt/navigate_through_poses_w_replanning_and_recovery.xml b/src/cyy_navigation2/bt/navigate_through_poses_w_replanning_and_recovery.xml deleted file mode 100644 index 1378863..0000000 --- a/src/cyy_navigation2/bt/navigate_through_poses_w_replanning_and_recovery.xml +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/cyy_navigation2/bt/navigate_to_pose_w_replanning_and_recovery.xml b/src/cyy_navigation2/bt/navigate_to_pose_w_replanning_and_recovery.xml deleted file mode 100644 index 2396b84..0000000 --- a/src/cyy_navigation2/bt/navigate_to_pose_w_replanning_and_recovery.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/cyy_navigation2/bt/navigate_to_pose_w_replanning_goal_patience_and_recovery.xml b/src/cyy_navigation2/bt/navigate_to_pose_w_replanning_goal_patience_and_recovery.xml deleted file mode 100644 index 6b5883b..0000000 --- a/src/cyy_navigation2/bt/navigate_to_pose_w_replanning_goal_patience_and_recovery.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/cyy_navigation2/bt/navigate_w_recovery_and_replanning_only_if_path_becomes_invalid.xml b/src/cyy_navigation2/bt/navigate_w_recovery_and_replanning_only_if_path_becomes_invalid.xml deleted file mode 100644 index d21efa3..0000000 --- a/src/cyy_navigation2/bt/navigate_w_recovery_and_replanning_only_if_path_becomes_invalid.xml +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/cyy_navigation2/bt/navigate_w_replanning_distance.xml b/src/cyy_navigation2/bt/navigate_w_replanning_distance.xml deleted file mode 100644 index 8ca5dbb..0000000 --- a/src/cyy_navigation2/bt/navigate_w_replanning_distance.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - diff --git a/src/cyy_navigation2/bt/navigate_w_replanning_only_if_goal_is_updated.xml b/src/cyy_navigation2/bt/navigate_w_replanning_only_if_goal_is_updated.xml deleted file mode 100644 index 3e88944..0000000 --- a/src/cyy_navigation2/bt/navigate_w_replanning_only_if_goal_is_updated.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - diff --git a/src/cyy_navigation2/bt/navigate_w_replanning_only_if_path_becomes_invalid.xml b/src/cyy_navigation2/bt/navigate_w_replanning_only_if_path_becomes_invalid.xml deleted file mode 100644 index e921db5..0000000 --- a/src/cyy_navigation2/bt/navigate_w_replanning_only_if_path_becomes_invalid.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/cyy_navigation2/bt/navigate_w_replanning_speed.xml b/src/cyy_navigation2/bt/navigate_w_replanning_speed.xml deleted file mode 100644 index f0f47c4..0000000 --- a/src/cyy_navigation2/bt/navigate_w_replanning_speed.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - diff --git a/src/cyy_navigation2/bt/navigate_w_replanning_time.xml b/src/cyy_navigation2/bt/navigate_w_replanning_time.xml deleted file mode 100644 index 33c2c41..0000000 --- a/src/cyy_navigation2/bt/navigate_w_replanning_time.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - diff --git a/src/cyy_navigation2/bt/odometry_calibration.xml b/src/cyy_navigation2/bt/odometry_calibration.xml deleted file mode 100644 index 49000e1..0000000 --- a/src/cyy_navigation2/bt/odometry_calibration.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/src/cyy_navigation2/config/nav2_params.yaml b/src/cyy_navigation2/config/nav2_params.yaml deleted file mode 100644 index 295058a..0000000 --- a/src/cyy_navigation2/config/nav2_params.yaml +++ /dev/null @@ -1,348 +0,0 @@ -amcl: - ros__parameters: - use_sim_time: True - alpha1: 0.5 - alpha2: 0.5 - alpha3: 0.5 - alpha4: 0.5 - alpha5: 0.5 - base_frame_id: "base_link" - beam_skip_distance: 0.5 - beam_skip_error_threshold: 0.9 - beam_skip_threshold: 0.3 - do_beamskip: true - global_frame_id: "map" - lambda_short: 0.1 - laser_likelihood_max_dist: 4.0 - laser_max_range: 100.0 - laser_min_range: -1.0 - laser_model_type: "likelihood_field" - max_beams: 120 - max_particles: 4000 - min_particles: 1000 - odom_frame_id: "odom" - pf_err: 0.01 - pf_z: 0.99 - recovery_alpha_fast: 0.0 - recovery_alpha_slow: 0.0 - resample_interval: 2 - robot_model_type: "nav2_amcl::DifferentialMotionModel" - save_pose_rate: 0.5 - sigma_hit: 0.2 - tf_broadcast: true - transform_tolerance: 1.0 - update_min_a: 0.2 - update_min_d: 0.25 - z_hit: 0.9 - z_max: 0.05 - z_rand: 0.1 - z_short: 0.05 - scan_topic: scan - -bt_navigator: - ros__parameters: - use_sim_time: True - global_frame: map - robot_base_frame: base_link - odom_topic: /odom - bt_loop_duration: 10 - default_server_timeout: 20 - wait_for_service_timeout: 1000 - # 'default_nav_through_poses_bt_xml' and 'default_nav_to_pose_bt_xml' are use defaults: - # nav2_bt_navigator/navigate_to_pose_w_replanning_and_recovery.xml - # nav2_bt_navigator/navigate_through_poses_w_replanning_and_recovery.xml - # They can be set here or via a RewrittenYaml remap from a parent launch file to Nav2. - plugin_lib_names: - - nav2_compute_path_to_pose_action_bt_node - - nav2_compute_path_through_poses_action_bt_node - - nav2_smooth_path_action_bt_node - - nav2_follow_path_action_bt_node - - nav2_spin_action_bt_node - - nav2_wait_action_bt_node - - nav2_assisted_teleop_action_bt_node - - nav2_back_up_action_bt_node - - nav2_drive_on_heading_bt_node - - nav2_clear_costmap_service_bt_node - - nav2_is_stuck_condition_bt_node - - nav2_goal_reached_condition_bt_node - - nav2_goal_updated_condition_bt_node - - nav2_globally_updated_goal_condition_bt_node - - nav2_is_path_valid_condition_bt_node - - nav2_initial_pose_received_condition_bt_node - - nav2_reinitialize_global_localization_service_bt_node - - nav2_rate_controller_bt_node - - nav2_distance_controller_bt_node - - nav2_speed_controller_bt_node - - nav2_truncate_path_action_bt_node - - nav2_truncate_path_local_action_bt_node - - nav2_goal_updater_node_bt_node - - nav2_recovery_node_bt_node - - nav2_pipeline_sequence_bt_node - - nav2_round_robin_node_bt_node - - nav2_transform_available_condition_bt_node - - nav2_time_expired_condition_bt_node - - nav2_path_expiring_timer_condition - - nav2_distance_traveled_condition_bt_node - - nav2_single_trigger_bt_node - - nav2_goal_updated_controller_bt_node - - nav2_is_battery_low_condition_bt_node - - nav2_navigate_through_poses_action_bt_node - - nav2_navigate_to_pose_action_bt_node - - nav2_remove_passed_goals_action_bt_node - - nav2_planner_selector_bt_node - - nav2_controller_selector_bt_node - - nav2_goal_checker_selector_bt_node - - nav2_controller_cancel_bt_node - - nav2_path_longer_on_approach_bt_node - - nav2_wait_cancel_bt_node - - nav2_spin_cancel_bt_node - - nav2_back_up_cancel_bt_node - - nav2_assisted_teleop_cancel_bt_node - - nav2_drive_on_heading_cancel_bt_node - - nav2_is_battery_charging_condition_bt_node - -bt_navigator_navigate_through_poses_rclcpp_node: - ros__parameters: - use_sim_time: True - -bt_navigator_navigate_to_pose_rclcpp_node: - ros__parameters: - use_sim_time: True - -controller_server: - ros__parameters: - use_sim_time: True - controller_frequency: 20.0 - min_x_velocity_threshold: 0.001 - min_y_velocity_threshold: 0.5 - min_theta_velocity_threshold: 0.001 - failure_tolerance: 0.3 - progress_checker_plugin: "progress_checker" - goal_checker_plugins: ["general_goal_checker"] # "precise_goal_checker" - controller_plugins: ["FollowPath"] - - # Progress checker parameters - progress_checker: - plugin: "nav2_controller::SimpleProgressChecker" - required_movement_radius: 0.5 - movement_time_allowance: 10.0 - # Goal checker parameters - #precise_goal_checker: - # plugin: "nav2_controller::SimpleGoalChecker" - # xy_goal_tolerance: 0.25 - # yaw_goal_tolerance: 0.25 - # stateful: True - general_goal_checker: - stateful: True - plugin: "nav2_controller::SimpleGoalChecker" - xy_goal_tolerance: 0.25 - yaw_goal_tolerance: 0.25 - # DWB parameters - FollowPath: - plugin: "dwb_core::DWBLocalPlanner" - debug_trajectory_details: True - min_vel_x: 0.0 - min_vel_y: 0.0 - max_vel_x: 0.50 - max_vel_y: 0.0 - max_vel_theta: 3.0 - min_speed_xy: 0.0 - max_speed_xy: 0.50 - min_speed_theta: 0.0 - # Add high threshold velocity for turtlebot 3 issue. - # https://github.com/ROBOTIS-GIT/turtlebot3_simulations/issues/75 - acc_lim_x: 2.5 - acc_lim_y: 0.0 - acc_lim_theta: 3.2 - decel_lim_x: -2.5 - decel_lim_y: 0.0 - decel_lim_theta: -3.2 - vx_samples: 20 - vy_samples: 5 - vtheta_samples: 20 - sim_time: 1.7 - linear_granularity: 0.05 - angular_granularity: 0.025 - transform_tolerance: 0.2 - xy_goal_tolerance: 0.25 - trans_stopped_velocity: 0.25 - short_circuit_trajectory_evaluation: True - stateful: True - critics: ["RotateToGoal", "Oscillation", "BaseObstacle", "GoalAlign", "PathAlign", "PathDist", "GoalDist"] - BaseObstacle.scale: 0.02 - PathAlign.scale: 32.0 - PathAlign.forward_point_distance: 0.1 - GoalAlign.scale: 24.0 - GoalAlign.forward_point_distance: 0.1 - PathDist.scale: 32.0 - GoalDist.scale: 24.0 - RotateToGoal.scale: 32.0 - RotateToGoal.slowing_factor: 5.0 - RotateToGoal.lookahead_time: -1.0 - -local_costmap: - local_costmap: - ros__parameters: - update_frequency: 5.0 - publish_frequency: 2.0 - global_frame: odom - robot_base_frame: base_link - use_sim_time: True - rolling_window: true - width: 3 - height: 3 - resolution: 0.05 - robot_radius: 0.20 - plugins: ["voxel_layer", "inflation_layer"] - inflation_layer: - plugin: "nav2_costmap_2d::InflationLayer" - cost_scaling_factor: 3.0 - inflation_radius: 0.30 - voxel_layer: - plugin: "nav2_costmap_2d::VoxelLayer" - enabled: True - publish_voxel_map: True - origin_z: 0.0 - z_resolution: 0.05 - z_voxels: 16 - max_obstacle_height: 2.0 - mark_threshold: 0 - observation_sources: scan - scan: - topic: /scan - max_obstacle_height: 2.0 - clearing: True - marking: True - data_type: "LaserScan" - raytrace_max_range: 3.0 - raytrace_min_range: 0.0 - obstacle_max_range: 2.5 - obstacle_min_range: 0.0 - static_layer: - plugin: "nav2_costmap_2d::StaticLayer" - map_subscribe_transient_local: True - always_send_full_costmap: True - -global_costmap: - global_costmap: - ros__parameters: - update_frequency: 1.0 - publish_frequency: 1.0 - global_frame: map - robot_base_frame: base_link - use_sim_time: True - robot_radius: 0.20 - resolution: 0.05 - track_unknown_space: true - plugins: ["static_layer", "obstacle_layer", "inflation_layer"] - obstacle_layer: - plugin: "nav2_costmap_2d::ObstacleLayer" - enabled: True - observation_sources: scan - scan: - topic: /scan - max_obstacle_height: 2.0 - clearing: True - marking: True - data_type: "LaserScan" - raytrace_max_range: 3.0 - raytrace_min_range: 0.0 - obstacle_max_range: 2.5 - obstacle_min_range: 0.0 - static_layer: - plugin: "nav2_costmap_2d::StaticLayer" - map_subscribe_transient_local: True - inflation_layer: - plugin: "nav2_costmap_2d::InflationLayer" - cost_scaling_factor: 3.0 - inflation_radius: 0.30 - always_send_full_costmap: True - -map_server: - ros__parameters: - use_sim_time: True - # Overridden in launch by the "map" launch configuration or provided default value. - # To use in yaml, remove the default "map" value in the tb3_simulation_launch.py file & provide full path to map below. - yaml_filename: "" - -map_saver: - ros__parameters: - use_sim_time: True - save_map_timeout: 5.0 - free_thresh_default: 0.25 - occupied_thresh_default: 0.65 - map_subscribe_transient_local: True - -planner_server: - ros__parameters: - expected_planner_frequency: 20.0 - use_sim_time: True - planner_plugins: ["GridBased"] - GridBased: - plugin: "nav2_navfn_planner/NavfnPlanner" - tolerance: 0.5 - use_astar: false - allow_unknown: true - -smoother_server: - ros__parameters: - use_sim_time: True - smoother_plugins: ["simple_smoother"] - simple_smoother: - plugin: "nav2_smoother::SimpleSmoother" - tolerance: 1.0e-10 - max_its: 1000 - do_refinement: True - -behavior_server: - ros__parameters: - costmap_topic: local_costmap/costmap_raw - footprint_topic: local_costmap/published_footprint - cycle_frequency: 10.0 - behavior_plugins: ["backup", "drive_on_heading", "assisted_teleop", "wait"] - backup: - plugin: "nav2_behaviors/BackUp" - drive_on_heading: - plugin: "nav2_behaviors/DriveOnHeading" - wait: - plugin: "nav2_behaviors/Wait" - assisted_teleop: - plugin: "nav2_behaviors/AssistedTeleop" - global_frame: odom - robot_base_frame: base_link - transform_tolerance: 0.3 - use_sim_time: true - simulate_ahead_time: 2.0 - max_rotational_vel: 1.0 - min_rotational_vel: 0.4 - rotational_acc_lim: 3.2 - -robot_state_publisher: - ros__parameters: - use_sim_time: True - -waypoint_follower: - ros__parameters: - use_sim_time: True - loop_rate: 20 - stop_on_failure: false - waypoint_task_executor_plugin: "wait_at_waypoint" - wait_at_waypoint: - plugin: "nav2_waypoint_follower::WaitAtWaypoint" - enabled: True - waypoint_pause_duration: 200 - -velocity_smoother: - ros__parameters: - use_sim_time: True - smoothing_frequency: 20.0 - scale_velocities: False - feedback: "OPEN_LOOP" - max_velocity: [0.26, 0.0, 1.0] - min_velocity: [-0.26, 0.0, -1.0] - max_accel: [2.5, 0.0, 3.2] - max_decel: [-2.5, 0.0, -3.2] - odom_topic: "odom" - odom_duration: 0.1 - deadband_velocity: [0.0, 0.0, 0.0] - velocity_timeout: 1.0 diff --git a/src/cyy_navigation2/launch/car_bringup.launch.py b/src/cyy_navigation2/launch/car_bringup.launch.py deleted file mode 100644 index ebed688..0000000 --- a/src/cyy_navigation2/launch/car_bringup.launch.py +++ /dev/null @@ -1,108 +0,0 @@ -#!/usr/bin/env python3 -""" -小车导航系统启动文件 -启动所有必要的硬件和导航节点 -""" - -import os -from ament_index_python.packages import get_package_share_directory -from launch import LaunchDescription -from launch.actions import IncludeLaunchDescription, DeclareLaunchArgument, TimerAction, LogInfo -from launch.launch_description_sources import PythonLaunchDescriptionSource, FrontendLaunchDescriptionSource -from launch.substitutions import LaunchConfiguration, PathJoinSubstitution, PythonExpression -from launch_ros.actions import Node -from launch_ros.substitutions import FindPackageShare -from launch.conditions import IfCondition, UnlessCondition - -def generate_launch_description(): - # 获取包路径 - cyy_navigation2_dir = get_package_share_directory('cyy_navigation2') - - # 声明启动参数 - use_base = LaunchConfiguration('use_base', default='true') - use_lidar = LaunchConfiguration('use_lidar', default='true') - use_description = LaunchConfiguration('use_description', default='true') - use_bridge = LaunchConfiguration('use_bridge', default='true') - - # 启动参数列表 - launch_arguments = [ - DeclareLaunchArgument( - 'use_base', - default_value='true', - description='启动底盘控制' - ), - DeclareLaunchArgument( - 'use_lidar', - default_value='true', - description='启动激光雷达' - ), - DeclareLaunchArgument( - 'use_description', - default_value='true', - description='启动URDF显示' - ), - DeclareLaunchArgument( - 'use_bridge', - default_value='true', - description='启动ROS Bridge' - ), - ] - - # 创建启动描述 - ld = LaunchDescription(launch_arguments) - - # 1. 启动底盘控制 - base_launch = IncludeLaunchDescription( - PythonLaunchDescriptionSource([ - FindPackageShare('origincar_base'), '/launch/base_serial.launch.py' - ]), - condition=IfCondition(use_base) - ) - - # 添加延迟,确保底盘先启动 - ld.add_action(TimerAction( - period=1.0, - actions=[LogInfo(msg='启动底盘控制...'), base_launch] - )) - - # 2. 启动激光雷达 - lidar_launch = IncludeLaunchDescription( - PythonLaunchDescriptionSource([ - FindPackageShare('lslidar_driver'), '/launch/lsn10_launch.py' - ]), - condition=IfCondition(use_lidar) - ) - - ld.add_action(TimerAction( - period=2.0, - actions=[LogInfo(msg='启动激光雷达...'), lidar_launch] - )) - - # 3. 启动URDF显示 - description_launch = IncludeLaunchDescription( - PythonLaunchDescriptionSource([ - FindPackageShare('origincar_description'), '/launch/display.launch.py' - ]), - condition=IfCondition(use_description) - ) - - ld.add_action(TimerAction( - period=3.0, - actions=[LogInfo(msg='启动URDF显示...'), description_launch] - )) - - # 4. 启动ROS Bridge - bridge_launch = IncludeLaunchDescription( - FrontendLaunchDescriptionSource([ - FindPackageShare('rosbridge_server'), '/launch/rosbridge_websocket_launch.xml' - ]), - condition=IfCondition(use_bridge) - ) - - ld.add_action(TimerAction( - period=4.0, - actions=[LogInfo(msg='启动ROS Bridge...'), bridge_launch] - )) - - - return ld diff --git a/src/cyy_navigation2/launch/cyy_nav.launch.py b/src/cyy_navigation2/launch/cyy_nav.launch.py deleted file mode 100644 index 26f4de1..0000000 --- a/src/cyy_navigation2/launch/cyy_nav.launch.py +++ /dev/null @@ -1,41 +0,0 @@ -import os -from ament_index_python.packages import get_package_share_directory -from launch import LaunchDescription -from launch.actions import IncludeLaunchDescription -from launch.launch_description_sources import PythonLaunchDescriptionSource -from launch.substitutions import LaunchConfiguration -from launch_ros.actions import Node - - -def generate_launch_description(): - # =============================1.λĵַ============================================================= - cyy_navigation2_dir = get_package_share_directory('cyy_navigation2') - nav2_bringup_dir = get_package_share_directory('nav2_bringup') - slam = LaunchConfiguration('slam', default='True') - # =============================2.ȡļ·=================================================== - # use_sim_time Ҫótrue,ΪgazeboǷ滷ʱͨ/clockȡϵͳʱ - use_sim_time = LaunchConfiguration('use_sim_time', default='false') - map_yaml_path = LaunchConfiguration('map', - default=os.path.join(cyy_navigation2_dir, 'maps', 'cyy_map1.yaml')) - nav2_param_path = LaunchConfiguration('params_file', - default=os.path.join(cyy_navigation2_dir, 'param', 'nav2_params.yaml')) - rviz_config_dir = os.path.join(nav2_bringup_dir, 'rviz', 'nav2_default_view.rviz') - - # =============================3.launchļ룺ͼ·Ƿʹ÷ʱԼnav2ļ============== - nav2_bringup_launch = IncludeLaunchDescription( - PythonLaunchDescriptionSource([nav2_bringup_dir, '/launch', '/bringup_launch.py']), - launch_arguments={ - 'map': map_yaml_path, - 'use_sim_time': use_sim_time, - 'params_file': nav2_param_path, - 'slam': slam}.items(), - ) - rviz_node = Node( - package='rviz2', - executable='rviz2', - name='rviz2', - arguments=['-d', rviz_config_dir], - parameters=[{'use_sim_time': use_sim_time}], - output='screen') - - return LaunchDescription([nav2_bringup_launch]) \ No newline at end of file diff --git a/src/cyy_navigation2/launch/cyy_nav_box.launch.py b/src/cyy_navigation2/launch/cyy_nav_box.launch.py deleted file mode 100644 index c6fd3f2..0000000 --- a/src/cyy_navigation2/launch/cyy_nav_box.launch.py +++ /dev/null @@ -1,86 +0,0 @@ -import os -from ament_index_python.packages import get_package_share_directory -from launch import LaunchDescription -from launch.actions import IncludeLaunchDescription, DeclareLaunchArgument -from launch.launch_description_sources import PythonLaunchDescriptionSource -from launch.substitutions import LaunchConfiguration -from launch_ros.actions import Node - -def generate_launch_description(): - # 获取包路径 - cyy_navigation2_dir = get_package_share_directory('cyy_navigation2') - nav2_bringup_dir = get_package_share_directory('nav2_bringup') - - # 声明参数 - use_sim_time = LaunchConfiguration('use_sim_time', default='False') - slam = LaunchConfiguration('slam', default='False') - localization = LaunchConfiguration('localization', default='False') - - # 定义文件路径 - map_yaml_path = os.path.join(cyy_navigation2_dir, 'maps', 'cyy_map.yaml') - nav2_param_path = os.path.join(cyy_navigation2_dir, 'param', 'nav2_params.yaml') - slam_params_file = os.path.join(cyy_navigation2_dir, 'param', 'slam_toolbox_localization.yaml') - - # 定义地图基础路径(用于 .posegraph 文件) - map_base_path = os.path.join(cyy_navigation2_dir, 'maps', 'cyy_map') - - # 检查 .posegraph 文件是否存在 - posegraph_path = map_base_path + '.posegraph' - if not os.path.exists(posegraph_path): - print(f"警告: .posegraph 文件不存在: {posegraph_path}") - print("将使用 AMCL 替代") - use_slam_toolbox = False - else: - use_slam_toolbox = True - print(f"找到 .posegraph 文件: {posegraph_path}") - - # 创建启动描述 - ld = LaunchDescription([ - DeclareLaunchArgument('use_sim_time', default_value='False'), - DeclareLaunchArgument('slam', default_value='False'), - DeclareLaunchArgument('localization', default_value='False'), - ]) - - # 如果使用 slam_toolbox - if use_slam_toolbox: - slam_toolbox_node = Node( - package='slam_toolbox', - executable='localization_slam_toolbox_node', - name='slam_toolbox', - output='screen', - parameters=[ - slam_params_file, - {'use_sim_time': use_sim_time}, - {'map_file_name': map_base_path}, - {'map_start_pose': [0.0, 0.0, 0.0]} - ], - remappings=[('/scan', '/scan')] - ) - ld.add_action(slam_toolbox_node) - # 使用 slam_toolbox 时,Nav2 不启用定位 - localization_arg = 'False' - else: - # 使用 AMCL - localization_arg = 'True' - - # Nav2 启动 - 使用正确的路径 - nav2_launch_path = os.path.join(nav2_bringup_dir, 'launch', 'bringup_launch.py') - if not os.path.exists(nav2_launch_path): - print(f"错误: 找不到 Nav2 启动文件: {nav2_launch_path}") - return ld - - nav2_bringup_launch = IncludeLaunchDescription( - PythonLaunchDescriptionSource(nav2_launch_path), - launch_arguments={ - 'map': map_yaml_path, - 'use_sim_time': use_sim_time, - 'params_file': nav2_param_path, - 'slam': slam, - 'localization': localization_arg, - 'autostart': 'True', - }.items(), - ) - - ld.add_action(nav2_bringup_launch) - - return ld \ No newline at end of file diff --git a/src/cyy_navigation2/maps/cyy_map.data b/src/cyy_navigation2/maps/cyy_map.data deleted file mode 100644 index f1ee3aa..0000000 Binary files a/src/cyy_navigation2/maps/cyy_map.data and /dev/null differ diff --git a/src/cyy_navigation2/maps/cyy_map.pgm b/src/cyy_navigation2/maps/cyy_map.pgm deleted file mode 100644 index 294e35a..0000000 Binary files a/src/cyy_navigation2/maps/cyy_map.pgm and /dev/null differ diff --git a/src/cyy_navigation2/maps/cyy_map.yaml b/src/cyy_navigation2/maps/cyy_map.yaml deleted file mode 100644 index 8d57c8b..0000000 --- a/src/cyy_navigation2/maps/cyy_map.yaml +++ /dev/null @@ -1,7 +0,0 @@ -image: cyy_map.pgm -mode: trinary -resolution: 0.01 -origin: [-2.27, -1.63, 0] -negate: 0 -occupied_thresh: 0.65 -free_thresh: 0.25 \ No newline at end of file diff --git a/src/cyy_navigation2/maps/cyy_map1.pgm b/src/cyy_navigation2/maps/cyy_map1.pgm deleted file mode 100644 index c1da83d..0000000 Binary files a/src/cyy_navigation2/maps/cyy_map1.pgm and /dev/null differ diff --git a/src/cyy_navigation2/maps/cyy_map1.yaml b/src/cyy_navigation2/maps/cyy_map1.yaml deleted file mode 100644 index 097f099..0000000 --- a/src/cyy_navigation2/maps/cyy_map1.yaml +++ /dev/null @@ -1,7 +0,0 @@ -image: cyy_map1.pgm -mode: trinary -resolution: 0.01 -origin: [-3.49, -3.24, 0] -negate: 0 -occupied_thresh: 0.65 -free_thresh: 0.25 \ No newline at end of file diff --git a/src/cyy_navigation2/package.xml b/src/cyy_navigation2/package.xml deleted file mode 100644 index 8d7370f..0000000 --- a/src/cyy_navigation2/package.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - cyy_navigation2 - 0.0.0 - TODO: Package description - root - TODO: License declaration - - ament_cmake - - nav2_bringup - - ament_lint_auto - ament_lint_common - - - ament_cmake - - diff --git a/src/cyy_navigation2/param/nav2_params.yaml b/src/cyy_navigation2/param/nav2_params.yaml deleted file mode 100644 index 02c388c..0000000 --- a/src/cyy_navigation2/param/nav2_params.yaml +++ /dev/null @@ -1,353 +0,0 @@ -amcl: - ros__parameters: - enabled: False - use_sim_time: True - alpha1: 0.2 - alpha2: 0.2 - alpha3: 0.2 - alpha4: 0.2 - alpha5: 0.2 - base_frame_id: "base_link" - beam_skip_distance: 0.5 - beam_skip_error_threshold: 0.9 - beam_skip_threshold: 0.3 - do_beamskip: false - global_frame_id: "map" - lambda_short: 0.1 - laser_likelihood_max_dist: 2.0 - laser_max_range: 100.0 - laser_min_range: -1.0 - laser_model_type: "likelihood_field" - max_beams: 60 - max_particles: 2000 - min_particles: 500 - odom_frame_id: "odom" - pf_err: 0.05 - pf_z: 0.99 - recovery_alpha_fast: 0.0 - recovery_alpha_slow: 0.0 - resample_interval: 1 - robot_model_type: "nav2_amcl::DifferentialMotionModel" - save_pose_rate: 0.5 - sigma_hit: 0.2 - tf_broadcast: true - transform_tolerance: 1.0 - update_min_a: 0.2 - update_min_d: 0.25 - z_hit: 0.5 - z_max: 0.05 - z_rand: 0.5 - z_short: 0.05 - scan_topic: scan - -bt_navigator: - ros__parameters: - use_sim_time: True - global_frame: map - robot_base_frame: base_link - odom_topic: /odom - bt_loop_duration: 10 - default_server_timeout: 20 - wait_for_service_timeout: 1000 - # 'default_nav_through_poses_bt_xml' and 'default_nav_to_pose_bt_xml' are use defaults: - # nav2_bt_navigator/navigate_to_pose_w_replanning_and_recovery.xml - # nav2_bt_navigator/navigate_through_poses_w_replanning_and_recovery.xml - # They can be set here or via a RewrittenYaml remap from a parent launch file to Nav2. - plugin_lib_names: - - nav2_compute_path_to_pose_action_bt_node - - nav2_compute_path_through_poses_action_bt_node - - nav2_smooth_path_action_bt_node - - nav2_follow_path_action_bt_node - - nav2_spin_action_bt_node - - nav2_wait_action_bt_node - - nav2_assisted_teleop_action_bt_node - - nav2_back_up_action_bt_node - - nav2_drive_on_heading_bt_node - - nav2_clear_costmap_service_bt_node - - nav2_is_stuck_condition_bt_node - - nav2_goal_reached_condition_bt_node - - nav2_goal_updated_condition_bt_node - - nav2_globally_updated_goal_condition_bt_node - - nav2_is_path_valid_condition_bt_node - - nav2_initial_pose_received_condition_bt_node - - nav2_reinitialize_global_localization_service_bt_node - - nav2_rate_controller_bt_node - - nav2_distance_controller_bt_node - - nav2_speed_controller_bt_node - - nav2_truncate_path_action_bt_node - - nav2_truncate_path_local_action_bt_node - - nav2_goal_updater_node_bt_node - - nav2_recovery_node_bt_node - - nav2_pipeline_sequence_bt_node - - nav2_round_robin_node_bt_node - - nav2_transform_available_condition_bt_node - - nav2_time_expired_condition_bt_node - - nav2_path_expiring_timer_condition - - nav2_distance_traveled_condition_bt_node - - nav2_single_trigger_bt_node - - nav2_goal_updated_controller_bt_node - - nav2_is_battery_low_condition_bt_node - - nav2_navigate_through_poses_action_bt_node - - nav2_navigate_to_pose_action_bt_node - - nav2_remove_passed_goals_action_bt_node - - nav2_planner_selector_bt_node - - nav2_controller_selector_bt_node - - nav2_goal_checker_selector_bt_node - - nav2_controller_cancel_bt_node - - nav2_path_longer_on_approach_bt_node - - nav2_wait_cancel_bt_node - - nav2_spin_cancel_bt_node - - nav2_back_up_cancel_bt_node - - nav2_assisted_teleop_cancel_bt_node - - nav2_drive_on_heading_cancel_bt_node - - nav2_is_battery_charging_condition_bt_node - -bt_navigator_navigate_through_poses_rclcpp_node: - ros__parameters: - use_sim_time: True - -bt_navigator_navigate_to_pose_rclcpp_node: - ros__parameters: - use_sim_time: True - -controller_server: - ros__parameters: - use_sim_time: True - controller_frequency: 20.0 - min_x_velocity_threshold: 0.001 - min_y_velocity_threshold: 0.5 - min_theta_velocity_threshold: 0.001 - failure_tolerance: 0.3 - progress_checker_plugin: "progress_checker" - goal_checker_plugins: ["general_goal_checker"] # "precise_goal_checker" - controller_plugins: ["FollowPath"] - - # Progress checker parameters - progress_checker: - plugin: "nav2_controller::SimpleProgressChecker" - required_movement_radius: 0.5 - movement_time_allowance: 10.0 - # Goal checker parameters - #precise_goal_checker: - # plugin: "nav2_controller::SimpleGoalChecker" - # xy_goal_tolerance: 0.25 - # yaw_goal_tolerance: 0.25 - # stateful: True - general_goal_checker: - stateful: True - plugin: "nav2_controller::SimpleGoalChecker" - xy_goal_tolerance: 0.25 - yaw_goal_tolerance: 6.28 - # DWB parameters - FollowPath: - plugin: "dwb_core::DWBLocalPlanner" - debug_trajectory_details: True - min_vel_x: -0.50 - min_vel_y: 0.0 - max_vel_x: 0.50 - max_vel_y: 0.0 - max_vel_theta: 1.0 - min_speed_xy: 0.0 - max_speed_xy: 0.50 - min_speed_theta: 0.0 - # Add high threshold velocity for turtlebot 3 issue. - # https://github.com/ROBOTIS-GIT/turtlebot3_simulations/issues/75 - acc_lim_x: 2.5 - acc_lim_y: 0.0 - acc_lim_theta: 3.2 - decel_lim_x: -2.5 - decel_lim_y: 0.0 - decel_lim_theta: -3.2 - vx_samples: 20 - vy_samples: 0 - vtheta_samples: 20 - sim_time: 1.7 - linear_granularity: 0.05 - angular_granularity: 0.025 - transform_tolerance: 0.2 - xy_goal_tolerance: 0.25 - trans_stopped_velocity: 0.25 - short_circuit_trajectory_evaluation: True - stateful: True - critics: ["RotateToGoal", "Oscillation", "BaseObstacle", "GoalAlign", "PathAlign", "PathDist", "GoalDist"] - BaseObstacle.scale: 0.01 - PathAlign.scale: 32.0 - PathAlign.forward_point_distance: 0.1 - GoalAlign.scale: 24.0 - GoalAlign.forward_point_distance: 0.1 - PathDist.scale: 32.0 - GoalDist.scale: 24.0 - RotateToGoal.scale: 32.0 - RotateToGoal.slowing_factor: 5.0 - RotateToGoal.lookahead_time: -1.0 - -local_costmap: - local_costmap: - ros__parameters: - update_frequency: 5.0 - publish_frequency: 2.0 - global_frame: odom - robot_base_frame: base_link - use_sim_time: True - rolling_window: true - width: 3 - height: 3 - resolution: 0.05 - footprint: "[[0.2, 0.15], [0.2, -0.15], [-0.2, -0.15], [-0.2, 0.15]]" - robot_radius: 0.00 - plugins: ["voxel_layer", "inflation_layer"] - inflation_layer: - plugin: "nav2_costmap_2d::InflationLayer" - cost_scaling_factor: 3.0 - inflation_radius: 0.10 - voxel_layer: - plugin: "nav2_costmap_2d::VoxelLayer" - enabled: True - publish_voxel_map: True - origin_z: 0.0 - z_resolution: 0.05 - z_voxels: 16 - max_obstacle_height: 2.0 - mark_threshold: 0 - observation_sources: scan - scan: - topic: /scan - max_obstacle_height: 2.0 - clearing: True - marking: True - data_type: "LaserScan" - raytrace_max_range: 3.0 - raytrace_min_range: 0.0 - obstacle_max_range: 2.5 - obstacle_min_range: 0.0 - static_layer: - plugin: "nav2_costmap_2d::StaticLayer" - map_subscribe_transient_local: True - always_send_full_costmap: True - -global_costmap: - global_costmap: - ros__parameters: - update_frequency: 1.0 - publish_frequency: 1.0 - global_frame: map - robot_base_frame: base_link - use_sim_time: True - footprint: "[[0.2, 0.15], [0.2, -0.15], [-0.2, -0.15], [-0.2, 0.15]]" - robot_radius: 0.0 - resolution: 0.05 - track_unknown_space: true - plugins: ["static_layer", "obstacle_layer", "inflation_layer"] - obstacle_layer: - plugin: "nav2_costmap_2d::ObstacleLayer" - enabled: True - observation_sources: scan - scan: - topic: /scan - max_obstacle_height: 2.0 - clearing: True - marking: True - data_type: "LaserScan" - raytrace_max_range: 3.0 - raytrace_min_range: 0.0 - obstacle_max_range: 2.5 - obstacle_min_range: 0.0 - static_layer: - plugin: "nav2_costmap_2d::StaticLayer" - map_subscribe_transient_local: True - inflation_layer: - plugin: "nav2_costmap_2d::InflationLayer" - cost_scaling_factor: 3.0 - inflation_radius: 0.30 - always_send_full_costmap: True - -map_server: - ros__parameters: - use_sim_time: True - # Overridden in launch by the "map" launch configuration or provided default value. - # To use in yaml, remove the default "map" value in the tb3_simulation_launch.py file & provide full path to map below. - yaml_filename: "" - -map_saver: - ros__parameters: - use_sim_time: True - save_map_timeout: 5.0 - free_thresh_default: 0.25 - occupied_thresh_default: 0.65 - map_subscribe_transient_local: True - -planner_server: - ros__parameters: - expected_planner_frequency: 20.0 - use_sim_time: True - planner_plugins: ["GridBased"] - GridBased: - plugin: "nav2_navfn_planner/NavfnPlanner" - tolerance: 0.5 - use_astar: false - allow_unknown: true - -smoother_server: - ros__parameters: - use_sim_time: True - smoother_plugins: ["simple_smoother"] - simple_smoother: - plugin: "nav2_smoother::SimpleSmoother" - tolerance: 1.0e-10 - max_its: 1000 - do_refinement: True - -behavior_server: - ros__parameters: - costmap_topic: local_costmap/costmap_raw - footprint_topic: local_costmap/published_footprint - cycle_frequency: 10.0 - behavior_plugins: ["spin", "backup", "drive_on_heading", "assisted_teleop", "wait"] - spin: - plugin: "nav2_behaviors/Spin" - backup: - plugin: "nav2_behaviors/BackUp" - drive_on_heading: - plugin: "nav2_behaviors/DriveOnHeading" - wait: - plugin: "nav2_behaviors/Wait" - assisted_teleop: - plugin: "nav2_behaviors/AssistedTeleop" - global_frame: odom - robot_base_frame: base_link - transform_tolerance: 0.3 - use_sim_time: true - simulate_ahead_time: 2.0 - max_rotational_vel: 1.0 - min_rotational_vel: 0.4 - rotational_acc_lim: 3.2 - -robot_state_publisher: - ros__parameters: - use_sim_time: True - -waypoint_follower: - ros__parameters: - use_sim_time: True - loop_rate: 20 - stop_on_failure: false - waypoint_task_executor_plugin: "wait_at_waypoint" - wait_at_waypoint: - plugin: "nav2_waypoint_follower::WaitAtWaypoint" - enabled: True - waypoint_pause_duration: 200 - -velocity_smoother: - ros__parameters: - use_sim_time: True - smoothing_frequency: 20.0 - scale_velocities: False - feedback: "OPEN_LOOP" - max_velocity: [0.26, 0.0, 1.0] - min_velocity: [-0.26, 0.0, -1.0] - max_accel: [2.5, 0.0, 3.2] - max_decel: [-2.5, 0.0, -3.2] - odom_topic: "odom" - odom_duration: 0.1 - deadband_velocity: [0.0, 0.0, 0.0] - velocity_timeout: 1.0 diff --git a/src/cyy_navigation2/param/slam_toolbox_localization.yaml b/src/cyy_navigation2/param/slam_toolbox_localization.yaml deleted file mode 100644 index cd751e1..0000000 --- a/src/cyy_navigation2/param/slam_toolbox_localization.yaml +++ /dev/null @@ -1,54 +0,0 @@ -slam_toolbox: - ros__parameters: - # 核心模式设置 - mode: "localization" # 重要:设置为定位模式 - map_file_name: "" # 由启动参数传入 - map_start_pose: [0.0, 0.0, 0.0] - # ROS框架设置 - odom_frame: "odom" - map_frame: "map" - base_frame: "base_link" - scan_topic: "/scan" - - # 求解器设置 - solver_plugin: "solver_plugins::CeresSolver" - ceres_linear_solver: "SPARSE_NORMAL_CHOLESKY" - ceres_preconditioner: "SCHUR_JACOBI" - ceres_trust_strategy: "LEVENBERG_MARQUARDT" - ceres_dogleg_type: "TRADITIONAL_DOGLEG" - ceres_loss_function: "None" - - # 定位优化参数 - use_scan_matching: true - use_scan_barycenter: true - minimum_travel_distance: 0.05 - minimum_travel_heading: 0.087 - - # 扫描处理 - scan_buffer_size: 20 - throttle_scans: 1 - - # 回环检测(定位模式可关闭) - do_loop_closing: false - - # 搜索参数 - link_match_minimum_response_fine: 0.2 - link_scan_maximum_distance: 2.0 - loop_search_maximum_distance: 5.0 - - # 性能参数 - minimum_time_interval: 0.1 - transform_publish_period: 0.02 - map_update_interval: 0.5 - - # 地图参数 - resolution: 0.05 - max_laser_range: 15.0 - min_laser_range: 0.2 - - # 初始位姿(可选,可以通过RViz设置) - # map_start_pose: [0.0, 0.0, 0.0] - - # 调试 - debug_logging: false - enable_interactive_mode: true \ No newline at end of file diff --git a/src/cyy_slamtoolbox/CMakeLists.txt b/src/cyy_slamtoolbox/CMakeLists.txt deleted file mode 100644 index 305da3e..0000000 --- a/src/cyy_slamtoolbox/CMakeLists.txt +++ /dev/null @@ -1,61 +0,0 @@ -# 设置CMake最低版本要求 -cmake_minimum_required(VERSION 3.8) -# 定义项目名称(应与package.xml中的一致) -project(cyy_slamtoolbox) - -# 如果未设置,默认使用C++17标准 -if(NOT CMAKE_CXX_STANDARD) - set(CMAKE_CXX_STANDARD 17) -endif() - -# 查找编译依赖 -find_package(ament_cmake REQUIRED) -# 查找slam_toolbox包 -find_package(slam_toolbox REQUIRED) -# 查找其他可能的依赖,如传感器消息、几何库等 -find_package(rclcpp REQUIRED) -find_package(std_msgs REQUIRED) -find_package(sensor_msgs REQUIRED) -find_package(nav_msgs REQUIRED) -find_package(tf2 REQUIRED) -find_package(tf2_ros REQUIRED) -find_package(geometry_msgs REQUIRED) - -# 消息输出,用于调试 -message(STATUS "开始配置项目: ${PROJECT_NAME}") - -# 包含头文件目录 -include_directories( - include - ${ament_INCLUDE_DIRS} -) - -# 如果有自定义的C++节点源文件,在此添加可执行文件 -# 例如,如果您有自定义的SLAM处理节点: -# add_executable(origincar_slam_node src/origincar_slam_node.cpp) -# ament_target_dependencies(origincar_slam_node -# rclcpp std_msgs sensor_msgs nav_msgs tf2 tf2_ros geometry_msgs slam_toolbox) -# -# 安装目标(将可执行文件安装到lib/) -# install(TARGETS origincar_slam_node -# DESTINATION lib/${PROJECT_NAME}) - -# 安装launch文件到share//launch目录 -install(DIRECTORY launch - DESTINATION share/${PROJECT_NAME} - PATTERN "*.py" -) - -# 安装配置文件(如YAML参数文件)到share//config目录 -install(DIRECTORY config - DESTINATION share/${PROJECT_NAME} - PATTERN "*.yaml" - PATTERN "*.yml" -) - - -# 声明ament包依赖关系(确保在package.xml中已声明这些依赖) -ament_export_dependencies(slam_toolbox rclcpp std_msgs sensor_msgs nav_msgs tf2 tf2_ros geometry_msgs) - -# 必须调用此函数来生成必要的CMake配置 -ament_package() \ No newline at end of file diff --git a/src/cyy_slamtoolbox/config/angular_filter_example.yaml b/src/cyy_slamtoolbox/config/angular_filter_example.yaml deleted file mode 100644 index 26ef078..0000000 --- a/src/cyy_slamtoolbox/config/angular_filter_example.yaml +++ /dev/null @@ -1,9 +0,0 @@ -scan_to_scan_filter_chain: - ros__parameters: - filter1: - name: angle - type: laser_filters/LaserScanAngularBoundsFilter - params: - lower_angle: -1.52 - upper_angle: 1.52 - \ No newline at end of file diff --git a/src/cyy_slamtoolbox/config/box_filter_example.yaml b/src/cyy_slamtoolbox/config/box_filter_example.yaml deleted file mode 100644 index ae63991..0000000 --- a/src/cyy_slamtoolbox/config/box_filter_example.yaml +++ /dev/null @@ -1,15 +0,0 @@ -scan_to_scan_filter_chain: - ros__parameters: - filter1: - name: box_filter - type: laser_filters/LaserScanBoxFilter - params: - box_frame: base_link - max_x: 0.5 - max_y: 0.5 - max_z: 0.5 - min_x: -0.5 - min_y: -0.5 - min_z: -0.5 - - invert: false # activate to remove all points outside of the box diff --git a/src/cyy_slamtoolbox/config/footprint_filter_example.yaml b/src/cyy_slamtoolbox/config/footprint_filter_example.yaml deleted file mode 100644 index aa3ae16..0000000 --- a/src/cyy_slamtoolbox/config/footprint_filter_example.yaml +++ /dev/null @@ -1,7 +0,0 @@ -scan_to_scan_filter_chain: - ros__parameters: - filter1: - name: footprint_filter - type: laser_filters/LaserScanFootprintFilter - params: - inscribed_radius: 0.325 diff --git a/src/cyy_slamtoolbox/config/intensity_filter_example.yaml b/src/cyy_slamtoolbox/config/intensity_filter_example.yaml deleted file mode 100644 index 05d0827..0000000 --- a/src/cyy_slamtoolbox/config/intensity_filter_example.yaml +++ /dev/null @@ -1,9 +0,0 @@ -scan_to_scan_filter_chain: - ros__parameters: - filter1: - name: intensity - type: laser_filters/LaserScanIntensityFilter - params: - lower_threshold: 8000. - upper_threshold: 100000. - disp_histogram: 0 diff --git a/src/cyy_slamtoolbox/config/laser_filter_config.yaml b/src/cyy_slamtoolbox/config/laser_filter_config.yaml deleted file mode 100644 index 05730e4..0000000 --- a/src/cyy_slamtoolbox/config/laser_filter_config.yaml +++ /dev/null @@ -1,19 +0,0 @@ -scan_filter_chain: - - name: angle_bounds - type: laser_filters/LaserScanAngularBoundsFilter - params: - # 示例:如果您只想处理前方180度的数据,可以设置为: - lower_angle: -1.57 # 约-90度 - upper_angle: 1.57 # 约90度 - - - name: range_filter - type: laser_filters/LaserScanRangeFilter - params: - # 过滤掉无效的距离值,这对于SLAM非常重要 - lower_threshold: 0.2 # 忽略小于0.2米的测量(如雷达自身的噪声) - upper_threshold: 20.0 # 忽略大于20.0米的测量(通常是不稳定的数据) - use_message_range_limits: false - - - name: interpolation - type: laser_filters/InterpolationFilter - # 此滤波器没有参数,它会自动对因过滤产生的无效值(如NaN)进行插值修复[1](@ref) \ No newline at end of file diff --git a/src/cyy_slamtoolbox/config/mapper_params_lifelong.yaml b/src/cyy_slamtoolbox/config/mapper_params_lifelong.yaml deleted file mode 100644 index fe39dc2..0000000 --- a/src/cyy_slamtoolbox/config/mapper_params_lifelong.yaml +++ /dev/null @@ -1,87 +0,0 @@ - -slam_toolbox: - ros__parameters: - - # Plugin params - solver_plugin: solver_plugins::CeresSolver - ceres_linear_solver: SPARSE_NORMAL_CHOLESKY - ceres_preconditioner: SCHUR_JACOBI - ceres_trust_strategy: LEVENBERG_MARQUARDT - ceres_dogleg_type: TRADITIONAL_DOGLEG - ceres_loss_function: None - - # ROS Parameters - odom_frame: odom - map_frame: map - base_frame: base_footprint - scan_topic: /scan - use_map_saver: true - mode: mapping - - # lifelong params - lifelong_search_use_tree: false - lifelong_minimum_score: 0.1 - lifelong_iou_match: 0.85 - lifelong_node_removal_score: 0.04 - lifelong_overlap_score_scale: 0.06 - lifelong_constraint_multiplier: 0.08 - lifelong_nearby_penalty: 0.001 - lifelong_candidates_scale: 0.03 - - # if you'd like to immediately start continuing a map at a given pose - # or at the dock, but they are mutually exclusive, if pose is given - # will use pose - #map_file_name: test_steve - #map_start_pose: [0.0, 0.0, 0.0] - #map_start_at_dock: true - - debug_logging: false - throttle_scans: 1 - transform_publish_period: 0.02 #if 0 never publishes odometry - map_update_interval: 5.0 - resolution: 0.05 - min_laser_range: 0.0 #for rastering images - max_laser_range: 20.0 #for rastering images - minimum_time_interval: 0.5 - transform_timeout: 0.2 - tf_buffer_duration: 10. - stack_size_to_use: 40000000 #// program needs a larger stack size to serialize large maps - - # General Parameters - use_scan_matching: true - use_scan_barycenter: true - minimum_travel_distance: 0.5 - minimum_travel_heading: 0.5 - scan_buffer_size: 10 - scan_buffer_maximum_scan_distance: 10.0 - link_match_minimum_response_fine: 0.1 - link_scan_maximum_distance: 1.5 - loop_search_maximum_distance: 3.0 - do_loop_closing: true - loop_match_minimum_chain_size: 10 - loop_match_maximum_variance_coarse: 3.0 - loop_match_minimum_response_coarse: 0.35 - loop_match_minimum_response_fine: 0.45 - - # Correlation Parameters - Correlation Parameters - correlation_search_space_dimension: 0.5 - correlation_search_space_resolution: 0.01 - correlation_search_space_smear_deviation: 0.1 - - # Correlation Parameters - Loop Closure Parameters - loop_search_space_dimension: 8.0 - loop_search_space_resolution: 0.05 - loop_search_space_smear_deviation: 0.03 - - # Scan Matcher Parameters - distance_variance_penalty: 0.5 - angle_variance_penalty: 1.0 - - fine_search_angle_offset: 0.00349 - coarse_search_angle_offset: 0.349 - coarse_angle_resolution: 0.0349 - minimum_angle_penalty: 0.9 - minimum_distance_penalty: 0.5 - use_response_expansion: true - min_pass_through: 2 - occupancy_threshold: 0.1 diff --git a/src/cyy_slamtoolbox/config/mapper_params_localization.yaml b/src/cyy_slamtoolbox/config/mapper_params_localization.yaml deleted file mode 100644 index 176f2e2..0000000 --- a/src/cyy_slamtoolbox/config/mapper_params_localization.yaml +++ /dev/null @@ -1,70 +0,0 @@ -slam_toolbox: - ros__parameters: - solver_plugin: solver_plugins::CeresSolver - ceres_linear_solver: SPARSE_NORMAL_CHOLESKY - ceres_preconditioner: SCHUR_JACOBI - ceres_trust_strategy: LEVENBERG_MARQUARDT - ceres_dogleg_type: TRADITIONAL_DOGLEG - ceres_loss_function: None - - # ROS Parameters - odom_frame: odom - map_frame: map - base_frame: base_link - scan_topic: /scan - mode: localization #localization - - # if you'd like to start localizing on bringup in a map and pose - #map_file_name: test_steve - #map_start_pose: [5.0, 1.0, 0.0] - - debug_logging: false - throttle_scans: 1 - transform_publish_period: 0.02 #if 0 never publishes odometry - map_update_interval: 5.0 - resolution: 0.05 - min_laser_range: 0.0 #for rastering images - max_laser_range: 20.0 #for rastering images - minimum_time_interval: 0.5 - transform_timeout: 0.2 - tf_buffer_duration: 30. - stack_size_to_use: 40000000 #// program needs a larger stack size to serialize large maps - - # General Parameters - use_scan_matching: true - use_scan_barycenter: true - minimum_travel_distance: 0.5 - minimum_travel_heading: 0.5 - scan_buffer_size: 3 - scan_buffer_maximum_scan_distance: 10.0 - link_match_minimum_response_fine: 0.1 - link_scan_maximum_distance: 1.5 - do_loop_closing: true - loop_match_minimum_chain_size: 3 - loop_match_maximum_variance_coarse: 3.0 - loop_match_minimum_response_coarse: 0.35 - loop_match_minimum_response_fine: 0.45 - - # Correlation Parameters - Correlation Parameters - correlation_search_space_dimension: 0.5 - correlation_search_space_resolution: 0.01 - correlation_search_space_smear_deviation: 0.1 - - # Correlation Parameters - Loop Closure Parameters - loop_search_space_dimension: 8.0 - loop_search_space_resolution: 0.05 - loop_search_space_smear_deviation: 0.03 - loop_search_maximum_distance: 3.0 - - # Scan Matcher Parameters - distance_variance_penalty: 0.5 - angle_variance_penalty: 1.0 - - fine_search_angle_offset: 0.00349 - coarse_search_angle_offset: 0.349 - coarse_angle_resolution: 0.0349 - minimum_angle_penalty: 0.9 - minimum_distance_penalty: 0.5 - use_response_expansion: true - min_pass_through: 2 - occupancy_threshold: 0.1 diff --git a/src/cyy_slamtoolbox/config/mapper_params_offline.yaml b/src/cyy_slamtoolbox/config/mapper_params_offline.yaml deleted file mode 100644 index d7d8587..0000000 --- a/src/cyy_slamtoolbox/config/mapper_params_offline.yaml +++ /dev/null @@ -1,69 +0,0 @@ -slam_toolbox: - ros__parameters: - - # Plugin params - solver_plugin: solver_plugins::CeresSolver - ceres_linear_solver: SPARSE_NORMAL_CHOLESKY - ceres_preconditioner: SCHUR_JACOBI - ceres_trust_strategy: LEVENBERG_MARQUARDT - ceres_dogleg_type: TRADITIONAL_DOGLEG - ceres_loss_function: None - - # ROS Parameters - odom_frame: odom - map_frame: map - base_frame: base_footprint - scan_topic: /scan - use_map_saver: true - mode: mapping #localization - debug_logging: false - throttle_scans: 1 - transform_publish_period: 0.02 #if 0 never publishes odometry - map_update_interval: 10.0 - resolution: 0.05 - min_laser_range: 0.0 #for rastering images - max_laser_range: 20.0 #for rastering images - minimum_time_interval: 0.5 - transform_timeout: 0.2 - tf_buffer_duration: 14400. - stack_size_to_use: 40000000 #// program needs a larger stack size to serialize large maps - enable_interactive_mode: true - - # General Parameters - use_scan_matching: true - use_scan_barycenter: true - minimum_travel_distance: 0.5 - minimum_travel_heading: 0.5 - scan_buffer_size: 10 - scan_buffer_maximum_scan_distance: 10.0 - link_match_minimum_response_fine: 0.1 - link_scan_maximum_distance: 1.5 - loop_search_maximum_distance: 3.0 - do_loop_closing: true - loop_match_minimum_chain_size: 10 - loop_match_maximum_variance_coarse: 3.0 - loop_match_minimum_response_coarse: 0.35 - loop_match_minimum_response_fine: 0.45 - - # Correlation Parameters - Correlation Parameters - correlation_search_space_dimension: 0.5 - correlation_search_space_resolution: 0.01 - correlation_search_space_smear_deviation: 0.1 - - # Correlation Parameters - Loop Closure Parameters - loop_search_space_dimension: 8.0 - loop_search_space_resolution: 0.05 - loop_search_space_smear_deviation: 0.03 - - # Scan Matcher Parameters - distance_variance_penalty: 0.5 - angle_variance_penalty: 1.0 - - fine_search_angle_offset: 0.00349 - coarse_search_angle_offset: 0.349 - coarse_angle_resolution: 0.0349 - minimum_angle_penalty: 0.9 - minimum_distance_penalty: 0.5 - use_response_expansion: true - min_pass_through: 2 - occupancy_threshold: 0.1 diff --git a/src/cyy_slamtoolbox/config/mapper_params_online_async.yaml b/src/cyy_slamtoolbox/config/mapper_params_online_async.yaml deleted file mode 100644 index 8a392d5..0000000 --- a/src/cyy_slamtoolbox/config/mapper_params_online_async.yaml +++ /dev/null @@ -1,78 +0,0 @@ -slam_toolbox: - ros__parameters: - - # Plugin params - solver_plugin: solver_plugins::CeresSolver - ceres_linear_solver: SPARSE_NORMAL_CHOLESKY - ceres_preconditioner: SCHUR_JACOBI - ceres_trust_strategy: LEVENBERG_MARQUARDT - ceres_dogleg_type: TRADITIONAL_DOGLEG - ceres_loss_function: None - - # ROS Parameters - odom_frame: odom - map_frame: map - base_frame: base_link - scan_topic: /scan - use_map_saver: true - mode: mapping #localization - samples: 440 - # if you'd like to immediately start continuing a map at a given pose - # or at the dock, but they are mutually exclusive, if pose is given - # will use pose - #map_file_name: test_steve - # map_start_pose: [0.0, 0.0, 0.0] - #map_start_at_dock: true - - debug_logging: false - throttle_scans: 5 - transform_publish_period: 0.02 #if 0 never publishes odometry - map_update_interval: 0.01 - resolution: 0.01 - min_laser_range: 0.21 #for rastering images - max_laser_range: 15.0 #for rastering images - minimum_time_interval: 0.1 - transform_timeout: 2.0 - tf_buffer_duration: 30. - stack_size_to_use: 40000000 #// program needs a larger stack size to serialize large maps - enable_interactive_mode: true - - # General Parameters - use_scan_matching: true - use_scan_barycenter: true - minimum_travel_distance: 0.2 - minimum_travel_heading: 0.2 - scan_buffer_size: 10 - samples: 440 - scan_buffer_maximum_scan_distance: 10.0 - link_match_minimum_response_fine: 0.1 - link_scan_maximum_distance: 1.5 - loop_search_maximum_distance: 3.0 - do_loop_closing: true - loop_match_minimum_chain_size: 10 - loop_match_maximum_variance_coarse: 3.0 - loop_match_minimum_response_coarse: 0.35 - loop_match_minimum_response_fine: 0.45 - - # Correlation Parameters - Correlation Parameters - correlation_search_space_dimension: 0.5 - correlation_search_space_resolution: 0.05 - correlation_search_space_smear_deviation: 0.1 - - # Correlation Parameters - Loop Closure Parameters - loop_search_space_dimension: 8.0 - loop_search_space_resolution: 0.05 - loop_search_space_smear_deviation: 0.03 - - # Scan Matcher Parameters - distance_variance_penalty: 0.5 - angle_variance_penalty: 1.0 - - fine_search_angle_offset: 0.00349 - coarse_search_angle_offset: 0.349 - coarse_angle_resolution: 0.0349 - minimum_angle_penalty: 0.9 - minimum_distance_penalty: 0.5 - use_response_expansion: true - min_pass_through: 2 - occupancy_threshold: 0.1 diff --git a/src/cyy_slamtoolbox/config/mapper_params_online_sync.yaml b/src/cyy_slamtoolbox/config/mapper_params_online_sync.yaml deleted file mode 100644 index 4ccc68c..0000000 --- a/src/cyy_slamtoolbox/config/mapper_params_online_sync.yaml +++ /dev/null @@ -1,77 +0,0 @@ -slam_toolbox: - ros__parameters: - - # Plugin params - solver_plugin: solver_plugins::CeresSolver - ceres_linear_solver: SPARSE_NORMAL_CHOLESKY - ceres_preconditioner: SCHUR_JACOBI - ceres_trust_strategy: LEVENBERG_MARQUARDT - ceres_dogleg_type: TRADITIONAL_DOGLEG - ceres_loss_function: None - - # ROS Parameters - odom_frame: odom - map_frame: map - base_frame: base_footprint - scan_topic: /scan - use_map_saver: true - mode: mapping #localization - - # if you'd like to immediately start continuing a map at a given pose - # or at the dock, but they are mutually exclusive, if pose is given - # will use pose - #map_file_name: test_steve - #map_start_pose: [0.0, 0.0, 0.0] - #map_start_at_dock: true - - debug_logging: false - throttle_scans: 1 - transform_publish_period: 0.02 #if 0 never publishes odometry - map_update_interval: 5.0 - resolution: 0.05 - min_laser_range: 0.0 #for rastering images - max_laser_range: 20.0 #for rastering images - minimum_time_interval: 0.5 - transform_timeout: 0.2 - tf_buffer_duration: 30. - stack_size_to_use: 40000000 #// program needs a larger stack size to serialize large maps - enable_interactive_mode: true - - # General Parameters - use_scan_matching: true - use_scan_barycenter: true - minimum_travel_distance: 0.5 - minimum_travel_heading: 0.5 - scan_buffer_size: 10 - scan_buffer_maximum_scan_distance: 10.0 - link_match_minimum_response_fine: 0.1 - link_scan_maximum_distance: 1.5 - loop_search_maximum_distance: 3.0 - do_loop_closing: true - loop_match_minimum_chain_size: 10 - loop_match_maximum_variance_coarse: 3.0 - loop_match_minimum_response_coarse: 0.35 - loop_match_minimum_response_fine: 0.45 - - # Correlation Parameters - Correlation Parameters - correlation_search_space_dimension: 0.5 - correlation_search_space_resolution: 0.01 - correlation_search_space_smear_deviation: 0.1 - - # Correlation Parameters - Loop Closure Parameters - loop_search_space_dimension: 8.0 - loop_search_space_resolution: 0.05 - loop_search_space_smear_deviation: 0.03 - - # Scan Matcher Parameters - distance_variance_penalty: 0.5 - angle_variance_penalty: 1.0 - - fine_search_angle_offset: 0.00349 - coarse_search_angle_offset: 0.349 - coarse_angle_resolution: 0.0349 - minimum_angle_penalty: 0.9 - minimum_distance_penalty: 0.5 - use_response_expansion: true - min_pass_through: 2 - occupancy_threshold: 0.1 diff --git a/src/cyy_slamtoolbox/config/mask_filter_example.yaml b/src/cyy_slamtoolbox/config/mask_filter_example.yaml deleted file mode 100644 index 17751d1..0000000 --- a/src/cyy_slamtoolbox/config/mask_filter_example.yaml +++ /dev/null @@ -1,16 +0,0 @@ -scan_to_scan_filter_chain: - ros__parameters: - filter1: - name: mask - type: laser_filters/LaserScanMaskFilter - params: - masks: - laser: - - 100. - - 101. - - 102. - - 103. - - 104. - - 1000. - - 1001. - - 1002. diff --git a/src/cyy_slamtoolbox/config/median_filter_example.yaml b/src/cyy_slamtoolbox/config/median_filter_example.yaml deleted file mode 100644 index ea6c447..0000000 --- a/src/cyy_slamtoolbox/config/median_filter_example.yaml +++ /dev/null @@ -1,20 +0,0 @@ -scan_to_scan_filter_chain: - ros__parameters: - filter1: - type: laser_filters/LaserArrayFilter - name: median - params: - range_filter_chain: - filter1: - name: median - type: filters/MultiChannelMedianFilterFloat - params: - number_of_observations: 5 - unused: 10 - intensity_filter_chain: - filter1: - name: median - type: filters/MultiChannelMedianFilterFloat - params: - number_of_observations: 5 - unused: 10 diff --git a/src/cyy_slamtoolbox/config/median_spatial_filter_example.yaml b/src/cyy_slamtoolbox/config/median_spatial_filter_example.yaml deleted file mode 100644 index bbe95e0..0000000 --- a/src/cyy_slamtoolbox/config/median_spatial_filter_example.yaml +++ /dev/null @@ -1,17 +0,0 @@ -scan_to_scan_filter_chain: - ros__parameters: - filter1: - name: median_spatial - type: laser_filters/LaserScanMedianSpatialFilter - params: - window_size: 31 - filter2: - name: median_filter - type: laser_filters/LaserArrayFilter - params: - range_filter_chain: - filter1: - name: median - type: filters/MultiChannelMedianFilterFloat - params: - number_of_observations: 3 \ No newline at end of file diff --git a/src/cyy_slamtoolbox/config/multiple_filters_example.yaml b/src/cyy_slamtoolbox/config/multiple_filters_example.yaml deleted file mode 100644 index e992449..0000000 --- a/src/cyy_slamtoolbox/config/multiple_filters_example.yaml +++ /dev/null @@ -1,42 +0,0 @@ -scan_to_scan_filter_chain: - ros__parameters: - filter1: - type: laser_filters/LaserArrayFilter - name: laser_median_5 - params: - range_filter_chain: - filter1: - name: median_5 - type: filters/MultiChannelMedianFilterFloat - params: - number_of_observations: 5 - unused: 10 - intensity_filter_chain: - filter2: - name: median_5 - type: filters/MultiChannelMedianFilterFloat - params: - number_of_observations: 5 - unused: 10 - filter2: - name: intensity - type: laser_filters/LaserScanIntensityFilter - params: - lower_threshold: 8000. - upper_threshold: 100000. - disp_histogram: 0 - filter3: - name: shadows - type: laser_filters/ScanShadowsFilter - params: - min_angle: 10. - max_angle: 170. - neighbors: 20 - window: 0 - filter4: - name: dark_shadows - type: laser_filters/LaserScanIntensityFilter - params: - lower_threshold: 100. - upper_threshold: 10000. - disp_histogram: 0 diff --git a/src/cyy_slamtoolbox/config/pass_through_example.yaml b/src/cyy_slamtoolbox/config/pass_through_example.yaml deleted file mode 100644 index e69de29..0000000 diff --git a/src/cyy_slamtoolbox/config/polygon_filter_example.yaml b/src/cyy_slamtoolbox/config/polygon_filter_example.yaml deleted file mode 100644 index 90bf7d9..0000000 --- a/src/cyy_slamtoolbox/config/polygon_filter_example.yaml +++ /dev/null @@ -1,10 +0,0 @@ -scan_to_scan_filter_chain: - ros__parameters: - filter1: - name: polygon_filter - type: laser_filters/LaserScanPolygonFilter - params: - polygon_frame: base_link - polygon: '[[0.0, 0.0], [0.1, 0.1], [0.1, 0.0], [0.0, -0.1]]' - invert: false - footprint_topic: base_footprint_exclude diff --git a/src/cyy_slamtoolbox/config/range_filter_example.yaml b/src/cyy_slamtoolbox/config/range_filter_example.yaml deleted file mode 100644 index 27869ed..0000000 --- a/src/cyy_slamtoolbox/config/range_filter_example.yaml +++ /dev/null @@ -1,11 +0,0 @@ -scan_to_scan_filter_chain: - ros__parameters: - filter1: - name: box_filter - type: laser_filters/LaserScanRangeFilter - params: - use_message_range_limits: false # if not specified defaults to false - lower_threshold: 0.5 # if not specified defaults to 0.0 - upper_threshold: 1.0 # if not specified defaults to 100000.0 - lower_replacement_value: -.inf # if not specified defaults to NaN - upper_replacement_value: .inf # if not specified defaults to NaN diff --git a/src/cyy_slamtoolbox/config/scan_blob_filter_example.yaml b/src/cyy_slamtoolbox/config/scan_blob_filter_example.yaml deleted file mode 100644 index eb9f4ab..0000000 --- a/src/cyy_slamtoolbox/config/scan_blob_filter_example.yaml +++ /dev/null @@ -1,8 +0,0 @@ -scan_to_scan_filter_chain: - ros__parameters: - filter1: - name: scan_blob_filter - type: laser_filters/ScanBlobFilter - params: - max_radius: 0.25 # maximum radius to be considered as blob object - min_points: 6 # min scan points to be considered as blob object diff --git a/src/cyy_slamtoolbox/config/sector_filter_example.yaml b/src/cyy_slamtoolbox/config/sector_filter_example.yaml deleted file mode 100644 index e278235..0000000 --- a/src/cyy_slamtoolbox/config/sector_filter_example.yaml +++ /dev/null @@ -1,12 +0,0 @@ -scan_to_scan_filter_chain: - ros__parameters: - filter1: - name: scan_filter - type: laser_filters/LaserScanSectorFilter - params: - angle_min: 2.54 # if not specified defaults to 0.0 - angle_max: -2.54 # if not specified defaults to 0.0 - range_min: 0.2 # if not specified defaults to 0.0 - range_max: 2.0 # if not specified defaults to 100000.0 - clear_inside: true # if not specified defaults to true - invert: false # (!clear_inside) if not specified defaults to false diff --git a/src/cyy_slamtoolbox/config/shadow_filter_example.yaml b/src/cyy_slamtoolbox/config/shadow_filter_example.yaml deleted file mode 100644 index 82504fe..0000000 --- a/src/cyy_slamtoolbox/config/shadow_filter_example.yaml +++ /dev/null @@ -1,18 +0,0 @@ -scan_to_scan_filter_chain: - ros__parameters: - filter1: - name: shadows - type: laser_filters/ScanShadowsFilter - params: - min_angle: 10. - max_angle: 170. - neighbors: 20 - window: 1 - filter2: - name: dark_shadows - type: laser_filters/LaserScanIntensityFilter - params: - lower_threshold: 100. - upper_threshold: 10000. - disp_histogram: 0 - diff --git a/src/cyy_slamtoolbox/config/slam_toolbox_default.rviz b/src/cyy_slamtoolbox/config/slam_toolbox_default.rviz deleted file mode 100644 index c079a07..0000000 --- a/src/cyy_slamtoolbox/config/slam_toolbox_default.rviz +++ /dev/null @@ -1,137 +0,0 @@ -Panels: - - Class: rviz_common/Displays - Help Height: 78 - Name: Displays - Property Tree Widget: - Expanded: - - /Global Options1 - - /Status1 - Splitter Ratio: 0.5 - Tree Height: 154 - - Class: rviz_common/Selection - Name: Selection - - Class: rviz_common/Tool Properties - Expanded: - - /2D Goal Pose1 - - /Publish Point1 - Name: Tool Properties - Splitter Ratio: 0.5886790156364441 - - Class: rviz_common/Views - Expanded: - - /Current View1 - Name: Views - Splitter Ratio: 0.5 - - Class: rviz_common/Time - Experimental: false - Name: Time - SyncMode: 0 - SyncSource: "" - - Class: slam_toolbox::SlamToolboxPlugin - Name: SlamToolboxPlugin -Visualization Manager: - Class: "" - Displays: - - Alpha: 0.5 - Cell Size: 1 - Class: rviz_default_plugins/Grid - Color: 160; 160; 164 - Enabled: true - Line Style: - Line Width: 0.029999999329447746 - Value: Lines - Name: Grid - Normal Cell Count: 0 - Offset: - X: 0 - Y: 0 - Z: 0 - Plane: XY - Plane Cell Count: 10 - Reference Frame: - Value: true - Enabled: true - Global Options: - Background Color: 48; 48; 48 - Fixed Frame: map - Frame Rate: 30 - Name: root - Tools: - - Class: rviz_default_plugins/Interact - Hide Inactive Objects: true - - Class: rviz_default_plugins/MoveCamera - - Class: rviz_default_plugins/Select - - Class: rviz_default_plugins/FocusCamera - - Class: rviz_default_plugins/Measure - Line color: 128; 128; 0 - - Class: rviz_default_plugins/SetInitialPose - Covariance x: 0.25 - Covariance y: 0.25 - Covariance yaw: 0.06853891909122467 - Topic: - Depth: 5 - Durability Policy: Volatile - History Policy: Keep Last - Reliability Policy: Reliable - Value: /initialpose - - Class: rviz_default_plugins/SetGoal - Topic: - Depth: 5 - Durability Policy: Volatile - History Policy: Keep Last - Reliability Policy: Reliable - Value: /goal_pose - - Class: rviz_default_plugins/PublishPoint - Single click: true - Topic: - Depth: 5 - Durability Policy: Volatile - History Policy: Keep Last - Reliability Policy: Reliable - Value: /clicked_point - Transformation: - Current: - Class: rviz_default_plugins/TF - Value: true - Views: - Current: - Class: rviz_default_plugins/Orbit - Distance: 10 - Enable Stereo Rendering: - Stereo Eye Separation: 0.05999999865889549 - Stereo Focal Distance: 1 - Swap Stereo Eyes: false - Value: false - Focal Point: - X: 0 - Y: 0 - Z: 0 - Focal Shape Fixed Size: true - Focal Shape Size: 0.05000000074505806 - Invert Z Axis: false - Name: Current View - Near Clip Distance: 0.009999999776482582 - Pitch: 0.785398006439209 - Target Frame: - Value: Orbit (rviz) - Yaw: 0.785398006439209 - Saved: ~ -Window Geometry: - Displays: - collapsed: false - Height: 846 - Hide Left Dock: false - Hide Right Dock: false - QMainWindow State: 000000ff00000000fd000000040000000000000217000002b0fc0200000009fb0000001200530065006c0065006300740069006f006e00000001e10000009b0000005c00fffffffb0000001e0054006f006f006c002000500072006f007000650072007400690065007302000001ed000001df00000185000000a3fb000000120056006900650077007300200054006f006f02000001df000002110000018500000122fb000000200054006f006f006c002000500072006f0070006500720074006900650073003203000002880000011d000002210000017afb000000100044006900730070006c006100790073010000003d00000125000000c900fffffffb0000002000730065006c0065006300740069006f006e00200062007500660066006500720200000138000000aa0000023a00000294fb00000014005700690064006500530074006500720065006f02000000e6000000d2000003ee0000030bfb0000000c004b0069006e0065006300740200000186000001060000030c00000261fb000000220053006c0061006d0054006f006f006c0062006f00780050006c007500670069006e0100000168000001850000018500ffffff000000010000010f000002b0fc0200000003fb0000001e0054006f006f006c002000500072006f00700065007200740069006500730100000041000000780000000000000000fb0000000a00560069006500770073010000003d000002b0000000a400fffffffb0000001200530065006c0065006300740069006f006e010000025a000000b200000000000000000000000200000490000000a9fc0100000001fb0000000a00560069006500770073030000004e00000080000002e10000019700000003000004b00000003efc0100000002fb0000000800540069006d00650100000000000004b0000002eb00fffffffb0000000800540069006d006501000000000000045000000000000000000000017e000002b000000004000000040000000800000008fc0000000100000002000000010000000a0054006f006f006c00730100000000ffffffff0000000000000000 - Selection: - collapsed: false - SlamToolboxPlugin: - collapsed: false - Time: - collapsed: false - Tool Properties: - collapsed: false - Views: - collapsed: false - Width: 1200 - X: 72 - Y: 60 diff --git a/src/cyy_slamtoolbox/config/speckle_filter_example.yaml b/src/cyy_slamtoolbox/config/speckle_filter_example.yaml deleted file mode 100644 index 6f8c6a7..0000000 --- a/src/cyy_slamtoolbox/config/speckle_filter_example.yaml +++ /dev/null @@ -1,19 +0,0 @@ -scan_filter_chain: -- name: speckle_filter - type: laser_filters/LaserScanSpeckleFilter - params: - # Select which filter type to use. - # 0: Range based filtering (distance between consecutive points) - # 1: Euclidean filtering based on radius outlier search - filter_type: 0 - - # Only ranges smaller than this range are taken into account - max_range: 2.0 - - # filter_type[0] (Distance): max distance between consecutive points - # filter_type[1] (RadiusOutlier): max distance between points - max_range_difference: 0.1 - - # filter_type[0] (Distance): Number of consecutive ranges that will be tested for max_distance - # filter_type[1] (RadiusOutlier): Minimum number of neighbors - filter_window: 2 diff --git a/src/cyy_slamtoolbox/launch/cyy_slam_toolbox_launch.launch.py b/src/cyy_slamtoolbox/launch/cyy_slam_toolbox_launch.launch.py deleted file mode 100644 index aa4ff01..0000000 --- a/src/cyy_slamtoolbox/launch/cyy_slam_toolbox_launch.launch.py +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env python3 -from launch import LaunchDescription -from launch_ros.actions import Node -from ament_index_python.packages import get_package_share_directory -import os - -def generate_launch_description(): - # 获取参数文件路径 - pkg_share = get_package_share_directory('cyy_slamtoolbox') - params_file = os.path.join(pkg_share, 'config', 'mapper_params_online_async.yaml') - - # 创建SLAM Toolbox节点 - slam_toolbox_node = Node( - package='slam_toolbox', - executable='async_slam_toolbox_node', # 或 sync_slam_toolbox_node - name='slam_toolbox', - output='screen', - parameters=[params_file] - ) - - - return LaunchDescription([ - slam_toolbox_node - ]) \ No newline at end of file diff --git a/src/cyy_slamtoolbox/launch/cyy_slam_toolbox_location.launch.py b/src/cyy_slamtoolbox/launch/cyy_slam_toolbox_location.launch.py deleted file mode 100644 index c8c784a..0000000 --- a/src/cyy_slamtoolbox/launch/cyy_slam_toolbox_location.launch.py +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env python3 -from launch import LaunchDescription -from launch_ros.actions import Node -from ament_index_python.packages import get_package_share_directory -import os - -def generate_launch_description(): - # ȡļ· - pkg_share = get_package_share_directory('cyy_slamtoolbox') - params_file = os.path.join(pkg_share, 'config', 'mapper_params_localization.yaml') - - # SLAM Toolboxڵ - slam_toolbox_node = Node( - package='slam_toolbox', - executable='localization_slam_toolbox_node', # sync_slam_toolbox_node - name='slam_toolbox', - output='screen', - parameters=[params_file] - ) - - - return LaunchDescription([ - slam_toolbox_node - ]) \ No newline at end of file diff --git a/src/cyy_slamtoolbox/launch/filter.launch.py b/src/cyy_slamtoolbox/launch/filter.launch.py deleted file mode 100644 index 19f7450..0000000 --- a/src/cyy_slamtoolbox/launch/filter.launch.py +++ /dev/null @@ -1,24 +0,0 @@ -from launch import LaunchDescription -from launch_ros.actions import Node -from ament_index_python.packages import get_package_share_directory -import os - -def generate_launch_description(): - # 假设配置文件路径,你需要根据实际情况修改 - config_path = os.path.join( - get_package_share_directory('cyy_slamtoolbox'), - 'config', - 'angular_filter_example.yaml' - ) - - laser_filter_node = Node( - package='laser_filters', - executable='scan_to_scan_filter_chain', - name='laser_filter', - output='screen', - parameters=[config_path], - # 重新映射话题:从/base_scan原始数据过滤后发布到/scan - remappings=[('scan', '/base_scan'), ('scan_filtered', '/scan')] - ) - - return LaunchDescription([laser_filter_node]) \ No newline at end of file diff --git a/src/cyy_slamtoolbox/package.xml b/src/cyy_slamtoolbox/package.xml deleted file mode 100644 index 18ae51b..0000000 --- a/src/cyy_slamtoolbox/package.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - cyy_slamtoolbox - 0.0.0 - TODO: Package description - root - TODO: License declaration - - ament_cmake - - ament_lint_auto - ament_lint_common - - - ament_cmake - - diff --git a/src/gc_navigation2_real/CMakeLists.txt b/src/gc_navigation2_real/CMakeLists.txt deleted file mode 100644 index 8a939d4..0000000 --- a/src/gc_navigation2_real/CMakeLists.txt +++ /dev/null @@ -1,23 +0,0 @@ -cmake_minimum_required(VERSION 3.8) -project(gc_navigation2_real) - -if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") - add_compile_options(-Wall -Wextra -Wpedantic) -endif() - -# find dependencies -find_package(ament_cmake REQUIRED) - -install( - DIRECTORY launch config params maps behavior_tree - DESTINATION share/${PROJECT_NAME} -) - -if(BUILD_TESTING) - find_package(ament_lint_auto REQUIRED) - set(ament_cmake_copyright_FOUND TRUE) - set(ament_cmake_cpplint_FOUND TRUE) - ament_lint_auto_find_test_dependencies() -endif() - -ament_package() diff --git a/src/gc_navigation2_real/behavior_tree/nav_to_pose_ackermann.xml b/src/gc_navigation2_real/behavior_tree/nav_to_pose_ackermann.xml deleted file mode 100644 index c3343f7..0000000 --- a/src/gc_navigation2_real/behavior_tree/nav_to_pose_ackermann.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/gc_navigation2_real/config/slam_toolbox_async_real.yaml b/src/gc_navigation2_real/config/slam_toolbox_async_real.yaml deleted file mode 100644 index 85b0e2a..0000000 --- a/src/gc_navigation2_real/config/slam_toolbox_async_real.yaml +++ /dev/null @@ -1,78 +0,0 @@ -slam_toolbox: - ros__parameters: - - # ============================ Solver 插件参数 ====================================== - solver_plugin: solver_plugins::CeresSolver - ceres_linear_solver: SPARSE_NORMAL_CHOLESKY - ceres_preconditioner: SCHUR_JACOBI - ceres_trust_strategy: LEVENBERG_MARQUARDT - ceres_dogleg_type: TRADITIONAL_DOGLEG - ceres_loss_function: None - - # ============================ ROS 基础参数(实车)=================================== - odom_frame: odom_combined # 实车:EKF 融合后的里程计坐标系 - map_frame: map # 地图坐标系 - base_frame: base_footprint # 机器人基座坐标系(与 URDF 根帧一致) - scan_topic: /scan # 激光雷达话题(实车镭神雷达) - use_map_saver: true # 启用地图保存功能 - mode: mapping # mapping = 定位 + 实时建图 - - # ============================ 已有地图加载 ========================================== - # map_file_name: "" # 从零开始建图,留空 - map_start_pose: [0.0, 0.0, 0.0] # 初始位姿 [x, y, yaw] - - # ============================ 调试与性能 =========================================== - debug_logging: false - throttle_scans: 1 # 每 N 帧处理一次(实车每秒10帧左右) - transform_publish_period: 0.02 # TF 发布周期(秒) - map_update_interval: 3.0 # /map 话题更新间隔(秒) - resolution: 0.05 # 地图分辨率(米/像素) - restamp_tf: false - min_laser_range: 0.15 # 实车雷达盲区约 0.12m,设 0.15 过滤近处噪点 - max_laser_range: 12.0 # 实车雷达最大有效距离(镭神 N10 ≈ 10-15m) - minimum_time_interval: 0.3 # 最小处理时间间隔(实车可适当放宽) - transform_timeout: 0.2 # TF 查找超时 - tf_buffer_duration: 30.0 # TF 缓冲区时长 - stack_size_to_use: 40000000 # 栈大小(序列化大地图需要) - enable_interactive_mode: true # 交互模式:允许外部工具编辑地图 - - # ============================ 通用建图参数 ========================================= - use_scan_matching: true - use_scan_barycenter: true - minimum_travel_distance: 0.3 # 实车最小移动距离(米),小于仿真以更频繁更新 - minimum_travel_heading: 0.3 # 最小转向角度(弧度) - check_min_dist_and_heading_precisely: false - scan_buffer_size: 10 # 扫描缓冲区大小 - scan_buffer_maximum_scan_distance: 10.0 - link_match_minimum_response_fine: 0.1 - link_scan_maximum_distance: 1.5 - - # ============================ 回环检测参数 ========================================= - do_loop_closing: true # 启用回环检测 - loop_match_minimum_chain_size: 10 - loop_match_maximum_variance_coarse: 3.0 - loop_match_minimum_response_coarse: 0.35 - loop_match_minimum_response_fine: 0.45 - loop_search_maximum_distance: 3.0 - - # ============================ 相关性匹配参数 ======================================= - correlation_search_space_dimension: 0.5 - correlation_search_space_resolution: 0.01 - correlation_search_space_smear_deviation: 0.1 - - loop_search_space_dimension: 8.0 - loop_search_space_resolution: 0.05 - loop_search_space_smear_deviation: 0.03 - - # ============================ 扫描匹配器参数 ======================================== - distance_variance_penalty: 0.5 - angle_variance_penalty: 1.0 - - fine_search_angle_offset: 0.00349 - coarse_search_angle_offset: 0.349 - coarse_angle_resolution: 0.0349 - minimum_angle_penalty: 0.9 - minimum_distance_penalty: 0.5 - use_response_expansion: true - min_pass_through: 2 - occupancy_threshold: 0.1 diff --git a/src/gc_navigation2_real/config/slam_toolbox_localization_real.yaml b/src/gc_navigation2_real/config/slam_toolbox_localization_real.yaml deleted file mode 100644 index 7466496..0000000 --- a/src/gc_navigation2_real/config/slam_toolbox_localization_real.yaml +++ /dev/null @@ -1,77 +0,0 @@ -slam_toolbox: - ros__parameters: - - # ============================ Solver 插件参数 ====================================== - solver_plugin: solver_plugins::CeresSolver - ceres_linear_solver: SPARSE_NORMAL_CHOLESKY - ceres_preconditioner: SCHUR_JACOBI - ceres_trust_strategy: LEVENBERG_MARQUARDT - ceres_dogleg_type: TRADITIONAL_DOGLEG - ceres_loss_function: None - - # ============================ ROS 基础参数(实车定位模式)============================ - odom_frame: odom_combined # 实车:EKF 融合后的里程计坐标系 - map_frame: map - base_frame: base_footprint - scan_topic: /scan - mode: localization # 纯定位模式,不更新地图 - - # ============================ 已有地图加载 ========================================== - # 由 launch 文件通过 map_file_name 参数传入 .posegraph 路径 - # map_file_name: "" - map_start_pose: [0.0, 0.0, 0.0] - - # ============================ 调试与性能 =========================================== - debug_logging: false - throttle_scans: 2 # 每2帧处理一次(实车激光较慢时使用) - transform_publish_period: 0.02 - map_update_interval: 5.0 - resolution: 0.05 - restamp_tf: false - min_laser_range: 0.15 # 过滤雷达盲区噪点 - max_laser_range: 12.0 # 实车雷达最大有效距离 - minimum_time_interval: 0.3 - transform_timeout: 0.2 - tf_buffer_duration: 30.0 - stack_size_to_use: 40000000 - - # ============================ 通用参数 ============================================= - use_scan_matching: true - use_scan_barycenter: true - minimum_travel_distance: 0.3 - minimum_travel_heading: 0.3 - check_min_dist_and_heading_precisely: false - scan_buffer_size: 10 - scan_buffer_maximum_scan_distance: 10.0 - link_match_minimum_response_fine: 0.1 - link_scan_maximum_distance: 1.5 - - # 定位模式关闭回环检测 - do_loop_closing: false - loop_match_minimum_chain_size: 10 - loop_match_maximum_variance_coarse: 3.0 - loop_match_minimum_response_coarse: 0.35 - loop_match_minimum_response_fine: 0.45 - loop_search_maximum_distance: 3.0 - - # ============================ 相关性匹配参数 ======================================= - correlation_search_space_dimension: 0.5 - correlation_search_space_resolution: 0.01 - correlation_search_space_smear_deviation: 0.1 - - loop_search_space_dimension: 8.0 - loop_search_space_resolution: 0.05 - loop_search_space_smear_deviation: 0.03 - - # ============================ 扫描匹配器参数 ======================================== - distance_variance_penalty: 0.5 - angle_variance_penalty: 1.0 - - fine_search_angle_offset: 0.00349 - coarse_search_angle_offset: 0.349 - coarse_angle_resolution: 0.0349 - minimum_angle_penalty: 0.9 - minimum_distance_penalty: 0.5 - use_response_expansion: true - min_pass_through: 2 - occupancy_threshold: 0.1 diff --git a/src/gc_navigation2_real/launch/real_bringup.launch.py b/src/gc_navigation2_real/launch/real_bringup.launch.py deleted file mode 100644 index 096a166..0000000 --- a/src/gc_navigation2_real/launch/real_bringup.launch.py +++ /dev/null @@ -1,54 +0,0 @@ -#!/usr/bin/env python3 -# ============================================================================ -# real_bringup.launch.py -# 功能:实车基础 bringup — 底盘驱动 + 激光雷达 + TF 树 -# -# 适用场景: -# - 单独调试底盘通信和传感器数据 -# - 遥控测试(无导航) -# - 作为其他 launch 文件的基础模块 -# -# 启动内容: -# origincar_base bringup — 串口驱动 + EKF + IMU 滤波 + TF + robot_state_publisher -# lslidar_driver — 镭神激光雷达 → /scan -# -# 使用方式: -# ros2 launch gc_navigation2_real real_bringup.launch.py -# ============================================================================ - -from ament_index_python.packages import get_package_share_directory -from launch import LaunchDescription -from launch.actions import IncludeLaunchDescription, DeclareLaunchArgument -from launch.launch_description_sources import PythonLaunchDescriptionSource - - -def generate_launch_description(): - """生成 LaunchDescription,启动实车底盘 + 雷达 + TF(无导航)""" - - # ============================ 1. 包路径 ========================================= - origincar_base_dir = get_package_share_directory('origincar_base') - - # ============================ 2. 实车底盘 bringup =============================== - # 注:origincar_bringup 已包含 robot_state_publisher + joint_state_publisher + 静态 TF - origincar_bringup = IncludeLaunchDescription( - PythonLaunchDescriptionSource( - [origincar_base_dir, '/launch', '/origincar_bringup.launch.py']), - ) - - # ============================ 3. 镭神激光雷达驱动 =============================== - lslidar_launch = IncludeLaunchDescription( - PythonLaunchDescriptionSource( - [get_package_share_directory('lslidar_driver'), - '/launch', '/lsn10_launch.py']), - ) - - # ============================ 4. 组装 LaunchDescription ========================= - return LaunchDescription([ - DeclareLaunchArgument( - 'use_sim_time', - default_value='false', - description='使用仿真时间(实车必须为 false)'), - - origincar_bringup, - lslidar_launch, - ]) diff --git a/src/gc_navigation2_real/launch/real_nav2_slam.launch.py b/src/gc_navigation2_real/launch/real_nav2_slam.launch.py deleted file mode 100644 index c9cf7ab..0000000 --- a/src/gc_navigation2_real/launch/real_nav2_slam.launch.py +++ /dev/null @@ -1,110 +0,0 @@ -#!/usr/bin/env python3 -# ============================================================================ -# real_nav2_slam.launch.py -# 功能:实车导航 — 已知静态地图 + SLAM 定位 + Nav2 导航 -# -# 架构: -# origincar_base (bringup) — 底盘串口驱动 + EKF 里程计 + IMU 滤波 + TF -# lslidar_driver — 镭神激光雷达驱动 → /scan -# map_server — 加载 yaml+pgm 全量静态地图 → /map -# slam_toolbox (localization) — 加载 .posegraph,激光扫描匹配定位 -# 发布 map→odom_combined TF(替代 AMCL) -# ⚠️ /map 话题重映射为 /slam_map,避免冲突 -# navigation_launch — Nav2 导航栈 -# global_costmap 从 /map 获取全量静态地图 -# -# 使用方式: -# ros2 launch gc_navigation2_real real_nav2_slam.launch.py -# ============================================================================ - -import os -from ament_index_python.packages import get_package_share_directory -from launch import LaunchDescription -from launch.actions import IncludeLaunchDescription, DeclareLaunchArgument -from launch.launch_description_sources import PythonLaunchDescriptionSource -from launch.substitutions import LaunchConfiguration -from launch_ros.actions import Node - - -def generate_launch_description(): - """生成 LaunchDescription,启动实车底盘 + 雷达 + SLAM定位 + Nav2 导航""" - ld = LaunchDescription() - - # =============================1. 包路径=========================================== - pkg_dir = get_package_share_directory('gc_navigation2_real') - nav2_bringup_dir = get_package_share_directory('nav2_bringup') - origincar_base_dir = get_package_share_directory('origincar_base') - - # =============================2. 参数============================================= - use_sim_time = LaunchConfiguration('use_sim_time', default='false') - map_yaml_path = LaunchConfiguration('map', default=os.path.join( - pkg_dir, 'maps', 'my_map.yaml')) - nav2_param_path = LaunchConfiguration('params_file', default=os.path.join( - pkg_dir, 'params', 'gc_navigation_slam_real.yaml')) - slam_params_file = os.path.join( - pkg_dir, 'config', 'slam_toolbox_localization_real.yaml') - posegraph_path = os.path.join( - pkg_dir, 'maps', 'my_map.posegraph') - - # =============================3. 实车底盘 bringup ================================ - origincar_bringup = IncludeLaunchDescription( - PythonLaunchDescriptionSource( - [origincar_base_dir, '/launch', '/origincar_bringup.launch.py']), - ) - - # =============================4. 镭神激光雷达驱动 ================================ - lslidar_launch = IncludeLaunchDescription( - PythonLaunchDescriptionSource( - [get_package_share_directory('lslidar_driver'), - '/launch', '/lsn10_launch.py']), - ) - - # =============================5. map_server:全量静态地图 ========================== - map_server_node = Node( - package='nav2_map_server', - executable='map_server', - name='map_server', - output='screen', - parameters=[{'yaml_filename': map_yaml_path, 'use_sim_time': False}], - ) - map_server_lifecycle = Node( - package='nav2_lifecycle_manager', - executable='lifecycle_manager', - name='lifecycle_manager_map', - output='screen', - parameters=[{'use_sim_time': False, 'autostart': True, - 'node_names': ['map_server']}], - ) - - # =============================6. slam_toolbox 定位模式(替代 AMCL)================== - # ⚠️ /map 重映射到 /slam_map,避免覆盖 map_server 的全量地图 - slam_toolbox_node = Node( - package='slam_toolbox', - executable='localization_slam_toolbox_node', - name='slam_toolbox', - output='screen', - parameters=[slam_params_file, - {'use_sim_time': False, - 'map_file_name': posegraph_path}], - remappings=[('/map', '/slam_map')], - ) - - # =============================7. Nav2 导航栈 ===================================== - navigation_launch = IncludeLaunchDescription( - PythonLaunchDescriptionSource( - [nav2_bringup_dir, '/launch', '/navigation_launch.py']), - launch_arguments={ - 'use_sim_time': use_sim_time, - 'params_file': nav2_param_path, - }.items(), - ) - - # =============================8. 组装============================================= - ld.add_action(origincar_bringup) - ld.add_action(lslidar_launch) - ld.add_action(map_server_node) - ld.add_action(map_server_lifecycle) - ld.add_action(slam_toolbox_node) - ld.add_action(navigation_launch) - - return ld diff --git a/src/gc_navigation2_real/launch/real_nav2_slam_online.launch.py b/src/gc_navigation2_real/launch/real_nav2_slam_online.launch.py deleted file mode 100644 index 248d160..0000000 --- a/src/gc_navigation2_real/launch/real_nav2_slam_online.launch.py +++ /dev/null @@ -1,135 +0,0 @@ -#!/usr/bin/env python3 -# ============================================================================ -# real_nav2_slam_online.launch.py -# 功能:实车导航 — 已知全局地图 + SLAM 在线更新 + Nav2 导航 -# -# 架构: -# ┌─ /map(全量静态地图) -# map_server ──────────┤ -# └─ 来自 my_map.yaml + my_map.pgm -# -# ┌─ map→odom_combined TF(激光扫描匹配定位) -# slam_toolbox ────────┤ -# (async mapping) └─ /slam_map(实时建图结果,重映射避免冲突) -# -# navigation ┌─ global_costmap/static_layer ← /map(全量地图) -# ├─ local_costmap/obstacle_layer ← /scan(实时避障) -# └─ planner + controller + behavior -# -# 关键设计: -# 1. map_server 提供全量静态底图 → Foxglove 中看到完整房间布局 -# 2. slam_toolbox 定位 + 实时建图,/slam_map 可单独查看更新效果 -# 3. 实时避障通过 costmap 的 obstacle_layer 实现(不依赖地图更新) -# 4. 定期调用 /slam_toolbox/serialize_map 保存更新后的地图 -# -# 与仿真版的区别: -# - 无 Gazebo,无 spawn_entity -# - 使用 origincar_base bringup(串口驱动 + EKF + IMU) -# - 使用 lslidar_driver(镭神实车雷达) -# - use_sim_time: False -# - TF 帧适配实车(odom_combined, base_footprint) -# -# 使用方式: -# ros2 launch gc_navigation2_real real_nav2_slam_online.launch.py -# ============================================================================ - -import os -from ament_index_python.packages import get_package_share_directory -from launch import LaunchDescription -from launch.actions import IncludeLaunchDescription, DeclareLaunchArgument -from launch.launch_description_sources import PythonLaunchDescriptionSource -from launch.substitutions import LaunchConfiguration -from launch_ros.actions import Node -from launch.actions import ExecuteProcess - - -def generate_launch_description(): - """启动实车底盘 + 雷达 + 静态地图 + SLAM 在线定位建图 + Nav2 导航""" - ld = LaunchDescription() - - # =============================1. 包路径=========================================== - pkg_dir = get_package_share_directory('gc_navigation2_real') - nav2_bringup_dir = get_package_share_directory('nav2_bringup') - origincar_base_dir = get_package_share_directory('origincar_base') - - # =============================2. 参数============================================= - use_sim_time = LaunchConfiguration('use_sim_time', default='false') - map_yaml_path = os.path.join(pkg_dir, 'maps', 'my_map.yaml') - nav2_param_path = LaunchConfiguration('params_file', default=os.path.join( - pkg_dir, 'params', 'gc_navigation_slam_real.yaml')) - slam_params_file = os.path.join(pkg_dir, 'config', 'slam_toolbox_async_real.yaml') - posegraph_path = os.path.join(pkg_dir, 'maps', 'my_map.posegraph') - - # =============================3. 实车底盘 bringup ================================ - origincar_bringup = IncludeLaunchDescription( - PythonLaunchDescriptionSource( - [origincar_base_dir, '/launch', '/origincar_bringup.launch.py']), - ) - - # =============================4. 镭神激光雷达驱动 ================================ - lslidar_launch = IncludeLaunchDescription( - PythonLaunchDescriptionSource( - [get_package_share_directory('lslidar_driver'), - '/launch', '/lsn10_launch.py']), - ) - - # =============================5. map_server:全量静态地图 ========================== - map_server_node = Node( - package='nav2_map_server', - executable='map_server', - name='map_server', - output='screen', - parameters=[{'yaml_filename': map_yaml_path, 'use_sim_time': False}], - ) - map_server_lifecycle = Node( - package='nav2_lifecycle_manager', - executable='lifecycle_manager', - name='lifecycle_manager_map', - output='screen', - parameters=[{'use_sim_time': False, 'autostart': True, - 'node_names': ['map_server']}], - ) - - # =============================6. slam_toolbox:定位 + 实时建图======================== - # ⚠️ /map 重映射到 /slam_map,避免覆盖 map_server 的全量地图 - slam_toolbox_node = Node( - package='slam_toolbox', - executable='async_slam_toolbox_node', - name='slam_toolbox', - output='screen', - parameters=[slam_params_file, {'use_sim_time': False}], - remappings=[('/map', '/slam_map')], - ) - - # =============================7. 加载已有序列化地图 ================================= - load_map_cmd = ExecuteProcess( - cmd=[ - 'bash', '-c', - 'sleep 8 && ' - 'ros2 service call /slam_toolbox/deserialize_map ' - 'slam_toolbox/srv/DeserializePoseGraph ' - "'{filename: \"%s\", match_type: 1}'" % posegraph_path, - ], - output='screen', - ) - - # =============================8. Nav2 导航栈 ===================================== - navigation_launch = IncludeLaunchDescription( - PythonLaunchDescriptionSource( - [nav2_bringup_dir, '/launch', '/navigation_launch.py']), - launch_arguments={ - 'use_sim_time': use_sim_time, - 'params_file': nav2_param_path, - }.items(), - ) - - # =============================9. 组装============================================ - ld.add_action(origincar_bringup) - ld.add_action(lslidar_launch) - ld.add_action(map_server_node) - ld.add_action(map_server_lifecycle) - ld.add_action(slam_toolbox_node) - ld.add_action(load_map_cmd) - ld.add_action(navigation_launch) - - return ld diff --git a/src/gc_navigation2_real/launch/real_slam_mapping.launch.py b/src/gc_navigation2_real/launch/real_slam_mapping.launch.py deleted file mode 100644 index f957e03..0000000 --- a/src/gc_navigation2_real/launch/real_slam_mapping.launch.py +++ /dev/null @@ -1,103 +0,0 @@ -#!/usr/bin/env python3 -# ============================================================================ -# real_slam_mapping.launch.py -# 功能:实车 SLAM 建图启动文件(无 Gazebo 仿真) -# -# 适用场景: -# - 在实际场地遥控机器人建立环境地图 -# - 在已有地图基础上增量更新 -# - 单独调试 slam_toolbox 建图参数 -# -# 架构: -# origincar_base (bringup) — 底盘串口驱动 + EKF 里程计 + IMU 滤波 + TF -# lslidar_driver — 镭神激光雷达驱动 → /scan -# async_slam_toolbox_node — 激光 SLAM 建图(mapping 模式) -# 发布 map→odom_combined TF -# 发布 /map 话题(实时地图) -# -# 使用方式: -# ros2 launch gc_navigation2_real real_slam_mapping.launch.py -# -# 保存地图: -# ros2 service call /slam_toolbox/serialize_map slam_toolbox/srv/SerializePoseGraph \ -# "{filename: '/home/guoch/test_ws/src/gc_navigation2_real/maps/my_map'}" -# ros2 run nav2_map_server map_saver_cli -f -# ============================================================================ - -import os -from ament_index_python.packages import get_package_share_directory -from launch import LaunchDescription -from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription -from launch.substitutions import LaunchConfiguration -from launch_ros.actions import Node -from launch.launch_description_sources import PythonLaunchDescriptionSource - - -def generate_launch_description(): - """生成 LaunchDescription,启动实车底盘 + 雷达 + slam_toolbox 建图""" - - # ============================ 1. 包路径 ========================================= - pkg_dir = get_package_share_directory('gc_navigation2_real') - origincar_base_dir = get_package_share_directory('origincar_base') - - # ============================ 2. 声明启动参数 ==================================== - use_sim_time = LaunchConfiguration('use_sim_time', default='false') - - # slam_params_file: slam_toolbox 配置文件 - slam_params_file = LaunchConfiguration( - 'slam_params_file', - default=os.path.join(pkg_dir, 'config', 'slam_toolbox_async_real.yaml')) - - # map_file_name: 可选,加载已有序列化地图继续建图 - map_file_name = LaunchConfiguration('map_file_name', default='') - - # ============================ 3. 实车底盘 bringup =============================== - # 启动 origincar_base:串口驱动 + EKF + IMU 滤波 + TF 发布 - # 注:origincar_bringup 已包含 robot_state_publisher + joint_state_publisher + 静态 TF - origincar_bringup = IncludeLaunchDescription( - PythonLaunchDescriptionSource( - [origincar_base_dir, '/launch', '/origincar_bringup.launch.py']), - ) - - # ============================ 4. 镭神激光雷达驱动 =============================== - # 启动 lslidar_driver → /scan 话题 - lslidar_launch = IncludeLaunchDescription( - PythonLaunchDescriptionSource( - [get_package_share_directory('lslidar_driver'), - '/launch', '/lsn10_launch.py']), - ) - - # ============================ 5. slam_toolbox 建图节点 ============================ - slam_toolbox_node = Node( - package='slam_toolbox', - executable='async_slam_toolbox_node', - name='slam_toolbox', - output='screen', - parameters=[ - slam_params_file, - { - 'use_sim_time': False, - 'map_file_name': map_file_name, - }, - ], - ) - - # ============================ 6. 组装 LaunchDescription ========================= - return LaunchDescription([ - DeclareLaunchArgument( - 'use_sim_time', - default_value='false', - description='使用仿真时间(实车必须为 false)'), - DeclareLaunchArgument( - 'slam_params_file', - default_value=os.path.join(pkg_dir, 'config', 'slam_toolbox_async_real.yaml'), - description='slam_toolbox 参数配置文件路径'), - DeclareLaunchArgument( - 'map_file_name', - default_value='', - description='已有序列化地图路径(.posegraph),留空则从零开始建图'), - - origincar_bringup, - lslidar_launch, - slam_toolbox_node, - ]) diff --git a/src/gc_navigation2_real/maps/Readme.txt b/src/gc_navigation2_real/maps/Readme.txt deleted file mode 100644 index 75b15b6..0000000 --- a/src/gc_navigation2_real/maps/Readme.txt +++ /dev/null @@ -1,3 +0,0 @@ -# 实车地图存放目录 -# 使用 map_saver_cli 保存地图到此目录: -# ros2 run nav2_map_server map_saver_cli -f ~/test_ws/src/gc_navigation2_real/maps/your_map_name diff --git a/src/gc_navigation2_real/package.xml b/src/gc_navigation2_real/package.xml deleted file mode 100644 index bbc6199..0000000 --- a/src/gc_navigation2_real/package.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - gc_navigation2_real - 0.0.0 - Real-world navigation package: SLAM + Nav2 for OriginCar on physical robot (no Gazebo) - guoch - TODO: License declaration - - ament_cmake - - rclcpp - slam_toolbox - nav2_bringup - origincar_base - origincar_description - origincar_msg - robot_state_publisher - joint_state_publisher - robot_localization - imu_filter_madgwick - tf2_ros - lslidar_driver - - ament_lint_auto - ament_lint_common - - - ament_cmake - - diff --git a/src/gc_navigation2_real/params/gc_navigation_slam_real.yaml b/src/gc_navigation2_real/params/gc_navigation_slam_real.yaml deleted file mode 100644 index 02e1ea1..0000000 --- a/src/gc_navigation2_real/params/gc_navigation_slam_real.yaml +++ /dev/null @@ -1,353 +0,0 @@ -# ============================================================================ -# gc_navigation_slam_real.yaml -# 实车 Nav2 导航参数(SLAM 定位方案,无 AMCL) -# -# 与仿真版的区别: -# - use_sim_time: False(使用系统时钟) -# - TF 帧适配实车(odom_combined, base_footprint) -# - 速度/加速度参数适当降低以保证实车安全 -# - 激光雷达参数匹配镭神 N10 实车性能 -# ============================================================================ - -slam_toolbox: - ros__parameters: - use_sim_time: False - -bt_navigator: - ros__parameters: - use_sim_time: False - global_frame: map - robot_base_frame: base_footprint - odom_topic: /odom_combined - bt_loop_duration: 50 - default_server_timeout: 20 - # 阿克曼底盘专用 BT:移除 Spin,恢复行为 = 清代价地图 → 后退 → 等待 - default_nav_to_pose_bt_xml: /home/guoch/test_ws/install/gc_navigation2_real/share/gc_navigation2_real/behavior_tree/nav_to_pose_ackermann.xml - plugin_lib_names: - - nav2_compute_path_to_pose_action_bt_node - - nav2_compute_path_through_poses_action_bt_node - - nav2_smooth_path_action_bt_node - - nav2_follow_path_action_bt_node - - nav2_spin_action_bt_node - - nav2_wait_action_bt_node - - nav2_back_up_action_bt_node - - nav2_drive_on_heading_bt_node - - nav2_clear_costmap_service_bt_node - - nav2_is_stuck_condition_bt_node - - nav2_goal_reached_condition_bt_node - - nav2_goal_updated_condition_bt_node - - nav2_globally_updated_goal_condition_bt_node - - nav2_is_path_valid_condition_bt_node - - nav2_initial_pose_received_condition_bt_node - - nav2_reinitialize_global_localization_service_bt_node - - nav2_rate_controller_bt_node - - nav2_distance_controller_bt_node - - nav2_speed_controller_bt_node - - nav2_truncate_path_action_bt_node - - nav2_truncate_path_local_action_bt_node - - nav2_goal_updater_node_bt_node - - nav2_recovery_node_bt_node - - nav2_pipeline_sequence_bt_node - - nav2_round_robin_node_bt_node - - nav2_transform_available_condition_bt_node - - nav2_time_expired_condition_bt_node - - nav2_path_expiring_timer_condition - - nav2_distance_traveled_condition_bt_node - - nav2_single_trigger_bt_node - - nav2_is_battery_low_condition_bt_node - - nav2_navigate_through_poses_action_bt_node - - nav2_navigate_to_pose_action_bt_node - - nav2_remove_passed_goals_action_bt_node - - nav2_planner_selector_bt_node - - nav2_controller_selector_bt_node - - nav2_goal_checker_selector_bt_node - - nav2_controller_cancel_bt_node - - nav2_path_longer_on_approach_bt_node - - nav2_wait_cancel_bt_node - - nav2_spin_cancel_bt_node - - nav2_back_up_cancel_bt_node - - nav2_drive_on_heading_cancel_bt_node - -bt_navigator_rclcpp_node: - ros__parameters: - use_sim_time: False - -controller_server: - ros__parameters: - use_sim_time: False - controller_frequency: 20.0 - FollowPath: - plugin: "nav2_mppi_controller::MPPIController" - time_steps: 36 - model_dt: 0.05 - batch_size: 1000 - vx_std: 0.2 - vy_std: 0.0 - wz_std: 0.4 - vx_max: 0.5 # 第一阶段提速:0.4→0.5(仿真已验证安全) - vx_min: -0.30 # 第一阶段提速:-0.25→-0.30 - vy_max: 0.0 - wz_max: 1.5 # 实车最大角速度降低 - iteration_count: 1 - temperature: 0.3 - gamma: 0.015 - motion_model: "Ackermann" - visualize: false - TrajectoryVisualizer: - trajectory_step: 5 - time_step: 3 - AckermannConstraints: - min_turning_r: 0.4 - critics: ["ConstraintCritic", "CostCritic", "GoalCritic", "GoalAngleCritic", "PathAlignCritic", "PathFollowCritic", "PathAngleCritic", "PreferForwardCritic"] - ConstraintCritic: - enabled: true - cost_power: 1 - cost_weight: 4.0 - GoalCritic: - enabled: true - cost_power: 1 - cost_weight: 5.0 - threshold_to_consider: 1.4 - GoalAngleCritic: - enabled: true - cost_power: 1 - cost_weight: 3.0 - threshold_to_consider: 0.5 - PreferForwardCritic: - enabled: true - cost_power: 1 - cost_weight: 5.0 - threshold_to_consider: 0.5 - CostCritic: - enabled: true - cost_power: 1 - cost_weight: 3.81 - critical_cost: 300.0 - consider_footprint: true - collision_cost: 1000000.0 - near_goal_distance: 1.0 - trajectory_point_step: 2 - PathAlignCritic: - enabled: true - cost_power: 1 - cost_weight: 14.0 - max_path_occupancy_ratio: 0.05 - trajectory_point_step: 4 - threshold_to_consider: 0.5 - offset_from_furthest: 20 - use_path_orientations: false - PathFollowCritic: - enabled: true - cost_power: 1 - cost_weight: 5.0 - offset_from_furthest: 5 - threshold_to_consider: 1.4 - PathAngleCritic: - enabled: true - cost_power: 1 - cost_weight: 2.0 - offset_from_furthest: 4 - threshold_to_consider: 0.5 - max_angle_to_furthest: 1.0 - forward_preference: true - -controller_server_rclcpp_node: - ros__parameters: - use_sim_time: False - -local_costmap: - local_costmap: - ros__parameters: - update_frequency: 5.0 - publish_frequency: 2.0 - transform_tolerance: 0.5 - global_frame: odom_combined # 实车:EKF 融合后的里程计坐标系 - robot_base_frame: base_footprint # 实车:URDF 根帧 - use_sim_time: False - rolling_window: true - width: 3 - height: 3 - resolution: 0.05 - footprint: "[[0.14, 0.085], - [0.14, -0.085], - [-0.14, -0.085], - [-0.14, 0.085]]" - footprint_padding: 0.02 - plugins: ["voxel_layer", "inflation_layer"] - inflation_layer: - plugin: "nav2_costmap_2d::InflationLayer" - cost_scaling_factor: 3.0 - inflation_radius: 0.55 - voxel_layer: - plugin: "nav2_costmap_2d::VoxelLayer" - enabled: True - publish_voxel_map: True - origin_z: 0.0 - z_resolution: 0.05 - z_voxels: 16 - max_obstacle_height: 2.0 - mark_threshold: 0 - observation_sources: scan - scan: - topic: /scan - max_obstacle_height: 2.0 - clearing: True - marking: True - data_type: "LaserScan" - raytrace_max_range: 3.0 - raytrace_min_range: 0.0 - obstacle_max_range: 2.5 - obstacle_min_range: 0.0 - static_layer: - map_subscribe_transient_local: True - always_send_full_costmap: True - local_costmap_client: - ros__parameters: - use_sim_time: False - local_costmap_rclcpp_node: - ros__parameters: - use_sim_time: False - -global_costmap: - global_costmap: - ros__parameters: - use_sim_time: False - transform_tolerance: 0.5 - update_frequency: 1.0 - publish_frequency: 1.0 - global_frame: map - robot_base_frame: base_footprint # 实车:与 URDF 根帧一致 - footprint: "[[0.14, 0.085], - [0.14, -0.085], - [-0.14, -0.085], - [-0.14, 0.085]]" - footprint_padding: 0.02 - resolution: 0.05 - track_unknown_space: true - plugins: ["static_layer", "obstacle_layer", "inflation_layer"] - obstacle_layer: - plugin: "nav2_costmap_2d::ObstacleLayer" - enabled: True - observation_sources: scan - scan: - topic: /scan - max_obstacle_height: 2.0 - clearing: True - marking: True - data_type: "LaserScan" - raytrace_max_range: 3.0 - raytrace_min_range: 0.0 - obstacle_max_range: 2.5 - obstacle_min_range: 0.0 - static_layer: - plugin: "nav2_costmap_2d::StaticLayer" - map_subscribe_transient_local: True - inflation_layer: - plugin: "nav2_costmap_2d::InflationLayer" - cost_scaling_factor: 3.0 - inflation_radius: 0.55 - always_send_full_costmap: True - global_costmap_client: - ros__parameters: - use_sim_time: False - global_costmap_rclcpp_node: - ros__parameters: - use_sim_time: False - -map_saver: - ros__parameters: - use_sim_time: False - save_map_timeout: 5.0 - free_thresh_default: 0.25 - occupied_thresh_default: 0.65 - map_subscribe_transient_local: True - -planner_server: - ros__parameters: - planner_plugins: ["GridBased"] - use_sim_time: False - - GridBased: - plugin: "nav2_smac_planner/SmacPlannerHybrid" - downsample_costmap: false - downsampling_factor: 1 - tolerance: 0.25 - allow_unknown: true - max_iterations: 1000000 - max_on_approach_iterations: 1000 - max_planning_time: 5.0 - motion_model_for_search: "REEDS_SHEPP" - angle_quantization_bins: 72 - analytic_expansion_ratio: 3.5 - analytic_expansion_max_length: 3.0 - minimum_turning_radius: 0.40 - reverse_penalty: 1.3 - change_penalty: 0.0 - non_straight_penalty: 1.2 - cost_penalty: 2.0 - retrospective_penalty: 0.015 - lookup_table_size: 20.0 - cache_obstacle_heuristic: false - viz_expansions: false - smooth_path: True - - smoother: - max_iterations: 1000 - w_smooth: 0.3 - w_data: 0.2 - tolerance: 1.0e-10 - do_refinement: true - refinement_num: 2 - -planner_server_rclcpp_node: - ros__parameters: - use_sim_time: False - -smoother_server: - ros__parameters: - use_sim_time: False - smoother_plugins: ["simple_smoother"] - simple_smoother: - plugin: "nav2_smoother::SimpleSmoother" - tolerance: 1.0e-10 - max_its: 1000 - do_refinement: True - -behavior_server: - ros__parameters: - costmap_topic: local_costmap/costmap_raw - footprint_topic: local_costmap/published_footprint - cycle_frequency: 10.0 - behavior_plugins: ["spin", "backup", "wait"] - spin: - plugin: "nav2_behaviors/Spin" - backup: - plugin: "nav2_behaviors/BackUp" - backup_dist: 0.8 - backup_speed: 0.18 - wait: - plugin: "nav2_behaviors/Wait" - wait_duration: 0.5 - global_frame: odom_combined # 实车:EKF 融合后的里程计坐标系 - robot_base_frame: base_footprint # 实车:URDF 根帧 - transform_tolerance: 0.5 - use_sim_time: False - simulate_ahead_time: 2.0 - max_rotational_vel: 1.0 - min_rotational_vel: 0.4 - rotational_acc_lim: 3.2 - -robot_state_publisher: - ros__parameters: - use_sim_time: False - -waypoint_follower: - ros__parameters: - loop_rate: 20 - use_sim_time: False - stop_on_failure: false - waypoint_task_executor_plugin: "wait_at_waypoint" - wait_at_waypoint: - plugin: "nav2_waypoint_follower::WaitAtWaypoint" - enabled: True - waypoint_pause_duration: 200 diff --git a/src/gc_navigation2_slamtoolbox/CMakeLists.txt b/src/gc_navigation2_slamtoolbox/CMakeLists.txt deleted file mode 100644 index 25a809b..0000000 --- a/src/gc_navigation2_slamtoolbox/CMakeLists.txt +++ /dev/null @@ -1,31 +0,0 @@ -cmake_minimum_required(VERSION 3.8) -project(gc_navigation2_slamtoolbox) - -if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") - add_compile_options(-Wall -Wextra -Wpedantic) -endif() - -# find dependencies -find_package(ament_cmake REQUIRED) -# uncomment the following section in order to fill in -# further dependencies manually. -# find_package( REQUIRED) -# 查找slam_toolbox包 -find_package(slam_toolbox REQUIRED) -install( - DIRECTORY launch config params maps world - DESTINATION share/${PROJECT_NAME} -) -if(BUILD_TESTING) - find_package(ament_lint_auto REQUIRED) - # the following line skips the linter which checks for copyrights - # comment the line when a copyright and license is added to all source files - set(ament_cmake_copyright_FOUND TRUE) - # the following line skips cpplint (only works in a git repo) - # comment the line when this package is in a git repo and when - # a copyright and license is added to all source files - set(ament_cmake_cpplint_FOUND TRUE) - ament_lint_auto_find_test_dependencies() -endif() - -ament_package() diff --git a/src/gc_navigation2_slamtoolbox/config/mapper_params_lifelong.yaml b/src/gc_navigation2_slamtoolbox/config/mapper_params_lifelong.yaml deleted file mode 100644 index fd1088a..0000000 --- a/src/gc_navigation2_slamtoolbox/config/mapper_params_lifelong.yaml +++ /dev/null @@ -1,89 +0,0 @@ - -slam_toolbox: - ros__parameters: - - # Plugin params - solver_plugin: solver_plugins::CeresSolver - ceres_linear_solver: SPARSE_NORMAL_CHOLESKY - ceres_preconditioner: SCHUR_JACOBI - ceres_trust_strategy: LEVENBERG_MARQUARDT - ceres_dogleg_type: TRADITIONAL_DOGLEG - ceres_loss_function: None - - # ROS Parameters - odom_frame: odom - map_frame: map - base_frame: base_link - scan_topic: /scan - use_map_saver: true - mode: mapping - - # lifelong params - lifelong_search_use_tree: false - lifelong_minimum_score: 0.1 - lifelong_iou_match: 0.85 - lifelong_node_removal_score: 0.04 - lifelong_overlap_score_scale: 0.06 - lifelong_constraint_multiplier: 0.08 - lifelong_nearby_penalty: 0.001 - lifelong_candidates_scale: 0.03 - - # if you'd like to immediately start continuing a map at a given pose - # or at the dock, but they are mutually exclusive, if pose is given - # will use pose - #map_file_name: test_steve - #map_start_pose: [0.0, 0.0, 0.0] - #map_start_at_dock: true - - debug_logging: false - throttle_scans: 1 - transform_publish_period: 0.02 #if 0 never publishes odometry - map_update_interval: 5.0 - resolution: 0.05 - restamp_tf: false - min_laser_range: 0.0 #for rastering images - max_laser_range: 20.0 #for rastering images - minimum_time_interval: 0.5 - transform_timeout: 0.2 - tf_buffer_duration: 10. - stack_size_to_use: 40000000 #// program needs a larger stack size to serialize large maps - - # General Parameters - use_scan_matching: true - use_scan_barycenter: true - minimum_travel_distance: 0.5 - minimum_travel_heading: 0.5 - check_min_dist_and_heading_precisely: false - scan_buffer_size: 10 - scan_buffer_maximum_scan_distance: 10.0 - link_match_minimum_response_fine: 0.1 - link_scan_maximum_distance: 1.5 - loop_search_maximum_distance: 3.0 - do_loop_closing: true - loop_match_minimum_chain_size: 10 - loop_match_maximum_variance_coarse: 3.0 - loop_match_minimum_response_coarse: 0.35 - loop_match_minimum_response_fine: 0.45 - - # Correlation Parameters - Correlation Parameters - correlation_search_space_dimension: 0.5 - correlation_search_space_resolution: 0.01 - correlation_search_space_smear_deviation: 0.1 - - # Correlation Parameters - Loop Closure Parameters - loop_search_space_dimension: 8.0 - loop_search_space_resolution: 0.05 - loop_search_space_smear_deviation: 0.03 - - # Scan Matcher Parameters - distance_variance_penalty: 0.5 - angle_variance_penalty: 1.0 - - fine_search_angle_offset: 0.00349 - coarse_search_angle_offset: 0.349 - coarse_angle_resolution: 0.0349 - minimum_angle_penalty: 0.9 - minimum_distance_penalty: 0.5 - use_response_expansion: true - min_pass_through: 2 - occupancy_threshold: 0.1 diff --git a/src/gc_navigation2_slamtoolbox/config/mapper_params_localization.yaml b/src/gc_navigation2_slamtoolbox/config/mapper_params_localization.yaml deleted file mode 100644 index b6356ef..0000000 --- a/src/gc_navigation2_slamtoolbox/config/mapper_params_localization.yaml +++ /dev/null @@ -1,72 +0,0 @@ -slam_toolbox: - ros__parameters: - solver_plugin: solver_plugins::CeresSolver - ceres_linear_solver: SPARSE_NORMAL_CHOLESKY - ceres_preconditioner: SCHUR_JACOBI - ceres_trust_strategy: LEVENBERG_MARQUARDT - ceres_dogleg_type: TRADITIONAL_DOGLEG - ceres_loss_function: None - - # ROS Parameters - odom_frame: odom - map_frame: map - base_frame: base_link - scan_topic: /scan - mode: localization #localization - - # if you'd like to start localizing on bringup in a map and pose - map_file_name: /home/guoch/test_ws/src/gc_navigation2_slamtoolbox/maps/my_map.posegraph - map_start_pose: [0.0, 0.0, 0.0] - - debug_logging: false - throttle_scans: 1 - transform_publish_period: 0.02 #if 0 never publishes odometry - map_update_interval: 5.0 - resolution: 0.05 - restamp_tf: false - min_laser_range: 0.0 #for rastering images - max_laser_range: 20.0 #for rastering images - minimum_time_interval: 0.5 - transform_timeout: 0.2 - tf_buffer_duration: 30. - stack_size_to_use: 40000000 #// program needs a larger stack size to serialize large maps - - # General Parameters - use_scan_matching: true - use_scan_barycenter: true - minimum_travel_distance: 0.5 - minimum_travel_heading: 0.5 - check_min_dist_and_heading_precisely: false - scan_buffer_size: 3 - scan_buffer_maximum_scan_distance: 10.0 - link_match_minimum_response_fine: 0.1 - link_scan_maximum_distance: 1.5 - do_loop_closing: true - loop_match_minimum_chain_size: 3 - loop_match_maximum_variance_coarse: 3.0 - loop_match_minimum_response_coarse: 0.35 - loop_match_minimum_response_fine: 0.45 - - # Correlation Parameters - Correlation Parameters - correlation_search_space_dimension: 0.5 - correlation_search_space_resolution: 0.01 - correlation_search_space_smear_deviation: 0.1 - - # Correlation Parameters - Loop Closure Parameters - loop_search_space_dimension: 8.0 - loop_search_space_resolution: 0.05 - loop_search_space_smear_deviation: 0.03 - loop_search_maximum_distance: 3.0 - - # Scan Matcher Parameters - distance_variance_penalty: 0.5 - angle_variance_penalty: 1.0 - - fine_search_angle_offset: 0.00349 - coarse_search_angle_offset: 0.349 - coarse_angle_resolution: 0.0349 - minimum_angle_penalty: 0.9 - minimum_distance_penalty: 0.5 - use_response_expansion: true - min_pass_through: 2 - occupancy_threshold: 0.1 diff --git a/src/gc_navigation2_slamtoolbox/config/mapper_params_offline.yaml b/src/gc_navigation2_slamtoolbox/config/mapper_params_offline.yaml deleted file mode 100644 index 4d9dba2..0000000 --- a/src/gc_navigation2_slamtoolbox/config/mapper_params_offline.yaml +++ /dev/null @@ -1,71 +0,0 @@ -slam_toolbox: - ros__parameters: - - # Plugin params - solver_plugin: solver_plugins::CeresSolver - ceres_linear_solver: SPARSE_NORMAL_CHOLESKY - ceres_preconditioner: SCHUR_JACOBI - ceres_trust_strategy: LEVENBERG_MARQUARDT - ceres_dogleg_type: TRADITIONAL_DOGLEG - ceres_loss_function: None - - # ROS Parameters - odom_frame: odom - map_frame: map - base_frame: base_footprint - scan_topic: /scan - use_map_saver: true - mode: mapping #localization - debug_logging: false - throttle_scans: 1 - transform_publish_period: 0.02 #if 0 never publishes odometry - map_update_interval: 10.0 - resolution: 0.05 - restamp_tf: false - min_laser_range: 0.0 #for rastering images - max_laser_range: 20.0 #for rastering images - minimum_time_interval: 0.5 - transform_timeout: 0.2 - tf_buffer_duration: 14400. - stack_size_to_use: 40000000 #// program needs a larger stack size to serialize large maps - enable_interactive_mode: true - - # General Parameters - use_scan_matching: true - use_scan_barycenter: true - minimum_travel_distance: 0.5 - minimum_travel_heading: 0.5 - check_min_dist_and_heading_precisely: false - scan_buffer_size: 10 - scan_buffer_maximum_scan_distance: 10.0 - link_match_minimum_response_fine: 0.1 - link_scan_maximum_distance: 1.5 - loop_search_maximum_distance: 3.0 - do_loop_closing: true - loop_match_minimum_chain_size: 10 - loop_match_maximum_variance_coarse: 3.0 - loop_match_minimum_response_coarse: 0.35 - loop_match_minimum_response_fine: 0.45 - - # Correlation Parameters - Correlation Parameters - correlation_search_space_dimension: 0.5 - correlation_search_space_resolution: 0.01 - correlation_search_space_smear_deviation: 0.1 - - # Correlation Parameters - Loop Closure Parameters - loop_search_space_dimension: 8.0 - loop_search_space_resolution: 0.05 - loop_search_space_smear_deviation: 0.03 - - # Scan Matcher Parameters - distance_variance_penalty: 0.5 - angle_variance_penalty: 1.0 - - fine_search_angle_offset: 0.00349 - coarse_search_angle_offset: 0.349 - coarse_angle_resolution: 0.0349 - minimum_angle_penalty: 0.9 - minimum_distance_penalty: 0.5 - use_response_expansion: true - min_pass_through: 2 - occupancy_threshold: 0.1 diff --git a/src/gc_navigation2_slamtoolbox/config/mapper_params_online_multi_async.yaml b/src/gc_navigation2_slamtoolbox/config/mapper_params_online_multi_async.yaml deleted file mode 100644 index 9b8e220..0000000 --- a/src/gc_navigation2_slamtoolbox/config/mapper_params_online_multi_async.yaml +++ /dev/null @@ -1,74 +0,0 @@ -$(var namespace)/slam_toolbox: - ros__parameters: - - # Plugin params - solver_plugin: solver_plugins::CeresSolver - ceres_linear_solver: SPARSE_NORMAL_CHOLESKY - ceres_preconditioner: SCHUR_JACOBI - ceres_trust_strategy: LEVENBERG_MARQUARDT - ceres_dogleg_type: TRADITIONAL_DOGLEG - ceres_loss_function: None - - # ROS Parameters - odom_frame: global_odom - map_frame: map - base_frame: base_footprint - scan_topic: scan - mode: mapping #localization - - # if you'd like to immediately start continuing a map at a given pose - # or at the dock, but they are mutually exclusive, if pose is given - # will use pose - #map_file_name: test_steve - # map_start_pose: [0.0, 0.0, 0.0] - #map_start_at_dock: true - - debug_logging: false - throttle_scans: 1 - transform_publish_period: 0.02 #if 0 never publishes odometry - map_update_interval: 5.0 - resolution: 0.05 - max_laser_range: 20.0 #for rastering images - minimum_time_interval: 0.5 - transform_timeout: 0.2 - tf_buffer_duration: 30.0 - stack_size_to_use: 40000000 #// program needs a larger stack size to serialize large maps - enable_interactive_mode: true - - # General Parameters - use_scan_matching: true - use_scan_barycenter: true - minimum_travel_distance: 0.5 - minimum_travel_heading: 0.5 - check_min_dist_and_heading_precisely: false - scan_buffer_size: 10 - scan_buffer_maximum_scan_distance: 10.0 - link_match_minimum_response_fine: 0.1 - link_scan_maximum_distance: 1.5 - loop_search_maximum_distance: 3.0 - do_loop_closing: true - loop_match_minimum_chain_size: 10 - loop_match_maximum_variance_coarse: 3.0 - loop_match_minimum_response_coarse: 0.35 - loop_match_minimum_response_fine: 0.45 - - # Correlation Parameters - Correlation Parameters - correlation_search_space_dimension: 0.5 - correlation_search_space_resolution: 0.01 - correlation_search_space_smear_deviation: 0.1 - - # Correlation Parameters - Loop Closure Parameters - loop_search_space_dimension: 8.0 - loop_search_space_resolution: 0.05 - loop_search_space_smear_deviation: 0.03 - - # Scan Matcher Parameters - distance_variance_penalty: 0.5 - angle_variance_penalty: 1.0 - - fine_search_angle_offset: 0.00349 - coarse_search_angle_offset: 0.349 - coarse_angle_resolution: 0.0349 - minimum_angle_penalty: 0.9 - minimum_distance_penalty: 0.5 - use_response_expansion: true diff --git a/src/gc_navigation2_slamtoolbox/config/mapper_params_online_sync.yaml b/src/gc_navigation2_slamtoolbox/config/mapper_params_online_sync.yaml deleted file mode 100644 index 73a4ac7..0000000 --- a/src/gc_navigation2_slamtoolbox/config/mapper_params_online_sync.yaml +++ /dev/null @@ -1,79 +0,0 @@ -slam_toolbox: - ros__parameters: - - # Plugin params - solver_plugin: solver_plugins::CeresSolver - ceres_linear_solver: SPARSE_NORMAL_CHOLESKY - ceres_preconditioner: SCHUR_JACOBI - ceres_trust_strategy: LEVENBERG_MARQUARDT - ceres_dogleg_type: TRADITIONAL_DOGLEG - ceres_loss_function: None - - # ROS Parameters - odom_frame: odom - map_frame: map - base_frame: base_footprint - scan_topic: /scan - use_map_saver: true - mode: mapping #localization - - # if you'd like to immediately start continuing a map at a given pose - # or at the dock, but they are mutually exclusive, if pose is given - # will use pose - #map_file_name: test_steve - #map_start_pose: [0.0, 0.0, 0.0] - #map_start_at_dock: true - - debug_logging: false - throttle_scans: 1 - transform_publish_period: 0.02 #if 0 never publishes odometry - map_update_interval: 5.0 - resolution: 0.05 - restamp_tf: false - min_laser_range: 0.0 #for rastering images - max_laser_range: 20.0 #for rastering images - minimum_time_interval: 0.5 - transform_timeout: 0.2 - tf_buffer_duration: 30. - stack_size_to_use: 40000000 #// program needs a larger stack size to serialize large maps - enable_interactive_mode: true - - # General Parameters - use_scan_matching: true - use_scan_barycenter: true - minimum_travel_distance: 0.5 - minimum_travel_heading: 0.5 - check_min_dist_and_heading_precisely: false - scan_buffer_size: 10 - scan_buffer_maximum_scan_distance: 10.0 - link_match_minimum_response_fine: 0.1 - link_scan_maximum_distance: 1.5 - loop_search_maximum_distance: 3.0 - do_loop_closing: true - loop_match_minimum_chain_size: 10 - loop_match_maximum_variance_coarse: 3.0 - loop_match_minimum_response_coarse: 0.35 - loop_match_minimum_response_fine: 0.45 - - # Correlation Parameters - Correlation Parameters - correlation_search_space_dimension: 0.5 - correlation_search_space_resolution: 0.01 - correlation_search_space_smear_deviation: 0.1 - - # Correlation Parameters - Loop Closure Parameters - loop_search_space_dimension: 8.0 - loop_search_space_resolution: 0.05 - loop_search_space_smear_deviation: 0.03 - - # Scan Matcher Parameters - distance_variance_penalty: 0.5 - angle_variance_penalty: 1.0 - - fine_search_angle_offset: 0.00349 - coarse_search_angle_offset: 0.349 - coarse_angle_resolution: 0.0349 - minimum_angle_penalty: 0.9 - minimum_distance_penalty: 0.5 - use_response_expansion: true - min_pass_through: 2 - occupancy_threshold: 0.1 diff --git a/src/gc_navigation2_slamtoolbox/config/nav_to_pose_ackermann.xml b/src/gc_navigation2_slamtoolbox/config/nav_to_pose_ackermann.xml deleted file mode 100644 index 5b2cc52..0000000 --- a/src/gc_navigation2_slamtoolbox/config/nav_to_pose_ackermann.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/gc_navigation2_slamtoolbox/config/slam_toolbox_async.yaml b/src/gc_navigation2_slamtoolbox/config/slam_toolbox_async.yaml deleted file mode 100644 index d0b1e16..0000000 --- a/src/gc_navigation2_slamtoolbox/config/slam_toolbox_async.yaml +++ /dev/null @@ -1,82 +0,0 @@ -slam_toolbox: - ros__parameters: - - # ============================ Solver 插件参数 ====================================== - solver_plugin: solver_plugins::CeresSolver - ceres_linear_solver: SPARSE_NORMAL_CHOLESKY - ceres_preconditioner: SCHUR_JACOBI - ceres_trust_strategy: LEVENBERG_MARQUARDT - ceres_dogleg_type: TRADITIONAL_DOGLEG - ceres_loss_function: None - - # ============================ ROS 基础参数 ========================================= - odom_frame: odom # 里程计坐标系 - map_frame: map # 地图坐标系 - base_frame: base_link # 机器人基座坐标系(与 URDF 根帧一致) - scan_topic: /scan # 激光雷达话题 - use_map_saver: true # 启用地图保存功能 - mode: mapping # mapping = 定位 + 实时建图(地图可更新) - - # ============================ 已有地图加载(在其基础上继续更新)========================== - # 启动时暂不加载(注释掉),通过服务在启动后手动加载: - # ros2 service call /slam_toolbox/deserialize_map slam_toolbox/srv/DeserializePoseGraph "{filename: '/home/guoch/test_ws/src/gc_navigation2_slamtoolbox/maps/my_map.posegraph', match_type: 1}" - # map_file_name: /home/guoch/test_ws/src/gc_navigation2_slamtoolbox/maps/my_map.posegraph - map_start_pose: [-2.0, -2.0, 0.0] # 初始位姿 [x, y, yaw](map 坐标系下) - # map_start_at_dock: true # 或从 docking 位姿启动(与 pose 互斥) - - # ============================ 调试与性能 =========================================== - debug_logging: false # 调试日志(生产环境关闭) - throttle_scans: 10 # 每 N 帧激光处理一次(1=全部处理) - transform_publish_period: 0.02 # TF 发布周期(秒),0=不发布里程计 - map_update_interval: 3.0 # /map 话题更新间隔(秒),越小越实时 - resolution: 0.05 # 地图分辨率(米/像素) - restamp_tf: false # 是否重新打时间戳 - min_laser_range: 0.0 # 激光最小有效距离(米) - max_laser_range: 20.0 # 激光最大有效距离(米) - minimum_time_interval: 0.5 # 最小处理时间间隔(秒) - transform_timeout: 0.2 # TF 查找超时(秒) - tf_buffer_duration: 30.0 # TF 缓冲区时长(秒) - stack_size_to_use: 40000000 # 栈大小(序列化大地图需要) - enable_interactive_mode: true # 交互模式:允许外部工具编辑地图 - - # ============================ 通用建图参数 ========================================= - use_scan_matching: true # 启用扫描匹配 - use_scan_barycenter: true # 使用扫描重心 - minimum_travel_distance: 0.1 # 最小移动距离触发处理(米) - minimum_travel_heading: 0.1 # 最小转向角度触发处理(弧度) - check_min_dist_and_heading_precisely: false - scan_buffer_size: 5 # 扫描缓冲区大小(越大匹配越稳定) - scan_buffer_maximum_scan_distance: 5.0 # 缓冲区最大扫描距离 - link_match_minimum_response_fine: 0.1 # 精细匹配最小响应 - link_scan_maximum_distance: 1.5 # 链接扫描最大距离 - - # ============================ 回环检测参数 ========================================= - do_loop_closing: true # 启用回环检测(消除累积误差) - loop_match_minimum_chain_size: 10 # 最小回环链大小 - loop_match_maximum_variance_coarse: 3.0 # 粗匹配最大方差 - loop_match_minimum_response_coarse: 0.35 # 粗匹配最小响应 - loop_match_minimum_response_fine: 0.45 # 精细匹配最小响应 - loop_search_maximum_distance: 3.0 # 回环搜索最大距离 - - # ============================ 相关性匹配 - 扫描匹配参数 ============================== - correlation_search_space_dimension: 0.5 # 搜索空间维度 - correlation_search_space_resolution: 0.01 # 搜索空间分辨率 - correlation_search_space_smear_deviation: 0.1 # 搜索空间平滑偏差 - - # ============================ 相关性匹配 - 回环检测参数 ============================== - loop_search_space_dimension: 8.0 # 回环搜索空间维度 - loop_search_space_resolution: 0.05 # 回环搜索分辨率 - loop_search_space_smear_deviation: 0.03 # 回环搜索平滑偏差 - - # ============================ 扫描匹配器参数 ======================================== - distance_variance_penalty: 0.5 # 距离方差惩罚 - angle_variance_penalty: 1.0 # 角度方差惩罚 - - fine_search_angle_offset: 0.00349 # 精细搜索角度偏移 - coarse_search_angle_offset: 0.349 # 粗搜索角度偏移 - coarse_angle_resolution: 0.0349 # 粗搜索角度分辨率 - minimum_angle_penalty: 0.9 # 最小角度惩罚 - minimum_distance_penalty: 0.5 # 最小距离惩罚 - use_response_expansion: true # 使用响应扩展 - min_pass_through: 2 # 最小通过次数 - occupancy_threshold: 0.1 # 占据阈值 diff --git a/src/gc_navigation2_slamtoolbox/config/slam_toolbox_localization.yaml b/src/gc_navigation2_slamtoolbox/config/slam_toolbox_localization.yaml deleted file mode 100644 index 56ef629..0000000 --- a/src/gc_navigation2_slamtoolbox/config/slam_toolbox_localization.yaml +++ /dev/null @@ -1,55 +0,0 @@ -slam_toolbox: - ros__parameters: - # 核心模式设置 - use_sim_time: true - mode: "localization" # 重要:设置为定位模式 - map_file_name: "" # 由启动参数传入 - map_start_pose: [0.0,0.0,0.0] - # ROS框架设置 - odom_frame: "odom" - map_frame: "map" - base_frame: "base_footprint" - scan_topic: "/scan" - - # 求解器设置 - solver_plugin: "solver_plugins::CeresSolver" - ceres_linear_solver: "SPARSE_NORMAL_CHOLESKY" - ceres_preconditioner: "SCHUR_JACOBI" - ceres_trust_strategy: "LEVENBERG_MARQUARDT" - ceres_dogleg_type: "TRADITIONAL_DOGLEG" - ceres_loss_function: "None" - - # 定位优化参数 - use_scan_matching: true - use_scan_barycenter: true - minimum_travel_distance: 0.05 - minimum_travel_heading: 0.087 - - # 扫描处理 - scan_buffer_size: 50 - throttle_scans: 2 - - # 回环检测(定位模式可关闭) - do_loop_closing: false - - # 搜索参数 - link_match_minimum_response_fine: 0.2 - link_scan_maximum_distance: 2.0 - loop_search_maximum_distance: 5.0 - - # 性能参数 - minimum_time_interval: 0.1 - transform_publish_period: 0.02 - map_update_interval: 0.5 - - # 地图参数 - resolution: 0.05 - max_laser_range: 15.0 - min_laser_range: 0.2 - - # 初始位姿(可选,可以通过RViz设置) - # map_start_pose: [0.0, 0.0, 0.0] - - # 调试 - debug_logging: false - enable_interactive_mode: true \ No newline at end of file diff --git a/src/gc_navigation2_slamtoolbox/config/slam_toolbox_mapping.yaml b/src/gc_navigation2_slamtoolbox/config/slam_toolbox_mapping.yaml deleted file mode 100644 index 44a3d68..0000000 --- a/src/gc_navigation2_slamtoolbox/config/slam_toolbox_mapping.yaml +++ /dev/null @@ -1,73 +0,0 @@ -slam_toolbox: - ros__parameters: - - # === Solver === - solver_plugin: solver_plugins::CeresSolver - ceres_linear_solver: SPARSE_NORMAL_CHOLESKY - ceres_preconditioner: SCHUR_JACOBI - ceres_trust_strategy: LEVENBERG_MARQUARDT - ceres_dogleg_type: TRADITIONAL_DOGLEG - ceres_loss_function: None - - # === ROS 基础 === - odom_frame: odom - map_frame: map - base_frame: base_link - scan_topic: /scan - mode: mapping - use_map_saver: true - - # === 调试与性能 === - debug_logging: false - throttle_scans: 1 - transform_publish_period: 0.02 - map_update_interval: 3.0 - resolution: 0.05 - min_laser_range: 0.15 - max_laser_range: 20.0 - minimum_time_interval: 0.5 - transform_timeout: 0.2 - tf_buffer_duration: 30.0 - stack_size_to_use: 40000000 - enable_interactive_mode: true - - # === 建图参数 === - use_scan_matching: true - use_scan_barycenter: true - minimum_travel_distance: 0.5 - minimum_travel_heading: 0.1 - scan_buffer_size: 10 - scan_buffer_maximum_scan_distance: 10.0 - link_match_minimum_response_fine: 0.1 - link_scan_maximum_distance: 1.5 - - # === 回环检测 === - do_loop_closing: true - loop_match_minimum_chain_size: 10 - loop_match_maximum_variance_coarse: 3.0 - loop_match_minimum_response_coarse: 0.35 - loop_match_minimum_response_fine: 0.45 - loop_search_maximum_distance: 3.0 - - # === 扫描匹配 === - correlation_search_space_dimension: 0.5 - correlation_search_space_resolution: 0.01 - correlation_search_space_smear_deviation: 0.1 - loop_search_space_dimension: 8.0 - loop_search_space_resolution: 0.05 - loop_search_space_smear_deviation: 0.03 - - # === 匹配器参数 === - distance_variance_penalty: 0.5 - angle_variance_penalty: 1.0 - fine_search_angle_offset: 0.00349 - coarse_search_angle_offset: 0.349 - coarse_angle_resolution: 0.0349 - minimum_angle_penalty: 0.9 - minimum_distance_penalty: 0.5 - use_response_expansion: true - min_pass_through: 2 - occupancy_threshold: 0.1 - - # MessageFilter queue size (default 1, too small for high-rate lidar) - scan_queue_size: 20 diff --git a/src/gc_navigation2_slamtoolbox/launch/gc_nav2_with_amcl.launch.py b/src/gc_navigation2_slamtoolbox/launch/gc_nav2_with_amcl.launch.py deleted file mode 100644 index a20c1b7..0000000 --- a/src/gc_navigation2_slamtoolbox/launch/gc_nav2_with_amcl.launch.py +++ /dev/null @@ -1,156 +0,0 @@ -# ============================================================================ -# gc_nav2_with_amcl.launch.py -# 功能:基于 AMCL(自适应蒙特卡洛定位)的导航启动文件 -# -# 架构: -# Gazebo 仿真环境 -# ├── robot_state_publisher — 发布机器人 TF 树(URDF 模型) -# └── nav2_bringup_launch — Nav2 一体化启动(包含以下子模块): -# ├── map_server — 加载 my_map.yaml,发布全量静态地图到 /map -# ├── AMCL — 粒子滤波定位,发布 map→odom TF -# │ 需要手动设置 /initialpose 初始位姿 -# ├── planner_server — 全局/局部路径规划器(SmacHybrid) -# ├── controller_server — 路径跟踪控制器(MPPI Ackermann) -# ├── behavior_server — 恢复行为服务器(spin/backup/wait) -# └── bt_navigator — 行为树导航编排器 -# -# 与 SLAM 定位方案的区别: -# AMCL: 粒子滤波定位,需要手动设置初始位姿,地图固定不更新 -# SLAM定位: 激光扫描匹配定位,自动定位,可加载 .posegraph 序列化地图 -# ============================================================================ - -import os -from ament_index_python.packages import get_package_share_directory -from launch import LaunchDescription -from launch.actions import IncludeLaunchDescription, DeclareLaunchArgument, TimerAction -from launch.launch_description_sources import PythonLaunchDescriptionSource -from launch.substitutions import LaunchConfiguration -from launch_ros.actions import Node -from launch_ros.parameter_descriptions import ParameterValue -from launch.substitutions import Command -from launch.actions import ExecuteProcess - - -def generate_launch_description(): - """生成 LaunchDescription,启动 Gazebo + AMCL定位 + Nav2 导航""" - ld = LaunchDescription() - - # =============================1.定位到包的地址============================================================= - # 通过 ament_index 获取各功能包的安装路径 - gc_navigation_fish_dir = get_package_share_directory( - 'gc_navigation2_slamtoolbox') - nav2_bringup_dir = get_package_share_directory('nav2_bringup') - origincar_urdf_dir = get_package_share_directory( - 'origincar_description') - - # =============================2.声明参数,获取配置文件路径=================================================== - # use_sim_time: 仿真时间开关。Gazebo 下必须为 True, - # 因为仿真环境通过 /clock 话题提供时间,而非系统时间 - use_sim_time = LaunchConfiguration('use_sim_time', default='true') - - # map_yaml_path: 全量静态地图 yaml 文件路径 - # 传给 bringup_launch → map_server 加载并发布到 /map - map_yaml_path = LaunchConfiguration('map', default=os.path.join( - gc_navigation_fish_dir, 'maps', 'my_map.yaml')) - - # nav2_param_path: Nav2 导航栈参数文件(含 AMCL 粒子滤波配置) - # 注意:此处用 gc_navigation_amcl.yaml,包含 AMCL 参数(粒子数、运动模型等) - # SLAM 方案则用 gc_navigation_slam.yaml(不含 AMCL) - nav2_param_path = LaunchConfiguration('params_file', default=os.path.join( - gc_navigation_fish_dir, 'params', 'gc_navigation_amcl.yaml')) - - # =============================3.声明启动launch文件========================================================== - # bringup_launch.py 是 Nav2 的一体化启动入口,内部自动处理: - # 1. 声明所有 launch 参数(map, slam, use_sim_time, params_file 等) - # 2. 根据 slam 参数决定启动模式: - # slam=False(默认)→ localization_launch(map_server + AMCL) - # slam=True → slam_launch(slam_toolbox 在线建图) - # 3. 启动 navigation_launch(planner + controller + behavior + bt_navigator) - # 4. 通过 RewrittenYaml 实现参数文件中的变量替换 - # - # 传入参数: - # map: 地图 yaml 文件路径(map_server 加载,AMCL 定位) - # use_sim_time: 仿真时间模式(Gazebo 下必须为 true) - # params_file: Nav2 全部节点的参数配置 - nav2_bringup_launch = IncludeLaunchDescription( - PythonLaunchDescriptionSource( - [nav2_bringup_dir, '/launch', '/bringup_launch.py']), - launch_arguments={ - 'map': map_yaml_path, - 'use_sim_time': use_sim_time, - 'params_file': nav2_param_path}.items(), - ) - - # =============================4.Gazebo仿真设置========================================================== - # robot_name_in_model: Gazebo 中机器人的模型名称,需与 URDF 中一致 - robot_name_in_model = 'mycar' - - # default_model_path: 机器人 URDF 模型文件路径 - # 使用 xacro 宏展开生成最终的 URDF - default_model_path = os.path.join( - origincar_urdf_dir, "urdf", "origincar.urdf") - - # 声明 model 启动参数,支持命令行覆盖:ros2 launch ... model:=/path/to/custom.urdf - model = DeclareLaunchArgument( - name="model", default_value=default_model_path) - - # Gazebo 仿真世界文件路径 - gazebo_world_path = os.path.join(origincar_urdf_dir, 'world/test.world') - - # 启动 Gazebo 仿真器进程 - # --verbose: 输出详细日志 - # -s libgazebo_ros_init.so: 加载 ROS ↔ Gazebo 通信初始化插件 - # -s libgazebo_ros_factory.so: 加载模型生成(spawn_entity)插件 - start_gazebo_cmd = ExecuteProcess( - cmd=['gazebo', '--verbose', '-s', 'libgazebo_ros_init.so', - '-s', 'libgazebo_ros_factory.so', gazebo_world_path], - output='screen') - - # 在 Gazebo 世界中生成机器人模型 - # -entity: 模型在 Gazebo 中的实例名(mycar) - # -file: 要加载的 URDF 模型文件 - # 生成后 Gazebo 会为模型创建对应的关节状态话题等 - spawn_entity_cmd = Node( - package='gazebo_ros', - executable='spawn_entity.py', - arguments=['-entity', robot_name_in_model, - '-file', default_model_path], - output='screen' - ) - - # robot_description: 将 XACRO/URDF 模型字符串设为 ROS 参数 - # robot_state_publisher 读取此参数发布各连杆的 TF 坐标变换 - robot_description = ParameterValue( - Command(["xacro ", LaunchConfiguration("model")]), value_type=str) - - # robot_state_publisher: 发布机器人各关节、连杆的 TF 变换 - # - 订阅 joint_states 话题获取关节角度 - # - 根据 URDF 模型计算 base_link → laser_link, wheel_link 等变换 - # - publish_frequency=30Hz 确保 TF 更新平滑 - # - use_sim_time=True 使用 /clock 仿真时间 - robot_state_publisher = Node( - package="robot_state_publisher", - executable="robot_state_publisher", - parameters=[{"robot_description": robot_description, - 'use_sim_time': True, 'publish_frequency': 30.0}] - ) - - # joint_state_publisher: 发布非固定关节的默认状态 - # 如果 Gazebo 已经发布 joint_states,此节点可以注释掉避免冲突 - # joint_state_publisher = Node( - # package="joint_state_publisher", - # executable="joint_state_publisher" - # ) - - # =============================5.将所有 Action 添加到 LaunchDescription ================================== - # 注意:nav2_bringup_launch 必须在 Gazebo 启动之后, - # 否则会出现 /clock 话题未就绪的问题 - # 可通过 TimerAction 添加延迟,或依赖 launch 系统的自动排序 - ld.add_action(model) # 1. 声明模型路径参数 - ld.add_action(nav2_bringup_launch) # 2. 启动 Nav2 一体化(map_server + AMCL + 导航) - ld.add_action(start_gazebo_cmd) # 3. 启动 Gazebo 仿真器 - ld.add_action(spawn_entity_cmd) # 4. 在 Gazebo 中生成机器人 - ld.add_action(robot_state_publisher) # 5. 发布机器人 TF 树 - # ld.add_action(joint_state_publisher) # 6. (可选) 默认关节状态发布 - - return ld diff --git a/src/gc_navigation2_slamtoolbox/launch/gc_nav2_with_slam.launch.py b/src/gc_navigation2_slamtoolbox/launch/gc_nav2_with_slam.launch.py deleted file mode 100644 index a896429..0000000 --- a/src/gc_navigation2_slamtoolbox/launch/gc_nav2_with_slam.launch.py +++ /dev/null @@ -1,196 +0,0 @@ -# ============================================================================ -# gc_nav2_with_slam.launch.py -# 功能:基于 slam_toolbox 定位的导航启动文件 -# -# 架构: -# Gazebo 仿真环境 -# ├── robot_state_publisher — 发布机器人 TF 树(URDF 模型) -# ├── map_server — 加载 my_map.yaml,发布全量静态地图到 /map -# ├── slam_toolbox — 加载 my_map.posegraph,激光扫描匹配定位 -# │ 发布 map→odom TF,替代 AMCL 的粒子滤波 -# │ ⚠️ /map 话题重映射为 /slam_map,避免冲突 -# └── navigation_launch — Nav2 导航栈(路径规划 + 运动控制) -# global_costmap 从 /map 获取全量静态地图 -# -# 与 AMCL 方案的区别: -# AMCL: 粒子滤波定位,需要手动设置初始位姿 -# SLAM定位: 激光扫描匹配定位,自动根据地图特征定位 -# ============================================================================ - -import os -from ament_index_python.packages import get_package_share_directory -from launch import LaunchDescription -from launch.actions import IncludeLaunchDescription, DeclareLaunchArgument -from launch.launch_description_sources import PythonLaunchDescriptionSource -from launch.substitutions import LaunchConfiguration -from launch_ros.actions import Node -from launch_ros.parameter_descriptions import ParameterValue -from launch.substitutions import Command -from launch.actions import ExecuteProcess - - -def generate_launch_description(): - """生成 LaunchDescription,启动 Gazebo + SLAM定位 + Nav2 导航""" - ld = LaunchDescription() - - # =============================1.定位到包的地址============================================================= - # 通过 ament_index 获取各功能包的安装路径 - pkg_dir = get_package_share_directory('gc_navigation2_slamtoolbox') - nav2_bringup_dir = get_package_share_directory('nav2_bringup') - origincar_urdf_dir = get_package_share_directory('origincar_description') - - # =============================2.声明参数=============================================================== - # use_sim_time: 仿真时间开关。Gazebo 下必须为 True, - # 因为仿真环境通过 /clock 话题提供时间,而非系统时间 - use_sim_time = LaunchConfiguration('use_sim_time', default='true') - - # map_yaml_path: 全量静态地图 yaml 文件路径 - # 由 map_server 加载,发布到 /map 供 global_costmap 使用 - map_yaml_path = LaunchConfiguration('map', default=os.path.join( - pkg_dir, 'maps', 'my_map.yaml')) - - # nav2_param_path: Nav2 导航栈参数文件(不含 AMCL,含 slam_toolbox) - nav2_param_path = LaunchConfiguration('params_file', default=os.path.join( - pkg_dir, 'params', 'gc_navigation_slam.yaml')) - - # slam_params_file: slam_toolbox 定位模式的参数文件 - # mode: localization — 只定位不建图 - # 包含 solver 配置、激光匹配参数、TF 帧定义等 - slam_params_file = os.path.join( - pkg_dir, 'config', 'mapper_params_localization.yaml') - - # posegraph_path: slam_toolbox 定位所需的序列化地图文件 - # .posegraph 文件保存了 slam_toolbox 建图时的位姿图 - # 配合 .data 文件,slam_toolbox 可以还原完整地图用于激光匹配 - posegraph_path = os.path.join( - pkg_dir, 'maps', 'my_map.posegraph') - - # =============================3.slam_toolbox 定位模式(替代 AMCL)========================================= - # localization_slam_toolbox_node: - # - 加载 .posegraph 序列化地图用于激光扫描匹配 - # - 发布 map→odom 坐标变换(替代 AMCL 的粒子滤波定位) - # - 发布 /pose 话题(当前定位位姿) - # - # ⚠️ 关键:将 slam_toolbox 的 /map 重映射为 /slam_map - # 避免覆盖 map_server 发布到 /map 的全量静态地图 - # 确保 global_costmap 的 static_layer 能获取完整地图边界 - slam_toolbox_node = Node( - package='slam_toolbox', - executable='localization_slam_toolbox_node', - name='slam_toolbox', - output='screen', - parameters=[slam_params_file, - {'use_sim_time': True, - 'map_file_name': posegraph_path}], - remappings=[('/map', '/slam_map')], - ) - - # =============================4.map_server 提供全量静态地图给 global_costmap ============================= - # map_server: - # - 加载 my_map.yaml + my_map.pgm 格式的传统静态地图 - # - 发布完整地图到 /map 话题(199×266 像素,分辨率 0.05 m) - # - 这是 global_costmap 静态层的唯一数据来源 - # - 是 lifecycle 节点,需要 lifecycle_manager 激活 - map_server_node = Node( - package='nav2_map_server', - executable='map_server', - name='map_server', - output='screen', - parameters=[{'yaml_filename': map_yaml_path, - 'use_sim_time': True}], - ) - - # lifecycle_manager: 管理 map_server 的生命周期(configure → activate) - # autostart=True 表示启动后自动激活 map_server - map_server_lifecycle = Node( - package='nav2_lifecycle_manager', - executable='lifecycle_manager', - name='lifecycle_manager_map', - output='screen', - parameters=[{'use_sim_time': True, - 'autostart': True, - 'node_names': ['map_server']}], - ) - - # =============================5.仅启动 nav2 navigation(不含 localization)================================= - # 为什么用 navigation_launch 而不是 bringup_launch? - # bringup_launch 包含 localization_launch(AMCL + map_server) - # 由于 slam_toolbox 已经替代了 AMCL,只需 navigation_launch 的: - # - planner_server — 全局/局部路径规划 - # - controller_server — 路径跟踪控制(MPPI) - # - behavior_server — 行为树(spin/backup/wait 恢复) - # - bt_navigator — 行为树导航编排 - # - costmap 层 — global_costmap + local_costmap - navigation_launch = IncludeLaunchDescription( - PythonLaunchDescriptionSource( - [nav2_bringup_dir, '/launch', '/navigation_launch.py']), - launch_arguments={ - 'use_sim_time': use_sim_time, - 'params_file': nav2_param_path}.items(), - ) - - # =============================6.Gazebo仿真设置========================================================== - # robot_name_in_model: Gazebo 中机器人的模型名称,需与 URDF 中一致 - robot_name_in_model = 'mycar' - - # default_model_path: 机器人 URDF 模型文件路径 - # 使用 xacro 预处理生成最终的 URDF - default_model_path = os.path.join( - origincar_urdf_dir, "urdf", "origincar.urdf") - - # 声明 model 启动参数,支持命令行覆盖 URDF 路径 - model = DeclareLaunchArgument( - name="model", default_value=default_model_path) - - # Gazebo 世界文件路径 - gazebo_world_path = os.path.join(origincar_urdf_dir, 'world/test.world') - - # 启动 Gazebo 仿真器 - # --verbose: 详细日志输出 - # -s libgazebo_ros_init.so: 加载 ROS-Gazebo 初始化插件 - # -s libgazebo_ros_factory.so: 加载模型生成插件 - start_gazebo_cmd = ExecuteProcess( - cmd=['gazebo', '--verbose', '-s', 'libgazebo_ros_init.so', - '-s', 'libgazebo_ros_factory.so', gazebo_world_path], - output='screen') - - # 在 Gazebo 中生成机器人模型 - # -entity: 模型实例名称 - # -file: URDF 模型文件 - spawn_entity_cmd = Node( - package='gazebo_ros', - executable='spawn_entity.py', - arguments=['-entity', robot_name_in_model, - '-file', default_model_path], - output='screen' - ) - - # robot_description: 将 URDF/XACRO 模型转换为 ROS 参数 - # robot_state_publisher 订阅此参数发布 TF 树 - robot_description = ParameterValue( - Command(["xacro ", LaunchConfiguration("model")]), value_type=str) - - # robot_state_publisher: 发布机器人各连杆的 TF 变换 - # base_link → laser_link, wheel_link 等关节状态 - # publish_frequency=30Hz 保证平滑的 TF 更新 - robot_state_publisher = Node( - package="robot_state_publisher", - executable="robot_state_publisher", - parameters=[{"robot_description": robot_description, - 'use_sim_time': True, 'publish_frequency': 30.0}] - ) - - # =============================7.将所有 Action 添加到 LaunchDescription ================================== - # 启动顺序由 Launch 系统自动管理依赖 - ld.add_action(model) # 1. 声明模型参数 - ld.add_action(start_gazebo_cmd) # 2. 启动 Gazebo 仿真器 - ld.add_action(spawn_entity_cmd) # 3. 生成机器人模型 - ld.add_action(robot_state_publisher) # 4. 发布 TF 树 - ld.add_action(map_server_node) # 5. 加载全量静态地图 → /map - ld.add_action(map_server_lifecycle) # 6. 激活 map_server - ld.add_action(slam_toolbox_node) # 7. 启动 SLAM 定位 → map→odom TF - ld.add_action(navigation_launch) # 8. 启动 Nav2 导航栈 - - return ld - - diff --git a/src/gc_navigation2_slamtoolbox/launch/gc_nav2_with_slam_online.launch.py b/src/gc_navigation2_slamtoolbox/launch/gc_nav2_with_slam_online.launch.py deleted file mode 100644 index c2020d6..0000000 --- a/src/gc_navigation2_slamtoolbox/launch/gc_nav2_with_slam_online.launch.py +++ /dev/null @@ -1,181 +0,0 @@ -# ============================================================================ -# gc_nav2_with_slam_online.launch.py -# 功能:已知全局地图 + SLAM 在线更新 + 导航 -# -# 架构: -# ┌─ /map(全量静态地图,199×266) -# map_server ──────────┤ -# └─ 来自 my_map.yaml + my_map.pgm -# -# ┌─ map→odom TF(激光扫描匹配定位) -# slam_toolbox ────────┤ -# (async mapping) └─ /slam_map(实时建图结果,重映射避免冲突) -# -# navigation ┌─ global_costmap/static_layer ← /map(全量地图) -# ├─ local_costmap/obstacle_layer ← /scan(实时避障) -# └─ planner + controller + behavior -# -# 关键设计: -# 1. map_server 提供全量静态底图 → Foxglove 中看到完整房间布局 -# 2. slam_toolbox 定位 + 实时建图,/slam_map 可单独查看更新效果 -# 3. 实时避障通过 costmap 的 obstacle_layer 实现(不依赖地图更新) -# 4. 定期调用 /slam_toolbox/serialize_map 保存更新后的地图 -# ============================================================================ - -import os -from ament_index_python.packages import get_package_share_directory -from launch import LaunchDescription -from launch.actions import IncludeLaunchDescription, DeclareLaunchArgument, SetEnvironmentVariable -from launch.launch_description_sources import PythonLaunchDescriptionSource -from launch.substitutions import LaunchConfiguration -from launch_ros.actions import Node -from launch_ros.parameter_descriptions import ParameterValue -from launch.substitutions import Command -from launch.actions import ExecuteProcess - - -def generate_launch_description(): - """启动 Gazebo + 已知全局地图 + SLAM 在线定位建图 + Nav2 导航""" - ld = LaunchDescription() - - # =============================1.包路径================================================================ - pkg_dir = get_package_share_directory('gc_navigation2_slamtoolbox') - nav2_bringup_dir = get_package_share_directory('nav2_bringup') - origincar_urdf_dir = get_package_share_directory('origincar_description') - - # =============================2.参数================================================================== - use_sim_time = LaunchConfiguration('use_sim_time', default='true') - map_yaml_path = os.path.join(pkg_dir, 'maps', 'zhihui.yaml') - nav2_param_path = LaunchConfiguration('params_file', default=os.path.join( - pkg_dir, 'params', 'gc_navigation_slam.yaml')) - slam_params_file = os.path.join(pkg_dir, 'config', 'slam_toolbox_async.yaml') - posegraph_path = os.path.join(pkg_dir, 'maps', 'zhihui.posegraph') - - # =============================3.map_server:全量静态地图(Foxglove 看到的全局地图)======================== - map_server_node = Node( - package='nav2_map_server', - executable='map_server', - name='map_server', - output='screen', - parameters=[{'yaml_filename': map_yaml_path, 'use_sim_time': True}], - ) - map_server_lifecycle = Node( - package='nav2_lifecycle_manager', - executable='lifecycle_manager', - name='lifecycle_manager_map', - output='screen', - parameters=[{'use_sim_time': True, 'autostart': True, - 'node_names': ['map_server']}], - ) - - # =============================4.slam_toolbox:定位 + 实时建图============================================= - # ⚠️ /map 重映射到 /slam_map,避免覆盖 map_server 的全量地图 - slam_toolbox_node = Node( - package='slam_toolbox', - executable='async_slam_toolbox_node', - name='slam_toolbox', - output='screen', - parameters=[slam_params_file, {'use_sim_time': True}], - remappings=[('/map', '/slam_map')], - ) - - # =============================5.加载已有序列化地图======================================================= - # 通过 ros2 service call 在 slam_toolbox 启动后加载 - import launch - load_map_cmd = ExecuteProcess( - cmd=[ - 'bash', '-c', - # 等待 slam_toolbox 服务就绪后加载地图 - 'sleep 8 && ' - 'ros2 service call /slam_toolbox/deserialize_map ' - 'slam_toolbox/srv/DeserializePoseGraph ' - "'{filename: \"%s\", match_type: 1}'" % posegraph_path, - ], - output='screen', - ) - - # =============================6.Nav2 导航栈============================================================ - navigation_launch = IncludeLaunchDescription( - PythonLaunchDescriptionSource( - [nav2_bringup_dir, '/launch', '/navigation_launch.py']), - launch_arguments={ - 'use_sim_time': use_sim_time, - 'params_file': nav2_param_path, - }.items(), - ) - - # =============================7.Gazebo 仿真============================================================ - robot_name_in_model = 'mycar' - default_model_path = os.path.join(origincar_urdf_dir, 'urdf', 'origincar.urdf') - model = DeclareLaunchArgument(name='model', default_value=default_model_path) - gazebo_world_path = os.path.join(origincar_urdf_dir, 'world', 'zhihui.world') - start_gazebo_cmd = ExecuteProcess( - cmd=['gazebo', '--verbose', - '-s', 'libgazebo_ros_init.so', - '-s', 'libgazebo_ros_factory.so', - gazebo_world_path], - output='screen', - ) - - # =============================7a.机器人初始位姿参数===================================================== - # 通过命令行参数覆盖,例如: - # ros2 launch ... spawn_x:=1.0 spawn_y:=-2.0 spawn_yaw:=1.57 - spawn_x = LaunchConfiguration('spawn_x', default='-4.311092') - spawn_y = LaunchConfiguration('spawn_y', default='-4.299756') - spawn_z = LaunchConfiguration('spawn_z', default='0.0') - spawn_yaw = LaunchConfiguration('spawn_yaw', default='0.0') - - set_spawn_x = SetEnvironmentVariable('SPAWN_X', spawn_x) - set_spawn_y = SetEnvironmentVariable('SPAWN_Y', spawn_y) - set_spawn_z = SetEnvironmentVariable('SPAWN_Z', spawn_z) - set_spawn_yaw = SetEnvironmentVariable('SPAWN_YAW', spawn_yaw) - - # =============================7b.在 Gazebo 中生成机器人================================================= - # 通过 bash 读取环境变量,确保位姿参数正确传递 - spawn_entity_cmd = ExecuteProcess( - cmd=['bash', '-c', - 'ros2 run gazebo_ros spawn_entity.py ' - '-entity mycar ' - f'-file {default_model_path} ' - '-x $SPAWN_X -y $SPAWN_Y -z $SPAWN_Z -Y $SPAWN_YAW'], - output='screen', - ) - - robot_description = ParameterValue( - Command(['xacro ', LaunchConfiguration('model')]), value_type=str, - ) - robot_state_publisher = Node( - package='robot_state_publisher', - executable='robot_state_publisher', - parameters=[{'robot_description': robot_description, - 'use_sim_time': True, 'publish_frequency': 30.0}], - ) - - # =============================8.组装================================================================== - ld.add_action(model) - ld.add_action(DeclareLaunchArgument( - 'spawn_x', default_value='-4.311092', - description='机器人初始 x 坐标(m)')) - ld.add_action(DeclareLaunchArgument( - 'spawn_y', default_value='-4.299756', - description='机器人初始 y 坐标(m)')) - ld.add_action(DeclareLaunchArgument( - 'spawn_z', default_value='0.0', - description='机器人初始 z 坐标(m)')) - ld.add_action(DeclareLaunchArgument( - 'spawn_yaw', default_value='0.0', - description='机器人初始偏航角(rad)')) - ld.add_action(start_gazebo_cmd) - ld.add_action(set_spawn_x) - ld.add_action(set_spawn_y) - ld.add_action(set_spawn_z) - ld.add_action(set_spawn_yaw) - ld.add_action(spawn_entity_cmd) - ld.add_action(robot_state_publisher) - ld.add_action(map_server_node) - ld.add_action(map_server_lifecycle) - ld.add_action(slam_toolbox_node) - ld.add_action(load_map_cmd) - ld.add_action(navigation_launch) - - return ld diff --git a/src/gc_navigation2_slamtoolbox/launch/gc_nav2_with_slam_online_real.launch.py b/src/gc_navigation2_slamtoolbox/launch/gc_nav2_with_slam_online_real.launch.py deleted file mode 100644 index 4a684fb..0000000 --- a/src/gc_navigation2_slamtoolbox/launch/gc_nav2_with_slam_online_real.launch.py +++ /dev/null @@ -1,73 +0,0 @@ -# ============================================================================ -# gc_nav2_with_slam_online_real.launch.py -# 功能:真机实时建图 — slam_toolbox 从零建图 + Nav2 导航 -# 依赖:需先启动 origincar_bringup(底盘驱动 + EKF) -# ============================================================================ - -import os -from ament_index_python.packages import get_package_share_directory -from launch import LaunchDescription -from launch.actions import IncludeLaunchDescription, DeclareLaunchArgument -from launch.launch_description_sources import PythonLaunchDescriptionSource -from launch.substitutions import LaunchConfiguration -from launch_ros.actions import Node -from launch_ros.parameter_descriptions import ParameterValue -from launch.substitutions import Command - - -def generate_launch_description(): - """真机实时建图:slam_toolbox 从零建图 + Nav2 导航""" - ld = LaunchDescription() - - # === 1. 包路径 === - pkg_dir = get_package_share_directory('gc_navigation2_slamtoolbox') - nav2_bringup_dir = get_package_share_directory('nav2_bringup') - origincar_urdf_dir = get_package_share_directory('origincar_description') - - # === 2. 参数 === - use_sim_time = LaunchConfiguration('use_sim_time', default='false') - nav2_param_path = LaunchConfiguration('params_file', default=os.path.join( - pkg_dir, 'params', 'gc_navigation_slam.yaml')) - slam_params_file = os.path.join(pkg_dir, 'config', 'slam_toolbox_mapping.yaml') - - # === 3. slam_toolbox:实时建图 → 发布 map→odom === - slam_toolbox_node = Node( - package='slam_toolbox', - executable='async_slam_toolbox_node', - name='slam_toolbox', - output='screen', - parameters=[slam_params_file, - {'use_sim_time': use_sim_time}], - ) - - # === 4. Nav2 导航栈 === - navigation_launch = IncludeLaunchDescription( - PythonLaunchDescriptionSource( - [nav2_bringup_dir, '/launch', '/navigation_launch.py']), - launch_arguments={ - 'use_sim_time': use_sim_time, - 'params_file': nav2_param_path, - }.items(), - ) - - # === 5. 机器人模型(URDF 已定义 base_footprint→base_link,无需 static TF)=== - model = DeclareLaunchArgument( - name='model', - default_value=os.path.join(origincar_urdf_dir, 'urdf', 'origincar.urdf')) - - robot_description = ParameterValue( - Command(['xacro ', LaunchConfiguration('model')]), value_type=str) - robot_state_publisher = Node( - package='robot_state_publisher', - executable='robot_state_publisher', - parameters=[{'robot_description': robot_description, - 'use_sim_time': use_sim_time, 'publish_frequency': 30.0}], - ) - - # === 6. 组装 === - ld.add_action(model) - ld.add_action(robot_state_publisher) - ld.add_action(slam_toolbox_node) - ld.add_action(navigation_launch) - - return ld diff --git a/src/gc_navigation2_slamtoolbox/launch/gc_nav_slamtoolbox_lifelong.launch.py b/src/gc_navigation2_slamtoolbox/launch/gc_nav_slamtoolbox_lifelong.launch.py deleted file mode 100644 index f1f8042..0000000 --- a/src/gc_navigation2_slamtoolbox/launch/gc_nav_slamtoolbox_lifelong.launch.py +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/env python3 -from launch import LaunchDescription -from launch_ros.actions import Node -from ament_index_python.packages import get_package_share_directory -import os - - -def generate_launch_description(): - # 获取参数文件路径 - pkg_share = get_package_share_directory('gc_navigation2_slamtoolbox') - params_file = os.path.join( - pkg_share, 'config', 'mapper_params_lifelong.yaml') - - # 创建SLAM Toolbox节点 - slam_toolbox_node = Node( - package='slam_toolbox', - executable='async_slam_toolbox_node', # 或 sync_slam_toolbox_node - name='slam_toolbox', - output='screen', - parameters=[params_file] - ) - - return LaunchDescription([ - slam_toolbox_node - ]) diff --git a/src/gc_navigation2_slamtoolbox/launch/gc_nav_slamtoolbox_location.launch.py b/src/gc_navigation2_slamtoolbox/launch/gc_nav_slamtoolbox_location.launch.py deleted file mode 100644 index 63f180e..0000000 --- a/src/gc_navigation2_slamtoolbox/launch/gc_nav_slamtoolbox_location.launch.py +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/env python3 -from launch import LaunchDescription -from launch_ros.actions import Node -from ament_index_python.packages import get_package_share_directory -import os - - -def generate_launch_description(): - # 获取参数文件路径 - pkg_share = get_package_share_directory('gc_navigation2_slamtoolbox') - params_file = os.path.join( - pkg_share, 'config', 'mapper_params_localization.yaml') - - # 创建SLAM Toolbox节点 - slam_toolbox_node = Node( - package='slam_toolbox', - executable='localization_slam_toolbox_node', # 或 sync_slam_toolbox_node - name='slam_toolbox', - output='screen', - parameters=[params_file] - ) - - return LaunchDescription([ - slam_toolbox_node - ]) diff --git a/src/gc_navigation2_slamtoolbox/launch/gc_nav_slamtoolbox_on_async.launch.py b/src/gc_navigation2_slamtoolbox/launch/gc_nav_slamtoolbox_on_async.launch.py deleted file mode 100644 index 6f6ccfb..0000000 --- a/src/gc_navigation2_slamtoolbox/launch/gc_nav_slamtoolbox_on_async.launch.py +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/env python3 -from launch import LaunchDescription -from launch_ros.actions import Node -from ament_index_python.packages import get_package_share_directory -import os - - -def generate_launch_description(): - # 获取参数文件路径 - pkg_share = get_package_share_directory('gc_navigation2_slamtoolbox') - params_file = os.path.join( - pkg_share, 'config', 'mapper_params_online_async.yaml') - - # 创建SLAM Toolbox节点 - slam_toolbox_node = Node( - package='slam_toolbox', - executable='async_slam_toolbox_node', # 或 sync_slam_toolbox_node - name='slam_toolbox', - output='screen', - parameters=[params_file] - ) - - return LaunchDescription([ - slam_toolbox_node - ]) diff --git a/src/gc_navigation2_slamtoolbox/launch/gc_slam_mapping.launch.py b/src/gc_navigation2_slamtoolbox/launch/gc_slam_mapping.launch.py deleted file mode 100644 index 1247175..0000000 --- a/src/gc_navigation2_slamtoolbox/launch/gc_slam_mapping.launch.py +++ /dev/null @@ -1,196 +0,0 @@ -#!/usr/bin/env python3 -# ============================================================================ -# gc_slam_mapping.launch.py -# 功能:Gazebo 仿真环境 + SLAM 建图启动文件 -# -# 适用场景: -# - 在 Gazebo 仿真中遥控机器人建立环境地图 -# - 在已有地图基础上增量更新 -# - 单独调试 slam_toolbox 建图参数 -# -# 架构: -# Gazebo 仿真器 — 加载 zhihui.world(智慧楼墙体环境) -# spawn_entity — 在 Gazebo 中生成机器人模型 -# robot_state_publisher — 发布机器人 TF 树(URDF 模型) -# joint_state_publisher — 发布关节状态 -# async_slam_toolbox_node — 激光 SLAM 建图(mapping 模式) -# 发布 map→odom TF -# 发布 /map 话题(实时地图) -# -# 使用方式: -# ros2 launch gc_navigation2_slamtoolbox gc_slam_mapping.launch.py -# -# 保存地图: -# ros2 service call /slam_toolbox/serialize_map slam_toolbox/srv/SerializePoseGraph \ -# "{filename: '/home/guoch/test_ws/src/gc_navigation2_slamtoolbox/maps/my_map'}" -# ros2 run nav2_map_server map_saver_cli -f -# ============================================================================ - -import os -from ament_index_python.packages import get_package_share_directory -from launch import LaunchDescription -from launch.actions import DeclareLaunchArgument, ExecuteProcess, SetEnvironmentVariable -from launch.substitutions import LaunchConfiguration -from launch_ros.actions import Node -from launch_ros.parameter_descriptions import ParameterValue -from launch.substitutions import Command - - -def generate_launch_description(): - """生成 LaunchDescription,启动 Gazebo + slam_toolbox 建图""" - - # ============================ 1. 包路径 ========================================= - pkg_dir = get_package_share_directory('gc_navigation2_slamtoolbox') - origincar_urdf_dir = get_package_share_directory('origincar_description') - - # ============================ 2. 声明启动参数 ==================================== - use_sim_time = LaunchConfiguration('use_sim_time', default='true') - - # slam_params_file: slam_toolbox 配置文件 - slam_params_file = LaunchConfiguration( - 'slam_params_file', - default=os.path.join(pkg_dir, 'config', 'slam_toolbox_async.yaml')) - - # map_file_name: 可选,加载已有序列化地图继续建图 - map_file_name = LaunchConfiguration('map_file_name', default='') - - # model: 机器人 URDF 模型路径(用于 xacro 处理) - # origincar.urdf 是纯 URDF(不含 xacro 宏),xacro 会原样透传 - default_model_path = os.path.join( - origincar_urdf_dir, 'urdf', 'origincar.urdf') - model = DeclareLaunchArgument( - name='model', default_value=default_model_path) - - # spawn_model: Gazebo 中生成机器人用的 URDF(不含 xacro 宏) - spawn_model_path = os.path.join( - origincar_urdf_dir, 'urdf', 'origincar.urdf') - - # ============================ 3. 设置 GAZEBO_MODEL_PATH ========================== - # 让 Gazebo 能找到 zhihui 模型,同时保留标准模型路径 - gazebo_model_path = os.path.join(pkg_dir, 'world') - existing_gazebo_path = os.environ.get('GAZEBO_MODEL_PATH', '') - if existing_gazebo_path: - full_gazebo_path = f'{gazebo_model_path}:{existing_gazebo_path}' - else: - full_gazebo_path = gazebo_model_path - set_gazebo_model_path = SetEnvironmentVariable( - name='GAZEBO_MODEL_PATH', - value=full_gazebo_path - ) - - # ============================ 4. 启动 Gazebo 仿真器 ============================== - gazebo_world_path = os.path.join(pkg_dir, 'world', 'zhihui.world') - start_gazebo_cmd = ExecuteProcess( - cmd=['gazebo', '--verbose', - '-s', 'libgazebo_ros_init.so', - '-s', 'libgazebo_ros_factory.so', - gazebo_world_path], - output='screen' - ) - - # ============================ 5. 机器人初始位姿参数 ============================== - # 通过命令行参数覆盖,例如: - # ros2 launch ... spawn_x:=1.0 spawn_y:=-2.0 spawn_yaw:=1.57 - spawn_x = LaunchConfiguration('spawn_x', default='-4.311092') - spawn_y = LaunchConfiguration('spawn_y', default='-4.299756') - spawn_z = LaunchConfiguration('spawn_z', default='0.0') - spawn_yaw = LaunchConfiguration('spawn_yaw', default='0.0') - - # 将位姿参数设为环境变量,供 spawn 命令使用 - set_spawn_x = SetEnvironmentVariable('SPAWN_X', spawn_x) - set_spawn_y = SetEnvironmentVariable('SPAWN_Y', spawn_y) - set_spawn_z = SetEnvironmentVariable('SPAWN_Z', spawn_z) - set_spawn_yaw = SetEnvironmentVariable('SPAWN_YAW', spawn_yaw) - - # ============================ 6. 在 Gazebo 中生成机器人 ========================== - # 通过 bash 读取环境变量,确保位姿参数正确传递 - robot_name_in_model = 'mycar' - spawn_entity_cmd = ExecuteProcess( - cmd=['bash', '-c', - 'ros2 run gazebo_ros spawn_entity.py ' - '-entity mycar ' - f'-file {spawn_model_path} ' - '-x $SPAWN_X -y $SPAWN_Y -z $SPAWN_Z -Y $SPAWN_YAW'], - output='screen' - ) - - # ============================ 7. robot_state_publisher =========================== - robot_description = ParameterValue( - Command(['xacro ', LaunchConfiguration('model')]), - value_type=str - ) - robot_state_publisher_node = Node( - package='robot_state_publisher', - executable='robot_state_publisher', - name='robot_state_publisher', - output='screen', - parameters=[{ - 'robot_description': robot_description, - 'use_sim_time': True, - 'publish_frequency': 30.0, - }], - ) - - # ============================ 8. joint_state_publisher =========================== - joint_state_publisher_node = Node( - package='joint_state_publisher', - executable='joint_state_publisher', - name='joint_state_publisher', - output='screen', - parameters=[{'use_sim_time': use_sim_time}], - ) - - # ============================ 9. slam_toolbox 建图节点 ============================ - slam_toolbox_node = Node( - package='slam_toolbox', - executable='async_slam_toolbox_node', - name='slam_toolbox', - output='screen', - parameters=[ - slam_params_file, - { - 'use_sim_time': use_sim_time, - 'map_file_name': map_file_name, - }, - ], - ) - - # ============================ 10. 组装 LaunchDescription ========================= - return LaunchDescription([ - DeclareLaunchArgument( - 'use_sim_time', - default_value='true', - description='使用仿真时间(Gazebo=true, 实车=false)'), - DeclareLaunchArgument( - 'slam_params_file', - default_value=os.path.join(pkg_dir, 'config', 'slam_toolbox_async.yaml'), - description='slam_toolbox 参数配置文件路径'), - DeclareLaunchArgument( - 'map_file_name', - default_value='', - description='已有序列化地图路径(.posegraph),留空则从零开始建图'), - DeclareLaunchArgument( - 'spawn_x', default_value='-4.311092', - description='机器人初始 x 坐标(m)'), - DeclareLaunchArgument( - 'spawn_y', default_value='-4.299756', - description='机器人初始 y 坐标(m)'), - DeclareLaunchArgument( - 'spawn_z', default_value='0.0', - description='机器人初始 z 坐标(m)'), - DeclareLaunchArgument( - 'spawn_yaw', default_value='0.0', - description='机器人初始偏航角(rad)'), - model, - - set_gazebo_model_path, - set_spawn_x, - set_spawn_y, - set_spawn_z, - set_spawn_yaw, - start_gazebo_cmd, - spawn_entity_cmd, - robot_state_publisher_node, - joint_state_publisher_node, - slam_toolbox_node, - ]) diff --git a/src/gc_navigation2_slamtoolbox/maps/my_map.data b/src/gc_navigation2_slamtoolbox/maps/my_map.data deleted file mode 100644 index 68c09b6..0000000 Binary files a/src/gc_navigation2_slamtoolbox/maps/my_map.data and /dev/null differ diff --git a/src/gc_navigation2_slamtoolbox/maps/my_map.pgm b/src/gc_navigation2_slamtoolbox/maps/my_map.pgm deleted file mode 100644 index 809a0ed..0000000 Binary files a/src/gc_navigation2_slamtoolbox/maps/my_map.pgm and /dev/null differ diff --git a/src/gc_navigation2_slamtoolbox/maps/my_map.posegraph b/src/gc_navigation2_slamtoolbox/maps/my_map.posegraph deleted file mode 100644 index 34c432a..0000000 Binary files a/src/gc_navigation2_slamtoolbox/maps/my_map.posegraph and /dev/null differ diff --git a/src/gc_navigation2_slamtoolbox/maps/my_map.yaml b/src/gc_navigation2_slamtoolbox/maps/my_map.yaml deleted file mode 100644 index d5afba9..0000000 --- a/src/gc_navigation2_slamtoolbox/maps/my_map.yaml +++ /dev/null @@ -1,7 +0,0 @@ -image: my_map.pgm -mode: trinary -resolution: 0.05 -origin: [-2.15, -5.81, 0] -negate: 0 -occupied_thresh: 0.65 -free_thresh: 0.25 \ No newline at end of file diff --git a/src/gc_navigation2_slamtoolbox/maps/zhihui.data b/src/gc_navigation2_slamtoolbox/maps/zhihui.data deleted file mode 100644 index 31d30e4..0000000 Binary files a/src/gc_navigation2_slamtoolbox/maps/zhihui.data and /dev/null differ diff --git a/src/gc_navigation2_slamtoolbox/maps/zhihui.pgm b/src/gc_navigation2_slamtoolbox/maps/zhihui.pgm deleted file mode 100644 index 9a4fc43..0000000 Binary files a/src/gc_navigation2_slamtoolbox/maps/zhihui.pgm and /dev/null differ diff --git a/src/gc_navigation2_slamtoolbox/maps/zhihui.posegraph b/src/gc_navigation2_slamtoolbox/maps/zhihui.posegraph deleted file mode 100644 index 5e49a17..0000000 Binary files a/src/gc_navigation2_slamtoolbox/maps/zhihui.posegraph and /dev/null differ diff --git a/src/gc_navigation2_slamtoolbox/maps/zhihui.yaml b/src/gc_navigation2_slamtoolbox/maps/zhihui.yaml deleted file mode 100644 index 43ed9c8..0000000 --- a/src/gc_navigation2_slamtoolbox/maps/zhihui.yaml +++ /dev/null @@ -1,7 +0,0 @@ -image: zhihui.pgm -mode: trinary -resolution: 0.05 -origin: [-4.98, -4.71, 0] -negate: 0 -occupied_thresh: 0.65 -free_thresh: 0.25 \ No newline at end of file diff --git a/src/gc_navigation2_slamtoolbox/package.xml b/src/gc_navigation2_slamtoolbox/package.xml deleted file mode 100644 index 5bea8eb..0000000 --- a/src/gc_navigation2_slamtoolbox/package.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - gc_navigation2_slamtoolbox - 0.0.0 - TODO: Package description - guoch - TODO: License declaration - - ament_cmake - - ament_lint_auto - ament_lint_common - - - ament_cmake - - diff --git a/src/gc_navigation2_slamtoolbox/params/gc_navigation_amcl.yaml b/src/gc_navigation2_slamtoolbox/params/gc_navigation_amcl.yaml deleted file mode 100644 index 867a16a..0000000 --- a/src/gc_navigation2_slamtoolbox/params/gc_navigation_amcl.yaml +++ /dev/null @@ -1,413 +0,0 @@ -amcl: - ros__parameters: - use_sim_time: True - alpha1: 0.2 - alpha2: 0.2 - alpha3: 0.2 - alpha4: 0.2 - alpha5: 0.2 - base_frame_id: "base_link" - beam_skip_distance: 0.5 - beam_skip_error_threshold: 0.9 - beam_skip_threshold: 0.3 - do_beamskip: false - global_frame_id: "map" - lambda_short: 0.1 - laser_likelihood_max_dist: 2.0 - laser_max_range: 100.0 - laser_min_range: -1.0 - laser_model_type: "likelihood_field" - max_beams: 60 - max_particles: 2000 - min_particles: 500 - odom_frame_id: "odom" - pf_err: 0.05 - pf_z: 0.99 - recovery_alpha_fast: 0.0 - recovery_alpha_slow: 0.0 - resample_interval: 1 - robot_model_type: "nav2_amcl::DifferentialMotionModel" - save_pose_rate: 0.5 - sigma_hit: 0.2 - tf_broadcast: true - transform_tolerance: 10.0 - update_min_a: 0.2 - update_min_d: 0.25 - z_hit: 0.5 - z_max: 0.05 - z_rand: 0.5 - z_short: 0.05 - scan_topic: scan - -amcl_map_client: - ros__parameters: - use_sim_time: True - -amcl_rclcpp_node: - ros__parameters: - use_sim_time: True - -bt_navigator: - ros__parameters: - use_sim_time: True - global_frame: map - robot_base_frame: base_link - odom_topic: /odom - bt_loop_duration: 20 - default_server_timeout: 20 - # 'default_nav_through_poses_bt_xml' and 'default_nav_to_pose_bt_xml' are use defaults: - # nav2_bt_navigator/navigate_to_pose_w_replanning_and_recovery.xml - # nav2_bt_navigator/navigate_through_poses_w_replanning_and_recovery.xml - # They can be set here or via a RewrittenYaml remap from a parent launch file to Nav2. - plugin_lib_names: - - nav2_compute_path_to_pose_action_bt_node - - nav2_compute_path_through_poses_action_bt_node - - nav2_smooth_path_action_bt_node - - nav2_follow_path_action_bt_node - - nav2_spin_action_bt_node - - nav2_wait_action_bt_node - - nav2_back_up_action_bt_node - - nav2_drive_on_heading_bt_node - - nav2_clear_costmap_service_bt_node - - nav2_is_stuck_condition_bt_node - - nav2_goal_reached_condition_bt_node - - nav2_goal_updated_condition_bt_node - - nav2_globally_updated_goal_condition_bt_node - - nav2_is_path_valid_condition_bt_node - - nav2_initial_pose_received_condition_bt_node - - nav2_reinitialize_global_localization_service_bt_node - - nav2_rate_controller_bt_node - - nav2_distance_controller_bt_node - - nav2_speed_controller_bt_node - - nav2_truncate_path_action_bt_node - - nav2_truncate_path_local_action_bt_node - - nav2_goal_updater_node_bt_node - - nav2_recovery_node_bt_node - - nav2_pipeline_sequence_bt_node - - nav2_round_robin_node_bt_node - - nav2_transform_available_condition_bt_node - - nav2_time_expired_condition_bt_node - - nav2_path_expiring_timer_condition - - nav2_distance_traveled_condition_bt_node - - nav2_single_trigger_bt_node - - nav2_is_battery_low_condition_bt_node - - nav2_navigate_through_poses_action_bt_node - - nav2_navigate_to_pose_action_bt_node - - nav2_remove_passed_goals_action_bt_node - - nav2_planner_selector_bt_node - - nav2_controller_selector_bt_node - - nav2_goal_checker_selector_bt_node - - nav2_controller_cancel_bt_node - - nav2_path_longer_on_approach_bt_node - - nav2_wait_cancel_bt_node - - nav2_spin_cancel_bt_node - - nav2_back_up_cancel_bt_node - - nav2_drive_on_heading_cancel_bt_node - -bt_navigator_rclcpp_node: - ros__parameters: - use_sim_time: True - -controller_server: - ros__parameters: - use_sim_time: True - controller_frequency: 30.0 - FollowPath: - plugin: "nav2_mppi_controller::MPPIController" - time_steps: 56 - model_dt: 0.05 - batch_size: 2000 - vx_std: 0.2 - vy_std: 0.0 - wz_std: 0.4 - vx_max: 0.5 - vx_min: -0.35 - vy_max: 0.0 - wz_max: 1.9 - iteration_count: 1 - temperature: 0.3 - gamma: 0.015 - motion_model: "Ackermann" - visualize: false - TrajectoryVisualizer: - trajectory_step: 5 - time_step: 3 - AckermannConstraints: - min_turning_r: 0.4 - critics: ["ConstraintCritic", "CostCritic", "GoalCritic", "GoalAngleCritic", "PathAlignCritic", "PathFollowCritic", "PathAngleCritic", "PreferForwardCritic"] - ConstraintCritic: - enabled: true - cost_power: 1 - cost_weight: 4.0 - GoalCritic: - enabled: true - cost_power: 1 - cost_weight: 5.0 - threshold_to_consider: 1.4 - GoalAngleCritic: - enabled: true - cost_power: 1 - cost_weight: 3.0 - threshold_to_consider: 0.5 - PreferForwardCritic: - enabled: true - cost_power: 1 - cost_weight: 5.0 - threshold_to_consider: 0.5 - # Option to replace Cost and use Obstacles instead - # ObstaclesCritic: - # enabled: true - # cost_power: 1 - # repulsion_weight: 1.5 - # critical_weight: 20.0 - # consider_footprint: false - # collision_cost: 10000.0 - # collision_margin_distance: 0.1 - # near_goal_distance: 0.5 - CostCritic: - enabled: true - cost_power: 1 - cost_weight: 3.81 - critical_cost: 300.0 - consider_footprint: true - collision_cost: 1000000.0 - near_goal_distance: 1.0 - trajectory_point_step: 2 - PathAlignCritic: - enabled: true - cost_power: 1 - cost_weight: 14.0 - max_path_occupancy_ratio: 0.05 - trajectory_point_step: 4 - threshold_to_consider: 0.5 - offset_from_furthest: 20 - use_path_orientations: false - PathFollowCritic: - enabled: true - cost_power: 1 - cost_weight: 5.0 - offset_from_furthest: 5 - threshold_to_consider: 1.4 - PathAngleCritic: - enabled: true - cost_power: 1 - cost_weight: 2.0 - offset_from_furthest: 4 - threshold_to_consider: 0.5 - max_angle_to_furthest: 1.0 - forward_preference: true - # VelocityDeadbandCritic: - # enabled: true - # cost_power: 1 - # cost_weight: 35.0 - # deadband_velocities: [0.05, 0.05, 0.05] - # TwirlingCritic: - # enabled: true - # twirling_cost_power: 1 - # twirling_cost_weight: 10.0 - -controller_server_rclcpp_node: - ros__parameters: - use_sim_time: True - -local_costmap: - local_costmap: - ros__parameters: - update_frequency: 5.0 - publish_frequency: 2.0 - transform_tolerance: 0.5 - global_frame: odom - robot_base_frame: base_link - use_sim_time: True - rolling_window: true - width: 3 - height: 3 - resolution: 0.05 - footprint: "[[0.14, 0.085], - [0.14, -0.085], - [-0.14, -0.085], - [-0.14, 0.085]]" - footprint_padding: 0.02 - plugins: ["voxel_layer", "inflation_layer"] - inflation_layer: - plugin: "nav2_costmap_2d::InflationLayer" - cost_scaling_factor: 3.0 - inflation_radius: 0.55 - voxel_layer: - plugin: "nav2_costmap_2d::VoxelLayer" - enabled: True - publish_voxel_map: True - origin_z: 0.0 - z_resolution: 0.05 - z_voxels: 16 - max_obstacle_height: 2.0 - mark_threshold: 0 - observation_sources: scan - scan: - topic: /scan - max_obstacle_height: 2.0 - clearing: True - marking: True - data_type: "LaserScan" - raytrace_max_range: 3.0 - raytrace_min_range: 0.0 - obstacle_max_range: 2.5 - obstacle_min_range: 0.0 - static_layer: - map_subscribe_transient_local: True - always_send_full_costmap: True - local_costmap_client: - ros__parameters: - use_sim_time: True - local_costmap_rclcpp_node: - ros__parameters: - use_sim_time: True - -global_costmap: - global_costmap: - ros__parameters: - use_sim_time: True - transform_tolerance: 0.5 - update_frequency: 1.0 - publish_frequency: 1.0 - global_frame: map - robot_base_frame: base_link - use_sim_time: True - footprint: "[[0.14, 0.085], - [0.14, -0.085], - [-0.14, -0.085], - [-0.14, 0.085]]" - footprint_padding: 0.02 - resolution: 0.05 - track_unknown_space: true - plugins: ["static_layer", "obstacle_layer", "inflation_layer"] - obstacle_layer: - plugin: "nav2_costmap_2d::ObstacleLayer" - enabled: True - observation_sources: scan - scan: - topic: /scan - max_obstacle_height: 2.0 - clearing: True - marking: True - data_type: "LaserScan" - raytrace_max_range: 3.0 - raytrace_min_range: 0.0 - obstacle_max_range: 2.5 - obstacle_min_range: 0.0 - static_layer: - plugin: "nav2_costmap_2d::StaticLayer" - map_subscribe_transient_local: True - inflation_layer: - plugin: "nav2_costmap_2d::InflationLayer" - cost_scaling_factor: 3.0 - inflation_radius: 0.55 - always_send_full_costmap: True - global_costmap_client: - ros__parameters: - use_sim_time: True - global_costmap_rclcpp_node: - ros__parameters: - use_sim_time: True - -map_server: - ros__parameters: - use_sim_time: True - yaml_filename: "turtlebot3_world.yaml" - -map_saver: - ros__parameters: - use_sim_time: True - save_map_timeout: 5.0 - free_thresh_default: 0.25 - occupied_thresh_default: 0.65 - map_subscribe_transient_local: True - -planner_server: - ros__parameters: - planner_plugins: ["GridBased"] - use_sim_time: True - - GridBased: - plugin: "nav2_smac_planner/SmacPlannerHybrid" - downsample_costmap: false # whether or not to downsample the map - downsampling_factor: 1 # multiplier for the resolution of the costmap layer (e.g. 2 on a 5cm costmap would be 10cm) - tolerance: 0.25 # dist-to-goal heuristic cost (distance) for valid tolerance endpoints if exact goal cannot be found. - allow_unknown: true # allow traveling in unknown space - max_iterations: 1000000 # maximum total iterations to search for before failing (in case unreachable), set to -1 to disable - max_on_approach_iterations: 1000 # Maximum number of iterations after within tolerances to continue to try to find exact solution - max_planning_time: 5.0 # max time in s for planner to plan, smooth - motion_model_for_search: "REEDS_SHEPP" # or REEDS_SHEPP 可以倒车 - angle_quantization_bins: 72 # Number of angle bins for search - analytic_expansion_ratio: 3.5 # The ratio to attempt analytic expansions during search for final approach. - analytic_expansion_max_length: 3.0 # For Hybrid/Lattice nodes: The maximum length of the analytic expansion to be considered valid to prevent unsafe shortcutting - minimum_turning_radius: 0.40 # minimum turning radius in m of path / vehicle - reverse_penalty: 2.0 # Penalty to apply if motion is reversing, must be => 1 - change_penalty: 0.0 # Penalty to apply if motion is changing directions (L to R), must be >= 0 - non_straight_penalty: 1.2 # Penalty to apply if motion is non-straight, must be => 1 - cost_penalty: 2.0 # Penalty to apply to higher cost areas when adding into the obstacle map dynamic programming distance expansion heuristic. This drives the robot more towards the center of passages. A value between 1.3 - 3.5 is reasonable. - retrospective_penalty: 0.015 - lookup_table_size: 20.0 # Size of the dubin/reeds-sheep distance window to cache, in meters. - cache_obstacle_heuristic: false # Cache the obstacle map dynamic programming distance expansion heuristic between subsiquent replannings of the same goal location. Dramatically speeds up replanning performance (40x) if costmap is largely static. - viz_expansions: false # For Hybrid nodes: Whether to publish expansions on the /expansions topic as an array of poses (the orientation has no meaning). WARNING: heavy to compute and to display, for debug only as it degrades the performance. - smooth_path: True # If true, does a simple and quick smoothing post-processing to the path - - smoother: - max_iterations: 1000 - w_smooth: 0.3 - w_data: 0.2 - tolerance: 1.0e-10 - do_refinement: true - refinement_num: 2 - -planner_server_rclcpp_node: - ros__parameters: - use_sim_time: True - -smoother_server: - ros__parameters: - use_sim_time: True - smoother_plugins: ["simple_smoother"] - simple_smoother: - plugin: "nav2_smoother::SimpleSmoother" - tolerance: 1.0e-10 - max_its: 1000 - do_refinement: True - -behavior_server: - ros__parameters: - costmap_topic: local_costmap/costmap_raw - footprint_topic: local_costmap/published_footprint - cycle_frequency: 10.0 - behavior_plugins: ["spin", "backup", "wait"] - spin: - plugin: "nav2_behaviors/Spin" - backup: - plugin: "nav2_behaviors/BackUp" - # drive_on_heading: - # plugin: "nav2_behaviors/DriveOnHeading" - wait: - plugin: "nav2_behaviors/Wait" - global_frame: odom - robot_base_frame: base_link - transform_tolerance: 0.5 - use_sim_time: True - simulate_ahead_time: 2.0 - max_rotational_vel: 1.0 - min_rotational_vel: 0.4 - rotational_acc_lim: 3.2 - -robot_state_publisher: - ros__parameters: - use_sim_time: True - -waypoint_follower: - ros__parameters: - loop_rate: 20 - use_sim_time: True - stop_on_failure: false - waypoint_task_executor_plugin: "wait_at_waypoint" - wait_at_waypoint: - plugin: "nav2_waypoint_follower::WaitAtWaypoint" - enabled: True - waypoint_pause_duration: 200 diff --git a/src/gc_navigation2_slamtoolbox/params/gc_navigation_slam.yaml b/src/gc_navigation2_slamtoolbox/params/gc_navigation_slam.yaml deleted file mode 100644 index 1384445..0000000 --- a/src/gc_navigation2_slamtoolbox/params/gc_navigation_slam.yaml +++ /dev/null @@ -1,343 +0,0 @@ -slam_toolbox: - ros__parameters: - use_sim_time: False - -bt_navigator: - ros__parameters: - use_sim_time: False - global_frame: map - robot_base_frame: base_footprint - odom_topic: /odom - bt_loop_duration: 50 - default_server_timeout: 20 - # 阿克曼底盘专用 BT:移除 Spin,恢复行为 = 清代价地图 → 后退 → 等待 - default_nav_to_pose_bt_xml: /home/sunrise/yiliao_ws/install/gc_navigation2_slamtoolbox/share/gc_navigation2_slamtoolbox/config/nav_to_pose_ackermann.xml - plugin_lib_names: - - nav2_compute_path_to_pose_action_bt_node - - nav2_compute_path_through_poses_action_bt_node - - nav2_smooth_path_action_bt_node - - nav2_follow_path_action_bt_node - - nav2_spin_action_bt_node - - nav2_wait_action_bt_node - - nav2_back_up_action_bt_node - - nav2_drive_on_heading_bt_node - - nav2_clear_costmap_service_bt_node - - nav2_is_stuck_condition_bt_node - - nav2_goal_reached_condition_bt_node - - nav2_goal_updated_condition_bt_node - - nav2_globally_updated_goal_condition_bt_node - - nav2_is_path_valid_condition_bt_node - - nav2_initial_pose_received_condition_bt_node - - nav2_reinitialize_global_localization_service_bt_node - - nav2_rate_controller_bt_node - - nav2_distance_controller_bt_node - - nav2_speed_controller_bt_node - - nav2_truncate_path_action_bt_node - - nav2_truncate_path_local_action_bt_node - - nav2_goal_updater_node_bt_node - - nav2_recovery_node_bt_node - - nav2_pipeline_sequence_bt_node - - nav2_round_robin_node_bt_node - - nav2_transform_available_condition_bt_node - - nav2_time_expired_condition_bt_node - - nav2_path_expiring_timer_condition - - nav2_distance_traveled_condition_bt_node - - nav2_single_trigger_bt_node - - nav2_is_battery_low_condition_bt_node - - nav2_navigate_through_poses_action_bt_node - - nav2_navigate_to_pose_action_bt_node - - nav2_remove_passed_goals_action_bt_node - - nav2_planner_selector_bt_node - - nav2_controller_selector_bt_node - - nav2_goal_checker_selector_bt_node - - nav2_controller_cancel_bt_node - - nav2_path_longer_on_approach_bt_node - - nav2_wait_cancel_bt_node - - nav2_spin_cancel_bt_node - - nav2_back_up_cancel_bt_node - - nav2_drive_on_heading_cancel_bt_node - -bt_navigator_rclcpp_node: - ros__parameters: - use_sim_time: False - -controller_server: - ros__parameters: - use_sim_time: False - controller_frequency: 20.0 - FollowPath: - plugin: "nav2_mppi_controller::MPPIController" - time_steps: 36 - model_dt: 0.05 - batch_size: 1000 - vx_std: 0.2 - vy_std: 0.0 - wz_std: 0.4 - vx_max: 0.5 - vx_min: -0.35 - vy_max: 0.0 - wz_max: 1.9 - iteration_count: 1 - temperature: 0.3 - gamma: 0.015 - motion_model: "Ackermann" - visualize: false - TrajectoryVisualizer: - trajectory_step: 5 - time_step: 3 - AckermannConstraints: - min_turning_r: 0.4 - critics: ["ConstraintCritic", "CostCritic", "GoalCritic", "GoalAngleCritic", "PathAlignCritic", "PathFollowCritic", "PathAngleCritic", "PreferForwardCritic"] - ConstraintCritic: - enabled: true - cost_power: 1 - cost_weight: 4.0 - GoalCritic: - enabled: true - cost_power: 1 - cost_weight: 5.0 - threshold_to_consider: 1.4 - GoalAngleCritic: - enabled: true - cost_power: 1 - cost_weight: 3.0 - threshold_to_consider: 0.5 - PreferForwardCritic: - enabled: true - cost_power: 1 - cost_weight: 5.0 - threshold_to_consider: 0.5 - CostCritic: - enabled: true - cost_power: 1 - cost_weight: 3.81 - critical_cost: 300.0 - consider_footprint: true - collision_cost: 1000000.0 - near_goal_distance: 1.0 - trajectory_point_step: 2 - PathAlignCritic: - enabled: true - cost_power: 1 - cost_weight: 14.0 - max_path_occupancy_ratio: 0.05 - trajectory_point_step: 4 - threshold_to_consider: 0.5 - offset_from_furthest: 20 - use_path_orientations: false - PathFollowCritic: - enabled: true - cost_power: 1 - cost_weight: 5.0 - offset_from_furthest: 5 - threshold_to_consider: 1.4 - PathAngleCritic: - enabled: true - cost_power: 1 - cost_weight: 2.0 - offset_from_furthest: 4 - threshold_to_consider: 0.5 - max_angle_to_furthest: 1.0 - forward_preference: true - -controller_server_rclcpp_node: - ros__parameters: - use_sim_time: False - -local_costmap: - local_costmap: - ros__parameters: - update_frequency: 5.0 - publish_frequency: 2.0 - transform_tolerance: 0.5 - global_frame: odom - robot_base_frame: base_link - use_sim_time: False - rolling_window: true - width: 3 - height: 3 - resolution: 0.05 - footprint: "[[0.14, 0.085], - [0.14, -0.085], - [-0.14, -0.085], - [-0.14, 0.085]]" - footprint_padding: 0.02 - plugins: ["voxel_layer", "inflation_layer"] - inflation_layer: - plugin: "nav2_costmap_2d::InflationLayer" - cost_scaling_factor: 3.0 - inflation_radius: 0.55 - voxel_layer: - plugin: "nav2_costmap_2d::VoxelLayer" - enabled: True - publish_voxel_map: True - origin_z: 0.0 - z_resolution: 0.05 - z_voxels: 16 - max_obstacle_height: 2.0 - mark_threshold: 0 - observation_sources: scan - scan: - topic: /scan - max_obstacle_height: 2.0 - clearing: True - marking: True - data_type: "LaserScan" - raytrace_max_range: 3.0 - raytrace_min_range: 0.0 - obstacle_max_range: 2.5 - obstacle_min_range: 0.0 - static_layer: - map_subscribe_transient_local: True - always_send_full_costmap: True - local_costmap_client: - ros__parameters: - use_sim_time: False - local_costmap_rclcpp_node: - ros__parameters: - use_sim_time: False - -global_costmap: - global_costmap: - ros__parameters: - use_sim_time: False - transform_tolerance: 0.5 - update_frequency: 1.0 - publish_frequency: 1.0 - global_frame: map - robot_base_frame: base_link - use_sim_time: False - footprint: "[[0.14, 0.085], - [0.14, -0.085], - [-0.14, -0.085], - [-0.14, 0.085]]" - footprint_padding: 0.02 - resolution: 0.05 - track_unknown_space: true - plugins: ["static_layer", "obstacle_layer", "inflation_layer"] - obstacle_layer: - plugin: "nav2_costmap_2d::ObstacleLayer" - enabled: True - observation_sources: scan - scan: - topic: /scan - max_obstacle_height: 2.0 - clearing: True - marking: True - data_type: "LaserScan" - raytrace_max_range: 3.0 - raytrace_min_range: 0.0 - obstacle_max_range: 2.5 - obstacle_min_range: 0.0 - static_layer: - plugin: "nav2_costmap_2d::StaticLayer" - map_subscribe_transient_local: True - inflation_layer: - plugin: "nav2_costmap_2d::InflationLayer" - cost_scaling_factor: 3.0 - inflation_radius: 0.55 - always_send_full_costmap: True - global_costmap_client: - ros__parameters: - use_sim_time: False - global_costmap_rclcpp_node: - ros__parameters: - use_sim_time: False - -map_saver: - ros__parameters: - use_sim_time: False - save_map_timeout: 5.0 - free_thresh_default: 0.25 - occupied_thresh_default: 0.65 - map_subscribe_transient_local: True - -planner_server: - ros__parameters: - planner_plugins: ["GridBased"] - use_sim_time: False - - GridBased: - plugin: "nav2_smac_planner/SmacPlannerHybrid" - downsample_costmap: false - downsampling_factor: 1 - tolerance: 0.25 - allow_unknown: true - max_iterations: 1000000 - max_on_approach_iterations: 1000 - max_planning_time: 5.0 - motion_model_for_search: "REEDS_SHEPP" - angle_quantization_bins: 72 - analytic_expansion_ratio: 3.5 - analytic_expansion_max_length: 3.0 - minimum_turning_radius: 0.40 - reverse_penalty: 1.3 # 后退惩罚,越小越愿意后退(默认 2.0,设为 1.3 允许灵活倒车) - change_penalty: 0.0 - non_straight_penalty: 1.2 - cost_penalty: 2.0 - retrospective_penalty: 0.015 - lookup_table_size: 20.0 - cache_obstacle_heuristic: false - viz_expansions: false - smooth_path: True - - smoother: - max_iterations: 1000 - w_smooth: 0.3 - w_data: 0.2 - tolerance: 1.0e-10 - do_refinement: true - refinement_num: 2 - -planner_server_rclcpp_node: - ros__parameters: - use_sim_time: False - -smoother_server: - ros__parameters: - use_sim_time: False - smoother_plugins: ["simple_smoother"] - simple_smoother: - plugin: "nav2_smoother::SimpleSmoother" - tolerance: 1.0e-10 - max_its: 1000 - do_refinement: True - -behavior_server: - ros__parameters: - costmap_topic: local_costmap/costmap_raw - footprint_topic: local_costmap/published_footprint - cycle_frequency: 10.0 - behavior_plugins: ["spin", "backup", "wait"] - spin: - plugin: "nav2_behaviors/Spin" # 需保留以匹配默认 BT XML - backup: - plugin: "nav2_behaviors/BackUp" - backup_dist: 0.8 - backup_speed: 0.18 - wait: - plugin: "nav2_behaviors/Wait" - wait_duration: 0.5 - global_frame: odom - robot_base_frame: base_link - transform_tolerance: 0.5 - use_sim_time: False - simulate_ahead_time: 2.0 - max_rotational_vel: 1.0 - min_rotational_vel: 0.4 - rotational_acc_lim: 3.2 - -robot_state_publisher: - ros__parameters: - use_sim_time: False - -waypoint_follower: - ros__parameters: - loop_rate: 20 - use_sim_time: False - stop_on_failure: false - waypoint_task_executor_plugin: "wait_at_waypoint" - wait_at_waypoint: - plugin: "nav2_waypoint_follower::WaitAtWaypoint" - enabled: True - waypoint_pause_duration: 200 diff --git a/src/gc_navigation2_slamtoolbox/params/gc_navigation_slam.yaml.bak b/src/gc_navigation2_slamtoolbox/params/gc_navigation_slam.yaml.bak deleted file mode 100644 index 31f37c5..0000000 --- a/src/gc_navigation2_slamtoolbox/params/gc_navigation_slam.yaml.bak +++ /dev/null @@ -1,343 +0,0 @@ -slam_toolbox: - ros__parameters: - use_sim_time: True - -bt_navigator: - ros__parameters: - use_sim_time: True - global_frame: map - robot_base_frame: base_footprint - odom_topic: /odom - bt_loop_duration: 50 - default_server_timeout: 20 - # 阿克曼底盘专用 BT:移除 Spin,恢复行为 = 清代价地图 → 后退 → 等待 - default_nav_to_pose_bt_xml: /home/guoch/test_ws/install/gc_navigation2_slamtoolbox/share/gc_navigation2_slamtoolbox/config/nav_to_pose_ackermann.xml - plugin_lib_names: - - nav2_compute_path_to_pose_action_bt_node - - nav2_compute_path_through_poses_action_bt_node - - nav2_smooth_path_action_bt_node - - nav2_follow_path_action_bt_node - - nav2_spin_action_bt_node - - nav2_wait_action_bt_node - - nav2_back_up_action_bt_node - - nav2_drive_on_heading_bt_node - - nav2_clear_costmap_service_bt_node - - nav2_is_stuck_condition_bt_node - - nav2_goal_reached_condition_bt_node - - nav2_goal_updated_condition_bt_node - - nav2_globally_updated_goal_condition_bt_node - - nav2_is_path_valid_condition_bt_node - - nav2_initial_pose_received_condition_bt_node - - nav2_reinitialize_global_localization_service_bt_node - - nav2_rate_controller_bt_node - - nav2_distance_controller_bt_node - - nav2_speed_controller_bt_node - - nav2_truncate_path_action_bt_node - - nav2_truncate_path_local_action_bt_node - - nav2_goal_updater_node_bt_node - - nav2_recovery_node_bt_node - - nav2_pipeline_sequence_bt_node - - nav2_round_robin_node_bt_node - - nav2_transform_available_condition_bt_node - - nav2_time_expired_condition_bt_node - - nav2_path_expiring_timer_condition - - nav2_distance_traveled_condition_bt_node - - nav2_single_trigger_bt_node - - nav2_is_battery_low_condition_bt_node - - nav2_navigate_through_poses_action_bt_node - - nav2_navigate_to_pose_action_bt_node - - nav2_remove_passed_goals_action_bt_node - - nav2_planner_selector_bt_node - - nav2_controller_selector_bt_node - - nav2_goal_checker_selector_bt_node - - nav2_controller_cancel_bt_node - - nav2_path_longer_on_approach_bt_node - - nav2_wait_cancel_bt_node - - nav2_spin_cancel_bt_node - - nav2_back_up_cancel_bt_node - - nav2_drive_on_heading_cancel_bt_node - -bt_navigator_rclcpp_node: - ros__parameters: - use_sim_time: True - -controller_server: - ros__parameters: - use_sim_time: True - controller_frequency: 20.0 - FollowPath: - plugin: "nav2_mppi_controller::MPPIController" - time_steps: 36 - model_dt: 0.05 - batch_size: 1000 - vx_std: 0.2 - vy_std: 0.0 - wz_std: 0.4 - vx_max: 0.5 - vx_min: -0.35 - vy_max: 0.0 - wz_max: 1.9 - iteration_count: 1 - temperature: 0.3 - gamma: 0.015 - motion_model: "Ackermann" - visualize: false - TrajectoryVisualizer: - trajectory_step: 5 - time_step: 3 - AckermannConstraints: - min_turning_r: 0.4 - critics: ["ConstraintCritic", "CostCritic", "GoalCritic", "GoalAngleCritic", "PathAlignCritic", "PathFollowCritic", "PathAngleCritic", "PreferForwardCritic"] - ConstraintCritic: - enabled: true - cost_power: 1 - cost_weight: 4.0 - GoalCritic: - enabled: true - cost_power: 1 - cost_weight: 5.0 - threshold_to_consider: 1.4 - GoalAngleCritic: - enabled: true - cost_power: 1 - cost_weight: 3.0 - threshold_to_consider: 0.5 - PreferForwardCritic: - enabled: true - cost_power: 1 - cost_weight: 5.0 - threshold_to_consider: 0.5 - CostCritic: - enabled: true - cost_power: 1 - cost_weight: 3.81 - critical_cost: 300.0 - consider_footprint: true - collision_cost: 1000000.0 - near_goal_distance: 1.0 - trajectory_point_step: 2 - PathAlignCritic: - enabled: true - cost_power: 1 - cost_weight: 14.0 - max_path_occupancy_ratio: 0.05 - trajectory_point_step: 4 - threshold_to_consider: 0.5 - offset_from_furthest: 20 - use_path_orientations: false - PathFollowCritic: - enabled: true - cost_power: 1 - cost_weight: 5.0 - offset_from_furthest: 5 - threshold_to_consider: 1.4 - PathAngleCritic: - enabled: true - cost_power: 1 - cost_weight: 2.0 - offset_from_furthest: 4 - threshold_to_consider: 0.5 - max_angle_to_furthest: 1.0 - forward_preference: true - -controller_server_rclcpp_node: - ros__parameters: - use_sim_time: True - -local_costmap: - local_costmap: - ros__parameters: - update_frequency: 5.0 - publish_frequency: 2.0 - transform_tolerance: 0.5 - global_frame: odom - robot_base_frame: base_link - use_sim_time: True - rolling_window: true - width: 3 - height: 3 - resolution: 0.05 - footprint: "[[0.14, 0.085], - [0.14, -0.085], - [-0.14, -0.085], - [-0.14, 0.085]]" - footprint_padding: 0.02 - plugins: ["voxel_layer", "inflation_layer"] - inflation_layer: - plugin: "nav2_costmap_2d::InflationLayer" - cost_scaling_factor: 3.0 - inflation_radius: 0.55 - voxel_layer: - plugin: "nav2_costmap_2d::VoxelLayer" - enabled: True - publish_voxel_map: True - origin_z: 0.0 - z_resolution: 0.05 - z_voxels: 16 - max_obstacle_height: 2.0 - mark_threshold: 0 - observation_sources: scan - scan: - topic: /scan - max_obstacle_height: 2.0 - clearing: True - marking: True - data_type: "LaserScan" - raytrace_max_range: 3.0 - raytrace_min_range: 0.0 - obstacle_max_range: 2.5 - obstacle_min_range: 0.0 - static_layer: - map_subscribe_transient_local: True - always_send_full_costmap: True - local_costmap_client: - ros__parameters: - use_sim_time: True - local_costmap_rclcpp_node: - ros__parameters: - use_sim_time: True - -global_costmap: - global_costmap: - ros__parameters: - use_sim_time: True - transform_tolerance: 0.5 - update_frequency: 1.0 - publish_frequency: 1.0 - global_frame: map - robot_base_frame: base_link - use_sim_time: True - footprint: "[[0.14, 0.085], - [0.14, -0.085], - [-0.14, -0.085], - [-0.14, 0.085]]" - footprint_padding: 0.02 - resolution: 0.05 - track_unknown_space: true - plugins: ["static_layer", "obstacle_layer", "inflation_layer"] - obstacle_layer: - plugin: "nav2_costmap_2d::ObstacleLayer" - enabled: True - observation_sources: scan - scan: - topic: /scan - max_obstacle_height: 2.0 - clearing: True - marking: True - data_type: "LaserScan" - raytrace_max_range: 3.0 - raytrace_min_range: 0.0 - obstacle_max_range: 2.5 - obstacle_min_range: 0.0 - static_layer: - plugin: "nav2_costmap_2d::StaticLayer" - map_subscribe_transient_local: True - inflation_layer: - plugin: "nav2_costmap_2d::InflationLayer" - cost_scaling_factor: 3.0 - inflation_radius: 0.55 - always_send_full_costmap: True - global_costmap_client: - ros__parameters: - use_sim_time: True - global_costmap_rclcpp_node: - ros__parameters: - use_sim_time: True - -map_saver: - ros__parameters: - use_sim_time: True - save_map_timeout: 5.0 - free_thresh_default: 0.25 - occupied_thresh_default: 0.65 - map_subscribe_transient_local: True - -planner_server: - ros__parameters: - planner_plugins: ["GridBased"] - use_sim_time: True - - GridBased: - plugin: "nav2_smac_planner/SmacPlannerHybrid" - downsample_costmap: false - downsampling_factor: 1 - tolerance: 0.25 - allow_unknown: true - max_iterations: 1000000 - max_on_approach_iterations: 1000 - max_planning_time: 5.0 - motion_model_for_search: "REEDS_SHEPP" - angle_quantization_bins: 72 - analytic_expansion_ratio: 3.5 - analytic_expansion_max_length: 3.0 - minimum_turning_radius: 0.40 - reverse_penalty: 1.3 # 后退惩罚,越小越愿意后退(默认 2.0,设为 1.3 允许灵活倒车) - change_penalty: 0.0 - non_straight_penalty: 1.2 - cost_penalty: 2.0 - retrospective_penalty: 0.015 - lookup_table_size: 20.0 - cache_obstacle_heuristic: false - viz_expansions: false - smooth_path: True - - smoother: - max_iterations: 1000 - w_smooth: 0.3 - w_data: 0.2 - tolerance: 1.0e-10 - do_refinement: true - refinement_num: 2 - -planner_server_rclcpp_node: - ros__parameters: - use_sim_time: True - -smoother_server: - ros__parameters: - use_sim_time: True - smoother_plugins: ["simple_smoother"] - simple_smoother: - plugin: "nav2_smoother::SimpleSmoother" - tolerance: 1.0e-10 - max_its: 1000 - do_refinement: True - -behavior_server: - ros__parameters: - costmap_topic: local_costmap/costmap_raw - footprint_topic: local_costmap/published_footprint - cycle_frequency: 10.0 - behavior_plugins: ["spin", "backup", "wait"] - spin: - plugin: "nav2_behaviors/Spin" # 需保留以匹配默认 BT XML - backup: - plugin: "nav2_behaviors/BackUp" - backup_dist: 0.8 - backup_speed: 0.18 - wait: - plugin: "nav2_behaviors/Wait" - wait_duration: 0.5 - global_frame: odom - robot_base_frame: base_link - transform_tolerance: 0.5 - use_sim_time: True - simulate_ahead_time: 2.0 - max_rotational_vel: 1.0 - min_rotational_vel: 0.4 - rotational_acc_lim: 3.2 - -robot_state_publisher: - ros__parameters: - use_sim_time: True - -waypoint_follower: - ros__parameters: - loop_rate: 20 - use_sim_time: True - stop_on_failure: false - waypoint_task_executor_plugin: "wait_at_waypoint" - wait_at_waypoint: - plugin: "nav2_waypoint_follower::WaitAtWaypoint" - enabled: True - waypoint_pause_duration: 200 diff --git a/src/gc_navigation2_slamtoolbox/world/zhihui/model.config b/src/gc_navigation2_slamtoolbox/world/zhihui/model.config deleted file mode 100644 index 70585d9..0000000 --- a/src/gc_navigation2_slamtoolbox/world/zhihui/model.config +++ /dev/null @@ -1,11 +0,0 @@ - - - zhihui - 1.0 - model.sdf - - - - - - diff --git a/src/gc_navigation2_slamtoolbox/world/zhihui/model.sdf b/src/gc_navigation2_slamtoolbox/world/zhihui/model.sdf deleted file mode 100644 index e1ef463..0000000 --- a/src/gc_navigation2_slamtoolbox/world/zhihui/model.sdf +++ /dev/null @@ -1,471 +0,0 @@ - - - - -2.11635 -1.73906 0 0 -0 0 - - - - - 1.75 0.15 2.5 - - - 0 0 1.25 0 -0 0 - - - 0 0 1.25 0 -0 0 - - - 1.75 0.15 2.5 - - - - - 1 1 1 1 - - - 0 - - - -1.61999 -0.744014 0 0 -0 0 - - - - - - 2.75 0.15 2.5 - - - 0 0 1.25 0 -0 0 - - - 0 0 1.25 0 -0 0 - - - 2.75 0.15 2.5 - - - - - 1 1 1 1 - - - 0 - - - 1.62754 -0.744014 0 0 -0 0 - - - - - - 1 0.15 2.5 - - - 0 0 1.25 0 -0 0 - - - 0 0 1.25 0 -0 0 - - - 1 0.15 2.5 - - - - - 1 1 1 1 - - - 0 - - - -0.827543 -0.3078 0 0 -0 1.5708 - - - - - - 1 0.15 2.5 - - - 0 0 1.25 0 -0 0 - - - 0 0 1.25 0 -0 0 - - - 1 0.15 2.5 - - - - - 1 1 1 1 - - - 0 - - - 0.327543 -0.319014 0 0 -0 1.5708 - - - - - - 5 0.15 2.5 - - - 0 0 1.25 0 -0 0 - - - 0 0 1.25 0 -0 0 - - - 5 0.15 2.5 - - - - - 1 1 1 1 - - - 0 - - - 0.062177 -2.89677 0 0 -0 0 - - - - - - 3.75 0.15 2.5 - - - 0 0 1.25 0 -0 0 - - - 0 0 1.25 0 -0 0 - - - 3.75 0.15 2.5 - - - - - 1 1 1 1 - - - 0 - - - -0.305988 0.758719 0 0 -0 0 - - - - - - 3.75 0.15 2.5 - - - 0 0 1.25 0 -0 0 - - - 0 0 1.25 0 -0 0 - - - 3.75 0.15 2.5 - - - - - 1 1 1 1 - - - 0 - - - -0.300519 2.09188 0 0 -0 0 - - - - - - 1.5 0.15 2.5 - - - 0 0 1.25 0 -0 0 - - - 0 0 1.25 0 -0 0 - - - 1.5 0.15 2.5 - - - - - 1 1 1 1 - - - 0 - - - 1.65085 1.41824 0 0 -0 -1.5708 - - - - - - 2.75 0.15 2.5 - - - 0 0 1.25 0 -0 0 - - - 0 0 1.25 0 -0 0 - - - 2.75 0.15 2.5 - - - - - 1 1 1 1 - - - 0 - - - 2.3125 1.40828 0 0 -0 1.5708 - - - - - - 5.25 0.15 2.5 - - - 0 0 1.25 0 -0 0 - - - 0 0 1.25 0 -0 0 - - - 5.25 0.15 2.5 - - - - - 1 1 1 1 - - - 0 - - - -0.19189 2.74413 0 0 -0 3.14159 - - - - - - 2 0.15 2.5 - - - 0 0 1.25 0 -0 0 - - - 0 0 1.25 0 -0 0 - - - 2 0.15 2.5 - - - - - 1 1 1 1 - - - 0 - - - 2.6265 -1.8264 0 0 -0 1.5708 - - - - - - 1.5 0.15 2.5 - - - 0 0 1.25 0 -0 0 - - - 0 0 1.25 0 -0 0 - - - 1.5 0.15 2.5 - - - - - 1 1 1 1 - - - 0 - - - -2.25486 1.43754 0 0 -0 -1.5708 - - - - - - 3 0.15 2.5 - - - 0 0 1.25 0 -0 0 - - - 0 0 1.25 0 -0 0 - - - 3 0.15 2.5 - - - - - 1 1 1 1 - - - 0 - - - -2.89932 1.47176 0 0 -0 -1.5708 - - - - - - 2.25 0.15 2.5 - - - 0 0 1.25 0 -0 0 - - - 0 0 1.25 0 -0 0 - - - 2.25 0.15 2.5 - - - - - 1 1 1 1 - - - 0 - - - -1.87754 0.1172 0 0 -0 3.14159 - - - - - - 2.13496 0.15 2.5 - - - 0 0 1.25 0 -0 0 - - - 0 0 1.25 0 -0 0 - - - 2.13496 0.15 2.5 - - - - - 1 1 1 1 - - - 0 - - - 1.32002 0.107134 0 0 -0 0.001157 - - - - - - 2 0.15 2.5 - - - 0 0 1.25 0 -0 0 - - - 0 0 1.25 0 -0 0 - - - 2 0.15 2.5 - - - - - 1 1 1 1 - - - 0 - - - -2.50971 -1.81518 0 0 -0 1.5708 - - 1 - - diff --git a/src/gc_navigation_fish/CMakeLists.txt b/src/gc_navigation_fish/CMakeLists.txt deleted file mode 100644 index 21e4ee1..0000000 --- a/src/gc_navigation_fish/CMakeLists.txt +++ /dev/null @@ -1,29 +0,0 @@ -cmake_minimum_required(VERSION 3.8) -project(gc_navigation_fish) - -if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") - add_compile_options(-Wall -Wextra -Wpedantic) -endif() - -# find dependencies -find_package(ament_cmake REQUIRED) -# uncomment the following section in order to fill in -# further dependencies manually. -# find_package( REQUIRED) -install( - DIRECTORY launch param maps - DESTINATION share/${PROJECT_NAME} -) -if(BUILD_TESTING) - find_package(ament_lint_auto REQUIRED) - # the following line skips the linter which checks for copyrights - # comment the line when a copyright and license is added to all source files - set(ament_cmake_copyright_FOUND TRUE) - # the following line skips cpplint (only works in a git repo) - # comment the line when this package is in a git repo and when - # a copyright and license is added to all source files - set(ament_cmake_cpplint_FOUND TRUE) - ament_lint_auto_find_test_dependencies() -endif() - -ament_package() diff --git a/src/gc_navigation_fish/launch/gc_navigation.launch.py b/src/gc_navigation_fish/launch/gc_navigation.launch.py deleted file mode 100644 index 2419737..0000000 --- a/src/gc_navigation_fish/launch/gc_navigation.launch.py +++ /dev/null @@ -1,34 +0,0 @@ -import os -from ament_index_python.packages import get_package_share_directory -from launch import LaunchDescription -from launch.actions import IncludeLaunchDescription -from launch.launch_description_sources import PythonLaunchDescriptionSource -from launch.substitutions import LaunchConfiguration -from launch_ros.actions import Node - - -def generate_launch_description(): - # =============================1.定位到包的地址============================================================= - gc_navigation_fish_dir = get_package_share_directory( - 'gc_navigation_fish') - nav2_bringup_dir = get_package_share_directory('nav2_bringup') - - # =============================2.声明参数,获取配置文件路径=================================================== - # use_sim_time 这里要设置成true,因为gazebo是仿真环境,其时间是通过/clock话题获取,而不是系统时间 - use_sim_time = LaunchConfiguration('use_sim_time', default='false') - map_yaml_path = LaunchConfiguration('map', default=os.path.join( - gc_navigation_fish_dir, 'maps', 'test_map.yaml')) - nav2_param_path = LaunchConfiguration('params_file', default=os.path.join( - gc_navigation_fish_dir, 'param', 'gc_navigation.yaml')) - # =============================3.声明启动launch文件,传入:地图路径、是否使用仿真时间以及nav2参数文件============== - nav2_bringup_launch = IncludeLaunchDescription( - PythonLaunchDescriptionSource( - [nav2_bringup_dir, '/launch', '/bringup_launch.py']), - launch_arguments={ - 'map': map_yaml_path, - 'use_sim_time': use_sim_time, - 'params_file': nav2_param_path}.items(), - ) - - - return LaunchDescription([nav2_bringup_launch]) diff --git a/src/gc_navigation_fish/maps/test_map.pgm b/src/gc_navigation_fish/maps/test_map.pgm deleted file mode 100644 index 079a090..0000000 Binary files a/src/gc_navigation_fish/maps/test_map.pgm and /dev/null differ diff --git a/src/gc_navigation_fish/maps/test_map.yaml b/src/gc_navigation_fish/maps/test_map.yaml deleted file mode 100644 index 2d524cd..0000000 --- a/src/gc_navigation_fish/maps/test_map.yaml +++ /dev/null @@ -1,7 +0,0 @@ -image: test_map.pgm -mode: trinary -resolution: 0.05 -origin: [-2.03, -6.12, 0] -negate: 0 -occupied_thresh: 0.65 -free_thresh: 0.25 \ No newline at end of file diff --git a/src/gc_navigation_fish/package.xml b/src/gc_navigation_fish/package.xml deleted file mode 100644 index f54f961..0000000 --- a/src/gc_navigation_fish/package.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - gc_navigation_fish - 0.0.0 - TODO: Package description - guoch - TODO: License declaration - - ament_cmake - - ament_lint_auto - ament_lint_common - nav2_bringup - - ament_cmake - - diff --git a/src/gc_navigation_fish/param/gc_navigation.yaml b/src/gc_navigation_fish/param/gc_navigation.yaml deleted file mode 100644 index 0b6f53a..0000000 --- a/src/gc_navigation_fish/param/gc_navigation.yaml +++ /dev/null @@ -1,408 +0,0 @@ -amcl: - ros__parameters: - use_sim_time: False - alpha1: 0.2 - alpha2: 0.2 - alpha3: 0.2 - alpha4: 0.2 - alpha5: 0.2 - base_frame_id: "base_link" - beam_skip_distance: 0.5 - beam_skip_error_threshold: 0.9 - beam_skip_threshold: 0.3 - do_beamskip: false - global_frame_id: "map" - lambda_short: 0.1 - laser_likelihood_max_dist: 2.0 - laser_max_range: 100.0 - laser_min_range: -1.0 - laser_model_type: "likelihood_field" - max_beams: 60 - max_particles: 2000 - min_particles: 500 - odom_frame_id: "odom" - pf_err: 0.05 - pf_z: 0.99 - recovery_alpha_fast: 0.0 - recovery_alpha_slow: 0.0 - resample_interval: 1 - robot_model_type: "nav2_amcl::DifferentialMotionModel" - save_pose_rate: 0.5 - sigma_hit: 0.2 - tf_broadcast: true - transform_tolerance: 10.0 - update_min_a: 0.2 - update_min_d: 0.25 - z_hit: 0.5 - z_max: 0.05 - z_rand: 0.5 - z_short: 0.05 - scan_topic: scan - -amcl_map_client: - ros__parameters: - use_sim_time: False - -amcl_rclcpp_node: - ros__parameters: - use_sim_time: False - -bt_navigator: - ros__parameters: - use_sim_time: False - global_frame: map - robot_base_frame: base_link - odom_topic: /odom - bt_loop_duration: 10 - default_server_timeout: 20 - # 'default_nav_through_poses_bt_xml' and 'default_nav_to_pose_bt_xml' are use defaults: - # nav2_bt_navigator/navigate_to_pose_w_replanning_and_recovery.xml - # nav2_bt_navigator/navigate_through_poses_w_replanning_and_recovery.xml - # They can be set here or via a RewrittenYaml remap from a parent launch file to Nav2. - plugin_lib_names: - - nav2_compute_path_to_pose_action_bt_node - - nav2_compute_path_through_poses_action_bt_node - - nav2_smooth_path_action_bt_node - - nav2_follow_path_action_bt_node - - nav2_spin_action_bt_node - - nav2_wait_action_bt_node - - nav2_back_up_action_bt_node - - nav2_drive_on_heading_bt_node - - nav2_clear_costmap_service_bt_node - - nav2_is_stuck_condition_bt_node - - nav2_goal_reached_condition_bt_node - - nav2_goal_updated_condition_bt_node - - nav2_globally_updated_goal_condition_bt_node - - nav2_is_path_valid_condition_bt_node - - nav2_initial_pose_received_condition_bt_node - - nav2_reinitialize_global_localization_service_bt_node - - nav2_rate_controller_bt_node - - nav2_distance_controller_bt_node - - nav2_speed_controller_bt_node - - nav2_truncate_path_action_bt_node - - nav2_truncate_path_local_action_bt_node - - nav2_goal_updater_node_bt_node - - nav2_recovery_node_bt_node - - nav2_pipeline_sequence_bt_node - - nav2_round_robin_node_bt_node - - nav2_transform_available_condition_bt_node - - nav2_time_expired_condition_bt_node - - nav2_path_expiring_timer_condition - - nav2_distance_traveled_condition_bt_node - - nav2_single_trigger_bt_node - - nav2_is_battery_low_condition_bt_node - - nav2_navigate_through_poses_action_bt_node - - nav2_navigate_to_pose_action_bt_node - - nav2_remove_passed_goals_action_bt_node - - nav2_planner_selector_bt_node - - nav2_controller_selector_bt_node - - nav2_goal_checker_selector_bt_node - - nav2_controller_cancel_bt_node - - nav2_path_longer_on_approach_bt_node - - nav2_wait_cancel_bt_node - - nav2_spin_cancel_bt_node - - nav2_back_up_cancel_bt_node - - nav2_drive_on_heading_cancel_bt_node - -bt_navigator_rclcpp_node: - ros__parameters: - use_sim_time: False - -controller_server: - ros__parameters: - controller_frequency: 30.0 - FollowPath: - plugin: "nav2_mppi_controller::MPPIController" - time_steps: 56 - model_dt: 0.05 - batch_size: 2000 - vx_std: 0.2 - vy_std: 0.0 - wz_std: 0.4 - vx_max: 0.5 - vx_min: -0.35 - vy_max: 0.0 - wz_max: 1.9 - iteration_count: 1 - temperature: 0.3 - gamma: 0.015 - motion_model: "Ackermann" - visualize: false - TrajectoryVisualizer: - trajectory_step: 5 - time_step: 3 - AckermannConstraints: - min_turning_r: 0.4 - critics: ["ConstraintCritic", "CostCritic", "GoalCritic", "GoalAngleCritic", "PathAlignCritic", "PathFollowCritic", "PathAngleCritic", "PreferForwardCritic"] - ConstraintCritic: - enabled: true - cost_power: 1 - cost_weight: 4.0 - GoalCritic: - enabled: true - cost_power: 1 - cost_weight: 5.0 - threshold_to_consider: 1.4 - GoalAngleCritic: - enabled: true - cost_power: 1 - cost_weight: 3.0 - threshold_to_consider: 0.5 - PreferForwardCritic: - enabled: true - cost_power: 1 - cost_weight: 5.0 - threshold_to_consider: 0.5 - # Option to replace Cost and use Obstacles instead - # ObstaclesCritic: - # enabled: true - # cost_power: 1 - # repulsion_weight: 1.5 - # critical_weight: 20.0 - # consider_footprint: false - # collision_cost: 10000.0 - # collision_margin_distance: 0.1 - # near_goal_distance: 0.5 - CostCritic: - enabled: true - cost_power: 1 - cost_weight: 3.81 - critical_cost: 300.0 - consider_footprint: true - collision_cost: 1000000.0 - near_goal_distance: 1.0 - trajectory_point_step: 2 - PathAlignCritic: - enabled: true - cost_power: 1 - cost_weight: 14.0 - max_path_occupancy_ratio: 0.05 - trajectory_point_step: 4 - threshold_to_consider: 0.5 - offset_from_furthest: 20 - use_path_orientations: false - PathFollowCritic: - enabled: true - cost_power: 1 - cost_weight: 5.0 - offset_from_furthest: 5 - threshold_to_consider: 1.4 - PathAngleCritic: - enabled: true - cost_power: 1 - cost_weight: 2.0 - offset_from_furthest: 4 - threshold_to_consider: 0.5 - max_angle_to_furthest: 1.0 - forward_preference: true - # VelocityDeadbandCritic: - # enabled: true - # cost_power: 1 - # cost_weight: 35.0 - # deadband_velocities: [0.05, 0.05, 0.05] - # TwirlingCritic: - # enabled: true - # twirling_cost_power: 1 - # twirling_cost_weight: 10.0 - -controller_server_rclcpp_node: - ros__parameters: - use_sim_time: False - -local_costmap: - local_costmap: - ros__parameters: - update_frequency: 5.0 - publish_frequency: 2.0 - global_frame: odom - robot_base_frame: base_link - use_sim_time: False - rolling_window: true - width: 3 - height: 3 - resolution: 0.05 - footprint: "[[0.14, 0.085], - [0.14, -0.085], - [-0.14, -0.085], - [-0.14, 0.085]]" - footprint_padding: 0.02 - plugins: ["voxel_layer", "inflation_layer"] - inflation_layer: - plugin: "nav2_costmap_2d::InflationLayer" - cost_scaling_factor: 3.0 - inflation_radius: 0.55 - voxel_layer: - plugin: "nav2_costmap_2d::VoxelLayer" - enabled: True - publish_voxel_map: True - origin_z: 0.0 - z_resolution: 0.05 - z_voxels: 16 - max_obstacle_height: 2.0 - mark_threshold: 0 - observation_sources: scan - scan: - topic: /scan - max_obstacle_height: 2.0 - clearing: True - marking: True - data_type: "LaserScan" - raytrace_max_range: 3.0 - raytrace_min_range: 0.0 - obstacle_max_range: 2.5 - obstacle_min_range: 0.0 - static_layer: - map_subscribe_transient_local: True - always_send_full_costmap: True - local_costmap_client: - ros__parameters: - use_sim_time: False - local_costmap_rclcpp_node: - ros__parameters: - use_sim_time: False - -global_costmap: - global_costmap: - ros__parameters: - update_frequency: 1.0 - publish_frequency: 1.0 - global_frame: map - robot_base_frame: base_link - use_sim_time: False - footprint: "[[0.14, 0.085], - [0.14, -0.085], - [-0.14, -0.085], - [-0.14, 0.085]]" - footprint_padding: 0.02 - resolution: 0.05 - track_unknown_space: true - plugins: ["static_layer", "obstacle_layer", "inflation_layer"] - obstacle_layer: - plugin: "nav2_costmap_2d::ObstacleLayer" - enabled: True - observation_sources: scan - scan: - topic: /scan - max_obstacle_height: 2.0 - clearing: True - marking: True - data_type: "LaserScan" - raytrace_max_range: 3.0 - raytrace_min_range: 0.0 - obstacle_max_range: 2.5 - obstacle_min_range: 0.0 - static_layer: - plugin: "nav2_costmap_2d::StaticLayer" - map_subscribe_transient_local: True - inflation_layer: - plugin: "nav2_costmap_2d::InflationLayer" - cost_scaling_factor: 3.0 - inflation_radius: 0.55 - always_send_full_costmap: True - global_costmap_client: - ros__parameters: - use_sim_time: False - global_costmap_rclcpp_node: - ros__parameters: - use_sim_time: False - -map_server: - ros__parameters: - use_sim_time: False - yaml_filename: "turtlebot3_world.yaml" - -map_saver: - ros__parameters: - use_sim_time: False - save_map_timeout: 5.0 - free_thresh_default: 0.25 - occupied_thresh_default: 0.65 - map_subscribe_transient_local: True - -planner_server: - ros__parameters: - planner_plugins: ["GridBased"] - use_sim_time: False - - GridBased: - plugin: "nav2_smac_planner/SmacPlannerHybrid" - downsample_costmap: false # whether or not to downsample the map - downsampling_factor: 1 # multiplier for the resolution of the costmap layer (e.g. 2 on a 5cm costmap would be 10cm) - tolerance: 0.25 # dist-to-goal heuristic cost (distance) for valid tolerance endpoints if exact goal cannot be found. - allow_unknown: true # allow traveling in unknown space - max_iterations: 1000000 # maximum total iterations to search for before failing (in case unreachable), set to -1 to disable - max_on_approach_iterations: 1000 # Maximum number of iterations after within tolerances to continue to try to find exact solution - max_planning_time: 5.0 # max time in s for planner to plan, smooth - motion_model_for_search: "REEDS_SHEPP" # or REEDS_SHEPP 可以倒车 - angle_quantization_bins: 72 # Number of angle bins for search - analytic_expansion_ratio: 3.5 # The ratio to attempt analytic expansions during search for final approach. - analytic_expansion_max_length: 3.0 # For Hybrid/Lattice nodes: The maximum length of the analytic expansion to be considered valid to prevent unsafe shortcutting - minimum_turning_radius: 0.40 # minimum turning radius in m of path / vehicle - reverse_penalty: 2.0 # Penalty to apply if motion is reversing, must be => 1 - change_penalty: 0.0 # Penalty to apply if motion is changing directions (L to R), must be >= 0 - non_straight_penalty: 1.2 # Penalty to apply if motion is non-straight, must be => 1 - cost_penalty: 2.0 # Penalty to apply to higher cost areas when adding into the obstacle map dynamic programming distance expansion heuristic. This drives the robot more towards the center of passages. A value between 1.3 - 3.5 is reasonable. - retrospective_penalty: 0.015 - lookup_table_size: 20.0 # Size of the dubin/reeds-sheep distance window to cache, in meters. - cache_obstacle_heuristic: false # Cache the obstacle map dynamic programming distance expansion heuristic between subsiquent replannings of the same goal location. Dramatically speeds up replanning performance (40x) if costmap is largely static. - viz_expansions: false # For Hybrid nodes: Whether to publish expansions on the /expansions topic as an array of poses (the orientation has no meaning). WARNING: heavy to compute and to display, for debug only as it degrades the performance. - smooth_path: True # If true, does a simple and quick smoothing post-processing to the path - - smoother: - max_iterations: 1000 - w_smooth: 0.3 - w_data: 0.2 - tolerance: 1.0e-10 - do_refinement: true - refinement_num: 2 - -planner_server_rclcpp_node: - ros__parameters: - use_sim_time: False - -smoother_server: - ros__parameters: - use_sim_time: False - smoother_plugins: ["simple_smoother"] - simple_smoother: - plugin: "nav2_smoother::SimpleSmoother" - tolerance: 1.0e-10 - max_its: 1000 - do_refinement: True - -behavior_server: - ros__parameters: - costmap_topic: local_costmap/costmap_raw - footprint_topic: local_costmap/published_footprint - cycle_frequency: 10.0 - behavior_plugins: ["spin", "backup", "drive_on_heading", "wait"] - spin: - plugin: "nav2_behaviors/Spin" - backup: - plugin: "nav2_behaviors/BackUp" - drive_on_heading: - plugin: "nav2_behaviors/DriveOnHeading" - wait: - plugin: "nav2_behaviors/Wait" - global_frame: odom - robot_base_frame: base_link - transform_tolerance: 0.1 - use_sim_time: False - simulate_ahead_time: 2.0 - max_rotational_vel: 1.0 - min_rotational_vel: 0.4 - rotational_acc_lim: 3.2 - -robot_state_publisher: - ros__parameters: - use_sim_time: False - -waypoint_follower: - ros__parameters: - loop_rate: 20 - stop_on_failure: false - waypoint_task_executor_plugin: "wait_at_waypoint" - wait_at_waypoint: - plugin: "nav2_waypoint_follower::WaitAtWaypoint" - enabled: True - waypoint_pause_duration: 200 diff --git a/src/gc_navigation_fish/param/navigation_test.yaml b/src/gc_navigation_fish/param/navigation_test.yaml deleted file mode 100644 index 86160da..0000000 --- a/src/gc_navigation_fish/param/navigation_test.yaml +++ /dev/null @@ -1,173 +0,0 @@ -# ========================= -# 🚫 删除 amcl(SLAM模式不需要) -# ========================= -# ❌ 已移除 amcl 整块 -# ❌ 已移除 amcl_map_client -# ❌ 已移除 amcl_rclcpp_node - - -# ========================= -# 🚫 删除 map_server(由 slam_toolbox 提供 map) -# ========================= -# ❌ 已移除 map_server -# ❌ 已移除 map_saver - - -# ========================= -# BT Navigator -# ========================= -bt_navigator: - ros__parameters: - use_sim_time: false # ✅ 改为 false(真车) - global_frame: map - robot_base_frame: base_link - odom_topic: /odom - bt_loop_duration: 10 - default_server_timeout: 20 - plugin_lib_names: - - nav2_compute_path_to_pose_action_bt_node - - nav2_follow_path_action_bt_node - - nav2_goal_reached_condition_bt_node - - nav2_initial_pose_received_condition_bt_node - - nav2_is_path_valid_condition_bt_node - - nav2_navigate_to_pose_action_bt_node - -bt_navigator_rclcpp_node: - ros__parameters: - use_sim_time: false # ✅ 改为 false - - -# ========================= -# Controller Server(保持你的MPPI) -# ========================= -controller_server: - ros__parameters: - use_sim_time: false # ✅ 改为 false - controller_frequency: 30.0 - controller_plugins: ["FollowPath"] # ✅ 确保声明插件 - - FollowPath: - plugin: "nav2_mppi_controller::MPPIController" - motion_model: "Ackermann" - time_steps: 56 - model_dt: 0.05 - batch_size: 2000 - vx_max: 0.5 - vx_min: -0.35 - wz_max: 1.9 - -controller_server_rclcpp_node: - ros__parameters: - use_sim_time: false # ✅ 改为 false - - -# ========================= -# Planner Server(Smac Hybrid A*) -# ========================= -planner_server: - ros__parameters: - use_sim_time: false # ✅ 改为 false - planner_plugins: ["GridBased"] - - GridBased: - plugin: "nav2_smac_planner/SmacPlannerHybrid" - motion_model_for_search: "REEDS_SHEPP" - minimum_turning_radius: 0.40 - allow_unknown: true - -planner_server_rclcpp_node: - ros__parameters: - use_sim_time: false # ✅ 改为 false - - -# ========================= -# Local Costmap -# ========================= -local_costmap: - local_costmap: - ros__parameters: - use_sim_time: false # ✅ 改为 false - global_frame: odom - robot_base_frame: base_link - rolling_window: true - width: 3 - height: 3 - resolution: 0.05 - plugins: ["voxel_layer", "inflation_layer"] - - voxel_layer: - plugin: "nav2_costmap_2d::VoxelLayer" - observation_sources: scan - scan: - topic: /scan - data_type: "LaserScan" - marking: true - clearing: true - - inflation_layer: - plugin: "nav2_costmap_2d::InflationLayer" - inflation_radius: 0.55 - - local_costmap_rclcpp_node: - ros__parameters: - use_sim_time: false # ✅ 改为 false - - -# ========================= -# Global Costmap -# ========================= -global_costmap: - global_costmap: - ros__parameters: - use_sim_time: false # ✅ 改为 false - global_frame: map - robot_base_frame: base_link - resolution: 0.05 - track_unknown_space: true - plugins: ["obstacle_layer", "inflation_layer"] # ✅ 删除 static_layer(SLAM模式不需要) - - obstacle_layer: - plugin: "nav2_costmap_2d::ObstacleLayer" - observation_sources: scan - scan: - topic: /scan - data_type: "LaserScan" - marking: true - clearing: true - - inflation_layer: - plugin: "nav2_costmap_2d::InflationLayer" - inflation_radius: 0.55 - - global_costmap_rclcpp_node: - ros__parameters: - use_sim_time: false # ✅ 改为 false - - -# ========================= -# Behavior Server -# ========================= -behavior_server: - ros__parameters: - use_sim_time: false # ✅ 改为 false - global_frame: odom - robot_base_frame: base_link - behavior_plugins: ["spin", "backup", "drive_on_heading", "wait"] - - spin: - plugin: "nav2_behaviors/Spin" - backup: - plugin: "nav2_behaviors/BackUp" - drive_on_heading: - plugin: "nav2_behaviors/DriveOnHeading" - wait: - plugin: "nav2_behaviors/Wait" - - -# ========================= -# Waypoint Follower -# ========================= -waypoint_follower: - ros__parameters: - use_sim_time: false # ✅ 改为 false - loop_rate: 20 \ No newline at end of file diff --git a/src/gc_slam_toolbox_fish/CMakeLists.txt b/src/gc_slam_toolbox_fish/CMakeLists.txt deleted file mode 100644 index 262d40e..0000000 --- a/src/gc_slam_toolbox_fish/CMakeLists.txt +++ /dev/null @@ -1,29 +0,0 @@ -cmake_minimum_required(VERSION 3.8) -project(gc_slam_toolbox_fish) - -if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") - add_compile_options(-Wall -Wextra -Wpedantic) -endif() - -# find dependencies -find_package(ament_cmake REQUIRED) -# uncomment the following section in order to fill in -# further dependencies manually. -# find_package( REQUIRED) -install( - DIRECTORY config launch rviz - DESTINATION share/${PROJECT_NAME} -) -if(BUILD_TESTING) - find_package(ament_lint_auto REQUIRED) - # the following line skips the linter which checks for copyrights - # comment the line when a copyright and license is added to all source files - set(ament_cmake_copyright_FOUND TRUE) - # the following line skips cpplint (only works in a git repo) - # comment the line when this package is in a git repo and when - # a copyright and license is added to all source files - set(ament_cmake_cpplint_FOUND TRUE) - ament_lint_auto_find_test_dependencies() -endif() - -ament_package() diff --git a/src/gc_slam_toolbox_fish/config/gc_2d.lua b/src/gc_slam_toolbox_fish/config/gc_2d.lua deleted file mode 100644 index 329a2ee..0000000 --- a/src/gc_slam_toolbox_fish/config/gc_2d.lua +++ /dev/null @@ -1,63 +0,0 @@ -include "map_builder.lua" -include "trajectory_builder.lua" - -options = { - map_builder = MAP_BUILDER, - trajectory_builder = TRAJECTORY_BUILDER, - map_frame = "map", - tracking_frame = "base_link", - -- base_link改为odom,发布map到odom之间的位姿态 - published_frame = "odom", - odom_frame = "odom", - -- true改为false,不用提供里程计数据 - provide_odom_frame = false, - -- false改为true,仅发布2D位资 - publish_frame_projected_to_2d = true, - -- false改为true,使用里程计数据 - use_odometry = true, - use_nav_sat = false, - use_landmarks = false, - -- 0改为1,使用一个雷达 - num_laser_scans = 1, - -- 1改为0,不使用多波雷达 - num_multi_echo_laser_scans = 0, - -- 10改为1,1/1=1等于不分割 - num_subdivisions_per_laser_scan = 1, - num_point_clouds = 0, - lookup_transform_timeout_sec = 0.2, - submap_publish_period_sec = 0.3, - pose_publish_period_sec = 5e-3, - trajectory_publish_period_sec = 30e-3, - rangefinder_sampling_ratio = 1., - odometry_sampling_ratio = 1., - fixed_frame_pose_sampling_ratio = 1., - imu_sampling_ratio = 1., - landmarks_sampling_ratio = 1., -} - - --- false改为true,启动2D SLAM -MAP_BUILDER.use_trajectory_builder_2d = true - --- 0改成0.10,比机器人半径小的都忽略 -TRAJECTORY_BUILDER_2D.min_range = 0.10 --- 30改成3.5,限制在雷达最大扫描范围内,越小一般越精确些 -TRAJECTORY_BUILDER_2D.max_range = 3.5 --- 5改成3,传感器数据超出有效范围最大值 -TRAJECTORY_BUILDER_2D.missing_data_ray_length = 3. --- true改成false,不使用IMU数据,大家可以开启,然后对比下效果 -TRAJECTORY_BUILDER_2D.use_imu_data = false --- false改成true,使用实时回环检测来进行前端的扫描匹配 -TRAJECTORY_BUILDER_2D.use_online_correlative_scan_matching = true --- 1.0改成0.1,提高对运动的敏感度 -TRAJECTORY_BUILDER_2D.motion_filter.max_angle_radians = math.rad(0.1) - --- 0.55改成0.65,Fast csm的最低分数,高于此分数才进行优化。 -POSE_GRAPH.constraint_builder.min_score = 0.65 ---0.6改成0.7,全局定位最小分数,低于此分数则认为目前全局定位不准确 -POSE_GRAPH.constraint_builder.global_localization_min_score = 0.7 - --- 设置0可关闭全局SLAM --- POSE_GRAPH.optimize_every_n_nodes = 0 - -return options diff --git a/src/gc_slam_toolbox_fish/launch/catograph.launch.py b/src/gc_slam_toolbox_fish/launch/catograph.launch.py deleted file mode 100644 index ff51eec..0000000 --- a/src/gc_slam_toolbox_fish/launch/catograph.launch.py +++ /dev/null @@ -1,63 +0,0 @@ - -import os -from launch import LaunchDescription -from launch.substitutions import LaunchConfiguration -from launch_ros.actions import Node -from launch_ros.substitutions import FindPackageShare - - -def generate_launch_description(): - # 定位到功能包的地址 - pkg_share = FindPackageShare( - package='gc_slam_toolbox_fish').find('gc_slam_toolbox_fish') - - # =====================运行节点需要的配置======================================================================= - # 是否使用仿真时间,我们用gazebo,这里设置成true - use_sim_time = LaunchConfiguration('use_sim_time', default='true') - # 地图的分辨率 - resolution = LaunchConfiguration('resolution', default='0.05') - # 地图的发布周期 - publish_period_sec = LaunchConfiguration( - 'publish_period_sec', default='1.0') - # 配置文件夹路径 - configuration_directory = LaunchConfiguration( - 'configuration_directory', default=os.path.join(pkg_share, 'config')) - # 配置文件 - configuration_basename = LaunchConfiguration( - 'configuration_basename', default='gc_2d.lua') - rviz_config_dir = os.path.join(pkg_share, 'config')+"/cartographer.rviz" - print(f"rviz config in {rviz_config_dir}") - - # =====================声明三个节点,cartographer/occupancy_grid_node/rviz_node================================= - cartographer_node = Node( - package='cartographer_ros', - executable='cartographer_node', - name='cartographer_node', - output='screen', - parameters=[{'use_sim_time': use_sim_time}], - arguments=['-configuration_directory', configuration_directory, - '-configuration_basename', configuration_basename]) - - cartographer_occupancy_grid_node = Node( - package='cartographer_ros', - executable='cartographer_occupancy_grid_node', - name='cartographer_occupancy_grid_node', - output='screen', - parameters=[{'use_sim_time': use_sim_time}], - arguments=['-resolution', resolution, '-publish_period_sec', publish_period_sec]) - - rviz_node = Node( - package='rviz2', - executable='rviz2', - name='rviz2', - arguments=['-d', rviz_config_dir], - parameters=[{'use_sim_time': use_sim_time}], - output='screen') - - # ===============================================定义启动文件======================================================== - ld = LaunchDescription() - ld.add_action(cartographer_node) - ld.add_action(cartographer_occupancy_grid_node) - # ld.add_action(rviz_node) - - return ld diff --git a/src/gc_slam_toolbox_fish/package.xml b/src/gc_slam_toolbox_fish/package.xml deleted file mode 100644 index 81a27f4..0000000 --- a/src/gc_slam_toolbox_fish/package.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - gc_slam_toolbox_fish - 0.0.0 - TODO: Package description - guoch - TODO: License declaration - - ament_cmake - - ament_lint_auto - ament_lint_common - - - ament_cmake - - diff --git a/src/ground_slam/.gitignore b/src/ground_slam/.gitignore deleted file mode 100755 index f89770e..0000000 --- a/src/ground_slam/.gitignore +++ /dev/null @@ -1,51 +0,0 @@ -build/ -bin/ -lib/ -debug/ -msg_gen/ -srv_gen/ -msg/*Action.msg -msg/*ActionFeedback.msg -msg/*ActionGoal.msg -msg/*ActionResult.msg -msg/*Feedback.msg -msg/*Goal.msg -msg/*Result.msg -msg/_*.py - -# Generated by dynamic reconfigure -*.cfgc -/cfg/cpp/ -/cfg/*.py - -# Ignore generated docs -*.dox -*.wikidoc - -# eclipse stuff -.project -.cproject - -# qcreator stuff -CMakeLists.txt.user - -srv/_*.py -*.pcd -*.pyc -qtcreator-* -*.user - -*~ - -# Emacs -.#* - -# Catkin custom files -CATKIN_IGNORE -bag - -.vscode/* -log/* -saving/* -debug/* -test/* \ No newline at end of file diff --git a/src/ground_slam/CMakeLists.txt b/src/ground_slam/CMakeLists.txt deleted file mode 100755 index 369b352..0000000 --- a/src/ground_slam/CMakeLists.txt +++ /dev/null @@ -1,118 +0,0 @@ -cmake_minimum_required(VERSION 3.8) -project(ground_slam) - -# Default to C++17 (ROS2 Humble standard) -if(NOT CMAKE_CXX_STANDARD) - set(CMAKE_CXX_STANDARD 17) -endif() -set(CMAKE_CXX_STANDARD_REQUIRED ON) - -set(CMAKE_BUILD_TYPE Release) -set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) - -# ── ROS2 packages ────────────────────────────────────── -find_package(ament_cmake REQUIRED) -find_package(rclcpp REQUIRED) -find_package(geometry_msgs REQUIRED) -find_package(nav_msgs REQUIRED) -find_package(std_msgs REQUIRED) -find_package(sensor_msgs REQUIRED) -find_package(cv_bridge REQUIRED) -find_package(tf2 REQUIRED) -find_package(tf2_geometry_msgs REQUIRED) -find_package(tf2_ros REQUIRED) -find_package(visualization_msgs REQUIRED) - -# ── System dependencies ──────────────────────────────── -find_package(OpenCV 4.2 REQUIRED) -find_package(OpenMP REQUIRED) -find_package(Eigen3 REQUIRED) -find_package(FFTW3 REQUIRED) -find_package(Ceres REQUIRED) -find_package(yaml-cpp REQUIRED) -find_package(Boost REQUIRED) -find_package(VTK REQUIRED) - -# ── Compiler flags ───────────────────────────────────── -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -O3 -march=native") -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -O3 -march=native -Wno-reorder") -if(OPENMP_FOUND) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") -endif() - -# ── Include directories ──────────────────────────────── -include_directories( - ${PROJECT_SOURCE_DIR}/include - ${OpenCV_INCLUDE_DIRS} - ${EIGEN3_INCLUDE_DIR} - ${FFTW3_INCLUDE_DIRS} - ${YAML_CPP_INCLUDE_DIR} - ${CERES_INCLUDE_DIRS} - ${Boost_INCLUDE_DIRS} - ${VTK_INCLUDE_DIRS} -) - -# ── Core library ─────────────────────────────────────── -add_library(${PROJECT_NAME}_lib SHARED - src/optimization_2d/pose_graph_2d.cc - src/utils.cc - src/dataset.cc - src/camera.cc - src/frame.cc - src/edge.cc - src/correlation_flow.cc - src/loop_closure.cc - src/map.cc - src/map_builder.cc - src/thread_publisher.cc - src/map_stitcher.cc - src/visualization.cc - src/timer.cc -) - -target_link_libraries(${PROJECT_NAME}_lib - -lfftw3 - -lfftw3f - ${OpenCV_LIBS} - ${EIGEN3_LIBS} - ${CERES_LIBRARIES} - yaml-cpp - ${Boost_LIBRARIES} - ${VTK_LIBRARIES} -) - -# ROS2 deps (header-only via include_directories above, link where needed) -ament_target_dependencies(${PROJECT_NAME}_lib - rclcpp - geometry_msgs - nav_msgs - std_msgs - sensor_msgs - cv_bridge - tf2 - tf2_geometry_msgs - tf2_ros - visualization_msgs -) - -# ── Executable ───────────────────────────────────────── -add_executable(${PROJECT_NAME} main.cpp) -target_link_libraries(${PROJECT_NAME} ${PROJECT_NAME}_lib) - -ament_target_dependencies(${PROJECT_NAME} - rclcpp -) - -# ── Install ──────────────────────────────────────────── -install(TARGETS ${PROJECT_NAME} ${PROJECT_NAME}_lib - ARCHIVE DESTINATION lib - LIBRARY DESTINATION lib - RUNTIME DESTINATION lib/${PROJECT_NAME} -) - -install(DIRECTORY configs/ - DESTINATION share/${PROJECT_NAME}/configs -) - -ament_package() diff --git a/src/ground_slam/LICENSE.md b/src/ground_slam/LICENSE.md deleted file mode 100644 index 1b0ab18..0000000 --- a/src/ground_slam/LICENSE.md +++ /dev/null @@ -1,674 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Use with the GNU Affero General Public License. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - {one line to give the program's name and a brief idea of what it does.} - Copyright (C) {year} {name of author} - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - {project} Copyright (C) {year} {fullname} - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. \ No newline at end of file diff --git a/src/ground_slam/README.md b/src/ground_slam/README.md deleted file mode 100644 index 9c4fee8..0000000 --- a/src/ground_slam/README.md +++ /dev/null @@ -1,138 +0,0 @@ -

GroundSLAM: A Robust Visual SLAM System for Warehouse Robots Using Ground Textures

- Kuan Xu1, - Zheng Yang1, - Lihua Xie1, - Chen Wang2 -

- -

- 1: Centre for Advanced Robotics Technology Innovation (CARTIN), Nanyang Technological University
- 2: Spatial AI & Robotics (SAIR) Lab, Computer Science and Engineering, University at Buffalo
-

- - -

- - 🎥 [Youtube] | - 🎥 [Bilibili] - 📊 [Supplementary] - -

- - -pipeline - -GroundSLAM is a novel **feature-free** and **ground-texture-based** SLAM system for **the warehouse robot**. Our system can provide robust pose estimation and localization in environments with many **dynamic** objects or **open spaces**, such as warehouses, which is very challenging for localization systems with a forward-facing camera or LiDAR. GroundSLAM consists of three components: feature-free visual odometry, ground-texture-based loop detection and map optimization, and map reuse. Specifically, we introduce a kernel cross-correlator for **image-level pose tracking**, loop detection, and map reuse to improve localization accuracy and robustness, and incorporate adaptive pruning strategies to enhance efficiency. Due to these specific designs, GroundSLAM more **robust** and **accurate** when dealing with ground images with **few textures** or with many **repetitive patterns** than the feature-based methods. - - - -**Video:** - - -

- -

- -## Test Environment -### Dependencies -* OpenCV 4.2 -* Eigen 3 -* Ceres 2.0.0 -* FFTW3 -* ROS noetic -* Boost -* yaml-cpp -* VTK - -## Build -``` - cd ~/catkin_ws/src - git clone https://github.com/sair-lab/GroundSLAM.git - cd ../ - catkin_make - source ~/catkin_ws/devel/setup.bash -``` - -## Run - -Modify the configuration file in [configs](configs) and then run - -``` -rosrun ground_slam ground_slam src/GroundSLAM/configs/your_config.yaml -``` - -## Data - -### PathTex Dataset - - pathtex_dataset - - -Our data collection platform is a modified Weston SCOUT Robot. The robot is equipped with an IDS uEye monocular camera, which is positioned at the bottom and facing downward, placed at a height of 0.1m above the ground. To ensure constant illumination, a set of LED lights are arranged around the camera. For ground truth, a prism is installed on the top of the robot, and its position is tracked by a Leica Nova MS60 MultiStation laser tracker. - -We collect the data of 10 common ground textures, including 6 $\color{lightblue}{outdoor}$ textures and 4 $\color{red}{indoor}$ textures. The table below provides detailed information and download links for each sequence. The **camera parameters** can be found [here](https://entuedu-my.sharepoint.com/:u:/g/personal/kuan_xu_staff_main_ntu_edu_sg/EQqXW2eDcXNAkBWlSGgq6bgBe2yYdjdcuSJ8HEFey3haGg?e=nOg2ym). - - - - -Sequence Name|Total Size|Total Images|Download Link -:--:|:--:|:--:|:--: -Brick_seq1|1.0g|3119|[Link](https://entuedu-my.sharepoint.com/:u:/g/personal/kuan_xu_staff_main_ntu_edu_sg/EUMENxrPbQBFmzAQmfhMw4YB4df6_uq6ua7H1fo9A7NC7g?e=5Mzy9Q) -Brick_seq2|0.9g|5328|[Link](https://entuedu-my.sharepoint.com/:u:/g/personal/kuan_xu_staff_main_ntu_edu_sg/EY1-hFr2taZJqjxE4k6-W6oB-XenzRAk_RW8DME6VvqUmg?e=PSQEi6) -Carpet1_seq1|1.7g|8458|[Link](https://entuedu-my.sharepoint.com/:u:/g/personal/kuan_xu_staff_main_ntu_edu_sg/ETuQX1ePORdKmQJ_wFXT1mUBS6MqJ3LoZ-eeUsDhhXouug?e=AmMgBX) -Carpet1_seq2|1.7g|8499|[Link](https://entuedu-my.sharepoint.com/:u:/g/personal/kuan_xu_staff_main_ntu_edu_sg/EQwzCVxFMT1Hh9BMMNljwSgBM27RXd7v8gdM3KMNWm5mDQ?e=aSoH1v) -Carpet2_seq1|3.0g|15481|[Link](https://entuedu-my.sharepoint.com/:u:/g/personal/kuan_xu_staff_main_ntu_edu_sg/EZ6Y6xsmk6xBjkkU7JNrVQIB_zTovWY8-AOPdW7AN7XJLw?e=GvlK03) -Carpet3_seq1|0.7g|4500|[Link](https://entuedu-my.sharepoint.com/:u:/g/personal/kuan_xu_staff_main_ntu_edu_sg/EXxxHyPOvsFBh8judFQqhtEB-kI6uBzFmKcCiNDZZBzBIw?e=917b5c) -Carpet3_seq2|0.7g|4385|[Link](https://entuedu-my.sharepoint.com/:u:/g/personal/kuan_xu_staff_main_ntu_edu_sg/EQHoNL0xtpdKj6e6mhBBLyEBl-7s5N0cJ6U47jzT1tJheg?e=ot4hSH) -Carpet3_seq3|1.0g|6428|[Link](https://entuedu-my.sharepoint.com/:u:/g/personal/kuan_xu_staff_main_ntu_edu_sg/EcE3o-HN0UJEpc57_EJM3kcBSVSIQ8M7oCjkWsZlUQRKLw?e=qG8MUM) -Coarse_asphalt_seq1|1.2g|5897|[Link](https://entuedu-my.sharepoint.com/:u:/g/personal/kuan_xu_staff_main_ntu_edu_sg/EQbDBVemPH9Cp7bqV2ZwfFIBD_gsHQ-d3atPfSY8__6DKQ?e=ASludI) -Concrete_seq1|1.0g|5850|[Link](https://entuedu-my.sharepoint.com/:u:/g/personal/kuan_xu_staff_main_ntu_edu_sg/EcIYh8RIhClKs7ogwgFmS_QBlflxcx-eR33BwRVerNXFgg?e=8McLDA) -Concrete_seq2|0.9g|5975|[Link](https://entuedu-my.sharepoint.com/:u:/g/personal/kuan_xu_staff_main_ntu_edu_sg/EbNJ5FdpQSJMqK-2zyoEPNoBNCO4ZzhuzjzTL2m1AYZQKQ?e=feQNUX) -Fine_asphalt_seq1|1.1g|5119|[Link](https://entuedu-my.sharepoint.com/:u:/g/personal/kuan_xu_staff_main_ntu_edu_sg/EY22RWOcM89ApAYEr0E5I5EB6QhINnL5iGsbgli8INjuXg?e=HArfqb) -Fine_asphalt_seq2|1.3g|11897|[Link](https://entuedu-my.sharepoint.com/:u:/g/personal/kuan_xu_staff_main_ntu_edu_sg/ERBTClOvkpBHgNeAEc5co4sBI5E-ubQ2MqNFwlfys07mbQ?e=WDd0uP) -Granite_tiles_seq1|1.2g|7194|[Link](https://entuedu-my.sharepoint.com/:u:/g/personal/kuan_xu_staff_main_ntu_edu_sg/ERNkKMy_nvFFmORT7LU_MxEB7TDzhAsNKEEfBf_cNG4Zbg?e=sjDkYW) -Granite_tiles_seq2|1.6g|10633|[Link](https://entuedu-my.sharepoint.com/:u:/g/personal/kuan_xu_staff_main_ntu_edu_sg/EU-8ocb82WZDpErJuOGfR6oBbQwXEpAzR-nykA6wXk9zeg?e=Vx4P1t) -Gravel_road1_seq1|0.8g|4883|[Link](https://entuedu-my.sharepoint.com/:u:/g/personal/kuan_xu_staff_main_ntu_edu_sg/ERRQQR0VTCVEqSdo9pM85zwBNMQFRBcgev4VVIZtjg68Vg?e=KFxJST) -Gravel_road2_seq1|2.1g|11776|[Link](https://entuedu-my.sharepoint.com/:u:/g/personal/kuan_xu_staff_main_ntu_edu_sg/EZS9BNL-ct1Nu3_Ag1Z0YuIBt6ah02i8vojro4eHexs4ww?e=hQOLIF) - - -### Run with Your Data - -The data should be organized in the following format: -``` -dataroot -├── image_names.txt -├── rgb -│   ├── 00001.png -│   ├── 00002.png -│   ├── 00003.png -│   └── ...... -└── times.txt -``` -where `image_names.txt` contains the image names in `/dataroot/rgb` and `times.txt` contains the corresponding double type timestamps. - -## Experiments - -### Data Association - - data_association - -We compare the data association of our system with ORB and SIFT on the HD Ground dataset. The numbers of features and matching inliers are given. For our method, the correction results are projected to three coordinate axes and represent the estimation of the 3-DOF movement. The vertical axis is the confidence of estimated movement on the horizontal axis. The higher the value of the peak relative to other positions, the greater the confidence of motion estimation. The results show that the data association of our system is more stable for various ground texture images. - -### Visual Odometry -
- - -
- -This experiment is conducted on our PathTex dataset. The left figure shows the trajectories produced by our system and GT-SLAM on 4 sequences. The right figure provides the comparison of error distributions of different systems on the Gravel_road2_seq1 sequence, where the vertical axis is the proportion of pose errors that are less than the given error threshold on the horizontal axis. - -### Loop Closure - -
- - -
- -These two figures show the performance difference of GroundSLAM with and without loop correction on the Fine_asphalt_seq2 sequence. It is seen that the pose errors are significantly decreased after the loop correction. diff --git a/src/ground_slam/cmake/FindEigen3.cmake b/src/ground_slam/cmake/FindEigen3.cmake deleted file mode 100755 index 0bb8c71..0000000 --- a/src/ground_slam/cmake/FindEigen3.cmake +++ /dev/null @@ -1,94 +0,0 @@ -# - Try to find Eigen3 lib -# -# This module supports requiring a minimum version, e.g. you can do -# find_package(Eigen3 3.1.2) -# to require version 3.1.2 or newer of Eigen3. -# -# Once done this will define -# -# EIGEN3_FOUND - system has eigen lib with correct version -# EIGEN3_INCLUDE_DIR - the eigen include directory -# EIGEN3_VERSION - eigen version - -# Copyright (c) 2006, 2007 Montel Laurent, -# Copyright (c) 2008, 2009 Gael Guennebaud, -# Copyright (c) 2009 Benoit Jacob -# Redistribution and use is allowed according to the terms of the 2-clause BSD license. - - -if(NOT Eigen3_FIND_VERSION) - if(NOT Eigen3_FIND_VERSION_MAJOR) - set(Eigen3_FIND_VERSION_MAJOR 2) - endif(NOT Eigen3_FIND_VERSION_MAJOR) - if(NOT Eigen3_FIND_VERSION_MINOR) - set(Eigen3_FIND_VERSION_MINOR 91) - endif(NOT Eigen3_FIND_VERSION_MINOR) - if(NOT Eigen3_FIND_VERSION_PATCH) - set(Eigen3_FIND_VERSION_PATCH 0) - endif(NOT Eigen3_FIND_VERSION_PATCH) - - set(Eigen3_FIND_VERSION "${Eigen3_FIND_VERSION_MAJOR}.${Eigen3_FIND_VERSION_MINOR}.${Eigen3_FIND_VERSION_PATCH}") -endif(NOT Eigen3_FIND_VERSION) - -macro(_eigen3_check_version) - file(READ "${EIGEN3_INCLUDE_DIR}/Eigen/src/Core/util/Macros.h" _eigen3_version_header) - - string(REGEX MATCH "define[ \t]+EIGEN_WORLD_VERSION[ \t]+([0-9]+)" _eigen3_world_version_match "${_eigen3_version_header}") - set(EIGEN3_WORLD_VERSION "${CMAKE_MATCH_1}") - string(REGEX MATCH "define[ \t]+EIGEN_MAJOR_VERSION[ \t]+([0-9]+)" _eigen3_major_version_match "${_eigen3_version_header}") - set(EIGEN3_MAJOR_VERSION "${CMAKE_MATCH_1}") - string(REGEX MATCH "define[ \t]+EIGEN_MINOR_VERSION[ \t]+([0-9]+)" _eigen3_minor_version_match "${_eigen3_version_header}") - set(EIGEN3_MINOR_VERSION "${CMAKE_MATCH_1}") - - set(EIGEN3_VERSION ${EIGEN3_WORLD_VERSION}.${EIGEN3_MAJOR_VERSION}.${EIGEN3_MINOR_VERSION}) - if(${EIGEN3_VERSION} VERSION_LESS ${Eigen3_FIND_VERSION}) - set(EIGEN3_VERSION_OK FALSE) - else(${EIGEN3_VERSION} VERSION_LESS ${Eigen3_FIND_VERSION}) - set(EIGEN3_VERSION_OK TRUE) - endif(${EIGEN3_VERSION} VERSION_LESS ${Eigen3_FIND_VERSION}) - - if(NOT EIGEN3_VERSION_OK) - - message(STATUS "Eigen3 version ${EIGEN3_VERSION} found in ${EIGEN3_INCLUDE_DIR}, " - "but at least version ${Eigen3_FIND_VERSION} is required") - endif(NOT EIGEN3_VERSION_OK) -endmacro(_eigen3_check_version) - -if (EIGEN3_INCLUDE_DIR) - - # in cache already - _eigen3_check_version() - set(EIGEN3_FOUND ${EIGEN3_VERSION_OK}) - -else (EIGEN3_INCLUDE_DIR) - - # specific additional paths for some OS - if (WIN32) - set(EIGEN_ADDITIONAL_SEARCH_PATHS ${EIGEN_ADDITIONAL_SEARCH_PATHS} "C:/Program Files/Eigen/include" "C:/Program Files (x86)/Eigen/include") - endif(WIN32) - - find_path(EIGEN3_INCLUDE_DIR NAMES signature_of_eigen3_matrix_library - PATHS - ${CMAKE_INSTALL_PREFIX}/include - ${EIGEN_ADDITIONAL_SEARCH_PATHS} - ${KDE4_INCLUDE_DIR} - PATH_SUFFIXES eigen3 eigen - ) - - if(EIGEN3_INCLUDE_DIR) - _eigen3_check_version() - endif(EIGEN3_INCLUDE_DIR) - - include(FindPackageHandleStandardArgs) - find_package_handle_standard_args(Eigen3 DEFAULT_MSG EIGEN3_INCLUDE_DIR EIGEN3_VERSION_OK) - - mark_as_advanced(EIGEN3_INCLUDE_DIR) - -endif(EIGEN3_INCLUDE_DIR) - -if(EIGEN3_FOUND) - include_directories(${EIGEN3_INCLUDE_DIR}) - link_directories(${EIGEN3_LIBRARIES}) -else(EIGEN3_FOUND) - MESSAGE(FATAL_ERROR "Eigen3 library not found") -endif(EIGEN3_FOUND) \ No newline at end of file diff --git a/src/ground_slam/cmake/FindFFTW3.cmake b/src/ground_slam/cmake/FindFFTW3.cmake deleted file mode 100755 index ff45261..0000000 --- a/src/ground_slam/cmake/FindFFTW3.cmake +++ /dev/null @@ -1,18 +0,0 @@ -# - Find FFTW3 -# Find the native FFTW3 includes and library -# -# FFTW3_INCLUDE_DIRS - where to find fftw3.h -# FFTW3_LIBRARIES - List of libraries when using FFTW3. -# FFTW3_FOUND - True if FFTW3 found. - -if (FFTW3_INCLUDE_DIRS) - set(FFTW3_FIND_QUIETLY TRUE) -endif() - -find_path(FFTW3_INCLUDE_DIRS fftw3.h) -find_library(FFTW3_LIBRARIES NAMES fftw3) - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(FFTW3 DEFAULT_MSG FFTW3_LIBRARIES FFTW3_INCLUDE_DIRS) - -mark_as_advanced(FFTW3_LIBRARIES FFTW3_INCLUDE_DIRS) diff --git a/src/ground_slam/configs/config_HD.yaml b/src/ground_slam/configs/config_HD.yaml deleted file mode 100644 index 9749322..0000000 --- a/src/ground_slam/configs/config_HD.yaml +++ /dev/null @@ -1,49 +0,0 @@ -dataset: - camera_config: /media/zheng/xukuanssd/NTU/ground_texture/HD_ground/camera.yaml - dataroot: /media/zheng/xukuanssd/NTU/ground_texture/HD_ground/ramp_rubber/database/seq0033 - image_dir_name: rgb - -correlation_flow: - gaussian: - sigma: 0.2 - height: 1200 - kernel: 0 # {0: "polynomial", 1: "gaussian"} - lambda: 0.1 - polynomial: - offset: 0.1 - power: 3 - rotation_channel: 480 - rotation_divisor: 720 - width: 1600 - -keyframe_selection: - lower_response_thr: 30 - max_angle: 6.3 - max_distance: 0.01 - upper_response_thr: 90 - -map: - grid_scale: 0.1 # the true size of one grid - -loop_closure: - to_find_loop: true - angle_response_thr: 60 - distance_thr: 5 - frame_gap_thr: 100 - position_response_thr: 60 - -map_sticther: - cell_size: 1000 - stitch_map: true - -visualization: - frame_id: map - topic: - image: /kcc_slam/image - frame_pose: /kcc_slam/frame_pose - kcc_pose: /kcc_slam/kcc_pose - map: /kcc_slam/occupancy_map - -saving: - save_pose: true - saving_root: /home/xukuan/debug/kcc diff --git a/src/ground_slam/configs/config_geekplus.yaml b/src/ground_slam/configs/config_geekplus.yaml deleted file mode 100644 index ff333d3..0000000 --- a/src/ground_slam/configs/config_geekplus.yaml +++ /dev/null @@ -1,50 +0,0 @@ -dataset: - dataroot: "/home/zheng/datasets/loopclosure/" - camera_config: "/home/zheng/datasets/loopclosure/camera.yaml" - image_dir_name: "" - -correlation_flow: - width: 448 - height: 448 - rotation_divisor: 720 #720 # Higher means higher resolution, but slower - rotation_channel: 480 #480 # Lower means faster. Too lower, e.g., less than 10, may produce error about 1/rotation_divisor*360 degrees. 64 may work well. - lambda: 0.1 # For regularization - kernel: 0 #1 # {0: "polynomial", 1: "gaussian"} - polynomial: # (X^T Y + offset).pow(power) - offset: 0.1 - power: 3 - gaussian: # exp(-(|X-Y|^2/(2*sigma^2))) - sigma: 0.2 # For Gaussian Kernel - -keyframe_selection: - to_find_loop: true - max_distance: 0.2 # in normalized plane, real size equal max_distance*camera_height - max_angle: 0.5 # rad - lower_response_thr: 30 - upper_response_thr: 60 - -map: - grid_scale: 0.1 # the true size of one grid - -loop_closure: - to_find_loop: true - position_response_thr: 60 # this should be tuned together with width and height: higher width*height -> higher threshold - angle_response_thr: 60 # this should be tuned together with rotation_divisor and rotation_channel: higher divisor*channel -> higher threshold - frame_gap_thr: 100 - distance_thr: 5 # in normalized plane, real size equal distance_thr*camera_height - -map_sticther: - stitch_map: true # whether to stitch map - cell_size: 1000 - -visualization: - frame_id: "map" - topic: - image: /kcc_slam/undistort_image - kcc_pose: "/kcc_slam/kcc_pose" - frame_pose: "/kcc_slam/frame_pose" - map: "/kcc_slam/occupancy_map" - -saving: - save_pose: true - saving_root: "/home/zheng/projects/ros_ws/src/kcc_slam/saving/experiments" \ No newline at end of file diff --git a/src/ground_slam/configs/config_ntu.yaml b/src/ground_slam/configs/config_ntu.yaml deleted file mode 100644 index 0678a70..0000000 --- a/src/ground_slam/configs/config_ntu.yaml +++ /dev/null @@ -1,49 +0,0 @@ -dataset: - camera_config: /media/data/datasets/ntu/NTU_Ground_Texture_Dataset/camera.yaml - dataroot: /media/data/datasets/ntu/NTU_Ground_Texture_Dataset/brick-V3 - image_dir_name: rgb - -correlation_flow: - gaussian: - sigma: 0.2 - height: 480 - kernel: 0 # {0: "polynomial", 1: "gaussian"} - lambda: 0.1 - polynomial: - offset: 0.1 - power: 3 - rotation_channel: 480 - rotation_divisor: 720 - width: 640 - -keyframe_selection: - lower_response_thr: 30 - max_angle: 0.052359877 - max_distance: 0.4 - upper_response_thr: 90 - -map: - grid_scale: 0.1 # the true size of one grid - -loop_closure: - to_find_loop: true - angle_response_thr: 60 - distance_thr: 5 - frame_gap_thr: 100 - position_response_thr: 60 - -map_sticther: - cell_size: 1000 - stitch_map: true - -visualization: - frame_id: map - topic: - image: /kcc_slam/image - frame_pose: /kcc_slam/frame_pose - kcc_pose: /kcc_slam/kcc_pose - map: /kcc_slam/occupancy_map - -saving: - save_pose: true - saving_root: /home/xukuan/debug/kcc diff --git a/src/ground_slam/figures/data_association.jpg b/src/ground_slam/figures/data_association.jpg deleted file mode 100644 index b59c5b5..0000000 Binary files a/src/ground_slam/figures/data_association.jpg and /dev/null differ diff --git a/src/ground_slam/figures/features_small.jpg b/src/ground_slam/figures/features_small.jpg deleted file mode 100644 index 32efc20..0000000 Binary files a/src/ground_slam/figures/features_small.jpg and /dev/null differ diff --git a/src/ground_slam/figures/fig1.jpg b/src/ground_slam/figures/fig1.jpg deleted file mode 100644 index c61fbe2..0000000 Binary files a/src/ground_slam/figures/fig1.jpg and /dev/null differ diff --git a/src/ground_slam/figures/loop_error.jpg b/src/ground_slam/figures/loop_error.jpg deleted file mode 100644 index 8a9b23e..0000000 Binary files a/src/ground_slam/figures/loop_error.jpg and /dev/null differ diff --git a/src/ground_slam/figures/loop_trajectory.jpg b/src/ground_slam/figures/loop_trajectory.jpg deleted file mode 100644 index e911c72..0000000 Binary files a/src/ground_slam/figures/loop_trajectory.jpg and /dev/null differ diff --git a/src/ground_slam/figures/pipeline.png b/src/ground_slam/figures/pipeline.png deleted file mode 100644 index d0cb802..0000000 Binary files a/src/ground_slam/figures/pipeline.png and /dev/null differ diff --git a/src/ground_slam/figures/rmse_curve.jpg b/src/ground_slam/figures/rmse_curve.jpg deleted file mode 100644 index 6197e4d..0000000 Binary files a/src/ground_slam/figures/rmse_curve.jpg and /dev/null differ diff --git a/src/ground_slam/figures/sample_images.jpg b/src/ground_slam/figures/sample_images.jpg deleted file mode 100644 index d5caa81..0000000 Binary files a/src/ground_slam/figures/sample_images.jpg and /dev/null differ diff --git a/src/ground_slam/figures/trajectory.jpg b/src/ground_slam/figures/trajectory.jpg deleted file mode 100644 index 85f7585..0000000 Binary files a/src/ground_slam/figures/trajectory.jpg and /dev/null differ diff --git a/src/ground_slam/figures/video.png b/src/ground_slam/figures/video.png deleted file mode 100644 index 9a3b242..0000000 Binary files a/src/ground_slam/figures/video.png and /dev/null differ diff --git a/src/ground_slam/include/camera.h b/src/ground_slam/include/camera.h deleted file mode 100644 index b8447b2..0000000 --- a/src/ground_slam/include/camera.h +++ /dev/null @@ -1,59 +0,0 @@ -#ifndef CAMERA_H_ -#define CAMERA_H_ - -#include -#include -#include -#include -#include -#include -#include - -class Camera{ -public: - Camera(); - Camera(const std::string& camera_file); - Camera& operator=(const Camera& camera); - - void UndistortImage(cv::Mat& image, cv::Mat& undistort_image); - void GetNewCameraMatrix(cv::Mat& camera_matrix); - double GetImageHeight(); - double GetImageWidth(); - double GetHeight(); - bool HeightIsAccurate(); - void GetExtrinsics(Eigen::Matrix3d& extrinsics); - double GetLengthOfPixel(); - - Eigen::Vector3d ConvertPrincipalToCenter(const Eigen::Vector3d& image_plane_pose); - Eigen::Vector3d ConvertCenterToPrincipal(const Eigen::Vector3d& image_center_pose); - - // Image plane: pixel plane, principal point on the image is the origin - // Camera: normalized plane, - // Robot: robot body coordinate system. - bool ConvertImagePlanePoseToCamera(Eigen::Vector3d& image_plane_pose, Eigen::Vector3d& camera_pose); - bool ConvertCameraPoseToImagePlane(Eigen::Vector3d& image_plane_pose, Eigen::Vector3d& camera_pose); - bool ConvertCameraPoseToRobot(Eigen::Vector3d& camera_pose, Eigen::Vector3d& robot_pose); - bool ConvertRobotPoseToCamera(Eigen::Vector3d& camera_pose, Eigen::Vector3d& robot_pose); - bool ConvertImagePlanePoseToRobot(Eigen::Vector3d& image_plane_pose, Eigen::Vector3d& robot_pose); - bool ConvertRobotPoseToImagePlane(Eigen::Vector3d& image_plane_pose, Eigen::Vector3d& robot_pose); - -private: - int _image_height; - int _image_width; - double _scale; - double _new_scale; - int _new_width; - int _new_height; - double _height; - bool _accurate_height; - cv::Mat _K; - cv::Mat _new_K; - cv::Mat _D; - cv::Mat _map1; - cv::Mat _map2; - Eigen::Matrix3d _extrinsics; -}; - -typedef std::shared_ptr CameraPtr; - -#endif // CAMERA_H_ \ No newline at end of file diff --git a/src/ground_slam/include/circ_shift.h b/src/ground_slam/include/circ_shift.h deleted file mode 100644 index dd37b42..0000000 --- a/src/ground_slam/include/circ_shift.h +++ /dev/null @@ -1,252 +0,0 @@ -// circ_shift.h -// https://stackoverflow.com/questions/46077242/eigen-modifyable-custom-expression/46301503#46301503 -// this file implements circShift, fftshift, and ifftshift for Eigen vectors/matrices. -// - -#pragma once -#include - -template using bool_constant = std::integral_constant; - -namespace helper -{ -namespace detail -{ -template -constexpr std::true_type is_matrix(Eigen::MatrixBase); -std::false_type constexpr is_matrix(...); - -template -constexpr std::true_type is_array(Eigen::ArrayBase); -std::false_type constexpr is_array(...); -} - - -template -struct is_matrix : decltype(detail::is_matrix(std::declval>())) -{ -}; - -template -struct is_array : decltype(detail::is_array(std::declval>())) -{ -}; - -template -using is_matrix_or_array = bool_constant::value || is_matrix::value>; - -/* - * Index something if it's not an scalar - */ -template ::value, int>::type = 0> -auto index_if_necessary(T&& thing, Eigen::Index idx) -{ - return thing(idx); -} - -/* - * Overload for scalar. - */ -template >::value, int>::type = 0> - auto index_if_necessary(T&& thing, Eigen::Index) -{ - return thing; -} -} - -namespace Eigen -{ -template -class CircShiftedView; - -namespace internal -{ -template -struct traits> - : traits -{ - enum - { - RowsAtCompileTime = traits::RowsAtCompileTime, - ColsAtCompileTime = traits::ColsAtCompileTime, - MaxRowsAtCompileTime = (RowsAtCompileTime != Dynamic - ? int(RowsAtCompileTime) - : int(traits::MaxRowsAtCompileTime)), - MaxColsAtCompileTime = (ColsAtCompileTime != Dynamic - ? int(ColsAtCompileTime) - : int(traits::MaxColsAtCompileTime)), - XprTypeIsRowMajor = (int(traits::Flags) & RowMajorBit) != 0, - IsRowMajor = ((MaxRowsAtCompileTime == 1 && MaxColsAtCompileTime != 1) ? 1 - : (MaxColsAtCompileTime == 1 && MaxRowsAtCompileTime != 1) ? 0 - : XprTypeIsRowMajor), - FlagsRowMajorBit = IsRowMajor ? RowMajorBit : 0, - FlagsLvalueBit = is_lvalue::value ? LvalueBit : 0, - Flags = (traits::Flags & HereditaryBits) | FlagsLvalueBit | FlagsRowMajorBit - }; -}; -} - -template -class CircShiftedViewImpl; - - -template -class CircShiftedView : public CircShiftedViewImpl::StorageKind> -{ -public: - typedef typename CircShiftedViewImpl::StorageKind>::Base Base; - EIGEN_GENERIC_PUBLIC_INTERFACE(CircShiftedView) - EIGEN_INHERIT_ASSIGNMENT_OPERATORS(CircShiftedView) - - typedef typename internal::ref_selector::non_const_type MatrixTypeNested; - typedef typename internal::remove_all::type NestedExpression; - - template - CircShiftedView(XprType& xpr, const T0& rowShift, const T1& colShift) - : m_xpr(xpr), m_rowShift(rowShift), m_colShift(colShift) - { - for (auto c = 0; c < xpr.cols(); ++c) - assert(std::abs(helper::index_if_necessary(m_rowShift, c)) < m_xpr.rows()); // row shift must be within +- rows()-1 - for (auto r = 0; r < xpr.rows(); ++r) - assert(std::abs(helper::index_if_necessary(m_colShift, r)) < m_xpr.cols()); // col shift must be within +- cols()-1 - } - - /** \returns number of rows */ - Index rows() const { return m_xpr.rows(); } - - /** \returns number of columns */ - Index cols() const { return m_xpr.cols(); } - - /** \returns the nested expression */ - const typename internal::remove_all::type& - nestedExpression() const { return m_xpr; } - - /** \returns the nested expression */ - typename internal::remove_reference::type& - nestedExpression() { return m_xpr.const_cast_derived(); } - - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE - Index getRowIdx(Index row, Index col) const - { - Index R = m_xpr.rows(); - assert(row >= 0 && row < R && col >= 0 && col < m_xpr.cols()); - Index r = row - helper::index_if_necessary(m_rowShift, col); - if (r >= R) - return r - R; - if (r < 0) - return r + R; - return r; - } - - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE - Index getColIdx(Index row, Index col) const - { - Index C = m_xpr.cols(); - assert(row >= 0 && row < m_xpr.rows() && col >= 0 && col < C); - Index c = col - helper::index_if_necessary(m_colShift, row); - if (c >= C) - return c - C; - if (c < 0) - return c + C; - return c; - } - -protected: - MatrixTypeNested m_xpr; - RowShift m_rowShift; - ColShift m_colShift; -}; - - -// Generic API dispatcher -template -class CircShiftedViewImpl - : public internal::generic_xpr_base>::type -{ - public: - typedef typename internal::generic_xpr_base>::type Base; -}; - -namespace internal -{ -template -struct unary_evaluator, IndexBased> - : evaluator_base> -{ - typedef CircShiftedView XprType; - - enum - { - CoeffReadCost = (evaluator::CoeffReadCost - + NumTraits::AddCost /* for comparison */ - + NumTraits::AddCost) /* for addition */, - Flags = (evaluator::Flags & HereditaryBits), - Alignment = 0 - }; - - EIGEN_DEVICE_FUNC explicit unary_evaluator(const XprType& xpr) : m_argImpl(xpr.nestedExpression()), m_xpr(xpr) - { - EIGEN_INTERNAL_CHECK_COST_VALUE(CoeffReadCost); - } - - typedef typename XprType::Scalar Scalar; - typedef typename XprType::CoeffReturnType CoeffReturnType; - - - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE - CoeffReturnType coeff(Index row, Index col) const - { - return m_argImpl.coeff(m_xpr.getRowIdx(row, col), m_xpr.getColIdx(row, col)); - } - - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE - CoeffReturnType coeff(Index idx) const - { - if (m_xpr.cols() == 1) - return m_argImpl.coeff(m_xpr.getRowIdx(idx, 1), 1); - if (m_xpr.rows() == 1) - return m_argImpl.coeff(1, m_xpr.getColIdx(1, idx)); - assert(m_xpr.cols() == 1 || m_xpr.rows() == 1); - // default no-assert case - assume col vector - return m_argImpl.coeff(m_xpr.getRowIdx(idx, 1), 1); - } - - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE - Scalar& coeffRef(Index row, Index col) - { - assert(row >= 0 && row < m_xpr.rows() && col >= 0 && col < m_xpr.cols()); - - return m_argImpl.coeffRef(m_xpr.getRowIdx(row, col), m_xpr.getColIdx(row, col)); - } - - protected: - - evaluator m_argImpl; - const XprType& m_xpr; -}; -} // end namespace internal -} // end namespace Eigen - -template -auto circShift(Eigen::DenseBase& x, RowShift r, ColShift c) -{ - return Eigen::CircShiftedView(x.derived(), r, c); -} - -template -auto fftshift(Eigen::DenseBase& x) -{ - Eigen::Index rs = x.rows() / 2; - Eigen::Index cs = x.cols() / 2; - return Eigen::CircShiftedView(x.derived(), rs, cs); -} - -template -auto ifftshift(Eigen::DenseBase& x) -{ - Eigen::Index rs = (x.rows() + 1) / 2; - Eigen::Index cs = (x.cols() + 1) / 2; - return Eigen::CircShiftedView(x.derived(), rs, cs); -} \ No newline at end of file diff --git a/src/ground_slam/include/correlation_flow.h b/src/ground_slam/include/correlation_flow.h deleted file mode 100644 index bbe3d96..0000000 --- a/src/ground_slam/include/correlation_flow.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef CORRELATION_FLOW_H -#define CORRELATION_FLOW_H - -#include -#include "utils.h" -#include "read_configs.h" - -class CorrelationFlow{ - -public: - CorrelationFlow(CFConfig& cf_config, double &image_height, double &image_width); - void ComputeIntermedium(const Eigen::ArrayXXf&, Eigen::ArrayXXcf&, Eigen::ArrayXXcf&); - Eigen::Vector3d ComputePose(const Eigen::ArrayXXcf&, const Eigen::ArrayXXf&, const Eigen::ArrayXXcf&, const Eigen::ArrayXXcf&, Eigen::Vector3d&, bool); - -private: - CFConfig cfg; - Eigen::ArrayXXcf target_fft; - Eigen::ArrayXXcf target_rotation_fft; - Eigen::ArrayXXcf FFT(const Eigen::ArrayXXf&); - Eigen::ArrayXXf IFFT(const Eigen::ArrayXXcf&); - Eigen::ArrayXXcf GetTargetFFT(int, int); - inline Eigen::ArrayXXf RemoveZeroComponent(const Eigen::ArrayXXf&); - inline Eigen::ArrayXXcf gaussian_kernel(const Eigen::ArrayXXcf&, int, int); - inline Eigen::ArrayXXcf gaussian_kernel(const Eigen::ArrayXXcf&, const Eigen::ArrayXXcf&, int, int); - inline Eigen::ArrayXXcf polynomial_kernel(const Eigen::ArrayXXcf&, int, int); - inline Eigen::ArrayXXcf polynomial_kernel(const Eigen::ArrayXXcf&, const Eigen::ArrayXXcf&, int, int); - float EstimateTrans(const Eigen::ArrayXXcf&, const Eigen::ArrayXXcf&, const Eigen::ArrayXXcf&, int, int, Eigen::Vector2d&); - inline Eigen::ArrayXXf polar(const Eigen::ArrayXXf&); - inline float GetInfo(const Eigen::ArrayXXf&, float); - - // void PrintArrayToFile (const Eigen::ArrayXXf target); -}; - -typedef std::shared_ptr CorrelationFlowPtr; - -#endif // CORRELATION_FLOW_H \ No newline at end of file diff --git a/src/ground_slam/include/dataset.h b/src/ground_slam/include/dataset.h deleted file mode 100644 index 31834f8..0000000 --- a/src/ground_slam/include/dataset.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef DATASET_H_ -#define DATASET_H_ - -#include -#include -#include -#include -#include -#include - -#include "utils.h" - - -class Dataset{ -public: - Dataset(const std::string& dataroot, const std::string& image_dir_name); - size_t GetDatasetLength(); - bool GetImage(cv::Mat& image, size_t idx); - double GetTimestamp(size_t idx); - -private: - std::string _dataroot; - std::string _image_dir; - std::string _image_name_file_path; - std::vector _image_names; - std::string _time_file_path; - std::vector _timestamps; -}; - -#endif // DATASET_H_ \ No newline at end of file diff --git a/src/ground_slam/include/edge.h b/src/ground_slam/include/edge.h deleted file mode 100644 index bf4581b..0000000 --- a/src/ground_slam/include/edge.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef EDGE_H_ -#define EDGE_H_ - -#include -#include -#include - -#include "utils.h" - -struct Edge{ - enum Type { - Odom = 0, - KCC = 1, - Loop = 2, - Others = 3, - }; - - int _edge_id; - Type _type; - int _from; - int _to; - Eigen::Vector3d _T; - Eigen::Matrix3d _information; - - Edge(); - Edge(int edge_id, Type type, int from, int to, Eigen::Vector3d& T, Eigen::Matrix3d& information); -}; - -typedef std::shared_ptr EdgePtr; - -#endif // EDGE_H_ \ No newline at end of file diff --git a/src/ground_slam/include/frame.h b/src/ground_slam/include/frame.h deleted file mode 100644 index 836f082..0000000 --- a/src/ground_slam/include/frame.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef FRAME_H_ -#define FRAME_H_ - -#include -#include -#include - -#include "utils.h" - - -class Frame{ -public: - Frame(); - Frame(int frame_id); - Frame(int frame_id, double timestamp, Eigen::ArrayXXf&, Eigen::ArrayXXcf&, Eigen::ArrayXXcf&); - Frame& operator=(const Frame& other); - - void SetFrameId(int frame_id); - int GetFrameId(); - double GetTimestamp(); - Eigen::ArrayXXf GetFrame(); - void SetFFTResult(Eigen::ArrayXXcf& fft_result); - void SetFFTResult(Eigen::ArrayXXcf& fft_result, Eigen::ArrayXXcf& depth_fft_result); - void GetFFTResult(Eigen::ArrayXXcf& fft_result); - void GetFFTResult(Eigen::ArrayXXcf& fft_result, Eigen::ArrayXXcf& depth_fft_result); - void SetPose(Eigen::Vector3d& pose); - void GetPose(Eigen::Vector3d& pose); - void AddEdge(int edge_id); - void GetEdgeIds(std::vector& edge_ids); - void SaveToDisk(const std::string root_dir); - -private: - int _frame_id; - double _timestamp; - Eigen::ArrayXXf _frame; - Eigen::ArrayXXcf _fft_result; - Eigen::ArrayXXcf _fft_polar; - Eigen::ArrayXXcf _depth_fft_result; - Eigen::Vector3d _pose; - std::vector _edge_ids; -}; - -typedef std::shared_ptr FramePtr; - -#endif // FRAME_H_ \ No newline at end of file diff --git a/src/ground_slam/include/loop_closure.h b/src/ground_slam/include/loop_closure.h deleted file mode 100644 index 274dd9c..0000000 --- a/src/ground_slam/include/loop_closure.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef LOOP_CLOSURE_H_ -#define LOOP_CLOSURE_H_ - -#include "read_configs.h" -#include "correlation_flow.h" -#include "map.h" - - -struct LoopClosureResult{ - bool found; - Eigen::Vector3d response; - FramePtr current_frame; - FramePtr loop_frame; - Eigen::Vector3d relative_pose; - - LoopClosureResult(): found(false), response(-1.0, -1.0, -1.0) {} - LoopClosureResult(bool _found, Eigen::Vector3d _resopnse): found(_found), response(_resopnse) {} - LoopClosureResult& operator=(const LoopClosureResult& other){ - found = other.found; - response = other.response; - current_frame = other.current_frame; - loop_frame = other.loop_frame; - relative_pose = other.relative_pose; - return *this; - } -}; - -class LoopClosure{ -public: - LoopClosure(LoopClosureConfig& loop_closure_config, CorrelationFlowPtr correlation_flow, MapPtr map); - LoopClosureResult FindLoopClosure(Eigen::ArrayXXf& image, FramePtr& current_frame); - LoopClosureResult FindLoopClosure(Eigen::ArrayXXf& image, FramePtr& current_frame, Eigen::Vector3d& prior_pose); - LoopClosureResult FindLoopClosure(Eigen::ArrayXXf& image, FramePtr& current_frame, std::vector& frames); - -private: - LoopClosureConfig _loop_thr; - CorrelationFlowPtr _correlation_flow; - MapPtr _map; -}; - -typedef std::shared_ptr LoopClosurePtr; - -#endif // LOOP_CLOSURE_H_ \ No newline at end of file diff --git a/src/ground_slam/include/map.h b/src/ground_slam/include/map.h deleted file mode 100644 index c501023..0000000 --- a/src/ground_slam/include/map.h +++ /dev/null @@ -1,81 +0,0 @@ -#ifndef MAP_H_ -#define MAP_H_ - -#include -#include -#include -#include - -#include "read_configs.h" -#include "camera.h" -#include "frame.h" -#include "edge.h" -#include "utils.h" - - -struct GridLocation{ - GridLocation() : x(0), y(0) {} - GridLocation(int x_, int y_) : x(x_), y(y_) {} - GridLocation& operator=(const GridLocation& other){ - x = other.x; - y = other.y; - return *this; - } - friend std::ostream & operator<<(std::ostream &out, GridLocation &loc){ - out << "(" << loc.x << ", " << loc.y << ")"; - return out; - } - - int x; - int y; -}; - -struct GridLocationHash{ - std::size_t operator() (const GridLocation& loc) const{ - return std::hash()(loc.x) ^ std::hash()(loc.y); - } -}; - -struct GridLocationEqual{ - bool operator()(const GridLocation& l1, const GridLocation& l2) const{ - return l1.x == l2.x && l1.y == l2.y; - } -}; - -typedef std::unordered_set FrameSet; -typedef std::unordered_map GridMap; - -class Map{ -public: - Map(); - Map(MapConfig& map_config); - - void AddFrame(FramePtr& frame); - void SetFrameDistance(FramePtr& frame, double distance); - void AddEdge(EdgePtr& edge); - - int GetAllFrames(std::vector& frames); - double GetFrameDistance(FramePtr& frame); - int GetAllEdges(std::vector& edges); - - void UpdatePoses(AlignedMap frame_poses); - - GridLocation ComputeGridLocation(double x, double y); - GridLocation ComputeGridLocation(Eigen::Vector3d pose); - int GetFramesInGrids(std::vector& frames, std::vector& grid_locations); - - FramePtr GetBaseframe(); - -private: - CameraPtr _camera; - std::map _frames; - std::map _frame_distanses; - std::map _edges; - double _grid_scale; - GridMap _grid_map; - FramePtr _baseframe; -}; - -typedef std::shared_ptr MapPtr; - -#endif // MAP_H_ \ No newline at end of file diff --git a/src/ground_slam/include/map_builder.h b/src/ground_slam/include/map_builder.h deleted file mode 100644 index 941a787..0000000 --- a/src/ground_slam/include/map_builder.h +++ /dev/null @@ -1,83 +0,0 @@ -#ifndef MAP_BUILDER_H_ -#define MAP_BUILDER_H_ - -#include "read_configs.h" -#include "camera.h" -#include "frame.h" -#include "correlation_flow.h" -#include "map.h" -#include "loop_closure.h" -#include "map_stitcher.h" - - -class MapBuilder{ -public: - MapBuilder(Configs& configs); - - bool AddNewInput(cv::Mat& image, double timestamp = -1); - void ComputeFFTResult(cv::Mat& image); - void ConstructFrame(double timestamp); - void SetCurrentFramePose(); - bool Initialize(); - void UpdateIntermedium(); - void UpdateCurrentPose(); - bool Tracking(Eigen::Vector3d& response); - void AddCFEdge(); - void AddCFEdgeToMap(Eigen::Vector3d& relative_pose, int from, int to, - int edge_id, Edge::Type edge_type, Eigen::Matrix3d& info); - Eigen::Vector2d ComputeRelativeDA(); - void SetFrameDistance(); - bool FindLoopClosure(); - void AddLoopEdges(); - bool OptimizeMap(); - void CheckAndOptimize(); - void UpdateValueAfterLoop(); - - // for visualization - bool GetCFPose(Eigen::Vector3d& pose); - bool GetFramePoses(Aligned& poses, std::vector& timestamps); - bool GetOccupancyMapOrigin( - Eigen::Vector3d& pixel_origin, Eigen::Matrix& real_origin); // [qw, qx, qy, qz, x, y, z] - double GetMapResolution(); - OccupancyData& GetMapData(); - -private: - bool _init; - int _frame_id; - int _edge_id; - bool _last_lost; - - // tmp - FramePtr _last_frame; - FramePtr _current_frame; - // image plane pose - Eigen::Vector3d _last_cf_pose; - Eigen::Vector3d _current_cf_pose; - // real scale pose - Eigen::Vector3d _last_cf_real_pose; - Eigen::Vector3d _current_cf_real_pose; - // robot pose - Eigen::Vector3d _last_pose; - Eigen::Vector3d _current_pose; - // distance - double _distance; - - // intermedium rsults - Eigen::ArrayXXf _image_array; - Eigen::ArrayXXcf _last_fft_result; - Eigen::ArrayXXcf _last_fft_polar; - Eigen::ArrayXXcf _fft_result; - Eigen::ArrayXXcf _fft_polar; - std::vector _loop_matches; - - Configs _configs; - CameraPtr _camera; - CorrelationFlowPtr _correlation_flow; - KeyframeSelectionConfig _kfs_config; - MapPtr _map; - LoopClosurePtr _loop_closure; - MapStitcherPtr _map_stitcher; -}; - - -#endif // MAP_BUILDER_H diff --git a/src/ground_slam/include/map_stitcher.h b/src/ground_slam/include/map_stitcher.h deleted file mode 100644 index e16de59..0000000 --- a/src/ground_slam/include/map_stitcher.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef MAP_STITCHER_H_ -#define MAP_STITCHER_H_ - -#include "optimization_2d/pose_graph_2d_error_term.h" -#include "camera.h" -#include "frame.h" -#include "map.h" -#include "read_configs.h" - - -struct Cell{ - int size; - Eigen::ArrayXXi data; - Eigen::ArrayXXi weight; - - Cell(): size(0) {} - Cell(int _size): size(_size), data(Eigen::ArrayXXi::Zero(_size, _size)), weight(Eigen::ArrayXXi::Zero(_size, _size)) {} -}; - -typedef std::unordered_map OccupancyData; - -class MapStitcher{ -public: - MapStitcher(MapStitcherConfig config, CameraPtr camera); - void InsertFrame(FramePtr frame, cv::Mat& image); - // input is the posion in one axis, output is the cell and the position in cell - Eigen::Vector2i ComputeCellPosition(int x); - void AddImageToOccupancy(FramePtr frame); - void RecomputeOccupancy(); - OccupancyData& GetOccupancyData(); - -private: - int _cell_size; - bool _to_stitch; - CameraPtr _camera; - std::unordered_map _raw_images; - OccupancyData _occupancy_data; -}; - -typedef std::shared_ptr MapStitcherPtr; - -#endif // MAP_STITCHER_H_ \ No newline at end of file diff --git a/src/ground_slam/include/optimization_2d/angle_local_parameterization.h b/src/ground_slam/include/optimization_2d/angle_local_parameterization.h deleted file mode 100644 index ed19c15..0000000 --- a/src/ground_slam/include/optimization_2d/angle_local_parameterization.h +++ /dev/null @@ -1,66 +0,0 @@ -// Ceres Solver - A fast non-linear least squares minimizer -// Copyright 2016 Google Inc. All rights reserved. -// http://ceres-solver.org/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// * Neither the name of Google Inc. nor the names of its contributors may be -// used to endorse or promote products derived from this software without -// specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. -// -// Author: vitus@google.com (Michael Vitus) - -#ifndef OPTIMIZATION_2D_ANGLE_LOCAL_PARAMETERIZATION_H_ -#define OPTIMIZATION_2D_ANGLE_LOCAL_PARAMETERIZATION_H_ - -#include - -#include "normalize_angle.h" - - -namespace ceres { -namespace optimization_2d { - -// Defines a local parameterization for updating the angle to be constrained in -// [-pi to pi). -class AngleLocalParameterization { - public: - template - bool operator()(const T* theta_radians, - const T* delta_theta_radians, - T* theta_radians_plus_delta) const { - *theta_radians_plus_delta = - NormalizeAngle(*theta_radians + *delta_theta_radians); - - return true; - } - - static ceres::LocalParameterization* Create() { - return (new ceres::AutoDiffLocalParameterization); - } -}; - -} // namespace optimization_2d -} // namespace ceres - -#endif // OPTIMIZATION_2D_ANGLE_LOCAL_PARAMETERIZATION_H_ \ No newline at end of file diff --git a/src/ground_slam/include/optimization_2d/normalize_angle.h b/src/ground_slam/include/optimization_2d/normalize_angle.h deleted file mode 100644 index 29a9805..0000000 --- a/src/ground_slam/include/optimization_2d/normalize_angle.h +++ /dev/null @@ -1,52 +0,0 @@ -// Ceres Solver - A fast non-linear least squares minimizer -// Copyright 2016 Google Inc. All rights reserved. -// http://ceres-solver.org/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// * Neither the name of Google Inc. nor the names of its contributors may be -// used to endorse or promote products derived from this software without -// specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. -// -// Author: vitus@google.com (Michael Vitus) - -#ifndef OPTIMIZATION_2D_NORMALIZE_ANGLE_H_ -#define OPTIMIZATION_2D_NORMALIZE_ANGLE_H_ - -#include -#include - -namespace ceres { -namespace optimization_2d { - -// Normalizes the angle in radians between [-pi and pi). -template -inline T NormalizeAngle(const T& angle_radians) { - // Use ceres::floor because it is specialized for double and Jet types. - T two_pi(2.0 * M_PI); - return angle_radians - - two_pi * ceres::floor((angle_radians + T(M_PI)) / two_pi); -} - -} // namespace optimization_2d -} // namespace ceres - -#endif // OPTIMIZATION_2D_NORMALIZE_ANGLE_H_ \ No newline at end of file diff --git a/src/ground_slam/include/optimization_2d/pose_graph_2d.h b/src/ground_slam/include/optimization_2d/pose_graph_2d.h deleted file mode 100644 index 64154f1..0000000 --- a/src/ground_slam/include/optimization_2d/pose_graph_2d.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef OPTIMIZATION_2D_POSE_GRAPH_2D_H_ -#define OPTIMIZATION_2D_POSE_GRAPH_2D_H_ - -#include -#include -#include -#include -#include -#include - -#include "angle_local_parameterization.h" -#include "pose_graph_2d_error_term.h" -#include "types.h" - -namespace ceres { -namespace optimization_2d { - -void BuildOptimizationProblem(const std::vector& constraints, - std::map* poses, - ceres::Problem* problem); - -void BuildOptimizationProblemWithScale(const std::vector& constraints, - std::vector& scale_data, - const std::vector& scale_data_idx, - std::map* poses, - ceres::Problem* problem); - -bool SolveOptimizationProblem(ceres::Problem* problem); - -} // namespace optimization_2d -} // namespace ceres - -#endif // OPTIMIZATION_2D_POSE_GRAPH_2D_H_ \ No newline at end of file diff --git a/src/ground_slam/include/optimization_2d/pose_graph_2d_error_term.h b/src/ground_slam/include/optimization_2d/pose_graph_2d_error_term.h deleted file mode 100644 index 9b5a35d..0000000 --- a/src/ground_slam/include/optimization_2d/pose_graph_2d_error_term.h +++ /dev/null @@ -1,183 +0,0 @@ -// Ceres Solver - A fast non-linear least squares minimizer -// Copyright 2016 Google Inc. All rights reserved. -// http://ceres-solver.org/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// * Neither the name of Google Inc. nor the names of its contributors may be -// used to endorse or promote products derived from this software without -// specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. -// -// Author: vitus@google.com (Michael Vitus) -// -// Cost function for a 2D pose graph formulation. - -#ifndef OPTIMIZATION_2D_POSE_GRAPH_2D_ERROR_TERM_H_ -#define OPTIMIZATION_2D_POSE_GRAPH_2D_ERROR_TERM_H_ - -#include - -#include "optimization_2d/normalize_angle.h" - -namespace ceres { -namespace optimization_2d { - -template -Eigen::Matrix RotationMatrix2D(T yaw_radians) { - const T cos_yaw = ceres::cos(yaw_radians); - const T sin_yaw = ceres::sin(yaw_radians); - - Eigen::Matrix rotation; - rotation << cos_yaw, -sin_yaw, sin_yaw, cos_yaw; - return rotation; -} - -// Computes the error term for two poses that have a relative pose measurement -// between them. Let the hat variables be the measurement. -// -// residual = information^{1/2} * [ r_a^T * (p_b - p_a) - \hat{p_ab} ] -// [ Normalize(yaw_b - yaw_a - \hat{yaw_ab}) ] -// -// where r_a is the rotation matrix that rotates a vector represented in frame A -// into the global frame, and Normalize(*) ensures the angles are in the range -// [-pi, pi). -class PoseGraph2dErrorTerm { - public: - PoseGraph2dErrorTerm(double x_ab, - double y_ab, - double yaw_ab_radians, - const Eigen::Matrix3d& sqrt_information) - : p_ab_(x_ab, y_ab), - yaw_ab_radians_(yaw_ab_radians), - sqrt_information_(sqrt_information) {} - - template - bool operator()(const T* const x_a, - const T* const y_a, - const T* const yaw_a, - const T* const x_b, - const T* const y_b, - const T* const yaw_b, - T* residuals_ptr) const { - const Eigen::Matrix p_a(*x_a, *y_a); - const Eigen::Matrix p_b(*x_b, *y_b); - - Eigen::Map> residuals_map(residuals_ptr); - - residuals_map.template head<2>() = - RotationMatrix2D(*yaw_a).transpose() * (p_b - p_a) - p_ab_.cast(); - residuals_map(2) = NormalizeAngle( - (*yaw_b - *yaw_a) - static_cast(yaw_ab_radians_)); - - // Scale the residuals by the square root information matrix to account for - // the measurement uncertainty. - residuals_map = sqrt_information_.template cast() * residuals_map; - - return true; - } - - static ceres::CostFunction* Create(double x_ab, - double y_ab, - double yaw_ab_radians, - const Eigen::Matrix3d& sqrt_information) { - return (new ceres:: - AutoDiffCostFunction( - new PoseGraph2dErrorTerm( - x_ab, y_ab, yaw_ab_radians, sqrt_information))); - } - - EIGEN_MAKE_ALIGNED_OPERATOR_NEW - - private: - // The position of B relative to A in the A frame. - const Eigen::Vector2d p_ab_; - // The orientation of frame B relative to frame A. - const double yaw_ab_radians_; - // The inverse square root of the measurement covariance matrix. - const Eigen::Matrix3d sqrt_information_; -}; - - -class PoseGraph2dErrorTermWithScale { - public: - PoseGraph2dErrorTermWithScale(double x_ab, - double y_ab, - double yaw_ab_radians, - const Eigen::Matrix3d& sqrt_information) - : p_ab_(x_ab, y_ab), - yaw_ab_radians_(yaw_ab_radians), - sqrt_information_(sqrt_information) {} - - template - bool operator()(const T* const x_a, - const T* const y_a, - const T* const yaw_a, - const T* const x_b, - const T* const y_b, - const T* const yaw_b, - const T* const scale, - T* residuals_ptr) const { - const Eigen::Matrix p_a(*x_a, *y_a); - const Eigen::Matrix p_b(*x_b, *y_b); - - Eigen::Map> residuals_map(residuals_ptr); - - Eigen::Matrix scale_matrix = Eigen::Matrix::Identity(); - scale_matrix *= (*scale); - - residuals_map.template head<2>() = - RotationMatrix2D(*yaw_a).transpose() * (p_b - p_a) - scale_matrix * p_ab_.cast(); - residuals_map(2) = NormalizeAngle( - (*yaw_b - *yaw_a) - static_cast(yaw_ab_radians_)); - - // Scale the residuals by the square root information matrix to account for - // the measurement uncertainty. - residuals_map = sqrt_information_.template cast() * residuals_map; - - return true; - } - - static ceres::CostFunction* Create(double x_ab, - double y_ab, - double yaw_ab_radians, - const Eigen::Matrix3d& sqrt_information) { - return (new ceres:: - AutoDiffCostFunction( - new PoseGraph2dErrorTermWithScale( - x_ab, y_ab, yaw_ab_radians, sqrt_information))); - } - - EIGEN_MAKE_ALIGNED_OPERATOR_NEW - - private: - // The position of B relative to A in the A frame. - const Eigen::Vector2d p_ab_; - // The orientation of frame B relative to frame A. - const double yaw_ab_radians_; - // The inverse square root of the measurement covariance matrix. - const Eigen::Matrix3d sqrt_information_; -}; - - -} // namespace optimization_2d -} // namespace ceres - -#endif // OPTIMIZATION_2D_POSE_GRAPH_2D_ERROR_TERM_H_ \ No newline at end of file diff --git a/src/ground_slam/include/optimization_2d/types.h b/src/ground_slam/include/optimization_2d/types.h deleted file mode 100644 index dd2bc35..0000000 --- a/src/ground_slam/include/optimization_2d/types.h +++ /dev/null @@ -1,116 +0,0 @@ -// Ceres Solver - A fast non-linear least squares minimizer -// Copyright 2016 Google Inc. All rights reserved. -// http://ceres-solver.org/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// * Neither the name of Google Inc. nor the names of its contributors may be -// used to endorse or promote products derived from this software without -// specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. -// -// Author: vitus@google.com (Michael Vitus) -// -// Defines the types used in the 2D pose graph SLAM formulation. Each vertex of -// the graph has a unique integer ID with a position and orientation. There are -// delta transformation constraints between two vertices. - -#ifndef OPTIMIZATION_2D_TYPES_H_ -#define OPTIMIZATION_2D_TYPES_H_ - -#include -#include - -#include "optimization_2d/normalize_angle.h" - -namespace ceres { -namespace optimization_2d { - -struct ScaleData{ - double scale; - bool fixed; - - ScaleData() {} - ScaleData(double _scale, bool _fixed): scale(_scale), fixed(_fixed) {} - -}; - -inline std::istream& operator>>(std::istream& input, ScaleData& scale_data) { - input >> scale_data.scale >> scale_data.fixed; - // Normalize the angle between -pi to pi. - return input; -} - -// The state for each vertex in the pose graph. -struct Pose2d { - double x; - double y; - double yaw_radians; - - // The name of the data type in the g2o file format. - static std::string name() { return "VERTEX_SE2"; } -}; - -inline std::istream& operator>>(std::istream& input, Pose2d& pose) { - input >> pose.x >> pose.y >> pose.yaw_radians; - // Normalize the angle between -pi to pi. - pose.yaw_radians = NormalizeAngle(pose.yaw_radians); - return input; -} - -// The constraint between two vertices in the pose graph. The constraint is the -// transformation from vertex id_begin to vertex id_end. -struct Constraint2d { - int id_begin; - int id_end; - - double x; - double y; - double yaw_radians; - - // The inverse of the covariance matrix for the measurement. The order of the - // entries are x, y, and yaw. - Eigen::Matrix3d information; - - // The name of the data type in the g2o file format. - static std::string name() { return "EDGE_SE2"; } -}; - -inline std::istream& operator>>(std::istream& input, Constraint2d& constraint) { - input >> constraint.id_begin >> constraint.id_end >> constraint.x >> - constraint.y >> constraint.yaw_radians >> constraint.information(0, 0) >> - constraint.information(0, 1) >> constraint.information(0, 2) >> - constraint.information(1, 1) >> constraint.information(1, 2) >> - constraint.information(2, 2); - - // Set the lower triangular part of the information matrix. - constraint.information(1, 0) = constraint.information(0, 1); - constraint.information(2, 0) = constraint.information(0, 2); - constraint.information(2, 1) = constraint.information(1, 2); - - // Normalize the angle between -pi to pi. - constraint.yaw_radians = NormalizeAngle(constraint.yaw_radians); - return input; -} - -} // namespace optimization_2d -} // namespace ceres - -#endif // OPTIMIZATION_2D_TYPES_H_ \ No newline at end of file diff --git a/src/ground_slam/include/read_configs.h b/src/ground_slam/include/read_configs.h deleted file mode 100644 index b5e7d7a..0000000 --- a/src/ground_slam/include/read_configs.h +++ /dev/null @@ -1,137 +0,0 @@ -#ifndef READ_CONFIGS_H_ -#define READ_CONFIGS_H_ - -#include -#include - -#include "utils.h" - - -struct DatasetConfig{ - std::string dataroot; - std::string image_dir_name; - std::string camera_file; -}; - -struct CFConfig{ - int width; - int height; - float lambda; - int kernel; - float sigma; - float offset; - int power; - int rotation_divisor; - int rotation_channel; -}; - -struct KeyframeSelectionConfig{ - double max_distance; - double max_angle; - double lower_response_thr; - double upper_response_thr; -}; - -struct MapConfig{ - double grid_scale; -}; - -struct LoopClosureConfig{ - bool to_find_loop; - double position_response_thr; - double angle_response_thr; - int frame_gap_thr; - double distance_thr; -}; - -struct MapStitcherConfig{ - bool stitch_map; - int cell_size; -}; - -struct VisualizationConfig{ - std::string frame_id; - std::string kcc_pose_topic; - std::string frame_pose_topic; - std::string map_topic; - std::string image_topic; -}; - -struct SavingConfig{ - std::string saving_root; - bool save_pose; -}; - -struct Configs{ - DatasetConfig dataset_config; - CFConfig cf_config; - KeyframeSelectionConfig keyframe_selection_config; - MapConfig map_config; - LoopClosureConfig loop_closure_config; - MapStitcherConfig map_stitcher_config; - VisualizationConfig visualization_config; - SavingConfig saving_config; - - Configs(const std::string& config_file){ - if(!FileExists(config_file)){ - std::cout << "config file: " << config_file << " doesn't exist" << std::endl; - return; - } - - YAML::Node file_node = YAML::LoadFile(config_file); - YAML::Node dataset_node = file_node["dataset"]; - dataset_config.dataroot = dataset_node["dataroot"].as(); - dataset_config.image_dir_name = dataset_node["image_dir_name"].as(); - dataset_config.camera_file = dataset_node["camera_config"].as(); - - YAML::Node cf_node = file_node["correlation_flow"]; - cf_config.width = cf_node["width"].as(); - cf_config.height = cf_node["height"].as(); - cf_config.lambda = cf_node["lambda"].as(); - cf_config.rotation_divisor = cf_node["rotation_divisor"].as(); - cf_config.rotation_channel = cf_node["rotation_channel"].as(); - cf_config.kernel = cf_node["kernel"].as(); - cf_config.offset = cf_node["polynomial"]["offset"].as(); - cf_config.power = cf_node["polynomial"]["power"].as(); - cf_config.sigma = cf_node["gaussian"]["sigma"].as(); - - YAML::Node kfs_node = file_node["keyframe_selection"]; - keyframe_selection_config.max_distance = kfs_node["max_distance"].as(); - keyframe_selection_config.max_angle = kfs_node["max_angle"].as(); - keyframe_selection_config.lower_response_thr = kfs_node["lower_response_thr"].as(); - keyframe_selection_config.upper_response_thr = kfs_node["upper_response_thr"].as(); - - YAML::Node map_node = file_node["map"]; - map_config.grid_scale = map_node["grid_scale"].as(); - - YAML::Node loop_closure_node = file_node["loop_closure"]; - loop_closure_config.to_find_loop = - loop_closure_node["to_find_loop"].as(); - loop_closure_config.position_response_thr = - loop_closure_node["position_response_thr"].as(); - loop_closure_config.angle_response_thr = - loop_closure_node["angle_response_thr"].as(); - loop_closure_config.frame_gap_thr = - loop_closure_node["frame_gap_thr"].as(); - loop_closure_config.distance_thr = - loop_closure_node["distance_thr"].as(); - - YAML::Node map_stitcher_node = file_node["map_sticther"]; - map_stitcher_config.stitch_map = map_stitcher_node["stitch_map"].as(); - map_stitcher_config.cell_size = map_stitcher_node["cell_size"].as(); - - YAML::Node visualization_node = file_node["visualization"]; - visualization_config.frame_id = visualization_node["frame_id"].as(); - visualization_config.kcc_pose_topic = visualization_node["topic"]["kcc_pose"].as(); - visualization_config.frame_pose_topic = visualization_node["topic"]["frame_pose"].as(); - visualization_config.map_topic = visualization_node["topic"]["map"].as(); - visualization_config.image_topic = visualization_node["topic"]["image"].as(); - - YAML::Node saving_node = file_node["saving"]; - saving_config.saving_root = saving_node["saving_root"].as(); - saving_config.save_pose = saving_node["save_pose"].as(); - } -}; - - -#endif // READ_CONFIGS_H_ \ No newline at end of file diff --git a/src/ground_slam/include/thread_publisher.h b/src/ground_slam/include/thread_publisher.h deleted file mode 100644 index 5b24191..0000000 --- a/src/ground_slam/include/thread_publisher.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef THREAD_PUBLISHER_H_ -#define THREAD_PUBLISHER_H_ -#include -#include -#include -#include -#include -#include -#include - -template -class ThreadPublisher { -public: - ThreadPublisher(); - ~ThreadPublisher(); - - void Register(std::function&)> cb); - void Start(); - void Publish(const std::shared_ptr msg); - void Process(); - void ShutDown(); - -private: - std::mutex msg_mutex_; - std::condition_variable msg_cond_; - std::queue> msgs_; - std::thread publish_thread_; - std::vector&)>> callbacks_; - bool shutdown_requested_; -}; - -#endif // THREAD_PUBLISHER_H_ diff --git a/src/ground_slam/include/timer.h b/src/ground_slam/include/timer.h deleted file mode 100755 index d0d84e7..0000000 --- a/src/ground_slam/include/timer.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef _TIMER_H_ -#define _TIMER_H_ - -#include -#include - - -typedef struct{ - struct timeval start; - struct timeval stop; -}Timer; - -void startTimer(Timer *pTimer); -void stopTimer(Timer *pTimer); -double getElapsedTime(Timer *pTimer); -void writeTimeToFile(double arrTime[], int nCount, int nFrameNo, char *filename); - -#define INITIALIZE_TIMER Timer stTimer; double arrTime[100] -#define START_TIMER startTimer(&stTimer) -#define STOP_TIMER(text) stopTimer(&stTimer); printf(text); printf(": %.1f\n",getElapsedTime(&stTimer)) -#define END_TIMER(nIndex) stopTimer(&stTimer); arrTime[nIndex] = getElapsedTime(&stTimer) -#define ACC_TIMER(nIndex) stopTimer(&stTimer); arrTime[nIndex] += getElapsedTime(&stTimer) -#define WRITE_TIME_FILE(nCount, nFrameNo, filename) writeTimeToFile(arrTime, nCount, nFrameNo, (char *)filename) - -#endif//_TIMER_H_ - - diff --git a/src/ground_slam/include/utils.h b/src/ground_slam/include/utils.h deleted file mode 100644 index 93642b4..0000000 --- a/src/ground_slam/include/utils.h +++ /dev/null @@ -1,82 +0,0 @@ -#ifndef UTILS_H_ -#define UTILS_H_ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -// Eigen type -template