first commit
This commit is contained in:
428
.gitignore
vendored
Normal file
428
.gitignore
vendored
Normal file
@@ -0,0 +1,428 @@
|
||||
# ---> VisualStudio
|
||||
## Ignore Visual Studio temporary files, build results, and
|
||||
## files generated by popular Visual Studio add-ons.
|
||||
##
|
||||
## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
|
||||
|
||||
# User-specific files
|
||||
*.rsuser
|
||||
*.suo
|
||||
*.user
|
||||
*.userosscache
|
||||
*.sln.docstates
|
||||
|
||||
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||
*.userprefs
|
||||
|
||||
# Mono auto generated files
|
||||
mono_crash.*
|
||||
|
||||
# Build results
|
||||
[Dd]ebug/
|
||||
[Dd]ebugPublic/
|
||||
[Rr]elease/
|
||||
[Rr]eleases/
|
||||
x64/
|
||||
x86/
|
||||
[Ww][Ii][Nn]32/
|
||||
[Aa][Rr][Mm]/
|
||||
[Aa][Rr][Mm]64/
|
||||
bld/
|
||||
[Bb]in/
|
||||
[Oo]bj/
|
||||
[Ll]og/
|
||||
[Ll]ogs/
|
||||
|
||||
# Visual Studio 2015/2017 cache/options directory
|
||||
.vs/
|
||||
# Uncomment if you have tasks that create the project's static files in wwwroot
|
||||
#wwwroot/
|
||||
|
||||
# Visual Studio 2017 auto generated files
|
||||
Generated\ Files/
|
||||
|
||||
# MSTest test Results
|
||||
[Tt]est[Rr]esult*/
|
||||
[Bb]uild[Ll]og.*
|
||||
|
||||
# NUnit
|
||||
*.VisualState.xml
|
||||
TestResult.xml
|
||||
nunit-*.xml
|
||||
|
||||
# Build Results of an ATL Project
|
||||
[Dd]ebugPS/
|
||||
[Rr]eleasePS/
|
||||
dlldata.c
|
||||
|
||||
# Benchmark Results
|
||||
BenchmarkDotNet.Artifacts/
|
||||
|
||||
# .NET Core
|
||||
project.lock.json
|
||||
project.fragment.lock.json
|
||||
artifacts/
|
||||
|
||||
# ASP.NET Scaffolding
|
||||
ScaffoldingReadMe.txt
|
||||
|
||||
# StyleCop
|
||||
StyleCopReport.xml
|
||||
|
||||
# Files built by Visual Studio
|
||||
*_i.c
|
||||
*_p.c
|
||||
*_h.h
|
||||
*.ilk
|
||||
*.meta
|
||||
*.obj
|
||||
*.iobj
|
||||
*.pch
|
||||
*.pdb
|
||||
*.ipdb
|
||||
*.pgc
|
||||
*.pgd
|
||||
*.rsp
|
||||
*.sbr
|
||||
*.tlb
|
||||
*.tli
|
||||
*.tlh
|
||||
*.tmp
|
||||
*.tmp_proj
|
||||
*_wpftmp.csproj
|
||||
*.log
|
||||
*.tlog
|
||||
*.vspscc
|
||||
*.vssscc
|
||||
.builds
|
||||
*.pidb
|
||||
*.svclog
|
||||
*.scc
|
||||
|
||||
# Chutzpah Test files
|
||||
_Chutzpah*
|
||||
|
||||
# Visual C++ cache files
|
||||
ipch/
|
||||
*.aps
|
||||
*.ncb
|
||||
*.opendb
|
||||
*.opensdf
|
||||
*.sdf
|
||||
*.cachefile
|
||||
*.VC.db
|
||||
*.VC.VC.opendb
|
||||
|
||||
# Visual Studio profiler
|
||||
*.psess
|
||||
*.vsp
|
||||
*.vspx
|
||||
*.sap
|
||||
|
||||
# Visual Studio Trace Files
|
||||
*.e2e
|
||||
|
||||
# TFS 2012 Local Workspace
|
||||
$tf/
|
||||
|
||||
# Guidance Automation Toolkit
|
||||
*.gpState
|
||||
|
||||
# ReSharper is a .NET coding add-in
|
||||
_ReSharper*/
|
||||
*.[Rr]e[Ss]harper
|
||||
*.DotSettings.user
|
||||
|
||||
# TeamCity is a build add-in
|
||||
_TeamCity*
|
||||
|
||||
# DotCover is a Code Coverage Tool
|
||||
*.dotCover
|
||||
|
||||
# AxoCover is a Code Coverage Tool
|
||||
.axoCover/*
|
||||
!.axoCover/settings.json
|
||||
|
||||
# Coverlet is a free, cross platform Code Coverage Tool
|
||||
coverage*.json
|
||||
coverage*.xml
|
||||
coverage*.info
|
||||
|
||||
# Visual Studio code coverage results
|
||||
*.coverage
|
||||
*.coveragexml
|
||||
|
||||
# NCrunch
|
||||
_NCrunch_*
|
||||
.*crunch*.local.xml
|
||||
nCrunchTemp_*
|
||||
|
||||
# MightyMoose
|
||||
*.mm.*
|
||||
AutoTest.Net/
|
||||
|
||||
# Web workbench (sass)
|
||||
.sass-cache/
|
||||
|
||||
# Installshield output folder
|
||||
[Ee]xpress/
|
||||
|
||||
# DocProject is a documentation generator add-in
|
||||
DocProject/buildhelp/
|
||||
DocProject/Help/*.HxT
|
||||
DocProject/Help/*.HxC
|
||||
DocProject/Help/*.hhc
|
||||
DocProject/Help/*.hhk
|
||||
DocProject/Help/*.hhp
|
||||
DocProject/Help/Html2
|
||||
DocProject/Help/html
|
||||
|
||||
# Click-Once directory
|
||||
publish/
|
||||
|
||||
# Publish Web Output
|
||||
*.[Pp]ublish.xml
|
||||
*.azurePubxml
|
||||
# Note: Comment the next line if you want to checkin your web deploy settings,
|
||||
# but database connection strings (with potential passwords) will be unencrypted
|
||||
*.pubxml
|
||||
*.publishproj
|
||||
|
||||
# Microsoft Azure Web App publish settings. Comment the next line if you want to
|
||||
# checkin your Azure Web App publish settings, but sensitive information contained
|
||||
# in these scripts will be unencrypted
|
||||
PublishScripts/
|
||||
|
||||
# NuGet Packages
|
||||
*.nupkg
|
||||
# NuGet Symbol Packages
|
||||
*.snupkg
|
||||
# The packages folder can be ignored because of Package Restore
|
||||
**/[Pp]ackages/*
|
||||
# except build/, which is used as an MSBuild target.
|
||||
!**/[Pp]ackages/build/
|
||||
# except packages in Navigations. Thư mục cha phải được bỏ ignore TRƯỚC: git không xét lại
|
||||
# negation cho thứ nằm trong một thư mục đã bị loại, nên `!.../move_base/` đứng một mình vô tác dụng
|
||||
# (đúng cách mà khối Algorithms bên dưới đang làm).
|
||||
!src/Navigations/Packages/
|
||||
!src/Navigations/Packages/move_base/
|
||||
!src/Navigations/Packages/move_base2
|
||||
# except packages in Algorithms
|
||||
!src/Algorithms/Packages/
|
||||
!src/Algorithms/Packages/global_planners/
|
||||
!src/Algorithms/Packages/local_planners/
|
||||
# Uncomment if necessary however generally it will be regenerated when needed
|
||||
#!**/[Pp]ackages/repositories.config
|
||||
# NuGet v3's project.json files produces more ignorable files
|
||||
*.nuget.props
|
||||
*.nuget.targets
|
||||
|
||||
# Microsoft Azure Build Output
|
||||
csx/
|
||||
*.build.csdef
|
||||
|
||||
# Microsoft Azure Emulator
|
||||
ecf/
|
||||
rcf/
|
||||
|
||||
# Windows Store app package directories and files
|
||||
AppPackages/
|
||||
BundleArtifacts/
|
||||
Package.StoreAssociation.xml
|
||||
_pkginfo.txt
|
||||
*.appx
|
||||
*.appxbundle
|
||||
*.appxupload
|
||||
|
||||
# Visual Studio cache files
|
||||
# files ending in .cache can be ignored
|
||||
*.[Cc]ache
|
||||
# but keep track of directories ending in .cache
|
||||
!?*.[Cc]ache/
|
||||
|
||||
# Others
|
||||
ClientBin/
|
||||
~$*
|
||||
*~
|
||||
*.dbmdl
|
||||
*.dbproj.schemaview
|
||||
*.jfm
|
||||
*.pfx
|
||||
*.publishsettings
|
||||
orleans.codegen.cs
|
||||
|
||||
# Including strong name files can present a security risk
|
||||
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
|
||||
#*.snk
|
||||
|
||||
# Since there are multiple workflows, uncomment next line to ignore bower_components
|
||||
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
|
||||
#bower_components/
|
||||
|
||||
# RIA/Silverlight projects
|
||||
Generated_Code/
|
||||
|
||||
# Backup & report files from converting an old project file
|
||||
# to a newer Visual Studio version. Backup files are not needed,
|
||||
# because we have git ;-)
|
||||
_UpgradeReport_Files/
|
||||
Backup*/
|
||||
UpgradeLog*.XML
|
||||
UpgradeLog*.htm
|
||||
ServiceFabricBackup/
|
||||
*.rptproj.bak
|
||||
|
||||
# SQL Server files
|
||||
*.mdf
|
||||
*.ldf
|
||||
*.ndf
|
||||
|
||||
# Business Intelligence projects
|
||||
*.rdl.data
|
||||
*.bim.layout
|
||||
*.bim_*.settings
|
||||
*.rptproj.rsuser
|
||||
*- [Bb]ackup.rdl
|
||||
*- [Bb]ackup ([0-9]).rdl
|
||||
*- [Bb]ackup ([0-9][0-9]).rdl
|
||||
|
||||
# Microsoft Fakes
|
||||
FakesAssemblies/
|
||||
|
||||
# GhostDoc plugin setting file
|
||||
*.GhostDoc.xml
|
||||
|
||||
# Node.js Tools for Visual Studio
|
||||
.ntvs_analysis.dat
|
||||
node_modules/
|
||||
|
||||
# Visual Studio 6 build log
|
||||
*.plg
|
||||
|
||||
# Visual Studio 6 workspace options file
|
||||
*.opt
|
||||
|
||||
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
|
||||
*.vbw
|
||||
|
||||
# Visual Studio 6 auto-generated project file (contains which files were open etc.)
|
||||
*.vbp
|
||||
|
||||
# Visual Studio 6 workspace and project file (working project files containing files to include in project)
|
||||
*.dsw
|
||||
*.dsp
|
||||
|
||||
# Visual Studio 6 technical files
|
||||
*.ncb
|
||||
*.aps
|
||||
|
||||
# Visual Studio LightSwitch build output
|
||||
**/*.HTMLClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/ModelManifest.xml
|
||||
**/*.Server/GeneratedArtifacts
|
||||
**/*.Server/ModelManifest.xml
|
||||
_Pvt_Extensions
|
||||
|
||||
# Paket dependency manager
|
||||
.paket/paket.exe
|
||||
paket-files/
|
||||
|
||||
# FAKE - F# Make
|
||||
.fake/
|
||||
|
||||
# CodeRush personal settings
|
||||
.cr/personal
|
||||
|
||||
# Python Tools for Visual Studio (PTVS)
|
||||
__pycache__/
|
||||
*.pyc
|
||||
|
||||
# Cake - Uncomment if you are using it
|
||||
# tools/**
|
||||
# !tools/packages.config
|
||||
|
||||
# Tabs Studio
|
||||
*.tss
|
||||
|
||||
# Telerik's JustMock configuration file
|
||||
*.jmconfig
|
||||
|
||||
# BizTalk build output
|
||||
*.btp.cs
|
||||
*.btm.cs
|
||||
*.odx.cs
|
||||
*.xsd.cs
|
||||
|
||||
# OpenCover UI analysis results
|
||||
OpenCover/
|
||||
|
||||
# Azure Stream Analytics local run output
|
||||
ASALocalRun/
|
||||
|
||||
# MSBuild Binary and Structured Log
|
||||
*.binlog
|
||||
|
||||
# NVidia Nsight GPU debugger configuration file
|
||||
*.nvuser
|
||||
|
||||
# MFractors (Xamarin productivity tool) working folder
|
||||
.mfractor/
|
||||
|
||||
# Local History for Visual Studio
|
||||
.localhistory/
|
||||
|
||||
# Visual Studio History (VSHistory) files
|
||||
.vshistory/
|
||||
|
||||
# BeatPulse healthcheck temp database
|
||||
healthchecksdb
|
||||
|
||||
# Backup folder for Package Reference Convert tool in Visual Studio 2017
|
||||
MigrationBackup/
|
||||
|
||||
# Ionide (cross platform F# VS Code tools) working folder
|
||||
.ionide/
|
||||
|
||||
# Fody - auto-generated XML schema
|
||||
FodyWeavers.xsd
|
||||
|
||||
# VS Code files for those working on multiple tools
|
||||
.vscode/*
|
||||
!.vscode/settings.json
|
||||
!.vscode/tasks.json
|
||||
!.vscode/launch.json
|
||||
!.vscode/extensions.json
|
||||
*.code-workspace
|
||||
|
||||
# Local History for Visual Studio Code
|
||||
.history/
|
||||
|
||||
# Windows Installer files from build outputs
|
||||
*.cab
|
||||
*.msi
|
||||
*.msix
|
||||
*.msm
|
||||
*.msp
|
||||
|
||||
# JetBrains Rider
|
||||
*.sln.iml
|
||||
|
||||
# ---> VisualStudioCode
|
||||
.vscode/*
|
||||
!.vscode/settings.json
|
||||
!.vscode/tasks.json
|
||||
!.vscode/launch.json
|
||||
!.vscode/extensions.json
|
||||
!.vscode/*.code-snippets
|
||||
|
||||
# Local History for Visual Studio Code
|
||||
.history/
|
||||
|
||||
# Built Visual Studio Code Extensions
|
||||
*.vsix
|
||||
|
||||
build
|
||||
install
|
||||
devel
|
||||
|
||||
52
.gitmodules
vendored
Normal file
52
.gitmodules
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
[submodule "src/Libraries/common_msgs"]
|
||||
path = src/Libraries/common_msgs
|
||||
url = https://git.pnkr.asia/DuongTD/common_msgs.git
|
||||
[submodule "src/Libraries/costmap_2d"]
|
||||
path = src/Libraries/costmap_2d
|
||||
url = https://git.pnkr.asia/DuongTD/costmap_2d.git
|
||||
branch = dev_cam_intel
|
||||
[submodule "src/Libraries/geometry2"]
|
||||
path = src/Libraries/geometry2
|
||||
url = https://git.pnkr.asia/DuongTD/geometry2.git
|
||||
[submodule "src/Libraries/laser_geometry"]
|
||||
path = src/Libraries/laser_geometry
|
||||
url = https://git.pnkr.asia/DuongTD/laser_geometry.git
|
||||
[submodule "src/Libraries/robot_time"]
|
||||
path = src/Libraries/robot_time
|
||||
url = https://git.pnkr.asia/DuongTD/robot_time.git
|
||||
[submodule "src/Libraries/voxel_grid"]
|
||||
path = src/Libraries/voxel_grid
|
||||
url = https://git.pnkr.asia/DuongTD/voxel_grid.git
|
||||
[submodule "src/Libraries/data_convert"]
|
||||
path = src/Libraries/data_convert
|
||||
url = https://git.pnkr.asia/DuongTD/data_convert.git
|
||||
[submodule "src/Algorithms/Packages/global_planners/custom_planner"]
|
||||
path = src/Algorithms/Packages/global_planners/custom_planner
|
||||
url = https://git.pnkr.asia/DuongTD/custom_planner.git
|
||||
[submodule "src/Algorithms/Packages/global_planners/dock_planner"]
|
||||
path = src/Algorithms/Packages/global_planners/dock_planner
|
||||
url = https://git.pnkr.asia/DuongTD/dock_planner.git
|
||||
[submodule "src/Libraries/xmlrpcpp"]
|
||||
path = src/Libraries/xmlrpcpp
|
||||
url = https://git.pnkr.asia/DuongTD/xmlrpcpp.git
|
||||
[submodule "src/Libraries/laser_filter"]
|
||||
path = src/Libraries/laser_filter
|
||||
url = https://git.pnkr.asia/DuongTD/laser_filter.git
|
||||
[submodule "src/Libraries/action_core"]
|
||||
path = src/Libraries/action_core
|
||||
url = https://git.pnkr.asia/DuongTD/action_core.git
|
||||
[submodule "src/Libraries/recovery_core"]
|
||||
path = src/Libraries/recovery_core
|
||||
url = https://git.pnkr.asia/DuongTD/recovery_core.git
|
||||
[submodule "src/Libraries/mission_adapters"]
|
||||
path = src/Libraries/mission_adapters
|
||||
url = https://git.pnkr.asia/DuongTD/mission_adapters.git
|
||||
[submodule "src/Navigations/Packages/move_base2"]
|
||||
path = src/Navigations/Packages/move_base2
|
||||
url = https://git.pnkr.asia/DuongTD/move_base2.git
|
||||
[submodule "src/Algorithms/Packages/local_planners/stanley_local_planner"]
|
||||
path = src/Algorithms/Packages/local_planners/stanley_local_planner
|
||||
url = https://git.pnkr.asia/DuongTD/stanley_local_planner.git
|
||||
[submodule "src/Libraries/angles"]
|
||||
path = src/Libraries/angles
|
||||
url = https://git.pnkr.asia/DuongTD/angles.git
|
||||
63
CATKIN_BUILD_README.md
Normal file
63
CATKIN_BUILD_README.md
Normal file
@@ -0,0 +1,63 @@
|
||||
# Catkin Build Instructions
|
||||
|
||||
## Vấn đề
|
||||
|
||||
Thư mục này có `CMakeLists.txt` ở root để hỗ trợ **standalone CMake build**.
|
||||
Tuy nhiên, **catkin workspace không được phép có CMakeLists.txt ở root**.
|
||||
|
||||
Khi chạy `catkin_make` trong thư mục này, bạn sẽ gặp lỗi:
|
||||
```
|
||||
The specified base path contains a CMakeLists.txt but "catkin_make" must be invoked in the root of workspace
|
||||
```
|
||||
|
||||
## Giải pháp
|
||||
|
||||
### Option 1: Sử dụng script tự động (Khuyến nghị)
|
||||
|
||||
```bash
|
||||
# Chạy script setup
|
||||
./setup_catkin_workspace.sh
|
||||
|
||||
# Build trong workspace mới
|
||||
cd ../pnkx_nav_catkin_ws
|
||||
rm -rf build devel
|
||||
catkin_make -DCMAKE_BUILD_TYPE=RelWithDebInfo \
|
||||
-DCMAKE_CXX_FLAGS="-fsanitize=address -fno-omit-frame-pointer" \
|
||||
-DCMAKE_C_FLAGS="-fsanitize=address -fno-omit-frame-pointer" \
|
||||
-DCMAKE_EXE_LINKER_FLAGS="-fsanitize=address"
|
||||
source devel/setup.bash
|
||||
```
|
||||
|
||||
### Option 2: Tạo workspace thủ công
|
||||
|
||||
```bash
|
||||
# Tạo workspace
|
||||
mkdir -p ~/pnkx_nav_catkin_ws/src
|
||||
cd ~/pnkx_nav_catkin_ws/src
|
||||
|
||||
# Link các packages có package.xml
|
||||
ln -s /path/to/pnkx_nav_core/src/Navigations/Packages/move_base move_base
|
||||
# ... link các packages khác nếu cần
|
||||
|
||||
# Build
|
||||
cd ~/pnkx_nav_catkin_ws
|
||||
catkin_make
|
||||
```
|
||||
|
||||
## Build Systems
|
||||
|
||||
Project này hỗ trợ **2 build systems**:
|
||||
|
||||
1. **Standalone CMake** (mặc định)
|
||||
- Build trực tiếp trong thư mục này: `mkdir build && cd build && cmake .. && make`
|
||||
- Không cần catkin workspace
|
||||
|
||||
2. **Catkin** (cho ROS integration)
|
||||
- Cần tạo workspace riêng (xem hướng dẫn trên)
|
||||
- Packages tự động detect catkin mode khi build trong workspace
|
||||
|
||||
## Chi tiết
|
||||
|
||||
Xem `src/Navigations/Packages/move_base/BUILD_INSTRUCTIONS.md` để biết chi tiết về cách build package `move_base` với cả hai hệ thống.
|
||||
|
||||
|
||||
402
CMAKE_BUILD_README.md
Normal file
402
CMAKE_BUILD_README.md
Normal file
@@ -0,0 +1,402 @@
|
||||
# Hướng dẫn Build bằng CMake
|
||||
|
||||
Hướng dẫn chi tiết để build project `pnkx_nav_core` sử dụng CMake standalone (không cần Catkin workspace).
|
||||
|
||||
## Mục lục
|
||||
|
||||
1. [Yêu cầu hệ thống](#yêu-cầu-hệ-thống)
|
||||
2. [Cài đặt Dependencies](#cài-đặt-dependencies)
|
||||
3. [Build Project](#build-project)
|
||||
4. [Các tùy chọn Build](#các-tùy-chọn-build)
|
||||
5. [Install](#install)
|
||||
6. [Sử dụng trong project khác](#sử-dụng-trong-project-khác)
|
||||
7. [Troubleshooting](#troubleshooting)
|
||||
|
||||
---
|
||||
|
||||
## Yêu cầu hệ thống
|
||||
|
||||
### Hệ điều hành
|
||||
- Linux (Ubuntu 18.04+ hoặc tương đương)
|
||||
### Compiler
|
||||
- **GCC**: phiên bản 7.0 trở lên (hỗ trợ C++17)
|
||||
- **Clang**: phiên bản 5.0 trở lên
|
||||
|
||||
### CMake
|
||||
- **CMake**: phiên bản 3.10 trở lên
|
||||
|
||||
Kiểm tra phiên bản:
|
||||
```bash
|
||||
cmake --version
|
||||
g++ --version
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Cài đặt Dependencies
|
||||
|
||||
### Linux (Ubuntu/Debian)
|
||||
|
||||
```bash
|
||||
# Cập nhật package list
|
||||
sudo apt-get update
|
||||
|
||||
# Cài đặt CMake và build tools
|
||||
sudo apt-get install -y cmake build-essential
|
||||
|
||||
# Cài đặt các thư viện cần thiết
|
||||
sudo apt-get install -y \
|
||||
libboost-all-dev \
|
||||
libeigen3-dev \
|
||||
libyaml-cpp-dev \
|
||||
libpcl-dev \
|
||||
libgoogle-glog-dev
|
||||
sudo apt install liborocos-kdl-dev
|
||||
|
||||
# Optional: Cài đặt Google Test (nếu muốn build tests)
|
||||
sudo apt-get install -y libgtest-dev
|
||||
```
|
||||
|
||||
**Lưu ý:** Hướng dẫn này dành cho hệ thống Linux. Nếu sử dụng các distro khác (CentOS, Fedora, Arch, etc.), vui lòng cài đặt các packages tương ứng bằng package manager của distro đó.
|
||||
|
||||
---
|
||||
|
||||
## Build Project
|
||||
|
||||
### Bước 1: Clone repository
|
||||
|
||||
```bash
|
||||
git clone https://git.pnkr.asia/HiepLM/pnkx_nav_core.git
|
||||
cd pnkx_nav_core
|
||||
git submodule init
|
||||
git submodule update
|
||||
```
|
||||
|
||||
### Bước 2: Tạo thư mục build
|
||||
|
||||
```bash
|
||||
mkdir build
|
||||
cd build
|
||||
```
|
||||
|
||||
### Bước 3: Cấu hình với CMake
|
||||
|
||||
```bash
|
||||
# Cấu hình cơ bản (Release mode)
|
||||
cmake ..
|
||||
|
||||
# Hoặc chỉ định build type rõ ràng
|
||||
cmake -DCMAKE_BUILD_TYPE=Release ..
|
||||
|
||||
# Hoặc Debug mode (để debug)
|
||||
cmake -DCMAKE_BUILD_TYPE=Debug ..
|
||||
```
|
||||
|
||||
### Bước 4: Build
|
||||
|
||||
```bash
|
||||
# Build tất cả targets
|
||||
make
|
||||
|
||||
# Hoặc build với nhiều cores (nhanh hơn)
|
||||
make -j$(nproc)
|
||||
```
|
||||
|
||||
### Bước 5: Kiểm tra build thành công
|
||||
|
||||
```bash
|
||||
# Kiểm tra các thư viện đã được build
|
||||
ls -la lib/
|
||||
|
||||
# Kiểm tra các executable (nếu có)
|
||||
ls -la bin/
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Các tùy chọn Build
|
||||
|
||||
### Build Type
|
||||
|
||||
```bash
|
||||
# Release mode (mặc định) - tối ưu hóa
|
||||
cmake -DCMAKE_BUILD_TYPE=Release ..
|
||||
|
||||
# Debug mode - với debug symbols
|
||||
cmake -DCMAKE_BUILD_TYPE=Debug ..
|
||||
|
||||
# RelWithDebInfo - Release với debug info
|
||||
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo ..
|
||||
|
||||
# MinSizeRel - Tối ưu kích thước
|
||||
cmake -DCMAKE_BUILD_TYPE=MinSizeRel ..
|
||||
```
|
||||
|
||||
### Build chỉ một target cụ thể
|
||||
|
||||
```bash
|
||||
# Build chỉ một library
|
||||
make robot_cpp_node_handle
|
||||
|
||||
# Build chỉ move_base
|
||||
make move_base
|
||||
|
||||
# Build chỉ C API
|
||||
make navigation_c_api
|
||||
```
|
||||
|
||||
### Các tùy chọn CMake khác
|
||||
|
||||
```bash
|
||||
# Tắt warnings (đã được cấu hình sẵn trong CMakeLists.txt)
|
||||
cmake -DCMAKE_CXX_FLAGS="-w" ..
|
||||
|
||||
# Chỉ định compiler
|
||||
cmake -DCMAKE_CXX_COMPILER=g++-9 ..
|
||||
|
||||
# Chỉ định install prefix
|
||||
cmake -DCMAKE_INSTALL_PREFIX=/usr/local ..
|
||||
|
||||
# Build tests (nếu có)
|
||||
cmake -DBUILD_TESTS=ON ..
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Install
|
||||
|
||||
Sau khi build thành công, bạn có thể install các thư viện và headers vào hệ thống:
|
||||
|
||||
```bash
|
||||
# Install vào thư mục mặc định (/usr/local)
|
||||
sudo make install
|
||||
|
||||
# Hoặc install vào thư mục tùy chỉnh
|
||||
cmake -DCMAKE_INSTALL_PREFIX=/opt/pnkx_nav_core ..
|
||||
make install
|
||||
```
|
||||
|
||||
Cấu trúc sau khi install:
|
||||
```
|
||||
/usr/local/
|
||||
├── include/
|
||||
│ ├── robot/
|
||||
│ ├── nav_core2/
|
||||
│ ├── mkt_algorithm/
|
||||
│ └── ...
|
||||
├── lib/
|
||||
│ ├── librobot_cpp_node_handle.so
|
||||
│ ├── libmove_base.so
|
||||
│ └── ...
|
||||
└── lib/cmake/
|
||||
├── robot_cpp/
|
||||
├── move_base/
|
||||
└── ...
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Sử dụng trong project khác
|
||||
|
||||
### Sử dụng với CMake
|
||||
|
||||
Sau khi install, bạn có thể sử dụng trong CMakeLists.txt của project khác:
|
||||
|
||||
```cmake
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
project(my_project)
|
||||
|
||||
# Tìm các packages
|
||||
find_package(robot_cpp REQUIRED)
|
||||
find_package(move_base REQUIRED)
|
||||
find_package(navigation_c_api REQUIRED)
|
||||
|
||||
# Link libraries
|
||||
add_executable(my_app main.cpp)
|
||||
target_link_libraries(my_app
|
||||
PRIVATE
|
||||
robot_cpp
|
||||
move_base
|
||||
navigation_c_api
|
||||
)
|
||||
```
|
||||
|
||||
### Sử dụng C API (cho .NET/C#)
|
||||
|
||||
Xem hướng dẫn chi tiết trong `examples/README.md` và `examples/QUICK_START.md`.
|
||||
|
||||
Tóm tắt:
|
||||
```bash
|
||||
# Copy shared library
|
||||
cp build/src/APIs/c_api/libnavigation_c_api.so /path/to/your/project/
|
||||
|
||||
# Sử dụng trong C#
|
||||
[DllImport("libnavigation_c_api.so")]
|
||||
public static extern IntPtr create_navigation();
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Lỗi: "Could not find Boost"
|
||||
|
||||
```bash
|
||||
# Kiểm tra Boost đã được cài đặt
|
||||
dpkg -l | grep libboost
|
||||
|
||||
# Cài đặt lại nếu thiếu
|
||||
sudo apt-get install libboost-all-dev
|
||||
```
|
||||
|
||||
### Lỗi: "Could not find Eigen3"
|
||||
|
||||
```bash
|
||||
# Cài đặt Eigen3
|
||||
sudo apt-get install libeigen3-dev
|
||||
|
||||
# Hoặc chỉ định đường dẫn
|
||||
cmake -DEigen3_DIR=/usr/include/eigen3 ..
|
||||
```
|
||||
|
||||
### Lỗi: "Could not find yaml-cpp"
|
||||
|
||||
```bash
|
||||
# Cài đặt yaml-cpp
|
||||
sudo apt-get install libyaml-cpp-dev
|
||||
```
|
||||
|
||||
### Lỗi: "undefined reference"
|
||||
|
||||
Đảm bảo tất cả dependencies đã được build theo đúng thứ tự:
|
||||
1. Core libraries (tf3, robot_time, xmlrpcpp, robot_cpp)
|
||||
2. Geometry và messages (geometry2, common_msgs)
|
||||
3. Navigation cores (nav_core, nav_core2)
|
||||
4. Algorithms (score_algorithm, mkt_algorithm)
|
||||
5. Main packages (move_base)
|
||||
|
||||
Build lại từ đầu:
|
||||
```bash
|
||||
cd build
|
||||
rm -rf *
|
||||
cmake ..
|
||||
make -j$(nproc)
|
||||
```
|
||||
|
||||
### Lỗi: "Permission denied" khi install
|
||||
|
||||
```bash
|
||||
# Sử dụng sudo cho system-wide install
|
||||
sudo make install
|
||||
|
||||
# Hoặc install vào user directory
|
||||
cmake -DCMAKE_INSTALL_PREFIX=$HOME/local ..
|
||||
make install
|
||||
```
|
||||
|
||||
### Build chậm
|
||||
|
||||
```bash
|
||||
# Sử dụng nhiều cores
|
||||
make -j$(nproc)
|
||||
|
||||
# Chỉ build target cần thiết
|
||||
make robot_cpp_node_handle # Thay vì make all
|
||||
```
|
||||
|
||||
### Clean build
|
||||
|
||||
```bash
|
||||
# Xóa toàn bộ build directory
|
||||
cd build
|
||||
rm -rf *
|
||||
|
||||
# Hoặc xóa chỉ các file object
|
||||
make clean
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Cấu trúc Build Output
|
||||
|
||||
Sau khi build, cấu trúc thư mục `build/` sẽ như sau:
|
||||
|
||||
```
|
||||
build/
|
||||
├── CMakeCache.txt
|
||||
├── CMakeFiles/
|
||||
├── cmake_install.cmake
|
||||
├── Makefile
|
||||
├── lib/
|
||||
│ ├── librobot_cpp_console.so
|
||||
│ ├── librobot_cpp_node_handle.so
|
||||
│ ├── libmove_base.so
|
||||
│ ├── libnavigation_c_api.so
|
||||
│ └── ...
|
||||
├── src/
|
||||
│ ├── Libraries/
|
||||
│ │ ├── robot_cpp/
|
||||
│ │ └── ...
|
||||
│ ├── Navigations/
|
||||
│ │ └── ...
|
||||
│ └── Algorithms/
|
||||
│ └── ...
|
||||
└── bin/ # (nếu có executables)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Environment Variables
|
||||
|
||||
Một số biến môi trường hữu ích:
|
||||
|
||||
```bash
|
||||
# Chỉ định config directory cho NodeHandle
|
||||
export PNKX_NAV_CORE_CONFIG_DIR=/path/to/config
|
||||
|
||||
# Chỉ định workspace directory
|
||||
export PNKX_NAV_CORE_DIR=/path/to/pnkx_nav_core
|
||||
|
||||
# LD_LIBRARY_PATH (nếu không install)
|
||||
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path/to/pnkx_nav_core/build/lib
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Quick Reference
|
||||
|
||||
### Build nhanh (một lệnh)
|
||||
|
||||
```bash
|
||||
mkdir -p build && cd build && cmake .. && make -j$(nproc)
|
||||
```
|
||||
|
||||
### Build và Install
|
||||
|
||||
```bash
|
||||
mkdir -p build && cd build && cmake .. && make -j$(nproc) && sudo make install
|
||||
```
|
||||
|
||||
### Rebuild từ đầu
|
||||
|
||||
```bash
|
||||
rm -rf build && mkdir build && cd build && cmake .. && make -j$(nproc)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Liên kết hữu ích
|
||||
|
||||
- [CMake Documentation](https://cmake.org/documentation/)
|
||||
- [C++17 Reference](https://en.cppreference.com/w/cpp/17)
|
||||
- [Examples](./examples/README.md)
|
||||
- [Catkin Build Guide](./CATKIN_BUILD_README.md)
|
||||
|
||||
---
|
||||
|
||||
## Ghi chú
|
||||
|
||||
- Project này sử dụng **C++17** standard
|
||||
- Warnings đã được tắt trong build configuration (`-w` flag)
|
||||
- Tất cả libraries được build dưới dạng **shared libraries** (.so)
|
||||
- Build type mặc định là **Release** với optimization `-O3`
|
||||
270
CMakeLists.txt
Normal file
270
CMakeLists.txt
Normal file
@@ -0,0 +1,270 @@
|
||||
# ========================================================
|
||||
# ROOT CMakeLists.txt
|
||||
# Đặt ở: Navigations/CMakeLists.txt
|
||||
# ========================================================
|
||||
cmake_minimum_required(VERSION 3.0.2)
|
||||
project(navigations VERSION 1.0.0 LANGUAGES CXX)
|
||||
|
||||
# Chuẩn C++
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
# Build type
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE Release)
|
||||
endif()
|
||||
|
||||
# Flags chung
|
||||
# Warning flags - disabled to suppress warnings during build
|
||||
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w") # -w suppresses all warnings
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
|
||||
|
||||
message(STATUS "========================================")
|
||||
message(STATUS "Building Navigations Project")
|
||||
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
|
||||
message(STATUS "C++ Standard: ${CMAKE_CXX_STANDARD}")
|
||||
message(STATUS "========================================")
|
||||
|
||||
# Build các packages theo thứ tự phụ thuộc
|
||||
# 1. Core libraries (header-only hoặc base libraries)
|
||||
|
||||
if (NOT TARGET robot_time)
|
||||
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Libraries/robot_time)
|
||||
endif()
|
||||
|
||||
if (NOT TARGET xmlrpcpp)
|
||||
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Libraries/xmlrpcpp)
|
||||
endif()
|
||||
|
||||
if (NOT TARGET robot_cpp)
|
||||
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Libraries/robot_cpp)
|
||||
endif()
|
||||
|
||||
if (NOT TARGET data_convert)
|
||||
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Libraries/data_convert)
|
||||
endif()
|
||||
|
||||
if (NOT TARGET geometry2)
|
||||
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Libraries/geometry2)
|
||||
endif()
|
||||
|
||||
if (NOT TARGET common_msgs)
|
||||
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Libraries/common_msgs)
|
||||
endif()
|
||||
|
||||
if (NOT TARGET laser_geometry)
|
||||
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Libraries/laser_geometry)
|
||||
endif()
|
||||
|
||||
if (NOT TARGET voxel_grid)
|
||||
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Libraries/voxel_grid)
|
||||
endif()
|
||||
|
||||
if (NOT TARGET robot_nav_2d_msgs)
|
||||
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Libraries/robot_nav_2d_msgs)
|
||||
endif()
|
||||
|
||||
if (NOT TARGET costmap_2d)
|
||||
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Libraries/costmap_2d)
|
||||
endif()
|
||||
|
||||
if (NOT TARGET robot_nav_2d_utils)
|
||||
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Libraries/robot_nav_2d_utils)
|
||||
endif()
|
||||
|
||||
if (NOT TARGET laser_filter)
|
||||
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Libraries/laser_filter)
|
||||
endif()
|
||||
|
||||
# KHÔNG phải gói `angles` ở src/Algorithms/Libraries — đó là package khác, target tên `angles`.
|
||||
# Gói này là port của ROS `angles`, project và target đều tên `robot_angles_prv`, và đó chính là
|
||||
# thứ stanley_local_planner link tới. Guard phải kiểm `robot_angles_prv`, kiểm `angles` sẽ trúng
|
||||
# nhầm gói kia rồi bỏ qua gói này, và link mới hỏng ở tận cuối build.
|
||||
if (NOT TARGET robot_angles_prv)
|
||||
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Libraries/angles)
|
||||
endif()
|
||||
|
||||
if (NOT TARGET robot_nav_core)
|
||||
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Navigations/Cores/robot_nav_core)
|
||||
endif()
|
||||
|
||||
if (NOT TARGET nav_grid)
|
||||
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Navigations/Libraries/nav_grid)
|
||||
endif()
|
||||
|
||||
if (NOT TARGET robot_nav_core2)
|
||||
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Navigations/Cores/robot_nav_core2)
|
||||
endif()
|
||||
|
||||
if (NOT TARGET robot_nav_core_adapter)
|
||||
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Navigations/Cores/robot_nav_core_adapter)
|
||||
endif()
|
||||
|
||||
if (NOT TARGET move_base_core)
|
||||
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Navigations/Cores/move_base_core)
|
||||
endif()
|
||||
|
||||
if (NOT TARGET mkt_msgs)
|
||||
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Algorithms/Libraries/mkt_msgs)
|
||||
endif()
|
||||
|
||||
if (NOT TARGET angles)
|
||||
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Algorithms/Libraries/angles)
|
||||
endif()
|
||||
|
||||
if (NOT TARGET kalman)
|
||||
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Algorithms/Libraries/kalman)
|
||||
endif()
|
||||
|
||||
if (NOT TARGET score_algorithm)
|
||||
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Algorithms/Cores/score_algorithm)
|
||||
endif()
|
||||
|
||||
if (NOT TARGET mkt_plugins)
|
||||
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Algorithms/Libraries/mkt_plugins)
|
||||
endif()
|
||||
|
||||
if (NOT TARGET mkt_algorithm)
|
||||
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Algorithms/Libraries/mkt_algorithm)
|
||||
endif()
|
||||
|
||||
if (NOT TARGET two_points_planner)
|
||||
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Algorithms/Packages/global_planners/two_points_planner)
|
||||
endif()
|
||||
|
||||
if (NOT TARGET custom_planner)
|
||||
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Algorithms/Packages/global_planners/custom_planner)
|
||||
endif()
|
||||
|
||||
if (NOT TARGET dock_planner)
|
||||
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Algorithms/Packages/global_planners/dock_planner)
|
||||
endif()
|
||||
|
||||
if (NOT TARGET pnkx_local_planner)
|
||||
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Algorithms/Packages/local_planners/pnkx_local_planner)
|
||||
endif()
|
||||
|
||||
# Local planner đang chạy trên robot thật: cả bốn profile trong move_base_common_params.yaml đều
|
||||
# trỏ `StanleyLocalPlanner`. Thiếu libstanley_local_planner.so là move_base2 chết ngay ở
|
||||
# `initialize()` ("could not load the initial local planner").
|
||||
if (NOT TARGET stanley_local_planner)
|
||||
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Algorithms/Packages/local_planners/stanley_local_planner)
|
||||
endif()
|
||||
|
||||
if (NOT TARGET robot_actionlib_msgs)
|
||||
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Navigations/Libraries/robot_actionlib_msgs)
|
||||
endif()
|
||||
|
||||
if (NOT TARGET robot_move_base_msgs)
|
||||
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Navigations/Libraries/robot_move_base_msgs)
|
||||
endif()
|
||||
|
||||
# Mission/action/recovery framework + navigation runtime. Bốn gói này đã được đưa hẳn vào cây
|
||||
# (submodule) nên add thẳng như mọi gói in-tree khác, KHÔNG đi qua pnkx_add_test_package.
|
||||
#
|
||||
# Thứ tự là ràng buộc thật, không phải phong cách: move_base2 tiêu thụ API của cả ba gói trên
|
||||
# (ActionRunner <- action_core, RecoveryRunner <- recovery_core, MissionLayer <- mission_adapters)
|
||||
# nên phải đứng cuối.
|
||||
if (NOT TARGET action_core)
|
||||
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Libraries/action_core)
|
||||
endif()
|
||||
|
||||
if (NOT TARGET recovery_core)
|
||||
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Libraries/recovery_core)
|
||||
endif()
|
||||
|
||||
if (NOT TARGET mission_adapters)
|
||||
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Libraries/mission_adapters)
|
||||
endif()
|
||||
|
||||
if (NOT TARGET move_base2_core)
|
||||
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Navigations/Packages/move_base2)
|
||||
endif()
|
||||
|
||||
# 3. Packages being migrated from AMR_T800/Test
|
||||
#
|
||||
# Prefer the future in-tree location. Until the migration is physically done,
|
||||
# keep the current sibling Test directory buildable from this root CMake file.
|
||||
option(PNKX_NAV_CORE_BUILD_TEST_PACKAGES
|
||||
"Build navigation packages currently kept in AMR_T800/Test"
|
||||
ON)
|
||||
|
||||
option(PNKX_NAV_CORE_BUILD_CATKIN_TEST_PACKAGES
|
||||
"Build Test packages that require a catkin workspace instead of standalone CMake"
|
||||
OFF)
|
||||
|
||||
set(PNKX_NAV_CORE_TEST_PACKAGES_DIR ""
|
||||
CACHE PATH "Directory containing the migrated navigation Test packages")
|
||||
|
||||
if(NOT PNKX_NAV_CORE_TEST_PACKAGES_DIR)
|
||||
if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/Test")
|
||||
set(PNKX_NAV_CORE_TEST_PACKAGES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/Test")
|
||||
elseif(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../Test")
|
||||
set(PNKX_NAV_CORE_TEST_PACKAGES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../Test")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
function(pnkx_add_test_package package_name)
|
||||
set(package_dir "${PNKX_NAV_CORE_TEST_PACKAGES_DIR}/${package_name}")
|
||||
if(EXISTS "${package_dir}/CMakeLists.txt")
|
||||
message(STATUS "[pnkx_nav_core] Adding migrated Test package: ${package_name}")
|
||||
add_subdirectory("${package_dir}" "${CMAKE_BINARY_DIR}/Test/${package_name}")
|
||||
else()
|
||||
message(WARNING
|
||||
"[pnkx_nav_core] Test package '${package_name}' was not found in "
|
||||
"'${PNKX_NAV_CORE_TEST_PACKAGES_DIR}'.")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
if(PNKX_NAV_CORE_BUILD_TEST_PACKAGES AND NOT PNKX_NAV_CORE_TEST_PACKAGES_DIR)
|
||||
# Không còn là lỗi: bốn gói từng nằm ở Test/ nay đã in-tree, nên một cây không có Test/ vẫn
|
||||
# build được đầy đủ nav runtime. Chỉ những gói CHƯA di trú (planner, msgs) là bị bỏ qua.
|
||||
message(STATUS
|
||||
"[pnkx_nav_core] No Test package directory found — skipping the packages still kept "
|
||||
"in AMR_T800/Test. Set PNKX_NAV_CORE_TEST_PACKAGES_DIR to build them.")
|
||||
set(PNKX_NAV_CORE_BUILD_TEST_PACKAGES OFF)
|
||||
endif()
|
||||
|
||||
if(PNKX_NAV_CORE_BUILD_TEST_PACKAGES)
|
||||
# Foundation and message packages.
|
||||
pnkx_add_test_package(angles)
|
||||
pnkx_add_test_package(image_geometry)
|
||||
pnkx_add_test_package(grid_map_core)
|
||||
pnkx_add_test_package(vda5050_msgs)
|
||||
|
||||
# Planner libraries and plugins. SBPL must precede its lattice plugin.
|
||||
pnkx_add_test_package(sbpl)
|
||||
pnkx_add_test_package(sbpl_lattice_planner)
|
||||
pnkx_add_test_package(base_local_planner)
|
||||
pnkx_add_test_package(hybrid_local_planner)
|
||||
pnkx_add_test_package(mppi_local_planner)
|
||||
pnkx_add_test_package(priest_local_planner)
|
||||
pnkx_add_test_package(stanley_local_planner)
|
||||
|
||||
# Supporting runtime packages and test utilities.
|
||||
# action_core / recovery_core / mission_adapters / move_base2 KHÔNG còn ở đây — đã in-tree,
|
||||
# add ở mục 2 bên trên.
|
||||
pnkx_add_test_package(depth_image_proc)
|
||||
pnkx_add_test_package(nav_test_harness)
|
||||
endif()
|
||||
|
||||
# These packages call find_package(catkin REQUIRED ...) for T800 packages.
|
||||
# Keep them outside the standalone graph until their dependencies export
|
||||
# *Config.cmake files, or build them through a catkin workspace.
|
||||
if(PNKX_NAV_CORE_BUILD_CATKIN_TEST_PACKAGES)
|
||||
pnkx_add_test_package(deep_mpc_local_planner)
|
||||
pnkx_add_test_package(nav_ros_bridge)
|
||||
pnkx_add_test_package(depth_local_costmap_noetic_test)
|
||||
endif()
|
||||
|
||||
# C API for .NET/C# integration. Target is `nav_c_api` — the guard must name the same target,
|
||||
# otherwise it never matches and the subdirectory is added twice on a re-entrant configure.
|
||||
if (NOT TARGET nav_c_api)
|
||||
add_subdirectory(${CMAKE_SOURCE_DIR}/src/APIs/c_api)
|
||||
endif()
|
||||
|
||||
message(STATUS "========================================")
|
||||
message(STATUS "All packages configured successfully")
|
||||
message(STATUS "========================================")
|
||||
3
README.md
Normal file
3
README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
# pnkx_nav_core
|
||||
|
||||
Phần mềm quản lý việc di chuyển navigation
|
||||
154
config/runtime/action_handlers_params.yaml
Normal file
154
config/runtime/action_handlers_params.yaml
Normal file
@@ -0,0 +1,154 @@
|
||||
# =================================================================================================
|
||||
# action_core — action handler của move_base2.
|
||||
#
|
||||
# Quy ước comment: dòng mô tả = LÀ GÌ / vì sao; `► Chỉnh:` = tăng giảm theo triệu chứng nào.
|
||||
#
|
||||
# D8: navigation runtime chạy TRỌN một mission — đi tới đích xong thì chạy nốt action của chặng rồi
|
||||
# mới báo kết quả. Trong lúc chạy action robot KHÔNG phát cmd_vel.
|
||||
#
|
||||
# Handler là plugin của gói `action_core`, nạp qua Boost.DLL đúng như planner/recovery. Thêm một
|
||||
# loại action mới = viết một `.so` + thêm một dòng ở đây, không phải sửa dòng nào của navigation.
|
||||
#
|
||||
# Vì sao file này tồn tại: thiếu handler thì `ActionRunner::start` từ chối và chặng mang action đi
|
||||
# thẳng tới ABORTED — tức mọi order VDA5050 có node action fail ở chặng đầu tiên.
|
||||
#
|
||||
# BA TẦNG TIMEOUT, đừng lẫn:
|
||||
# 1. `timeout` của chính handler (trong khối handler bên dưới) — handler tự biết thiết bị của nó;
|
||||
# 2. `action_patience` của state machine — lưới chung cho MỌI action, mặc định tắt;
|
||||
# 3. `mission_timeout` của mission layer — lưới cho cả chặng nav + action.
|
||||
# =================================================================================================
|
||||
|
||||
actions:
|
||||
# Danh sách handler được nạp.
|
||||
# name: tên instance = namespace param riêng bên dưới
|
||||
# type: alias Boost.DLL, phải có `library_path` ở cuối file
|
||||
#
|
||||
# ► Chỉnh: một `type` được phép khai nhiều `name` để có nhiều instance khác tuning. Handler nào
|
||||
# không khai `action_types` sẽ không bao giờ được gọi.
|
||||
handlers:
|
||||
# Dò: lấy mẫu frame thô của LiDAR/camera, lọc, ghi ra `dock_target` cho chặng sau tra.
|
||||
- {name: detect_charger, type: FrameSamplerActionHandler}
|
||||
|
||||
- {name: detect_pallet, type: FrameSamplerActionHandler}
|
||||
|
||||
# --- detect: lấy mẫu frame đích rồi ghi ra một frame TF ổn định ---------------------------------
|
||||
detect_charger:
|
||||
action_types: [DETECTCHARGER]
|
||||
input_frame: charger_raw # <-- tên perception publish
|
||||
output_frame: dock_target
|
||||
|
||||
# Frame THÔ để lấy mẫu (do perception publish). CỐ Ý KHÔNG KHAI: mặc định là chuỗi rỗng, nghĩa
|
||||
# là handler lấy frame từ `goal_frame` của chính action trong order — linh hoạt hơn, thêm một
|
||||
# trạm mới không phải sửa file này. Khai chuỗi rỗng trong YAML dễ bị parse thành `null` (khác
|
||||
# `""`), nên để trống hẳn thay vì khai.
|
||||
# ► Chỉnh: chỉ khai khi perception publish một frame CỐ ĐỊNH cho mọi lần dò, ví dụ:
|
||||
# input_frame: charger_raw
|
||||
# Đây là khoá quyết định handler dò CÁI GÌ khi tắt `use_simulated_goal` để chạy robot thật.
|
||||
|
||||
# STUB chỉ cho Gazebo/dev: thay perception bằng target cố định trong `base_link`. Handler quy nó
|
||||
# sang `map` MỘT LẦN rồi ghi `dock_target` tĩnh vào tf3, nên target không chạy theo robot khi
|
||||
# chặng docking bắt đầu.
|
||||
# ► Chỉnh: PHẢI đặt false trước khi chạy robot thật, để handler lấy frame do perception publish.
|
||||
# Để true trên robot thật = robot tiến vào một điểm bịa.
|
||||
use_simulated_goal: false
|
||||
simulated_parent_frame: base_link
|
||||
simulated_offset_x: -1.5 # [m] ► Chỉnh: chỉ có nghĩa khi use_simulated_goal: true.
|
||||
simulated_offset_y: 0.2 # [m] Đặt theo vị trí vật thể giả trong world Gazebo.
|
||||
simulated_offset_yaw: 0.0 # [rad]
|
||||
|
||||
# [s] Chờ robot đứng hẳn trước khi lấy mẫu — pose lúc vừa dừng còn dao động cơ khí.
|
||||
# ► Chỉnh: TĂNG nếu robot nặng/treo mềm và mẫu đầu bị lệch. GIẢM để rút ngắn chu kỳ dock.
|
||||
settle_delay: 1.0
|
||||
|
||||
# [s] Cửa sổ thu mẫu.
|
||||
# ► Chỉnh: TĂNG cùng `min_samples` khi perception publish thưa hoặc nhiễu; GIẢM để dock nhanh
|
||||
# hơn khi frame đã rất ổn định.
|
||||
sample_window: 2.0
|
||||
|
||||
# Số mẫu tối thiểu phải thu được trong cửa sổ, nếu không -> kFailed.
|
||||
# ► Chỉnh: đặt ~= (tần số publish của perception) x `sample_window` x 0.5 để còn dư địa. Đặt cao
|
||||
# quá là action fail dù frame vẫn tốt.
|
||||
min_samples: 20
|
||||
|
||||
# Độ tản tối đa của tập mẫu. Tản hơn -> kFailed, KHÔNG lùi vào.
|
||||
# ► Chỉnh: đây là chốt AN TOÀN, không phải nút để "cho qua". Nới ra nghĩa là chấp nhận tiến vào
|
||||
# một đích đo không chắc. Đo độ tản thật trên hiện trường rồi đặt ~1.5 lần giá trị đó.
|
||||
max_spread_xy: 0.03 # [m]
|
||||
max_spread_yaw: 0.05 # [rad]
|
||||
|
||||
# [s] Phải giữ trạng thái ĐẠT liên tục ngần này mới chốt kết quả; tản trở lại một tick là reset
|
||||
# đồng hồ. 0 = chốt ngay cửa sổ đạt đầu tiên, đúng hành vi trước đây.
|
||||
# ► Chỉnh: đặt 0.5-1.0 khi perception thỉnh thoảng bám nhầm vật thể khác một cách ỔN ĐỊNH — khi
|
||||
# ấy mẫu vẫn chụm, chỉ là chụm quanh sai chỗ, và một cửa sổ đơn lẻ không phân biệt được. Cộng
|
||||
# thẳng vào thời gian dock.
|
||||
hold_time: 0.0
|
||||
|
||||
# [s] Frame thô không tới trong khoảng này -> kFailed.
|
||||
# ► Chỉnh: phải > settle_delay + sample_window (1.0 + 2.0) cộng dư địa cho perception khởi động.
|
||||
timeout: 15.0
|
||||
|
||||
detect_pallet:
|
||||
action_types: [DETECTPALLET]
|
||||
input_frame: pallet_raw # <-- tên perception publish
|
||||
output_frame: dock_target
|
||||
|
||||
# Frame THÔ để lấy mẫu (do perception publish). CỐ Ý KHÔNG KHAI: mặc định là chuỗi rỗng, nghĩa
|
||||
# là handler lấy frame từ `goal_frame` của chính action trong order — linh hoạt hơn, thêm một
|
||||
# trạm mới không phải sửa file này. Khai chuỗi rỗng trong YAML dễ bị parse thành `null` (khác
|
||||
# `""`), nên để trống hẳn thay vì khai.
|
||||
# ► Chỉnh: chỉ khai khi perception publish một frame CỐ ĐỊNH cho mọi lần dò, ví dụ:
|
||||
# input_frame: charger_raw
|
||||
# Đây là khoá quyết định handler dò CÁI GÌ khi tắt `use_simulated_goal` để chạy robot thật.
|
||||
|
||||
# STUB chỉ cho Gazebo/dev: thay perception bằng target cố định trong `base_link`. Handler quy nó
|
||||
# sang `map` MỘT LẦN rồi ghi `dock_target` tĩnh vào tf3, nên target không chạy theo robot khi
|
||||
# chặng docking bắt đầu.
|
||||
# ► Chỉnh: PHẢI đặt false trước khi chạy robot thật, để handler lấy frame do perception publish.
|
||||
# Để true trên robot thật = robot tiến vào một điểm bịa.
|
||||
use_simulated_goal: false
|
||||
simulated_parent_frame: base_link
|
||||
simulated_offset_x: -1.5 # [m] ► Chỉnh: chỉ có nghĩa khi use_simulated_goal: true.
|
||||
simulated_offset_y: 0.2 # [m] Đặt theo vị trí vật thể giả trong world Gazebo.
|
||||
simulated_offset_yaw: 0.0 # [rad]
|
||||
|
||||
# [s] Chờ robot đứng hẳn trước khi lấy mẫu — pose lúc vừa dừng còn dao động cơ khí.
|
||||
# ► Chỉnh: TĂNG nếu robot nặng/treo mềm và mẫu đầu bị lệch. GIẢM để rút ngắn chu kỳ dock.
|
||||
settle_delay: 1.0
|
||||
|
||||
# [s] Cửa sổ thu mẫu.
|
||||
# ► Chỉnh: TĂNG cùng `min_samples` khi perception publish thưa hoặc nhiễu; GIẢM để dock nhanh
|
||||
# hơn khi frame đã rất ổn định.
|
||||
sample_window: 2.0
|
||||
|
||||
# Số mẫu tối thiểu phải thu được trong cửa sổ, nếu không -> kFailed.
|
||||
# ► Chỉnh: đặt ~= (tần số publish của perception) x `sample_window` x 0.5 để còn dư địa. Đặt cao
|
||||
# quá là action fail dù frame vẫn tốt.
|
||||
min_samples: 1
|
||||
|
||||
# Độ tản tối đa của tập mẫu. Tản hơn -> kFailed, KHÔNG lùi vào.
|
||||
# ► Chỉnh: đây là chốt AN TOÀN, không phải nút để "cho qua". Nới ra nghĩa là chấp nhận tiến vào
|
||||
# một đích đo không chắc. Đo độ tản thật trên hiện trường rồi đặt ~1.5 lần giá trị đó.
|
||||
max_spread_xy: 0.1 # [m]
|
||||
max_spread_yaw: 0.1 # [rad]
|
||||
|
||||
# [s] Phải giữ trạng thái ĐẠT liên tục ngần này mới chốt kết quả; tản trở lại một tick là reset
|
||||
# đồng hồ. 0 = chốt ngay cửa sổ đạt đầu tiên, đúng hành vi trước đây.
|
||||
# ► Chỉnh: đặt 0.5-1.0 khi perception thỉnh thoảng bám nhầm vật thể khác một cách ỔN ĐỊNH — khi
|
||||
# ấy mẫu vẫn chụm, chỉ là chụm quanh sai chỗ, và một cửa sổ đơn lẻ không phân biệt được. Cộng
|
||||
# thẳng vào thời gian dock.
|
||||
hold_time: 0.0
|
||||
|
||||
# [s] Frame thô không tới trong khoảng này -> kFailed.
|
||||
# ► Chỉnh: phải > settle_delay + sample_window (1.0 + 2.0) cộng dư địa cho perception khởi động.
|
||||
timeout: 40.0
|
||||
|
||||
|
||||
|
||||
# ⚠ CỐ Ý KHÔNG KHAI: khoá `hang` (mặc định false) là TEST HOOK làm handler treo vĩnh viễn, chỉ
|
||||
# dùng để kiểm đường timeout trong unit test. Khai `hang: true` trên robot = chặng đứng im cho
|
||||
# tới khi hết `timeout` ở trên. Đừng thêm vào file runtime.
|
||||
|
||||
# Bảng symbol -> thư viện cho Boost.DLL. KHÔNG phải tham số tinh chỉnh — thiếu `library_path` là
|
||||
# nguyên nhân phổ biến nhất của lỗi "plugin build xong nhưng runtime báo không tìm thấy".
|
||||
FrameSamplerActionHandler:
|
||||
library_path: libaction_core_frame_sampler_action_handler
|
||||
103
config/runtime/compound_actions_params.yaml
Normal file
103
config/runtime/compound_actions_params.yaml
Normal file
@@ -0,0 +1,103 @@
|
||||
# =================================================================================================
|
||||
# action_core / mission_adapters — compound action: "phải dò rồi mới biết đích".
|
||||
#
|
||||
# Quy ước comment: dòng mô tả = LÀ GÌ / vì sao; `► Chỉnh:` = sửa thế nào cho đúng.
|
||||
#
|
||||
# Đây là bảng mở rộng của `VDA5050SourceAdapter`: một action của fleet được DỊCH thành một chuỗi
|
||||
# chặng (nav + action) trước khi xuống navigation. Fleet chỉ gửi `charge`; `DetectCharger` và
|
||||
# `startCharging` là actionType NỘI BỘ do adapter sinh ra, không bao giờ xuất hiện trong order JSON.
|
||||
#
|
||||
# File riêng thay vì sửa `mission_adapters_params.yaml`: file đó là symlink sang cây config của
|
||||
# `pnkx_nav_core` (submodule). `robot::NodeHandle` gộp mọi file YAML trong thư mục config vào một
|
||||
# cây, nên khoá `vda5050_src` ở đây hợp nhất với khoá cùng tên bên kia.
|
||||
#
|
||||
# ── Bảng này chỉ giữ CẤU TRÚC ────────────────────────────────────────────────────────────────────
|
||||
#
|
||||
# Tên frame cụ thể đến từ `actionParameters` của chính order, nên thêm một trạm sạc mới KHÔNG phải
|
||||
# sửa file này.
|
||||
#
|
||||
# Bốn từ khoá của một step, phải có ĐÚNG MỘT:
|
||||
# action: <type> chặng chỉ-action; mang nguyên actionParameters của action gốc
|
||||
# move_to: <frame> chặng nav, frame cố định
|
||||
# move_to_param: <key> chặng nav, frame lấy từ actionParameters[<key>] của action gốc
|
||||
# move: <mét> chặng nav tương đối; dương = tiến, âm = lùi
|
||||
#
|
||||
# Tuỳ chọn cho step navigation: profile (position | docking | go_straight | rotate), marker.
|
||||
# `marker` chỉ hợp lệ với `profile: docking`: nó chọn override trong
|
||||
# maker_sources.yaml/docking_marker_profiles. Không khai = dùng cặp docking mặc định.
|
||||
# Tolerance thuộc YAML riêng của local planner đang được profile chọn, không khai ở đây.
|
||||
#
|
||||
# ── Ba quy tắc khi sửa ───────────────────────────────────────────────────────────────────────────
|
||||
# 1. Mỗi `action: X` thêm mới PHẢI có handler nhận `X` trong `action_handlers_params.yaml`
|
||||
# (`action_types`), nếu không chặng đó ABORT.
|
||||
# 2. `clear_queue_on_failure: true` (mission_adapters_params.yaml) là thứ ngăn robot chạy bước
|
||||
# thiết bị khi bước dò/bước tiến vào đã hỏng — đừng tắt khi còn dùng compound action.
|
||||
# 3. Thứ tự step là hợp đồng an toàn: dò -> vào vị trí -> mới thao tác thiết bị. Đảo thứ tự nghĩa
|
||||
# là đóng relay / nâng càng khi chưa vào đúng chỗ.
|
||||
# =================================================================================================
|
||||
|
||||
vda5050_src:
|
||||
compound_actions:
|
||||
# --- charge: vào trạm sạc ---------------------------------------------------------------------
|
||||
CHARGE:
|
||||
steps:
|
||||
# 1. Dò: đứng yên lấy mẫu frame thô, lọc nhiễu, ghi ra `dock_target`.
|
||||
# Robot không phát cmd_vel trong EXECUTING_ACTIONS nên đây đúng là lúc để lọc.
|
||||
# Tham số lọc (sample_window, max_spread_*) nằm ở khối `detect` bên action_handlers.
|
||||
- {action: DETECTCHARGER}
|
||||
|
||||
# 2. Tiến vào đích vừa dò được bằng profile docking. Sai số do local planner đọc từ YAML
|
||||
# của chính plugin đó (hybrid_local_planner_params.yaml), KHÔNG khai ở đây.
|
||||
- {move_to: dock_target, profile: docking, marker: charger}
|
||||
|
||||
# # 3. Thao tác thiết bị. Chặng 1 hoặc 2 hỏng thì `clear_queue_on_failure` xoá chặng này —
|
||||
# # robot không bao giờ đóng relay khi chưa vào được vị trí.
|
||||
# - {action: STARTCHARGING}
|
||||
|
||||
# --- PickUp: lấy kệ ---------------------------------------------------------------------------
|
||||
PICKUP:
|
||||
steps:
|
||||
- {action: DETECTPALLET}
|
||||
- {move_to: dock_target, profile: docking, marker: pallet}
|
||||
# - {action: LIFTFORK}
|
||||
# # Lùi ra khỏi khe kệ. Quãng đường tương đối được quy ra pose tuyệt đối tại `submit`, từ pose
|
||||
# # LÚC ĐÓ — lúc adapter sinh chặng thì robot còn chưa tới nơi.
|
||||
# # ► Chỉnh: [m] âm = lùi. Đặt đủ dài để càng nâng ra hẳn khỏi khe kệ trước khi robot xoay;
|
||||
# # quá ngắn thì kệ quệt vào giá, quá dài thì tốn thời gian và có thể lùi vào lối đi chung.
|
||||
# - {move: -0.5, profile: go_straight}
|
||||
|
||||
# --- DOCKTO: vào vị trí kệ, cùng chuỗi với PICKUP ----------------------------------------------
|
||||
#
|
||||
# Entry point `dockTo` của BaseNavigation/C API đã bị GỠ; fleet gửi action này qua order hoặc
|
||||
# instantActions và nó phải nở ra chuỗi chặng ở đây, nếu không chặng ABORT vì không có handler.
|
||||
#
|
||||
# Bước thiết bị giữ nguyên trạng thái comment như PICKUP: `sim_noop` chỉ log rồi báo thành công,
|
||||
# bật lên trên robot thật nghĩa là báo "đã nâng kệ" trong khi càng chưa nhúc nhích.
|
||||
DOCKTO:
|
||||
steps:
|
||||
- {action: DETECTPALLET}
|
||||
- {move_to: dock_target, profile: docking, marker: trolley}
|
||||
# - {action: LIFTFORK}
|
||||
# - {move: -0.5, profile: go_straight}
|
||||
|
||||
# --- UNDOCKFROMSTATION: lùi ra khỏi trạm --------------------------------------------------------
|
||||
#
|
||||
# Thay cho entry point `moveStraightTo` đã bị gỡ. Không có bước thiết bị nào nên an toàn để bật.
|
||||
# ► Chỉnh: [m] ÂM = lùi. Đặt đủ dài để robot ra hẳn khỏi trạm trước khi xoay; quá ngắn thì quệt
|
||||
# vào trạm, quá dài thì lùi vào lối đi chung. Profile `go_straight` KHÔNG tránh vật cản.
|
||||
UNDOCKFROMSTATION:
|
||||
steps:
|
||||
- {move: 2.0, profile: go_straight}
|
||||
|
||||
# --- GoStraight / Rotate: hai lệnh chuyển động trần, dùng để kiểm thử và cho quy trình đơn giản
|
||||
GOSTRAIGHT:
|
||||
steps:
|
||||
# ► Chỉnh: [m] dương = tiến, âm = lùi. Profile `go_straight` không tránh vật cản dọc đường —
|
||||
# chỉ dùng cho quãng ngắn đã biết là trống.
|
||||
- {move: 2.0, profile: go_straight}
|
||||
|
||||
ROTATE:
|
||||
steps:
|
||||
# ► Chỉnh: `move: 0.0` = không tịnh tiến; góc quay lấy từ actionParameters của order.
|
||||
# Profile `rotate` dùng PNKXRotateLocalPlanner, tham số ở YAML của plugin đó.
|
||||
- {move: 0.0, profile: rotate}
|
||||
36
config/runtime/config/costmap_params.yaml
Normal file
36
config/runtime/config/costmap_params.yaml
Normal file
@@ -0,0 +1,36 @@
|
||||
robot_costmap_2d:
|
||||
global_frame: map
|
||||
robot_base_frame: base_link
|
||||
rolling_window: false
|
||||
track_unknown_space: false
|
||||
|
||||
plugins:
|
||||
- name: static_layer
|
||||
type: StaticLayer
|
||||
|
||||
- name: inflation_layer
|
||||
type: InflationLayer
|
||||
|
||||
- name: obstacle_layer
|
||||
type: ObstacleLayer
|
||||
|
||||
- name: voxel_layer
|
||||
type: VoxelLayer
|
||||
|
||||
library_path: ./libplugins.so
|
||||
footprint:
|
||||
- [0.3, 0.3]
|
||||
- [0.3, -0.3]
|
||||
- [-0.3, -0.3]
|
||||
- [-0.3, 0.3]
|
||||
|
||||
transform_tolerance: 0.0
|
||||
update_frequency: 1.0
|
||||
width: 0.0
|
||||
height: 0.0
|
||||
resolution: 0.0
|
||||
origin_x: 0.0
|
||||
origin_y: 0.0
|
||||
|
||||
footprint_padding: 0.0
|
||||
robot_radius: 0.0
|
||||
5
config/runtime/config/inflation_layer_params.yaml
Normal file
5
config/runtime/config/inflation_layer_params.yaml
Normal file
@@ -0,0 +1,5 @@
|
||||
inflation_layer:
|
||||
enabled: true
|
||||
inflate_unknown: false
|
||||
cost_scaling_factor: 15.0
|
||||
inflation_radius: 0.55
|
||||
19
config/runtime/config/obstacle_layer_params.yaml
Normal file
19
config/runtime/config/obstacle_layer_params.yaml
Normal file
@@ -0,0 +1,19 @@
|
||||
obstacle_layer:
|
||||
enabled: true
|
||||
track_unknown_space: true
|
||||
transform_tolerance: 0.2
|
||||
topic: "map"
|
||||
sensor_frame: laser_frame
|
||||
observation_persistence: 0.0
|
||||
expected_update_rate: 0.0
|
||||
data_type: PointCloud
|
||||
min_obstacle_height: 0.0
|
||||
max_obstacle_height: 2.0
|
||||
inf_is_valid: false
|
||||
clearing: false
|
||||
marking: true
|
||||
obstacle_range: 2.5
|
||||
raytrace_range: 3.0
|
||||
footprint_clearing_enabled: true
|
||||
combination_method: 1
|
||||
|
||||
11
config/runtime/config/static_layer_params.yaml
Normal file
11
config/runtime/config/static_layer_params.yaml
Normal file
@@ -0,0 +1,11 @@
|
||||
static_layer:
|
||||
enabled: true
|
||||
map_topic: "map"
|
||||
first_map_only: false
|
||||
subscribe_to_updates: false
|
||||
track_unknown_space: true
|
||||
use_maximum: false
|
||||
lethal_cost_threshold: 100
|
||||
unknown_cost_value: -1
|
||||
trinary_costmap: true
|
||||
base_frame_id: "map"
|
||||
15
config/runtime/config/voxel_layer_params.yaml
Normal file
15
config/runtime/config/voxel_layer_params.yaml
Normal file
@@ -0,0 +1,15 @@
|
||||
voxel_layer:
|
||||
enabled: true
|
||||
footprint_clearing_enabled: true
|
||||
max_obstacle_height: 3.0
|
||||
origin_z: 0.0
|
||||
z_resolution: 0.2
|
||||
z_voxels: 16
|
||||
unknown_threshold: 15.0
|
||||
mark_threshold: 0
|
||||
combination_method: 1
|
||||
frustum_clearing_enabled: true
|
||||
frustum_clearing_pixel_step: 8
|
||||
frustum_min_range: 0.20
|
||||
frustum_max_range: 3.0
|
||||
frustum_depth_camera_topic: /camera/depth/data
|
||||
39
config/runtime/costmap_common_params.yaml
Normal file
39
config/runtime/costmap_common_params.yaml
Normal file
@@ -0,0 +1,39 @@
|
||||
robot_base_frame: base_link
|
||||
transform_tolerance: 1.0
|
||||
performance_metrics_enabled: true
|
||||
performance_metrics_period: 5.0
|
||||
obstacle_range: 3.0
|
||||
#mark_threshold: 1
|
||||
publish_voxel_map: true
|
||||
footprint_padding: 0.0
|
||||
|
||||
navigation_map:
|
||||
map_topic: /map
|
||||
map_pkg: managerments
|
||||
map_file: maze
|
||||
|
||||
virtual_walls_map:
|
||||
map_topic: /map
|
||||
namespace: /virtual_walls
|
||||
map_pkg: managerments
|
||||
map_file: maze
|
||||
use_maximum: true
|
||||
lethal_cost_threshold: 100
|
||||
|
||||
obstacles:
|
||||
observation_sources:
|
||||
# b_scan
|
||||
|
||||
b_scan:
|
||||
topic: /b_scan
|
||||
data_type: LaserScan
|
||||
clearing: true
|
||||
marking: true
|
||||
inf_is_valid: true
|
||||
frustum_clearing_enabled: false
|
||||
min_obstacle_height: 0.0
|
||||
max_obstacle_height: 0.25
|
||||
|
||||
# Việc xoá vật cản (clearing) của camera depth do VoxelLayer đảm nhiệm bằng
|
||||
# frustum clearing, lấy dữ liệu từ /camera/depth/image_raw +
|
||||
# /camera/depth/camera_info. Nhánh /camera_right/depth/data cũng đi đường đó.
|
||||
15
config/runtime/costmap_global_params.yaml
Normal file
15
config/runtime/costmap_global_params.yaml
Normal file
@@ -0,0 +1,15 @@
|
||||
global_costmap:
|
||||
library_path: libplugins
|
||||
robot_base_frame: base_link
|
||||
global_frame: map
|
||||
update_frequency: 1.0
|
||||
publish_frequency: 1.0
|
||||
raytrace_range: 3.0
|
||||
resolution: 0.05
|
||||
z_resolution: 0.2
|
||||
rolling_window: false
|
||||
z_voxels: 10
|
||||
inflation:
|
||||
cost_scaling_factor: 10.0 # Exponential rate at which the obstacle cost drops off (default: 10). Must be chosen so that the cost value is > 0 at robot's circumscribed radius.
|
||||
inflation_radius: 0.6 # Max. distance from an obstacle at which costs are incurred for planning paths. Must be > robot's circumscribed radius.
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
global_costmap:
|
||||
frame_id: map
|
||||
plugins:
|
||||
- {name: navigation_map, type: "StaticLayer" }
|
||||
- {name: obstacles, type: "VoxelLayer" }
|
||||
- {name: inflation, type: "InflationLayer" }
|
||||
obstacles:
|
||||
enabled: false
|
||||
footprint_clearing_enabled: true
|
||||
18
config/runtime/costmap_local_params.yaml
Normal file
18
config/runtime/costmap_local_params.yaml
Normal file
@@ -0,0 +1,18 @@
|
||||
local_costmap:
|
||||
library_path: libplugins
|
||||
global_frame: odom
|
||||
robot_base_frame: base_link
|
||||
update_frequency: 6.0
|
||||
publish_frequency: 6.0
|
||||
rolling_window: true
|
||||
raytrace_range: 3.0
|
||||
resolution: 0.05
|
||||
z_resolution: 0.15
|
||||
z_voxels: 8
|
||||
inflation:
|
||||
cost_scaling_factor: 10.0 # Exponential rate at which the obstacle cost drops off (default: 10). Must be chosen so that the cost value is > 0 at robot's circumscribed radius.
|
||||
inflation_radius: 0.3 # Max. distance from an obstacle at which costs are incurred for planning paths. Must be > robot's circumscribed radius.
|
||||
width: 8.0
|
||||
height: 8.0
|
||||
origin_x: 0.0
|
||||
origin_y: 0.0
|
||||
@@ -0,0 +1,8 @@
|
||||
local_costmap:
|
||||
frame_id: odom
|
||||
plugins:
|
||||
- {name: obstacles, type: "VoxelLayer" }
|
||||
- {name: inflation, type: "InflationLayer" }
|
||||
obstacles:
|
||||
enabled: true
|
||||
footprint_clearing_enabled: true
|
||||
42
config/runtime/custom_global_params.yaml
Normal file
42
config/runtime/custom_global_params.yaml
Normal file
@@ -0,0 +1,42 @@
|
||||
# custom_planner — tham số runtime, đọc qua robot::NodeHandle("CustomPlanner").
|
||||
# Thiếu key nào thì dùng default trong CustomPlannerConfig (cùng giá trị ghi ở đây).
|
||||
#
|
||||
# Khối cũ (environment_type, planner_type, allocated_time, initial_epsilon,
|
||||
# force_scratch_limit, forward_search, nominalvel_mpersecs,
|
||||
# timetoturn45degsinplace_secs, allow_unknown, directory_to_save_paths,
|
||||
# pathway_filename, current_pose_topic_name) đã bỏ: không chỗ nào trong cây này
|
||||
# đọc chúng — đó là tham số SBPL còn sót từ thời CustomPlanner chưa có config
|
||||
# riêng. Tham số SBPL thật nằm ở sbpl_global_params.yaml.
|
||||
CustomPlanner:
|
||||
library_path: libcustom_planner
|
||||
|
||||
# [m] start/goal cách pathway dưới ngưỡng này thì coi là đã bám vào pathway
|
||||
# (quyết định cách nối NURBS start/goal vào tuyến).
|
||||
pathway_attach_distance: 0.1
|
||||
|
||||
# [m] order không có node/edge (goal trần): chỉ nhận khi start-goal gần hơn
|
||||
# ngưỡng này, ngược lại trả false để move_base2 dùng backup planner.
|
||||
bare_goal_max_distance: 0.2
|
||||
|
||||
# Bước tham số u trong [0,1] khi đo chiều dài NURBS một cạnh (không phải mét).
|
||||
nurbs_length_t_interval: 0.01
|
||||
|
||||
# [m] khoảng cách mong muốn giữa hai pose khi lấy mẫu NURBS nối start/goal.
|
||||
nurbs_point_spacing: 0.05
|
||||
|
||||
# [rad] hai cạnh thẳng đầu gãy dưới góc này thì bỏ cạnh đầu khi tính yaw.
|
||||
skip_edge_angle: 0.4712 # = 0.15*pi
|
||||
|
||||
# [rad] góc nối giữa hai cạnh <= tight: gãy gắt (cost 20); < wide: gãy vừa (cost 10).
|
||||
cost_angle_tight: 0.3142 # = 0.1*pi
|
||||
cost_angle_wide: 1.4137 # = 0.45*pi
|
||||
|
||||
# [rad] cửa sổ góc đổi hướng cần chèn chuỗi pose xoay tại chỗ giữa hai cạnh.
|
||||
rotation_insert_min: 1.4137 # = 0.45*pi
|
||||
rotation_insert_max: 2.6704 # = 0.85*pi
|
||||
|
||||
# [rad] bước yaw giữa hai pose xoay tại chỗ được chèn.
|
||||
rotation_step: 0.1571 # = 0.05*pi
|
||||
|
||||
# [rad] |yaw goal - hướng cạnh cuối| vượt ngưỡng này thì đoạn cuối đi lùi.
|
||||
backward_decision_angle: 1.5708 # = 0.5*pi
|
||||
88
config/runtime/dock_global_params.yaml
Normal file
88
config/runtime/dock_global_params.yaml
Normal file
@@ -0,0 +1,88 @@
|
||||
# DockPlanner — global planner sinh đường vào dock.
|
||||
#
|
||||
# Hình dạng đường: một đoạn cua rời xa dock (lead-in), một điểm đổi chiều (cusp),
|
||||
# rồi một đoạn THẲNG cuối trùng hướng yaw của goal. Đoạn cuối luôn thẳng để robot
|
||||
# đã đạt đúng hướng trước khi chui vào dock — đi cong vào gầm trolley rất dễ va.
|
||||
#
|
||||
# Mép nào của robot áp vào dock được SUY RA theo từng lần lập plan, dựa vào phía
|
||||
# robot đang đứng so với goal. Không khai báo bằng tham số:
|
||||
# robot ở phía +X của goal -> lead-in đi TIẾN, đoạn cuối đi LÙI
|
||||
# (mép sau áp dock: càng nâng chui vào pallet)
|
||||
# robot ở phía -X của goal -> lead-in đi LÙI, đoạn cuối đi TIẾN
|
||||
# (mép trước áp dock: chấu sạc ở đầu xe)
|
||||
# Suy được như vậy vì goal đã được offset sẵn từ tầng trên, sao cho base_link
|
||||
# dừng đúng tại goal khi manơ hoàn tất.
|
||||
#
|
||||
# Kiểm tra va chạm / vùng trống CỐ Ý chưa cấu hình ở đây: DockPlanner hiện chỉ
|
||||
# sinh hình học. Đừng thêm cost_threshold, allow_unknown hay check_free_space
|
||||
# cho tới khi phần kiểm va chạm được hiện thực.
|
||||
DockPlanner:
|
||||
# Thư viện Boost.DLL chứa symbol export tên "DockPlanner".
|
||||
library_path: libdock_planner
|
||||
|
||||
kinematics:
|
||||
# Hai frame trục bánh, dùng để ĐO wheel_base từ TF. Phải trùng với cặp frame
|
||||
# StanleyControl đang dùng, nếu lệch thì bán kính cua tính ra sai.
|
||||
front_axle_frame: "steer_link"
|
||||
rear_axle_frame: "base_link"
|
||||
|
||||
# [rad] Góc lái lớn nhất của mô hình xe đạp tương đương khi chạy đoạn cua.
|
||||
# PHẢI đo trên robot thật. Đây KHÔNG phải tick servo, KHÔNG phải góc vô lăng,
|
||||
# cũng KHÔNG phải góc pivot tại chỗ.
|
||||
# Quyết định bán kính cua nhỏ nhất: R_min = wheel_base / tan(góc này).
|
||||
# Khai lớn hơn thực tế -> planner sinh cung robot bám không nổi, robot lệch
|
||||
# path. Khai nhỏ hơn thực tế -> đường vòng rộng, tốn không gian.
|
||||
max_steering_angle: 0.7
|
||||
|
||||
maneuver:
|
||||
# [m] Cusp được đặt cách điểm xuất phát ít nhất khoảng này, đo theo hướng RỜI
|
||||
# XA dock. Bảo đảm luôn có một đoạn lead-in thật trước khi đổi chiều, thay vì
|
||||
# cusp trùng ngay vị trí robot.
|
||||
minimum_forward_distance: 0.25
|
||||
|
||||
# [m] Từ chối lập plan nếu cusp phải nằm xa hơn khoảng này so với điểm xuất
|
||||
# phát để thoả ràng buộc bán kính cua và khoảng hở với dock.
|
||||
# Tăng lên nếu robot đứng lệch nhiều mà vẫn muốn ra được plan; giảm xuống nếu
|
||||
# muốn chặn sớm những manơ chiếm quá nhiều không gian.
|
||||
maximum_forward_extension: 3.0
|
||||
|
||||
# [m] Bật kiểu vào dock KHÔNG CÓ CUSP (một cung hội tụ vào trục goal rồi đi
|
||||
# thẳng vào, giữ nguyên một chiều chạy) khi khoảng chỗ còn lại cho cung —
|
||||
# tức khoảng cách dọc trục từ robot tới goal trừ đi độ dài đoạn thẳng cuối —
|
||||
# vượt ngưỡng này.
|
||||
# Bán kính cung VẪN được kiểm với giới hạn Ackermann. Trượt bất kỳ phép kiểm
|
||||
# nào thì quay về đường có cusp, nên tham số này chỉ có thể BỚT một lần đổi
|
||||
# chiều, không bao giờ thêm.
|
||||
# Đặt 0 = tắt hẳn, luôn lập đường có cusp.
|
||||
#
|
||||
# ĐANG BẬT trên robot thật. Kiểu không-cusp mới chỉ được quan sát trong mô
|
||||
# phỏng, nên lần chạy đầu phải đứng cạnh robot xem hình dạng đường trước khi
|
||||
# cho chạy tự động. Tắt lại bằng cách đặt về 0.
|
||||
direct_entry_min_curve_room: 0.4
|
||||
|
||||
terminal:
|
||||
# [m] Khoảng hở CỘNG THÊM cho đoạn thẳng cuối, ngoài phần thân robot nhô ra ở
|
||||
# mép áp dock (rear_extent khi đoạn cuối đi lùi, front_extent khi đi tiến) và,
|
||||
# nếu dock_anchor=center, ngoài nửa thân dock phía tiếp cận.
|
||||
# Tăng lên nếu thấy robot dừng quá sát dock.
|
||||
reverse_distance_padding: 0.0
|
||||
|
||||
# [m] Độ dài đoạn thẳng cuối MONG MUỐN. Giá trị thực tế là
|
||||
# max(giá trị này, phần nhô mép áp dock + nửa thân dock + padding), nên đặt 0
|
||||
# là chỉ dùng khoảng hở tối thiểu.
|
||||
# Tăng lên thì robot có quãng thẳng dài hơn để chỉnh hết sai số hướng trước
|
||||
# khi vào dock, ĐỔI LẠI ăn vào chỗ dành cho cung, nên đặt lớn quá sẽ đẩy plan
|
||||
# quay về kiểu có cusp.
|
||||
straight_length: 0.0
|
||||
|
||||
sampling:
|
||||
# [m] Khoảng cách lớn nhất giữa hai điểm liên tiếp trên đường, áp dụng cho cả
|
||||
# đoạn cung lẫn đoạn thẳng. Nhỏ hơn = đường mượt hơn nhưng nhiều điểm hơn.
|
||||
path_point_spacing: 0.05
|
||||
|
||||
# footprint_dock và dock_anchor KHÔNG khai ở đây. move_base2 chọn theo từng
|
||||
# marker rồi rót vào namespace này trước khi khởi tạo plugin.
|
||||
#
|
||||
# dock_anchor: 'center' (mặc định) — goal nằm ở tâm dock; nửa thân dock phía
|
||||
# tiếp cận (lấy từ footprint_dock) được cộng vào khoảng hở cusp.
|
||||
# 'face' — goal đã nằm sẵn trên mặt tiếp cận; footprint_dock bị bỏ qua.
|
||||
69
config/runtime/hybrid_local_planner_params.yaml
Normal file
69
config/runtime/hybrid_local_planner_params.yaml
Normal file
@@ -0,0 +1,69 @@
|
||||
# HybridLocalPlanner — local planner lai Pure Pursuit + DWA.
|
||||
# Bám path bằng Pure Pursuit khi đường trống, chuyển sang DWA khi gặp vật cản,
|
||||
# rồi nhập lại (rejoin) về path cũ.
|
||||
HybridLocalPlanner:
|
||||
# base_local_planner: "hybrid_local_planner/HybridLocalPlanner"
|
||||
# HybridLocalPlanner:
|
||||
library_path: libhybrid_local_planner
|
||||
|
||||
# ===== Giới hạn động học robot =====
|
||||
max_forward_velocity: 1.0 # [m/s] trần vận tốc tiến
|
||||
max_reverse_velocity: 0.25 # [m/s] trần vận tốc lùi, ghi bằng ĐỘ LỚN DƯƠNG
|
||||
avoidance_max_velocity: 0.4 # [m/s] trần vận tốc khi đang né vật cản, thấp hơn để an toàn
|
||||
max_angular_velocity: 0.6 # [rad/s] trần tốc độ quay
|
||||
min_in_place_angular_velocity: 0.3 # [rad/s] tốc độ quay tối thiểu khi quay tại chỗ,
|
||||
# đặt quá thấp thì servo không thắng nổi ma sát tĩnh
|
||||
acc_lim_x: 0.1 # [m/s^2] trần gia tốc khi tăng tốc
|
||||
decel_lim_x: 0.5 # [m/s^2] trần gia tốc khi giảm tốc (độ lớn dương)
|
||||
acc_lim_theta: 2.0 # [rad/s^2] trần gia tốc góc
|
||||
min_turn_radius: 0.0 # [m] bán kính cua nhỏ nhất. 0 = không ràng buộc (vi sai)
|
||||
robot_radius: 0.1 # [m] bán kính robot, chỉ dùng khi use_footprint = false
|
||||
footprint_padding: 0.08 # [m] nới footprint thêm để có biên an toàn
|
||||
use_footprint: true # true = kiểm va chạm theo footprint đa giác,
|
||||
# false = coi robot là hình tròn robot_radius
|
||||
|
||||
# ===== Dung sai tới đích =====
|
||||
xy_goal_tolerance: 0.02 # [m] sai số vị trí chấp nhận là đã tới goal
|
||||
yaw_goal_tolerance: 0.02 # [rad] sai số góc chấp nhận là đã tới goal
|
||||
|
||||
# ===== Quỹ đạo và cách đọc path toàn cục =====
|
||||
max_global_plan_lookahead_dist: 3.0 # [m] chỉ lấy phần path trong tầm này để bám
|
||||
global_plan_viapoint_sep: 0.5 # [m] khoảng cách giữa các điểm trung gian trích ra từ path
|
||||
global_plan_goal_sep: 0.05 # [m] khoảng cách lấy mẫu dày hơn ở đoạn gần goal
|
||||
predict_time: 3.0 # [s] DWA mô phỏng quỹ đạo trước bao lâu
|
||||
sim_period: 0.1 # [s] bước thời gian khi mô phỏng
|
||||
sim_time_samples: 10 # số bước mô phỏng trên mỗi quỹ đạo ứng viên
|
||||
|
||||
# ===== Trọng số hàm chi phí DWA =====
|
||||
# Tăng một trọng số tức là giảm tương đối tất cả những cái còn lại.
|
||||
w_omega: 2.5 # phạt quay nhiều, giữ robot đi thẳng khi có thể
|
||||
obs_cost_gain: 1.3 # phạt tiến gần vật cản
|
||||
path_cost_gain: 0.5 # phạt lệch khỏi path toàn cục
|
||||
to_goal_cost_gain: 0.8 # thưởng cho quỹ đạo tiến gần goal
|
||||
speed_cost_gain: 0.5 # thưởng cho quỹ đạo chạy nhanh
|
||||
|
||||
# ===== Vật cản =====
|
||||
obs_range: 2.5 # [m] bán kính quét vật cản quanh robot
|
||||
|
||||
# ===== Thiết lập chung =====
|
||||
segment_transition_threshold: 0.03 # [m] ngưỡng coi là đã tới hết một chặng path;
|
||||
# cũng là khoảng cách DWA dừng ở chặng trung gian
|
||||
rotation_segment_yaw_threshold: 0.05 # [rad] bỏ qua nhiễu yaw nhỏ hơn ngưỡng này khi hai
|
||||
# điểm path trùng vị trí, tránh quay vặt vô nghĩa
|
||||
direction_change_hysteresis: 0.15 # tích vô hướng chuẩn hoá. Trễ để robot không lật
|
||||
# tiến/lùi liên tục quanh điểm đổi chiều
|
||||
use_obstacle_avoidance: true # false = tắt nhánh DWA, chỉ chạy Pure Pursuit
|
||||
slow_velocity_th: 0.1 # [m/s] dưới ngưỡng này coi như robot đang bò chậm
|
||||
turn_direction_th: 0.1 # [rad] ngưỡng xác định robot đang rẽ hướng nào
|
||||
|
||||
# ----- Giai đoạn nhập lại path sau khi né vật cản -----
|
||||
avoidance_clear_hold_time: 0.5 # [s] phải thấy đường thông liên tục bấy lâu mới thôi né,
|
||||
# tránh nhấp nháy né/không né
|
||||
rejoin_blend_time: 0.8 # [s] thời gian pha trộn mượt khi chuyển về bám path
|
||||
rejoin_max_velocity: 0.25 # [m/s] trần vận tốc trong lúc nhập lại
|
||||
rejoin_heading_tolerance: 0.35 # [rad] lệch hướng nhỏ hơn ngưỡng này mới cho nhập lại
|
||||
rejoin_path_tolerance: 0.20 # [m] lệch ngang nhỏ hơn ngưỡng này mới cho nhập lại
|
||||
pp_max_omega_correction: 0.15 # [rad/s] trần lượng hiệu chỉnh quay của Pure Pursuit
|
||||
rejoin_acc_lim_theta: 1.0 # [rad/s^2] trần gia tốc góc riêng cho giai đoạn nhập lại
|
||||
rejoin_lookahead_distance: 0.8 # [m] cự ly nhìn trước khi nhập lại. Lớn = vào mượt nhưng
|
||||
# cắt cua; nhỏ = bám sát nhưng dễ lắc
|
||||
83
config/runtime/maker_sources.yaml
Normal file
83
config/runtime/maker_sources.yaml
Normal file
@@ -0,0 +1,83 @@
|
||||
# =================================================================================================
|
||||
# move_base2 — danh sách marker docking hợp lệ và cặp planner riêng của từng marker.
|
||||
#
|
||||
# Quy ước comment: dòng mô tả = LÀ GÌ / vì sao; `► Chỉnh:` = sửa thế nào cho đúng.
|
||||
#
|
||||
# Danh sách cho phép, dùng cho `BaseNavigation::dockTo(marker, ...)`.
|
||||
#
|
||||
# move_base2 docking quy `goal_frame` thành pose TUYỆT ĐỐI rồi chạy DockPlanner + local planner
|
||||
# docking. Nó KHÔNG đọc bộ tham số per-marker của PNKXDockingLocalPlanner cũ (plugins,
|
||||
# maker_goal_frame, delay, timeout, velocity, tolerance, lookahead) — những khoá đó nếu còn sót lại
|
||||
# ở đâu đó cũng không có tác dụng.
|
||||
# =================================================================================================
|
||||
|
||||
# Marker mà host được phép gửi xuống. Đây là ALLOW-LIST: tên không có trong dòng này bị từ chối
|
||||
# ngay tại `dockTo`, không đi tới planner.
|
||||
#
|
||||
# ► Chỉnh: chỉ thêm/bớt TÊN, cách nhau bằng khoảng trắng. Giữ danh sách tối thiểu — mỗi tên thừa là
|
||||
# một đường vào chưa được kiểm chứng. Sẽ bỏ hẳn khi `dockTo` được chuyển sang dock_sequences khai
|
||||
# báo trong compound_actions_params.yaml.
|
||||
maker_sources: trolley charger dock_station pallet
|
||||
|
||||
# Marker có entry ở đây dùng CẶP PLANNER RIÊNG. Marker rỗng, hoặc chỉ có trong `maker_sources` mà
|
||||
# không nằm trong bảng này, sẽ dùng cặp `docking` mặc định của move_base_common_params.yaml.
|
||||
#
|
||||
# ► Chỉnh: chỉ khai marker nào THỰC SỰ cần planner khác mặc định. Tham số của planner nằm ở YAML
|
||||
# riêng của plugin (dock_global_params.yaml, stanley_local_planner_params.yaml), KHÔNG khai ở đây —
|
||||
# trừ `dock_anchor` và `footprint_dock` dưới đây.
|
||||
#
|
||||
# ── dock_anchor ───────────────────────────────────────────────────────────────────────────────────
|
||||
#
|
||||
# Goal pose của marker nằm ở đâu trên đối tượng dock:
|
||||
# center — goal ở tâm footprint dock; DockPlanner cộng thêm extent từ tâm tới mặt tiếp cận
|
||||
# (lấy từ footprint_dock). Mặc định khi không khai — giữ nguyên hành vi cũ.
|
||||
# face — goal đã nằm ngay tâm MẶT tiếp cận; dock không đóng góp vào khoảng dừng,
|
||||
# footprint_dock bị bỏ qua hoàn toàn (DockPlanner log info nếu vẫn khai).
|
||||
#
|
||||
# ── footprint_dock ────────────────────────────────────────────────────────────────────────────────
|
||||
#
|
||||
# Đa giác của ĐỐI TƯỢNG DOCK (kệ / trạm sạc), [m], trong frame của goal pose. KHÔNG phải footprint
|
||||
# robot: footprint robot khai ở costmap và dùng cho collision check, còn khoá này vào khoảng dừng
|
||||
# của DockCalc — điểm robot bắt đầu đoạn căn thẳng trước dock:
|
||||
#
|
||||
# alignment_distance = <extent mép robot dẫn đầu> + <extent tâm dock → mặt gần> + padding
|
||||
#
|
||||
# Chỉ dùng khi `dock_anchor: center`. Khai thiếu = dock bị coi là một điểm, robot tiến sát hơn dự
|
||||
# tính đúng extent tới mặt gần.
|
||||
#
|
||||
# ⚠ CHƯA KHAI TRÊN ROBOT NÀY — cố ý. Không khai = giữ đúng hành vi đang chạy ngoài hiện trường;
|
||||
# khai một con số chưa đo là dịch điểm dừng của robot đi đúng nửa chiều dài số đó.
|
||||
# ► Chỉnh: đo kích thước THẬT của từng loại kệ/trạm rồi mở comment. Trục x là hướng robot tiến
|
||||
# vào. Chúng khác nhau theo loại — để trùng số là mất tác dụng của việc khai theo marker.
|
||||
#
|
||||
# Hai khoá trên là các khoá DUY NHẤT trong bảng này được rót xuống plugin:
|
||||
# `PlannerRunner::bindDockingMarker()` chép chúng sang namespace của `global_planner` khai ngay bên
|
||||
# trên, TRƯỚC khi instance được dựng, rồi dựng lại instance khi marker đổi.
|
||||
#
|
||||
# ⚠ Chỉ `DockPlanner` đọc hai khoá này. Marker nào khai global planner khác thì giá trị vẫn được
|
||||
# chép sang namespace đó nhưng không ai đọc — không lỗi, không log, chỉ là không có tác dụng.
|
||||
docking_marker_profiles:
|
||||
trolley:
|
||||
global_planner: DockPlanner
|
||||
local_planner: StanleyDockingLocalPlanner
|
||||
# Goal ở trọng tâm xe trolley (robot chui gầm) → cộng extent tâm→mặt từ footprint_dock.
|
||||
dock_anchor: center
|
||||
# footprint_dock: [[x,-y],[x,y],[-x,y],[-x,-y]] # đo rồi mở
|
||||
|
||||
charger:
|
||||
global_planner: DockPlanner
|
||||
local_planner: StanleyDockingLocalPlanner
|
||||
# Goal teach ngay tâm mặt trạm sạc → dock không đóng góp khoảng dừng.
|
||||
dock_anchor: face
|
||||
|
||||
dock_station:
|
||||
global_planner: DockPlanner
|
||||
local_planner: StanleyDockingLocalPlanner
|
||||
dock_anchor: center
|
||||
# footprint_dock: [[x,-y],[x,y],[-x,y],[-x,-y]] # đo rồi mở
|
||||
|
||||
pallet:
|
||||
global_planner: DockPlanner
|
||||
local_planner: StanleyDockingLocalPlanner
|
||||
dock_anchor: center
|
||||
footprint_dock: [[0.5,-0.5],[0.5,0.5],[-0.5,0.5],[-0.5,-0.5]]
|
||||
101
config/runtime/mission_adapters_params.yaml
Normal file
101
config/runtime/mission_adapters_params.yaml
Normal file
@@ -0,0 +1,101 @@
|
||||
# =================================================================================================
|
||||
# mission_adapters — tham số RUNTIME của mission layer.
|
||||
#
|
||||
# Quy ước comment: dòng mô tả = LÀ GÌ / vì sao; `► Chỉnh:` = tăng giảm theo triệu chứng nào.
|
||||
#
|
||||
# Mission layer đứng GIỮA nguồn nhiệm vụ (VDA5050 Order, goal trần) và navigation: nó cắt order
|
||||
# thành từng CHẶNG tại mỗi node có action, chỉ chạy phần `released`, nối tiếp theo `orderUpdateId`
|
||||
# thay vì chạy lại từ đầu, và giữ hàng đợi chặng.
|
||||
#
|
||||
# Đây là bản đang có hiệu lực. Bản trong `Test/mission_adapters/test/config/` chỉ phục vụ test và
|
||||
# chỉ được đọc khi chạy kèm PNKX_NAV_CORE_CONFIG_DIR trỏ vào đúng thư mục đó.
|
||||
#
|
||||
# Bật/tắt cả tầng này bằng `mission_layer_enabled` trong `move_base_common_params.yaml`.
|
||||
# =================================================================================================
|
||||
|
||||
mission_adapters:
|
||||
# Nguồn mission. Thêm một loại nguồn mới = thêm một entry ở đây + một plugin .so, không phải sửa
|
||||
# code của gói.
|
||||
# name: tên instance, cũng là namespace param riêng của nó
|
||||
# type: tên symbol export bằng BOOST_DLL_ALIAS, phải có khoá library_path tương ứng bên dưới
|
||||
#
|
||||
# goal_src : goal trần từ host (không có edge) — dùng khi test bằng RViz/sim.
|
||||
# vda5050_src : Order VDA5050 đầy đủ (node + edge + action), đường chạy production.
|
||||
# instant_src : một action lẻ ngoài order (VDA5050 `instantActions`).
|
||||
#
|
||||
# ► Chỉnh: bỏ bớt một nguồn = tắt đường vào tương ứng. Bỏ HẾT thì runtime tự quay về đường trực
|
||||
# tiếp (như `mission_layer_enabled: false`) kèm log cảnh báo — thiếu plugin không được phép biến
|
||||
# thành robot đứng im không rõ lý do.
|
||||
#
|
||||
# ⚠ Bỏ `instant_src` KHÔNG quay về hành vi cũ: `MissionLayer::submitInstantActions` kiểm
|
||||
# `handles(kInstantAction)`, không nguồn nào khai schema đó thì mọi instantAction (trừ
|
||||
# cancelOrder/startPause/stopPause) bị từ chối ngay tại cửa với `actionNotSupported`.
|
||||
# Đường host tự chạy IO cho `PICKUP`/`LOAD`/... đã bị gỡ, không còn chỗ nào nhận thay.
|
||||
mission_sources:
|
||||
- {name: goal_src, type: GoalSourceAdapter}
|
||||
- {name: vda5050_src, type: VDA5050SourceAdapter}
|
||||
- {name: instant_src, type: InstantActionSourceAdapter}
|
||||
|
||||
# [s] Trần thời gian cho MỘT chặng (navigation + action), tính từ lúc chặng được giao.
|
||||
# 0 = tắt. Quá hạn thì chặng bị đánh dấu thất bại VÀ navigation được bảo dừng — lưới cuối cho
|
||||
# trường hợp navigation không bao giờ báo kết quả về.
|
||||
#
|
||||
# ► Chỉnh: đây là lưới an toàn CUỐI CÙNG, không phải cơ chế timeout chính (mỗi action handler đã
|
||||
# tự timeout, và navigation có `planner_patience`/`controller_patience`).
|
||||
# - Bật (vd 120–300 s) khi cần chắc chắn fleet luôn nhận được kết quả chặng.
|
||||
# - Đặt phải LỚN HƠN chặng dài nhất cộng toàn bộ thời gian recovery có thể xảy ra, nếu không
|
||||
# robot đang phục hồi bình thường sẽ bị cắt ngang và báo fail oan.
|
||||
mission_timeout: 0.0
|
||||
|
||||
# Một chặng thất bại thì xử lý phần còn lại của hàng đợi thế nào.
|
||||
# true = xoá sạch hàng đợi (mặc định, an toàn cho tuyến đường tuần tự kiểu VDA5050: không tới
|
||||
# được node n thì chạy tiếp chặng n+1 là cắt ngang đoạn chưa được cho phép đi)
|
||||
# false = chỉ bỏ chặng lỗi rồi chạy tiếp.
|
||||
#
|
||||
# ► Chỉnh: chỉ đặt false khi các mission trong hàng đợi ĐỘC LẬP với nhau, không phải các chặng của
|
||||
# cùng một tuyến. Với compound action (charge/PickUp) thì BẮT BUỘC true: nó chính là thứ ngăn
|
||||
# robot chạy bước `startCharging`/`LiftFork` khi bước dò hoặc bước tiến vào đã hỏng.
|
||||
clear_queue_on_failure: true
|
||||
|
||||
# =================================================================================================
|
||||
# Param riêng của từng instance nguồn mission, đặt theo `name` khai ở `mission_sources`.
|
||||
# =================================================================================================
|
||||
vda5050_src:
|
||||
# Frame gán cho goal/start sinh ra từ nodePosition của VDA5050.
|
||||
# Lưu ý: `mapId` trong VDA5050 là danh tính bản đồ, KHÔNG phải frame TF, nên không dùng làm frame.
|
||||
#
|
||||
# ► Chỉnh: phải khớp `global_frame` của costmap global. Sai frame ở đây thì mọi goal lệch vị trí
|
||||
# hoặc TF không quy đổi được, và lỗi hiện ra ở tận tầng planner nên rất khó truy.
|
||||
global_frame: map
|
||||
|
||||
# Bảng compound action (`CHARGE`, `PICKUP`, ...) KHÔNG khai ở đây mà ở
|
||||
# `compound_actions_params.yaml` — file đó cũng dùng khoá `vda5050_src` và được
|
||||
# `robot::NodeHandle` GỘP vào chung một cây.
|
||||
|
||||
# --- instant_src: một action lẻ ngoài order (VDA5050 `instantActions`) ---------------------------
|
||||
instant_src:
|
||||
# Namespace của nguồn khác để DÙNG CHUNG bảng `compound_actions` của nó.
|
||||
#
|
||||
# Đây là lý do adapter này là class con của VDA5050SourceAdapter chứ không phải plugin riêng:
|
||||
# `CHARGE` gửi dạng node action và `CHARGE` gửi dạng instantAction phải nở ra CÙNG một chuỗi
|
||||
# chặng. Khai một bảng thứ hai dưới khoá `instant_src` sẽ chạy được ngay hôm nay rồi trôi lệch
|
||||
# dần — triệu chứng là robot lùi vào trạm bằng toạ độ cũ vì một trong hai bảng thiếu bước dò.
|
||||
#
|
||||
# ► Chỉnh: gần như không bao giờ. Giá trị mặc định (khi không khai khoá này) cũng là
|
||||
# `vda5050_src`; khai rõ ở đây để người đọc thấy quan hệ mà không phải tra code.
|
||||
compound_actions_from: vda5050_src
|
||||
|
||||
# Bảng symbol -> thư viện cho Boost.DLL. KHÔNG phải tham số tinh chỉnh.
|
||||
#
|
||||
# Thiếu khoá library_path là nguyên nhân phổ biến nhất của lỗi "plugin build xong nhưng runtime báo
|
||||
# không tìm thấy". Tên không có đuôi .so được resolve qua PNKX_NAV_CORE_LIBRARY_PATH / devel/lib /
|
||||
# LD_LIBRARY_PATH — tức phải `source devel/setup.bash` trước khi chạy.
|
||||
GoalSourceAdapter:
|
||||
library_path: libmission_adapters_goal_source
|
||||
|
||||
VDA5050SourceAdapter:
|
||||
library_path: libmission_adapters_vda5050_source
|
||||
|
||||
# Cùng file .so với VDA5050SourceAdapter — đây là class con, khác symbol BOOST_DLL_ALIAS.
|
||||
InstantActionSourceAdapter:
|
||||
library_path: libmission_adapters_vda5050_source
|
||||
304
config/runtime/move_base_common_params.yaml
Normal file
304
config/runtime/move_base_common_params.yaml
Normal file
@@ -0,0 +1,304 @@
|
||||
# =================================================================================================
|
||||
# move_base2 — tham số lõi của navigation runtime.
|
||||
#
|
||||
# Quy ước comment trong file này:
|
||||
# • dòng mô tả = tham số đó LÀ GÌ và vì sao tồn tại
|
||||
# • `► Chỉnh:` = tăng/giảm theo triệu chứng nào, miền giá trị, và tương tác với tham số khác
|
||||
#
|
||||
# Đọc file này cùng `recovery_behaviors_params.yaml` (recovery gen-2) và
|
||||
# `mission_adapters_params.yaml` (mission layer) — ba file cùng mô tả một luồng chạy.
|
||||
#
|
||||
# `robot::NodeHandle` GỘP mọi file YAML trong thư mục config thành một cây. Trùng khoá giữa hai file
|
||||
# là lỗi khó thấy nhất ở đây: file khớp trước thắng. Đặt tên khoá cho riêng biệt.
|
||||
# =================================================================================================
|
||||
|
||||
# --- Cặp planner của từng kiểu chuyển động -------------------------------------------------------
|
||||
#
|
||||
# move_base2 nạp trực tiếp `robot_nav_core2::LocalPlanner`; không dùng LocalPlannerAdapter (bridge
|
||||
# chỉ dành cho move_base cũ).
|
||||
#
|
||||
# ► Chỉnh: đây là lựa chọn KIẾN TRÚC, không phải số tinh chỉnh. Đổi tên planner ở đây thì tham số
|
||||
# của planner đó nằm ở YAML riêng của nó (symlink từ pnkx_nav_core/config/), và phải có khoá
|
||||
# `library_path` tương ứng, nếu không runtime báo "không tìm thấy plugin".
|
||||
position:
|
||||
global_planner: CustomPlanner # vật chất hoá tuyến NURBS từ edge của VDA5050 Order.
|
||||
# MÙ VẬT CẢN theo thiết kế — nó là route materializer, không
|
||||
# phải search planner. Chỉ có bản makePlan(Order, ...).
|
||||
local_planner: StanleyLocalPlanner
|
||||
|
||||
docking:
|
||||
# goal_frame đã được ControlLoop quy thành pose tuyệt đối. DockPlanner dùng đúng contract
|
||||
# makePlan(start, goal, plan), còn CustomPlanner chỉ xử lý makePlan(Order, start, goal, plan).
|
||||
# đây là config default sẽ được dùng nếu config theo từng maker docking ở file maker_sources.yaml bị bỏ trống
|
||||
global_planner: DockPlanner
|
||||
local_planner: StanleyDockingLocalPlanner
|
||||
|
||||
go_straight:
|
||||
global_planner: TwoPointsPlanner
|
||||
local_planner: StanleyDockingLocalPlanner
|
||||
|
||||
rotate:
|
||||
global_planner: TwoPointsPlanner
|
||||
local_planner: StanleyDockingLocalPlanner
|
||||
|
||||
# Đường lùi chung cho mọi profile: planner chính trả false hoặc plan rỗng thì move_base2 đổi sang
|
||||
# planner này đúng MỘT lần cho request hiện tại. Backup cũng fail thì mới chạy recovery; request mới
|
||||
# luôn bắt đầu lại từ planner chính. Backup gọi makePlan(start, goal, plan), không mang VDA5050
|
||||
# Order, để SBPLLatticePlanner (chỉ có overload ba tham số) dùng được.
|
||||
#
|
||||
# ► Chỉnh: để rỗng = tắt đường lùi (mọi lỗi planner đi thẳng vào recovery). Giữ SBPL trừ khi có
|
||||
# planner khác vừa chấp nhận contract 3 tham số vừa tránh được vật cản.
|
||||
# ► Lưu ý vận hành: khi order KHÔNG có edge (goal trần), CustomPlanner fail và runtime luôn rơi về
|
||||
# backup này. Tức trên sim goal-trần, plan thực tế do SBPL sinh chứ không phải NURBS — mật độ pose
|
||||
# và hình học khác production. Đừng tinh chỉnh tham số tuyến chỉ dựa trên sim goal-trần.
|
||||
backup_global_planner: TwoPointsPlanner
|
||||
|
||||
# Compound docking quy `goal_frame` thành pose tuyệt đối; HybridLocalPlanner không đọc maker_name.
|
||||
# `true` chỉ dành cho PNKXDockingLocalPlanner legacy, vốn phải chọn marker trước initialize().
|
||||
#
|
||||
# ► Chỉnh: giữ false cho move_base2. Đặt true chỉ khi quay lại dùng local planner docking legacy.
|
||||
docking_requires_marker: false
|
||||
|
||||
# Bảng `library_path` và tham số riêng của CustomPlanner, DockPlanner, TwoPointsPlanner cùng các
|
||||
# local planner nằm trong các YAML runtime đồng hành (symlink từ pnkx_nav_core/config/). Không lặp
|
||||
# lại chúng ở đây để tránh hai nguồn cấu hình cho cùng một plugin.
|
||||
|
||||
# =================================================================================================
|
||||
# Nhịp điều khiển và các đồng hồ kiên nhẫn (contract 2026-08-04 — tách replan nền khỏi recovery)
|
||||
# =================================================================================================
|
||||
|
||||
# [Hz] Nhịp control loop: đọc pose, chạy state machine, gọi controller, phát cmd_vel.
|
||||
# ► Chỉnh: phải >= nhịp mà local planner giải xong một lần. Priest/Hybrid solve ~30 ms nên 30 Hz là
|
||||
# sát trần — nếu log hiện nhiều dòng "solve took ... (limit ...)" thì HẠ xuống 20 Hz thay vì ép
|
||||
# planner chạy nhanh hơn. Tăng lên >30 chỉ có nghĩa khi controller thật sự rẻ hơn 1/f giây.
|
||||
controller_frequency: 30.0
|
||||
|
||||
# [s] Controller không ra lệnh (kể cả mất pose) thì robot DỪNG TẠI CHỖ và vẫn ở CONTROLLING;
|
||||
# quá controller_patience mới vào RECOVERING(controlling_failed). Không còn nhánh "hỏng một cycle
|
||||
# là nhảy về PLANNING" — replan trong lúc chạy là việc của planner_frequency bên dưới.
|
||||
#
|
||||
# ► Chỉnh: giá trị hiện tại = ĐÚNG MỘT chu kỳ 30 Hz, tức "mất lệnh một nhịp là leo thang ngay".
|
||||
# - TĂNG (vd 0.5–1.0 s) nếu robot vào recovery quá nhạy ở khúc cua gắt hoặc lúc local planner
|
||||
# thỉnh thoảng trượt một nhịp — đây là chỉnh thường gặp nhất.
|
||||
# - GIẢM chỉ khi muốn phản ứng cực nhanh và chắc chắn controller không bao giờ trượt nhịp.
|
||||
# - <= 0 = tắt hẳn, KHÔNG khuyến nghị: controller chết vĩnh viễn sẽ không ai phát hiện.
|
||||
controller_patience: 0.033333333
|
||||
|
||||
# [s] Trần cho chuỗi cycle costmap STALE liên tục ở CONTROLLING (2026-08-05). Costmap quá hạn thì
|
||||
# controller bị SKIP — data outage, không phải controller bất lực, nên controller_patience bị ĐÓNG
|
||||
# BĂNG trong lúc đó (33 ms đo outage là đo sai thứ: sim ABORT sau một cycle stale trong khi costmap
|
||||
# chỉ cần ~0.5 s để hồi). Stale liên tục quá trần này mới controlling_failed. 0 = tắt (hành vi cũ).
|
||||
#
|
||||
# ► Chỉnh: đặt >= vài lần chu kỳ cập nhật costmap chậm nhất. Costmap local 6 Hz + buffer sensor
|
||||
# 0.5 s ⇒ 2.0 s là ~4 lần dư địa.
|
||||
# - TĂNG nếu log hiện `controlling_failed` kèm "Sensor data is stale" mà sensor vẫn sống (mạng
|
||||
# lag, CPU nghẽn).
|
||||
# - GIẢM nếu muốn phát hiện mất sensor thật nhanh hơn — nhưng dưới 1.0 s sẽ bắt oan các nhịp
|
||||
# miss lẻ tẻ.
|
||||
sensor_patience: 2.0
|
||||
|
||||
# [Hz] Replan NỀN khi đang CONTROLLING: lập plan bất đồng bộ trên thread planner, plan mới về thì
|
||||
# thay ngay mà không đổi state, không dừng robot. Replan nền thất bại thì giữ plan cũ, không kích
|
||||
# backup planner, không vào recovery. 0 = tắt (chỉ lập plan khi state machine yêu cầu).
|
||||
#
|
||||
# ► Chỉnh: GIỮ 0 trong kiến trúc hiện tại. Ba lý do độc lập (xem TRAP_DETECTION_PLAN.md):
|
||||
# 1. `CustomPlanner` là route materializer, lập lại cho ra ĐÚNG tuyến cũ — lưới nào cũng vậy;
|
||||
# 2. tuyến cũ đang bị chắn nên luật plan-filter loại nó ⇒ kFailed lặp mỗi chu kỳ, tốn CPU vô ích;
|
||||
# 3. SBPL full-mission đo được 0.09–0.29 s/lượt ⇒ 1 Hz ăn 9–29% một core liên tục.
|
||||
# Chỉ bật (0.5–1.0) nếu sau này global planner vừa tránh được vật cản vừa đủ nhanh (~30 ms).
|
||||
planner_frequency: 0.0
|
||||
|
||||
# [s] Ở PLANNING quá lâu mà chưa có plan -> recovery. Mất pose ngay trong PLANNING dùng ngân sách
|
||||
# `controlling_failed` (xem recovery_behaviors_params.yaml).
|
||||
# ► Chỉnh: đặt > thời gian lập plan xấu nhất của global planner. SBPL `allocated_time: 10.0` ở
|
||||
# sbpl_global_params.yaml ⇒ 2.0 s là NGẮN HƠN trần của chính planner: nếu thấy leo thang trong khi
|
||||
# planner vẫn đang chạy, tăng giá trị này lên trên trần đó.
|
||||
planner_patience: 2.0
|
||||
|
||||
# Số lần lập plan HỎNG liên tiếp được phép trước khi leo thang. 0 = hỏng một lượt là leo thang ngay.
|
||||
# ► Chỉnh: TĂNG (1–3) nếu planner thỉnh thoảng fail do costmap chưa kịp cập nhật lúc vừa nhận goal.
|
||||
# < 0 = không giới hạn — chỉ an toàn khi `planner_patience > 0`, nếu không planner treo sẽ không
|
||||
# ai phát hiện (config validate chặn ca tắt cả hai).
|
||||
max_planning_retries: 0
|
||||
|
||||
# [s] Ở trong bán kính `oscillation_distance` quá lâu = coi là quẩn -> recovery `oscillation`.
|
||||
# ► Chỉnh: <= 0 là TẮT (giá trị hiện tại). Bật (vd 10–20 s) khi thấy robot lắc qua lắc lại tại chỗ
|
||||
# mà không trigger nào khác bắt được. Bật thì `oscillation_distance` bắt buộc phải > 0.
|
||||
oscillation_timeout: -1
|
||||
|
||||
# [m] Đi được quá quãng này thì: hết bị coi là quẩn, VÀ mọi cursor route recovery được reset, VÀ
|
||||
# trigger giám sát tuyến đang bị khoá được mở lại (contract 2026-08-05e).
|
||||
# ► Chỉnh: đây là định nghĩa "có tiến độ thật". GIẢM (0.2–0.3) nếu robot ở khu chật ít khi đi nổi
|
||||
# 0.5 m nên ngân sách recovery không bao giờ nạp lại. TĂNG nếu recovery được nạp lại quá dễ dãi
|
||||
# và robot cứ thử vô hạn thay vì báo lỗi lên fleet.
|
||||
oscillation_distance: 0.5
|
||||
|
||||
# =================================================================================================
|
||||
# Giới hạn vận tốc — hàng rào CUỐI trước khi Twist rời runtime (VelocityArbiter)
|
||||
#
|
||||
# Đây KHÔNG phải bộ điều khiển. Local planner đã có trần riêng trong YAML của nó; arbiter chỉ chặn
|
||||
# lệnh vô lý từ BẤT KỲ nguồn nào, kể cả recovery behavior nạp từ plugin ngoài. Hệ quả bắt buộc:
|
||||
# mọi trần ở đây phải NỚI HƠN trần tương ứng của planner một khoảng margin. Đặt sát hoặc chặt hơn
|
||||
# sẽ tái sinh đúng hai lỗi đã đo: acc_lim_x chặt hơn `goal_decel_limit` làm mềm cú phanh (trượt
|
||||
# đích), acc_lim_theta chặt hơn `max_steer_rate` tạo slew kép trên lệnh lái.
|
||||
#
|
||||
# Không khai các khoá này thì code rơi về default hard-code trong velocity_arbiter.h
|
||||
# (twist / 0.5 / -0.2 / 1.0 / 1.0 / 2.0) — trần 1.0 đã từng cắt cụt lệnh pivot 1.5708 rad.
|
||||
# =================================================================================================
|
||||
|
||||
# Twist đi qua arbiter mang NGHĨA gì. Quyết định ĐƠN VỊ của cả cụm trần bên dưới.
|
||||
# twist : chuẩn ROS — linear.x = vận tốc base [m/s], angular.z = tốc độ quay [rad/s].
|
||||
# steering : robot lái một bánh (bicycle) — linear.x = vận tốc BÁNH STEER [m/s],
|
||||
# angular.z = GÓC lái [rad]. Bật thì arbiter kiểm theo đơn vị góc và HÉT LÊN
|
||||
# (log_error + đếm `steeringAngleClamps`) mỗi khi lệnh đánh lái bị cắt, đồng thời
|
||||
# validate() chặn boot nếu `max_vel_theta > pi` (dấu hiệu chọn nhầm semantics).
|
||||
#
|
||||
# ► Chỉnh: đang để `twist` vì recovery behavior xoay tại chỗ phát angular.z theo rad/s — đổi sang
|
||||
# `steering` là đổi nghĩa cho CẢ recovery, nên chỉ đổi khi robot thật sự là bicycle VÀ route
|
||||
# recovery đã bỏ/thay hành vi xoay tại chỗ (bicycle không xoay tại chỗ được).
|
||||
# Riêng việc chạy được bicycle thì `max_vel_theta` bên dưới đã đủ: 1.5708 không còn bị cắt.
|
||||
command_semantics: steering
|
||||
|
||||
# [m/s] Trần tốc độ tiến (semantics `steering`: tốc độ bánh steer). Phải > max_vel_x của local
|
||||
# planner đang chạy — stanley 0.50, pnkx 1.2.
|
||||
# ► Chỉnh: nới thêm ~20% so với planner nhanh nhất được phép chạy. Hạ xuống dưới trần planner là
|
||||
# cắt cụt lệnh mỗi cycle mà planner không hề biết.
|
||||
max_vel_x: 1.20
|
||||
|
||||
# [m/s] Trần tốc độ lùi, ÂM. 0 = cấm lùi hẳn. Stanley min_vel_x = -0.25.
|
||||
# ► Chỉnh: giữ âm hơn trần lùi của planner. Đặt 0 khi robot không có cảm biến phía sau.
|
||||
min_vel_x: -0.25
|
||||
|
||||
# semantics `twist` : [rad/s] trần tốc độ quay.
|
||||
# semantics `steering`: [rad] giới hạn CƠ KHÍ của góc lái.
|
||||
# 1.5708 rad = 90 deg = đúng `steer_limit_standstill` / `align_steer_angle` của stanley. Đây là
|
||||
# con số quan trọng nhất của khối này: default cũ 1.0 kẹp lệnh pivot 1.5708 còn 57.3 deg, robot
|
||||
# không bao giờ đạt góc align và kẹt vĩnh viễn ở pha xoay.
|
||||
# ► Chỉnh: phải >= `align_steer_angle` của local planner. Ghi số thật, KHÔNG viết `M_PI / 2.0` —
|
||||
# parser không evaluate biểu thức.
|
||||
max_vel_theta: 1.5708
|
||||
|
||||
# [m/s^2] Trần biến thiên tốc độ dài, áp cho cả tăng lẫn giảm.
|
||||
# ► Chỉnh: phải > `goal_decel_limit` của planner (stanley 0.40), nếu không arbiter làm mềm cú
|
||||
# phanh về đích và robot trượt quá goal.
|
||||
acc_lim_x: 1.0
|
||||
|
||||
# semantics `twist` : [rad/s^2] trần biến thiên tốc độ quay.
|
||||
# semantics `steering`: [rad/s] trần TỐC ĐỘ đánh lái.
|
||||
# ► Chỉnh: phải >= tốc độ servo thật VÀ >= `max_steer_rate` của planner (stanley 1.00, servo đo
|
||||
# được đỉnh 1.08–1.35). 1.20 là mức nới tối thiểu; chặt hơn sẽ tạo slew kép chồng lên slew của
|
||||
# chính planner, lệnh lái trễ pha và bám line xấu đi.
|
||||
acc_lim_theta: 1.20
|
||||
|
||||
# =================================================================================================
|
||||
# Giám sát tuyến (contract 2026-08-04d)
|
||||
#
|
||||
# Hai phép đo chạy trong lúc robot bám plan, cùng một kết cục: robot DỪNG rồi chạy recovery của
|
||||
# trigger tương ứng (`path_blocked` / `off_path` trong recovery_behaviors_params.yaml).
|
||||
# - tuyến phía trước bị chắn -> khai hoả `path_blocked`
|
||||
# - robot đã lệch khỏi plan -> khai hoả `off_path`
|
||||
#
|
||||
# MỖI phép đo có BA nút độc lập và phải đủ CẢ BA mới sống:
|
||||
# (1) cờ riêng ở đây, (2) ngưỡng của nó > 0, (3) route tương ứng bên recovery khác rỗng.
|
||||
# =================================================================================================
|
||||
path_monitor:
|
||||
# Công tắc CHUNG; tắt cái này là tắt cả hai phép đo bên dưới.
|
||||
# ► Chỉnh: false = đưa hành vi về đúng như trước 2026-08-04d (chỉ còn controller_patience lo).
|
||||
# Dùng làm đường lùi nhanh khi nghi cơ chế giám sát gây vấn đề ngoài hiện trường.
|
||||
enabled: false
|
||||
|
||||
# Công tắc RIÊNG từng phép đo (2026-08-06). Trước đây chỉ tắt được bằng cách đặt ngưỡng về 0 —
|
||||
# giá trị ma, lẫn với "quên khai".
|
||||
# ► Chỉnh: hạ cờ để tắt mà VẪN GIỮ ngưỡng đã đo được — bật lại chỉ sửa một dòng.
|
||||
path_blocked_enabled: false
|
||||
off_path_enabled: false # tắt tường minh: max_cross_track chưa đo được nên chưa có ngưỡng thật
|
||||
|
||||
# [s] Nhịp quét costmap. KHÔNG quét mỗi control cycle (30 Hz) — quá phí.
|
||||
# ► Chỉnh: đặt ~= chu kỳ cập nhật costmap local (6 Hz ⇒ 0.17 s). Nhỏ hơn thế là quét lại cùng một
|
||||
# dữ liệu. TĂNG nếu CPU căng; đổi lại phản ứng chậm đi đúng chừng đó.
|
||||
check_period: 0.2
|
||||
|
||||
# [s] Điều kiện phải đúng LIÊN TỤC chừng này mới khai hoả (chống nhiễu một nhịp).
|
||||
# ► Chỉnh: TĂNG (0.8–1.5) nếu người đi ngang qua làm robot dừng oan. GIẢM nếu robot phản ứng quá
|
||||
# chậm với vật cản thật. Phải >= vài lần `check_period`, nếu không debounce vô nghĩa.
|
||||
confirm_time: 0.5
|
||||
|
||||
# Profile được giám sát. docking/go_straight/rotate KHÔNG được detour: đường cong vào dock là một
|
||||
# thể thống nhất, cắt ghép nó là phá chính hình học đó.
|
||||
# ► Chỉnh: gần như luôn để `[position]`. Thêm profile khác chỉ khi profile đó dùng tuyến tự do.
|
||||
profiles: [position]
|
||||
|
||||
# -- Phép đo 1: tuyến phía trước bị chắn --------------------------------------------------------
|
||||
|
||||
# [m] Quãng tuyến phía trước cần quét.
|
||||
# ► Chỉnh: phải <= nửa cửa sổ costmap local (8x8 m ⇒ ~4 m), ngoài đó không có dữ liệu.
|
||||
# - TĂNG (tới ~3.5) để phát hiện sớm hơn, có nhiều chỗ hơn để lập đường vòng;
|
||||
# - GIẢM (1.5–2.0) nếu robot dừng quá sớm trước vật cản mà local planner tự lách được.
|
||||
horizon: 3.0
|
||||
|
||||
# [m] Vật cản gần hơn mức này thì KHÔNG khai hoả: detour từ sát nách hầu như không ra nghiệm, và
|
||||
# ca đó đã có controller_patience lo.
|
||||
# ► Chỉnh: đặt ~= bán kính ngoại tiếp footprint + dư địa (footprint 0.6x0.6 ⇒ ~0.42 m). TĂNG nếu
|
||||
# thấy nhiều lượt detour `Solution not found` với vật cản rất gần.
|
||||
min_detour_distance: 0.5
|
||||
|
||||
# -- Phép đo 2: robot lệch khỏi plan ------------------------------------------------------------
|
||||
|
||||
# [m] Lệch khỏi plan ĐANG CHẠY quá mức này thì khai hoả. Đo với plan đang chạy chứ không phải
|
||||
# tuyến gốc — sau một lượt detour hợp lệ, plan đang chạy CHÍNH LÀ đường vòng nên không báo oan.
|
||||
# (Ràng buộc "lệch bao nhiêu so với tuyến fleet" là việc của `max_deviation` bên detour.)
|
||||
# ► Chỉnh: 0 = TẮT (hiện tại). Cách đặt đúng: chạy sim/robot qua các khúc cua gắt nhất của tuyến,
|
||||
# ghi cross-track đỉnh, rồi đặt ~1.5–2 lần giá trị đó. Đặt số mò là robot dừng oan giữa đường
|
||||
# cong. Bật thì nhớ bật cả `off_path_enabled`.
|
||||
max_cross_track: 0.0
|
||||
|
||||
# [s] Bỏ qua phép đo lệch tuyến ngay sau khi nhận plan mới — lúc preempt/đổi chặng pose robot có
|
||||
# thể lệch nhất thời so với plan vừa tới.
|
||||
# ► Chỉnh: TĂNG nếu `off_path` khai hoả ngay sau mỗi lần đổi chặng hoặc sau mỗi detour.
|
||||
grace_after_new_plan: 1.0
|
||||
|
||||
# =================================================================================================
|
||||
# Telemetry
|
||||
# =================================================================================================
|
||||
|
||||
# [s] Chu kỳ in bảng thông số runtime ra terminal: CPU của từng thread đã đăng ký (control loop,
|
||||
# thread lập plan, hai vòng cập nhật costmap), chi phí từng đoạn công việc (local planner, global
|
||||
# planner, cachePlans), RSS và tốc độ tăng RSS. 0 = tắt hẳn, không đo gì.
|
||||
#
|
||||
# Dòng "(không đăng ký)" trong bảng là phần CPU KHÔNG thuộc navigation stack — nó thuộc host ROS
|
||||
# (callback cảm biến, OPC-UA, VDA5050, TF bridge). Đọc con số đó trước khi kết luận move_base2 nặng.
|
||||
#
|
||||
# ► Chỉnh: đặt 2.0–5.0 khi đang truy CPU/rò bộ nhớ, rồi TRẢ VỀ 0. Đây là công cụ chẩn đoán, đừng để
|
||||
# chạy thường trực trên robot thật.
|
||||
runtime_stats_period: 0.0
|
||||
|
||||
# Bật/tắt toàn bộ recovery. Danh sách behavior và route nằm ở `recovery_behaviors_params.yaml`,
|
||||
# namespace `recovery`.
|
||||
# ► Chỉnh: false = mọi lỗi đi thẳng tới ABORTED, không thử phục hồi. Chỉ dùng khi cô lập lỗi lúc
|
||||
# debug; trên hiện trường để true.
|
||||
recovery_behavior_enabled: false
|
||||
|
||||
# =================================================================================================
|
||||
# Mission layer
|
||||
# =================================================================================================
|
||||
|
||||
# true (mặc định của move_base2): VDA5050 Order đi qua `mission_adapters` — order được cắt thành
|
||||
# từng chặng tại mỗi node có action, chỉ phần `released` được chạy, `orderUpdateId` nối tiếp thay vì
|
||||
# chạy lại từ đầu, và có `mission_timeout` làm lưới cuối. Nguồn mission và tham số của layer khai ở
|
||||
# `mission_adapters_params.yaml`.
|
||||
#
|
||||
# false: order đi thẳng xuống navigation như MỘT goal duy nhất — hành vi của move_base gen-1, và
|
||||
# cũng là hành vi đã chạy được trên sim trước 2026-07-31. Đây là đường lùi khi mission layer gây vấn
|
||||
# đề trên hiện trường: đổi một khoá, không phải build lại.
|
||||
#
|
||||
# Bật mà không nạp được nguồn nào thì runtime TỰ quay về đường trực tiếp kèm log cảnh báo — thiếu
|
||||
# plugin không được phép biến thành robot đứng im không rõ lý do.
|
||||
#
|
||||
# ► Chỉnh: tắt thì MẤT compound action (charge/PickUp), mất cắt chặng theo node, mất `mission_timeout`.
|
||||
# Chỉ tắt để cô lập sự cố, và nhớ bật lại.
|
||||
mission_layer_enabled: true
|
||||
|
||||
# Bảng symbol -> thư viện cho Boost.DLL. Đây KHÔNG phải tham số tinh chỉnh — thiếu khoá này là
|
||||
# nguyên nhân phổ biến nhất của lỗi "plugin build xong nhưng runtime báo không tìm thấy".
|
||||
MoveBase:
|
||||
library_path: libmove_base2
|
||||
98
config/runtime/mppi_local_planner_params.yaml
Normal file
98
config/runtime/mppi_local_planner_params.yaml
Normal file
@@ -0,0 +1,98 @@
|
||||
LocalPlannerAdapter:
|
||||
library_path: liblocal_planner_adapter
|
||||
yaw_goal_tolerance: 0.017
|
||||
xy_goal_tolerance: 0.03
|
||||
min_approach_linear_velocity: 0.06
|
||||
|
||||
MPPILocalPlanner:
|
||||
library_path: libmppi_local_planner
|
||||
|
||||
# ===== Giới hạn robot [m/s, rad/s] =====
|
||||
min_velocity: 0.0
|
||||
# Cao hon reference_velocity mot khoang dem (headroom). Neu de sat ref thi
|
||||
# nua tren cua nhieu sampling bi clamp o max, keo van toc trung binh xuong
|
||||
# (do duoc: ref0.45/max0.50 -> chi dat 0.33; max0.65 -> dat 0.41). Robot chay
|
||||
# duoc >0.6 m/s nen dat 0.65.
|
||||
max_velocity: 0.65
|
||||
max_angular_velocity: 1.0
|
||||
robot_radius: 0.30
|
||||
obstacle_point_radius: 0.08
|
||||
footprint_padding: 0.05
|
||||
|
||||
# ===== Lõi MPPI =====
|
||||
# Horizon = model_dt * time_steps = 3.6 s ~ 1.8 m @0.5 m/s.
|
||||
# Truoc day 1.4 s (0.7 m) qua ngan: robot chi "thay" vat can khi da sat, khong con
|
||||
# cho de vong qua -> hoac ket hoac lang nhang. Do thuc te: 0.7m/1.2m khong toi dich;
|
||||
# 1.8m toi dich voi quang duong chi dai hon 6% so voi duong thang.
|
||||
# Khong tang dt qua 0.15: dt=0.20 lam dao dong tang gap 4 lan.
|
||||
model_dt: 0.2
|
||||
time_steps: 20
|
||||
batch_size: 220
|
||||
# So thread OpenMP. De mac dinh (= 16 core) thi tranh chap voi gazebo/rviz/perception
|
||||
# lam 1 chu ky solveMPPI cham tu 0.9 ms len ~25 ms.
|
||||
num_threads: 4
|
||||
param_lambda: 100.0
|
||||
param_alpha: 0.98
|
||||
param_exploration: 0.05
|
||||
vx_std: 0.2
|
||||
wz_std: 0.25
|
||||
reference_velocity: 0.48
|
||||
|
||||
# ===== Path và goal =====
|
||||
# Phai lon hon horizon (1.8 m), neu khong terminal goal_weight se keo robot ve
|
||||
# diem cat cua reference path va lam no giam toc moi chu ky.
|
||||
max_global_plan_lookahead_dist: 3.0
|
||||
xy_goal_tolerance: 0.10
|
||||
yaw_goal_tolerance: 0.10
|
||||
|
||||
# ===== Costmap và trọng số hàm chi phí =====
|
||||
obstacle_range: 2.5
|
||||
obstacle_cost_threshold: 150
|
||||
obstacle_cell_step: 2
|
||||
max_obstacle_points: 180
|
||||
obstacle_influence_radius: 1.0
|
||||
# Cost vat can gio CONG DON tren tung cell (truoc day lay max), nen thang nay phai
|
||||
# nho hon nhieu. Giu 85 voi che do sum lam cost vot len ~180x85, ap dao moi thanh
|
||||
# phan khac -> dao dong manh va di vong xa 45%. Do thuc te tai T=24/dt=0.15:
|
||||
# weight=10 cho dao dong thap nhat va khoang ho 0.48 m (du 13 cm).
|
||||
obstacle_cost_use_sum: true
|
||||
obstacle_weight: 10.0
|
||||
collision_cost: 1000000.0
|
||||
progress_weight: 8.0
|
||||
terminal_progress_weight: 20.0
|
||||
goal_weight: 30.0
|
||||
# Phat v^2: gan 0 vi no truc tiep keo van toc xuong (phan truc giac voi robot
|
||||
# muon chay nhanh). Giu nho de van co chut smoothing.
|
||||
linear_control_weight: 0.2
|
||||
angular_control_weight: 0.2
|
||||
control_change_weight: 1.0
|
||||
# Giam toc khi lech huong: ha tu 0.8 xuong 0.3. Truoc day khi ne vat can
|
||||
# (yaw error lon) robot bo <0.1 m/s. 0.3 van giam toc vao cua nhung khong bo.
|
||||
yaw_error_slowdown: 0.1
|
||||
min_tracking_velocity: 0.08
|
||||
|
||||
# Phat hien ket: MPPI co the tra lenh hop le nhung ~0 mai o cuc tieu dia phuong.
|
||||
# Qua nguong nay controller bao that bai -> move_base PLANNING roi CLEARING.
|
||||
stuck_velocity_threshold: 0.03
|
||||
stuck_omega_threshold: 0.05
|
||||
stuck_patience_cycles: 40
|
||||
|
||||
# ===== Covariance thích nghi (giai đoạn 2) =====
|
||||
# Moi chu ky fit lai do rong nhieu cho TUNG buoc thoi gian tu chinh batch.
|
||||
# vx_std/wz_std o tren chi con la gia tri khoi tao va gia tri sau reset.
|
||||
adaptive_covariance: true
|
||||
gaussian_fitting_lambda: 5.0 # phai < param_lambda de trong so du nhon
|
||||
# San chon bang thuc nghiem: thap hon -> muot hon nhung cham va sat vat can hon.
|
||||
min_vx_std: 0.08
|
||||
max_vx_std: 0.35
|
||||
min_wz_std: 0.10
|
||||
max_wz_std: 0.60
|
||||
# Khi bi ket, no rong sigma dan qua tung chu ky de thoat cuc tieu dia phuong.
|
||||
stuck_sigma_inflation: 1.6
|
||||
hard_obstacle_cost_threshold: 254
|
||||
stage_xy_weight: 60.0
|
||||
stage_yaw_weight: 1.0
|
||||
stage_speed_weight: 12.0
|
||||
terminal_xy_weight: 90.0
|
||||
terminal_yaw_weight: 1.0
|
||||
terminal_speed_weight: 12.0
|
||||
48
config/runtime/mprim/base_local_planner_params.yaml
Normal file
48
config/runtime/mprim/base_local_planner_params.yaml
Normal file
@@ -0,0 +1,48 @@
|
||||
#For full documentation of the parameters in this file, and a list of all the
|
||||
#parameters available for TrajectoryPlannerROS, please see
|
||||
#http://www.ros.org/wiki/base_local_planner
|
||||
TrajectoryPlannerROS:
|
||||
#Set the acceleration limits of the robot
|
||||
acc_lim_th: 3.2
|
||||
acc_lim_x: 0.5
|
||||
acc_lim_y: 0.5
|
||||
|
||||
#Set the velocity limits of the robot
|
||||
max_vel_x: 0.4
|
||||
min_vel_x: 0.1
|
||||
max_rotational_vel: 1.0
|
||||
min_in_place_rotational_vel: 0.4
|
||||
|
||||
#The velocity the robot will command when trying to escape from a stuck situation
|
||||
escape_vel: -0.2
|
||||
|
||||
#For this example, we'll use a holonomic robot
|
||||
holonomic_robot: false
|
||||
|
||||
#Since we're using a holonomic robot, we'll set the set of y velocities it will sample
|
||||
y_vels: [-0.3, -0.1, 0.1, 0.3]
|
||||
|
||||
#Set the tolerance on achieving a goal
|
||||
xy_goal_tolerance: 0.1
|
||||
yaw_goal_tolerance: 0.05
|
||||
|
||||
#We'll configure how long and with what granularity we'll forward simulate trajectories
|
||||
sim_time: 3.0
|
||||
sim_granularity: 0.025
|
||||
vx_samples: 5
|
||||
vtheta_samples: 20
|
||||
|
||||
#Parameters for scoring trajectories
|
||||
goal_distance_bias: 0.4
|
||||
path_distance_bias: 0.7
|
||||
occdist_scale: 0.3
|
||||
heading_lookahead: 0.325
|
||||
|
||||
#We'll use the Dynamic Window Approach to control instead of Trajectory Rollout for this example
|
||||
dwa: false
|
||||
|
||||
#How far the robot must travel before oscillation flags are reset
|
||||
oscillation_reset_dist: 0.01
|
||||
|
||||
#Eat up the plan as the robot moves along it
|
||||
prune_plan: false
|
||||
55
config/runtime/mprim/dwa_local_planner_params.yaml
Normal file
55
config/runtime/mprim/dwa_local_planner_params.yaml
Normal file
@@ -0,0 +1,55 @@
|
||||
base_local_planner: dwa_local_planner/DWAPlannerROS
|
||||
DWAPlannerROS:
|
||||
# Robot configuration
|
||||
max_vel_x: 0.8
|
||||
min_vel_x: -0.2
|
||||
|
||||
max_vel_y: 0.0 # diff drive robot
|
||||
min_vel_y: 0.0 # diff drive robot
|
||||
|
||||
max_trans_vel: 0.8 # choose slightly less than the base's capability
|
||||
min_trans_vel: 0.1 # this is the min trans velocity when there is negligible rotational velocity
|
||||
trans_stopped_vel: 0.03
|
||||
|
||||
# Warning!
|
||||
# do not set min_trans_vel to 0.0 otherwise dwa will always think translational velocities
|
||||
# are non-negligible and small in place rotational velocities will be created.
|
||||
|
||||
max_rot_vel: 1.0 # choose slightly less than the base's capability
|
||||
min_rot_vel: 0.1 # this is the min angular velocity when there is negligible translational velocity
|
||||
rot_stopped_vel: 0.1
|
||||
|
||||
acc_lim_x: 1.5
|
||||
acc_lim_y: 0.0 # diff drive robot
|
||||
acc_limit_trans: 1.5
|
||||
acc_lim_theta: 2.0
|
||||
|
||||
# Goal tolerance
|
||||
yaw_goal_tolerance: 0.03 # yaw_goal_tolerance > (sim_time * min_rot_vel) / 2 (from Navigation Tuning Guide)
|
||||
xy_goal_tolerance: 0.08 # xy_goal_tolerance > (sim_time * min_vel_x) / 2
|
||||
latch_xy_goal_tolerance: true
|
||||
|
||||
# Forward simulation
|
||||
sim_time: 1.2
|
||||
vx_samples: 15
|
||||
vy_samples: 1 # diff drive robot, there is only one sample
|
||||
vtheta_samples: 20
|
||||
|
||||
# Trajectory scoring
|
||||
path_distance_bias: 64.0 # default: 32.0 mir: 32.0 - weighting for how much it should stick to the global path plan
|
||||
goal_distance_bias: 12.0 # default: 24.0 mir: 48.0 - weighting for how much it should attempt to reach its goal
|
||||
occdist_scale: 0.5 # default: 0.01 mir: 0.01 - weighting for how much the controller should avoid obstacles
|
||||
forward_point_distance: 0.325 # default: 0.325 mir: 0.325 - how far along to place an additional scoring point
|
||||
stop_time_buffer: 0.2 # default: 0.2 mir: 0.2 - amount of time a robot must stop before colliding for a valid traj.
|
||||
scaling_speed: 0.25 # default: 0.25 mir: 0.25 - absolute velocity at which to start scaling the robot's footprint
|
||||
max_scaling_factor: 0.2 # default: 0.2 mir: 0.2 - how much to scale the robot's footprint when at speed.
|
||||
prune_plan: true
|
||||
|
||||
# Oscillation prevention
|
||||
oscillation_reset_dist: 0.05 # 0.05 - how far to travel before resetting oscillation flags, in m
|
||||
oscillation_reset_angle: 0.2 # 0.2 - the angle the robot must turn before resetting Oscillation flags, in rad
|
||||
|
||||
# Debugging
|
||||
publish_traj_pc : true
|
||||
publish_cost_grid_pc: true
|
||||
global_frame_id: /odom # or <robot namespace>/odom
|
||||
217
config/runtime/mprim/ekf.yaml
Normal file
217
config/runtime/mprim/ekf.yaml
Normal file
@@ -0,0 +1,217 @@
|
||||
# The frequency, in Hz, at which the filter will output a position estimate. Note that the filter will not begin
|
||||
# computation until it receives at least one message from one of the inputs. It will then run continuously at the
|
||||
# frequency specified here, regardless of whether it receives more measurements. Defaults to 30 if unspecified.
|
||||
frequency: 50
|
||||
|
||||
# The period, in seconds, after which we consider a sensor to have timed out. In this event, we carry out a predict
|
||||
# cycle on the EKF without correcting it. This parameter can be thought of as the minimum frequency with which the
|
||||
# filter will generate new output. Defaults to 1 / frequency if not specified.
|
||||
sensor_timeout: 0.1
|
||||
|
||||
# ekf_localization_node and ukf_localization_node both use a 3D omnidirectional motion model. If this parameter is
|
||||
# set to true, no 3D information will be used in your state estimate. Use this if you are operating in a planar
|
||||
# environment and want to ignore the effect of small variations in the ground plane that might otherwise be detected
|
||||
# by, for example, an IMU. Defaults to false if unspecified.
|
||||
two_d_mode: true
|
||||
|
||||
# Use this parameter to provide an offset to the transform generated by ekf_localization_node. This can be used for
|
||||
# future dating the transform, which is required for interaction with some other packages. Defaults to 0.0 if
|
||||
# unspecified.
|
||||
transform_time_offset: 0.0
|
||||
|
||||
# Use this parameter to specify how long the tf listener should wait for a transform to become available.
|
||||
# Defaults to 0.0 if unspecified.
|
||||
transform_timeout: 0.0
|
||||
|
||||
# If you're having trouble, try setting this to true, and then echo the /diagnostics_agg topic to see if the node is
|
||||
# unhappy with any settings or data.
|
||||
print_diagnostics: true
|
||||
|
||||
# Debug settings. Not for the faint of heart. Outputs a ludicrous amount of information to the file specified by
|
||||
# debug_out_file. I hope you like matrices! Please note that setting this to true will have strongly deleterious
|
||||
# effects on the performance of the node. Defaults to false if unspecified.
|
||||
debug: false
|
||||
|
||||
# Defaults to "robot_localization_debug.txt" if unspecified. Please specify the full path.
|
||||
debug_out_file: /path/to/debug/file.txt
|
||||
|
||||
# Whether to broadcast the transformation over the /tf topic. Defaults to true if unspecified.
|
||||
publish_tf: true
|
||||
|
||||
# Whether to publish the acceleration state. Defaults to false if unspecified.
|
||||
publish_acceleration: false
|
||||
|
||||
# REP-105 (http://www.ros.org/reps/rep-0105.html) specifies four principal coordinate frames: base_link, odom, map, and
|
||||
# earth. base_link is the coordinate frame that is affixed to the robot. Both odom and map are world-fixed frames.
|
||||
# The robot's position in the odom frame will drift over time, but is accurate in the short term and should be
|
||||
# continuous. The odom frame is therefore the best frame for executing local motion plans. The map frame, like the odom
|
||||
# frame, is a world-fixed coordinate frame, and while it contains the most globally accurate position estimate for your
|
||||
# robot, it is subject to discrete jumps, e.g., due to the fusion of GPS data or a correction from a map-based
|
||||
# localization node. The earth frame is used to relate multiple map frames by giving them a common reference frame.
|
||||
# ekf_localization_node and ukf_localization_node are not concerned with the earth frame.
|
||||
# Here is how to use the following settings:
|
||||
# 1. Set the map_frame, odom_frame, and base_link frames to the appropriate frame names for your system.
|
||||
# 1a. If your system does not have a map_frame, just remove it, and make sure "world_frame" is set to the value of
|
||||
# odom_frame.
|
||||
# 2. If you are fusing continuous position data such as wheel encoder odometry, visual odometry, or IMU data, set
|
||||
# "world_frame" to your odom_frame value. This is the default behavior for robot_localization's state estimation nodes.
|
||||
# 3. If you are fusing global absolute position data that is subject to discrete jumps (e.g., GPS or position updates
|
||||
# from landmark observations) then:
|
||||
# 3a. Set your "world_frame" to your map_frame value
|
||||
# 3b. MAKE SURE something else is generating the odom->base_link transform. Note that this can even be another state
|
||||
# estimation node from robot_localization! However, that instance should *not* fuse the global data.
|
||||
map_frame: map # Defaults to "map" if unspecified
|
||||
odom_frame: $(arg tf_prefix)odom # Defaults to "odom" if unspecified
|
||||
base_link_frame: $(arg tf_prefix)base_link # Defaults to "base_link" if unspecified
|
||||
world_frame: $(arg tf_prefix)odom # Defaults to the value of odom_frame if unspecified
|
||||
|
||||
# The filter accepts an arbitrary number of inputs from each input message type (robot_nav_msgs/Odometry,
|
||||
# geometry_msgs/PoseWithCovarianceStamped, geometry_msgs/TwistWithCovarianceStamped,
|
||||
# robot_sensor_msgs/Imu). To add an input, simply append the next number in the sequence to its "base" name, e.g., odom0,
|
||||
# odom1, twist0, twist1, imu0, imu1, imu2, etc. The value should be the topic name. These parameters obviously have no
|
||||
# default values, and must be specified.
|
||||
odom0: odom
|
||||
|
||||
# Each sensor reading updates some or all of the filter's state. These options give you greater control over which
|
||||
# values from each measurement are fed to the filter. For example, if you have an odometry message as input, but only
|
||||
# want to use its Z position value, then set the entire vector to false, except for the third entry. The order of the
|
||||
# values is x, y, z, roll, pitch, yaw, vx, vy, vz, vroll, vpitch, vyaw, ax, ay, az. Note that not some message types
|
||||
# do not provide some of the state variables estimated by the filter. For example, a TwistWithCovarianceStamped message
|
||||
# has no pose information, so the first six values would be meaningless in that case. Each vector defaults to all false
|
||||
# if unspecified, effectively making this parameter required for each sensor.
|
||||
# see http://docs.ros.org/melodic/api/robot_localization/html/configuring_robot_localization.html
|
||||
odom0_config: [false, false, false, # x y z
|
||||
false, false, false, # roll pitch yaw
|
||||
true, true, false, # vx vy vz
|
||||
false, false, true, # vroll vpitch vyaw
|
||||
false, false, false] # ax ay az
|
||||
|
||||
# If you have high-frequency data or are running with a low frequency parameter value, then you may want to increase
|
||||
# the size of the subscription queue so that more measurements are fused.
|
||||
odom0_queue_size: 10
|
||||
|
||||
# [ADVANCED] Large messages in ROS can exhibit strange behavior when they arrive at a high frequency. This is a result
|
||||
# of Nagle's algorithm. This option tells the ROS subscriber to use the tcpNoDelay option, which disables Nagle's
|
||||
# algorithm.
|
||||
odom0_nodelay: false
|
||||
|
||||
# [ADVANCED] When measuring one pose variable with two sensors, a situation can arise in which both sensors under-
|
||||
# report their covariances. This can lead to the filter rapidly jumping back and forth between each measurement as they
|
||||
# arrive. In these cases, it often makes sense to (a) correct the measurement covariances, or (b) if velocity is also
|
||||
# measured by one of the sensors, let one sensor measure pose, and the other velocity. However, doing (a) or (b) isn't
|
||||
# always feasible, and so we expose the differential parameter. When differential mode is enabled, all absolute pose
|
||||
# data is converted to velocity data by differentiating the absolute pose measurements. These velocities are then
|
||||
# integrated as usual. NOTE: this only applies to sensors that provide pose measurements; setting differential to true
|
||||
# for twist measurements has no effect.
|
||||
odom0_differential: false
|
||||
|
||||
# [ADVANCED] When the node starts, if this parameter is true, then the first measurement is treated as a "zero point"
|
||||
# for all future measurements. While you can achieve the same effect with the differential paremeter, the key
|
||||
# difference is that the relative parameter doesn't cause the measurement to be converted to a velocity before
|
||||
# integrating it. If you simply want your measurements to start at 0 for a given sensor, set this to true.
|
||||
odom0_relative: false
|
||||
|
||||
# [ADVANCED] If your data is subject to outliers, use these threshold settings, expressed as Mahalanobis distances, to
|
||||
# control how far away from the current vehicle state a sensor measurement is permitted to be. Each defaults to
|
||||
# numeric_limits<double>::max() if unspecified. It is strongly recommended that these parameters be removed if not
|
||||
# required. Data is specified at the level of pose and twist variables, rather than for each variable in isolation.
|
||||
# For messages that have both pose and twist data, the parameter specifies to which part of the message we are applying
|
||||
# the thresholds.
|
||||
#odom0_pose_rejection_threshold: 5
|
||||
#odom0_twist_rejection_threshold: 1
|
||||
|
||||
# Further input parameter examples
|
||||
# see http://docs.ros.org/melodic/api/robot_localization/html/configuring_robot_localization.html
|
||||
imu0: imu_data
|
||||
imu0_config: [false, false, false, # x y z
|
||||
false, false, true, # roll pitch yaw
|
||||
false, false, false, # vx vy vz
|
||||
false, false, true, # vroll vpitch vyaw
|
||||
true, false, false] # ax ay az
|
||||
imu0_nodelay: false
|
||||
imu0_differential: false
|
||||
imu0_relative: true
|
||||
imu0_queue_size: 10
|
||||
#imu0_pose_rejection_threshold: 0.8 # Note the difference in parameter names
|
||||
#imu0_twist_rejection_threshold: 0.8 #
|
||||
#imu0_linear_acceleration_rejection_threshold: 0.8 #
|
||||
|
||||
# [ADVANCED] Some IMUs automatically remove acceleration due to gravity, and others don't. If yours doesn't, please set
|
||||
# this to true, and *make sure* your data conforms to REP-103, specifically, that the data is in ENU frame.
|
||||
imu0_remove_gravitational_acceleration: false
|
||||
|
||||
# [ADVANCED] The EKF and UKF models follow a standard predict/correct cycle. During prediction, if there is no
|
||||
# acceleration reference, the velocity at time t+1 is simply predicted to be the same as the velocity at time t. During
|
||||
# correction, this predicted value is fused with the measured value to produce the new velocity estimate. This can be
|
||||
# problematic, as the final velocity will effectively be a weighted average of the old velocity and the new one. When
|
||||
# this velocity is the integrated into a new pose, the result can be sluggish covergence. This effect is especially
|
||||
# noticeable with LIDAR data during rotations. To get around it, users can try inflating the process_noise_covariance
|
||||
# for the velocity variable in question, or decrease the variance of the variable in question in the measurement
|
||||
# itself. In addition, users can also take advantage of the control command being issued to the robot at the time we
|
||||
# make the prediction. If control is used, it will get converted into an acceleration term, which will be used during
|
||||
# predicition. Note that if an acceleration measurement for the variable in question is available from one of the
|
||||
# inputs, the control term will be ignored.
|
||||
# Whether or not we use the control input during predicition. Defaults to false.
|
||||
use_control: false
|
||||
# Whether the input (assumed to be cmd_vel) is a geometry_msgs/Twist or geometry_msgs/TwistStamped message. Defaults to
|
||||
# false.
|
||||
stamped_control: false
|
||||
# The last issued control command will be used in prediction for this period. Defaults to 0.2.
|
||||
control_timeout: 0.2
|
||||
# Which velocities are being controlled. Order is vx, vy, vz, vroll, vpitch, vyaw.
|
||||
control_config: [true, false, false, false, false, true]
|
||||
# Places limits on how large the acceleration term will be. Should match your robot's kinematics.
|
||||
acceleration_limits: [1.3, 0.0, 0.0, 0.0, 0.0, 3.4]
|
||||
# Acceleration and deceleration limits are not always the same for robots.
|
||||
deceleration_limits: [1.3, 0.0, 0.0, 0.0, 0.0, 4.5]
|
||||
# If your robot cannot instantaneously reach its acceleration limit, the permitted change can be controlled with these
|
||||
# gains
|
||||
acceleration_gains: [0.8, 0.0, 0.0, 0.0, 0.0, 0.9]
|
||||
# If your robot cannot instantaneously reach its deceleration limit, the permitted change can be controlled with these
|
||||
# gains
|
||||
deceleration_gains: [1.0, 0.0, 0.0, 0.0, 0.0, 1.0]
|
||||
|
||||
# [ADVANCED] The process noise covariance matrix can be difficult to tune, and can vary for each application, so it is
|
||||
# exposed as a configuration parameter. This matrix represents the noise we add to the total error after each
|
||||
# prediction step. The better the omnidirectional motion model matches your system, the smaller these values can be.
|
||||
# However, if users find that a given variable is slow to converge, one approach is to increase the
|
||||
# process_noise_covariance diagonal value for the variable in question, which will cause the filter's predicted error
|
||||
# to be larger, which will cause the filter to trust the incoming measurement more during correction. The values are
|
||||
# ordered as x, y, z, roll, pitch, yaw, vx, vy, vz, vroll, vpitch, vyaw, ax, ay, az. Defaults to the matrix below if
|
||||
# unspecified.
|
||||
process_noise_covariance: [0.05, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0.05, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0.06, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0.03, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0.03, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0.06, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0.025, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0.025, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0.04, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0.01, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.01, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.02, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.01, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.01, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.015]
|
||||
|
||||
# [ADVANCED] This represents the initial value for the state estimate error covariance matrix. Setting a diagonal
|
||||
# value (variance) to a large value will result in rapid convergence for initial measurements of the variable in
|
||||
# question. Users should take care not to use large values for variables that will not be measured directly. The values
|
||||
# are ordered as x, y, z, roll, pitch, yaw, vx, vy, vz, vroll, vpitch, vyaw, ax, ay, az. Defaults to the matrix below
|
||||
#if unspecified.
|
||||
initial_estimate_covariance: [100.0,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 100.0,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 1e-9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 1e-9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 1e-9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 1.0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 1e-9, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 1e-9, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 1e-9, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 1e-9, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1e-9, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1.0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10.0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10.0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1e-9]
|
||||
280
config/runtime/mprim/genmprim_unicycle_highcost_5cm.m
Normal file
280
config/runtime/mprim/genmprim_unicycle_highcost_5cm.m
Normal file
@@ -0,0 +1,280 @@
|
||||
% /*
|
||||
% * Copyright (c) 2008, Maxim Likhachev
|
||||
% * All rights reserved.
|
||||
% *
|
||||
% * 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 the Carnegie Mellon University 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.
|
||||
% */
|
||||
|
||||
function[] = genmprim_unicycle_highcost_5cm(outfilename)
|
||||
|
||||
%
|
||||
%generates motion primitives and saves them into file
|
||||
%
|
||||
%written by Maxim Likhachev
|
||||
%---------------------------------------------------
|
||||
%
|
||||
|
||||
%defines
|
||||
|
||||
UNICYCLE_MPRIM_16DEGS = 1;
|
||||
|
||||
|
||||
if UNICYCLE_MPRIM_16DEGS == 1
|
||||
resolution = 0.05;
|
||||
numberofangles = 16; %preferably a power of 2, definitely multiple of 8
|
||||
numberofprimsperangle = 7;
|
||||
|
||||
%multipliers (multiplier is used as costmult*cost)
|
||||
forwardcostmult = 1;
|
||||
backwardcostmult = 40;
|
||||
forwardandturncostmult = 2;
|
||||
sidestepcostmult = 10;
|
||||
turninplacecostmult = 20;
|
||||
|
||||
%note, what is shown x,y,theta changes (not absolute numbers)
|
||||
|
||||
%0 degreees
|
||||
basemprimendpts0_c = zeros(numberofprimsperangle, 4); %x,y,theta,costmult
|
||||
%x aligned with the heading of the robot, angles are positive
|
||||
%counterclockwise
|
||||
%0 theta change
|
||||
basemprimendpts0_c(1,:) = [1 0 0 forwardcostmult];
|
||||
basemprimendpts0_c(2,:) = [8 0 0 forwardcostmult];
|
||||
basemprimendpts0_c(3,:) = [-1 0 0 backwardcostmult];
|
||||
%1/16 theta change
|
||||
basemprimendpts0_c(4,:) = [8 1 1 forwardandturncostmult];
|
||||
basemprimendpts0_c(5,:) = [8 -1 -1 forwardandturncostmult];
|
||||
%turn in place
|
||||
basemprimendpts0_c(6,:) = [0 0 1 turninplacecostmult];
|
||||
basemprimendpts0_c(7,:) = [0 0 -1 turninplacecostmult];
|
||||
|
||||
%45 degrees
|
||||
basemprimendpts45_c = zeros(numberofprimsperangle, 4); %x,y,theta,costmult (multiplier is used as costmult*cost)
|
||||
%x aligned with the heading of the robot, angles are positive
|
||||
%counterclockwise
|
||||
%0 theta change
|
||||
basemprimendpts45_c(1,:) = [1 1 0 forwardcostmult];
|
||||
basemprimendpts45_c(2,:) = [6 6 0 forwardcostmult];
|
||||
basemprimendpts45_c(3,:) = [-1 -1 0 backwardcostmult];
|
||||
%1/16 theta change
|
||||
basemprimendpts45_c(4,:) = [5 7 1 forwardandturncostmult];
|
||||
basemprimendpts45_c(5,:) = [7 5 -1 forwardandturncostmult];
|
||||
%turn in place
|
||||
basemprimendpts45_c(6,:) = [0 0 1 turninplacecostmult];
|
||||
basemprimendpts45_c(7,:) = [0 0 -1 turninplacecostmult];
|
||||
|
||||
%22.5 degrees
|
||||
basemprimendpts22p5_c = zeros(numberofprimsperangle, 4); %x,y,theta,costmult (multiplier is used as costmult*cost)
|
||||
%x aligned with the heading of the robot, angles are positive
|
||||
%counterclockwise
|
||||
%0 theta change
|
||||
basemprimendpts22p5_c(1,:) = [2 1 0 forwardcostmult];
|
||||
basemprimendpts22p5_c(2,:) = [6 3 0 forwardcostmult];
|
||||
basemprimendpts22p5_c(3,:) = [-2 -1 0 backwardcostmult];
|
||||
%1/16 theta change
|
||||
basemprimendpts22p5_c(4,:) = [5 4 1 forwardandturncostmult];
|
||||
basemprimendpts22p5_c(5,:) = [7 2 -1 forwardandturncostmult];
|
||||
%turn in place
|
||||
basemprimendpts22p5_c(6,:) = [0 0 1 turninplacecostmult];
|
||||
basemprimendpts22p5_c(7,:) = [0 0 -1 turninplacecostmult];
|
||||
|
||||
else
|
||||
fprintf(1, 'ERROR: undefined mprims type\n');
|
||||
return;
|
||||
end;
|
||||
|
||||
|
||||
fout = fopen(outfilename, 'w');
|
||||
|
||||
|
||||
%write the header
|
||||
fprintf(fout, 'resolution_m: %f\n', resolution);
|
||||
fprintf(fout, 'numberofangles: %d\n', numberofangles);
|
||||
fprintf(fout, 'totalnumberofprimitives: %d\n', numberofprimsperangle*numberofangles);
|
||||
|
||||
%iterate over angles
|
||||
for angleind = 1:numberofangles
|
||||
|
||||
figure(1);
|
||||
hold off;
|
||||
|
||||
text(0, 0, int2str(angleind));
|
||||
|
||||
%iterate over primitives
|
||||
for primind = 1:numberofprimsperangle
|
||||
fprintf(fout, 'primID: %d\n', primind-1);
|
||||
fprintf(fout, 'startangle_c: %d\n', angleind-1);
|
||||
|
||||
%current angle
|
||||
currentangle = (angleind-1)*2*pi/numberofangles;
|
||||
currentangle_36000int = round((angleind-1)*36000/numberofangles);
|
||||
|
||||
%compute which template to use
|
||||
if (rem(currentangle_36000int, 9000) == 0)
|
||||
basemprimendpts_c = basemprimendpts0_c(primind,:);
|
||||
angle = currentangle;
|
||||
elseif (rem(currentangle_36000int, 4500) == 0)
|
||||
basemprimendpts_c = basemprimendpts45_c(primind,:);
|
||||
angle = currentangle - 45*pi/180;
|
||||
elseif (rem(currentangle_36000int-7875, 9000) == 0)
|
||||
basemprimendpts_c = basemprimendpts33p75_c(primind,:);
|
||||
basemprimendpts_c(1) = basemprimendpts33p75_c(primind, 2); %reverse x and y
|
||||
basemprimendpts_c(2) = basemprimendpts33p75_c(primind, 1);
|
||||
basemprimendpts_c(3) = -basemprimendpts33p75_c(primind, 3); %reverse the angle as well
|
||||
angle = currentangle - 78.75*pi/180;
|
||||
fprintf(1, '78p75\n');
|
||||
elseif (rem(currentangle_36000int-6750, 9000) == 0)
|
||||
basemprimendpts_c = basemprimendpts22p5_c(primind,:);
|
||||
basemprimendpts_c(1) = basemprimendpts22p5_c(primind, 2); %reverse x and y
|
||||
basemprimendpts_c(2) = basemprimendpts22p5_c(primind, 1);
|
||||
basemprimendpts_c(3) = -basemprimendpts22p5_c(primind, 3); %reverse the angle as well
|
||||
%fprintf(1, '%d %d %d onto %d %d %d\n', basemprimendpts22p5_c(1), basemprimendpts22p5_c(2), basemprimendpts22p5_c(3), ...
|
||||
% basemprimendpts_c(1), basemprimendpts_c(2), basemprimendpts_c(3));
|
||||
angle = currentangle - 67.5*pi/180;
|
||||
fprintf(1, '67p5\n');
|
||||
elseif (rem(currentangle_36000int-5625, 9000) == 0)
|
||||
basemprimendpts_c = basemprimendpts11p25_c(primind,:);
|
||||
basemprimendpts_c(1) = basemprimendpts11p25_c(primind, 2); %reverse x and y
|
||||
basemprimendpts_c(2) = basemprimendpts11p25_c(primind, 1);
|
||||
basemprimendpts_c(3) = -basemprimendpts11p25_c(primind, 3); %reverse the angle as well
|
||||
angle = currentangle - 56.25*pi/180;
|
||||
fprintf(1, '56p25\n');
|
||||
elseif (rem(currentangle_36000int-3375, 9000) == 0)
|
||||
basemprimendpts_c = basemprimendpts33p75_c(primind,:);
|
||||
angle = currentangle - 33.75*pi/180;
|
||||
fprintf(1, '33p75\n');
|
||||
elseif (rem(currentangle_36000int-2250, 9000) == 0)
|
||||
basemprimendpts_c = basemprimendpts22p5_c(primind,:);
|
||||
angle = currentangle - 22.5*pi/180;
|
||||
fprintf(1, '22p5\n');
|
||||
elseif (rem(currentangle_36000int-1125, 9000) == 0)
|
||||
basemprimendpts_c = basemprimendpts11p25_c(primind,:);
|
||||
angle = currentangle - 11.25*pi/180;
|
||||
fprintf(1, '11p25\n');
|
||||
else
|
||||
fprintf(1, 'ERROR: invalid angular resolution. angle = %d\n', currentangle_36000int);
|
||||
return;
|
||||
end;
|
||||
|
||||
%now figure out what action will be
|
||||
baseendpose_c = basemprimendpts_c(1:3);
|
||||
additionalactioncostmult = basemprimendpts_c(4);
|
||||
endx_c = round(baseendpose_c(1)*cos(angle) - baseendpose_c(2)*sin(angle));
|
||||
endy_c = round(baseendpose_c(1)*sin(angle) + baseendpose_c(2)*cos(angle));
|
||||
endtheta_c = rem(angleind - 1 + baseendpose_c(3), numberofangles);
|
||||
endpose_c = [endx_c endy_c endtheta_c];
|
||||
|
||||
fprintf(1, 'rotation angle=%f\n', angle*180/pi);
|
||||
|
||||
if baseendpose_c(2) == 0 & baseendpose_c(3) == 0
|
||||
%fprintf(1, 'endpose=%d %d %d\n', endpose_c(1), endpose_c(2), endpose_c(3));
|
||||
end;
|
||||
|
||||
%generate intermediate poses (remember they are w.r.t 0,0 (and not
|
||||
%centers of the cells)
|
||||
numofsamples = 10;
|
||||
intermcells_m = zeros(numofsamples,3);
|
||||
if UNICYCLE_MPRIM_16DEGS == 1
|
||||
startpt = [0 0 currentangle];
|
||||
endpt = [endpose_c(1)*resolution endpose_c(2)*resolution ...
|
||||
rem(angleind - 1 + baseendpose_c(3), numberofangles)*2*pi/numberofangles];
|
||||
intermcells_m = zeros(numofsamples,3);
|
||||
if ((endx_c == 0 & endy_c == 0) | baseendpose_c(3) == 0) %turn in place or move forward
|
||||
for iind = 1:numofsamples
|
||||
intermcells_m(iind,:) = [startpt(1) + (endpt(1) - startpt(1))*(iind-1)/(numofsamples-1) ...
|
||||
startpt(2) + (endpt(2) - startpt(2))*(iind-1)/(numofsamples-1) ...
|
||||
0];
|
||||
rotation_angle = (baseendpose_c(3) ) * (2*pi/numberofangles);
|
||||
intermcells_m(iind,3) = rem(startpt(3) + (rotation_angle)*(iind-1)/(numofsamples-1), 2*pi);
|
||||
|
||||
end;
|
||||
else %unicycle-based move forward or backward
|
||||
R = [cos(startpt(3)) sin(endpt(3)) - sin(startpt(3));
|
||||
sin(startpt(3)) -(cos(endpt(3)) - cos(startpt(3)))];
|
||||
S = pinv(R)*[endpt(1) - startpt(1); endpt(2) - startpt(2)];
|
||||
l = S(1);
|
||||
tvoverrv = S(2);
|
||||
rv = (baseendpose_c(3)*2*pi/numberofangles + l/tvoverrv);
|
||||
tv = tvoverrv*rv;
|
||||
|
||||
if l < 0
|
||||
fprintf(1, 'WARNING: l = %d < 0 -> bad action start/end points\n', l);
|
||||
l = 0;
|
||||
end;
|
||||
%compute rv
|
||||
%rv = baseendpose_c(3)*2*pi/numberofangles;
|
||||
%compute tv
|
||||
%tvx = (endpt(1) - startpt(1))*rv/(sin(endpt(3)) - sin(startpt(3)))
|
||||
%tvy = -(endpt(2) - startpt(2))*rv/(cos(endpt(3)) - cos(startpt(3)))
|
||||
%tv = (tvx + tvy)/2.0;
|
||||
%generate samples
|
||||
for iind = 1:numofsamples
|
||||
dt = (iind-1)/(numofsamples-1);
|
||||
|
||||
%dtheta = rv*dt + startpt(3);
|
||||
%intermcells_m(iind,:) = [startpt(1) + tv/rv*(sin(dtheta) - sin(startpt(3))) ...
|
||||
% startpt(2) - tv/rv*(cos(dtheta) - cos(startpt(3))) ...
|
||||
% dtheta];
|
||||
|
||||
if(dt*tv < l)
|
||||
intermcells_m(iind,:) = [startpt(1) + dt*tv*cos(startpt(3)) ...
|
||||
startpt(2) + dt*tv*sin(startpt(3)) ...
|
||||
startpt(3)];
|
||||
else
|
||||
dtheta = rv*(dt - l/tv) + startpt(3);
|
||||
intermcells_m(iind,:) = [startpt(1) + l*cos(startpt(3)) + tvoverrv*(sin(dtheta) - sin(startpt(3))) ...
|
||||
startpt(2) + l*sin(startpt(3)) - tvoverrv*(cos(dtheta) - cos(startpt(3))) ...
|
||||
dtheta];
|
||||
end;
|
||||
end;
|
||||
%correct
|
||||
errorxy = [endpt(1) - intermcells_m(numofsamples,1) ...
|
||||
endpt(2) - intermcells_m(numofsamples,2)];
|
||||
fprintf(1, 'l=%f errx=%f erry=%f\n', l, errorxy(1), errorxy(2));
|
||||
interpfactor = [0:1/(numofsamples-1):1];
|
||||
intermcells_m(:,1) = intermcells_m(:,1) + errorxy(1)*interpfactor';
|
||||
intermcells_m(:,2) = intermcells_m(:,2) + errorxy(2)*interpfactor';
|
||||
end;
|
||||
end;
|
||||
|
||||
%write out
|
||||
fprintf(fout, 'endpose_c: %d %d %d\n', endpose_c(1), endpose_c(2), endpose_c(3));
|
||||
fprintf(fout, 'additionalactioncostmult: %d\n', additionalactioncostmult);
|
||||
fprintf(fout, 'intermediateposes: %d\n', size(intermcells_m,1));
|
||||
for interind = 1:size(intermcells_m, 1)
|
||||
fprintf(fout, '%.4f %.4f %.4f\n', intermcells_m(interind,1), intermcells_m(interind,2), intermcells_m(interind,3));
|
||||
end;
|
||||
|
||||
plot(intermcells_m(:,1), intermcells_m(:,2));
|
||||
axis([-0.3 0.3 -0.3 0.3]);
|
||||
text(intermcells_m(numofsamples,1), intermcells_m(numofsamples,2), int2str(endpose_c(3)));
|
||||
hold on;
|
||||
|
||||
end;
|
||||
grid;
|
||||
pause;
|
||||
end;
|
||||
|
||||
fclose('all');
|
||||
416
config/runtime/mprim/genmprim_unicycle_highcost_5cm.py
Normal file
416
config/runtime/mprim/genmprim_unicycle_highcost_5cm.py
Normal file
@@ -0,0 +1,416 @@
|
||||
#!/usr/bin/env python3
|
||||
#
|
||||
# Copyright (c) 2016, David Conner (Christopher Newport University)
|
||||
# Based on genmprim_unicycle.m
|
||||
# Copyright (c) 2008, Maxim Likhachev
|
||||
# All rights reserved.
|
||||
# converted by libermate utility (https://github.com/awesomebytes/libermate)
|
||||
#
|
||||
# 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 the Carnegie Mellon University 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.
|
||||
|
||||
import numpy as np
|
||||
import rospkg
|
||||
|
||||
# if available import pylab (from matlibplot)
|
||||
matplotlib_found = False
|
||||
try:
|
||||
import matplotlib.pylab as plt
|
||||
|
||||
matplotlib_found = True
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
|
||||
def matrix_size(mat, elem=None):
|
||||
if not elem:
|
||||
return mat.shape
|
||||
else:
|
||||
return mat.shape[int(elem) - 1]
|
||||
|
||||
|
||||
def genmprim_unicycle(outfilename, visualize=False, separate_plots=False):
|
||||
visualize = matplotlib_found and visualize # Plot the primitives
|
||||
|
||||
# Local Variables: basemprimendpts22p5_c, endtheta_c, endx_c,
|
||||
# baseendpose_c, additionalactioncostmult, fout, numofsamples,
|
||||
# basemprimendpts45_c, primind, basemprimendpts0_c, rv, angle, outfilename,
|
||||
# numberofangles, startpt, UNICYCLE_MPRIM_16DEGS, sidestepcostmult,
|
||||
# rotation_angle, basemprimendpts_c, forwardandturncostmult,
|
||||
# forwardcostmult, turninplacecostmult, endpose_c, backwardcostmult,
|
||||
# interpfactor, S, R, tvoverrv, dtheta, intermcells_m, tv, dt,
|
||||
# currentangle, numberofprimsperangle, resolution, currentangle_36000int,
|
||||
# l, iind, errorxy, interind, endy_c, angleind, endpt
|
||||
# Function calls: plot, cos, pi, grid, figure, genmprim_unicycle, text,
|
||||
# int2str, pause, axis, sin, pinv, fprintf, fclose, rem, zeros, fopen,
|
||||
# round, size
|
||||
# %
|
||||
# %generates motion primitives and saves them into file
|
||||
# %
|
||||
# %written by Maxim Likhachev
|
||||
# %---------------------------------------------------
|
||||
# %
|
||||
# %defines
|
||||
UNICYCLE_MPRIM_16DEGS = 1.0
|
||||
if UNICYCLE_MPRIM_16DEGS == 1.0:
|
||||
resolution = 0.05
|
||||
numberofangles = 16
|
||||
# %preferably a power of 2, definitely multiple of 8
|
||||
numberofprimsperangle = 7
|
||||
# %multipliers (multiplier is used as costmult*cost)
|
||||
forwardcostmult = 1.0
|
||||
backwardcostmult = 40.0
|
||||
forwardandturncostmult = 2.0
|
||||
# sidestepcostmult = 10.0
|
||||
turninplacecostmult = 20.0
|
||||
# %note, what is shown x,y,theta changes (not absolute numbers)
|
||||
# %0 degreees
|
||||
basemprimendpts0_c = np.zeros((numberofprimsperangle, 4))
|
||||
# %x,y,theta,costmult
|
||||
# %x aligned with the heading of the robot, angles are positive
|
||||
# %counterclockwise
|
||||
# %0 theta change
|
||||
basemprimendpts0_c[0, :] = np.array(np.hstack((1.0, 0.0, 0.0, forwardcostmult)))
|
||||
basemprimendpts0_c[1, :] = np.array(np.hstack((8.0, 0.0, 0.0, forwardcostmult)))
|
||||
basemprimendpts0_c[2, :] = np.array(np.hstack((-1.0, 0.0, 0.0, backwardcostmult)))
|
||||
# %1/16 theta change
|
||||
basemprimendpts0_c[3, :] = np.array(np.hstack((8.0, 1.0, 1.0, forwardandturncostmult)))
|
||||
basemprimendpts0_c[4, :] = np.array(np.hstack((8.0, -1.0, -1.0, forwardandturncostmult)))
|
||||
# %turn in place
|
||||
basemprimendpts0_c[5, :] = np.array(np.hstack((0.0, 0.0, 1.0, turninplacecostmult)))
|
||||
basemprimendpts0_c[6, :] = np.array(np.hstack((0.0, 0.0, -1.0, turninplacecostmult)))
|
||||
# %45 degrees
|
||||
basemprimendpts45_c = np.zeros((numberofprimsperangle, 4))
|
||||
# %x,y,theta,costmult (multiplier is used as costmult*cost)
|
||||
# %x aligned with the heading of the robot, angles are positive
|
||||
# %counterclockwise
|
||||
# %0 theta change
|
||||
basemprimendpts45_c[0, :] = np.array(np.hstack((1.0, 1.0, 0.0, forwardcostmult)))
|
||||
basemprimendpts45_c[1, :] = np.array(np.hstack((6.0, 6.0, 0.0, forwardcostmult)))
|
||||
basemprimendpts45_c[2, :] = np.array(np.hstack((-1.0, -1.0, 0.0, backwardcostmult)))
|
||||
# %1/16 theta change
|
||||
basemprimendpts45_c[3, :] = np.array(np.hstack((5.0, 7.0, 1.0, forwardandturncostmult)))
|
||||
basemprimendpts45_c[4, :] = np.array(np.hstack((7.0, 5.0, -1.0, forwardandturncostmult)))
|
||||
# %turn in place
|
||||
basemprimendpts45_c[5, :] = np.array(np.hstack((0.0, 0.0, 1.0, turninplacecostmult)))
|
||||
basemprimendpts45_c[6, :] = np.array(np.hstack((0.0, 0.0, -1.0, turninplacecostmult)))
|
||||
# %22.5 degrees
|
||||
basemprimendpts22p5_c = np.zeros((numberofprimsperangle, 4))
|
||||
# %x,y,theta,costmult (multiplier is used as costmult*cost)
|
||||
# %x aligned with the heading of the robot, angles are positive
|
||||
# %counterclockwise
|
||||
# %0 theta change
|
||||
basemprimendpts22p5_c[0, :] = np.array(np.hstack((2.0, 1.0, 0.0, forwardcostmult)))
|
||||
basemprimendpts22p5_c[1, :] = np.array(np.hstack((6.0, 3.0, 0.0, forwardcostmult)))
|
||||
basemprimendpts22p5_c[2, :] = np.array(np.hstack((-2.0, -1.0, 0.0, backwardcostmult)))
|
||||
# %1/16 theta change
|
||||
basemprimendpts22p5_c[3, :] = np.array(np.hstack((5.0, 4.0, 1.0, forwardandturncostmult)))
|
||||
basemprimendpts22p5_c[4, :] = np.array(np.hstack((7.0, 2.0, -1.0, forwardandturncostmult)))
|
||||
# %turn in place
|
||||
basemprimendpts22p5_c[5, :] = np.array(np.hstack((0.0, 0.0, 1.0, turninplacecostmult)))
|
||||
basemprimendpts22p5_c[6, :] = np.array(np.hstack((0.0, 0.0, -1.0, turninplacecostmult)))
|
||||
else:
|
||||
print('ERROR: undefined mprims type\n')
|
||||
return []
|
||||
|
||||
fout = open(outfilename, 'w')
|
||||
# %write the header
|
||||
fout.write('resolution_m: %f\n' % (resolution))
|
||||
fout.write('numberofangles: %d\n' % (numberofangles))
|
||||
fout.write('totalnumberofprimitives: %d\n' % (numberofprimsperangle * numberofangles))
|
||||
# %iterate over angles
|
||||
for angleind in np.arange(1.0, (numberofangles) + 1):
|
||||
currentangle = ((angleind - 1) * 2.0 * np.pi) / numberofangles
|
||||
currentangle_36000int = np.round((angleind - 1) * 36000.0 / numberofangles)
|
||||
if visualize:
|
||||
if separate_plots:
|
||||
fig = plt.figure(angleind)
|
||||
plt.title('angle {:2.0f} (= {:3.1f} degrees)'.format(angleind - 1, currentangle_36000int / 100.0))
|
||||
else:
|
||||
fig = plt.figure(1)
|
||||
|
||||
plt.axis('equal')
|
||||
plt.axis([-10 * resolution, 10 * resolution, -10 * resolution, 10 * resolution])
|
||||
ax = fig.add_subplot(1, 1, 1)
|
||||
major_ticks = np.arange(-8 * resolution, 9 * resolution, 4 * resolution)
|
||||
minor_ticks = np.arange(-8 * resolution, 9 * resolution, resolution)
|
||||
ax.set_xticks(major_ticks)
|
||||
ax.set_xticks(minor_ticks, minor=True)
|
||||
ax.set_yticks(major_ticks)
|
||||
ax.set_yticks(minor_ticks, minor=True)
|
||||
ax.grid(which='minor', alpha=0.5)
|
||||
ax.grid(which='major', alpha=0.9)
|
||||
|
||||
# %iterate over primitives
|
||||
for primind in np.arange(1.0, (numberofprimsperangle) + 1):
|
||||
fout.write('primID: %d\n' % (primind - 1))
|
||||
fout.write('startangle_c: %d\n' % (angleind - 1))
|
||||
# %current angle
|
||||
# %compute which template to use
|
||||
if (currentangle_36000int % 9000) == 0:
|
||||
basemprimendpts_c = basemprimendpts0_c[int(primind) - 1, :]
|
||||
angle = currentangle
|
||||
elif (currentangle_36000int % 4500) == 0:
|
||||
basemprimendpts_c = basemprimendpts45_c[int(primind) - 1, :]
|
||||
angle = currentangle - 45.0 * np.pi / 180.0
|
||||
|
||||
# commented out because basemprimendpts33p75_c is undefined
|
||||
# elif ((currentangle_36000int - 7875) % 9000) == 0:
|
||||
# basemprimendpts_c = (
|
||||
# 1 * basemprimendpts33p75_c[primind, :]
|
||||
# ) # 1* to force deep copy to avoid reference update below
|
||||
# basemprimendpts_c[0] = basemprimendpts33p75_c[primind, 1]
|
||||
# # %reverse x and y
|
||||
# basemprimendpts_c[1] = basemprimendpts33p75_c[primind, 0]
|
||||
# basemprimendpts_c[2] = -basemprimendpts33p75_c[primind, 2]
|
||||
# # %reverse the angle as well
|
||||
# angle = currentangle - (78.75 * np.pi) / 180.0
|
||||
# print('78p75\n')
|
||||
|
||||
elif ((currentangle_36000int - 6750) % 9000) == 0:
|
||||
basemprimendpts_c = (
|
||||
1 * basemprimendpts22p5_c[int(primind) - 1, :]
|
||||
) # 1* to force deep copy to avoid reference update below
|
||||
basemprimendpts_c[0] = basemprimendpts22p5_c[int(primind) - 1, 1]
|
||||
# %reverse x and y
|
||||
basemprimendpts_c[1] = basemprimendpts22p5_c[int(primind) - 1, 0]
|
||||
basemprimendpts_c[2] = -basemprimendpts22p5_c[int(primind) - 1, 2]
|
||||
# %reverse the angle as well
|
||||
# print(
|
||||
# '%d : %d %d %d onto %d %d %d\n'
|
||||
# % (
|
||||
# primind - 1,
|
||||
# basemprimendpts22p5_c[int(primind) - 1, 0],
|
||||
# basemprimendpts22p5_c[int(primind) - 1, 1],
|
||||
# basemprimendpts22p5_c[int(primind) - 1, 2],
|
||||
# basemprimendpts_c[0],
|
||||
# basemprimendpts_c[1],
|
||||
# basemprimendpts_c[2],
|
||||
# )
|
||||
# )
|
||||
angle = currentangle - (67.5 * np.pi) / 180.0
|
||||
print('67p5\n')
|
||||
|
||||
# commented out because basemprimendpts11p25_c is undefined
|
||||
# elif ((currentangle_36000int - 5625) % 9000) == 0:
|
||||
# basemprimendpts_c = (
|
||||
# 1 * basemprimendpts11p25_c[primind, :]
|
||||
# ) # 1* to force deep copy to avoid reference update below
|
||||
# basemprimendpts_c[0] = basemprimendpts11p25_c[primind, 1]
|
||||
# # %reverse x and y
|
||||
# basemprimendpts_c[1] = basemprimendpts11p25_c[primind, 0]
|
||||
# basemprimendpts_c[2] = -basemprimendpts11p25_c[primind, 2]
|
||||
# # %reverse the angle as well
|
||||
# angle = currentangle - (56.25 * np.pi) / 180.0
|
||||
# print('56p25\n')
|
||||
|
||||
# commented out because basemprimendpts33p75_c is undefined
|
||||
# elif ((currentangle_36000int - 3375) % 9000) == 0:
|
||||
# basemprimendpts_c = basemprimendpts33p75_c[int(primind), :]
|
||||
# angle = currentangle - (33.75 * np.pi) / 180.0
|
||||
# print('33p75\n')
|
||||
|
||||
elif ((currentangle_36000int - 2250) % 9000) == 0:
|
||||
basemprimendpts_c = basemprimendpts22p5_c[int(primind) - 1, :]
|
||||
angle = currentangle - (22.5 * np.pi) / 180.0
|
||||
print('22p5\n')
|
||||
|
||||
# commented out because basemprimendpts11p25_c is undefined
|
||||
# elif ((currentangle_36000int - 1125) % 9000) == 0:
|
||||
# basemprimendpts_c = basemprimendpts11p25_c[int(primind), :]
|
||||
# angle = currentangle - (11.25 * np.pi) / 180.0
|
||||
# print('11p25\n')
|
||||
|
||||
else:
|
||||
print('ERROR: invalid angular resolution. angle = %d\n' % currentangle_36000int)
|
||||
return []
|
||||
|
||||
# %now figure out what action will be
|
||||
baseendpose_c = basemprimendpts_c[0:3]
|
||||
additionalactioncostmult = basemprimendpts_c[3]
|
||||
endx_c = np.round((baseendpose_c[0] * np.cos(angle)) - (baseendpose_c[1] * np.sin(angle)))
|
||||
endy_c = np.round((baseendpose_c[0] * np.sin(angle)) + (baseendpose_c[1] * np.cos(angle)))
|
||||
endtheta_c = np.fmod(angleind - 1 + baseendpose_c[2], numberofangles)
|
||||
endpose_c = np.array(np.hstack((endx_c, endy_c, endtheta_c)))
|
||||
print("endpose_c=", endpose_c)
|
||||
print(('rotation angle=%f\n' % (angle * 180.0 / np.pi)))
|
||||
# if np.logical_and(baseendpose_c[1] == 0., baseendpose_c[2] == 0.):
|
||||
# %fprintf(1, 'endpose=%d %d %d\n', endpose_c(1), endpose_c(2), endpose_c(3));
|
||||
|
||||
# %generate intermediate poses (remember they are w.r.t 0,0 (and not
|
||||
# %centers of the cells)
|
||||
numofsamples = 10
|
||||
intermcells_m = np.zeros((numofsamples, 3))
|
||||
if UNICYCLE_MPRIM_16DEGS == 1.0:
|
||||
startpt = np.array(np.hstack((0.0, 0.0, currentangle)))
|
||||
endpt = np.array(
|
||||
np.hstack(
|
||||
(
|
||||
(endpose_c[0] * resolution),
|
||||
(endpose_c[1] * resolution),
|
||||
(
|
||||
((np.fmod(angleind - 1 + baseendpose_c[2], numberofangles)) * 2.0 * np.pi)
|
||||
/ numberofangles
|
||||
),
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
print("startpt =", startpt)
|
||||
print("endpt =", endpt)
|
||||
intermcells_m = np.zeros((numofsamples, 3))
|
||||
if np.logical_or(np.logical_and(endx_c == 0.0, endy_c == 0.0), baseendpose_c[2] == 0.0):
|
||||
# %turn in place or move forward
|
||||
for iind in np.arange(1.0, (numofsamples) + 1):
|
||||
fraction = float(iind - 1) / (numofsamples - 1)
|
||||
intermcells_m[int(iind) - 1, :] = np.array(
|
||||
(
|
||||
startpt[0] + (endpt[0] - startpt[0]) * fraction,
|
||||
startpt[1] + (endpt[1] - startpt[1]) * fraction,
|
||||
0,
|
||||
)
|
||||
)
|
||||
rotation_angle = baseendpose_c[2] * (2.0 * np.pi / numberofangles)
|
||||
intermcells_m[int(iind) - 1, 2] = np.fmod(startpt[2] + rotation_angle * fraction, (2.0 * np.pi))
|
||||
# print " ",iind," of ",numofsamples," fraction=",fraction," rotation=",rotation_angle
|
||||
|
||||
else:
|
||||
# %unicycle-based move forward or backward (http://sbpl.net/node/53)
|
||||
R = np.array(
|
||||
np.vstack(
|
||||
(
|
||||
np.hstack((np.cos(startpt[2]), np.sin(endpt[2]) - np.sin(startpt[2]))),
|
||||
np.hstack((np.sin(startpt[2]), -np.cos(endpt[2]) + np.cos(startpt[2]))),
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
S = np.dot(np.linalg.pinv(R), np.array(np.vstack((endpt[0] - startpt[0], endpt[1] - startpt[1]))))
|
||||
l = S[0]
|
||||
tvoverrv = S[1]
|
||||
rv = (baseendpose_c[2] * 2.0 * np.pi / numberofangles) + l / tvoverrv
|
||||
tv = tvoverrv * rv
|
||||
|
||||
# print "R=\n",R
|
||||
# print "Rpi=\n",np.linalg.pinv(R)
|
||||
# print "S=\n",S
|
||||
# print "l=",l
|
||||
# print "tvoverrv=",tvoverrv
|
||||
# print "rv=",rv
|
||||
# print "tv=",tv
|
||||
|
||||
if l < 0.0:
|
||||
print(('WARNING: l = %f < 0 -> bad action start/end points\n' % (l)))
|
||||
l = 0.0
|
||||
|
||||
# %compute rv
|
||||
# %rv = baseendpose_c(3)*2*pi/numberofangles;
|
||||
# %compute tv
|
||||
# %tvx = (endpt(1) - startpt(1))*rv/(sin(endpt(3)) - sin(startpt(3)))
|
||||
# %tvy = -(endpt(2) - startpt(2))*rv/(cos(endpt(3)) - cos(startpt(3)))
|
||||
# %tv = (tvx + tvy)/2.0;
|
||||
# %generate samples
|
||||
for iind in np.arange(1, numofsamples + 1):
|
||||
dt = (iind - 1) / (numofsamples - 1)
|
||||
# %dtheta = rv*dt + startpt(3);
|
||||
# %intermcells_m(iind,:) = [startpt(1) + tv/rv*(sin(dtheta) - sin(startpt(3))) ...
|
||||
# % startpt(2) - tv/rv*(cos(dtheta) - cos(startpt(3))) ...
|
||||
# % dtheta];
|
||||
if (dt * tv) < l:
|
||||
intermcells_m[int(iind) - 1, :] = np.array(
|
||||
np.hstack(
|
||||
(
|
||||
startpt[0] + dt * tv * np.cos(startpt[2]),
|
||||
startpt[1] + dt * tv * np.sin(startpt[2]),
|
||||
startpt[2],
|
||||
)
|
||||
)
|
||||
)
|
||||
else:
|
||||
dtheta = rv * (dt - l / tv) + startpt[2]
|
||||
intermcells_m[int(iind) - 1, :] = np.array(
|
||||
np.hstack(
|
||||
(
|
||||
startpt[0]
|
||||
+ l * np.cos(startpt[2])
|
||||
+ tvoverrv * (np.sin(dtheta) - np.sin(startpt[2])),
|
||||
startpt[1]
|
||||
+ l * np.sin(startpt[2])
|
||||
- tvoverrv * (np.cos(dtheta) - np.cos(startpt[2])),
|
||||
dtheta,
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
# %correct
|
||||
errorxy = np.array(
|
||||
np.hstack(
|
||||
(
|
||||
endpt[0] - intermcells_m[int(numofsamples) - 1, 0],
|
||||
endpt[1] - intermcells_m[int(numofsamples) - 1, 1],
|
||||
)
|
||||
)
|
||||
)
|
||||
# print('l=%f errx=%f erry=%f\n'%(l, errorxy[0], errorxy[1]))
|
||||
interpfactor = np.array(
|
||||
np.hstack((np.arange(0.0, 1.0 + (1.0 / (numofsamples)), 1.0 / (numofsamples - 1))))
|
||||
)
|
||||
|
||||
# print "intermcells_m=",intermcells_m
|
||||
# print "interp'=",interpfactor.conj().T
|
||||
|
||||
intermcells_m[:, 0] = intermcells_m[:, 0] + errorxy[0] * interpfactor.conj().T
|
||||
intermcells_m[:, 1] = intermcells_m[:, 1] + errorxy[1] * interpfactor.conj().T
|
||||
|
||||
# %write out
|
||||
fout.write('endpose_c: %d %d %d\n' % (endpose_c[0], endpose_c[1], endpose_c[2]))
|
||||
fout.write('additionalactioncostmult: %d\n' % (additionalactioncostmult))
|
||||
fout.write('intermediateposes: %d\n' % (matrix_size(intermcells_m, 1.0)))
|
||||
for interind in np.arange(1.0, (matrix_size(intermcells_m, 1.0)) + 1):
|
||||
fout.write(
|
||||
'%.4f %.4f %.4f\n'
|
||||
% (
|
||||
intermcells_m[int(interind) - 1, 0],
|
||||
intermcells_m[int(interind) - 1, 1],
|
||||
intermcells_m[int(interind) - 1, 2],
|
||||
)
|
||||
)
|
||||
|
||||
if visualize:
|
||||
plt.plot(intermcells_m[:, 0], intermcells_m[:, 1], linestyle="-", marker="o")
|
||||
plt.text(endpt[0], endpt[1], '{:2.0f}'.format(endpose_c[2]))
|
||||
# if (visualize):
|
||||
# plt.waitforbuttonpress() # uncomment to plot each primitive set one at a time
|
||||
|
||||
fout.close()
|
||||
if visualize:
|
||||
# plt.waitforbuttonpress() # hold until buttom pressed
|
||||
plt.show() # Keep windows open until the program is terminated
|
||||
return []
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
rospack = rospkg.RosPack()
|
||||
outfilename = rospack.get_path('mir_navigation') + '/mprim/unicycle_highcost_5cm.mprim'
|
||||
genmprim_unicycle(outfilename, visualize=True)
|
||||
36
config/runtime/mprim/localization.yaml
Normal file
36
config/runtime/mprim/localization.yaml
Normal file
@@ -0,0 +1,36 @@
|
||||
Amcl:
|
||||
use_map_topic: true
|
||||
odom_model_type: "diff-corrected"
|
||||
gui_publish_rate: 5.0
|
||||
save_pose_rate: 0.5
|
||||
laser_max_beams: 300
|
||||
laser_min_range: -1.0
|
||||
laser_max_range: -1.0
|
||||
min_particles: 1000
|
||||
max_particles: 3000
|
||||
kld_err: 0.05
|
||||
kld_z: 0.99
|
||||
odom_alpha1: 0.02
|
||||
odom_alpha2: 0.01
|
||||
odom_alpha3: 0.01
|
||||
odom_alpha4: 0.02
|
||||
laser_z_hit: 0.5
|
||||
laser_z_short: 0.05
|
||||
laser_z_max: 0.05
|
||||
laser_z_rand: 0.5
|
||||
laser_sigma_hit: 0.2
|
||||
laser_lambda_short: 0.1
|
||||
laser_model_type: "likelihood_field"
|
||||
laser_likelihood_max_dist: 1.0
|
||||
update_min_d: 0.05
|
||||
update_min_a: 0.05
|
||||
odom_frame_id: odom
|
||||
base_frame_id: base_link
|
||||
global_frame_id: map
|
||||
resample_interval: 1
|
||||
transform_tolerance: 0.2
|
||||
recovery_alpha_slow: 0.001
|
||||
recovery_alpha_fast: 0.001
|
||||
initial_pose_x: 0.0
|
||||
initial_pose_y: 0.0
|
||||
initial_pose_a: 0.0
|
||||
63
config/runtime/mprim/mapping.yaml
Normal file
63
config/runtime/mprim/mapping.yaml
Normal file
@@ -0,0 +1,63 @@
|
||||
SlamToolBox:
|
||||
# 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
|
||||
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
|
||||
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
|
||||
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
|
||||
106
config/runtime/mprim/mpc_local_planner_params.yaml
Normal file
106
config/runtime/mprim/mpc_local_planner_params.yaml
Normal file
@@ -0,0 +1,106 @@
|
||||
base_local_planner: mpc_local_planner/MpcLocalPlannerROS
|
||||
MpcLocalPlannerROS:
|
||||
|
||||
odom_topic: odom
|
||||
|
||||
## Robot settings
|
||||
robot:
|
||||
type: "unicycle"
|
||||
unicycle:
|
||||
max_vel_x: 0.5
|
||||
max_vel_x_backwards: 0.3
|
||||
max_vel_theta: 0.3
|
||||
acc_lim_x: 0.4 # deactive bounds with zero
|
||||
dec_lim_x: 0.4 # deactive bounds with zero
|
||||
acc_lim_theta: 0.6 # deactivate bounds with zero
|
||||
|
||||
## Footprint model for collision avoidance
|
||||
footprint_model:
|
||||
type: "point"
|
||||
is_footprint_dynamic: False
|
||||
|
||||
## Collision avoidance
|
||||
collision_avoidance:
|
||||
min_obstacle_dist: 0.5 # Note, this parameter must be chosen w.r.t. the footprint_model
|
||||
enable_dynamic_obstacles: False
|
||||
force_inclusion_dist: 0.5
|
||||
cutoff_dist: 2.0
|
||||
include_costmap_obstacles: True
|
||||
costmap_obstacles_behind_robot_dist: 1.5
|
||||
collision_check_no_poses: 5
|
||||
|
||||
## Planning grid
|
||||
grid:
|
||||
type: "fd_grid"
|
||||
grid_size_ref: 20 # Set horizon length here (T = (grid_size_ref-1) * dt_ref); Note, also check max_global_plan_lookahead_dist
|
||||
dt_ref: 0.3 # and here the corresponding temporal resolution
|
||||
xf_fixed: [False, False, False] # Unfix final state -> we use terminal cost below
|
||||
warm_start: True
|
||||
collocation_method: "forward_differences"
|
||||
cost_integration_method: "left_sum"
|
||||
variable_grid:
|
||||
enable: False # We want a fixed grid
|
||||
min_dt: 0.0;
|
||||
max_dt: 10.0;
|
||||
grid_adaptation:
|
||||
enable: True
|
||||
dt_hyst_ratio: 0.1
|
||||
min_grid_size: 2
|
||||
max_grid_size: 50
|
||||
|
||||
## Planning options
|
||||
planning:
|
||||
objective:
|
||||
type: "quadratic_form" # minimum_time requires grid/variable_grid/enable=True and grid/xf_fixed set properly
|
||||
quadratic_form:
|
||||
state_weights: [2.0, 2.0, 0.25]
|
||||
control_weights: [0.1, 0.05]
|
||||
integral_form: False
|
||||
terminal_cost:
|
||||
type: "quadratic" # can be "none"
|
||||
quadratic:
|
||||
final_state_weights: [10.0, 10.0, 0.5]
|
||||
terminal_constraint:
|
||||
type: "none" # can be "none"
|
||||
l2_ball:
|
||||
weight_matrix: [1.0, 1.0, 1.0]
|
||||
radius: 5
|
||||
|
||||
## Controller options
|
||||
controller:
|
||||
outer_ocp_iterations: 1
|
||||
xy_goal_tolerance: 0.05
|
||||
yaw_goal_tolerance: 0.04
|
||||
global_plan_overwrite_orientation: False
|
||||
global_plan_prune_distance: 1.5
|
||||
allow_init_with_backward_motion: True
|
||||
max_global_plan_lookahead_dist: 1.0 # Check horizon length
|
||||
force_reinit_new_goal_dist: 1.0
|
||||
force_reinit_new_goal_angular: 1.57
|
||||
force_reinit_num_steps: 0
|
||||
prefer_x_feedback: False
|
||||
publish_ocp_results: True
|
||||
|
||||
## Solver settings
|
||||
solver:
|
||||
type: "ipopt"
|
||||
ipopt:
|
||||
iterations: 100
|
||||
max_cpu_time: -1.0
|
||||
ipopt_numeric_options:
|
||||
tol: 1e-3
|
||||
ipopt_string_options:
|
||||
linear_solver: "mumps"
|
||||
hessian_approximation: "exact" # exact or limited-memory
|
||||
lsq_lm:
|
||||
iterations: 10
|
||||
weight_init_eq: 2
|
||||
weight_init_ineq: 2
|
||||
weight_init_bounds: 2
|
||||
weight_adapt_factor_eq: 1.5
|
||||
weight_adapt_factor_ineq: 1.5
|
||||
weight_adapt_factor_bounds: 1.5
|
||||
weight_adapt_max_eq: 500
|
||||
weight_adapt_max_ineq: 500
|
||||
weight_adapt_max_bounds: 500
|
||||
|
||||
8
config/runtime/mprim/mqtt_general.yaml
Normal file
8
config/runtime/mprim/mqtt_general.yaml
Normal file
@@ -0,0 +1,8 @@
|
||||
# MQTT:
|
||||
# Name: T800
|
||||
# Host: 172.20.235.170
|
||||
# Port: 1885
|
||||
# Client_ID: T800
|
||||
# Username: robotics
|
||||
# Password: robotics
|
||||
# Keep_Alive: 60
|
||||
71
config/runtime/mprim/ros_diff_drive_controller.yaml
Normal file
71
config/runtime/mprim/ros_diff_drive_controller.yaml
Normal file
@@ -0,0 +1,71 @@
|
||||
# -----------------------------------
|
||||
left_wheel : 'left_wheel_joint'
|
||||
right_wheel : 'right_wheel_joint'
|
||||
publish_rate: 50 # this is what the real MiR platform publishes (default: 50)
|
||||
# These covariances are exactly what the real MiR platform publishes
|
||||
pose_covariance_diagonal : [0.00001, 0.00001, 1000000.0, 1000000.0, 1000000.0, 1000.0]
|
||||
twist_covariance_diagonal: [0.1, 0.1, 1000000.0, 1000000.0, 1000000.0, 1000.0]
|
||||
enable_odom_tf: true
|
||||
enable_wheel_tf: true
|
||||
allow_multiple_cmd_vel_publishers: true
|
||||
# open_loop: false
|
||||
# Wheel separation and diameter. These are both optional.
|
||||
# diff_drive_controller will attempt to read either one or both from the
|
||||
# URDF if not specified as a parameter.
|
||||
# We don't set the value here because it's different for each MiR type (100, 250, ...), and
|
||||
# the plugin figures out the correct values.
|
||||
wheel_separation : 0.5106
|
||||
wheel_radius : 0.1
|
||||
|
||||
# Wheel separation and radius multipliers
|
||||
wheel_separation_multiplier: 1.0 # default: 1.0
|
||||
wheel_radius_multiplier : 1.0 # default: 1.0
|
||||
|
||||
# Velocity commands timeout [s], default 0.5
|
||||
cmd_vel_timeout: 1.0
|
||||
|
||||
# frame_ids (same as real MiR platform)
|
||||
base_frame_id: base_link # default: base_link base_link
|
||||
odom_frame_id: odom # default: odom
|
||||
|
||||
# Velocity and acceleration limits
|
||||
# Whenever a min_* is unspecified, default to -max_*
|
||||
linear:
|
||||
x:
|
||||
has_velocity_limits : true
|
||||
max_velocity : 1.5 # m/s; move_base max_vel_x: 0.8
|
||||
min_velocity : -1.5 # m/s
|
||||
has_acceleration_limits: true
|
||||
max_acceleration : 0.5 # m/s^2; move_base acc_lim_x: 1.5
|
||||
min_acceleration : -0.5 # m/s^2
|
||||
has_jerk_limits : true
|
||||
max_jerk : 3.0 # m/s^3
|
||||
angular:
|
||||
z:
|
||||
has_velocity_limits : true
|
||||
max_velocity : 1.0 # rad/s; move_base max_rot_vel: 1.0
|
||||
min_velocity : -1.0
|
||||
has_acceleration_limits: true
|
||||
max_acceleration : 3.0 # rad/s^2; move_base acc_lim_th: 2.0
|
||||
has_jerk_limits : true
|
||||
max_jerk : 2.5 # rad/s^3
|
||||
|
||||
left_wheel_joint:
|
||||
lookup_name: WheelPlugin
|
||||
max_publish_rate: 50
|
||||
mesurement_topic: left_encoder
|
||||
frame_id: left_wheel_link
|
||||
wheel_topic: /left_wheel
|
||||
subscribe_queue_size: 1
|
||||
command_timeout: 5.0
|
||||
origin : [0.0, 0.255, 0.075, 0.0, 0.0, 0.0] # origin from base_frame_id
|
||||
|
||||
right_wheel_joint:
|
||||
lookup_name: WheelPlugin
|
||||
max_publish_rate: 50
|
||||
mesurement_topic: right_encoder
|
||||
frame_id: right_wheel_link
|
||||
wheel_topic: /right_wheel
|
||||
subscribe_queue_size: 1
|
||||
command_timeout: 5.0
|
||||
origin : [0.0, -0.255, 0.075, 0.0, 0.0, 0.0] # origin from base_frame_id
|
||||
10
config/runtime/mprim/sbpl_global_params.yaml
Normal file
10
config/runtime/mprim/sbpl_global_params.yaml
Normal file
@@ -0,0 +1,10 @@
|
||||
base_global_planner: SBPLLatticePlanner
|
||||
SBPLLatticePlanner:
|
||||
environment_type: XYThetaLattice
|
||||
planner_type: ARAPlanner
|
||||
allocated_time: 10.0
|
||||
initial_epsilon: 1.0
|
||||
force_scratch_limit: 10000
|
||||
forward_search: true
|
||||
nominalvel_mpersecs: 0.2
|
||||
timetoturn45degsinplace_secs: 0.6 # = 0.6 rad/s
|
||||
61
config/runtime/mprim/sick_line_guidance_mls.yaml
Normal file
61
config/runtime/mprim/sick_line_guidance_mls.yaml
Normal file
@@ -0,0 +1,61 @@
|
||||
bus:
|
||||
device: can0
|
||||
driver_plugin: can::SocketCANInterface
|
||||
master_allocator: canopen::SimpleMaster::Allocator
|
||||
sync:
|
||||
interval_ms: 10
|
||||
overflow: 0
|
||||
#
|
||||
# heartbeat: # simple heartbeat producer (optional, not supported by OLS or MLS, do not enable heartbeats)
|
||||
# rate: 100 # heartbeat rate (1/rate in seconds)
|
||||
# msg: "77f#05" # message to send, cansend format: heartbeat of node 127 with status 5=Started
|
||||
nodes:
|
||||
f_mlse:
|
||||
id: 0x01 # CAN-Node-ID of can device, default: Node-ID 10=0x0A for OLS and MLS
|
||||
eds_pkg: sick_line_guidance # package name for relative path
|
||||
eds_file: mls/SICK-MLS.eds # path to EDS/DCF file
|
||||
publish: ["1001","1018sub1","1018sub4","2021sub1!","2021sub2!","2021sub3!","2021sub4!","2022!"]
|
||||
# MLS: 1001 = error register, 1018sub1 = VendorID, 1018sub4 = SerialNumber, TPDO1 = 0x2021sub1 to 0x2021sub4 and 0x2022
|
||||
|
||||
# sick_line_guidance configuration of this node:
|
||||
sick_device_family: "MLS" # can devices of OLS10, OLS20 or MLS family currently supported
|
||||
sick_topic: "f_mlse" # MLS_Measurement messages are published in topic "/mls"
|
||||
subscribe_queue_size: 1
|
||||
sick_frame_id: "f_mlse" # MLS_Measurement messages are published frame_id "mls_measurement_frame"
|
||||
|
||||
# device configuration of writable parameter by dcf_overlay: "objectindex": "parametervalue"
|
||||
# example: "2027": "0x01" # Object 2027 (sensorFlipped, defaultvalue 0x00) will be configured with value 0x01
|
||||
# dcf_overlay:
|
||||
# "2028sub1": "0x01" # UseMarkers (0 = disable marker detection, 1 = enable marker detection), UINT8, DataType=0x0005, defaultvalue=0
|
||||
# "2028sub2": "0x02" # MarkerStyle (0 = disable marker detection, 1 = standard mode, 2 = extended mode), UINT8, DataType=0x0005, defaultvalue=0
|
||||
# "2028sub3": "0x01" # FailSafeMode (0 = disabled, 1 = enabled), UINT8, DataType=0x0005, defaultvalue=0
|
||||
# "2025": "1000" # Min.Level, UINT16, DataType=0x0006, defaultvalue=600
|
||||
# "2026": "1" # Offset [mm] Nullpunkt, INT16, DataType=0x0003, defaultvalue=0
|
||||
# "2027": "0x01" # sensorFlipped, UINT8, DataType=0x0005, defaultvalue=0
|
||||
# "2029": "0x01" # LockTeach, UINT8, DataType=0x0005, defaultvalue=0
|
||||
#
|
||||
|
||||
b_mlse:
|
||||
id: 0x02 # CAN-Node-ID of can device, default: Node-ID 10=0x0A for OLS and MLS
|
||||
eds_pkg: sick_line_guidance # package name for relative path
|
||||
eds_file: mls/SICK-MLS.eds # path to EDS/DCF file
|
||||
publish: ["1001","1018sub1","1018sub4","2021sub1!","2021sub2!","2021sub3!","2021sub4!","2022!"]
|
||||
# MLS: 1001 = error register, 1018sub1 = VendorID, 1018sub4 = SerialNumber, TPDO1 = 0x2021sub1 to 0x2021sub4 and 0x2022
|
||||
|
||||
# sick_line_guidance configuration of this node:
|
||||
sick_device_family: "MLS" # can devices of OLS10, OLS20 or MLS family currently supported
|
||||
sick_topic: "b_mlse" # MLS_Measurement messages are published in topic "/mls"
|
||||
subscribe_queue_size: 1
|
||||
sick_frame_id: "b_mlse" # MLS_Measurement messages are published frame_id "mls_measurement_frame"
|
||||
|
||||
# device configuration of writable parameter by dcf_overlay: "objectindex": "parametervalue"
|
||||
# example: "2027": "0x01" # Object 2027 (sensorFlipped, defaultvalue 0x00) will be configured with value 0x01
|
||||
# dcf_overlay:
|
||||
# "2028sub1": "0x01" # UseMarkers (0 = disable marker detection, 1 = enable marker detection), UINT8, DataType=0x0005, defaultvalue=0
|
||||
# "2028sub2": "0x02" # MarkerStyle (0 = disable marker detection, 1 = standard mode, 2 = extended mode), UINT8, DataType=0x0005, defaultvalue=0
|
||||
# "2028sub3": "0x01" # FailSafeMode (0 = disabled, 1 = enabled), UINT8, DataType=0x0005, defaultvalue=0
|
||||
# "2025": "1000" # Min.Level, UINT16, DataType=0x0006, defaultvalue=600
|
||||
# "2026": "1" # Offset [mm] Nullpunkt, INT16, DataType=0x0003, defaultvalue=0
|
||||
# "2027": "0x01" # sensorFlipped, UINT8, DataType=0x0005, defaultvalue=0
|
||||
# "2029": "0x01" # LockTeach, UINT8, DataType=0x0005, defaultvalue=0
|
||||
#
|
||||
1203
config/runtime/mprim/unicycle_5cm.mprim
Normal file
1203
config/runtime/mprim/unicycle_5cm.mprim
Normal file
File diff suppressed because it is too large
Load Diff
1683
config/runtime/mprim/unicycle_5cm_expensive_turn_in_place.mprim
Normal file
1683
config/runtime/mprim/unicycle_5cm_expensive_turn_in_place.mprim
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
2403
config/runtime/mprim/unicycle_5cm_noreverse_trolley.mprim
Normal file
2403
config/runtime/mprim/unicycle_5cm_noreverse_trolley.mprim
Normal file
File diff suppressed because it is too large
Load Diff
1683
config/runtime/mprim/unicycle_highcost_10cm.mprim
Normal file
1683
config/runtime/mprim/unicycle_highcost_10cm.mprim
Normal file
File diff suppressed because it is too large
Load Diff
1683
config/runtime/mprim/unicycle_highcost_1cm.mprim
Normal file
1683
config/runtime/mprim/unicycle_highcost_1cm.mprim
Normal file
File diff suppressed because it is too large
Load Diff
1683
config/runtime/mprim/unicycle_highcost_2_5cm.mprim
Normal file
1683
config/runtime/mprim/unicycle_highcost_2_5cm.mprim
Normal file
File diff suppressed because it is too large
Load Diff
1683
config/runtime/mprim/unicycle_highcost_2cm.mprim
Normal file
1683
config/runtime/mprim/unicycle_highcost_2cm.mprim
Normal file
File diff suppressed because it is too large
Load Diff
1683
config/runtime/mprim/unicycle_highcost_5cm.mprim
Normal file
1683
config/runtime/mprim/unicycle_highcost_5cm.mprim
Normal file
File diff suppressed because it is too large
Load Diff
203
config/runtime/pnkx_local_planner_params.yaml
Normal file
203
config/runtime/pnkx_local_planner_params.yaml
Normal file
@@ -0,0 +1,203 @@
|
||||
yaw_goal_tolerance: 0.02
|
||||
xy_goal_tolerance: 0.03
|
||||
min_approach_linear_velocity: 0.05
|
||||
|
||||
LocalPlannerAdapter:
|
||||
library_path: liblocal_planner_adapter
|
||||
PNKXLocalPlanner:
|
||||
# Thuật toán
|
||||
library_path: libpnkx_local_planner
|
||||
trajectory_generator_name: LimitedAccelGenerator
|
||||
algorithm_nav_name: MKTAlgorithmDiffPredictiveTrajectory
|
||||
algorithm_rotate_name: MKTAlgorithmDiffRotateToGoal
|
||||
# Bộ kiểm tra đã tới goal
|
||||
goal_checker_name: GoalChecker
|
||||
|
||||
PNKXDockingLocalPlanner:
|
||||
# Thuật toán
|
||||
library_path: libpnkx_local_planner
|
||||
trajectory_generator_name: LimitedAccelGenerator
|
||||
algorithm_nav_name: MKTAlgorithmDiffPredictiveTrajectory
|
||||
algorithm_rotate_name: MKTAlgorithmDiffRotateToGoal
|
||||
# Bộ kiểm tra đã tới goal
|
||||
goal_checker_name: GoalChecker
|
||||
|
||||
PNKXGoStraightLocalPlanner:
|
||||
# Thuật toán
|
||||
library_path: libpnkx_local_planner
|
||||
trajectory_generator_name: LimitedAccelGenerator
|
||||
algorithm_nav_name: MKTAlgorithmDiffGoStraight
|
||||
# Bộ kiểm tra đã tới goal
|
||||
goal_checker_name: GoalChecker
|
||||
|
||||
PNKXRotateLocalPlanner:
|
||||
# Thuật toán
|
||||
library_path: libpnkx_local_planner
|
||||
algorithm_rotate_name: MKTAlgorithmDiffRotateToGoal
|
||||
trajectory_generator_name: LimitedAccelGenerator
|
||||
# Bộ kiểm tra đã tới goal
|
||||
goal_checker_name: SimpleGoalChecker
|
||||
stateful: true
|
||||
|
||||
LimitedAccelGenerator:
|
||||
library_path: libmkt_plugins_standard_traj_generator
|
||||
max_vel_x: 1.2
|
||||
min_vel_x: -1.2
|
||||
|
||||
max_vel_y: 0.0 # robot vi sai: không có chuyển động ngang
|
||||
min_vel_y: 0.0 # robot vi sai: không có chuyển động ngang
|
||||
|
||||
max_speed_xy: 2.0 # [m/s] trần tốc độ tịnh tiến. Đặt thấp hơn khả năng thật của base một chút
|
||||
min_speed_xy: 0.25 # [m/s] tốc độ tịnh tiến tối thiểu khi gần như không quay
|
||||
|
||||
max_vel_theta: 0.4 # [rad/s] trần tốc độ quay. Đặt thấp hơn khả năng thật của base một chút
|
||||
min_vel_theta: 0.05 # [rad/s] tốc độ quay tối thiểu khi gần như không tịnh tiến
|
||||
|
||||
acc_lim_x: 3.0
|
||||
acc_lim_y: 0.0 # robot vi sai: không có chuyển động ngang
|
||||
acc_lim_theta: 1.5
|
||||
decel_lim_x: -3.0
|
||||
decel_lim_y: -0.0
|
||||
decel_lim_theta: -2.0
|
||||
|
||||
# Có cắt path thành từng chặng hay không
|
||||
split_path: true
|
||||
sim_time: 1.5
|
||||
vx_samples: 15
|
||||
vy_samples: 1
|
||||
vtheta_samples: 10
|
||||
discretize_by_time: true
|
||||
angular_granularity: 0.05
|
||||
linear_granularity: 0.1
|
||||
# sim_period: lấy theo chu kỳ điều khiển
|
||||
include_last_point: true
|
||||
|
||||
MKTAlgorithmDiffPredictiveTrajectory:
|
||||
library_path: libmkt_algorithm_diff
|
||||
xy_local_goal_tolerance: 0.05
|
||||
angle_threshold: 0.6
|
||||
index_samples: 60
|
||||
follow_step_path: true
|
||||
|
||||
# Chỉnh bộ lọc Kalman (lọc lệnh v và w trước khi gửi xuống base).
|
||||
# q_* = nhiễu quá trình, r_* = nhiễu đo. Tăng r_* -> lọc mạnh, lệnh mượt nhưng chậm đáp ứng
|
||||
kf_q_v: 0.25
|
||||
kf_q_w: 0.8
|
||||
kf_r_v: 0.05
|
||||
kf_r_w: 0.08
|
||||
kf_p0: 0.5
|
||||
kf_filter_angular: false
|
||||
|
||||
# ----- Điểm nhìn trước (lookahead) -----
|
||||
use_velocity_scaled_lookahead_dist: true # true = cự ly nhìn trước co giãn theo vận tốc; false = dùng cố định lookahead_dist. (mặc định: false)
|
||||
# chỉ có tác dụng khi cờ trên = false:
|
||||
lookahead_dist: 0.5 # [m] cự ly nhìn trước cố định để chọn điểm bám. (mặc định: 0.6)
|
||||
# chỉ có tác dụng khi cờ trên = true:
|
||||
min_lookahead_dist: 0.6 # [m] cận dưới của cự ly nhìn trước. Nhỏ quá thì robot lắc ở tốc độ thấp. (mặc định: 0.3)
|
||||
max_lookahead_dist: 2.0 # [m] cận trên của cự ly nhìn trước. Lớn quá thì robot cắt cua. (mặc định: 0.9)
|
||||
lookahead_time: 1.9 # [s] nhân với vận tốc hiện tại ra cự ly nhìn trước, tức hệ số lookahead. (mặc định: 1.5)
|
||||
min_journey_squared: 0.2 # [m^2] quãng đường bình phương tối thiểu mới xét tới goal (mặc định: 0.2)
|
||||
max_journey_squared: 0.5 # [m^2] quãng đường bình phương tối đa còn xét tới goal (mặc định: 0.2)
|
||||
max_lateral_accel: 0.9 # [m/s^2] trần gia tốc ngang, dùng để tự giảm tốc khi vào cua
|
||||
|
||||
# ----- Quay tại chỗ về đúng hướng -----
|
||||
# Chỉ được bật MỘT trong hai: use_rotate_to_heading hoặc allow_reversing
|
||||
use_rotate_to_heading: true # Cho phép quay tại chỗ về hướng path và về hướng goal. Nên bật với mọi robot quay tại chỗ được. (mặc định: true)
|
||||
# chỉ có tác dụng khi cờ trên = true:
|
||||
rotate_to_heading_min_angle: 0.03 # [rad] lệch hướng giữa path và robot vượt ngưỡng này thì quay tại chỗ trước khi chạy. (mặc định: 0.785)
|
||||
angular_decel_zone: 0.1
|
||||
|
||||
# Ngưỡng coi robot là ĐÃ DỪNG
|
||||
rot_stopped_velocity: 0.03
|
||||
trans_stopped_velocity: 0.03
|
||||
|
||||
use_final_heading_alignment: true
|
||||
final_heading_xy_tolerance: 0.1
|
||||
final_heading_angle_tolerance: 0.05
|
||||
final_heading_min_velocity: 0.05
|
||||
final_heading_kp_angular: 1.2
|
||||
final_heading_ki_angular: 0.002
|
||||
final_heading_kd_angular: 0.12
|
||||
|
||||
MKTAlgorithmDiffGoStraight:
|
||||
library_path: libmkt_algorithm_diff
|
||||
xy_local_goal_tolerance: 0.05
|
||||
angle_threshold: 0.8
|
||||
index_samples: 60
|
||||
follow_step_path: true
|
||||
|
||||
# ----- Điểm nhìn trước (lookahead) -----
|
||||
use_velocity_scaled_lookahead_dist: true # true = cự ly nhìn trước co giãn theo vận tốc; false = dùng cố định lookahead_dist. (mặc định: false)
|
||||
# chỉ có tác dụng khi cờ trên = false:
|
||||
lookahead_dist: 0.5 # [m] cự ly nhìn trước cố định để chọn điểm bám. (mặc định: 0.6)
|
||||
# chỉ có tác dụng khi cờ trên = true:
|
||||
min_lookahead_dist: 0.6 # [m] cận dưới của cự ly nhìn trước. Nhỏ quá thì robot lắc ở tốc độ thấp. (mặc định: 0.3)
|
||||
max_lookahead_dist: 2.0 # [m] cận trên của cự ly nhìn trước. Lớn quá thì robot cắt cua. (mặc định: 0.9)
|
||||
lookahead_time: 2.0 # [s] nhân với vận tốc hiện tại ra cự ly nhìn trước, tức hệ số lookahead. (mặc định: 1.5)
|
||||
min_journey_squared: 1.0 # [m^2] quãng đường bình phương tối thiểu mới xét tới goal (mặc định: 0.2)
|
||||
max_journey_squared: 1.0 # [m^2] quãng đường bình phương tối đa còn xét tới goal (mặc định: 0.2)
|
||||
max_lateral_accel: 0.9 # [m/s^2] trần gia tốc ngang, dùng để tự giảm tốc khi vào cua
|
||||
|
||||
# ----- Quay tại chỗ về đúng hướng -----
|
||||
# Chỉ được bật MỘT trong hai: use_rotate_to_heading hoặc allow_reversing
|
||||
use_rotate_to_heading: true # Cho phép quay tại chỗ về hướng path và về hướng goal. Nên bật với mọi robot quay tại chỗ được. (mặc định: true)
|
||||
# chỉ có tác dụng khi cờ trên = true:
|
||||
rotate_to_heading_min_angle: 0.03 # [rad] lệch hướng giữa path và robot vượt ngưỡng này thì quay tại chỗ trước khi chạy. (mặc định: 0.785)
|
||||
angular_decel_zone: 0.1
|
||||
|
||||
# Ngưỡng coi robot là ĐÃ DỪNG
|
||||
rot_stopped_velocity: 0.03
|
||||
trans_stopped_velocity: 0.03
|
||||
|
||||
use_final_heading_alignment: true
|
||||
final_heading_xy_tolerance: 0.1
|
||||
final_heading_angle_tolerance: 0.05
|
||||
final_heading_min_velocity: 0.05
|
||||
final_heading_kp_angular: 1.5
|
||||
final_heading_ki_angular: 0.2
|
||||
final_heading_kd_angular: 0.05
|
||||
|
||||
MKTAlgorithmDiffRotateToGoal:
|
||||
library_path: libmkt_algorithm_diff
|
||||
xy_local_goal_tolerance: 0.05
|
||||
angle_threshold: 0.47
|
||||
index_samples: 60
|
||||
follow_step_path: true
|
||||
|
||||
# ----- Điểm nhìn trước (lookahead) -----
|
||||
use_velocity_scaled_lookahead_dist: true # true = cự ly nhìn trước co giãn theo vận tốc; false = dùng cố định lookahead_dist. (mặc định: false)
|
||||
# chỉ có tác dụng khi cờ trên = false:
|
||||
lookahead_dist: 0.5 # [m] cự ly nhìn trước cố định để chọn điểm bám. (mặc định: 0.6)
|
||||
# chỉ có tác dụng khi cờ trên = true:
|
||||
min_lookahead_dist: 0.6 # [m] cận dưới của cự ly nhìn trước. Nhỏ quá thì robot lắc ở tốc độ thấp. (mặc định: 0.3)
|
||||
max_lookahead_dist: 2.0 # [m] cận trên của cự ly nhìn trước. Lớn quá thì robot cắt cua. (mặc định: 0.9)
|
||||
lookahead_time: 1.9 # [s] nhân với vận tốc hiện tại ra cự ly nhìn trước, tức hệ số lookahead. (mặc định: 1.5)
|
||||
min_journey_squared: 0.2 # [m^2] quãng đường bình phương tối thiểu mới xét tới goal (mặc định: 0.2)
|
||||
max_journey_squared: 0.8 # [m^2] quãng đường bình phương tối đa còn xét tới goal (mặc định: 0.2)
|
||||
max_lateral_accel: 0.9 # [m/s^2] trần gia tốc ngang, dùng để tự giảm tốc khi vào cua
|
||||
|
||||
# ----- Quay tại chỗ về đúng hướng -----
|
||||
# Chỉ được bật MỘT trong hai: use_rotate_to_heading hoặc allow_reversing
|
||||
use_rotate_to_heading: true # Cho phép quay tại chỗ về hướng path và về hướng goal. Nên bật với mọi robot quay tại chỗ được. (mặc định: true)
|
||||
# chỉ có tác dụng khi cờ trên = true:
|
||||
rotate_to_heading_min_angle: 0.03 # [rad] lệch hướng giữa path và robot vượt ngưỡng này thì quay tại chỗ trước khi chạy. (mặc định: 0.785)
|
||||
angular_decel_zone: 0.1
|
||||
|
||||
# Ngưỡng coi robot là ĐÃ DỪNG
|
||||
rot_stopped_velocity: 0.03
|
||||
trans_stopped_velocity: 0.03
|
||||
|
||||
use_final_heading_alignment: true
|
||||
final_heading_xy_tolerance: 0.1
|
||||
final_heading_angle_tolerance: 0.05
|
||||
final_heading_min_velocity: 0.05
|
||||
final_heading_kp_angular: 2.0
|
||||
near_goal_heading_kp: 1.5
|
||||
near_goal_heading_ki: 0.0
|
||||
near_goal_heading_kd: 0.0
|
||||
|
||||
GoalChecker:
|
||||
library_path: libmkt_plugins_goal_checker
|
||||
|
||||
SimpleGoalChecker:
|
||||
library_path: libmkt_plugins_goal_checker
|
||||
62
config/runtime/priest_local_planner_params.yaml
Normal file
62
config/runtime/priest_local_planner_params.yaml
Normal file
@@ -0,0 +1,62 @@
|
||||
PriestLocalPlanner:
|
||||
library_path: libpriest_local_planner
|
||||
|
||||
# ================= Tầm nhìn / bộ tối ưu =================
|
||||
t_fin: 7.0 # [s] tầm nhìn dự báo, robot lập kế hoạch trước bao lâu
|
||||
num_steps: 30 # số điểm mẫu trên mỗi quỹ đạo trong tầm nhìn đó
|
||||
num_batch: 60 # số quỹ đạo sinh ra mỗi vòng lặp CEM. Tăng = tìm kỹ hơn, tốn CPU hơn
|
||||
initial_up_sampling: 5 # hệ số sinh dư ứng viên ở vòng đầu trước khi lọc
|
||||
ellite_num: 40 # số quỹ đạo "tinh hoa" giữ lại, xếp hạng theo sai số chiếu
|
||||
num_warm: 20 # số quỹ đạo mang từ chu kỳ trước sang để khởi động nóng
|
||||
max_proj_iter: 8 # số vòng lặp chiếu luân phiên (alternating projection)
|
||||
max_cem_iter: 4 # số vòng lặp CEM mỗi chu kỳ điều khiển
|
||||
optimizer_threads: 4 # số thread giới hạn. Đừng lấy hết số core — overhead nuốt hết lợi ích
|
||||
solve_time_warn_ms: 30.0 # [ms] cảnh báo khi giải lâu hơn ngưỡng này, chừa biên trong chu kỳ 30 Hz
|
||||
lateral_std: 0.8 # [m] độ lệch chuẩn khi nhiễu loạn waypoint theo phương ngang.
|
||||
# Lớn = khám phá rộng, dễ tìm đường vòng; nhỏ = bám sát path toàn cục
|
||||
|
||||
# ================= Giới hạn robot (dẫn động vi sai) =================
|
||||
max_velocity: 0.5 # [m/s] trần vận tốc tiến
|
||||
max_angular_velocity: 0.4 # [rad/s] đồng thời được ép bên trong bộ tối ưu dưới dạng
|
||||
# chặn gia tốc ngang |a_n| <= max_angular_velocity * v
|
||||
max_acceleration: 0.5 # [m/s^2] dùng trong phép chiếu quỹ đạo
|
||||
reference_velocity: 0.4 # [m/s] tốc độ hành trình mong muốn dọc path
|
||||
v_eps: 0.05 # [m/s] chậm hơn ngưỡng này thì bỏ qua phần chặn/phạt độ cong,
|
||||
# tránh chia cho số gần 0 khi robot gần đứng yên
|
||||
v_min_seed: 0.05 # [m/s] vận tốc mồi theo hướng yaw khi robot đang đứng yên,
|
||||
# để bộ tối ưu có điểm xuất phát khác 0
|
||||
|
||||
# Đổi quỹ đạo -> lệnh vi sai (v, omega), có feedforward theo độ cong:
|
||||
# omega = clamp(omega_traj, +-max_angular_velocity) - heading_gain * sai_số_hướng
|
||||
heading_gain: 1.5 # [1/s] hệ số phản hồi trên sai số hướng.
|
||||
# Tăng = bẻ về path nhanh hơn nhưng dễ dao động
|
||||
heading_error_stop: 1.2 # [rad] lệch hướng lớn hơn ngưỡng này thì quay tại chỗ (v = 0)
|
||||
min_in_place_yawrate: 0.2 # [rad/s] tốc độ quay tối thiểu khi quay tại chỗ, tránh quay quá chậm
|
||||
|
||||
# ================= Goal / plan =================
|
||||
xy_goal_tolerance: 0.10 # [m] sai số vị trí chấp nhận là đã tới goal
|
||||
yaw_goal_tolerance: 0.10 # [rad] sai số góc chấp nhận là đã tới goal
|
||||
max_global_plan_lookahead_dist: 3.0 # [m] chỉ lấy phần path toàn cục trong tầm này để bám
|
||||
|
||||
# ================= Vật cản (lấy từ local costmap) =================
|
||||
num_obs: 40 # số vật cản đưa vào hàm chi phí CEM
|
||||
num_obs_proj: 30 # số vật cản gần nhất đưa vào phép chiếu
|
||||
obstacle_range: 2.5 # [m] bán kính quét costmap quanh robot
|
||||
robot_radius: 0.50 # [m] bán kính robot dùng cho phép kiểm va chạm
|
||||
obstacle_point_radius: 0.08 # [m] bán kính quy ước cho mỗi điểm vật cản
|
||||
footprint_padding: 0.05 # [m] nới footprint thêm để có biên an toàn
|
||||
obstacle_cost_threshold: 150 # ô costmap có cost >= ngưỡng này mới coi là vật cản
|
||||
obstacle_cell_step: 2 # bước nhảy khi quét ô costmap. Lớn = nhanh hơn, bỏ sót nhiều hơn
|
||||
max_obstacle_points: 150 # trần số điểm vật cản, chặn chi phí tính toán khi môi trường dày
|
||||
|
||||
# ================= Trọng số hàm chi phí =================
|
||||
# Chỉnh các trọng số này là chỉnh "tính cách" của planner. Tăng một cái tức là
|
||||
# giảm tương đối tất cả những cái còn lại.
|
||||
weight_smoothness: 0.1 # phạt quỹ đạo gãy khúc
|
||||
weight_track: 0.2 # phạt lệch khỏi path toàn cục
|
||||
weight_obs: 1.2 # phạt tiến gần vật cản
|
||||
weight_clearance: 3.0 # phần thưởng giữ khoảng hở, giá trị trong (0,1]: bằng 1 ngay tại
|
||||
# tâm vật cản, 0.5 tại biên va chạm, 0 khi ngoài tầm
|
||||
weight_angular: 0.5 # phạt kiểu bản lề khi |omega| vượt max_angular_velocity
|
||||
cem_lamda: 0.9 # nhiệt độ CEM. Thấp = chỉ tin nhóm tinh hoa, hội tụ nhanh nhưng dễ kẹt
|
||||
cem_alpha: 0.7 # hệ số pha trộn mean/cov giữa hai vòng CEM. Cao = đổi chậm, ổn định hơn
|
||||
310
config/runtime/recovery_behaviors_params.yaml
Normal file
310
config/runtime/recovery_behaviors_params.yaml
Normal file
@@ -0,0 +1,310 @@
|
||||
# =================================================================================================
|
||||
# recovery_core — bộ recovery behavior (gen-2, tick-based) và tham số vận hành.
|
||||
#
|
||||
# Quy ước comment: dòng mô tả = LÀ GÌ / vì sao; `► Chỉnh:` = tăng giảm theo triệu chứng nào.
|
||||
#
|
||||
# Đây là cây config RUNTIME. Bản dùng cho test của gói nằm ở
|
||||
# `Test/recovery_core/test/config/recovery_behaviors_params.yaml` — sửa tham số vận hành thì sửa ở
|
||||
# đây, đừng sửa bản test.
|
||||
#
|
||||
# Danh sách này được `recovery_core::RecoveryRegistry` đọc; caller (RecoveryRunner của move_base2)
|
||||
# truyền namespace `recovery` vào. Khoá `recovery_behaviors:` trong `move_base_common_params.yaml`
|
||||
# thuộc về move_base cũ và KHÔNG liên quan tới file này.
|
||||
# =================================================================================================
|
||||
|
||||
recovery:
|
||||
# `behaviors` là registry mọi plugin/instance CÓ THỂ dùng. Thứ tự ở đây chỉ là thứ tự nạp,
|
||||
# không còn quyết định luồng chạy. `routes` bên dưới chọn riêng chuỗi theo trigger.
|
||||
#
|
||||
# wait : không di chuyển. Vật cản động (người, xe khác) tự đi qua là xong.
|
||||
# clear : xoá vật cản đã tích trong costmap, gần trước rồi xa sau.
|
||||
# rotate : quay tại chỗ cho costmap nhìn lại xung quanh.
|
||||
# back_up: LÙI — hướng robot không có sensor, nên xếp cuối cùng.
|
||||
#
|
||||
# ► Chỉnh: khai ở đây KHÔNG làm behavior chạy — phải đưa tên nó vào một `route` bên dưới. Một
|
||||
# `type` được phép khai nhiều `name` khác nhau để có nhiều instance khác tuning (vd một
|
||||
# `back_up` lùi 0.1 m và một `back_up_far` lùi 0.6 m).
|
||||
behaviors:
|
||||
# - {name: wait, type: WaitRecovery}
|
||||
# - {name: clear, type: ClearCostmapRecovery}
|
||||
# # Đặt schema trước plugin: chưa có `DetourPathRecovery`/library_path thì RecoveryRunner bỏ
|
||||
# # entry này cùng warning, và bỏ nó khỏi từng route. Khi plugin SBPL được thêm sau này, không
|
||||
# # cần sửa move_base2 hay route.
|
||||
# - {name: detour_path, type: DetourPathRecovery}
|
||||
# - {name: rotate, type: RotateRecovery}
|
||||
# - {name: back_up, type: BackUpRecovery}
|
||||
|
||||
# trigger -> tên behavior thử tuần tự; lần lỗi kế tiếp cùng trigger mới tiến tới phần tử tiếp
|
||||
# theo của route đó. Đường quay về sau khi một behavior kết thúc (contract 2026-08-04b):
|
||||
# - planning_failed -> quay về PLANNING lập plan lại (không có plan nào để bám);
|
||||
# - controlling/oscillation-> quay về CONTROLLING bám tiếp GLOBAL PATH CŨ, KHÔNG lập plan lại
|
||||
# (thay plan trong lúc chạy là việc riêng của planner_frequency);
|
||||
# riêng khi leo thang từ PLANNING vì mất pose thì về PLANNING;
|
||||
# - behavior họ detour (output kPath, vd DetourPathRecovery) nộp path mới -> path đó được áp
|
||||
# và robot bám tiếp — cách duy nhất một recovery được thay plan.
|
||||
# Robot đi được quá `oscillation_distance` thì mọi cursor route được reset — ngân sách recovery
|
||||
# đầy lại theo tiến độ thật (2026-08-04).
|
||||
#
|
||||
# Ý NGHĨA TỪNG TRIGGER:
|
||||
# planning_failed : planner CÓ dữ liệu nhưng không tìm được đường.
|
||||
# controlling_failed : MẤT DỮ LIỆU/LỆNH — controller không ra lệnh (kể cả mất pose) quá
|
||||
# `controller_patience`, hoặc mất pose ngay trong PLANNING, hoặc costmap
|
||||
# stale liên tục quá `sensor_patience`.
|
||||
# oscillation : quẩn trong bán kính `oscillation_distance` quá `oscillation_timeout`.
|
||||
# path_blocked : DỰ BÁO tuyến phía trước bị chắn (giám sát tuyến).
|
||||
# off_path : DỰ BÁO robot đã lệch khỏi plan quá ngưỡng.
|
||||
#
|
||||
# ► Chỉnh route:
|
||||
# - route RỖNG = tắt hẳn trigger đó. `path_blocked`/`off_path` được phép rỗng; ba route còn lại
|
||||
# bắt buộc có ít nhất một behavior (config validate chặn).
|
||||
# - route được phép LẶP behavior: mỗi lần xuất hiện là một lượt thử (`[detour, wait, detour]`).
|
||||
# - route dài hơn = kiên nhẫn hơn nhưng chậm báo lỗi lên fleet hơn.
|
||||
# - thứ tự nên đi từ RẺ và AN TOÀN tới ĐẮT và RỦI RO: wait/clear -> rotate -> detour -> back_up.
|
||||
routes:
|
||||
# planning_failed: [wait, clear]
|
||||
# controlling_failed: [detour_path]
|
||||
# oscillation: [wait]
|
||||
# # Cursor reset (2026-08-05): recovery THÀNH CÔNG + NỘP PATH MỚI (detour) thì cursor của trigger
|
||||
# # đó reset NGAY — lần chắn kế tiếp là sự cố mới, detour được chạy lại. Từ chối/thất bại mới ăn
|
||||
# # vào ngân sách route.
|
||||
# #
|
||||
# # Cạn route KHÔNG còn nghĩa là ABORT (contract 2026-08-05e): `path_blocked`/`off_path` là DỰ
|
||||
# # BÁO, plan vẫn hợp lệ và controller vẫn ra lệnh được, nên robot bám tiếp plan cũ và trigger bị
|
||||
# # KHOÁ tới khi đi được quá `oscillation_distance`. Đường ABORT hợp lệ duy nhất đi qua
|
||||
# # `controlling_failed` (controller thật sự hết ra lệnh quá controller_patience) hoặc
|
||||
# # `planning_failed`.
|
||||
# path_blocked: [detour_path]
|
||||
# off_path: [detour_path]
|
||||
|
||||
# # --- wait: đứng yên, không phát vận tốc ---------------------------------------------------------
|
||||
# wait:
|
||||
# # [s] Thời gian đứng yên.
|
||||
# # ► Chỉnh: TĂNG (5–10) ở khu đông người để vật cản động kịp đi qua; GIẢM nếu robot đứng chờ quá
|
||||
# # lâu ở chỗ vật cản thật ra là tĩnh. Thời gian này robot KHÔNG phát cmd_vel.
|
||||
# wait_duration: 3.0
|
||||
|
||||
# # --- clear: xoá vật cản đã tích trong costmap ---------------------------------------------------
|
||||
# #
|
||||
# # Đường thoát đúng khi bẫy là VẬT CẢN MA (costmap giữ lại thứ không còn ở đó). Rẻ nhất trong bộ,
|
||||
# # nên thường đặt đầu route.
|
||||
# clear:
|
||||
# # [m] Cạnh vùng vuông quanh robot sẽ bị xoá.
|
||||
# # ► Chỉnh: TĂNG nếu ma nằm xa hơn (nhưng xoá rộng = mất cả vật cản THẬT vừa quan sát được, robot
|
||||
# # có thể lao vào chỗ vừa xoá). GIẢM để an toàn hơn. Đừng vượt quá cửa sổ costmap local (8 m).
|
||||
# reset_distance: 3.0
|
||||
# # false = xoá BÊN TRONG vùng; true = xoá BÊN NGOÀI (giữ lại vùng gần robot).
|
||||
# # ► Chỉnh: true chỉ hợp lý khi muốn giữ vật cản gần và bỏ dữ liệu xa đã cũ.
|
||||
# invert_area_to_clear: false
|
||||
# # local | global | both — costmap nào bị xoá.
|
||||
# # ► Chỉnh: `local` nếu chỉ muốn làm mới dữ liệu sensor mà không đụng bản đồ tích luỹ.
|
||||
# affected_maps: both
|
||||
# # Phải khớp `plugins:` của costmap; sai tên -> log kèm tên layer thật.
|
||||
# # ► Chỉnh: thêm tên layer nếu costmap có nhiều layer vật cản (vd `[obstacles, voxel_layer]`).
|
||||
# # Đây KHÔNG phải số tinh chỉnh — sai tên là behavior không xoá gì cả.
|
||||
# layer_names: [obstacles]
|
||||
|
||||
# # --- rotate: quay tại chỗ cho sensor quét lại xung quanh -----------------------------------------
|
||||
# rotate:
|
||||
# # true = quay đủ 2*pi để costmap thấy toàn bộ xung quanh.
|
||||
# # ► Chỉnh: false = quay theo `goal.angle` do caller đặt, và nếu caller không đặt thì dùng
|
||||
# # `target_angle` bên dưới. Giữ true cho mục đích "nhìn lại xung quanh".
|
||||
# full_rotation: true
|
||||
|
||||
# # [rad] Góc quay mặc định khi `full_rotation: false` VÀ caller không truyền `goal.angle`.
|
||||
# # Giá trị hiện tại = 2*pi (tức bằng full_rotation), nên khi `full_rotation: true` nó nằm im.
|
||||
# # ► Chỉnh: viết SỐ CỤ THỂ, đừng viết biểu thức kiểu `2 * 3.14159` — parser YAML không tính.
|
||||
# # Dấu quyết định chiều quay. Ví dụ nửa vòng: 3.141592653589793.
|
||||
# # Giá trị bị clamp về |target_angle| nên không thể quay quá một vòng.
|
||||
# target_angle: 6.283185307179586
|
||||
# # [rad/s] Độ lớn tốc độ quay; dấu do goal.angle quyết định.
|
||||
# # ► Chỉnh: phải <= max_vel_theta của robot. GIẢM nếu có tải cao/dễ đổ; TĂNG để recovery nhanh
|
||||
# # hơn nhưng sensor có thể nhoè khi quét.
|
||||
# angular_speed: 0.4
|
||||
# # [rad/s^2] Ramp gia tốc, tránh giật khi có tải.
|
||||
# # ► Chỉnh: GIẢM khi chở hàng dễ đổ; TĂNG nếu robot mất quá nhiều thời gian mới đạt tốc độ.
|
||||
# acc_lim_theta: 0.8
|
||||
# # [rad] Bước quét footprint dọc cung lúc start (kiểm va chạm trước khi quay).
|
||||
# # ► Chỉnh: GIẢM (0.05) để kiểm kỹ hơn ở chỗ chật, đổi lại tốn CPU lúc start. TĂNG thì có nguy cơ
|
||||
# # bỏ sót một vị trí góc bị chạm.
|
||||
# sim_granularity: 0.1
|
||||
# # [s] Lưới cuối nếu robot bị giữ cơ học (bánh trượt, bị chèn).
|
||||
# # ► Chỉnh: phải > thời gian quay 2*pi ở `angular_speed` (2π/0.4 ≈ 15.7 s) cộng dư địa ramp.
|
||||
# # Đặt thấp hơn là behavior LUÔN kết thúc bằng timeout.
|
||||
# timeout: 20.0
|
||||
|
||||
# # --- back_up: lùi thẳng -------------------------------------------------------------------------
|
||||
# #
|
||||
# # Hướng lùi KHÔNG có sensor -> rủi ro cao nhất trong bộ, thường xếp cuối route.
|
||||
# back_up:
|
||||
# # [m] Quãng lùi mặc định khi caller không chỉ định.
|
||||
# # ► Chỉnh: TĂNG (0.3–0.6) nếu robot cần lùi hẳn ra khỏi hốc/khe kệ mới xoay được; GIẢM nếu phía
|
||||
# # sau thường có người/vật. Nhớ phía sau là vùng mù.
|
||||
# backup_distance: 0.1
|
||||
# # [m] Trần cứng, chặn cả `goal.distance` do caller truyền lẫn param ở trên.
|
||||
# # ► Chỉnh: đây là chốt an toàn, đặt bằng quãng lùi mù xa nhất còn chấp nhận được ở hiện trường.
|
||||
# backup_distance_max: 1.0
|
||||
# # [m/s] ĐỘ LỚN; dấu âm (lùi) do plugin đặt.
|
||||
# # ► Chỉnh: giữ chậm (<= 0.15) vì đi mù. TĂNG chỉ khi có sensor sau.
|
||||
# linear_speed: 0.1
|
||||
# # [m/s^2] Ramp gia tốc.
|
||||
# # ► Chỉnh: GIẢM khi chở tải dễ đổ.
|
||||
# acc_lim_x: 0.3
|
||||
# # [s] Lưới cuối.
|
||||
# # ► Chỉnh: phải > backup_distance_max / linear_speed (1.0/0.1 = 10 s) cộng dư địa ramp.
|
||||
# timeout: 15.0
|
||||
|
||||
# # --- detour_path: lập đường vòng quanh vật cản rồi NỐI LẠI tuyến --------------------------------
|
||||
# #
|
||||
# # Gói `sbpl_recovery`, họ kPath: nó KHÔNG lái robot, chỉ TRẢ VỀ một path; runtime áp path đó và
|
||||
# # local planner đang active bám theo. Đường vòng được bám ngay, không replan (contract 08-04b).
|
||||
# detour_path:
|
||||
# # Instance planner RIÊNG, không dùng chung SBPLLatticePlanner của backup: detour gọi makePlan
|
||||
# # ĐỒNG BỘ trên control thread, nên `allocated_time` của instance này là trần treo control loop
|
||||
# # mỗi tick. Xem khối SBPLDetourPlanner ở cuối file.
|
||||
# #
|
||||
# # ► Chỉnh: `planner_name` là NAMESPACE PARAM (khối bên dưới), `planner_symbol` là ALIAS Boost.DLL
|
||||
# # CÓ THẬT trong .so. Đây không phải số tinh chỉnh — đổi sai là runtime không nạp được plugin.
|
||||
# planner_name: SBPLDetourPlanner
|
||||
# planner_symbol: SBPLLatticePlanner # libsbpl_lattice_planner chỉ export đúng một symbol này.
|
||||
# # Khác bộ local planner, nơi mỗi biến thể là một class riêng
|
||||
# # nên tên instance trùng alias.
|
||||
|
||||
# # "combined" (2026-08-05, vòng 3 — LƯỚI GỘP, xem DETOUR_MERGED_GRID_PLAN.md): snapshot global
|
||||
# # làm nền (tường/kệ tĩnh toàn bản đồ) + đè cửa sổ local lên (vật cản sensor tươi), SBPL lập
|
||||
# # đường TRÊN BẢN CHỤP GỘP — không giữ mutex costmap nào trong lúc search, map update không bị
|
||||
# # bỏ đói dù attempt thua. Một bên báo chắn là chắn; local FREE không xoá tường global.
|
||||
# # Cần planner export capability "<planner_symbol>ExternalGrid" (sbpl_lattice_planner có sẵn).
|
||||
# #
|
||||
# # ► Chỉnh: giữ `combined`. `local` = chỉ cửa sổ lăn, cho hệ không có global costmap — điểm nối
|
||||
# # kẹt trong cửa sổ. `global` = chỉ lưới tĩnh: ĐÃ ĐO và LOẠI trên sim, global không nạp sensor
|
||||
# # nên goal nào SBPL cũng vẽ xuyên đúng chỗ vật cản tươi (6/6 attempt hỏng).
|
||||
# costmap_source: combined
|
||||
|
||||
# # [m] Điểm nối phải cách robot tối thiểu chừng này (đo Euclid).
|
||||
# # ► Chỉnh: TĂNG nếu đường vòng quá ngắn/gấp khiến local planner không bám nổi. GIẢM nếu ở chỗ
|
||||
# # chật không tìm nổi điểm nối. Phải < `max_rejoin_distance` khi cái đó > 0.
|
||||
# planning_distance: 1.0
|
||||
|
||||
# # [m] TRẦN quét dọc plan, thuần tuỳ chọn. 0 = quét tới CUỐI PLAN (lưới gộp phủ toàn bản đồ nên
|
||||
# # không còn ràng buộc cửa sổ local). Quét luôn tự dừng ở rìa lưới.
|
||||
# # ► Chỉnh: GIỮ 0. Hai lần sim 2026-08-05 đặt cap hữu hạn (3.8 rồi 8.0) đều cắt quét ngay sau pose
|
||||
# # bẩn cuối và báo "không có chỗ sạch" OAN. Chỉ đặt > 0 khi muốn chặn cứng độ dài đường vòng.
|
||||
# max_rejoin_distance: 0.0
|
||||
|
||||
# # [m] Khoảng cách dọc plan giữa hai ứng viên điểm nối liên tiếp.
|
||||
# # ► Chỉnh: TĂNG để ba ứng viên trải rộng hơn (thử được nhiều chỗ khác nhau hơn); GIẢM để thử
|
||||
# # dày quanh một vùng. Cùng `attempts_per_run` quyết định tầm phủ: 3 x 0.5 = ~1.5 m.
|
||||
# sample_step: 0.5
|
||||
|
||||
# # [m] Điểm nối phải cách pose bẩn gần nhất CẢ HAI PHÍA dọc plan chừng này, và nằm SAU pose bẩn
|
||||
# # CUỐI CÙNG CÒN NHÌN THẤY ĐƯỢC (trong cửa sổ local — contract 2026-08-05f). Chỗ chắn ngoài tầm
|
||||
# # nhìn là dữ liệu cũ, không được quyền quyết định điểm nối.
|
||||
# # ► Chỉnh: TĂNG (0.8–1.0) nếu nhiều lượt SBPL báo `Solution not found` — 0.5 m có thể quá sát:
|
||||
# # "bẩn" ở đây do kiểm MỘT ô, còn SBPL kiểm footprint đầy đủ (0.6x0.6 + inflation 0.55 m).
|
||||
# # GIẢM nếu ở khu chật không bao giờ tìm được điểm nối.
|
||||
# rejoin_clearance: 0.5
|
||||
|
||||
# # Số ứng viên điểm nối thử tối đa trong một lượt; mỗi control cycle thử ĐÚNG MỘT ứng viên.
|
||||
# # ► Chỉnh: TĂNG = kiên nhẫn hơn nhưng mỗi lượt hỏng tốn thêm `allocated_time` giây treo control
|
||||
# # thread. GIẢM = từ bỏ nhanh, nhường cho behavior kế tiếp của route.
|
||||
# attempts_per_run: 3
|
||||
|
||||
# # Tuyến để NỐI LẠI (2026-08-05e). "reference" = tuyến GỐC của chặng, tức plan do planner sinh và
|
||||
# # recovery không thay được: đường vòng luôn quay về tuyến order, và `max_deviation` đo đúng hành
|
||||
# # lang fleet đã duyệt. "current" = plan đang bám (hành vi cũ) — sim đo được tuyến bị ăn mòn dần
|
||||
# # qua từng lượt detour (rejoin 106/305 -> 130/289 -> 132/273) và robot không bao giờ về tuyến.
|
||||
# # ► Chỉnh: giữ `reference`. Chỉ đổi sang `current` khi runtime không cấp được tuyến tham chiếu
|
||||
# # (khi đó behavior tự quay về `current` kèm cảnh báo, không cần sửa gì).
|
||||
# rejoin_on: reference
|
||||
|
||||
# # [m] Hành lang lệch tuyến cho phép quanh tuyến gốc của order. 0 = KHÔNG giới hạn.
|
||||
# # ► Chỉnh: giữ 0 cho tới khi biết dung sai thật của fleet master — đặt số mò còn tệ hơn tắt.
|
||||
# # Khi bật, đặt bằng chiều rộng hành lang mà fleet cho phép robot rời tuyến (thường 1–2 m).
|
||||
# # Đường vòng vượt hành lang sẽ bị TỪ CHỐI và thử ứng viên kế tiếp.
|
||||
# max_deviation: 0.0
|
||||
|
||||
# # [s] Trần cho cả lượt recovery này (base cưỡng chế, khác `allocated_time` của một lượt SBPL).
|
||||
# # ► Chỉnh: phải > attempts_per_run * allocated_time (3 x 0.4 = 1.2 s) cộng dư địa, nếu không
|
||||
# # behavior bị cắt giữa chừng trước khi thử hết ứng viên.
|
||||
# timeout: 10.0
|
||||
|
||||
# # Bảng symbol -> thư viện cho Boost.DLL. KHÔNG phải tham số tinh chỉnh — thiếu khoá `library_path`
|
||||
# # là nguyên nhân phổ biến nhất của lỗi "plugin build xong nhưng runtime báo không tìm thấy".
|
||||
# WaitRecovery:
|
||||
# library_path: librecovery_core_wait_recovery
|
||||
|
||||
# ClearCostmapRecovery:
|
||||
# library_path: librecovery_core_clear_costmap_recovery
|
||||
|
||||
# RotateRecovery:
|
||||
# library_path: librecovery_core_rotate_recovery
|
||||
|
||||
# BackUpRecovery:
|
||||
# library_path: librecovery_core_back_up_recovery
|
||||
|
||||
# DetourPathRecovery:
|
||||
# library_path: libsbpl_recovery
|
||||
|
||||
# # =================================================================================================
|
||||
# # Instance SBPL RIÊNG cho detour — cùng .so với SBPLLatticePlanner, khác tuning.
|
||||
# #
|
||||
# # Vì sao không dùng chung: `DetourPathRecovery::onUpdate` gọi makePlan ĐỒNG BỘ trên control thread,
|
||||
# # nên `allocated_time` ở đây là trần thời gian control loop bị treo mỗi tick — `cancel`/`pause` từ
|
||||
# # host không được xử lý trong khoảng đó. Bản backup để 10.0 s là hợp lý cho vai trò của nó, nhưng
|
||||
# # treo loop 10 s thì không.
|
||||
# # =================================================================================================
|
||||
# SBPLDetourPlanner:
|
||||
# # KHÔNG có `library_path` ở đây: `SBPLDetourPlanner` không phải symbol, nó chỉ là namespace param.
|
||||
# # Việc nạp .so đi theo `planner_symbol: SBPLLatticePlanner` ở trên.
|
||||
|
||||
# # Kiểu môi trường và thuật toán. XYThetaLattice là loại DUY NHẤT port này hỗ trợ.
|
||||
# # ► Chỉnh: `planner_type` có ARAPlanner (anytime, dùng epsilon) và ADPlanner (anytime + dynamic,
|
||||
# # tận dụng thay đổi costmap giữa hai lượt). Giữ ARAPlanner trừ khi đo được ADPlanner nhanh hơn.
|
||||
# environment_type: XYThetaLattice
|
||||
# planner_type: ARAPlanner
|
||||
|
||||
# # [s] TRẦN CỨNG cho một lượt SBPL — cũng là trần treo control thread mỗi tick.
|
||||
# # ► Chỉnh: TĂNG nếu log nhiều `Solution not found` mà thời điểm trả về đúng bằng giá trị này (tức
|
||||
# # HẾT GIỜ). GIẢM nếu control loop bị giật khi detour chạy. Trả về sớm hơn nhiều giá trị này
|
||||
# # nghĩa là search CẠN STATE — tăng thêm cũng vô ích, vấn đề nằm ở goal không tới được.
|
||||
# allocated_time: 0.4
|
||||
|
||||
# # Hệ số nới heuristic của ARA*: nghiệm đầu được phép đắt gấp `initial_epsilon` lần tối ưu, rồi
|
||||
# # thuật toán siết dần trong thời gian còn lại.
|
||||
# # ► Chỉnh: đây là nút ĐÁNH ĐỔI TỐC ĐỘ/CHẤT LƯỢNG quan trọng nhất.
|
||||
# # - TĂNG (5–15) = ra nghiệm rất nhanh nhưng đường xấu: gấp khúc, xoay tại chỗ, vòng xoắn.
|
||||
# # - GIẢM (1.0–2.0) = đường đẹp nhưng chậm, dễ hết giờ ở quãng xa.
|
||||
# # Đường vòng xấu mà vẫn ra nghiệm ⇒ giảm số này TRƯỚC khi đụng vào .mprim.
|
||||
# initial_epsilon: 2.0
|
||||
|
||||
# # Số ô costmap thay đổi tối đa còn cho phép lập plan tăng dần; vượt ngưỡng thì lập lại từ đầu.
|
||||
# # ► Chỉnh: hiếm khi cần. GIẢM nếu nghi plan tăng dần đang dùng dữ liệu cũ.
|
||||
# force_scratch_limit: 10000
|
||||
|
||||
# # Hướng tìm kiếm: true = từ start tới goal.
|
||||
# # ► Chỉnh: đổi sang false (backward) chỉ khi đo được nhanh hơn cho hình học tuyến của mình.
|
||||
# forward_search: true
|
||||
|
||||
# # Bỏ ràng buộc heading tại điểm xuất phát: SBPL được phép giả định robot đã xoay sẵn theo hướng
|
||||
# # tới goal, phần xoay để local planner lo.
|
||||
# # ► Chỉnh: `true` làm mỗi lượt HỎNG chạy HAI lần search (log: "no solution with free start
|
||||
# # heading, retrying with actual robot heading"), và lượt thành công có thể chạy BA lần (thêm
|
||||
# # một lượt "realign"). Đặt `false` cho detour để tiết kiệm — detour chạy khi robot ĐANG BÁM plan
|
||||
# # nên heading thật đã xuôi theo tuyến. Chỉ để `true` nếu local planner có bước xoay tại chỗ đầu
|
||||
# # path (turn_around_priority).
|
||||
# free_start_heading: true
|
||||
|
||||
# # [m/s] và [s] — dùng để quy quãng đường/góc thành CHI PHÍ thời gian, không phải giới hạn vận tốc
|
||||
# # thật của robot (giới hạn thật nằm ở local planner).
|
||||
# # ► Chỉnh: tỉ lệ giữa hai số này quyết định robot "thà đi vòng" hay "thà xoay tại chỗ".
|
||||
# # `timetoturn45degsinplace_secs` LỚN ⇒ xoay tại chỗ đắt ⇒ SBPL vẽ cung vòng thay vì xoay.
|
||||
# # Đặt sát tốc độ hành trình thật để chi phí phản ánh đúng thời gian.
|
||||
# nominalvel_mpersecs: 0.3
|
||||
# timetoturn45degsinplace_secs: 1.31
|
||||
|
||||
# # File motion primitive: tập cử động cơ sở (tiến, lùi, cung rẽ, xoay tại chỗ) kèm hệ số chi phí.
|
||||
# # ► Chỉnh: `resolution_m` trong file PHẢI khớp resolution costmap (0.05 m), nếu không SBPL từ chối
|
||||
# # nạp. Hình dạng đường vòng (gấp khúc / xoắn / nhiều đoạn xoay tại chỗ) do các
|
||||
# # `additionalactioncostmult` trong file này quyết định — sinh lại bằng `Test/mprim_gen`. Nên
|
||||
# # dùng file RIÊNG cho detour, đừng đè file mà global planner đang dùng chung.
|
||||
# primitive_filename: /home/duongtd/rl_ws/mir_robot/mir_navigation/mprim/unicycle_highcost_5cm.mprim
|
||||
15
config/runtime/sbpl_global_params.yaml
Normal file
15
config/runtime/sbpl_global_params.yaml
Normal file
@@ -0,0 +1,15 @@
|
||||
SBPLLatticePlanner:
|
||||
library_path: libsbpl_lattice_planner
|
||||
environment_type: XYThetaLattice
|
||||
planner_type: ARAPlanner
|
||||
allocated_time: 10.0
|
||||
initial_epsilon: 1.0
|
||||
force_scratch_limit: 10000
|
||||
forward_search: true
|
||||
# Bỏ ràng buộc heading xuất phát: local planner đã có bước quay tại chỗ đầu path
|
||||
# (turn_around_priority) nên không cần SBPL vẽ cung quay đầu khi goal ở phía sau.
|
||||
# Nếu không ra nghiệm, planner tự retry một lần với heading thật của robot.
|
||||
free_start_heading: true
|
||||
nominalvel_mpersecs: 0.3
|
||||
timetoturn45degsinplace_secs: 1.31 # = 0.6 rad/s
|
||||
primitive_filename: /home/duongtd/rl_ws/mir_robot/mir_navigation/mprim/unicycle_highcost_5cm.mprim
|
||||
606
config/runtime/stanley_local_planner_params.yaml
Normal file
606
config/runtime/stanley_local_planner_params.yaml
Normal file
@@ -0,0 +1,606 @@
|
||||
LocalPlannerAdapter:
|
||||
library_path: liblocal_planner_adapter
|
||||
yaw_goal_tolerance: 0.017
|
||||
xy_goal_tolerance: 0.03
|
||||
min_approach_linear_velocity: 0.06
|
||||
|
||||
StanleyLocalPlanner:
|
||||
library_path: libstanley_local_planner
|
||||
|
||||
# ============================================================================
|
||||
# Ghi chú chung về cách chỉnh:
|
||||
# - Mỗi tham số có dòng "Chỉnh:" mô tả tăng/giảm thì hành vi đổi thế nào và
|
||||
# dấu hiệu nào cho biết cần chỉnh. Chỉnh TỪNG tham số một, chạy lại, rồi
|
||||
# mới chỉnh tiếp — đổi nhiều thứ cùng lúc sẽ không biết cái nào có tác dụng.
|
||||
# - Số đo hiện trường lấy từ log [DBG-OFF] / [DBG-CURVE] / [DBG-STEER].
|
||||
# ============================================================================
|
||||
|
||||
# ================= Giới hạn robot =================
|
||||
max_vel_x: 1.20 # [m/s] tốc độ tiến tối đa, > 0.
|
||||
# Chỉnh: tăng khi cần chạy nhanh hơn; phải tăng kèm
|
||||
# quãng phanh (xem goal_decel_limit) và kiểm tra servo
|
||||
# còn theo kịp ([DBG-STEER]). Giảm nếu robot lắc ở tốc độ cao.
|
||||
min_vel_x: -0.25 # [m/s] tốc độ lùi tối đa, < 0 (dấu âm = lùi).
|
||||
# Chỉnh: như max_vel_x nhưng cho chiều lùi; lùi không có
|
||||
# preview cảm biến phía sau nên để chậm hơn tiến.
|
||||
wheel_base: 1.3118251 # [m] khoảng cách trục. 0 = tự đo từ TF front_axle_frame -> rear_axle_frame.
|
||||
# Chỉnh: chỉ đặt số cứng khi TF không có hoặc sai; số sai
|
||||
# làm feedforward atan(L*kappa) sai theo -> lệch cong.
|
||||
front_axle_frame: "steer_link"
|
||||
rear_axle_frame: "base_link"
|
||||
|
||||
# Hai giới hạn góc lái RIÊNG BIỆT.
|
||||
# Bám path không được dùng góc lái lớn: forward_vel_ tỉ lệ cos(delta) nên sụp về
|
||||
# speed_base, và vel_steer = v/cos(steer) được guard về 0 khi cos -> 0.
|
||||
# Xoay tại chỗ mới dùng hết 90 độ cơ khí.
|
||||
steer_limit_standstill: 1.5708 # [rad] trần góc lái khi |v| ~ 0. CẦN ĐO THỰC TẾ.
|
||||
# Chỉnh: giảm nếu robot bẻ lái quá gắt lúc khởi hành.
|
||||
steer_limit_at_max_vel: 0.5000 # [rad] trần góc lái khi |v| = max_vel_x. CẦN ĐO THỰC TẾ.
|
||||
# Chỉnh: giảm nếu lắc ở tốc độ cao; tăng nếu vào cua
|
||||
# gắt ở tốc độ cao mà lái bị kẹp trần (delta chạm limit
|
||||
# liên tục trong [DBG-OFF]).
|
||||
align_steer_angle: 1.5708 # [rad] góc lái khi xoay tại chỗ. Ghi số cụ thể, KHÔNG ghi M_PI/2.
|
||||
align_pivot_toward_curve: true # true: path cong ngay từ pose 0 (|ff| > 0.30 rad) thì pivot đỗ
|
||||
# bánh về PHÍA cua sắp tới (-90 thay vì +90), khỏi quét 2.6-3.1 rad
|
||||
# tại chỗ trước khi lăn bánh. ROBOT THẬT: kiểm tra drive nhận lệnh
|
||||
# -1.5708 trước khi bật (drive từ chối lệnh quá 90°, test 09/08).
|
||||
min_steer_angle: 0.20 # [rad] ngưỡng coi là "đang bẻ lái".
|
||||
# Chỉnh: hiếm khi cần; tăng nếu profile tốc độ giảm
|
||||
# oan vì các dao động lái nhỏ.
|
||||
max_steer_rate: 1.50 # [rad/s] tốc độ quay servo lái. Đo bằng [DBG-STEER] 07/08:
|
||||
# servo thật đạt đỉnh 1.08-1.35.
|
||||
# Chỉnh: đặt THẤP HƠN đỉnh đo được một chút để lệnh không
|
||||
# vượt quá khả năng servo; đặt cao hơn thực tế -> lệnh chạy
|
||||
# trước bánh -> overshoot rồi lắc qua lại.
|
||||
|
||||
# Offset zero của kênh lái, CỘNG vào mọi lệnh lái.
|
||||
# Log 05/08: robot đi thẳng nhưng encoder đọc +0.0373 rad (2.1 độ)
|
||||
# -> luật tỉ lệ phải "trả giá" bằng lệch ngang thường trực 5-8 cm.
|
||||
# Là CẦU TẠM đến khi calib zero encoder servo; calib xong đặt lại 0.0.
|
||||
steer_zero_offset: 0.037 # [rad]
|
||||
# Chỉnh: đo lại khi robot đi thẳng ổn định — giá trị đúng
|
||||
# là góc encoder đọc được lúc bánh thực sự thẳng. Sai dấu
|
||||
# sẽ NHÂN ĐÔI lệch thay vì khử. Sim để 0.0.
|
||||
|
||||
# ================= Dung sai đích =================
|
||||
xy_goal_tolerance: 0.030 # [m] dung sai vị trí. Phải khớp LocalPlannerAdapter.
|
||||
# Chỉnh: giảm khi cần dừng chính xác (dock); giảm quá mức
|
||||
# so với nhiễu định vị -> robot loay hoay mãi không latch đích.
|
||||
yaw_goal_tolerance: 0.020 # [rad] dung sai góc tại đích.
|
||||
# Chỉnh: như trên cho góc; nhỏ hơn nhiễu yaw -> xoay qua lại mãi.
|
||||
goal_sq_dist_tol: 0.05 # [m^2] thoát sớm vòng scan điểm gần nhất.
|
||||
# Chỉnh: hầu như không cần đụng; chỉ là tối ưu CPU.
|
||||
|
||||
# ================= Luật điều khiển (Stanley) =================
|
||||
path_yaw_mode: "tangent" # tangent | bearing. "bearing" là hành vi cũ, giữ để rollback
|
||||
# ngoài hiện trường không cần build lại. Luôn dùng "tangent".
|
||||
control_gain_e: 2.0 # gain hướng (tangent path - yaw robot).
|
||||
# Chỉnh: tăng -> quay đầu về hướng path nhanh hơn nhưng dễ
|
||||
# dao động; giảm nếu robot "vẫy đầu" quanh path. Đổi 0.5/lần.
|
||||
control_gain_d: 1.5 # gain nền của thành phần lệch ngang. ROBOT THẬT: 1.5.
|
||||
# Chỉnh: tăng -> kéo về path mạnh hơn, quá tay thì lắc kiểu
|
||||
# zigzag cắt qua path; giảm nếu zigzag, tăng nếu bám về quá chậm.
|
||||
# Robot thật đang chạy 1.5.
|
||||
gain_cte_weight: 0.8 # cộng vào k theo |lệch ngang| [1/m] — lệch to thì kéo mạnh hơn.
|
||||
# Chỉnh: tăng nếu lệch lớn hồi về quá chậm; giảm nếu cú hồi
|
||||
# đầu tiên bị giật.
|
||||
gain_heading_weight: 0.5 # cộng vào k theo |lỗi hướng| [1/rad].
|
||||
# Chỉnh: ít khi cần; tăng nhẹ nếu robot vào path với góc lớn
|
||||
# mà thành phần ngang phản ứng yếu.
|
||||
gain_min: 0.5 # chặn dưới của k. Chỉnh: sàn an toàn, giữ nguyên.
|
||||
gain_max: 2.3 # chặn trên của k.
|
||||
# Chỉnh: giảm nếu tổng gain bùng lên gây lắc khi vừa lệch
|
||||
# ngang vừa lệch hướng.
|
||||
soft_min_vel: 0.15 # [m/s] SÀN của mẫu số atan2(k*e, v). KHÔNG có trần.
|
||||
# Chỉnh: tăng -> lái dịu hơn ở tốc độ thấp (mẫu số to hơn);
|
||||
# giảm -> nhạy hơn khi bò chậm. Nếu robot giật lái lúc khởi
|
||||
# hành/gần dừng thì tăng lên 0.25-0.30.
|
||||
alpha_gain: 0.0 # lọc thông thấp lệnh lái [0..1]; 0 = tắt, đã có max_steer_rate lo.
|
||||
# Chỉnh: chỉ bật (0.2-0.5) nếu lệnh lái nhiễu răng cưa mà
|
||||
# slew limit chưa đủ; bật to quá gây trễ pha -> lắc chậm.
|
||||
curve_gain_e_bonus: 2.0 # cộng vào control_gain_e khi ở chế độ cong.
|
||||
# Chỉnh: sau rework feedforward đã gánh phần cong, bonus này
|
||||
# ít quan trọng hơn; giảm nếu trong cua robot phản ứng quá gắt.
|
||||
tangent_window_pts: 3 # số điểm lấy trung bình tangent khi plan không kèm yaw.
|
||||
# Chỉnh: tăng (5-7) nếu path răng cưa làm tangent nhiễu;
|
||||
# tăng nhiều làm cắt góc ở cua gắt.
|
||||
|
||||
# --- Rework bám cong (08/08) ---
|
||||
# Lỗi ngang đo tại BASE cho CẢ HAI chiều (biến thể đo tại trục lái tự chế ra
|
||||
# "phantom" L^2/2R trong cua — robot cắt VÀO TRONG cua khi tiến, dạt RA NGOÀI khi
|
||||
# lùi); mốc hướng preview một đoạn ngắn ĐỐI XỨNG hai chiều; bản thân đường cong do
|
||||
# feedforward atan(L*kappa) gánh. Sweep sim (R=1.5/3.0, hai chiều):
|
||||
# lệch max 0.013-0.016 m so với 0.061/0.129 trước đó.
|
||||
heading_preview: 0.10 # [m] mốc hướng (tangent) lấy TRƯỚC điểm neo base một đoạn này,
|
||||
# chung cho tiến và lùi.
|
||||
# Chỉnh: tăng (0.2-0.3) nếu servo trễ nhiều (robot thật trễ
|
||||
# 0.2-0.4 s) — robot vào cua muộn, lệch xuất hiện ở ĐẦU cua;
|
||||
# giảm về 0.1 nếu robot chớm cắt cua sớm. Quá to sẽ cắt góc
|
||||
# như lỗi cũ (preview 1.31 m chính là nguồn cắt-trong-cua).
|
||||
curve_feedforward_gain: 1.0 # gain feedforward atan(L*kappa); 0 = TẮT (rollback),
|
||||
# 1.0 = danh nghĩa hình học.
|
||||
# Chỉnh: nhìn dấu của lệch GIỮA cua trong [DBG-CURVE]:
|
||||
# còn dạt ra NGOÀI cua -> tăng 0.1/lần (tối đa ~1.3);
|
||||
# cắt vào TRONG cua -> giảm 0.1/lần. Sweep: 1.2 đã bắt đầu
|
||||
# đổi dấu (bù lố), nên đừng vượt 1.3. Đặt 0 để về luật cũ
|
||||
# không cần build lại.
|
||||
|
||||
# ===== Bù lệch hướng (heading bias: yawR - course, đo được +0.030 rad 07/08) =====
|
||||
# Yaw estimate lệch so với hướng đi thật một hằng số RE-ANCHOR khác nhau mỗi phiên
|
||||
# (IMU neo tuyệt đối), nên phải HỌC online từ course-over-ground chứ không cấu hình
|
||||
# cứng. steer offset không bù được cái này: MỐC hướng sai, không phải cơ cấu lái.
|
||||
heading_bias_mode: "apply" # off = tắt | log = chỉ ước lượng | apply = trừ bias đã học.
|
||||
# ROBOT THẬT: GIỮ "log". CHƯA bật "apply" — estimator vừa rework
|
||||
# 08/08 (fit 1-2 m + median seed + loại outlier + gate cross-track).
|
||||
# Nghiệm thu trước khi bật apply: chạy "log" 2 phiên (tắt nguồn
|
||||
# giữa 2 phiên), est phải ổn định ~+0.03 VÀ khớp yawR-crs trong
|
||||
# [DBG-SS] ở cả hai phiên. Lệch nhau = báo lại, đừng bật.
|
||||
# Sức khoẻ estimator xem [DBG-YAWBIAS]: rej= mẫu bị loại,
|
||||
# span= cửa sổ course [m], gate= (+ = đang học; c=course ngắn,
|
||||
# s=không thẳng, v=chậm, w=bánh đang bẻ, e=lệch ngang chưa yên,
|
||||
# t=teleport, o=outlier). SIM: "off".
|
||||
# log = chỉ ước lượng, [DBG-YAWBIAS] in số calib
|
||||
# apply= trừ bias đã học khỏi yaw đang điều khiển
|
||||
# (rollback hiện trường: chuyển "log", không cần build)
|
||||
# Chỉnh: quy trình chuẩn — chạy "log" vài phiên, số [DBG-YAWBIAS]
|
||||
# ổn định quanh một giá trị thì chuyển "apply". Sim để "off".
|
||||
heading_bias_tau: 30.0 # [s] hằng số thời gian EMA.
|
||||
# Chỉnh: tăng -> học chậm mà mượt; giảm -> bám nhanh nhưng
|
||||
# dễ nhiễm nhiễu course. 30 s là cân bằng cho phiên chạy dài.
|
||||
heading_bias_min_vel: 0.20 # [m/s] dưới tốc độ này không học (theo |v|, áp cả chiều lùi).
|
||||
# 0.20 (không phải 0.45 cũ): chất lượng course giờ phụ thuộc
|
||||
# QUÃNG ĐƯỜNG của cửa sổ PCA 1-2 m, không phụ thuộc tốc độ —
|
||||
# ngưỡng 0.45 là di sản của cửa sổ 2 điểm 0.15 m. Phải ≤ 0.25
|
||||
# thì các chặng LÙI (min_vel_x -0.25) mới học được.
|
||||
heading_bias_clamp: 0.05 # [rad] trần của lượng bù ĐƯỢC ÁP.
|
||||
# Chỉnh: an toàn — chỉ nâng khi [DBG-YAWBIAS] cho thấy bias
|
||||
# thật vượt trần một cách ổn định.
|
||||
heading_bias_min_samples: 30 # [chu kỳ] số mẫu học tối thiểu trước khi được áp.
|
||||
# 30 (không phải 60): sau rework, est tại n~26 đã trùng est cuối
|
||||
# phiên; để 60 thì route ngắn/nhiều lùi không bao giờ đủ mẫu —
|
||||
# log 09/08: est=0.040 đo đúng mà applied=0 cả phiên vì n kẹt 38,
|
||||
# robot trôi dần 3-5 cm trên đoạn thẳng trước cua.
|
||||
# Chỉnh: tăng nếu thấy áp bù quá sớm khi số còn nhiễu.
|
||||
|
||||
# ===== Tích phân bias lái (dọn phần dư) =====
|
||||
# Khi heading_bias_mode: apply thì nhiễu chính đã xử lý ở trên; tích phân này chỉ
|
||||
# quét phần còn sót. KHÔNG chạy cả hai ở cường độ tối đa.
|
||||
steer_bias_gain: 0.100 # [rad/(m*s)] 0 = TẮT. ROBOT THẬT: 0.10 — bộ bù CHÍNH khi mode
|
||||
# != apply (đo 08/08: mission 10-20 s, gain 0.02 cần ~50 s chạy
|
||||
# thẳng mới hội tụ nên không bao giờ tới; 0.10 xong trong ~1 chặng).
|
||||
# Khi apply được nghiệm thu và bật: hạ về 0.02 quét vụn —
|
||||
# KHÔNG chạy cả hai hết cỡ.
|
||||
# Chỉnh: tăng nếu vẫn còn lệch ngang thường trực nhỏ sau khi
|
||||
# đã xử lý zero offset + heading bias; tăng quá gây dao động
|
||||
# chậm chu kỳ dài (đặc trưng của tích phân quá tay).
|
||||
steer_bias_clamp: 0.05 # [rad] trần anti-windup.
|
||||
# Chỉnh: giữ nhỏ; nếu bias thật > 0.05 thì vấn đề là calib
|
||||
# phần cứng, không phải chỗ này.
|
||||
steer_bias_decay: 0.9999 # hệ số xả khi không đủ điều kiện tích phân. ROBOT THẬT: 0.9999
|
||||
# (~0.3%/s) — robot đứng chờ 30-60 s giữa mission; 0.995 (14%/s)
|
||||
# xả sạch bias mỗi lần đứng (log 08/08: 0.027 -> 0.010).
|
||||
# Chỉnh: gần 1 = nhớ lâu; giảm (0.99) nếu bias cũ đeo bám
|
||||
# sau khi điều kiện chạy đã đổi.
|
||||
steer_bias_min_vel: 0.15 # [m/s] dưới tốc này không tích phân (đứng yên/bò chậm
|
||||
# không phân biệt được bias với nhiễu).
|
||||
steer_bias_max_heading_err: 0.10 # [rad] lỗi hướng trên ngưỡng này không tích phân
|
||||
# (đang quay đầu chứ không phải bias).
|
||||
|
||||
# ================= Cửa sổ plan / lookahead =================
|
||||
max_global_plan_lookahead_dist: 3.0 # [m] trần cửa sổ.
|
||||
# Chỉnh: giảm nếu CPU nặng hoặc path xa gây nhiễu tangent;
|
||||
# phải đủ chứa quãng phanh v^2/(2a).
|
||||
min_lookahead: 0.50 # [m] sàn cửa sổ.
|
||||
# Chỉnh: tăng nếu cửa sổ ngắn làm tangent nhiễu lúc bò chậm.
|
||||
min_lookahead_near_goal: 0.40 # [m] sàn riêng khi gần đích.
|
||||
# Chỉnh: giảm nhẹ nếu gần đích cửa sổ dài kéo hướng lệch đi.
|
||||
dyn_lookahead_gain: 2.50 # [m/(m/s)] lookahead = min + gain*|v|.
|
||||
# Chỉnh: tăng -> nhìn xa hơn khi chạy nhanh (mượt, cắt góc);
|
||||
# giảm -> bám sát hơn (dễ lắc ở tốc độ cao).
|
||||
near_goal_freeze_dist: 0.50 # [m] dưới ngưỡng này: đóng băng yaw_path, chỉ chạy theta_d.
|
||||
# Chỉnh: tăng nếu cuối hành trình robot còn "vẹo đầu" theo
|
||||
# cửa sổ đang co; giảm nếu freeze quá sớm làm vào đích xiên.
|
||||
|
||||
# Ngưỡng liên tục chỉ số, tính bằng MÉT và quy ra index theo khoảng cách điểm đo
|
||||
# lúc runtime — độ phân giải plan là lựa chọn của global planner, không phải hằng số.
|
||||
# Áp cho CẢ closest (neo cửa sổ) lẫn target_idx_ (trong core).
|
||||
max_advance_dist: 0.20 # [m] quãng tiến tối đa dọc plan mỗi chu kỳ.
|
||||
# Chỉnh: phải > v_max * chu kỳ (0.04 m @ 1.2 m/s) nhiều lần;
|
||||
# quá nhỏ -> neo tụt lại sau robot; quá to -> mất tác dụng
|
||||
# chống nhảy index ở đoạn path gấp.
|
||||
max_back_dist: 0.10 # [m] quãng lùi tối đa dọc plan mỗi chu kỳ.
|
||||
# Chỉnh: giữ nhỏ hơn max_advance_dist; tăng nhẹ nếu sau
|
||||
# replan hợp lệ neo không chịu lùi về điểm đúng.
|
||||
|
||||
# ================= Độ cong =================
|
||||
high_curvature: 0.30 # [1/m] trên ngưỡng: co lookahead.
|
||||
mid_curvature: 0.20 # [1/m] trên ngưỡng: cắt cửa sổ transform.
|
||||
low_curvature: 0.10 # [1/m] trên ngưỡng: vào chế độ cong.
|
||||
# Chỉnh bộ ba: giảm low_curvature nếu robot vào cua mà chưa
|
||||
# kịp giảm tốc (vào chế độ cong sớm hơn); giữ thứ tự
|
||||
# low < mid < high.
|
||||
straight_confirm_steps: 110 # số chu kỳ thẳng liên tiếp trước khi rời chế độ cong.
|
||||
# Chỉnh: giảm (~60) nếu sau cua robot giữ tốc độ chậm quá lâu;
|
||||
# tăng nếu path cong-thẳng-cong liên tục làm nhảy chế độ.
|
||||
|
||||
# ================= Profile tốc độ =================
|
||||
speed_base: 0.30 # [m/s] nền của profile lái cosine.
|
||||
# Chỉnh: tốc độ "an toàn" khi đang bẻ lái nhiều; tăng nếu
|
||||
# robot quá rụt rè trong cua.
|
||||
curve_max_speed: 0.25 # [m/s] trần khi đang cong.
|
||||
# Chỉnh: tăng dần khi bám cong đã tốt (sau rework có thể thử
|
||||
# 0.3-0.35); lắc trong cua thì hạ xuống trước tiên.
|
||||
min_drive_speed: 0.07 # [m/s] sàn khi đang chạy.
|
||||
# Chỉnh: phải đủ thắng ma sát tĩnh của drive; robot khựng
|
||||
# từng nhịp ở tốc thấp -> tăng nhẹ.
|
||||
accel_distance: 2.00 # [m] quãng tăng tốc lại sau khi rời cua.
|
||||
# Chỉnh: giảm nếu sau cua tăng tốc quá ì; tăng nếu vọt ra
|
||||
# khỏi cua rồi lắc.
|
||||
decel_min: 0.05 # [m/s mỗi chu kỳ] mức giảm tốc khi dự đoán va chạm.
|
||||
decel_max: 0.10 # [m/s mỗi chu kỳ]
|
||||
# Chỉnh cặp này theo độ "phanh gấp" chấp nhận được khi
|
||||
# thấy vật cản; to quá gây giật, nhỏ quá phanh không kịp.
|
||||
collision_horizon_factor: 2.0 # nhân với max_vel_x ra quãng kiểm tra va chạm.
|
||||
# Chỉnh: tăng nếu tốc độ cao mà phát hiện vật cản trễ;
|
||||
# tăng kéo theo CPU kiểm tra footprint dài hơn.
|
||||
|
||||
# Governor quãng phanh: v <= sqrt(2*a*d_to_stop). Profile horizon một mình chỉ bắt
|
||||
# đầu phanh ~v*horizon trước đích (1.5 m @ 1.2 m/s, đòi ~1 m/s^2) — drive không theo
|
||||
# kịp và robot đã vượt đích 30 cm.
|
||||
goal_decel_limit: 0.30 # [m/s^2] ROBOT THẬT: 0.3 ĐÃ XÁC NHẬN dừng đúng @1.2 m/s; 0.4 vượt đích 30 cm.
|
||||
# Bắt đầu phanh tại v^2/(2a): 1.8 m @ 1.2 m/s, 0.3 m @ 0.5 m/s.
|
||||
# Chỉnh: robot vượt đích -> GIẢM
|
||||
# robot phanh quá sớm/bò vào đích lâu -> tăng dần
|
||||
# 0.05/lần, dừng ngay khi chớm vượt đích.
|
||||
min_approach_speed: 0.06 # [m/s] sàn tốc độ tiếp cận để profile sqrt vẫn chạm được đích.
|
||||
# Chỉnh: tăng nhẹ nếu robot bò quá chậm đoạn cuối; to quá
|
||||
# sẽ chạm đích với tốc độ dư -> dừng giật.
|
||||
|
||||
# ================= Align / phase =================
|
||||
heading_eps: 0.020 # [rad] lỗi hướng chấp nhận là "đã thẳng hàng".
|
||||
steer_eps: 0.020 # [rad] lỗi lái chấp nhận là "servo đã tới".
|
||||
# Chỉnh cặp eps: nhỏ hơn nhiễu encoder/yaw -> chờ align mãi
|
||||
# không xong (chatter wait_to_align); nới 0.005/lần.
|
||||
heading_align_tol: 0.050 # [rad] cổng cho đoạn tiến thẳng cuối (0.01 cũ là quá chặt).
|
||||
# Chỉnh: nới nếu cuối hành trình cứ dừng-xoay-dừng lặp lại.
|
||||
near_goal_dist: 0.50 # [m] dưới ngưỡng: bật chế độ tiến thẳng cuối.
|
||||
# Chỉnh: tăng nếu cần vào đích thẳng trục từ xa hơn (dock).
|
||||
steer_realign_off: 0.503 # [rad] trên ngưỡng: CẮT drive để chỉnh lại bánh (0.16*pi).
|
||||
steer_realign_on: 0.150 # [rad] dưới ngưỡng: CHẠY lại drive — phải NHỎ HƠN _off.
|
||||
# Chỉnh cặp hysteresis: khe _off - _on rộng = ít bật/tắt hơn;
|
||||
# nếu robot dừng/chạy lắt nhắt khi bẻ lái lớn thì NỚI RỘNG khe
|
||||
# (hạ _on hoặc nâng _off), đừng thu hẹp.
|
||||
steering_active: 0.094 # [rad] trên ngưỡng coi là lái đang hoạt động (0.03*pi).
|
||||
segment_transition_threshold: 0.010 # [m] Chỉnh: hiếm khi đụng.
|
||||
segment_end_ratio: 0.05 # phần còn lại của segment thì chuyển segment kế.
|
||||
# Chỉnh: tăng nếu chuyển segment trễ gây khựng ở khớp nối.
|
||||
xy_reached_gate_factor: 3.0 # nhân xy_goal_tolerance; cửa sổ 1 điểm chỉ được latch trong vùng này.
|
||||
# Chỉnh: chống latch đích sớm từ xa; tăng nếu miss latch
|
||||
# hợp lệ, giảm nếu latch khi còn cách đích xa.
|
||||
|
||||
# ================= TF guard =================
|
||||
# Đo trên robot thật: 225 cú nhảy map->odom, max 12.381 m, trùng thời điểm
|
||||
# localisation FinishTrajectory(1) 10:41:18 / AddTrajectory(2) 10:41:21. Nguồn nằm
|
||||
# ngoài gói này; đây là be bờ, không phải chữa gốc.
|
||||
tf_lookup_at_pose_stamp: true # true = tra tại pose.header.stamp thay vì "latest".
|
||||
# "latest" trả entry khác nhau mỗi lần gọi khi buffer
|
||||
# giữ hai transform map->odom. Giữ true.
|
||||
transform_tolerance: 0.20 # [s] tuổi chấp nhận khi tra theo timestamp.
|
||||
# Chỉnh: tăng nếu log báo transform quá cũ liên tục do
|
||||
# localisation publish thưa; to quá thì dùng TF ôi.
|
||||
max_plan_tf_jump_rate: 0.60 # [m/s] ROBOT THẬT: 0.60 — chặn xloc nhảy thật. SIM: nâng 1.5.
|
||||
# SIM: 1.5 — dynamic TF sim jitter 0.02-0.065 m/chu kỳ, để 0.6
|
||||
# thì budget ~0.02 m/chu kỳ -> reject dồn 30/30 và reset giữa
|
||||
# đường (log 08/08: 8 reset trong 2 lượt lùi).
|
||||
# ROBOT THẬT: hạ về 0.60 — xloc nhảy thật sự cần chặn.
|
||||
# Chỉnh: giảm nếu cú nhảy nhỏ vẫn lọt gây giật plan;
|
||||
# tăng nếu correction hợp lệ của localisation bị chặn oan
|
||||
# (đếm reject trong log [DBG-TF]).
|
||||
max_plan_tf_jump_abs: 1.00 # [m] trần cứng của bước chấp nhận: budget theo rate lớn dần
|
||||
# khi transform đứng yên lâu, không có trần thì cú nhảy
|
||||
# nhiều mét sau đoạn tĩnh dài sẽ được nhận luôn.
|
||||
# Chỉnh: giảm (0.5) nếu vẫn lọt cú nhảy lớn sau đoạn tĩnh.
|
||||
max_plan_tf_yaw_jump: 0.20 # [rad] ngưỡng xoay - code cũ chỉ soi tịnh tiến.
|
||||
# Chỉnh: giảm nếu plan xoay giật mà không bị bắt.
|
||||
tf_reject_window_cycles: 30 # cửa sổ trượt; vượt nghĩa là relocalisation thật.
|
||||
tf_reject_ratio: 0.5 # tỉ lệ reject trong cửa sổ thì kích reset.
|
||||
|
||||
# --- Đóng băng transform plan->odom theo từng leg (chống lắc khi map nhảy) ---
|
||||
plan_tf_freeze: false # true: transform map->odom yên đủ lâu thì KHÓA cho cả leg —
|
||||
# correction giữa chừng không còn dịch path dưới chân robot.
|
||||
# Dùng cho docking; false = live mỗi cycle như cũ.
|
||||
freeze_settle_cycles: 30 # [cycle] số cycle yên liên tiếp trước khi khóa. Phải >= 2x
|
||||
# chu kỳ update localization (AMCL ~2 Hz -> >= 1 s = 30 cycle),
|
||||
# không thì cửa sổ lọt giữa hai lần correction.
|
||||
freeze_settle_eps_xy: 0.005 # [m] bước transform/cycle dưới ngưỡng này tính là "yên".
|
||||
freeze_settle_eps_yaw: 0.005 # [rad]
|
||||
freeze_settle_timeout: 3.0 # [s] map nhảy liên tục không bao giờ yên -> hết hạn thì khóa
|
||||
# bản mới nhất kèm WARNING (live tiếp = đúng cái lắc đang trị).
|
||||
# Chỉnh cặp: window*ratio = số reject trước khi đầu hàng và
|
||||
# nhận vị trí mới; tăng nếu reset quá vội khi TF chỉ nhiễu
|
||||
# thoáng qua, giảm nếu ôm cache quá lâu sau relocalisation thật.
|
||||
|
||||
# ================= Debug =================
|
||||
debug_tf: false # nhom log TF (accepted-step, authority, chi tiet reject, fallback).
|
||||
# SIM: dynamic_tf nhieu chu dich -> tat cho log doc duoc.
|
||||
# ROBOT THAT: bat lai (true) khi san TF that.
|
||||
# Reset do reject keo dai van LUON duoc log bat ke cong tac nay.
|
||||
debug_offset: true # [DBG-OFF] 5 Hz bam path + thong ke max/mean |e| moi luot cua
|
||||
# (in kem dong DBG-CURVE exit) — soi lech trong duong cong.
|
||||
debug_level: 2 # 0=off 1=khi state đổi 2=throttle 1 Hz 3=mọi chu kỳ
|
||||
# 2 an toàn làm mặc định vận hành: gói này throttle bằng đồng hồ
|
||||
# riêng từng mục đích (log_*_throttle của robot_cpp dùng CHUNG MỘT
|
||||
# timer static cho cả process nên các dòng throttle nuốt lẫn nhau -
|
||||
# đừng dựa vào nó).
|
||||
# 3 in >1800 dòng/phút @ 30 Hz - chỉ dùng debug hiện trường.
|
||||
|
||||
StanleyDockingLocalPlanner:
|
||||
# Instance RIENG cua Stanley cho profile docking (cung .so, alias thu hai).
|
||||
# Block nay la BAN COPY DAY DU cua StanleyLocalPlanner + override — YAML khong
|
||||
# ke thua giua cac block: key thieu roi ve default C++ (vd steer_zero_offset 0),
|
||||
# KHONG roi ve block position (bay log 23). Sua tham so chung thi sua CA HAI block.
|
||||
# Cac dong override danh dau "DOCKING:". Comment chi tiet xem block position.
|
||||
library_path: libstanley_local_planner
|
||||
max_vel_x: 0.20 # [m/s] DOCKING: cham va co kiem soat
|
||||
min_vel_x: -0.20 # [m/s] DOCKING: lui cham vao dock
|
||||
wheel_base: 1.3118251 # [m] khoảng cách trục. 0 = tự đo từ TF front_axle_frame -> rear_axle_frame.
|
||||
front_axle_frame: "steer_link"
|
||||
rear_axle_frame: "base_link"
|
||||
steer_limit_standstill: 1.5708 # [rad] trần góc lái khi |v| ~ 0. CẦN ĐO THỰC TẾ.
|
||||
steer_limit_at_max_vel: 0.5000 # [rad] trần góc lái khi |v| = max_vel_x. CẦN ĐO THỰC TẾ.
|
||||
align_steer_angle: 1.5708 # [rad] góc lái khi xoay tại chỗ. Ghi số cụ thể, KHÔNG ghi M_PI/2.
|
||||
align_pivot_toward_curve: true # DOCKING: pivot do banh ve phia cua. ROBOT THAT: test drive nhan -90 truoc
|
||||
min_steer_angle: 0.20 # [rad] ngưỡng coi là "đang bẻ lái".
|
||||
max_steer_rate: 1.50 # [rad/s] tốc độ quay servo lái. Đo bằng [DBG-STEER] 07/08:
|
||||
steer_zero_offset: 0.037 # [rad]
|
||||
xy_goal_tolerance: 0.020 # [m] DOCKING: dung sai vi tri chat
|
||||
yaw_goal_tolerance: 0.050 # [rad] DOCKING: dung sai goc chat
|
||||
goal_sq_dist_tol: 0.05 # [m^2] thoát sớm vòng scan điểm gần nhất.
|
||||
path_yaw_mode: "tangent" # tangent | bearing. "bearing" là hành vi cũ, giữ để rollback
|
||||
control_gain_e: 2.0 # gain hướng (tangent path - yaw robot).
|
||||
control_gain_d: 1.5 # gain nền của thành phần lệch ngang. ROBOT THẬT: 1.5.
|
||||
gain_cte_weight: 0.9 # cộng vào k theo |lệch ngang| [1/m] — lệch to thì kéo mạnh hơn.
|
||||
gain_heading_weight: 0.5 # cộng vào k theo |lỗi hướng| [1/rad].
|
||||
gain_min: 0.5 # chặn dưới của k. Chỉnh: sàn an toàn, giữ nguyên.
|
||||
gain_max: 2.3 # chặn trên của k.
|
||||
soft_min_vel: 0.15 # [m/s] SÀN của mẫu số atan2(k*e, v). KHÔNG có trần.
|
||||
alpha_gain: 0.0 # lọc thông thấp lệnh lái [0..1]; 0 = tắt, đã có max_steer_rate lo.
|
||||
curve_gain_e_bonus: 2.0 # cộng vào control_gain_e khi ở chế độ cong.
|
||||
tangent_window_pts: 3 # số điểm lấy trung bình tangent khi plan không kèm yaw.
|
||||
heading_preview: 0.10 # [m] mốc hướng (tangent) lấy TRƯỚC điểm neo base một đoạn này,
|
||||
curve_feedforward_gain: 1.2 # gain feedforward atan(L*kappa); 0 = TẮT (rollback),
|
||||
heading_bias_mode: "inherit" # DOCKING: thua huong bu heading tu instance position (SharedHeadingBias)
|
||||
heading_bias_tau: 30.0 # [s] hằng số thời gian EMA.
|
||||
heading_bias_min_vel: 0.20 # [m/s] dưới tốc độ này không học (theo |v|, áp cả chiều lùi).
|
||||
heading_bias_clamp: 0.05 # [rad] trần của lượng bù ĐƯỢC ÁP.
|
||||
heading_bias_min_samples: 30 # [chu kỳ] số mẫu học tối thiểu trước khi được áp.
|
||||
steer_bias_gain: 0.100 # [rad/(m*s)] 0 = TẮT. ROBOT THẬT: 0.10 — bộ bù CHÍNH khi mode
|
||||
steer_bias_clamp: 0.05 # [rad] trần anti-windup.
|
||||
steer_bias_decay: 0.9999 # hệ số xả khi không đủ điều kiện tích phân. ROBOT THẬT: 0.9999
|
||||
steer_bias_min_vel: 0.15 # [m/s] dưới tốc này không tích phân (đứng yên/bò chậm
|
||||
steer_bias_max_heading_err: 0.10 # [rad] lỗi hướng trên ngưỡng này không tích phân
|
||||
max_global_plan_lookahead_dist: 3.0 # [m] trần cửa sổ.
|
||||
min_lookahead: 0.50 # [m] sàn cửa sổ.
|
||||
min_lookahead_near_goal: 0.40 # [m] sàn riêng khi gần đích.
|
||||
dyn_lookahead_gain: 2.50 # [m/(m/s)] lookahead = min + gain*|v|.
|
||||
near_goal_freeze_dist: 0.50 # [m] dưới ngưỡng này: đóng băng yaw_path, chỉ chạy theta_d.
|
||||
max_advance_dist: 0.20 # [m] quãng tiến tối đa dọc plan mỗi chu kỳ.
|
||||
max_back_dist: 0.10 # [m] quãng lùi tối đa dọc plan mỗi chu kỳ.
|
||||
high_curvature: 0.30 # [1/m] trên ngưỡng: co lookahead.
|
||||
mid_curvature: 0.20 # [1/m] trên ngưỡng: cắt cửa sổ transform.
|
||||
low_curvature: 0.10 # [1/m] trên ngưỡng: vào chế độ cong.
|
||||
straight_confirm_steps: 110 # số chu kỳ thẳng liên tiếp trước khi rời chế độ cong.
|
||||
speed_base: 0.20 # [m/s] nền của profile lái cosine.
|
||||
curve_max_speed: 0.20 # [m/s] trần khi đang cong.
|
||||
min_drive_speed: 0.07 # [m/s] sàn khi đang chạy.
|
||||
accel_distance: 2.00 # [m] quãng tăng tốc lại sau khi rời cua.
|
||||
decel_min: 0.05 # [m/s mỗi chu kỳ] mức giảm tốc khi dự đoán va chạm.
|
||||
decel_max: 0.10 # [m/s mỗi chu kỳ]
|
||||
collision_horizon_factor: 2.0 # nhân với max_vel_x ra quãng kiểm tra va chạm.
|
||||
goal_decel_limit: 0.30 # [m/s^2] ROBOT THẬT: 0.3 ĐÃ XÁC NHẬN dừng đúng @1.2 m/s; 0.4 vượt đích 30 cm.
|
||||
min_approach_speed: 0.06 # [m/s] sàn tốc độ tiếp cận để profile sqrt vẫn chạm được đích.
|
||||
heading_eps: 0.020 # [rad] lỗi hướng chấp nhận là "đã thẳng hàng".
|
||||
steer_eps: 0.020 # [rad] lỗi lái chấp nhận là "servo đã tới".
|
||||
heading_align_tol: 0.050 # [rad] cổng cho đoạn tiến thẳng cuối (0.01 cũ là quá chặt).
|
||||
near_goal_dist: 0.50 # [m] dưới ngưỡng: bật chế độ tiến thẳng cuối.
|
||||
steer_realign_off: 0.503 # [rad] trên ngưỡng: CẮT drive để chỉnh lại bánh (0.16*pi).
|
||||
steer_realign_on: 0.150 # [rad] dưới ngưỡng: CHẠY lại drive — phải NHỎ HƠN _off.
|
||||
steering_active: 0.094 # [rad] trên ngưỡng coi là lái đang hoạt động (0.03*pi).
|
||||
segment_transition_threshold: 0.010 # [m] Chỉnh: hiếm khi đụng.
|
||||
segment_end_ratio: 0.05 # phần còn lại của segment thì chuyển segment kế.
|
||||
xy_reached_gate_factor: 3.0 # nhân xy_goal_tolerance; cửa sổ 1 điểm chỉ được latch trong vùng này.
|
||||
tf_lookup_at_pose_stamp: true # true = tra tại pose.header.stamp thay vì "latest".
|
||||
transform_tolerance: 0.20 # [s] tuổi chấp nhận khi tra theo timestamp.
|
||||
max_plan_tf_jump_rate: 0.60 # [m/s] ROBOT THẬT: 0.60 — chặn xloc nhảy thật. SIM: nâng 1.5.
|
||||
max_plan_tf_jump_abs: 1.00 # [m] trần cứng của bước chấp nhận: budget theo rate lớn dần
|
||||
max_plan_tf_yaw_jump: 0.20 # [rad] ngưỡng xoay - code cũ chỉ soi tịnh tiến.
|
||||
tf_reject_window_cycles: 30 # cửa sổ trượt; vượt nghĩa là relocalisation thật.
|
||||
tf_reject_ratio: 0.5 # tỉ lệ reject trong cửa sổ thì kích reset.
|
||||
plan_tf_freeze: true # DOCKING: khoa transform map->odom theo leg, chong lac khi map nhay
|
||||
freeze_settle_cycles: 20 # [cycle] số cycle yên liên tiếp trước khi khóa. Phải >= 2x
|
||||
freeze_settle_eps_xy: 0.005 # [m] bước transform/cycle dưới ngưỡng này tính là "yên".
|
||||
freeze_settle_eps_yaw: 0.005 # [rad]
|
||||
freeze_settle_timeout: 3.0 # [s] map nhảy liên tục không bao giờ yên -> hết hạn thì khóa
|
||||
debug_tf: false # nhom log TF (accepted-step, authority, chi tiet reject, fallback).
|
||||
debug_offset: true # [DBG-OFF] 5 Hz bam path + thong ke max/mean |e| moi luot cua
|
||||
debug_level: 2 # 0=off 1=khi state đổi 2=throttle 1 Hz 3=mọi chu kỳ
|
||||
|
||||
StanleyGoStraightLocalPlanner:
|
||||
# Instance Stanley cho profile go_straight (cung .so, alias). Path 2 diem thang
|
||||
# la truong hop bam tam thuong nhat cua Stanley; move_straight lock gan goal.
|
||||
# Block la BAN COPY DAY DU cua StanleyLocalPlanner + override (YAML khong ke
|
||||
# thua giua cac block — key thieu roi ve default C++, bay log 23).
|
||||
library_path: libstanley_local_planner
|
||||
max_vel_x: 0.30 # [m/s] GO_STRAIGHT: leg tiep can ngan, cham va chinh xac
|
||||
min_vel_x: -0.20 # [m/s] GO_STRAIGHT: lui cham (vd lui ra khoi dock)
|
||||
wheel_base: 1.3118251 # [m] khoảng cách trục. 0 = tự đo từ TF front_axle_frame -> rear_axle_frame.
|
||||
front_axle_frame: "steer_link"
|
||||
rear_axle_frame: "base_link"
|
||||
steer_limit_standstill: 1.5708 # [rad] trần góc lái khi |v| ~ 0. CẦN ĐO THỰC TẾ.
|
||||
steer_limit_at_max_vel: 0.5000 # [rad] trần góc lái khi |v| = max_vel_x. CẦN ĐO THỰC TẾ.
|
||||
align_steer_angle: 1.5708 # [rad] góc lái khi xoay tại chỗ. Ghi số cụ thể, KHÔNG ghi M_PI/2.
|
||||
align_pivot_toward_curve: true # true: path cong ngay từ pose 0 (|ff| > 0.30 rad) thì pivot đỗ
|
||||
min_steer_angle: 0.20 # [rad] ngưỡng coi là "đang bẻ lái".
|
||||
max_steer_rate: 1.50 # [rad/s] tốc độ quay servo lái. Đo bằng [DBG-STEER] 07/08:
|
||||
steer_zero_offset: 0.037 # [rad]
|
||||
xy_goal_tolerance: 0.015 # [m] GO_STRAIGHT: dung sai chat nhu docking
|
||||
yaw_goal_tolerance: 0.010 # [rad]
|
||||
goal_sq_dist_tol: 0.05 # [m^2] thoát sớm vòng scan điểm gần nhất.
|
||||
path_yaw_mode: "tangent" # tangent | bearing. "bearing" là hành vi cũ, giữ để rollback
|
||||
control_gain_e: 2.0 # gain hướng (tangent path - yaw robot).
|
||||
control_gain_d: 1.5 # gain nền của thành phần lệch ngang. ROBOT THẬT: 1.5.
|
||||
gain_cte_weight: 0.8 # cộng vào k theo |lệch ngang| [1/m] — lệch to thì kéo mạnh hơn.
|
||||
gain_heading_weight: 0.5 # cộng vào k theo |lỗi hướng| [1/rad].
|
||||
gain_min: 0.5 # chặn dưới của k. Chỉnh: sàn an toàn, giữ nguyên.
|
||||
gain_max: 2.3 # chặn trên của k.
|
||||
soft_min_vel: 0.15 # [m/s] SÀN của mẫu số atan2(k*e, v). KHÔNG có trần.
|
||||
alpha_gain: 0.0 # lọc thông thấp lệnh lái [0..1]; 0 = tắt, đã có max_steer_rate lo.
|
||||
curve_gain_e_bonus: 2.0 # cộng vào control_gain_e khi ở chế độ cong.
|
||||
tangent_window_pts: 3 # số điểm lấy trung bình tangent khi plan không kèm yaw.
|
||||
heading_preview: 0.10 # [m] mốc hướng (tangent) lấy TRƯỚC điểm neo base một đoạn này,
|
||||
curve_feedforward_gain: 1.0 # gain feedforward atan(L*kappa); 0 = TẮT (rollback),
|
||||
heading_bias_mode: "inherit" # GO_STRAIGHT: thua huong bu tu instance position
|
||||
heading_bias_tau: 30.0 # [s] hằng số thời gian EMA.
|
||||
heading_bias_min_vel: 0.20 # [m/s] dưới tốc độ này không học (theo |v|, áp cả chiều lùi).
|
||||
heading_bias_clamp: 0.05 # [rad] trần của lượng bù ĐƯỢC ÁP.
|
||||
heading_bias_min_samples: 30 # [chu kỳ] số mẫu học tối thiểu trước khi được áp.
|
||||
steer_bias_gain: 0.100 # [rad/(m*s)] 0 = TẮT. ROBOT THẬT: 0.10 — bộ bù CHÍNH khi mode
|
||||
steer_bias_clamp: 0.05 # [rad] trần anti-windup.
|
||||
steer_bias_decay: 0.9999 # hệ số xả khi không đủ điều kiện tích phân. ROBOT THẬT: 0.9999
|
||||
steer_bias_min_vel: 0.15 # [m/s] dưới tốc này không tích phân (đứng yên/bò chậm
|
||||
steer_bias_max_heading_err: 0.10 # [rad] lỗi hướng trên ngưỡng này không tích phân
|
||||
max_global_plan_lookahead_dist: 3.0 # [m] trần cửa sổ.
|
||||
min_lookahead: 0.50 # [m] sàn cửa sổ.
|
||||
min_lookahead_near_goal: 0.40 # [m] sàn riêng khi gần đích.
|
||||
dyn_lookahead_gain: 2.50 # [m/(m/s)] lookahead = min + gain*|v|.
|
||||
near_goal_freeze_dist: 0.50 # [m] dưới ngưỡng này: đóng băng yaw_path, chỉ chạy theta_d.
|
||||
max_advance_dist: 0.20 # [m] quãng tiến tối đa dọc plan mỗi chu kỳ.
|
||||
max_back_dist: 0.10 # [m] quãng lùi tối đa dọc plan mỗi chu kỳ.
|
||||
high_curvature: 0.30 # [1/m] trên ngưỡng: co lookahead.
|
||||
mid_curvature: 0.20 # [1/m] trên ngưỡng: cắt cửa sổ transform.
|
||||
low_curvature: 0.10 # [1/m] trên ngưỡng: vào chế độ cong.
|
||||
straight_confirm_steps: 110 # số chu kỳ thẳng liên tiếp trước khi rời chế độ cong.
|
||||
speed_base: 0.30 # [m/s] nền của profile lái cosine.
|
||||
curve_max_speed: 0.25 # [m/s] trần khi đang cong.
|
||||
min_drive_speed: 0.07 # [m/s] sàn khi đang chạy.
|
||||
accel_distance: 2.00 # [m] quãng tăng tốc lại sau khi rời cua.
|
||||
decel_min: 0.05 # [m/s mỗi chu kỳ] mức giảm tốc khi dự đoán va chạm.
|
||||
decel_max: 0.10 # [m/s mỗi chu kỳ]
|
||||
collision_horizon_factor: 2.0 # nhân với max_vel_x ra quãng kiểm tra va chạm.
|
||||
goal_decel_limit: 0.30 # [m/s^2] ROBOT THẬT: 0.3 ĐÃ XÁC NHẬN dừng đúng @1.2 m/s; 0.4 vượt đích 30 cm.
|
||||
min_approach_speed: 0.06 # [m/s] sàn tốc độ tiếp cận để profile sqrt vẫn chạm được đích.
|
||||
heading_eps: 0.020 # [rad] lỗi hướng chấp nhận là "đã thẳng hàng".
|
||||
steer_eps: 0.020 # [rad] lỗi lái chấp nhận là "servo đã tới".
|
||||
heading_align_tol: 0.050 # [rad] cổng cho đoạn tiến thẳng cuối (0.01 cũ là quá chặt).
|
||||
near_goal_dist: 0.50 # [m] dưới ngưỡng: bật chế độ tiến thẳng cuối.
|
||||
steer_realign_off: 0.503 # [rad] trên ngưỡng: CẮT drive để chỉnh lại bánh (0.16*pi).
|
||||
steer_realign_on: 0.150 # [rad] dưới ngưỡng: CHẠY lại drive — phải NHỎ HƠN _off.
|
||||
steering_active: 0.094 # [rad] trên ngưỡng coi là lái đang hoạt động (0.03*pi).
|
||||
segment_transition_threshold: 0.010 # [m] Chỉnh: hiếm khi đụng.
|
||||
segment_end_ratio: 0.05 # phần còn lại của segment thì chuyển segment kế.
|
||||
xy_reached_gate_factor: 3.0 # nhân xy_goal_tolerance; cửa sổ 1 điểm chỉ được latch trong vùng này.
|
||||
tf_lookup_at_pose_stamp: true # true = tra tại pose.header.stamp thay vì "latest".
|
||||
transform_tolerance: 0.20 # [s] tuổi chấp nhận khi tra theo timestamp.
|
||||
max_plan_tf_jump_rate: 0.60 # [m/s] ROBOT THẬT: 0.60 — chặn xloc nhảy thật. SIM: nâng 1.5.
|
||||
max_plan_tf_jump_abs: 1.00 # [m] trần cứng của bước chấp nhận: budget theo rate lớn dần
|
||||
max_plan_tf_yaw_jump: 0.20 # [rad] ngưỡng xoay - code cũ chỉ soi tịnh tiến.
|
||||
tf_reject_window_cycles: 30 # cửa sổ trượt; vượt nghĩa là relocalisation thật.
|
||||
tf_reject_ratio: 0.5 # tỉ lệ reject trong cửa sổ thì kích reset.
|
||||
plan_tf_freeze: true # GO_STRAIGHT: khoa transform theo leg, chong lac khi map nhay
|
||||
freeze_settle_cycles: 30 # [cycle] số cycle yên liên tiếp trước khi khóa. Phải >= 2x
|
||||
freeze_settle_eps_xy: 0.005 # [m] bước transform/cycle dưới ngưỡng này tính là "yên".
|
||||
freeze_settle_eps_yaw: 0.005 # [rad]
|
||||
freeze_settle_timeout: 3.0 # [s] map nhảy liên tục không bao giờ yên -> hết hạn thì khóa
|
||||
debug_tf: false # nhom log TF (accepted-step, authority, chi tiet reject, fallback).
|
||||
debug_offset: true # [DBG-OFF] 5 Hz bam path + thong ke max/mean |e| moi luot cua
|
||||
debug_level: 2 # 0=off 1=khi state đổi 2=throttle 1 Hz 3=mọi chu kỳ
|
||||
|
||||
StanleyRotateLocalPlanner:
|
||||
# Instance Stanley cho profile rotate (cung .so, alias). Yeu cau rotate den voi
|
||||
# XY da nam trong tolerance -> controller vao thang Phase B: do banh +/-90 va
|
||||
# creep xoay ve yaw cua goal. Block la BAN COPY DAY DU + override (YAML khong
|
||||
# ke thua giua cac block).
|
||||
library_path: libstanley_local_planner
|
||||
max_vel_x: 0.30 # [m/s] ROTATE: chi dung cho creep pivot
|
||||
min_vel_x: -0.20 # [m/s]
|
||||
wheel_base: 1.3118251 # [m] khoảng cách trục. 0 = tự đo từ TF front_axle_frame -> rear_axle_frame.
|
||||
front_axle_frame: "steer_link"
|
||||
rear_axle_frame: "base_link"
|
||||
steer_limit_standstill: 1.5708 # [rad] trần góc lái khi |v| ~ 0. CẦN ĐO THỰC TẾ.
|
||||
steer_limit_at_max_vel: 0.5000 # [rad] trần góc lái khi |v| = max_vel_x. CẦN ĐO THỰC TẾ.
|
||||
align_steer_angle: 1.5708 # [rad] góc lái khi xoay tại chỗ. Ghi số cụ thể, KHÔNG ghi M_PI/2.
|
||||
align_pivot_toward_curve: true # true: path cong ngay từ pose 0 (|ff| > 0.30 rad) thì pivot đỗ
|
||||
min_steer_angle: 0.20 # [rad] ngưỡng coi là "đang bẻ lái".
|
||||
max_steer_rate: 1.50 # [rad/s] tốc độ quay servo lái. Đo bằng [DBG-STEER] 07/08:
|
||||
steer_zero_offset: 0.037 # [rad]
|
||||
xy_goal_tolerance: 0.10 # [m] ROTATE: goal ngay duoi chan robot — latch XY ngay lap tuc, chi con xoay yaw (Phase B)
|
||||
yaw_goal_tolerance: 0.010 # [rad] ROTATE: dung sai goc la san pham chinh
|
||||
goal_sq_dist_tol: 0.05 # [m^2] thoát sớm vòng scan điểm gần nhất.
|
||||
path_yaw_mode: "tangent" # tangent | bearing. "bearing" là hành vi cũ, giữ để rollback
|
||||
control_gain_e: 2.0 # gain hướng (tangent path - yaw robot).
|
||||
control_gain_d: 1.5 # gain nền của thành phần lệch ngang. ROBOT THẬT: 1.5.
|
||||
gain_cte_weight: 0.8 # cộng vào k theo |lệch ngang| [1/m] — lệch to thì kéo mạnh hơn.
|
||||
gain_heading_weight: 0.5 # cộng vào k theo |lỗi hướng| [1/rad].
|
||||
gain_min: 0.5 # chặn dưới của k. Chỉnh: sàn an toàn, giữ nguyên.
|
||||
gain_max: 2.3 # chặn trên của k.
|
||||
soft_min_vel: 0.15 # [m/s] SÀN của mẫu số atan2(k*e, v). KHÔNG có trần.
|
||||
alpha_gain: 0.0 # lọc thông thấp lệnh lái [0..1]; 0 = tắt, đã có max_steer_rate lo.
|
||||
curve_gain_e_bonus: 2.0 # cộng vào control_gain_e khi ở chế độ cong.
|
||||
tangent_window_pts: 3 # số điểm lấy trung bình tangent khi plan không kèm yaw.
|
||||
heading_preview: 0.10 # [m] mốc hướng (tangent) lấy TRƯỚC điểm neo base một đoạn này,
|
||||
curve_feedforward_gain: 1.0 # gain feedforward atan(L*kappa); 0 = TẮT (rollback),
|
||||
heading_bias_mode: "inherit" # ROTATE: xoay ve yaw tuyet doi nen can tru bu heading
|
||||
heading_bias_tau: 30.0 # [s] hằng số thời gian EMA.
|
||||
heading_bias_min_vel: 0.20 # [m/s] dưới tốc độ này không học (theo |v|, áp cả chiều lùi).
|
||||
heading_bias_clamp: 0.05 # [rad] trần của lượng bù ĐƯỢC ÁP.
|
||||
heading_bias_min_samples: 30 # [chu kỳ] số mẫu học tối thiểu trước khi được áp.
|
||||
steer_bias_gain: 0.100 # [rad/(m*s)] 0 = TẮT. ROBOT THẬT: 0.10 — bộ bù CHÍNH khi mode
|
||||
steer_bias_clamp: 0.05 # [rad] trần anti-windup.
|
||||
steer_bias_decay: 0.9999 # hệ số xả khi không đủ điều kiện tích phân. ROBOT THẬT: 0.9999
|
||||
steer_bias_min_vel: 0.15 # [m/s] dưới tốc này không tích phân (đứng yên/bò chậm
|
||||
steer_bias_max_heading_err: 0.10 # [rad] lỗi hướng trên ngưỡng này không tích phân
|
||||
max_global_plan_lookahead_dist: 3.0 # [m] trần cửa sổ.
|
||||
min_lookahead: 0.50 # [m] sàn cửa sổ.
|
||||
min_lookahead_near_goal: 0.40 # [m] sàn riêng khi gần đích.
|
||||
dyn_lookahead_gain: 2.50 # [m/(m/s)] lookahead = min + gain*|v|.
|
||||
near_goal_freeze_dist: 0.50 # [m] dưới ngưỡng này: đóng băng yaw_path, chỉ chạy theta_d.
|
||||
max_advance_dist: 0.20 # [m] quãng tiến tối đa dọc plan mỗi chu kỳ.
|
||||
max_back_dist: 0.10 # [m] quãng lùi tối đa dọc plan mỗi chu kỳ.
|
||||
high_curvature: 0.30 # [1/m] trên ngưỡng: co lookahead.
|
||||
mid_curvature: 0.20 # [1/m] trên ngưỡng: cắt cửa sổ transform.
|
||||
low_curvature: 0.10 # [1/m] trên ngưỡng: vào chế độ cong.
|
||||
straight_confirm_steps: 110 # số chu kỳ thẳng liên tiếp trước khi rời chế độ cong.
|
||||
speed_base: 0.30 # [m/s] nền của profile lái cosine.
|
||||
curve_max_speed: 0.25 # [m/s] trần khi đang cong.
|
||||
min_drive_speed: 0.07 # [m/s] sàn khi đang chạy.
|
||||
accel_distance: 2.00 # [m] quãng tăng tốc lại sau khi rời cua.
|
||||
decel_min: 0.05 # [m/s mỗi chu kỳ] mức giảm tốc khi dự đoán va chạm.
|
||||
decel_max: 0.10 # [m/s mỗi chu kỳ]
|
||||
collision_horizon_factor: 2.0 # nhân với max_vel_x ra quãng kiểm tra va chạm.
|
||||
goal_decel_limit: 0.30 # [m/s^2] ROBOT THẬT: 0.3 ĐÃ XÁC NHẬN dừng đúng @1.2 m/s; 0.4 vượt đích 30 cm.
|
||||
min_approach_speed: 0.06 # [m/s] sàn tốc độ tiếp cận để profile sqrt vẫn chạm được đích.
|
||||
heading_eps: 0.020 # [rad] lỗi hướng chấp nhận là "đã thẳng hàng".
|
||||
steer_eps: 0.020 # [rad] lỗi lái chấp nhận là "servo đã tới".
|
||||
heading_align_tol: 0.050 # [rad] cổng cho đoạn tiến thẳng cuối (0.01 cũ là quá chặt).
|
||||
near_goal_dist: 0.50 # [m] dưới ngưỡng: bật chế độ tiến thẳng cuối.
|
||||
steer_realign_off: 0.503 # [rad] trên ngưỡng: CẮT drive để chỉnh lại bánh (0.16*pi).
|
||||
steer_realign_on: 0.150 # [rad] dưới ngưỡng: CHẠY lại drive — phải NHỎ HƠN _off.
|
||||
steering_active: 0.094 # [rad] trên ngưỡng coi là lái đang hoạt động (0.03*pi).
|
||||
segment_transition_threshold: 0.010 # [m] Chỉnh: hiếm khi đụng.
|
||||
segment_end_ratio: 0.05 # phần còn lại của segment thì chuyển segment kế.
|
||||
xy_reached_gate_factor: 3.0 # nhân xy_goal_tolerance; cửa sổ 1 điểm chỉ được latch trong vùng này.
|
||||
tf_lookup_at_pose_stamp: true # true = tra tại pose.header.stamp thay vì "latest".
|
||||
transform_tolerance: 0.20 # [s] tuổi chấp nhận khi tra theo timestamp.
|
||||
max_plan_tf_jump_rate: 0.60 # [m/s] ROBOT THẬT: 0.60 — chặn xloc nhảy thật. SIM: nâng 1.5.
|
||||
max_plan_tf_jump_abs: 1.00 # [m] trần cứng của bước chấp nhận: budget theo rate lớn dần
|
||||
max_plan_tf_yaw_jump: 0.20 # [rad] ngưỡng xoay - code cũ chỉ soi tịnh tiến.
|
||||
tf_reject_window_cycles: 30 # cửa sổ trượt; vượt nghĩa là relocalisation thật.
|
||||
tf_reject_ratio: 0.5 # tỉ lệ reject trong cửa sổ thì kích reset.
|
||||
plan_tf_freeze: true # ROTATE: khoa transform — map nhay giua luc xoay khong keo lech goc tham chieu
|
||||
freeze_settle_cycles: 30 # [cycle] số cycle yên liên tiếp trước khi khóa. Phải >= 2x
|
||||
freeze_settle_eps_xy: 0.005 # [m] bước transform/cycle dưới ngưỡng này tính là "yên".
|
||||
freeze_settle_eps_yaw: 0.005 # [rad]
|
||||
freeze_settle_timeout: 3.0 # [s] map nhảy liên tục không bao giờ yên -> hết hạn thì khóa
|
||||
debug_tf: false # nhom log TF (accepted-step, authority, chi tiet reject, fallback).
|
||||
debug_offset: true # [DBG-OFF] 5 Hz bam path + thong ke max/mean |e| moi luot cua
|
||||
debug_level: 2 # 0=off 1=khi state đổi 2=throttle 1 Hz 3=mọi chu kỳ
|
||||
3
config/runtime/two_points_global_params.yaml
Normal file
3
config/runtime/two_points_global_params.yaml
Normal file
@@ -0,0 +1,3 @@
|
||||
TwoPointsPlanner:
|
||||
library_path: libtwo_points_planner
|
||||
lethal_obstacle: 20
|
||||
673
doc/architecture_discussion.md
Normal file
673
doc/architecture_discussion.md
Normal file
@@ -0,0 +1,673 @@
|
||||
# Thảo luận về Kiến trúc Navigation cho AMR
|
||||
|
||||
## Mục tiêu dự án
|
||||
|
||||
Nghiên cứu và phát triển hệ thống navigation (di chuyển bám quỹ đạo) cho robot AMR dạng hai bánh vi sai, **không sử dụng ROS**, viết thuần C++ với CMake trên Linux.
|
||||
|
||||
## Yêu cầu chức năng
|
||||
|
||||
Từ `readme.md`:
|
||||
|
||||
- Có khả năng thay đổi mô hình kinematics (dạng hai bánh vi sai, dạng steering bicycle, ...)
|
||||
- Có chức năng di chuyển từ điểm khởi đầu đến điểm đích
|
||||
- Có chức năng xoay tròn
|
||||
- Có chức năng đi thẳng
|
||||
- Có chức năng thay đổi vận tốc
|
||||
|
||||
## Sơ đồ kiến trúc hệ thống
|
||||
|
||||
Kiến trúc được thiết kế theo mô hình layered, tách biệt các concerns và cho phép mở rộng dễ dàng:
|
||||
|
||||
```mermaid
|
||||
flowchart TB
|
||||
%% ========== API LAYER ==========
|
||||
subgraph API["🌐 API Layer"]
|
||||
direction TB
|
||||
CAPI["<b>📦 C API</b><br/>━━━━━━━━━━━━━━━━<br/>🔌 nav_c_api<br/>💻 P/Invoke cho .NET/C#<br/>📝 Wrapper Functions<br/>🔗 Interop Layer"]
|
||||
style API fill:#E3F2FD,stroke:#1976D2,stroke-width:4px,color:#000
|
||||
style CAPI fill:#BBDEFB,stroke:#1976D2,stroke-width:3px,font-size:14px
|
||||
end
|
||||
|
||||
%% ========== USER CONTROLLER LAYER ==========
|
||||
subgraph UserController["🎮 User Controller Layer"]
|
||||
direction TB
|
||||
UserCtrl["<b>🔌 User Controller Plugin</b><br/>━━━━━━━━━━━━━━━━<br/>📚 Dynamic Loader<br/>⚙️ boost::dll<br/>🎯 Custom Behavior<br/>🔄 Runtime Loading"]
|
||||
style UserController fill:#F3E5F5,stroke:#7B1FA2,stroke-width:4px,color:#000
|
||||
style UserCtrl fill:#E1BEE7,stroke:#7B1FA2,stroke-width:3px,font-size:14px
|
||||
end
|
||||
|
||||
%% ========== INTERFACE LAYER ==========
|
||||
subgraph Interface["🔌 Interface Layer"]
|
||||
direction TB
|
||||
BaseNav["<b>📋 BaseNavigation</b><br/>━━━━━━━━━━━━━━━━<br/>🏗️ move_base_core::BaseNavigation<br/>🎯 Abstract Interface<br/>━━━━━━━━━━━━━━━━<br/>📍 moveTo (goal / order)<br/>🔄 executeInstantActions<br/>⏸️ pause, resume, cancel<br/>📊 getRobotPose"]
|
||||
style Interface fill:#FFF3E0,stroke:#E65100,stroke-width:4px,color:#000
|
||||
style BaseNav fill:#FFE0B2,stroke:#E65100,stroke-width:3px,font-size:14px
|
||||
end
|
||||
|
||||
%% ========== MOVE BASE CORE ==========
|
||||
subgraph MoveBaseCore["⚙️ Move Base Core"]
|
||||
direction TB
|
||||
MoveBase["<b>🚀 MoveBase</b><br/>━━━━━━━━━━━━━━━━<br/>📦 move_base::MoveBase<br/>🔄 State Machine<br/>━━━━━━━━━━━━━━━━<br/>📊 PLANNING<br/>🎮 CONTROLLING<br/>🧹 CLEARING<br/>━━━━━━━━━━━━━━━━<br/>🎛️ Control Loop<br/>🔄 executeCycle"]
|
||||
style MoveBaseCore fill:#E8F5E9,stroke:#2E7D32,stroke-width:4px,color:#000
|
||||
style MoveBase fill:#C8E6C9,stroke:#2E7D32,stroke-width:3px,font-size:14px
|
||||
end
|
||||
|
||||
%% ========== PLANNING LAYER ==========
|
||||
subgraph Planning["🗺️ Planning Layer - Plugin System"]
|
||||
direction LR
|
||||
GP["<b>🌍 Global Planner</b><br/>━━━━━━━━━━━━━━━━<br/>📋 nav_core::BaseGlobalPlanner<br/>🔌 Dynamic Plugin<br/>━━━━━━━━━━━━━━━━<br/>🎯 A*, D*, Hybrid A*<br/>📐 Long-range Planning<br/>🗺️ Global Path"]
|
||||
LP["<b>📍 Local Planner</b><br/>━━━━━━━━━━━━━━━━<br/>📋 nav_core::BaseLocalPlanner<br/>🔌 Dynamic Plugin<br/>━━━━━━━━━━━━━━━━<br/>🎯 DWA, TEB, MKT<br/>🚗 Velocity Commands<br/>🛡️ Obstacle Avoidance"]
|
||||
RB["<b>🔄 Recovery Behaviors</b><br/>━━━━━━━━━━━━━━━━<br/>📋 nav_core::RecoveryBehavior<br/>🔌 Dynamic Plugin<br/>━━━━━━━━━━━━━━━━<br/>🧹 Clear Costmap<br/>🔄 Rotate Recovery<br/>🚨 Emergency Stop"]
|
||||
style Planning fill:#E1F5FE,stroke:#0277BD,stroke-width:4px,color:#000
|
||||
style GP fill:#B3E5FC,stroke:#0277BD,stroke-width:3px,font-size:13px
|
||||
style LP fill:#B3E5FC,stroke:#0277BD,stroke-width:3px,font-size:13px
|
||||
style RB fill:#B3E5FC,stroke:#0277BD,stroke-width:3px,font-size:13px
|
||||
end
|
||||
|
||||
%% ========== COSTMAP LAYER ==========
|
||||
subgraph Costmap["🗺️ Costmap Layer"]
|
||||
direction LR
|
||||
GC["<b>🌍 Global Costmap</b><br/>━━━━━━━━━━━━━━━━<br/>📦 robot_costmap_2d::Costmap2DROBOT<br/>🌍 frame: map<br/>━━━━━━━━━━━━━━━━<br/>🗺️ Static Map<br/>🚫 Obstacles<br/>💰 Inflation Layer"]
|
||||
LC["<b>📍 Local Costmap</b><br/>━━━━━━━━━━━━━━━━<br/>📦 robot_costmap_2d::Costmap2DROBOT<br/>📍 frame: odom<br/>━━━━━━━━━━━━━━━━<br/>🔍 Dynamic Obstacles<br/>📡 Sensor Fusion<br/>⚡ Real-time Updates"]
|
||||
style Costmap fill:#F1F8E9,stroke:#558B2F,stroke-width:4px,color:#000
|
||||
style GC fill:#DCEDC8,stroke:#558B2F,stroke-width:3px,font-size:13px
|
||||
style LC fill:#DCEDC8,stroke:#558B2F,stroke-width:3px,font-size:13px
|
||||
end
|
||||
|
||||
%% ========== ALGORITHMS LAYER ==========
|
||||
subgraph Algorithms["🧮 Algorithms Layer"]
|
||||
direction LR
|
||||
MKTAlgo["<b>🚗 MKT Algorithm</b><br/>━━━━━━━━━━━━━━━━<br/>⚙️ Diff Drive Kinematics<br/>🚲 Bicycle Kinematics<br/>📐 Trajectory Generation"]
|
||||
ScoreAlgo["<b>📊 Score Algorithm</b><br/>━━━━━━━━━━━━━━━━<br/>📈 Trajectory Scoring<br/>✅ Goal Checking<br/>🎯 Path Evaluation"]
|
||||
KalmanAlgo["<b>🔍 Kalman Filter</b><br/>━━━━━━━━━━━━━━━━<br/>📊 State Estimation<br/>🔮 Sensor Fusion<br/>📉 Noise Filtering"]
|
||||
style Algorithms fill:#FCE4EC,stroke:#C2185B,stroke-width:4px,color:#000
|
||||
style MKTAlgo fill:#F8BBD0,stroke:#C2185B,stroke-width:3px,font-size:13px
|
||||
style ScoreAlgo fill:#F8BBD0,stroke:#C2185B,stroke-width:3px,font-size:13px
|
||||
style KalmanAlgo fill:#F8BBD0,stroke:#C2185B,stroke-width:3px,font-size:13px
|
||||
end
|
||||
|
||||
%% ========== DATA SOURCES ==========
|
||||
subgraph DataSources["📡 Data Sources"]
|
||||
direction TB
|
||||
Goal["<b>🎯 Goal Input</b><br/>━━━━━━━━━━━━━━━━<br/>📍 robot_geometry_msgs::PoseStamped<br/>📨 move_base_simple/goal"]
|
||||
Loc["<b>🌍 Localization</b><br/>━━━━━━━━━━━━━━━━<br/>📍 Pnkx Loc<br/>🗺️ Global Pose<br/>🔄 Pose Updates"]
|
||||
TF["<b>🔄 Transform System</b><br/>━━━━━━━━━━━━━━━━<br/>📐 tf3::BufferCore<br/>🌐 Coordinate Frames<br/>⏱️ Time Synchronization"]
|
||||
Odom["<b>🚗 Odometry</b><br/>━━━━━━━━━━━━━━━━<br/>📍 robot_geometry_msgs::Odometry<br/>⚡ Robot Velocity<br/>📊 Position Tracking"]
|
||||
Laser["<b>📡 Laser Sensors</b><br/>━━━━━━━━━━━━━━━━<br/>🔍 robot_sensor_msgs::LaserScan<br/>🚫 Obstacle Detection<br/>📏 Distance Measurement"]
|
||||
Map["<b>🗺️ Map Server</b><br/>━━━━━━━━━━━━━━━━<br/>📋 robot_nav_msgs::OccupancyGrid<br/>🏗️ Static Map<br/>📐 Map Metadata"]
|
||||
style DataSources fill:#FFF9C4,stroke:#F57F17,stroke-width:4px,color:#000
|
||||
style Goal fill:#FFF59D,stroke:#F57F17,stroke-width:3px,font-size:12px
|
||||
style Loc fill:#FFF59D,stroke:#F57F17,stroke-width:3px,font-size:12px
|
||||
style TF fill:#FFF59D,stroke:#F57F17,stroke-width:3px,font-size:12px
|
||||
style Odom fill:#FFF59D,stroke:#F57F17,stroke-width:3px,font-size:12px
|
||||
style Laser fill:#FFF59D,stroke:#F57F17,stroke-width:3px,font-size:12px
|
||||
style Map fill:#FFF59D,stroke:#F57F17,stroke-width:3px,font-size:12px
|
||||
end
|
||||
|
||||
%% ========== CONTROL LOOP ==========
|
||||
subgraph ControlLoop["🔄 Control Loop"]
|
||||
direction LR
|
||||
CmdVel["<b>⚡ Velocity Command</b><br/>━━━━━━━━━━━━━━━━<br/>📤 robot_geometry_msgs::Twist<br/>📨 cmd_vel<br/>━━━━━━━━━━━━━━━━<br/>➡️ Linear Velocity<br/>🔄 Angular Velocity"]
|
||||
BaseCtrl["<b>🎮 Base Controller</b><br/>━━━━━━━━━━━━━━━━<br/>🚗 diff_driver_controller<br/>🚲 steer_drive_controller<br/>━━━━━━━━━━━━━━━━<br/>⚙️ Kinematics<br/>🔧 Hardware Interface"]
|
||||
style ControlLoop fill:#FFEBEE,stroke:#C62828,stroke-width:4px,color:#000
|
||||
style CmdVel fill:#FFCDD2,stroke:#C62828,stroke-width:3px,font-size:13px
|
||||
style BaseCtrl fill:#FFCDD2,stroke:#C62828,stroke-width:3px,font-size:13px
|
||||
end
|
||||
|
||||
%% ========== CONNECTIONS ==========
|
||||
%% API to User Controller
|
||||
CAPI -->|"🔗 P/Invoke"| UserCtrl
|
||||
|
||||
%% User Controller to Interface
|
||||
UserCtrl -->|"🎯 Uses"| BaseNav
|
||||
|
||||
%% Interface to MoveBase
|
||||
BaseNav -->|"⚙️ Implements"| MoveBase
|
||||
|
||||
%% MoveBase to Planning
|
||||
MoveBase -->|"🎛️ Manages"| GP
|
||||
MoveBase -->|"🎛️ Manages"| LP
|
||||
MoveBase -->|"🎛️ Manages"| RB
|
||||
|
||||
%% MoveBase to Costmap
|
||||
MoveBase -->|"🎛️ Manages"| GC
|
||||
MoveBase -->|"🎛️ Manages"| LC
|
||||
|
||||
%% Data Sources to Components
|
||||
Goal -->|"📥 Input"| UserCtrl
|
||||
Goal -->|"📥 Input"| BaseNav
|
||||
Loc -->|"📍 Pose"| MoveBase
|
||||
TF -->|"🔄 Transforms"| MoveBase
|
||||
Laser -->|"📡 Scan Data"| LC
|
||||
Map -->|"🗺️ Static Map"| GC
|
||||
Odom -->|"⚡ Velocity"| LP
|
||||
Odom -->|"📍 Pose"| MoveBase
|
||||
|
||||
%% Planning Flow
|
||||
GC -->|"🗺️ Costmap"| GP
|
||||
GP -->|"🛤️ Global Path"| LP
|
||||
LC -->|"🗺️ Costmap"| LP
|
||||
LC -->|"🗺️ Costmap"| RB
|
||||
GC -->|"🗺️ Costmap"| RB
|
||||
|
||||
%% Algorithm Integration
|
||||
MKTAlgo -->|"🚗 Kinematics"| LP
|
||||
ScoreAlgo -->|"📊 Scoring"| LP
|
||||
KalmanAlgo -.->|"🔍 Filtering"| Loc
|
||||
|
||||
%% Control Flow
|
||||
LP -->|"⚡ Velocity Cmd"| CmdVel
|
||||
CmdVel -->|"▶️ Execute"| BaseCtrl
|
||||
BaseCtrl -->|"📊 Feedback"| Odom
|
||||
|
||||
%% Styling Classes
|
||||
classDef implemented fill:#C8E6C9,stroke:#2E7D32,stroke-width:4px,color:#000
|
||||
classDef partial fill:#FFF9C4,stroke:#F57F17,stroke-width:3px,color:#000
|
||||
classDef todo fill:#FFCDD2,stroke:#C62828,stroke-width:3px,color:#000
|
||||
|
||||
class BaseNav,MoveBase,GP,LP,RB,GC,LC,CAPI,MKTAlgo,ScoreAlgo,KalmanAlgo,UserCtrl implemented
|
||||
class BaseCtrl,Loc,Odom,Map,Laser,TF partial
|
||||
```
|
||||
|
||||
## Đề xuất giải pháp kiến trúc
|
||||
|
||||
### 1. Xác định phạm vi & yêu cầu vận hành
|
||||
|
||||
Cần làm rõ:
|
||||
- **Kịch bản sử dụng chính**: go-to-goal trong môi trường indoor/outdoor? Tốc độ di chuyển? Độ chính xác yêu cầu?
|
||||
- **Cảm biến có sẵn**: encoder, IMU, lidar, camera? Dữ liệu nào đã có?
|
||||
- **Yêu cầu real-time**: chu kỳ điều khiển (control loop frequency), độ trễ tối đa cho phép?
|
||||
|
||||
### 2. Kiến trúc tổng thể
|
||||
|
||||
**Các layer chính:**
|
||||
|
||||
1. **API Layer** ✅
|
||||
- C API (`nav_c_api`) cho P/Invoke với .NET/C#
|
||||
- Wrapper functions cho tất cả BaseNavigation methods
|
||||
|
||||
2. **User Controller Layer** ✅
|
||||
- **User Controller Plugin**: Dynamically allocated từ loader controller plugin
|
||||
- Sử dụng `boost::dll` để load plugins động
|
||||
- Cho phép user định nghĩa controller riêng để điều khiển navigation behavior
|
||||
- Kết nối với `BaseNavigation` interface
|
||||
|
||||
3. **Interface Layer** ✅
|
||||
- `move_base_core::BaseNavigation`: Abstract interface cho navigation
|
||||
- Định nghĩa các operations: moveTo (goal / order), executeInstantActions, pause, resume, cancel
|
||||
- Là lớp trung gian định nghĩa các phương thức và thuộc tính liên quan đến navigation
|
||||
|
||||
4. **Move Base Core** ✅
|
||||
- `move_base::MoveBase`: Core implementation của BaseNavigation
|
||||
- Quản lý state machine (PLANNING, CONTROLLING, CLEARING)
|
||||
- Điều phối global/local planner và recovery behaviors
|
||||
- Quản lý costmaps (global và local)
|
||||
- Thực thi control loop (executeCycle)
|
||||
|
||||
4. **Planning Layer** ✅
|
||||
- `robot_nav_core::BaseGlobalPlanner`: Interface cho global planners
|
||||
- **Global Planner Implementations**:
|
||||
- `custom_planner` - Custom path planner với curve support và merge path calculation
|
||||
- `dock_planner` - Docking-specific planner với dock calculation utilities
|
||||
- `two_points_planner` - Simple planner cho two-point navigation
|
||||
- `robot_nav_core::BaseLocalPlanner`: Interface cho local planners
|
||||
- **Local Planner Implementation**:
|
||||
- `pnkx_local_planner` - Main local planner với multiple behaviors:
|
||||
- Position planning (MKT algorithm)
|
||||
- Docking planning
|
||||
- Go straight planning
|
||||
- Rotate planning
|
||||
- `robot_nav_core::RecoveryBehavior`: Interface cho recovery behaviors
|
||||
- Plugin system sử dụng `boost::dll` và `robot::PluginLoaderHelper` để dynamic loading
|
||||
|
||||
5. **Costmap Layer** ✅
|
||||
- `robot_costmap_2d::Costmap2DROBOT`: Global và local costmap wrapper
|
||||
- `robot_costmap_2d::LayeredCostmap`: Layered costmap system
|
||||
- **Costmap Layers** (8 implementations):
|
||||
- `StaticLayer` - Static map từ OccupancyGrid
|
||||
- `ObstacleLayer` - Dynamic obstacles từ sensors
|
||||
- `InflationLayer` - Cost inflation cho robot footprint
|
||||
- `VoxelLayer` - 3D voxel grid cho obstacles
|
||||
- `CriticalLayer` - Critical zones marking
|
||||
- `DirectionalLayer` - Directional cost preferences
|
||||
- `PreferredLayer` - Preferred path zones
|
||||
- `UnpreferredLayer` - Unpreferred zones
|
||||
- Frame management: map (global), odom (local)
|
||||
- Thread-safe access với mutex
|
||||
- Observation buffer cho sensor data
|
||||
|
||||
6. **Algorithms Layer** ✅
|
||||
- **MKT Algorithm** (`mkt_algorithm`):
|
||||
- Differential drive kinematics:
|
||||
- `diff_go_straight` - Go straight behavior
|
||||
- `diff_predictive_trajectory` - Predictive trajectory following
|
||||
- `diff_rotate_to_goal` - Rotate to goal
|
||||
- Bicycle model kinematics:
|
||||
- `bicycle_go_straight` - Go straight với bicycle model
|
||||
- `bicycle_pure_pursuit` - Pure pursuit control
|
||||
- `bicycle_rotate_to_goal` - Rotate behavior
|
||||
- **MKT Plugins** (`mkt_plugins`):
|
||||
- `goal_checker` - Goal checking algorithms
|
||||
- `simple_goal_checker` - Simple goal checking
|
||||
- `standard_traj_generator` - Standard trajectory generation
|
||||
- `limited_accel_generator` - Acceleration-limited trajectory generation
|
||||
- `kinematic_parameters` - Kinematics parameter management
|
||||
- `xy_theta_iterator` - Trajectory iteration utilities
|
||||
- `velocity_iterator` - Velocity space iteration
|
||||
- `one_d_velocity_iterator` - 1D velocity iteration
|
||||
- **Score Algorithm** (`score_algorithm`):
|
||||
- Trajectory scoring và evaluation
|
||||
- Goal checking utilities
|
||||
- Trajectory generator interface
|
||||
- **Kalman Filter** (`kalman`):
|
||||
- State estimation
|
||||
- Sensor fusion
|
||||
- Noise filtering
|
||||
|
||||
7. **Data Sources** ⚠️ (Interface cần định nghĩa)
|
||||
- Localization source (Pnkx Loc)
|
||||
- Odometry source
|
||||
- Sensor transforms (tf3)
|
||||
- Map server
|
||||
- Laser sensors
|
||||
|
||||
8. **Control Layer** ⚠️ (Cần implementation)
|
||||
- Base Controller interface (Diff/Steer drive)
|
||||
- Velocity command execution
|
||||
|
||||
**Định dạng dữ liệu:**
|
||||
- `robot_geometry_msgs::Pose2D` / `robot_geometry_msgs::PoseStamped` (vị trí + hướng)
|
||||
- `robot_geometry_msgs::Twist` (vận tốc linear/angular)
|
||||
- `std::vector<robot_geometry_msgs::PoseStamped>` (đường đi)
|
||||
- `robot_costmap_2d::Costmap2D` (bản đồ chi phí)
|
||||
|
||||
### 3. Thiết kế từng module (interface level)
|
||||
|
||||
**Các interface đã có:** ✅
|
||||
|
||||
- `move_base_core::BaseNavigation` ✅
|
||||
- `initialize(TFListenerPtr)` - Khởi tạo với TF listener
|
||||
- `moveTo(goal, xy_tol, yaw_tol)` - Di chuyển đến goal
|
||||
- `moveTo(order, goal, ...)` - Một order VDA5050, cắt thành từng chặng
|
||||
- `executeInstantActions(actions)` - Một message `instantActions`, nở theo bảng compound
|
||||
|
||||
> **2026-08-10:** `dockTo` ×2, `rotateTo`, `moveStraightTo` đã bị **gỡ khỏi interface**. Chúng đẩy
|
||||
> goal thẳng vào lõi, bỏ qua mission layer, nên một goal đến giữa chừng thay thế chặng mà hàng đợi
|
||||
> đang chạy. Docking / xoay tại chỗ / đi thẳng giờ là khoá `profile:` của từng chặng trong order
|
||||
> (`compound_actions_params.yaml`), nên vẫn dùng được nguyên vẹn qua hai entry point còn lại.
|
||||
- `pause()`, `resume()`, `cancel()` - Điều khiển trạng thái
|
||||
- `getRobotPose(...)` - Lấy vị trí robot
|
||||
|
||||
- `robot_nav_core::BaseGlobalPlanner` ✅
|
||||
- `makePlan(start, goal, plan)` - Tạo global path
|
||||
- `initialize(name, costmap_robot)` - Khởi tạo với costmap
|
||||
- **Implementations**: `custom_planner`, `dock_planner`, `two_points_planner`
|
||||
|
||||
- `robot_nav_core::BaseLocalPlanner` ✅
|
||||
- `computeVelocityCommands(odom, cmd_vel)` - Tính toán velocity command
|
||||
- `setPlan(plan)` - Set global path để follow
|
||||
- `isGoalReached()` - Kiểm tra đã đến goal chưa
|
||||
- `swapPlanner(name)` - Thay đổi planner động (position, docking, go_straight, rotate)
|
||||
- `setTwistLinear/Angular(...)` - Set velocity limits
|
||||
- `getTwistLinear/Angular(...)` - Get velocity limits
|
||||
- **Implementation**: `pnkx_local_planner` với multiple behaviors
|
||||
|
||||
- `robot_nav_core::RecoveryBehavior` ✅
|
||||
- `runBehavior()` - Thực thi recovery behavior
|
||||
- `initialize(name, tf, global_costmap, local_costmap)` - Khởi tạo
|
||||
|
||||
- `robot_costmap_2d::Costmap2DROBOT` ✅
|
||||
- Wrapper cho costmap với robot footprint
|
||||
- Thread-safe access với mutex
|
||||
|
||||
**Các interface cần bổ sung:** ⚠️
|
||||
|
||||
- `ILocalizationSource` ⚠️
|
||||
- `getCurrentPose()` - Lấy vị trí hiện tại từ localization
|
||||
- `isAvailable()` - Kiểm tra localization có sẵn không
|
||||
|
||||
- `IOdometrySource` ⚠️
|
||||
- `getCurrentPose()` - Lấy vị trí từ odometry
|
||||
- `getCurrentVelocity()` - Lấy vận tốc hiện tại
|
||||
- `isAvailable()` - Kiểm tra odometry có sẵn không
|
||||
|
||||
- `IBaseController` ⚠️
|
||||
- `executeVelocity(cmd_vel)` - Thực thi velocity command
|
||||
- `stop()` - Dừng robot ngay lập tức
|
||||
- `getCurrentVelocity()` - Lấy vận tốc thực tế
|
||||
|
||||
- `IMapProvider` ⚠️
|
||||
- `getMap()` - Lấy static map
|
||||
- `isMapAvailable()` - Kiểm tra map có sẵn không
|
||||
|
||||
**Plugin mechanism:** ✅
|
||||
- Sử dụng `boost::dll` để dynamic loading plugins
|
||||
- Factory pattern với `boost::function` và `boost::dll::import_alias`
|
||||
- `robot::PluginLoaderHelper` để tìm library path từ plugin name
|
||||
- Config file YAML để specify plugin names
|
||||
- Plugin interfaces:
|
||||
- `robot_nav_core::BaseGlobalPlanner` - Global planners
|
||||
- `robot_nav_core::BaseLocalPlanner` - Local planners
|
||||
- `robot_nav_core::RecoveryBehavior` - Recovery behaviors
|
||||
- `robot_costmap_2d::Layer` - Costmap layers
|
||||
- Plugin registration với `BOOST_DLL_ALIAS` macro
|
||||
|
||||
### 4. Cơ chế giao tiếp & đồng bộ
|
||||
|
||||
**Lựa chọn transport:**
|
||||
- Shared memory + mutex (cho real-time nhẹ)
|
||||
- Message queue (ZeroMQ, nanomsg)
|
||||
- Event loop với callback thread-safe
|
||||
|
||||
**Time synchronization:**
|
||||
- Sử dụng `std::chrono` cho timestamp
|
||||
- Buffer dữ liệu để xử lý dữ liệu không đồng bộ
|
||||
|
||||
**Threading strategy:**
|
||||
- Mỗi module một thread riêng, hoặc
|
||||
- Scheduler chung quản lý tất cả
|
||||
|
||||
### 5. Chiến lược an toàn & recovery
|
||||
|
||||
**Monitoring:**
|
||||
- Heartbeat mechanism
|
||||
- Watchdog timer
|
||||
|
||||
**Recovery behaviors:**
|
||||
- Không tìm được đường đi
|
||||
- Mất localization
|
||||
- Obstacle chặn đường
|
||||
- Emergency stop mechanism
|
||||
- Giới hạn vận tốc theo trạng thái
|
||||
|
||||
### 6. Config & Logging/Diagnostics
|
||||
|
||||
**Configuration:**
|
||||
- File YAML/JSON cho:
|
||||
- Kinematics parameters
|
||||
- Velocity limits
|
||||
- Planner parameters
|
||||
- Sensor configurations
|
||||
|
||||
**Logging & Debugging:**
|
||||
- Logging framework (spdlog?)
|
||||
- Telemetry interface
|
||||
- Visualizer tool (SDL/ImGui) để debug map/path
|
||||
|
||||
### 7. Trạng thái triển khai & lộ trình
|
||||
|
||||
**Đã hoàn thành:** ✅
|
||||
|
||||
1. ✅ **Interface Layer**:
|
||||
- `move_base_core::BaseNavigation` - Abstract interface hoàn chỉnh
|
||||
- `move_base_core::common.h` - Common types và utilities
|
||||
|
||||
2. ✅ **Implementation Layer**:
|
||||
- `move_base::MoveBase` - Core implementation với state machine
|
||||
- `executeCycle()` - Control loop implementation
|
||||
- State management (PLANNING, CONTROLLING, CLEARING, PAUSED)
|
||||
- Threading với planner thread và control loop
|
||||
|
||||
3. ✅ **Planning Layer - Plugin System**:
|
||||
- **Global Planners** (3 implementations):
|
||||
- `custom_planner` - Custom path planning với curve support
|
||||
- `dock_planner` - Docking-specific planner
|
||||
- `two_points_planner` - Simple two-point planner
|
||||
- **Local Planners** (1 implementation):
|
||||
- `pnkx_local_planner` - Main local planner với:
|
||||
- `pnkx_docking_local_planner` - Docking behavior
|
||||
- `pnkx_go_straight_local_planner` - Go straight behavior
|
||||
- `pnkx_rotate_local_planner` - Rotate behavior
|
||||
- **Recovery Behaviors**: Interface đã định nghĩa
|
||||
- Plugin loading với `boost::dll` và `robot::PluginLoaderHelper`
|
||||
|
||||
4. ✅ **Costmap Layer**:
|
||||
- `robot_costmap_2d::Costmap2DROBOT` - Global và local costmap
|
||||
- **Costmap Layers** (8 implementations):
|
||||
- `static_layer` - Static map layer
|
||||
- `obstacle_layer` - Dynamic obstacles
|
||||
- `inflation_layer` - Cost inflation
|
||||
- `voxel_layer` - 3D voxel grid
|
||||
- `critical_layer` - Critical zones
|
||||
- `directional_layer` - Directional costs
|
||||
- `preferred_layer` - Preferred paths
|
||||
- `unpreferred_layer` - Unpreferred zones
|
||||
- Layered costmap system với plugin support
|
||||
|
||||
5. ✅ **Algorithms Layer**:
|
||||
- **MKT Algorithm**:
|
||||
- Differential drive kinematics (go_straight, rotate, predictive)
|
||||
- Bicycle model kinematics (go_straight, rotate, pure pursuit)
|
||||
- **MKT Plugins**:
|
||||
- `goal_checker` - Goal checking algorithms
|
||||
- `standard_traj_generator` - Standard trajectory generation
|
||||
- `kinematic_parameters` - Kinematics parameter management
|
||||
- `xy_theta_iterator` - Trajectory iteration
|
||||
- `limited_accel_generator` - Acceleration-limited trajectories
|
||||
- **Score Algorithm**: Trajectory scoring và goal checking
|
||||
- **Kalman Filter**: State estimation và filtering
|
||||
|
||||
6. ✅ **API Layer**:
|
||||
- `nav_c_api` - C API wrapper cho .NET/C# P/Invoke
|
||||
- Wrapper functions cho BaseNavigation methods
|
||||
|
||||
7. ✅ **Supporting Libraries**:
|
||||
- `tf3` - Transform system (buffer_core, transforms)
|
||||
- `robot_time` - Time management (Time, Duration, Timer, Rate)
|
||||
- `robot_cpp` - Core utilities:
|
||||
- `robot::init()` - Initialization
|
||||
- `robot::NodeHandle` - YAML config loading
|
||||
- `robot::PluginLoaderHelper` - Plugin discovery
|
||||
- `robot_nav_2d_utils` - 2D navigation utilities (conversions, path_ops, polygons, bounds, tf_help)
|
||||
- `robot_nav_2d_msgs` - 2D navigation messages
|
||||
- `geometry_msgs` - Geometry message types (29 types)
|
||||
- `robot_nav_msgs` - Navigation messages (24 types)
|
||||
- `robot_sensor_msgs` - Sensor messages (30 types)
|
||||
- `laser_geometry` - Laser scan geometry utilities
|
||||
- `voxel_grid` - Voxel grid implementation
|
||||
- `data_convert` - Data conversion utilities
|
||||
- `nav_grid` - Navigation grid utilities
|
||||
|
||||
**Đang triển khai / Cần bổ sung:** ⚠️
|
||||
|
||||
1. ⚠️ **Data Sources Interfaces**:
|
||||
- `ILocalizationSource` interface - Cần định nghĩa
|
||||
- `IOdometrySource` interface - Cần định nghĩa
|
||||
- `IMapProvider` interface - Cần định nghĩa
|
||||
- Integration với Pnkx Loc, odometry sources - Hiện tại dùng trực tiếp qua MoveBase methods
|
||||
|
||||
2. ⚠️ **Base Controller**:
|
||||
- `IBaseController` interface - Cần định nghĩa
|
||||
- Diff drive controller implementation - Cần implement
|
||||
- Steer drive controller implementation - Cần implement
|
||||
- Velocity command execution - Hiện tại chỉ có `setTwistLinear/Angular` trong local planner
|
||||
|
||||
3. ⚠️ **User Controller Plugin System**:
|
||||
- Factory để load user controller plugins - Cần implement
|
||||
- Interface cho User Controller - Cần định nghĩa
|
||||
- Integration với BaseNavigation - Cần implement
|
||||
|
||||
4. ⚠️ **Testing & Documentation**:
|
||||
- Unit tests cho các modules - Một số đã có (costmap, bounds, etc.)
|
||||
- Integration tests - Cần bổ sung
|
||||
- Simulation environment - TODO
|
||||
|
||||
**Lộ trình tiếp theo:**
|
||||
|
||||
**Phase 1: Data Sources & Base Controller** (Ưu tiên cao)
|
||||
- Định nghĩa interfaces cho data sources
|
||||
- Implement Base Controller interface và diff drive controller
|
||||
- Integration với MoveBase
|
||||
|
||||
**Phase 2: Control Loop & State Management** (Ưu tiên cao)
|
||||
- Hoàn thiện executeCycle trong MoveBase
|
||||
- State machine management
|
||||
- Threading strategy
|
||||
|
||||
**Phase 3: User Controller Plugin System** (Ưu tiên trung bình)
|
||||
- Factory pattern cho user controllers
|
||||
- Plugin loading mechanism
|
||||
- Integration testing
|
||||
|
||||
**Phase 4: Testing & Optimization** (Ưu tiên trung bình)
|
||||
- Unit tests cho các module
|
||||
- Integration tests
|
||||
- Performance optimization
|
||||
|
||||
**Testing strategy:**
|
||||
- Unit tests cho các module độc lập (gtest?)
|
||||
- Integration tests cho full navigation stack
|
||||
- Simulation environment (2D simulator) - TODO
|
||||
- Hardware-in-the-loop testing - TODO
|
||||
|
||||
## Cấu trúc thư mục
|
||||
|
||||
```
|
||||
pnkx_nav_core/
|
||||
├── src/
|
||||
│ ├── Navigations/
|
||||
│ │ ├── Cores/
|
||||
│ │ │ ├── move_base_core/ # BaseNavigation interface ✅
|
||||
│ │ │ │ ├── include/move_base_core/
|
||||
│ │ │ │ │ ├── navigation.h # BaseNavigation abstract class
|
||||
│ │ │ │ │ └── common.h # Common types (TFListenerPtr, etc.)
|
||||
│ │ │ ├── robot_nav_core/ # Planner interfaces ✅
|
||||
│ │ │ │ ├── include/robot_nav_core/
|
||||
│ │ │ │ │ ├── base_global_planner.h
|
||||
│ │ │ │ │ ├── base_local_planner.h
|
||||
│ │ │ │ │ └── recovery_behavior.h
|
||||
│ │ │ ├── robot_nav_core_adapter/ # Adapter utilities ✅
|
||||
│ │ │ │ ├── include/robot_nav_core_adapter/
|
||||
│ │ │ │ │ ├── global_planner_adapter.h
|
||||
│ │ │ │ │ ├── local_planner_adapter.h
|
||||
│ │ │ │ │ └── costmap_adapter.h
|
||||
│ │ │ └── robot_nav_core2/ # Additional nav utilities ✅
|
||||
│ │ │ ├── include/robot_nav_core2/
|
||||
│ │ │ │ ├── global_planner.h
|
||||
│ │ │ │ ├── local_planner.h
|
||||
│ │ │ │ └── costmap.h
|
||||
│ │ ├── Libraries/
|
||||
│ │ │ ├── nav_grid/ # Navigation grid utilities ✅
|
||||
│ │ │ └── (costmap, tf3, robot_time ở Libraries/)
|
||||
│ │ └── Packages/
|
||||
│ │ └── move_base/ # MoveBase implementation ✅
|
||||
│ │ ├── include/move_base/
|
||||
│ │ │ └── move_base.h
|
||||
│ │ └── src/
|
||||
│ │ ├── move_base.cpp
|
||||
│ │ └── move_base_main.cpp
|
||||
│ │
|
||||
│ ├── Algorithms/
|
||||
│ │ ├── Cores/
|
||||
│ │ │ └── score_algorithm/ # Trajectory scoring ✅
|
||||
│ │ │ ├── include/score_algorithm/
|
||||
│ │ │ │ ├── score_algorithm.h
|
||||
│ │ │ │ ├── goal_checker.h
|
||||
│ │ │ │ └── trajectory_generator.h
|
||||
│ │ ├── Libraries/
|
||||
│ │ │ ├── mkt_algorithm/ # MKT kinematics algorithms ✅
|
||||
│ │ │ │ ├── include/mkt_algorithm/
|
||||
│ │ │ │ │ ├── diff/ # Differential drive
|
||||
│ │ │ │ │ │ ├── diff_go_straight.h
|
||||
│ │ │ │ │ │ ├── diff_predictive_trajectory.h
|
||||
│ │ │ │ │ │ └── diff_rotate_to_goal.h
|
||||
│ │ │ │ │ └── bicycle/ # Bicycle model
|
||||
│ │ │ │ │ ├── bicycle.h
|
||||
│ │ │ │ │ ├── go_straight.h
|
||||
│ │ │ │ │ └── rotate_to_goal.h
|
||||
│ │ │ ├── mkt_plugins/ # MKT plugin components ✅
|
||||
│ │ │ │ ├── include/mkt_plugins/
|
||||
│ │ │ │ │ ├── goal_checker.h
|
||||
│ │ │ │ │ ├── standard_traj_generator.h
|
||||
│ │ │ │ │ ├── kinematic_parameters.h
|
||||
│ │ │ │ │ └── xy_theta_iterator.h
|
||||
│ │ │ ├── mkt_msgs/ # MKT message types ✅
|
||||
│ │ │ ├── kalman/ # Kalman filtering ✅
|
||||
│ │ │ └── angles/ # Angle utilities ✅
|
||||
│ │ └── Packages/
|
||||
│ │ ├── global_planners/
|
||||
│ │ │ ├── custom_planner/ # Custom global planner ✅
|
||||
│ │ │ ├── dock_planner/ # Docking planner ✅
|
||||
│ │ │ └── two_points_planner/ # Two points planner ✅
|
||||
│ │ └── local_planners/
|
||||
│ │ └── pnkx_local_planner/ # PNKX local planner ✅
|
||||
│ │ ├── include/pnkx_local_planner/
|
||||
│ │ │ ├── pnkx_local_planner.h
|
||||
│ │ │ ├── pnkx_docking_local_planner.h
|
||||
│ │ │ ├── pnkx_go_straight_local_planner.h
|
||||
│ │ │ └── pnkx_rotate_local_planner.h
|
||||
│ │
|
||||
│ ├── Libraries/
|
||||
│ │ ├── costmap_2d/ # Costmap system ✅
|
||||
│ │ │ ├── include/robot_costmap_2d/
|
||||
│ │ │ │ ├── costmap_2d_robot.h
|
||||
│ │ │ │ ├── layered_costmap.h
|
||||
│ │ │ │ └── layer.h
|
||||
│ │ │ ├── plugins/ # Costmap layers ✅
|
||||
│ │ │ │ ├── static_layer.cpp
|
||||
│ │ │ │ ├── obstacle_layer.cpp
|
||||
│ │ │ │ ├── inflation_layer.cpp
|
||||
│ │ │ │ ├── voxel_layer.cpp
|
||||
│ │ │ │ ├── critical_layer.cpp
|
||||
│ │ │ │ ├── directional_layer.cpp
|
||||
│ │ │ │ ├── preferred_layer.cpp
|
||||
│ │ │ │ └── unpreferred_layer.cpp
|
||||
│ │ │ └── config/ # Costmap configs
|
||||
│ │ ├── tf3/ # Transform system ✅
|
||||
│ │ ├── robot_time/ # Time management ✅
|
||||
│ │ ├── robot_cpp/ # Core utilities ✅
|
||||
│ │ │ ├── include/robot/
|
||||
│ │ │ │ ├── init.h # Initialization
|
||||
│ │ │ │ ├── node_handle.h # NodeHandle (YAML config)
|
||||
│ │ │ │ └── plugin_loader_helper.h # Plugin loader
|
||||
│ │ ├── robot_nav_2d_utils/ # 2D nav utilities ✅
|
||||
│ │ ├── robot_nav_2d_msgs/ # 2D nav messages ✅
|
||||
│ │ ├── geometry2/ # Geometry utilities ✅
|
||||
│ │ │ ├── robot_tf3_geometry_msgs/
|
||||
│ │ │ └── robot_tf3_sensor_msgs/
|
||||
│ │ ├── common_msgs/ # Message types ✅
|
||||
│ │ │ ├── robot_geometry_msgs/
|
||||
│ │ │ ├── robot_nav_msgs/
|
||||
│ │ │ ├── robot_sensor_msgs/
|
||||
│ │ │ ├── robot_std_msgs/
|
||||
│ │ │ ├── robot_protocol_msgs/
|
||||
│ │ │ └── robot_visualization_msgs/
|
||||
│ │ ├── laser_geometry/ # Laser geometry ✅
|
||||
│ │ ├── voxel_grid/ # Voxel grid ✅
|
||||
│ │ ├── data_convert/ # Data conversion ✅
|
||||
│ │ └── xmlrpcpp/ # XML-RPC utilities ✅
|
||||
│ │
|
||||
│ └── APIs/
|
||||
│ └── c_api/ # C API wrapper ✅
|
||||
│ ├── include/nav_c_api.h
|
||||
│ └── src/nav_c_api.cpp
|
||||
│
|
||||
├── build/ # Build artifacts
|
||||
├── config/ # Configuration files
|
||||
├── examples/ # Example code
|
||||
└── doc/ # Documentation
|
||||
├── architecture_discussion.md
|
||||
├── implementation_plan.md
|
||||
└── folders.md
|
||||
```
|
||||
|
||||
## Ghi chú
|
||||
|
||||
- ✅ Kiến trúc cốt lõi đã được triển khai với plugin system linh hoạt
|
||||
- ✅ **3 Global Planners** đã triển khai: custom_planner, dock_planner, two_points_planner
|
||||
- ✅ **1 Local Planner** đã triển khai: pnkx_local_planner với 4 behaviors (position, docking, go_straight, rotate)
|
||||
- ✅ **8 Costmap Layers** đã triển khai: static, obstacle, inflation, voxel, critical, directional, preferred, unpreferred
|
||||
- ✅ **MKT Algorithms** hỗ trợ cả differential drive và bicycle model
|
||||
- ✅ **Plugin System** hoàn chỉnh với `boost::dll` và `robot::PluginLoaderHelper`
|
||||
- ⚠️ Cần bổ sung data sources interfaces và base controller
|
||||
- 🔄 Kiến trúc được thiết kế để dễ dàng thay đổi thuật toán và mô hình kinematics thông qua plugin system
|
||||
- 📦 Tất cả components được build bằng CMake, hỗ trợ cả Catkin và Standalone CMake
|
||||
- 🔌 Plugin system sử dụng `boost::dll` cho dynamic loading
|
||||
- 🎯 MoveBase đã có control loop (`executeCycle`) và state machine hoàn chỉnh
|
||||
- 📚 Có đầy đủ message types: geometry_msgs (29), nav_msgs (24), sensor_msgs (30), std_msgs (32)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
1282
doc/diff_drive_c.drawio
Executable file
1282
doc/diff_drive_c.drawio
Executable file
File diff suppressed because one or more lines are too long
99
doc/folders.md
Normal file
99
doc/folders.md
Normal file
@@ -0,0 +1,99 @@
|
||||
# Cấu trúc thư mục pnkx_nav_core
|
||||
|
||||
Mô tả cấu trúc thư mục thực tế của dự án:
|
||||
|
||||
```
|
||||
pnkx_nav_core/
|
||||
├── src/
|
||||
│ ├── Navigations/
|
||||
│ │ ├── Cores/
|
||||
│ │ │ ├── move_base_core/ # BaseNavigation interface
|
||||
│ │ │ ├── robot_nav_core/ # Planner interfaces (BaseGlobalPlanner, BaseLocalPlanner, RecoveryBehavior)
|
||||
│ │ │ ├── robot_nav_core_adapter/ # Adapter utilities (global_planner_adapter, local_planner_adapter, costmap_adapter)
|
||||
│ │ │ └── robot_nav_core2/ # Additional nav utilities (global_planner, local_planner, costmap)
|
||||
│ │ ├── Libraries/
|
||||
│ │ │ └── nav_grid/ # Navigation grid utilities
|
||||
│ │ └── Packages/
|
||||
│ │ └── move_base/ # MoveBase implementation
|
||||
│ │
|
||||
│ ├── Algorithms/
|
||||
│ │ ├── Cores/
|
||||
│ │ │ └── score_algorithm/ # Trajectory scoring và goal checking
|
||||
│ │ ├── Libraries/
|
||||
│ │ │ ├── mkt_algorithm/ # MKT kinematics (diff drive & bicycle)
|
||||
│ │ │ ├── mkt_plugins/ # MKT plugin components
|
||||
│ │ │ ├── mkt_msgs/ # MKT message types
|
||||
│ │ │ ├── kalman/ # Kalman filtering
|
||||
│ │ │ └── angles/ # Angle utilities
|
||||
│ │ └── Packages/
|
||||
│ │ ├── global_planners/
|
||||
│ │ │ ├── custom_planner/ # Custom global planner
|
||||
│ │ │ ├── dock_planner/ # Docking planner
|
||||
│ │ │ └── two_points_planner/ # Two points planner
|
||||
│ │ └── local_planners/
|
||||
│ │ └── pnkx_local_planner/ # PNKX local planner
|
||||
│ │
|
||||
│ ├── Libraries/
|
||||
│ │ ├── costmap_2d/ # Costmap system với 8 layers
|
||||
│ │ ├── tf3/ # Transform system
|
||||
│ │ ├── robot_time/ # Time management
|
||||
│ │ ├── robot_cpp/ # Core utilities (init, NodeHandle, PluginLoaderHelper)
|
||||
│ │ ├── robot_nav_2d_utils/ # 2D navigation utilities
|
||||
│ │ ├── robot_nav_2d_msgs/ # 2D navigation messages
|
||||
│ │ ├── geometry2/ # Geometry utilities (tf3_geometry_msgs, tf3_sensor_msgs)
|
||||
│ │ ├── common_msgs/ # Message types
|
||||
│ │ │ ├── robot_geometry_msgs/ # Geometry messages (29 types)
|
||||
│ │ │ ├── robot_nav_msgs/ # Navigation messages (24 types)
|
||||
│ │ │ ├── robot_sensor_msgs/ # Sensor messages (30 types)
|
||||
│ │ │ ├── robot_std_msgs/ # Standard messages (32 types)
|
||||
│ │ │ ├── robot_protocol_msgs/ # Protocol messages
|
||||
│ │ │ ├── robot_visualization_msgs/ # Visualization messages
|
||||
│ │ │ └── utils/ # Message utilities
|
||||
│ │ ├── laser_geometry/ # Laser geometry utilities
|
||||
│ │ ├── voxel_grid/ # Voxel grid
|
||||
│ │ ├── data_convert/ # Data conversion
|
||||
│ │ └── xmlrpcpp/ # XML-RPC utilities
|
||||
│ │
|
||||
│ └── APIs/
|
||||
│ └── c_api/ # C API wrapper cho .NET/C#
|
||||
│
|
||||
├── build/ # Build artifacts
|
||||
├── config/ # Configuration files
|
||||
├── examples/ # Example code
|
||||
└── doc/ # Documentation
|
||||
├── architecture_discussion.md
|
||||
├── implementation_plan.md
|
||||
├── folders.md
|
||||
└── readme.md
|
||||
```
|
||||
|
||||
## Chi tiết các thư mục chính
|
||||
|
||||
### Navigations/
|
||||
- **Cores/**: Interfaces và core utilities
|
||||
- `move_base_core`: BaseNavigation interface
|
||||
- `robot_nav_core`: Planner interfaces
|
||||
- `robot_nav_core_adapter`: Adapter layer
|
||||
- `robot_nav_core2`: Additional utilities
|
||||
- **Libraries/**: Navigation libraries
|
||||
- `nav_grid`: Grid utilities
|
||||
- **Packages/**: Implementations
|
||||
- `move_base`: MoveBase implementation
|
||||
|
||||
### Algorithms/
|
||||
- **Cores/**: Core algorithms
|
||||
- `score_algorithm`: Trajectory scoring
|
||||
- **Libraries/**: Algorithm libraries
|
||||
- `mkt_algorithm`: Kinematics algorithms
|
||||
- `mkt_plugins`: Plugin components
|
||||
- `kalman`: Filtering
|
||||
- **Packages/**: Algorithm implementations
|
||||
- `global_planners/`: 3 planners
|
||||
- `local_planners/`: 1 planner với multiple behaviors
|
||||
|
||||
### Libraries/
|
||||
- **costmap_2d/**: Costmap system với 8 layers
|
||||
- **tf3/**: Transform system
|
||||
- **robot_cpp/**: Core utilities (init, NodeHandle, PluginLoaderHelper)
|
||||
- **common_msgs/**: Message type definitions
|
||||
- Các utilities khác: time, geometry, sensors, etc.
|
||||
230
doc/implementation_plan.md
Normal file
230
doc/implementation_plan.md
Normal file
@@ -0,0 +1,230 @@
|
||||
# Kế hoạch Implementation Navigation System
|
||||
|
||||
## Phân tích Kiến trúc Hiện tại
|
||||
|
||||
### ✅ Đã có sẵn:
|
||||
|
||||
1. **Interface Layer:**
|
||||
- `move_base_core::BaseNavigation` - Interface chính
|
||||
- `move_base::MoveBase` - Implementation
|
||||
|
||||
2. **Core Components:**
|
||||
- `nav_core::BaseGlobalPlanner` - Interface cho global planner
|
||||
- `nav_core::BaseLocalPlanner` - Interface cho local planner
|
||||
- `nav_core::RecoveryBehavior` - Interface cho recovery behaviors
|
||||
- Plugin system với `boost::dll` để load dynamic plugins
|
||||
|
||||
3. **Costmap System:**
|
||||
- `robot_costmap_2d::Costmap2DROBOT` - Global và local costmap
|
||||
- Costmap layers (static, obstacle, inflation, etc.)
|
||||
|
||||
4. **Supporting Libraries:**
|
||||
- `tf3` - Transform system
|
||||
- `robot_time` - Time management
|
||||
- `geometry_msgs` - Message types
|
||||
- `robot_nav_2d_msgs`, `robot_nav_2d_utils` - 2D navigation utilities
|
||||
|
||||
### ❌ Cần bổ sung/hoàn thiện:
|
||||
|
||||
1. **User Controller Plugin System:**
|
||||
- Factory để tạo User Controller từ plugin
|
||||
- Interface cho User Controller
|
||||
- Integration với BaseNavigation
|
||||
|
||||
2. **Data Sources Integration:**
|
||||
- Pnkx Loc interface
|
||||
- Odometry Source interface
|
||||
- Sensor Transform management
|
||||
- Map Server interface
|
||||
- Laser Sensor Sources interface
|
||||
|
||||
3. **Base Controller:**
|
||||
- Diff drive controller
|
||||
- Steer drive controller
|
||||
- Velocity command execution
|
||||
|
||||
4. **Hoàn thiện MoveBase:**
|
||||
- Control loop implementation
|
||||
- State machine management
|
||||
- Recovery behavior execution
|
||||
|
||||
## Kế hoạch Implementation
|
||||
|
||||
### Phase 1: Data Sources & Interfaces (Ưu tiên cao)
|
||||
|
||||
#### 1.1 Odometry Source Interface
|
||||
**File:** `src/Navigations/Cores/move_base_core/include/move_base_core/odometry_source.h`
|
||||
```cpp
|
||||
class IOdometrySource {
|
||||
virtual robot_geometry_msgs::PoseStamped getCurrentPose() = 0;
|
||||
virtual robot_geometry_msgs::Twist getCurrentVelocity() = 0;
|
||||
virtual bool isAvailable() = 0;
|
||||
};
|
||||
```
|
||||
|
||||
#### 1.2 Localization Source Interface (Pnkx Loc)
|
||||
**File:** `src/Navigations/Cores/move_base_core/include/move_base_core/localization_source.h`
|
||||
```cpp
|
||||
class ILocalizationSource {
|
||||
virtual robot_geometry_msgs::PoseStamped getRobotPose() = 0;
|
||||
virtual std::string getGlobalFrame() = 0;
|
||||
virtual bool isLocalized() = 0;
|
||||
};
|
||||
```
|
||||
|
||||
#### 1.3 Map Provider Interface
|
||||
**File:** `src/Navigations/Cores/move_base_core/include/move_base_core/map_provider.h`
|
||||
```cpp
|
||||
class IMapProvider {
|
||||
virtual robot_nav_msgs::OccupancyGrid getMap() = 0;
|
||||
virtual bool isMapAvailable() = 0;
|
||||
};
|
||||
```
|
||||
|
||||
#### 1.4 Sensor Data Interface
|
||||
**File:** `src/Navigations/Cores/move_base_core/include/move_base_core/sensor_source.h`
|
||||
```cpp
|
||||
class ISensorSource {
|
||||
virtual robot_sensor_msgs::LaserScan getLatestScan() = 0;
|
||||
virtual bool hasNewData() = 0;
|
||||
};
|
||||
```
|
||||
|
||||
### Phase 2: Base Controller (Ưu tiên cao)
|
||||
|
||||
#### 2.1 Base Controller Interface
|
||||
**File:** `src/Navigations/Cores/move_base_core/include/move_base_core/base_controller.h`
|
||||
```cpp
|
||||
class IBaseController {
|
||||
virtual bool setVelocity(const robot_geometry_msgs::Twist& cmd_vel) = 0;
|
||||
virtual bool stop() = 0;
|
||||
virtual robot_geometry_msgs::Twist getCurrentVelocity() = 0;
|
||||
};
|
||||
```
|
||||
|
||||
#### 2.2 Diff Drive Controller
|
||||
**File:** `src/Navigations/Packages/base_controllers/include/base_controllers/diff_drive_controller.h`
|
||||
- Implement IBaseController
|
||||
- Convert Twist to wheel velocities
|
||||
- Handle kinematics cho differential drive
|
||||
|
||||
#### 2.3 Steer Drive Controller
|
||||
**File:** `src/Navigations/Packages/base_controllers/include/base_controllers/steer_drive_controller.h`
|
||||
- Implement IBaseController
|
||||
- Convert Twist to steering angles và wheel velocities
|
||||
- Handle kinematics cho bicycle/steering model
|
||||
|
||||
### Phase 3: User Controller Plugin System (Ưu tiên trung bình)
|
||||
|
||||
#### 3.1 User Controller Interface
|
||||
**File:** `src/Navigations/Cores/move_base_core/include/move_base_core/user_controller.h`
|
||||
```cpp
|
||||
class IUserController {
|
||||
virtual void onGoalReceived(const robot_geometry_msgs::PoseStamped& goal) = 0;
|
||||
virtual void onNavigationStateChanged(move_base_core::State state) = 0;
|
||||
virtual void onFeedback(const NavFeedback& feedback) = 0;
|
||||
};
|
||||
```
|
||||
|
||||
#### 3.2 User Controller Factory
|
||||
**File:** `src/Navigations/Cores/move_base_core/src/user_controller_factory.cpp`
|
||||
- Load plugin từ config
|
||||
- Create instance với boost::dll
|
||||
- Manage lifecycle
|
||||
|
||||
### Phase 4: Control Loop & State Machine (Ưu tiên cao)
|
||||
|
||||
#### 4.1 Control Loop Implementation
|
||||
**File:** `src/Navigations/Packages/move_base/src/move_base_control_loop.cpp`
|
||||
- Main control loop thread
|
||||
- Planner thread management
|
||||
- Controller execution
|
||||
- Frequency control
|
||||
|
||||
#### 4.2 State Machine
|
||||
**File:** `src/Navigations/Packages/move_base/src/move_base_state_machine.cpp`
|
||||
- State transitions
|
||||
- Recovery behavior triggers
|
||||
- Goal management
|
||||
|
||||
### Phase 5: Integration & Testing (Ưu tiên trung bình)
|
||||
|
||||
#### 5.1 Integration Layer
|
||||
- Connect tất cả components
|
||||
- Data flow management
|
||||
- Error handling
|
||||
|
||||
#### 5.2 Testing
|
||||
- Unit tests
|
||||
- Integration tests
|
||||
- Simulation tests
|
||||
|
||||
## Cấu trúc Thư mục Đề xuất
|
||||
|
||||
```
|
||||
src/Navigations/
|
||||
├── Cores/
|
||||
│ ├── move_base_core/ ✅ Đã có
|
||||
│ │ ├── interfaces/
|
||||
│ │ │ ├── odometry_source.h ⚠️ Cần tạo
|
||||
│ │ │ ├── localization_source.h ⚠️ Cần tạo
|
||||
│ │ │ ├── map_provider.h ⚠️ Cần tạo
|
||||
│ │ │ ├── sensor_source.h ⚠️ Cần tạo
|
||||
│ │ │ ├── base_controller.h ⚠️ Cần tạo
|
||||
│ │ │ └── user_controller.h ⚠️ Cần tạo
|
||||
│ │ └── src/
|
||||
│ │ └── user_controller_factory.cpp ⚠️ Cần tạo
|
||||
│ ├── nav_core/ ✅ Đã có
|
||||
│ └── nav_core2/ ✅ Đã có
|
||||
│
|
||||
├── Packages/
|
||||
│ ├── move_base/ ✅ Đã có (cần hoàn thiện)
|
||||
│ │ └── src/
|
||||
│ │ ├── move_base_control_loop.cpp ⚠️ Cần tạo
|
||||
│ │ └── move_base_state_machine.cpp ⚠️ Cần tạo
|
||||
│ │
|
||||
│ └── base_controllers/ ⚠️ Cần tạo
|
||||
│ ├── include/
|
||||
│ │ └── base_controllers/
|
||||
│ │ ├── diff_drive_controller.h
|
||||
│ │ └── steer_drive_controller.h
|
||||
│ └── src/
|
||||
│ ├── diff_drive_controller.cpp
|
||||
│ └── steer_drive_controller.cpp
|
||||
│
|
||||
└── Libraries/
|
||||
└── (các libraries hiện có) ✅
|
||||
```
|
||||
|
||||
## Thứ tự Implementation
|
||||
|
||||
### Sprint 1: Foundation (1-2 tuần)
|
||||
1. ✅ Tạo interfaces cho data sources
|
||||
2. ✅ Tạo base controller interface
|
||||
3. ✅ Implement diff drive controller cơ bản
|
||||
|
||||
### Sprint 2: Integration (1-2 tuần)
|
||||
1. ✅ Integrate data sources vào MoveBase
|
||||
2. ✅ Implement control loop
|
||||
3. ✅ Connect base controller
|
||||
|
||||
### Sprint 3: Plugin System (1 tuần)
|
||||
1. ✅ User controller plugin system
|
||||
2. ✅ Factory pattern implementation
|
||||
|
||||
### Sprint 4: State Machine & Recovery (1 tuần)
|
||||
1. ✅ State machine implementation
|
||||
2. ✅ Recovery behavior integration
|
||||
|
||||
### Sprint 5: Testing & Polish (1 tuần)
|
||||
1. ✅ Unit tests
|
||||
2. ✅ Integration tests
|
||||
3. ✅ Documentation
|
||||
|
||||
## Notes
|
||||
|
||||
- Tất cả interfaces nên follow pattern của `BaseNavigation`
|
||||
- Sử dụng `boost::dll` cho plugin system (đã có sẵn)
|
||||
- Thread safety: sử dụng `boost::mutex` và `boost::recursive_mutex`
|
||||
- Error handling: throw exceptions, return bool cho simple operations
|
||||
|
||||
15
doc/readme.md
Normal file
15
doc/readme.md
Normal file
@@ -0,0 +1,15 @@
|
||||
Mô tả dựng án :
|
||||
Tôi đang nghiên cứu viết chương di chuyển bám quỹ đạo (navigation) cho robot amr dạng hai bánh vi sai. Tôi muốn bỏ ROS chuyển sang viết
|
||||
thuần trên Cmake.
|
||||
|
||||
Các chức năng cần có:
|
||||
- Có khả năng thay đổi mô hình kinematics như dạng hai bánh vi sai, dạng steering bicycle, ...
|
||||
- Có chức năng di chuyển từ điểủ khởi đầu đến điểm đích
|
||||
- Có chức năng xoay tròn
|
||||
- Có chức năng đi thẳng
|
||||
- Có chức năng thay đổi vận tốc
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
287
examples/NavigationExample/NavigationAPI.cs
Normal file
287
examples/NavigationExample/NavigationAPI.cs
Normal file
@@ -0,0 +1,287 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using NavigationExample;
|
||||
|
||||
namespace NavigationExample
|
||||
{
|
||||
/// <summary>
|
||||
/// C# P/Invoke wrapper for Navigation C API
|
||||
/// </summary>
|
||||
public class NavigationAPI
|
||||
{
|
||||
private const string DllName = "/usr/local/lib/libnav_c_api.so"; // Linux
|
||||
// For Windows: "nav_c_api.dll"
|
||||
// For macOS: "libnav_c_api.dylib"
|
||||
|
||||
// ============================================================================
|
||||
// Enums
|
||||
// ============================================================================
|
||||
public enum NavigationState
|
||||
{
|
||||
Pending = 0,
|
||||
Active = 1,
|
||||
Preempted = 2,
|
||||
Succeeded = 3,
|
||||
Aborted = 4,
|
||||
Rejected = 5,
|
||||
Preempting = 6,
|
||||
Recalling = 7,
|
||||
Recalled = 8,
|
||||
Lost = 9,
|
||||
Planning = 10,
|
||||
Controlling = 11,
|
||||
Clearing = 12,
|
||||
Paused = 13
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct NavFeedback
|
||||
{
|
||||
public NavigationState navigation_state;
|
||||
public IntPtr feed_back_str; // char*; free with nav_c_api_free_string
|
||||
public Pose2D current_pose;
|
||||
[MarshalAs(UnmanagedType.I1)]
|
||||
public bool goal_checked;
|
||||
[MarshalAs(UnmanagedType.I1)]
|
||||
public bool is_ready;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>Planner data output (plan, costmap, footprint).</summary>
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct PlannerDataOutput
|
||||
{
|
||||
public Path2D plan;
|
||||
public OccupancyGrid costmap;
|
||||
public OccupancyGridUpdate costmap_update;
|
||||
[MarshalAs(UnmanagedType.I1)]
|
||||
public bool is_costmap_updated;
|
||||
public PolygonStamped footprint;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct NavigationHandle
|
||||
{
|
||||
public IntPtr ptr;
|
||||
}
|
||||
|
||||
[DllImport(DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
||||
public static extern Header header_create(string frame_id);
|
||||
|
||||
[DllImport(DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
||||
public static extern Header header_set_data(
|
||||
uint seq,
|
||||
uint sec,
|
||||
uint nsec,
|
||||
string frame_id);
|
||||
|
||||
[DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern Time time_create();
|
||||
|
||||
/// <summary>Free a string allocated by the API (strdup).</summary>
|
||||
[DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void nav_c_api_free_string(IntPtr str);
|
||||
|
||||
/// <summary>Convert NavigationState to string; caller must free with nav_c_api_free_string.</summary>
|
||||
[DllImport(DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
||||
public static extern IntPtr navigation_state_to_string(NavigationState state);
|
||||
|
||||
[DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool navigation_get_feedback(NavigationHandle handle, ref NavFeedback out_feedback);
|
||||
|
||||
|
||||
/// <summary>Helper: copy unmanaged char* to managed string; does not free the pointer.</summary>
|
||||
public static string MarshalString(IntPtr p)
|
||||
{
|
||||
if (p == IntPtr.Zero) return string.Empty;
|
||||
return Marshal.PtrToStringAnsi(p) ?? string.Empty;
|
||||
}
|
||||
|
||||
/// <summary>Free strings inside NavFeedback (feed_back_str). Call after navigation_get_feedback when done.</summary>
|
||||
public static void navigation_free_feedback(ref NavFeedback feedback)
|
||||
{
|
||||
if (feedback.feed_back_str != IntPtr.Zero)
|
||||
{
|
||||
nav_c_api_free_string(feedback.feed_back_str);
|
||||
feedback.feed_back_str = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Navigation Handle Management
|
||||
// ============================================================================
|
||||
[DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern NavigationHandle navigation_create();
|
||||
|
||||
[DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void navigation_destroy(NavigationHandle handle);
|
||||
|
||||
/// <summary>Initialize navigation using an existing tf3 buffer (from libtf3). Caller owns the buffer and must call tf3_buffer_destroy after navigation_destroy.</summary>
|
||||
[DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool navigation_initialize(NavigationHandle handle, IntPtr tf3_buffer);
|
||||
|
||||
[DllImport(DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool navigation_set_robot_footprint(NavigationHandle handle, Point[] points, UIntPtr point_count);
|
||||
|
||||
[DllImport(DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool navigation_get_robot_footprint(NavigationHandle handle, ref Point[] out_points, ref UIntPtr out_count);
|
||||
|
||||
/// <summary>Send a goal for the robot to navigate to (global frame).</summary>
|
||||
[DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool navigation_move_to(NavigationHandle handle, PoseStamped goal);
|
||||
|
||||
/// <summary>Navigate using an Order message (graph nodes/edges). Order must be built or obtained from native side; call order_free when done if it was allocated by native.</summary>
|
||||
[DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool navigation_move_to_order(NavigationHandle handle, Order order, PoseStamped goal);
|
||||
|
||||
[DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool navigation_move_to_nodes_edges(NavigationHandle handle, IntPtr nodes, UIntPtr node_count, IntPtr edges, UIntPtr edge_count, PoseStamped goal);
|
||||
|
||||
// navigation_dock_to, navigation_dock_to_order, navigation_dock_to_nodes_edges,
|
||||
// navigation_move_straight_to and navigation_rotate_to no longer exist in the native
|
||||
// library. They pushed a goal past the mission layer, so one of them arriving mid-route
|
||||
// replaced the leg the mission queue was running without the queue noticing.
|
||||
//
|
||||
// Docking, go-straight and rotate are per-leg properties of an order now: set `profile:`
|
||||
// on the leg (`docking | go_straight | rotate`) plus `marker` for docking, then send it
|
||||
// through navigation_move_to_order or navigation_move_to_nodes_edges.
|
||||
|
||||
[DllImport(DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool navigation_pause(NavigationHandle handle);
|
||||
|
||||
[DllImport(DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool navigation_resume(NavigationHandle handle);
|
||||
|
||||
[DllImport(DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool navigation_cancel(NavigationHandle handle);
|
||||
|
||||
[DllImport(DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool navigation_set_twist_linear(NavigationHandle handle, double linear_x, double linear_y, double linear_z);
|
||||
|
||||
[DllImport(DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool navigation_set_twist_angular(NavigationHandle handle, double angular_x, double angular_y, double angular_z);
|
||||
|
||||
[DllImport(DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool navigation_get_robot_pose_stamped(NavigationHandle handle, ref PoseStamped out_pose);
|
||||
|
||||
[DllImport(DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool navigation_get_robot_pose_2d(NavigationHandle handle, ref Pose2D out_pose);
|
||||
|
||||
[DllImport(DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool navigation_get_twist(NavigationHandle handle, ref Twist2DStamped out_twist);
|
||||
|
||||
// ============================================================================
|
||||
// Navigation Data Management
|
||||
[DllImport(DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool navigation_add_laser_scan(NavigationHandle handle, string laser_scan_name, LaserScan laser_scan);
|
||||
|
||||
[DllImport(DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool navigation_add_odometry(NavigationHandle handle, string odometry_name, Odometry odometry);
|
||||
|
||||
[DllImport(DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool navigation_add_static_map(NavigationHandle handle, string map_name, OccupancyGrid occupancy_grid);
|
||||
|
||||
[DllImport(DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool navigation_get_static_map(NavigationHandle handle, string map_name, ref OccupancyGrid occupancy_grid);
|
||||
|
||||
[DllImport(DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool navigation_add_point_cloud(NavigationHandle handle, string point_cloud_name, PointCloud point_cloud);
|
||||
|
||||
[DllImport(DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool navigation_add_point_cloud2(NavigationHandle handle, string point_cloud2_name, PointCloud2 point_cloud2);
|
||||
|
||||
[DllImport(DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool navigation_get_laser_scan(NavigationHandle handle, string laser_scan_name, ref LaserScan out_scan);
|
||||
|
||||
[DllImport(DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool navigation_get_point_cloud(NavigationHandle handle, string point_cloud_name, ref PointCloud out_cloud);
|
||||
|
||||
[DllImport(DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool navigation_get_point_cloud2(NavigationHandle handle, string point_cloud2_name, ref PointCloud2 out_cloud);
|
||||
|
||||
[DllImport(DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool navigation_remove_static_map(NavigationHandle handle, string map_name);
|
||||
|
||||
[DllImport(DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool navigation_remove_laser_scan(NavigationHandle handle, string laser_scan_name);
|
||||
|
||||
[DllImport(DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool navigation_remove_point_cloud(NavigationHandle handle, string point_cloud_name);
|
||||
|
||||
[DllImport(DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool navigation_remove_point_cloud2(NavigationHandle handle, string point_cloud2_name);
|
||||
|
||||
[DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool navigation_remove_all_static_maps(NavigationHandle handle);
|
||||
|
||||
[DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool navigation_remove_all_laser_scans(NavigationHandle handle);
|
||||
|
||||
[DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool navigation_remove_all_point_clouds(NavigationHandle handle);
|
||||
|
||||
[DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool navigation_remove_all_point_cloud2s(NavigationHandle handle);
|
||||
|
||||
[DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool navigation_remove_all_data(NavigationHandle handle);
|
||||
|
||||
/// <summary>Get all static maps. out_maps must be pre-allocated; use navigation_get_all_static_maps_count or similar to get count first if needed.</summary>
|
||||
[DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool navigation_get_all_static_maps(NavigationHandle handle, [Out] NamedOccupancyGrid[] out_maps, ref UIntPtr out_count);
|
||||
|
||||
[DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool navigation_get_all_laser_scans(NavigationHandle handle, [Out] NamedLaserScan[] out_scans, ref UIntPtr out_count);
|
||||
|
||||
[DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool navigation_get_all_point_clouds(NavigationHandle handle, [Out] NamedPointCloud[] out_clouds, ref UIntPtr out_count);
|
||||
|
||||
[DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool navigation_get_all_point_cloud2s(NavigationHandle handle, [Out] NamedPointCloud2[] out_clouds, ref UIntPtr out_count);
|
||||
|
||||
[DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool navigation_get_global_data(NavigationHandle handle, ref PlannerDataOutput out_data);
|
||||
|
||||
[DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool navigation_get_local_data(NavigationHandle handle, ref PlannerDataOutput out_data);
|
||||
}
|
||||
}
|
||||
15
examples/NavigationExample/NavigationExample.csproj
Normal file
15
examples/NavigationExample/NavigationExample.csproj
Normal file
@@ -0,0 +1,15 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="SixLabors.ImageSharp" Version="3.1.7" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="libnav_c_api.so">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
498
examples/NavigationExample/Program.cs
Normal file
498
examples/NavigationExample/Program.cs
Normal file
@@ -0,0 +1,498 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text.RegularExpressions;
|
||||
using SixLabors.ImageSharp;
|
||||
using SixLabors.ImageSharp.PixelFormats;
|
||||
using NavigationExample;
|
||||
|
||||
|
||||
namespace NavigationExample
|
||||
{
|
||||
/// <summary>Thông tin map đọc từ file YAML (maze.yaml).</summary>
|
||||
public struct MazeMapConfig
|
||||
{
|
||||
public string ImagePath; // đường dẫn đầy đủ tới file ảnh
|
||||
public float Resolution;
|
||||
public double OriginX, OriginY, OriginZ;
|
||||
public int Negate; // 0 hoặc 1
|
||||
public double OccupiedThresh;
|
||||
public double FreeThresh;
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Example Usage
|
||||
// ============================================================================
|
||||
class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// Đọc file maze.yaml (image, resolution, origin, negate, occupied_thresh, free_thresh).
|
||||
/// ImagePath được resolve tuyệt đối theo thư mục chứa file yaml.
|
||||
/// </summary>
|
||||
static bool TryLoadMazeYaml(string yamlPath, out MazeMapConfig config)
|
||||
{
|
||||
config = default;
|
||||
if (string.IsNullOrEmpty(yamlPath) || !File.Exists(yamlPath))
|
||||
return false;
|
||||
string dir = Path.GetDirectoryName(Path.GetFullPath(yamlPath)) ?? "";
|
||||
try
|
||||
{
|
||||
string[] lines = File.ReadAllLines(yamlPath);
|
||||
foreach (string line in lines)
|
||||
{
|
||||
string trimmed = line.Trim();
|
||||
if (trimmed.Length == 0 || trimmed.StartsWith("#")) continue;
|
||||
int colon = trimmed.IndexOf(':');
|
||||
if (colon <= 0) continue;
|
||||
string key = trimmed.Substring(0, colon).Trim();
|
||||
string value = trimmed.Substring(colon + 1).Trim();
|
||||
if (key == "image")
|
||||
config.ImagePath = Path.Combine(dir, value);
|
||||
else if (key == "resolution" && float.TryParse(value, NumberStyles.Float, CultureInfo.InvariantCulture, out float res))
|
||||
config.Resolution = res;
|
||||
else if (key == "origin")
|
||||
{
|
||||
var m = Regex.Match(value, @"\[\s*([-\d.]+\s*),\s*([-\d.]+\s*),\s*([-\d.]+)\s*\]");
|
||||
if (m.Success)
|
||||
{
|
||||
config.OriginX = double.Parse(m.Groups[1].Value, CultureInfo.InvariantCulture);
|
||||
config.OriginY = double.Parse(m.Groups[2].Value, CultureInfo.InvariantCulture);
|
||||
config.OriginZ = double.Parse(m.Groups[3].Value, CultureInfo.InvariantCulture);
|
||||
}
|
||||
}
|
||||
else if (key == "negate" && int.TryParse(value, out int neg))
|
||||
config.Negate = neg;
|
||||
else if (key == "occupied_thresh" && double.TryParse(value, NumberStyles.Float, CultureInfo.InvariantCulture, out double ot))
|
||||
config.OccupiedThresh = ot;
|
||||
else if (key == "free_thresh" && double.TryParse(value, NumberStyles.Float, CultureInfo.InvariantCulture, out double ft))
|
||||
config.FreeThresh = ft;
|
||||
}
|
||||
return !string.IsNullOrEmpty(config.ImagePath);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Đọc file ảnh PNG và chuyển pixel sang byte[] occupancy (0=free, 100=occupied, 255=unknown).
|
||||
/// Dùng negate, occupied_thresh, free_thresh từ maze.yaml nếu cung cấp.
|
||||
/// </summary>
|
||||
static byte[] LoadMazePixelsAsOccupancy(string imagePath, out int width, out int height,
|
||||
int negate = 0, double occupiedThresh = 0.65, double freeThresh = 0.196)
|
||||
{
|
||||
width = 0;
|
||||
height = 0;
|
||||
if (string.IsNullOrEmpty(imagePath) || !File.Exists(imagePath))
|
||||
{
|
||||
LogError($"File not found: {imagePath}");
|
||||
return null;
|
||||
}
|
||||
try
|
||||
{
|
||||
using var image = Image.Load<Rgba32>(imagePath);
|
||||
int w = image.Width;
|
||||
int h = image.Height;
|
||||
width = w;
|
||||
height = h;
|
||||
byte[] data = new byte[w * h];
|
||||
image.ProcessPixelRows(accessor =>
|
||||
{
|
||||
for (int y = 0; y < accessor.Height; y++)
|
||||
{
|
||||
Span<Rgba32> row = accessor.GetRowSpan(y);
|
||||
for (int x = 0; x < row.Length; x++)
|
||||
{
|
||||
ref readonly Rgba32 p = ref row[x];
|
||||
double gray = (p.R + p.G + p.B) / 255.0 / 3.0;
|
||||
if (negate != 0) gray = 1.0 - gray;
|
||||
byte occ;
|
||||
if (gray <= freeThresh) occ = 0;
|
||||
else if (gray >= occupiedThresh) occ = 100;
|
||||
else occ = 255; // unknown
|
||||
data[y * w + x] = occ;
|
||||
}
|
||||
}
|
||||
});
|
||||
return data;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogError($"Load image failed: {ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// Helper method để hiển thị file và line number tự động
|
||||
static void LogError(string message,
|
||||
[CallerFilePath] string filePath = "",
|
||||
[CallerLineNumber] int lineNumber = 0,
|
||||
[CallerMemberName] string memberName = "")
|
||||
{
|
||||
// Lấy tên file từ đường dẫn đầy đủ
|
||||
string fileName = System.IO.Path.GetFileName(filePath);
|
||||
Console.WriteLine($"[{fileName}:{lineNumber}] {memberName}: {message}");
|
||||
}
|
||||
|
||||
static void Main(string[] args)
|
||||
{
|
||||
// Create tf3 buffer (replaces TF listener; used for all static transforms and navigation init)
|
||||
IntPtr tf3Buffer = TF3API.tf3_buffer_create(10);
|
||||
if (tf3Buffer == IntPtr.Zero)
|
||||
{
|
||||
LogError("Failed to create tf3 buffer (libtf3.so may be missing)");
|
||||
return;
|
||||
}
|
||||
Console.WriteLine($"[NavigationExample] TF3 buffer created, handle = 0x{tf3Buffer.ToInt64():X16}");
|
||||
string version = Marshal.PtrToStringAnsi(TF3API.tf3_get_version()) ?? "?";
|
||||
Console.WriteLine($"[TF3] {version}");
|
||||
|
||||
// Inject static transforms: map -> odom -> base_footprint -> base_link
|
||||
var tMapOdom = TF3API.CreateStaticTransform("map", "odom", 0, 0, 0, 0, 0, 0, 1);
|
||||
var tOdomFoot = TF3API.CreateStaticTransform("odom", "base_footprint", 0, 0, 0, 0, 0, 0, 1);
|
||||
var tFootLink = TF3API.CreateStaticTransform("base_footprint", "base_link", 0, 0, 0, 0, 0, 0, 1);
|
||||
if (!TF3API.tf3_set_transform(tf3Buffer, ref tMapOdom, "NavigationExample", true) ||
|
||||
!TF3API.tf3_set_transform(tf3Buffer, ref tOdomFoot, "NavigationExample", true) ||
|
||||
!TF3API.tf3_set_transform(tf3Buffer, ref tFootLink, "NavigationExample", true))
|
||||
{
|
||||
LogError("Failed to set static TF");
|
||||
TF3API.tf3_buffer_destroy(tf3Buffer);
|
||||
return;
|
||||
}
|
||||
|
||||
// Create navigation instance and initialize with tf3 buffer
|
||||
NavigationAPI.NavigationHandle navHandle = NavigationAPI.navigation_create();
|
||||
if (navHandle.ptr == IntPtr.Zero)
|
||||
{
|
||||
LogError("Failed to create navigation instance");
|
||||
TF3API.tf3_buffer_destroy(tf3Buffer);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!NavigationAPI.navigation_initialize(navHandle, tf3Buffer))
|
||||
{
|
||||
LogError("Failed to initialize navigation with tf3 buffer");
|
||||
NavigationAPI.navigation_destroy(navHandle);
|
||||
TF3API.tf3_buffer_destroy(tf3Buffer);
|
||||
return;
|
||||
}
|
||||
|
||||
while (true)
|
||||
{
|
||||
NavigationAPI.NavFeedback feedback = new NavigationAPI.NavFeedback();
|
||||
if (NavigationAPI.navigation_get_feedback(navHandle, ref feedback))
|
||||
{
|
||||
if (feedback.is_ready)
|
||||
{
|
||||
Console.WriteLine("Navigation is ready");
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Navigation is not ready");
|
||||
}
|
||||
}
|
||||
System.Threading.Thread.Sleep(100);
|
||||
}
|
||||
Console.WriteLine("[NavigationExample] Navigation initialized successfully");
|
||||
|
||||
|
||||
// Set robot footprint
|
||||
Point[] footprint = new Point[]
|
||||
{
|
||||
new Point { x = 0.3, y = -0.2, z = 0.0 },
|
||||
new Point { x = 0.3, y = 0.2, z = 0.0 },
|
||||
new Point { x = -0.3, y = 0.2, z = 0.0 },
|
||||
new Point { x = -0.3, y = -0.2, z = 0.0 }
|
||||
};
|
||||
NavigationAPI.navigation_set_robot_footprint(navHandle, footprint, new UIntPtr((uint)footprint.Length));
|
||||
|
||||
|
||||
IntPtr fFrameId = Marshal.StringToHGlobalAnsi("fscan");
|
||||
Header fscanHeader = NavigationAPI.header_create(Marshal.PtrToStringAnsi(fFrameId));
|
||||
LaserScan fscanHandle;
|
||||
fscanHandle.header = fscanHeader;
|
||||
fscanHandle.angle_min = -1.57f;
|
||||
fscanHandle.angle_max = 1.57f;
|
||||
fscanHandle.angle_increment = 0.785f;
|
||||
fscanHandle.time_increment = 0.0f;
|
||||
fscanHandle.scan_time = 0.1f;
|
||||
fscanHandle.range_min = 0.05f;
|
||||
fscanHandle.range_max = 10.0f;
|
||||
fscanHandle.ranges = Marshal.AllocHGlobal(sizeof(float) * 5);
|
||||
Marshal.Copy(new float[] { 1.0f, 1.2f, 1.1f, 0.9f, 1.3f }, 0, fscanHandle.ranges, 5);
|
||||
fscanHandle.ranges_count = new UIntPtr(5);
|
||||
fscanHandle.intensities = Marshal.AllocHGlobal(sizeof(float) * 5);
|
||||
Marshal.Copy(new float[] { 100.0f, 120.0f, 110.0f, 90.0f, 130.0f }, 0, fscanHandle.intensities, 5);
|
||||
fscanHandle.intensities_count = new UIntPtr(5);
|
||||
NavigationAPI.navigation_add_laser_scan(navHandle, "/fscan", fscanHandle);
|
||||
|
||||
IntPtr bFrameId = Marshal.StringToHGlobalAnsi("bscan");
|
||||
Header bscanHeader = NavigationAPI.header_create(Marshal.PtrToStringAnsi(bFrameId));
|
||||
LaserScan bscanHandle;
|
||||
bscanHandle.header = bscanHeader;
|
||||
bscanHandle.angle_min = 1.57f;
|
||||
bscanHandle.angle_max = -1.57f;
|
||||
bscanHandle.angle_increment = -0.785f;
|
||||
bscanHandle.time_increment = 0.0f;
|
||||
bscanHandle.scan_time = 0.1f;
|
||||
bscanHandle.range_min = 0.05f;
|
||||
bscanHandle.range_max = 10.0f;
|
||||
bscanHandle.ranges = Marshal.AllocHGlobal(sizeof(float) * 5);
|
||||
Marshal.Copy(new float[] { 1.0f, 1.2f, 1.1f, 0.9f, 1.3f }, 0, bscanHandle.ranges, 5);
|
||||
bscanHandle.ranges_count = new UIntPtr(5);
|
||||
bscanHandle.intensities = Marshal.AllocHGlobal(sizeof(float) * 5);
|
||||
Marshal.Copy(new float[] { 100.0f, 120.0f, 110.0f, 90.0f, 130.0f }, 0, bscanHandle.intensities, 5);
|
||||
bscanHandle.intensities_count = new UIntPtr(5);
|
||||
NavigationAPI.navigation_add_laser_scan(navHandle, "/bscan", bscanHandle);
|
||||
|
||||
IntPtr oFrameId = Marshal.StringToHGlobalAnsi("odom");
|
||||
Header odometryHeader = NavigationAPI.header_create(Marshal.PtrToStringAnsi(oFrameId));
|
||||
Odometry odometryHandle = new Odometry();
|
||||
odometryHandle.header = odometryHeader;
|
||||
IntPtr childFrameId = Marshal.StringToHGlobalAnsi("base_footprint");
|
||||
odometryHandle.child_frame_id = childFrameId;
|
||||
odometryHandle.pose.pose.position.x = 0.0;
|
||||
odometryHandle.pose.pose.position.y = 0.0;
|
||||
odometryHandle.pose.pose.position.z = 0.0;
|
||||
odometryHandle.pose.pose.orientation.x = 0.0;
|
||||
odometryHandle.pose.pose.orientation.y = 0.0;
|
||||
odometryHandle.pose.pose.orientation.z = 0.0;
|
||||
odometryHandle.pose.pose.orientation.w = 1.0;
|
||||
|
||||
double[] pose_covariance = new double[36];
|
||||
for(int i = 0; i < pose_covariance.Length; i++) {
|
||||
pose_covariance[i] = 0.0;
|
||||
}
|
||||
odometryHandle.pose.covariance = Marshal.AllocHGlobal(sizeof(double) * pose_covariance.Length);
|
||||
Marshal.Copy(pose_covariance, 0, odometryHandle.pose.covariance, pose_covariance.Length);
|
||||
odometryHandle.pose.covariance_count = new UIntPtr((uint)pose_covariance.Length);
|
||||
|
||||
odometryHandle.twist.twist.linear.x = 0.0;
|
||||
odometryHandle.twist.twist.linear.y = 0.0;
|
||||
odometryHandle.twist.twist.linear.z = 0.0;
|
||||
odometryHandle.twist.twist.angular.x = 0.0;
|
||||
odometryHandle.twist.twist.angular.y = 0.0;
|
||||
odometryHandle.twist.twist.angular.z = 0.0;
|
||||
double[] twist_covariance = new double[36];
|
||||
for(int i = 0; i < twist_covariance.Length; i++) {
|
||||
twist_covariance[i] = 0.0;
|
||||
}
|
||||
odometryHandle.twist.covariance = Marshal.AllocHGlobal(sizeof(double) * twist_covariance.Length);
|
||||
Marshal.Copy(twist_covariance, 0, odometryHandle.twist.covariance, twist_covariance.Length);
|
||||
odometryHandle.twist.covariance_count = new UIntPtr((uint)twist_covariance.Length);
|
||||
NavigationAPI.navigation_add_odometry(navHandle, "odometry", odometryHandle);
|
||||
|
||||
// Add static map: đọc maze.yaml rồi load ảnh và cập nhật mapMetaData
|
||||
string mapYamlPath = "maze.yaml";
|
||||
int mapWidth, mapHeight;
|
||||
byte[] data;
|
||||
MazeMapConfig mapConfig;
|
||||
if (TryLoadMazeYaml(mapYamlPath, out mapConfig))
|
||||
{
|
||||
data = LoadMazePixelsAsOccupancy(mapConfig.ImagePath, out mapWidth, out mapHeight,
|
||||
mapConfig.Negate, mapConfig.OccupiedThresh, mapConfig.FreeThresh);
|
||||
if (data == null)
|
||||
{
|
||||
mapWidth = 3;
|
||||
mapHeight = 10;
|
||||
data = new byte[30];
|
||||
for (int i = 0; i < data.Length; i++) data[i] = 100;
|
||||
Console.WriteLine("YAML loaded but image failed; using default map 3x10");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Loaded map from {0}: {1}x{2}, resolution={3}, origin=({4},{5},{6})",
|
||||
mapConfig.ImagePath, mapWidth, mapHeight, mapConfig.Resolution,
|
||||
mapConfig.OriginX, mapConfig.OriginY, mapConfig.OriginZ);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mapWidth = 3;
|
||||
mapHeight = 10;
|
||||
data = new byte[30];
|
||||
for (int i = 0; i < data.Length; i++) data[i] = 100;
|
||||
mapConfig = default;
|
||||
mapConfig.Resolution = 0.05f;
|
||||
mapConfig.OriginX = mapConfig.OriginY = mapConfig.OriginZ = 0.0;
|
||||
Console.WriteLine("maze.yaml not found, using default map 3x10");
|
||||
}
|
||||
|
||||
Time mapLoadTime = NavigationAPI.time_create();
|
||||
MapMetaData mapMetaData = new MapMetaData();
|
||||
mapMetaData.map_load_time = mapLoadTime;
|
||||
mapMetaData.resolution = mapConfig.Resolution;
|
||||
mapMetaData.width = (uint)mapWidth;
|
||||
mapMetaData.height = (uint)mapHeight;
|
||||
mapMetaData.origin = new Pose();
|
||||
mapMetaData.origin.position.x = mapConfig.OriginX;
|
||||
mapMetaData.origin.position.y = mapConfig.OriginY;
|
||||
mapMetaData.origin.position.z = mapConfig.OriginZ;
|
||||
mapMetaData.origin.orientation.x = 0.0;
|
||||
mapMetaData.origin.orientation.y = 0.0;
|
||||
mapMetaData.origin.orientation.z = 0.0;
|
||||
mapMetaData.origin.orientation.w = 1.0;
|
||||
OccupancyGrid occupancyGrid = new OccupancyGrid();
|
||||
IntPtr mapFrameId = Marshal.StringToHGlobalAnsi("map");
|
||||
occupancyGrid.header = NavigationAPI.header_create(Marshal.PtrToStringAnsi(mapFrameId));
|
||||
occupancyGrid.info = mapMetaData;
|
||||
occupancyGrid.data = Marshal.AllocHGlobal(sizeof(byte) * data.Length);
|
||||
Marshal.Copy(data, 0, occupancyGrid.data, data.Length);
|
||||
occupancyGrid.data_count = new UIntPtr((uint)data.Length);
|
||||
Console.WriteLine("data length: {0} {1}", data.Length, occupancyGrid.data_count);
|
||||
Console.WriteLine("C# OccupancyGrid sizeof={0} data_off={1} data_count_off={2}",
|
||||
Marshal.SizeOf<OccupancyGrid>(),
|
||||
Marshal.OffsetOf<OccupancyGrid>("data"),
|
||||
Marshal.OffsetOf<OccupancyGrid>("data_count"));
|
||||
|
||||
NavigationAPI.navigation_add_static_map(navHandle, "/map", occupancyGrid);
|
||||
|
||||
Twist2DStamped twist = new Twist2DStamped();
|
||||
if (NavigationAPI.navigation_get_twist(navHandle, ref twist))
|
||||
{
|
||||
Console.WriteLine(
|
||||
"Twist: {0}, {1}, {2}, {3}",
|
||||
NavigationAPI.MarshalString(twist.header.frame_id), twist.velocity.x, twist.velocity.y, twist.velocity.theta);
|
||||
}
|
||||
|
||||
// Build order (thao cách bom order): header + nodes + edges giống C++
|
||||
Order order = new Order();
|
||||
order.headerId = 1;
|
||||
order.timestamp = Marshal.StringToHGlobalAnsi("2026-02-28 10:00:00");
|
||||
order.version = Marshal.StringToHGlobalAnsi("1.0.0");
|
||||
order.manufacturer = Marshal.StringToHGlobalAnsi("Manufacturer");
|
||||
order.serialNumber = Marshal.StringToHGlobalAnsi("Serial Number");
|
||||
order.orderId = Marshal.StringToHGlobalAnsi("Order ID");
|
||||
order.orderUpdateId = 1;
|
||||
|
||||
// Nodes: giống for (auto node : order.nodes) { node_msg.nodeId = ...; node_msg.nodePosition.x = ...; order_msg.nodes.push_back(node_msg); }
|
||||
int nodeCount = 1;
|
||||
order.nodes = Marshal.AllocHGlobal(Marshal.SizeOf<Node>() * nodeCount);
|
||||
order.nodes_count = new UIntPtr((uint)nodeCount);
|
||||
Node node1 = new Node();
|
||||
node1.nodeId = Marshal.StringToHGlobalAnsi("node-1");
|
||||
node1.sequenceId = 0;
|
||||
node1.nodeDescription = Marshal.StringToHGlobalAnsi("Goal node");
|
||||
node1.released = 0;
|
||||
node1.nodePosition.x = 1.0;
|
||||
node1.nodePosition.y = 1.0;
|
||||
node1.nodePosition.theta = 0.0;
|
||||
node1.nodePosition.allowedDeviationXY = 0.1f;
|
||||
node1.nodePosition.allowedDeviationTheta = 0.05f;
|
||||
node1.nodePosition.mapId = Marshal.StringToHGlobalAnsi("map");
|
||||
node1.nodePosition.mapDescription = Marshal.StringToHGlobalAnsi("");
|
||||
node1.actions = IntPtr.Zero;
|
||||
node1.actions_count = UIntPtr.Zero;
|
||||
Marshal.StructureToPtr(node1, order.nodes, false);
|
||||
|
||||
// Edges: rỗng trong ví dụ này; nếu cần thì alloc và fill tương tự (edge_msg.edgeId, trajectory.controlPoints, ...)
|
||||
order.edges = IntPtr.Zero;
|
||||
order.edges_count = UIntPtr.Zero;
|
||||
order.zoneSetId = Marshal.StringToHGlobalAnsi("");
|
||||
|
||||
PoseStamped goal = new PoseStamped();
|
||||
goal.header = NavigationAPI.header_create(Marshal.PtrToStringAnsi(mapFrameId));
|
||||
goal.pose.position.x = 0.01;
|
||||
goal.pose.position.y = 0.01;
|
||||
goal.pose.position.z = 0.0;
|
||||
goal.pose.orientation.x = 0.0;
|
||||
goal.pose.orientation.y = 0.0;
|
||||
goal.pose.orientation.z = 0.0;
|
||||
goal.pose.orientation.w = 1.0;
|
||||
|
||||
|
||||
// Docking used to be its own call, navigation_dock_to(navHandle, "charger", goal).
|
||||
// It is a per-leg property of the order now: put `profile: docking` and `marker:
|
||||
// charger` on the leg and send the order, so the leg gets the same mission id,
|
||||
// lifecycle and cancel path as every other leg.
|
||||
NavigationAPI.navigation_move_to(navHandle, goal);
|
||||
|
||||
// NavigationAPI.navigation_move_to_nodes_edges(navHandle, order.nodes, order.nodes_count, order.edges, order.edges_count, goal);
|
||||
|
||||
// NavigationAPI.navigation_move_to_order(navHandle, order, goal);
|
||||
NavigationAPI.navigation_set_twist_linear(navHandle, 0.1, 0.0, 0.0);
|
||||
NavigationAPI.navigation_set_twist_angular(navHandle, 0.0, 0.0, 0.2);
|
||||
|
||||
while (true)
|
||||
{
|
||||
System.Threading.Thread.Sleep(100);
|
||||
// NavigationAPI.NavFeedback feedback = new NavigationAPI.NavFeedback();
|
||||
// if (NavigationAPI.navigation_get_feedback(navHandle, ref feedback))
|
||||
// {
|
||||
// if (feedback.navigation_state == NavigationAPI.NavigationState.Succeeded)
|
||||
// {
|
||||
// Console.WriteLine("Navigation is Succeeded");
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
|
||||
// NavigationAPI.PlannerDataOutput globalData = new NavigationAPI.PlannerDataOutput();
|
||||
// if (NavigationAPI.navigation_get_global_data(navHandle, ref globalData))
|
||||
// {
|
||||
// int n = (int)(uint)globalData.plan.poses_count;
|
||||
// int poseSize = Marshal.SizeOf<Pose2DStamped>();
|
||||
// for (int i = 0; i < n; i++)
|
||||
// {
|
||||
// IntPtr posePtr = IntPtr.Add(globalData.plan.poses, i * poseSize);
|
||||
// Pose2DStamped p = Marshal.PtrToStructure<Pose2DStamped>(posePtr);
|
||||
// double p_x = p.pose.x;
|
||||
// double p_y = p.pose.y;
|
||||
// double p_theta = p.pose.theta;
|
||||
// Console.WriteLine("Plan: {0}, {1}, {2}", p_x, p_y, p_theta);
|
||||
// }
|
||||
// if(globalData.is_costmap_updated) {
|
||||
// for(int i = 0; i < (int)(uint)globalData.costmap.data_count; i++) {
|
||||
// byte cellValue = Marshal.ReadByte(globalData.costmap.data, i);
|
||||
// Console.WriteLine("Costmap: {0} {1}", i, cellValue);
|
||||
// }
|
||||
// }
|
||||
// else {
|
||||
// Console.WriteLine("Global Costmap is not updated");
|
||||
// }
|
||||
// }
|
||||
|
||||
// NavigationAPI.PlannerDataOutput localData = new NavigationAPI.PlannerDataOutput();
|
||||
// if(NavigationAPI.navigation_get_local_data(navHandle, ref localData))
|
||||
// {
|
||||
// int n = (int)(uint)localData.plan.poses_count;
|
||||
// int poseSize = Marshal.SizeOf<Pose2DStamped>();
|
||||
// for (int i = 0; i < n; i++)
|
||||
// {
|
||||
// IntPtr posePtr = IntPtr.Add(localData.plan.poses, i * poseSize);
|
||||
// Pose2DStamped p = Marshal.PtrToStructure<Pose2DStamped>(posePtr);
|
||||
// double p_x = p.pose.x;
|
||||
// double p_y = p.pose.y;
|
||||
// double p_theta = p.pose.theta;
|
||||
// Console.WriteLine("Plan: {0}, {1}, {2}", p_x, p_y, p_theta);
|
||||
// }
|
||||
// if(localData.is_costmap_updated) {
|
||||
// for(int i = 0; i < (int)(uint)localData.costmap.data_count; i++) {
|
||||
// byte cellValue = Marshal.ReadByte(localData.costmap.data, i);
|
||||
// Console.WriteLine("Costmap: {0} {1}", i, cellValue);
|
||||
// }
|
||||
// }
|
||||
// else {
|
||||
// Console.WriteLine("Local Costmap is not updated");
|
||||
// }
|
||||
// }
|
||||
}
|
||||
// Cleanup (destroy nav first, then tf3 buffer)
|
||||
|
||||
NavigationAPI.navigation_destroy(navHandle);
|
||||
TF3API.tf3_buffer_destroy(tf3Buffer);
|
||||
Console.WriteLine("Press any key to exit...");
|
||||
try
|
||||
{
|
||||
Console.ReadKey(intercept: true);
|
||||
}
|
||||
catch (InvalidOperationException)
|
||||
{
|
||||
// Running without a real console (e.g. redirected/automated run).
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
133
examples/NavigationExample/TF3API.cs
Normal file
133
examples/NavigationExample/TF3API.cs
Normal file
@@ -0,0 +1,133 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace NavigationExample
|
||||
{
|
||||
|
||||
// ============================================================================
|
||||
// TF3 C API - P/Invoke wrapper for libtf3 (tf3 BufferCore)
|
||||
// ============================================================================
|
||||
public static class TF3API
|
||||
{
|
||||
private const string Tf3DllName = "/usr/local/lib/libtf3.so"; // Linux; Windows: tf3.dll, macOS: libtf3.dylib
|
||||
|
||||
public enum TF3_ErrorCode
|
||||
{
|
||||
TF3_OK = 0,
|
||||
TF3_ERROR_LOOKUP = 1,
|
||||
TF3_ERROR_CONNECTIVITY = 2,
|
||||
TF3_ERROR_EXTRAPOLATION = 3,
|
||||
TF3_ERROR_INVALID_ARGUMENT = 4,
|
||||
TF3_ERROR_TIMEOUT = 5,
|
||||
TF3_ERROR_UNKNOWN = 99
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
||||
public struct TF3_Transform
|
||||
{
|
||||
public long timestamp_sec;
|
||||
public long timestamp_nsec;
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
|
||||
public string frame_id;
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
|
||||
public string child_frame_id;
|
||||
public double translation_x;
|
||||
public double translation_y;
|
||||
public double translation_z;
|
||||
public double rotation_x;
|
||||
public double rotation_y;
|
||||
public double rotation_z;
|
||||
public double rotation_w;
|
||||
}
|
||||
|
||||
[DllImport(Tf3DllName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr tf3_buffer_create(int cache_time_sec);
|
||||
|
||||
[DllImport(Tf3DllName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void tf3_buffer_destroy(IntPtr buffer);
|
||||
|
||||
[DllImport(Tf3DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool tf3_set_transform(
|
||||
IntPtr buffer,
|
||||
ref TF3_Transform transform,
|
||||
string authority,
|
||||
[MarshalAs(UnmanagedType.I1)] bool is_static);
|
||||
|
||||
[DllImport(Tf3DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool tf3_lookup_transform(
|
||||
IntPtr buffer,
|
||||
string target_frame,
|
||||
string source_frame,
|
||||
long time_sec,
|
||||
long time_nsec,
|
||||
out TF3_Transform transform,
|
||||
out TF3_ErrorCode error_code);
|
||||
|
||||
[DllImport(Tf3DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool tf3_lookup_transform_full(
|
||||
IntPtr buffer,
|
||||
string target_frame,
|
||||
long target_time_sec,
|
||||
long target_time_nsec,
|
||||
string source_frame,
|
||||
long source_time_sec,
|
||||
long source_time_nsec,
|
||||
string fixed_frame,
|
||||
out TF3_Transform transform,
|
||||
out TF3_ErrorCode error_code);
|
||||
|
||||
[DllImport(Tf3DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool tf3_can_transform(
|
||||
IntPtr buffer,
|
||||
string target_frame,
|
||||
string source_frame,
|
||||
long time_sec,
|
||||
long time_nsec,
|
||||
System.Text.StringBuilder error_msg,
|
||||
int error_msg_len);
|
||||
|
||||
[DllImport(Tf3DllName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int tf3_get_all_frame_names(IntPtr buffer, System.Text.StringBuilder frames, int frames_len);
|
||||
|
||||
[DllImport(Tf3DllName, CallingConvention = CallingConvention.Cdecl)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool tf3_get_frame_tree(IntPtr buffer, System.Text.StringBuilder output, int output_len);
|
||||
|
||||
[DllImport(Tf3DllName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void tf3_clear(IntPtr buffer);
|
||||
|
||||
[DllImport(Tf3DllName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void tf3_get_current_time(out long sec, out long nsec);
|
||||
|
||||
[DllImport(Tf3DllName, CallingConvention = CallingConvention.Cdecl)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
public static extern bool tf3_get_last_error(IntPtr buffer, System.Text.StringBuilder error_msg, int error_msg_len);
|
||||
|
||||
[DllImport(Tf3DllName, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr tf3_get_version();
|
||||
|
||||
/// <summary>Helper: create TF3_Transform for static transform (identity or given pose).</summary>
|
||||
public static TF3_Transform CreateStaticTransform(string parentFrame, string childFrame,
|
||||
double tx = 0, double ty = 0, double tz = 0,
|
||||
double qx = 0, double qy = 0, double qz = 0, double qw = 1)
|
||||
{
|
||||
var t = new TF3_Transform();
|
||||
t.timestamp_sec = 0;
|
||||
t.timestamp_nsec = 0;
|
||||
t.frame_id = parentFrame ?? "";
|
||||
t.child_frame_id = childFrame ?? "";
|
||||
t.translation_x = tx;
|
||||
t.translation_y = ty;
|
||||
t.translation_z = tz;
|
||||
t.rotation_x = qx;
|
||||
t.rotation_y = qy;
|
||||
t.rotation_z = qz;
|
||||
t.rotation_w = qw;
|
||||
return t;
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
examples/NavigationExample/libnav_c_api.so
Executable file
BIN
examples/NavigationExample/libnav_c_api.so
Executable file
Binary file not shown.
BIN
examples/NavigationExample/maze.png
Normal file
BIN
examples/NavigationExample/maze.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.5 KiB |
6
examples/NavigationExample/maze.yaml
Normal file
6
examples/NavigationExample/maze.yaml
Normal file
@@ -0,0 +1,6 @@
|
||||
image: maze.png
|
||||
resolution: 0.05
|
||||
origin: [0.0, 0.0, 0.0]
|
||||
negate: 0
|
||||
occupied_thresh: 0.65
|
||||
free_thresh: 0.196
|
||||
274
examples/NavigationExample/msgs/CommonMsgs.cs
Normal file
274
examples/NavigationExample/msgs/CommonMsgs.cs
Normal file
@@ -0,0 +1,274 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace NavigationExample
|
||||
{
|
||||
// ============================================================================
|
||||
// Structures
|
||||
// ============================================================================
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Point
|
||||
{
|
||||
public double x;
|
||||
public double y;
|
||||
public double z;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Pose2D
|
||||
{
|
||||
public double x;
|
||||
public double y;
|
||||
public double theta;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Twist2D
|
||||
{
|
||||
public double x;
|
||||
public double y;
|
||||
public double theta;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Quaternion
|
||||
{
|
||||
public double x;
|
||||
public double y;
|
||||
public double z;
|
||||
public double w;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Position
|
||||
{
|
||||
public double x;
|
||||
public double y;
|
||||
public double z;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Pose
|
||||
{
|
||||
public Point position;
|
||||
public Quaternion orientation;
|
||||
}
|
||||
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Vector3
|
||||
{
|
||||
public double x;
|
||||
public double y;
|
||||
public double z;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Twist
|
||||
{
|
||||
public Vector3 linear;
|
||||
public Vector3 angular;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Header
|
||||
{
|
||||
public uint seq;
|
||||
public uint sec;
|
||||
public uint nsec;
|
||||
public IntPtr frame_id; // char*
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct PoseStamped
|
||||
{
|
||||
public Header header;
|
||||
public Pose pose;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Twist2DStamped
|
||||
{
|
||||
public Header header;
|
||||
public Twist2D velocity;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct LaserScan
|
||||
{
|
||||
public Header header;
|
||||
public float angle_min;
|
||||
public float angle_max;
|
||||
public float angle_increment;
|
||||
public float time_increment;
|
||||
public float scan_time;
|
||||
public float range_min;
|
||||
public float range_max;
|
||||
public IntPtr ranges;
|
||||
public UIntPtr ranges_count;
|
||||
public IntPtr intensities;
|
||||
public UIntPtr intensities_count;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct PointCloud
|
||||
{
|
||||
public Header header;
|
||||
public IntPtr points;
|
||||
public UIntPtr points_count;
|
||||
public IntPtr channels;
|
||||
public UIntPtr channels_count;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct PointCloud2
|
||||
{
|
||||
public Header header;
|
||||
public uint height;
|
||||
public uint width;
|
||||
public IntPtr fields;
|
||||
public UIntPtr fields_count;
|
||||
[MarshalAs(UnmanagedType.I1)]
|
||||
public bool is_bigendian;
|
||||
public uint point_step;
|
||||
public uint row_step;
|
||||
public IntPtr data;
|
||||
public UIntPtr data_count;
|
||||
[MarshalAs(UnmanagedType.I1)]
|
||||
public bool is_dense;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct PoseWithCovariance
|
||||
{
|
||||
public Pose pose;
|
||||
public IntPtr covariance;
|
||||
public UIntPtr covariance_count;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct TwistWithCovariance {
|
||||
public Twist twist;
|
||||
public IntPtr covariance;
|
||||
public UIntPtr covariance_count;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Odometry
|
||||
{
|
||||
public Header header;
|
||||
public IntPtr child_frame_id;
|
||||
public PoseWithCovariance pose;
|
||||
public TwistWithCovariance twist;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct OccupancyGrid
|
||||
{
|
||||
public Header header;
|
||||
public MapMetaData info;
|
||||
public IntPtr data;
|
||||
public UIntPtr data_count;
|
||||
}
|
||||
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct MapMetaData
|
||||
{
|
||||
public Time map_load_time;
|
||||
public float resolution;
|
||||
public uint width;
|
||||
public uint height;
|
||||
public Pose origin;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Time
|
||||
{
|
||||
public uint sec;
|
||||
public uint nsec;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Point32
|
||||
{
|
||||
public float x;
|
||||
public float y;
|
||||
public float z;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Pose2DStamped
|
||||
{
|
||||
public Header header;
|
||||
public Pose2D pose;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Polygon
|
||||
{
|
||||
public IntPtr points;
|
||||
public UIntPtr points_count;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct PolygonStamped
|
||||
{
|
||||
public Header header;
|
||||
public Polygon polygon;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct OccupancyGridUpdate
|
||||
{
|
||||
public Header header;
|
||||
public int x;
|
||||
public int y;
|
||||
public uint width;
|
||||
public uint height;
|
||||
public IntPtr data;
|
||||
public UIntPtr data_count;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Path2D
|
||||
{
|
||||
public Header header;
|
||||
public IntPtr poses;
|
||||
public UIntPtr poses_count;
|
||||
}
|
||||
|
||||
/// <summary>Name (char*) + OccupancyGrid for static map list API.</summary>
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct NamedOccupancyGrid
|
||||
{
|
||||
public IntPtr name;
|
||||
public OccupancyGrid grid;
|
||||
}
|
||||
|
||||
/// <summary>Name (char*) + LaserScan for laser scan list API.</summary>
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct NamedLaserScan
|
||||
{
|
||||
public IntPtr name;
|
||||
public LaserScan scan;
|
||||
}
|
||||
|
||||
/// <summary>Name (char*) + PointCloud for point cloud list API.</summary>
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct NamedPointCloud
|
||||
{
|
||||
public IntPtr name;
|
||||
public PointCloud cloud;
|
||||
}
|
||||
|
||||
/// <summary>Name (char*) + PointCloud2 for point cloud2 list API.</summary>
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct NamedPointCloud2
|
||||
{
|
||||
public IntPtr name;
|
||||
public PointCloud2 cloud;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
109
examples/NavigationExample/msgs/ProtocolMsgsTypes.cs
Normal file
109
examples/NavigationExample/msgs/ProtocolMsgsTypes.cs
Normal file
@@ -0,0 +1,109 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace NavigationExample
|
||||
{
|
||||
/// <summary>
|
||||
/// C# struct layout cho protocol_msgs (robot_protocol_msgs C API).
|
||||
/// Khớp với pnkx_nav_core/src/APIs/c_api/include/protocol_msgs/*.h
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct ControlPoint
|
||||
{
|
||||
public double x;
|
||||
public double y;
|
||||
public double weight;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct ActionParameter
|
||||
{
|
||||
public IntPtr key; // char*
|
||||
public IntPtr value; // char*
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct NodePosition
|
||||
{
|
||||
public double x;
|
||||
public double y;
|
||||
public double theta;
|
||||
public float allowedDeviationXY;
|
||||
public float allowedDeviationTheta;
|
||||
public IntPtr mapId; // char*
|
||||
public IntPtr mapDescription; // char*
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Trajectory
|
||||
{
|
||||
public uint degree;
|
||||
public IntPtr knotVector; // double*
|
||||
public UIntPtr knotVector_count;
|
||||
public IntPtr controlPoints; // ControlPoint*
|
||||
public UIntPtr controlPoints_count;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Action
|
||||
{
|
||||
public IntPtr actionType; // char*
|
||||
public IntPtr actionId; // char*
|
||||
public IntPtr actionDescription;// char*
|
||||
public IntPtr blockingType; // char*
|
||||
public IntPtr actionParameters; // ActionParameter*
|
||||
public UIntPtr actionParameters_count;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Node
|
||||
{
|
||||
public IntPtr nodeId; // char*
|
||||
public int sequenceId;
|
||||
public IntPtr nodeDescription; // char*
|
||||
public byte released;
|
||||
public NodePosition nodePosition;
|
||||
public IntPtr actions; // Action*
|
||||
public UIntPtr actions_count;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Edge
|
||||
{
|
||||
public IntPtr edgeId; // char*
|
||||
public int sequenceId;
|
||||
public IntPtr edgeDescription; // char*
|
||||
public byte released;
|
||||
public IntPtr startNodeId; // char*
|
||||
public IntPtr endNodeId; // char*
|
||||
public double maxSpeed;
|
||||
public double maxHeight;
|
||||
public double minHeight;
|
||||
public double orientation;
|
||||
public IntPtr orientationType; // char*
|
||||
public IntPtr direction; // char*
|
||||
public byte rotationAllowed;
|
||||
public double maxRotationSpeed;
|
||||
public Trajectory trajectory;
|
||||
public double length;
|
||||
public IntPtr actions; // Action*
|
||||
public UIntPtr actions_count;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Order
|
||||
{
|
||||
public int headerId;
|
||||
public IntPtr timestamp; // char*
|
||||
public IntPtr version; // char*
|
||||
public IntPtr manufacturer; // char*
|
||||
public IntPtr serialNumber; // char*
|
||||
public IntPtr orderId; // char*
|
||||
public uint orderUpdateId;
|
||||
public IntPtr nodes; // Node*
|
||||
public UIntPtr nodes_count;
|
||||
public IntPtr edges; // Edge*
|
||||
public UIntPtr edges_count;
|
||||
public IntPtr zoneSetId; // char*
|
||||
}
|
||||
}
|
||||
0
examples/NavigationExample/msgs/SensorMsgs.cs
Normal file
0
examples/NavigationExample/msgs/SensorMsgs.cs
Normal file
148
examples/QUICK_START.md
Normal file
148
examples/QUICK_START.md
Normal file
@@ -0,0 +1,148 @@
|
||||
# Quick Start - Chạy C# Example
|
||||
|
||||
## Bước 1: Cài đặt .NET SDK (nếu chưa có)
|
||||
|
||||
### Ubuntu/Debian:
|
||||
```bash
|
||||
# Cài đặt .NET 6.0 hoặc mới hơn
|
||||
wget https://dot.net/v1/dotnet-install.sh
|
||||
chmod +x dotnet-install.sh
|
||||
./dotnet-install.sh --channel 6.0
|
||||
|
||||
# Thêm vào PATH
|
||||
export PATH=$PATH:$HOME/.dotnet
|
||||
export DOTNET_ROOT=$HOME/.dotnet
|
||||
|
||||
# Hoặc cài qua apt (nếu có)
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y dotnet-sdk-6.0
|
||||
```
|
||||
|
||||
### Kiểm tra:
|
||||
```bash
|
||||
dotnet --version
|
||||
```
|
||||
|
||||
## Bước 2: Build C API Library
|
||||
|
||||
```bash
|
||||
cd /home/robotics/AGV/Diff_Wheel_Prj/pnkx_nav_core
|
||||
mkdir -p build
|
||||
cd build
|
||||
cmake ..
|
||||
make nav_c_api
|
||||
```
|
||||
|
||||
Library sẽ ở: `build/src/APIs/c_api/libnav_c_api.so`
|
||||
|
||||
## Bước 3: Chạy C# Example
|
||||
|
||||
### Cách 1: Dùng script tự động (Khuyến nghị)
|
||||
|
||||
```bash
|
||||
cd /home/robotics/AGV/Diff_Wheel_Prj/pnkx_nav_core/examples
|
||||
chmod +x run_example.sh
|
||||
./run_example.sh
|
||||
```
|
||||
|
||||
Script sẽ tự động:
|
||||
- ✅ Build library nếu chưa có
|
||||
- ✅ Tạo C# project
|
||||
- ✅ Copy library và source code
|
||||
- ✅ Set LD_LIBRARY_PATH cho tất cả dependencies
|
||||
- ✅ Build và chạy example
|
||||
|
||||
### Cách 2: Chạy thủ công
|
||||
|
||||
```bash
|
||||
# 1. Tạo project
|
||||
cd /home/robotics/AGV/Diff_Wheel_Prj/pnkx_nav_core/examples
|
||||
dotnet new console -n NavigationExample
|
||||
cd NavigationExample
|
||||
|
||||
# 2. Copy source code
|
||||
cp ../CSharpExample.cs Program.cs
|
||||
|
||||
# 3. Tạo .csproj
|
||||
cat > NavigationExample.csproj << 'EOF'
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<RuntimeIdentifier>linux-x64</RuntimeIdentifier>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<None Include="libnav_c_api.so">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
EOF
|
||||
|
||||
# 4. Copy library
|
||||
cp ../../build/src/APIs/c_api/libnav_c_api.so .
|
||||
|
||||
# 5. Set library path (quan trọng!)
|
||||
export LD_LIBRARY_PATH=../../build/src/APIs/c_api:$LD_LIBRARY_PATH
|
||||
export LD_LIBRARY_PATH=../../build/src/Navigations/Libraries/robot_costmap_2d:$LD_LIBRARY_PATH
|
||||
export LD_LIBRARY_PATH=../../build/src/Navigations/Libraries/geometry2/robot_tf3_geometry_msgs:$LD_LIBRARY_PATH
|
||||
export LD_LIBRARY_PATH=../../build/src/Navigations/Libraries/geometry2/robot_tf3_sensor_msgs:$LD_LIBRARY_PATH
|
||||
export LD_LIBRARY_PATH=../../build/src/Navigations/Packages/move_base:$LD_LIBRARY_PATH
|
||||
export LD_LIBRARY_PATH=../../build/src/Navigations/Cores/move_base_core:$LD_LIBRARY_PATH
|
||||
export LD_LIBRARY_PATH=../../build/src/Navigations/Libraries/tf3:$LD_LIBRARY_PATH
|
||||
export LD_LIBRARY_PATH=../../build/src/Navigations/Libraries/robot_time:$LD_LIBRARY_PATH
|
||||
|
||||
# 6. Build và chạy
|
||||
dotnet build
|
||||
dotnet run
|
||||
```
|
||||
|
||||
## Bước 4: Kiểm tra kết quả
|
||||
|
||||
Nếu chạy thành công, bạn sẽ thấy output như:
|
||||
```
|
||||
Robot pose: x=0.0, y=0.0, theta=0.0
|
||||
State: PENDING, Feedback: ...
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Lỗi: "dotnet: command not found"
|
||||
→ Cài đặt .NET SDK (xem Bước 1)
|
||||
|
||||
### Lỗi: "Unable to load DLL 'libnav_c_api.so'"
|
||||
```bash
|
||||
# Kiểm tra library có tồn tại không
|
||||
ls -la ../../build/src/APIs/c_api/libnav_c_api.so
|
||||
|
||||
# Set LD_LIBRARY_PATH (bao gồm tất cả dependencies)
|
||||
export LD_LIBRARY_PATH=../../build/src/APIs/c_api:$LD_LIBRARY_PATH
|
||||
export LD_LIBRARY_PATH=../../build/src/Navigations/Libraries/robot_costmap_2d:$LD_LIBRARY_PATH
|
||||
export LD_LIBRARY_PATH=../../build/src/Navigations/Libraries/geometry2/robot_tf3_geometry_msgs:$LD_LIBRARY_PATH
|
||||
export LD_LIBRARY_PATH=../../build/src/Navigations/Libraries/geometry2/robot_tf3_sensor_msgs:$LD_LIBRARY_PATH
|
||||
export LD_LIBRARY_PATH=../../build/src/Navigations/Packages/move_base:$LD_LIBRARY_PATH
|
||||
export LD_LIBRARY_PATH=../../build/src/Navigations/Cores/move_base_core:$LD_LIBRARY_PATH
|
||||
export LD_LIBRARY_PATH=../../build/src/Navigations/Libraries/tf3:$LD_LIBRARY_PATH
|
||||
export LD_LIBRARY_PATH=../../build/src/Navigations/Libraries/robot_time:$LD_LIBRARY_PATH
|
||||
|
||||
# Hoặc copy vào system lib
|
||||
sudo cp libnav_c_api.so /usr/local/lib/
|
||||
sudo ldconfig
|
||||
```
|
||||
|
||||
### Lỗi: "Missing dependencies"
|
||||
```bash
|
||||
# Kiểm tra dependencies
|
||||
ldd libnav_c_api.so
|
||||
|
||||
# Đảm bảo tất cả dependencies đều có sẵn
|
||||
```
|
||||
|
||||
### Lỗi: "Failed to create navigation instance"
|
||||
→ Đã được sửa! `navigation_create()` bây giờ tạo instance của `move_base::MoveBase`.
|
||||
Nếu vẫn gặp lỗi, kiểm tra:
|
||||
- Library đã được build đầy đủ: `make nav_c_api` trong build directory
|
||||
- Dependencies đã được build: `make move_base robot_costmap_2d`
|
||||
- LD_LIBRARY_PATH đã được set đúng
|
||||
|
||||
142
examples/README.md
Normal file
142
examples/README.md
Normal file
@@ -0,0 +1,142 @@
|
||||
# Hướng dẫn chạy C# Example
|
||||
|
||||
## Yêu cầu
|
||||
|
||||
1. **.NET SDK** (version 6.0 trở lên hoặc .NET 10)
|
||||
2. **C API Library** đã được build (`libnav_c_api.so`)
|
||||
3. **Linux environment** (hoặc WSL nếu dùng Windows)
|
||||
|
||||
## Bước 1: Build C API Library
|
||||
|
||||
```bash
|
||||
cd /home/robotics/AGV/Diff_Wheel_Prj/pnkx_nav_core
|
||||
mkdir -p build
|
||||
cd build
|
||||
cmake ..
|
||||
make nav_c_api
|
||||
```
|
||||
|
||||
Library sẽ được tạo tại: `build/src/APIs/c_api/libnav_c_api.so`
|
||||
|
||||
## Bước 2: Chạy script tự động (Khuyến nghị)
|
||||
|
||||
```bash
|
||||
cd /home/robotics/AGV/Diff_Wheel_Prj/pnkx_nav_core/examples
|
||||
chmod +x run_example.sh
|
||||
./run_example.sh
|
||||
```
|
||||
|
||||
Script sẽ tự động:
|
||||
- Build library nếu chưa có
|
||||
- Tạo C# project
|
||||
- Copy library và source code
|
||||
- Set LD_LIBRARY_PATH cho tất cả dependencies
|
||||
- Build và chạy example
|
||||
|
||||
## Bước 3: Hoặc chạy thủ công
|
||||
|
||||
### Tạo C# Project
|
||||
|
||||
```bash
|
||||
cd /home/robotics/AGV/Diff_Wheel_Prj/pnkx_nav_core/examples
|
||||
dotnet new console -n NavigationExample
|
||||
cd NavigationExample
|
||||
```
|
||||
|
||||
### Copy file và library
|
||||
|
||||
```bash
|
||||
# Copy C# source code
|
||||
cp ../CSharpExample.cs Program.cs
|
||||
|
||||
# Copy library vào thư mục project
|
||||
cp ../../build/src/APIs/c_api/libnav_c_api.so .
|
||||
```
|
||||
|
||||
## Bước 4: Cập nhật .csproj (nếu cần)
|
||||
|
||||
Tạo file `NavigationExample.csproj`:
|
||||
|
||||
```xml
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<RuntimeIdentifier>linux-x64</RuntimeIdentifier>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<None Include="libnav_c_api.so">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
```
|
||||
|
||||
## Bước 4: Build và chạy
|
||||
|
||||
```bash
|
||||
# Set LD_LIBRARY_PATH để tìm được tất cả dependencies
|
||||
export LD_LIBRARY_PATH=../../build/src/APIs/c_api:$LD_LIBRARY_PATH
|
||||
export LD_LIBRARY_PATH=../../build/src/Navigations/Libraries/robot_costmap_2d:$LD_LIBRARY_PATH
|
||||
export LD_LIBRARY_PATH=../../build/src/Navigations/Libraries/geometry2/robot_tf3_geometry_msgs:$LD_LIBRARY_PATH
|
||||
export LD_LIBRARY_PATH=../../build/src/Navigations/Libraries/geometry2/robot_tf3_sensor_msgs:$LD_LIBRARY_PATH
|
||||
export LD_LIBRARY_PATH=../../build/src/Navigations/Packages/move_base:$LD_LIBRARY_PATH
|
||||
export LD_LIBRARY_PATH=../../build/src/Navigations/Cores/move_base_core:$LD_LIBRARY_PATH
|
||||
export LD_LIBRARY_PATH=../../build/src/Navigations/Libraries/tf3:$LD_LIBRARY_PATH
|
||||
export LD_LIBRARY_PATH=../../build/src/Navigations/Libraries/robot_time:$LD_LIBRARY_PATH
|
||||
|
||||
# Build
|
||||
dotnet build
|
||||
|
||||
# Chạy
|
||||
dotnet run
|
||||
```
|
||||
|
||||
## Lưu ý
|
||||
|
||||
1. **Library path**: Đảm bảo `libnav_c_api.so` có thể được tìm thấy:
|
||||
- Copy vào cùng thư mục với executable
|
||||
- Hoặc set `LD_LIBRARY_PATH` environment variable
|
||||
- Hoặc copy vào `/usr/local/lib` và chạy `ldconfig`
|
||||
|
||||
2. **Dependencies**: Library cần các dependencies khác:
|
||||
```bash
|
||||
# Kiểm tra dependencies
|
||||
ldd libnav_c_api.so
|
||||
|
||||
# Đảm bảo tất cả dependencies đều có sẵn
|
||||
```
|
||||
|
||||
3. **Permissions**: Đảm bảo file có quyền execute:
|
||||
```bash
|
||||
chmod +x libnav_c_api.so
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Lỗi: "Unable to load DLL 'libnav_c_api.so'"
|
||||
|
||||
**Giải pháp:**
|
||||
```bash
|
||||
# Set LD_LIBRARY_PATH
|
||||
export LD_LIBRARY_PATH=/home/robotics/AGV/Diff_Wheel_Prj/pnkx_nav_core/build/src/APIs/c_api:$LD_LIBRARY_PATH
|
||||
|
||||
# Hoặc copy library vào system path
|
||||
sudo cp libnav_c_api.so /usr/local/lib/
|
||||
sudo ldconfig
|
||||
```
|
||||
|
||||
### Lỗi: "DllNotFoundException"
|
||||
|
||||
**Giải pháp:**
|
||||
- Kiểm tra tên file library có đúng không
|
||||
- Kiểm tra architecture (x64 vs x86)
|
||||
- Kiểm tra dependencies: `ldd libnav_c_api.so`
|
||||
|
||||
### Lỗi: "Symbol not found"
|
||||
|
||||
**Giải pháp:**
|
||||
- Đảm bảo library đã được build đầy đủ
|
||||
- Kiểm tra tên hàm trong C# có khớp với C API không
|
||||
|
||||
83
examples/START_HERE.md
Normal file
83
examples/START_HERE.md
Normal file
@@ -0,0 +1,83 @@
|
||||
# 🚀 Hướng dẫn chạy thử C API Navigation
|
||||
|
||||
## Cách nhanh nhất (1 lệnh)
|
||||
|
||||
```bash
|
||||
cd /home/robotics/AGV/Diff_Wheel_Prj/pnkx_nav_core/examples
|
||||
chmod +x run_example.sh
|
||||
./run_example.sh
|
||||
```
|
||||
|
||||
## Chi tiết các bước
|
||||
|
||||
### Bước 1: Build C API Library
|
||||
|
||||
```bash
|
||||
cd /home/robotics/AGV/Diff_Wheel_Prj/pnkx_nav_core/build
|
||||
cmake ..
|
||||
make nav_c_api
|
||||
```
|
||||
|
||||
Library sẽ được tạo tại: `build/src/APIs/c_api/libnav_c_api.so`
|
||||
|
||||
### Bước 2: Chạy C# Example
|
||||
|
||||
Script `run_example.sh` sẽ tự động:
|
||||
- ✅ Kiểm tra và build library nếu cần
|
||||
- ✅ Tạo C# project
|
||||
- ✅ Copy library và source code
|
||||
- ✅ Set LD_LIBRARY_PATH cho tất cả dependencies
|
||||
- ✅ Build và chạy example
|
||||
|
||||
```bash
|
||||
cd /home/robotics/AGV/Diff_Wheel_Prj/pnkx_nav_core/examples
|
||||
./run_example.sh
|
||||
```
|
||||
|
||||
## Kết quả mong đợi
|
||||
|
||||
Nếu chạy thành công, bạn sẽ thấy:
|
||||
|
||||
```
|
||||
==========================================
|
||||
Building and Running C# Navigation Example
|
||||
==========================================
|
||||
Library already exists: .../build/src/APIs/c_api/libnav_c_api.so
|
||||
C# project already exists
|
||||
Copying library...
|
||||
Building C# project...
|
||||
|
||||
Running example...
|
||||
==========================================
|
||||
Robot pose: x=0, y=0, theta=0
|
||||
State: PENDING, Feedback:
|
||||
==========================================
|
||||
Done!
|
||||
```
|
||||
|
||||
## Yêu cầu
|
||||
|
||||
1. **.NET SDK 6.0+** (script sẽ kiểm tra và hướng dẫn nếu thiếu)
|
||||
2. **Library đã được build** (script sẽ tự động build nếu thiếu)
|
||||
3. **Linux environment**
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Lỗi: "dotnet: command not found"
|
||||
→ Script sẽ hiển thị hướng dẫn cài đặt .NET SDK
|
||||
|
||||
### Lỗi: "Failed to create navigation instance"
|
||||
→ Đảm bảo `move_base` đã được build:
|
||||
```bash
|
||||
cd build && make move_base
|
||||
```
|
||||
|
||||
### Lỗi: "Cannot load library"
|
||||
→ Kiểm tra LD_LIBRARY_PATH đã được set đúng (script tự động set)
|
||||
|
||||
## Xem thêm
|
||||
|
||||
- `README.md` - Hướng dẫn chi tiết
|
||||
- `QUICK_START.md` - Quick start guide
|
||||
- `run_example.sh` - Script tự động
|
||||
|
||||
1887
examples/dotnet-install.sh
vendored
Executable file
1887
examples/dotnet-install.sh
vendored
Executable file
File diff suppressed because it is too large
Load Diff
123
examples/run_example.sh
Executable file
123
examples/run_example.sh
Executable file
@@ -0,0 +1,123 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Script để build và chạy C# example
|
||||
|
||||
set -e
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
||||
BUILD_DIR="$PROJECT_ROOT/build"
|
||||
LIB_DIR="$BUILD_DIR"
|
||||
EXAMPLE_DIR="$SCRIPT_DIR"
|
||||
|
||||
echo "=========================================="
|
||||
echo "Building and Running C# Navigation Example"
|
||||
echo "=========================================="
|
||||
echo ""
|
||||
echo "📁 Paths:"
|
||||
echo " SCRIPT_DIR: $SCRIPT_DIR"
|
||||
echo " PROJECT_ROOT: $PROJECT_ROOT"
|
||||
echo " BUILD_DIR: $BUILD_DIR"
|
||||
echo " LIB_DIR: $LIB_DIR"
|
||||
echo " EXAMPLE_DIR: $EXAMPLE_DIR"
|
||||
echo ""
|
||||
|
||||
|
||||
echo "Building C API library..."
|
||||
cd "$BUILD_DIR"
|
||||
cmake ..
|
||||
make
|
||||
sudo make install
|
||||
echo "Library built successfully!"
|
||||
|
||||
|
||||
# Kiểm tra dotnet có được cài đặt không
|
||||
if ! command -v dotnet &> /dev/null; then
|
||||
echo "=========================================="
|
||||
echo "WARNING: .NET SDK not found!"
|
||||
echo "=========================================="
|
||||
echo "To run the C# example, please install .NET SDK:"
|
||||
echo ""
|
||||
echo " Ubuntu/Debian:"
|
||||
echo " wget https://dot.net/v1/dotnet-install.sh -O dotnet-install.sh"
|
||||
echo " chmod +x dotnet-install.sh"
|
||||
echo " ./dotnet-install.sh --channel 6.0"
|
||||
echo " export PATH=\$PATH:\$HOME/.dotnet"
|
||||
echo ""
|
||||
echo " Or visit: https://dotnet.microsoft.com/download"
|
||||
echo ""
|
||||
echo "Skipping C# example. Library is available at:"
|
||||
echo " $LIB_DIR/libnav_c_api.so"
|
||||
echo "=========================================="
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Bước 2: Tạo C# project nếu chưa có
|
||||
if [ ! -d "$EXAMPLE_DIR/NavigationExample" ]; then
|
||||
echo "Creating C# project..."
|
||||
cd "$EXAMPLE_DIR"
|
||||
dotnet new console -n NavigationExample
|
||||
cd NavigationExample
|
||||
|
||||
# Tạo .csproj file
|
||||
cat > NavigationExample.csproj << 'EOF'
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<RuntimeIdentifier>linux-x64</RuntimeIdentifier>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<None Include="libnav_c_api.so">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
EOF
|
||||
|
||||
echo "C# project created!"
|
||||
else
|
||||
echo "C# project already exists"
|
||||
fi
|
||||
|
||||
# Luôn copy source code mới nhất (cập nhật file nếu đã có)
|
||||
cd "$EXAMPLE_DIR/NavigationExample"
|
||||
|
||||
# # Bước 3: Copy library
|
||||
# echo "Copying library..."
|
||||
# cp "$LIB_DIR/libnav_c_api.so" .
|
||||
|
||||
# Bước 4: Set LD_LIBRARY_PATH để tìm được tất cả dependencies
|
||||
# Main build directory (contains libtf3.so, librobot_cpp.so, etc.)
|
||||
export LD_LIBRARY_PATH="$BUILD_DIR:$LD_LIBRARY_PATH"
|
||||
# Library directories for dependencies
|
||||
export LD_LIBRARY_PATH="$BUILD_DIR/src/Libraries/robot_time:$LD_LIBRARY_PATH"
|
||||
export LD_LIBRARY_PATH="$BUILD_DIR/src/Libraries/xmlrpcpp:$LD_LIBRARY_PATH"
|
||||
export LD_LIBRARY_PATH="$BUILD_DIR/src/Libraries/robot_costmap_2d:$LD_LIBRARY_PATH"
|
||||
export LD_LIBRARY_PATH="$BUILD_DIR/src/Libraries/geometry2/robot_tf3_geometry_msgs:$LD_LIBRARY_PATH"
|
||||
export LD_LIBRARY_PATH="$BUILD_DIR/src/Libraries/geometry2/robot_tf3_sensor_msgs:$LD_LIBRARY_PATH"
|
||||
export LD_LIBRARY_PATH="$BUILD_DIR/src/Navigations/Packages/move_base:$LD_LIBRARY_PATH"
|
||||
export LD_LIBRARY_PATH="$BUILD_DIR/src/Navigations/Cores/move_base_core:$LD_LIBRARY_PATH"
|
||||
export LD_LIBRARY_PATH="$BUILD_DIR/src/Navigations/Libraries/tf3:$LD_LIBRARY_PATH"
|
||||
# Also add the example directory where the library is copied
|
||||
export LD_LIBRARY_PATH="$EXAMPLE_DIR/NavigationExample:$LD_LIBRARY_PATH"
|
||||
# Add the output directory where .NET places the library
|
||||
export LD_LIBRARY_PATH="$EXAMPLE_DIR/NavigationExample/bin/Debug/net6.0/linux-x64:$LD_LIBRARY_PATH"
|
||||
|
||||
# Bước 5: Build và chạy
|
||||
echo "Building C# project..."
|
||||
dotnet build
|
||||
|
||||
echo ""
|
||||
echo "Running example..."
|
||||
echo "=========================================="
|
||||
echo "LD_LIBRARY_PATH includes:"
|
||||
echo "$LD_LIBRARY_PATH" | tr ':' '\n' | head -5
|
||||
echo "..."
|
||||
echo "=========================================="
|
||||
dotnet run
|
||||
|
||||
echo "=========================================="
|
||||
echo "Done!"
|
||||
|
||||
29
pnkx_nav_core.sln
Normal file
29
pnkx_nav_core.sln
Normal file
@@ -0,0 +1,29 @@
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.5.2.0
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "examples", "examples", "{B36A84DF-456D-A817-6EDD-3EC3E7F6E11F}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NavigationExample", "examples\NavigationExample\NavigationExample.csproj", "{995839D6-1E72-F444-6587-97EF24F93814}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{995839D6-1E72-F444-6587-97EF24F93814}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{995839D6-1E72-F444-6587-97EF24F93814}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{995839D6-1E72-F444-6587-97EF24F93814}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{995839D6-1E72-F444-6587-97EF24F93814}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(NestedProjects) = preSolution
|
||||
{995839D6-1E72-F444-6587-97EF24F93814} = {B36A84DF-456D-A817-6EDD-3EC3E7F6E11F}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {1A56EED1-5E6A-48A6-9AEE-F39361B34305}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
0
robotapp.db
Normal file
0
robotapp.db
Normal file
116
setup_catkin_workspace.sh
Executable file
116
setup_catkin_workspace.sh
Executable file
@@ -0,0 +1,116 @@
|
||||
#!/bin/bash
|
||||
# ========================================================
|
||||
# Script to setup Catkin workspace for pnkx_nav_core
|
||||
# ========================================================
|
||||
|
||||
set -e
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
WORKSPACE_NAME="pnkx_nav_catkin_ws"
|
||||
WORKSPACE_DIR="${SCRIPT_DIR}/../${WORKSPACE_NAME}"
|
||||
|
||||
echo "=========================================="
|
||||
echo "Setting up Catkin workspace for pnkx_nav_core"
|
||||
echo "=========================================="
|
||||
echo ""
|
||||
|
||||
# Create workspace directory
|
||||
echo "Creating workspace directory: ${WORKSPACE_DIR}"
|
||||
mkdir -p "${WORKSPACE_DIR}/src"
|
||||
|
||||
# Check if src directory already has packages
|
||||
if [ -d "${WORKSPACE_DIR}/src" ] && [ "$(ls -A ${WORKSPACE_DIR}/src 2>/dev/null)" ]; then
|
||||
echo "Warning: ${WORKSPACE_DIR}/src already contains packages"
|
||||
read -p "Do you want to continue? (y/n) " -n 1 -r
|
||||
echo
|
||||
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
||||
echo "Aborted."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Create symlinks to packages that have package.xml
|
||||
echo ""
|
||||
echo "Creating symlinks to packages with package.xml..."
|
||||
|
||||
# Find all packages with package.xml in the source tree
|
||||
PACKAGES=(
|
||||
"src/Libraries/tf3"
|
||||
"src/Libraries/robot_nav_2d_utils"
|
||||
"src/Navigations/Libraries/nav_grid"
|
||||
"src/Navigations/Cores/nav_core"
|
||||
"src/Navigations/Cores/nav_core2"
|
||||
"src/Navigations/Cores/nav_core_adapter"
|
||||
"src/Navigations/Cores/move_base_core"
|
||||
"src/Navigations/Cores/nav_core_adapter"
|
||||
"src/Packages/move_base"
|
||||
"src/Navigations/Packages/move_base"
|
||||
)
|
||||
|
||||
for PKG_PATH in "${PACKAGES[@]}"; do
|
||||
FULL_PATH="${SCRIPT_DIR}/${PKG_PATH}"
|
||||
if [ -f "${FULL_PATH}/package.xml" ]; then
|
||||
PKG_NAME=$(basename "${PKG_PATH}")
|
||||
TARGET="${WORKSPACE_DIR}/src/${PKG_NAME}"
|
||||
|
||||
if [ -e "${TARGET}" ]; then
|
||||
echo " Warning: ${TARGET} already exists, skipping..."
|
||||
else
|
||||
echo " Linking: ${PKG_NAME} -> ${PKG_PATH}"
|
||||
ln -s "${FULL_PATH}" "${TARGET}"
|
||||
fi
|
||||
else
|
||||
echo " Warning: ${PKG_PATH}/package.xml not found, skipping..."
|
||||
fi
|
||||
done
|
||||
|
||||
# Create a README in the workspace
|
||||
cat > "${WORKSPACE_DIR}/README.md" << EOF
|
||||
# Catkin Workspace for pnkx_nav_core
|
||||
|
||||
This is a Catkin workspace containing ROS-compatible packages from pnkx_nav_core.
|
||||
|
||||
## Structure
|
||||
|
||||
\`\`\`
|
||||
${WORKSPACE_NAME}/
|
||||
├── src/ # Source packages (symlinked from pnkx_nav_core)
|
||||
└── build/ # Build directory (created by catkin_make)
|
||||
\`\`\`
|
||||
|
||||
## Building
|
||||
|
||||
\`\`\`bash
|
||||
cd ${WORKSPACE_DIR}
|
||||
catkin_make
|
||||
\`\`\`
|
||||
|
||||
## Source the workspace
|
||||
|
||||
After building, source the setup file:
|
||||
|
||||
\`\`\`bash
|
||||
source devel/setup.bash
|
||||
\`\`\`
|
||||
|
||||
## Note
|
||||
|
||||
Packages in \`src/\` are symlinked from the main pnkx_nav_core project.
|
||||
To add more packages, create symlinks in \`src/\` pointing to packages
|
||||
that have both \`CMakeLists.txt\` and \`package.xml\`.
|
||||
EOF
|
||||
|
||||
echo ""
|
||||
echo "=========================================="
|
||||
echo "Workspace setup complete!"
|
||||
echo "=========================================="
|
||||
echo ""
|
||||
echo "Next steps:"
|
||||
echo " 1. cd ${WORKSPACE_DIR}"
|
||||
echo " 2. catkin_make"
|
||||
echo " 3. source devel/setup.bash"
|
||||
echo ""
|
||||
echo "Note: Make sure all dependencies are built in the main project first"
|
||||
echo " using standalone CMake before building with catkin."
|
||||
echo ""
|
||||
|
||||
161
src/APIs/c_api/CMakeLists.txt
Normal file
161
src/APIs/c_api/CMakeLists.txt
Normal file
@@ -0,0 +1,161 @@
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
project(nav_c_api VERSION 1.0.0 LANGUAGES CXX)
|
||||
|
||||
# Chuẩn C++
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE Release)
|
||||
endif()
|
||||
|
||||
# Find Boost (filesystem needed for plugin path / boost::dll usage)
|
||||
find_package(Boost REQUIRED COMPONENTS filesystem system)
|
||||
|
||||
# Dependencies (robot_nav_2d_utils_conversions provides poseStampedToPose2D used by move_base_core/navigation.h)
|
||||
set(PACKAGES_DIR
|
||||
move_base_core
|
||||
robot_nav_2d_utils
|
||||
tf3
|
||||
robot_time
|
||||
robot_cpp
|
||||
geometry_msgs
|
||||
angles
|
||||
data_convert
|
||||
robot_protocol_msgs
|
||||
)
|
||||
|
||||
# Thư mục include
|
||||
include_directories(
|
||||
${PROJECT_SOURCE_DIR}/include
|
||||
)
|
||||
|
||||
# Tìm tất cả file source
|
||||
file(GLOB SOURCES
|
||||
"src/*.cpp"
|
||||
"src/std_msgs/*.cpp"
|
||||
"src/sensor_msgs/*.cpp"
|
||||
"src/geometry_msgs/*.cpp"
|
||||
"src/nav_msgs/*.cpp"
|
||||
"src/nav_2d_msgs/*.cpp"
|
||||
"src/robot_nav_msgs/*.cpp"
|
||||
"src/robot_geometry_msgs/*.cpp"
|
||||
"src/map_msgs/*.cpp"
|
||||
)
|
||||
file(GLOB HEADERS
|
||||
"include/*.h"
|
||||
"include/std_msgs/*.h"
|
||||
"include/sensor_msgs/*.h"
|
||||
"include/geometry_msgs/*.h"
|
||||
"include/nav_msgs/*.h"
|
||||
"include/nav_2d_msgs/*.h"
|
||||
"include/robot_nav_msgs/*.h"
|
||||
"include/robot_geometry_msgs/*.h"
|
||||
"include/map_msgs/*.h"
|
||||
)
|
||||
|
||||
# Tạo thư viện shared (.so)
|
||||
add_library(nav_c_api SHARED ${SOURCES} ${HEADERS})
|
||||
|
||||
# Link libraries
|
||||
target_link_libraries(nav_c_api
|
||||
PUBLIC
|
||||
${PACKAGES_DIR}
|
||||
PRIVATE
|
||||
Boost::boost
|
||||
Boost::filesystem
|
||||
Boost::system
|
||||
dl
|
||||
)
|
||||
|
||||
set_target_properties(nav_c_api PROPERTIES
|
||||
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
BUILD_RPATH "${CMAKE_BINARY_DIR}"
|
||||
INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib"
|
||||
)
|
||||
|
||||
# Set include directories
|
||||
target_include_directories(nav_c_api
|
||||
PUBLIC
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||
$<INSTALL_INTERFACE:include>
|
||||
)
|
||||
|
||||
# Cài đặt header files
|
||||
install(DIRECTORY include/
|
||||
DESTINATION include
|
||||
FILES_MATCHING PATTERN "*.h"
|
||||
)
|
||||
|
||||
# Cài đặt library
|
||||
install(TARGETS nav_c_api
|
||||
EXPORT nav_c_api-targets
|
||||
LIBRARY DESTINATION lib
|
||||
ARCHIVE DESTINATION lib
|
||||
RUNTIME DESTINATION bin
|
||||
)
|
||||
|
||||
# Export targets
|
||||
install(EXPORT nav_c_api-targets
|
||||
FILE nav_c_api-targets.cmake
|
||||
DESTINATION lib/cmake/nav_c_api
|
||||
)
|
||||
|
||||
# Tùy chọn build
|
||||
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
|
||||
option(BUILD_TESTS "Build test programs" OFF)
|
||||
|
||||
# Test cho lớp chuyển đổi. Không cần dựng navigation thật: mọi thứ ở đây là chuyển đổi thuần và
|
||||
# quản lý bộ nhớ, đúng chỗ tập trung rủi ro của gói này.
|
||||
#
|
||||
# Bật bằng: cmake -DBUILD_C_API_TESTS=ON, rồi chạy ./devel/lib/nav_c_api/test_convertor
|
||||
option(BUILD_C_API_TESTS "Build the C API converter tests" OFF)
|
||||
|
||||
if(BUILD_C_API_TESTS OR BUILD_TESTS)
|
||||
find_package(GTest QUIET)
|
||||
if(GTest_FOUND OR GTEST_FOUND)
|
||||
add_executable(test_convertor test/test_convertor.cpp)
|
||||
|
||||
target_link_libraries(test_convertor
|
||||
PRIVATE
|
||||
nav_c_api
|
||||
${GTEST_BOTH_LIBRARIES}
|
||||
pthread
|
||||
)
|
||||
|
||||
target_include_directories(test_convertor
|
||||
PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include
|
||||
${GTEST_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
# Test phải build với cảnh báo bật: -w của thư viện che đúng nhóm lỗi mà test này đi tìm.
|
||||
target_compile_options(test_convertor PRIVATE -Wall -Wextra)
|
||||
|
||||
set_target_properties(test_convertor PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
)
|
||||
|
||||
enable_testing()
|
||||
add_test(NAME test_convertor COMMAND test_convertor)
|
||||
message(STATUS "nav_c_api: converter tests enabled")
|
||||
else()
|
||||
message(WARNING "nav_c_api: GTest not found, converter tests skipped")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Flags biên dịch
|
||||
# Warning flags - disabled to suppress warnings during build
|
||||
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w") # -w suppresses all warnings
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
|
||||
|
||||
# In thông tin cấu hình
|
||||
message(STATUS "=================================")
|
||||
message(STATUS "Project: ${PROJECT_NAME}")
|
||||
message(STATUS "Version: ${PROJECT_VERSION}")
|
||||
message(STATUS "C++ Standard: ${CMAKE_CXX_STANDARD}")
|
||||
message(STATUS "=================================")
|
||||
|
||||
500
src/APIs/c_api/C_API_AUDIT.md
Normal file
500
src/APIs/c_api/C_API_AUDIT.md
Normal file
@@ -0,0 +1,500 @@
|
||||
# Rà soát gói `c_api` — những chỗ chưa hoàn thiện
|
||||
|
||||
Phạm vi: `pnkx_nav_core/src/APIs/c_api`. Đọc toàn bộ `src/nav_c_api.cpp` (1396 dòng),
|
||||
`src/convertor.cpp` (831), `src/std_msgs/Header.cpp`, `src/std_msgs/Time.cpp`, đối chiếu với
|
||||
`include/nav_c_api.h` và với `Test/move_base2` ở phía sau.
|
||||
|
||||
Ràng buộc: **không đổi chữ ký hàm, không đổi chức năng chính**.
|
||||
|
||||
Ngày rà soát: 2026-08-08. **Đã sửa cùng ngày** — xem cột trạng thái ở mỗi mục và mục "Đã làm gì"
|
||||
ở cuối. Một điểm nữa (**F25**) lộ ra trong lúc sửa, do chính bộ test mới bắt được.
|
||||
|
||||
---
|
||||
|
||||
## Tóm tắt
|
||||
|
||||
24 điểm, chia bốn mức. Ba điểm P0 là lỗi hành vi thật, không phải chuyện style:
|
||||
|
||||
| Mức | Số điểm | Bản chất |
|
||||
|---|---|---|
|
||||
| **P0** | 3 | Sai hành vi hoặc UB — ảnh hưởng trực tiếp tới robot |
|
||||
| **P1** | 3 | Hợp đồng lỏng: host không phân biệt được lỗi với dữ liệu rỗng |
|
||||
| **P2** | 6 | Rác debug, log sai cấp, format sai |
|
||||
| **P3** | 5 | Khai báo và tài liệu lệch với hiện thực |
|
||||
| **P4** | 7 | Nhỏ, nhất quán, hạ tầng |
|
||||
|
||||
Trong 24 điểm, **20 điểm sửa được mà không đụng chữ ký lẫn chức năng chính**. Bốn điểm còn lại
|
||||
(F4, F5, F6 một phần, và phần capacity của F5) buộc phải hoặc đổi hợp đồng trả về, hoặc thêm hàm mới
|
||||
song song — ghi rõ ở mục cuối.
|
||||
|
||||
---
|
||||
|
||||
## P0 — sai hành vi thật
|
||||
|
||||
### F1. `navigation_set_twist_linear` bỏ qua tham số `linear_x`
|
||||
|
||||
**Vị trí:** `src/nav_c_api.cpp:574-584`
|
||||
|
||||
```cpp
|
||||
robot_geometry_msgs::Vector3 linear;
|
||||
linear.x = 0.1; // <-- linear_x KHÔNG hề được dùng
|
||||
linear.y = linear_y;
|
||||
linear.z = linear_z;
|
||||
bool result = nav_ptr->setTwistLinear(linear);
|
||||
robot::log_info("setTwistLinear Forward %f", linear.x);
|
||||
|
||||
linear.x = -0.1; // <-- cũng hard-code
|
||||
result &= result && nav_ptr->setTwistLinear(linear);
|
||||
robot::log_info("setTwistLinear Backward %f", linear.x);
|
||||
return result;
|
||||
```
|
||||
|
||||
**Vấn đề.** Tham số `linear_x` của hàm không bao giờ được đọc. Trần vận tốc gửi xuống lõi luôn là
|
||||
`+0.1 m/s` cho chiều tiến và `-0.1 m/s` cho chiều lùi, bất kể host truyền giá trị nào. Hai tham số
|
||||
`linear_y` và `linear_z` thì lại được truyền đúng — đây là dấu hiệu code viết dở rồi bỏ quên, không
|
||||
phải quyết định thiết kế.
|
||||
|
||||
**Ảnh hưởng lên hành vi robot.** Hai chiều, đều xấu:
|
||||
|
||||
1. Đường hạ tốc của tầng an toàn không tới được lõi. Host tính ra "chỉ được chạy 0.3 m/s vì đang vào
|
||||
vùng hẹp" rồi gọi hàm này — lõi nhận 0.1 m/s. Ngược lại host muốn nâng lên 1.0 m/s cũng chỉ nhận
|
||||
được 0.1.
|
||||
2. Ngay khi host gọi hàm này lần đầu, robot bị khoá ở 0.1 m/s cho tới hết phiên chạy. Nếu host chỉ
|
||||
gọi khi cần giảm tốc thì robot sẽ không bao giờ về lại tốc độ bình thường.
|
||||
|
||||
**Lỗi thứ hai trong cùng hàm.** `result &= result && nav_ptr->setTwistLinear(linear)` — toán tử `&&`
|
||||
short-circuit: nếu lời gọi đầu trả `false` thì lời gọi thứ hai **không chạy**, nên trần chiều lùi
|
||||
không được đặt. Ý định rõ ràng là gọi cả hai rồi AND kết quả lại.
|
||||
|
||||
**Đã sửa.** Hợp đồng đúng: giá trị đi xuống lõi **nguyên dạng, giữ dấu**. Dấu của `linear_x` là thứ
|
||||
chọn chiều mà trần áp vào — âm đặt trần lùi, dương đặt trần tiến; local planner giữ hai trần riêng
|
||||
(`navigation_server.cpp:921-944`). Lấy trị tuyệt đối là vứt bỏ nửa thông tin của lời gọi.
|
||||
|
||||
Một lời gọi vì thế đặt **một** chiều. Host muốn chặn cả hai thì gọi hai lần — đúng như host ROS đang
|
||||
làm (`amr_control.cpp:707-709`, `amr_vda_5050_client_api.cpp:410-414`).
|
||||
|
||||
```c
|
||||
navigation_set_twist_linear(h, 0.6, 0.0, 0.0); // tiến <= 0.6 m/s
|
||||
navigation_set_twist_linear(h, -0.3, 0.0, 0.0); // lùi <= 0.3 m/s
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### F2. Gán `char*` có thể NULL vào `std::string`
|
||||
|
||||
**Vị trí:** `src/convertor.cpp:13` (LaserScan), `:44` (OccupancyGrid), `:115` (PoseStamped)
|
||||
|
||||
```cpp
|
||||
robot_laser_scan.header.frame_id = laser_scan.header.frame_id; // char* có thể NULL
|
||||
```
|
||||
|
||||
**Vấn đề.** Dựng `std::string` từ con trỏ NULL là hành vi không xác định — thực tế là segfault trong
|
||||
`strlen`. Các converter khác trong **chính file này** đều đã guard:
|
||||
|
||||
| Đã guard | Chưa guard |
|
||||
|---|---|
|
||||
| `convert2CppOdometry:73,75` | `convert2CppLaserScan:13` |
|
||||
| `convert2CppPointCloud:383` | `convert2CppOccupancyGrid:44` |
|
||||
| `convert2CppPointCloud2:408` | `convert2CppPoseStamped:115` |
|
||||
| `convert2CppOrder:731-745` | |
|
||||
| `convert2CppNode`, `convert2CppEdge`, `convert2CppAction`, `convert2CppNodePosition` | |
|
||||
|
||||
Nghĩa là quy ước "guard NULL" đã có sẵn và được áp dụng ở 7 chỗ; ba chỗ này bị bỏ sót.
|
||||
|
||||
**Ảnh hưởng.** `frame_id = NULL` hoàn toàn hợp lệ trong C, và **chính thư viện này sinh ra NULL**:
|
||||
`convert2COccupancyGrid:181` viết `frame_id.empty() ? nullptr : strdup(...)`. Nên vòng
|
||||
`navigation_get_static_map()` rồi `navigation_add_static_map()` — hoặc bất kỳ đường round-trip nào
|
||||
qua một message có `frame_id` rỗng — là segfault chắc chắn.
|
||||
|
||||
**Hướng sửa.** Thêm `? :` đúng như 7 chỗ còn lại. Không đụng chữ ký, không đổi chức năng.
|
||||
|
||||
---
|
||||
|
||||
### F3. `strdup(frame_id)` không kiểm NULL
|
||||
|
||||
**Vị trí:** `src/std_msgs/Header.cpp:8` (`header_create`) và `:18` (`header_set_data`)
|
||||
|
||||
```cpp
|
||||
extern "C" Header header_create(const char *frame_id) {
|
||||
Header header{};
|
||||
header.frame_id = strdup(frame_id); // NULL -> segfault
|
||||
```
|
||||
|
||||
**Vấn đề.** `strdup(NULL)` là UB. Hai hàm này nằm trong bề mặt công khai và C# gọi trực tiếp
|
||||
(`NavigationAPI.cs:69,72`).
|
||||
|
||||
**Hướng sửa.** `frame_id ? strdup(frame_id) : nullptr`.
|
||||
|
||||
---
|
||||
|
||||
## P1 — hợp đồng lỏng, host không phân biệt được lỗi
|
||||
|
||||
### F4. Bốn getter sensor luôn trả `true` kể cả khi tên không tồn tại
|
||||
|
||||
**Vị trí:** `src/nav_c_api.cpp:858` (`get_static_map`), `:882` (`get_laser_scan`), `:906`
|
||||
(`get_point_cloud`), `:930` (`get_point_cloud2`)
|
||||
|
||||
**Vấn đề.** `move_base2::NavigationServer::getStaticMap` dùng `lookupOrDefault`
|
||||
(`navigation_server.cpp:607-611`): tên không có trong map thì trả về object mặc định, không báo lỗi.
|
||||
`c_api` chuyển thẳng object rỗng đó ra rồi `return true`.
|
||||
|
||||
**Ảnh hưởng.** Host nhận `OccupancyGrid` với `width = 0`, `data = NULL` và một giá trị trả về `true`.
|
||||
Không có cách nào phân biệt "bản đồ tồn tại nhưng rỗng" với "gõ sai tên bản đồ". Sai tên là lỗi cấu
|
||||
hình phổ biến nhất ở đường sensor (tên phải khớp `topic` trong YAML costmap) — mà nó lại đúng là
|
||||
trường hợp API im lặng nhất.
|
||||
|
||||
**Hướng sửa.** Không sửa được nếu giữ nguyên chữ ký lẫn ngữ nghĩa: contract `BaseNavigation` không có
|
||||
đường báo "không tìm thấy". Ba lựa chọn, đều nằm ngoài ràng buộc đợt này:
|
||||
(a) tài liệu hoá rõ trong header rằng `true` không có nghĩa là tìm thấy;
|
||||
(b) đổi quy ước: trả `false` khi kết quả rỗng — **đổi hành vi**, có thể vỡ host đang chạy;
|
||||
(c) thêm hàm `navigation_has_static_map(handle, name)` bên `nav_c_api_2` để hỏi trước.
|
||||
|
||||
Khuyến nghị: (a) ngay, (c) khi có dịp.
|
||||
|
||||
---
|
||||
|
||||
### F5. Bốn hàm `get_all_*` và `get_robot_footprint` ghi vào mảng caller mà không biết dung lượng
|
||||
|
||||
**Vị trí:** `src/nav_c_api.cpp:954`, `:985`, `:1021`, `:1057`, và `:203`
|
||||
(`navigation_get_robot_footprint`)
|
||||
|
||||
```cpp
|
||||
auto maps = nav_ptr->getAllStaticMaps();
|
||||
out_count = maps.size();
|
||||
size_t i = 0;
|
||||
for (const auto &p : maps)
|
||||
{
|
||||
out_maps[i].name = strdup(p.first.c_str()); // ghi mù, không biết mảng dài bao nhiêu
|
||||
convert2COccupancyGrid(p.second, out_maps[i].grid);
|
||||
++i;
|
||||
}
|
||||
```
|
||||
|
||||
**Vấn đề.** Chữ ký chỉ có con trỏ ra và `size_t &out_count` (là tham số **ra**, không phải vào). Hàm
|
||||
không có cách nào biết mảng host cấp đủ chỗ hay không, và ghi đúng bằng số phần tử nó có.
|
||||
|
||||
**Ảnh hưởng.** Host cấp mảng 4 phần tử, lõi đang giữ 6 point cloud → ghi tràn 2 phần tử. Với
|
||||
`NamedOccupancyGrid` mỗi phần tử là một struct lớn, nên tràn không phải một byte mà hàng chục byte
|
||||
ra ngoài vùng — hỏng stack hoặc heap của host, và triệu chứng sẽ hiện ra ở chỗ hoàn toàn khác.
|
||||
|
||||
**Hướng sửa.** Không sửa được mà giữ chữ ký. Hai lựa chọn:
|
||||
(a) ghi cảnh báo trong header, nói rõ host phải cấp dư và bao nhiêu là đủ;
|
||||
(b) thêm biến thể có `size_t capacity` bên `nav_c_api_2`, giữ nguyên hàm cũ.
|
||||
|
||||
---
|
||||
|
||||
### F6. `navigation_initialize` luôn trả `true`
|
||||
|
||||
**Vị trí:** `src/nav_c_api.cpp:127`
|
||||
|
||||
**Vấn đề.** `BaseNavigation::initialize()` trả `void`, nên `c_api` `return true` ngay sau khi gọi.
|
||||
`move_base2` có năm đường thất bại trong `initialize()` (dựng costmap, cấu hình sensor, nạp plugin,
|
||||
cấu hình control loop, start control thread — `navigation_server.cpp:340-479`), mỗi đường chỉ đặt
|
||||
`nav_feedback_->is_ready = false` kèm lý do rồi return bình thường.
|
||||
|
||||
**Ảnh hưởng.** Host tưởng lõi đã sẵn sàng, gửi goal vào một lõi không có control thread. Goal nằm im
|
||||
vĩnh viễn: không cycle nào chạy, không state nào đổi, **không log gì**.
|
||||
|
||||
**Hướng sửa.** Đã có sẵn: `navigation_initialize_checked()` trong `nav_c_api_2` làm đúng việc này mà
|
||||
không đụng hàm cũ. Còn lại là chuyện host đổi sang gọi hàm mới.
|
||||
|
||||
---
|
||||
|
||||
## P2 — rác debug, log sai cấp, format sai
|
||||
|
||||
| # | Vị trí | Vấn đề | Ảnh hưởng |
|
||||
|---|---|---|---|
|
||||
| **F7** | `convertor.cpp:36-39` | `log_info` in `sizeof(OccupancyGrid)`, `offsetof(data)`, `offsetof(data_count)` **mỗi lần** convert map | Leftover của một lần dò lệch ABI. Chạy trên mọi `add_static_map` |
|
||||
| **F8** | `nav_c_api.cpp:190` | `printf("footprint x: %f, y: %f")` **trong vòng lặp từng điểm** | Footprint 8 điểm = 8 dòng mỗi lần đặt footprint |
|
||||
| **F9** | `nav_c_api.cpp:284, 319` (call site `move_straight_to` đã bị xoá cùng hàm) | `log_error` dùng để in giá trị bình thường: goal của `move_to_order`, goal của `move_to_nodes_edges` | Sai cấp log. Ai lọc log theo mức ERROR sẽ thấy toàn dữ liệu bình thường, lỗi thật bị chìm |
|
||||
| **F10** | `nav_c_api.cpp:86` | `log_warning("%s", path_file_so.c_str())` in đường dẫn `.so` mỗi lần `navigation_create` | Sai cấp; nên là `log_info` hoặc `log_debug` |
|
||||
| **F11** | `nav_c_api.cpp:748` | `log_info("occupancy_grid.data_count: %d", occupancy_grid.data_count)` — `%d` cho `size_t` | Format không khớp kiểu: UB, in ra số sai trên 64-bit. Bị `-w` che nên không có warning |
|
||||
| **F12** | 9 chỗ trong `nav_c_api.cpp` | `printf` trộn lẫn với `robot::log_*` | Hai hệ log song song. `printf` đi thẳng stdout, không vào file log, không có timestamp, không lọc theo mức được |
|
||||
|
||||
Tất cả P2 sửa được mà không đụng chữ ký lẫn chức năng.
|
||||
|
||||
---
|
||||
|
||||
## P3 — khai báo và tài liệu lệch với hiện thực
|
||||
|
||||
### F13. Ba symbol export nhưng không khai báo trong header
|
||||
|
||||
`navigation_state_to_string` (`nav_c_api.cpp:38`), `navigation_offset_goal_2d` (`:51`),
|
||||
`navigation_offset_goal_stamped` (`:66`).
|
||||
|
||||
Binding theo tên symbol (P/Invoke) vẫn gọi được, nhưng bên gọi C/C++ include `nav_c_api.h` thì không
|
||||
thấy. `NavigationAPI.cs:87` đang khai báo tay `navigation_state_to_string` — đúng, nhưng là đoán.
|
||||
|
||||
### F14. Header nhắc tới một hàm không tồn tại
|
||||
|
||||
`include/nav_c_api.h:119`:
|
||||
|
||||
> `@param out_points Output array of points (allocated by library, free with navigation_free_points)`
|
||||
|
||||
`navigation_free_points` **không tồn tại ở đâu cả** — không khai báo, không hiện thực, không export.
|
||||
Ngoài ra câu này còn sai thêm một tầng: `out_points` **không** do thư viện cấp phát, nó là mảng của
|
||||
caller (xem F5).
|
||||
|
||||
### F15. Doc của `navigation_rotate_to` mô tả một chữ ký khác
|
||||
|
||||
> **Không còn áp dụng, 2026-08-10.** `navigation_rotate_to` đã bị **xoá khỏi API** cùng nhóm
|
||||
> `navigation_dock_to*` và `navigation_move_straight_to` — chúng đi thẳng xuống lõi, bỏ qua mission
|
||||
> layer. Binding C# sai chữ ký nói ở đây vì thế cũng đã được gỡ. Giữ lại mục này làm ghi chép: bug
|
||||
> gốc là **binding đọc doc thay vì đọc chữ ký**, và rủi ro đó không mất đi cùng hàm.
|
||||
|
||||
`include/nav_c_api.h:196-202`:
|
||||
|
||||
```c
|
||||
/**
|
||||
* @brief Rotate in place to align with target orientation
|
||||
* @param handle Navigation handle
|
||||
* @param goal_yaw Desired heading (radians) <-- không có tham số nào tên goal_yaw
|
||||
* @return true if rotation command was sent successfully
|
||||
*/
|
||||
bool navigation_rotate_to(NavigationHandle handle, const PoseStamped goal);
|
||||
```
|
||||
|
||||
**Đây gần như chắc chắn là nguồn của một bug đang tồn tại phía C#.**
|
||||
`examples/NavigationExample/NavigationAPI.cs:165` khai báo:
|
||||
|
||||
```csharp
|
||||
public static extern bool navigation_rotate_to(NavigationHandle handle, double goal_yaw);
|
||||
```
|
||||
|
||||
Người viết binding đọc doc chứ không đọc chữ ký. Hậu quả ở tầng ABI: C# đẩy một `double` vào `xmm0`,
|
||||
C đọc một `PoseStamped` (struct lớn) từ stack — goal nhận được là rác, `isQuaternionValid` sẽ chặn
|
||||
hoặc `frame_id` là con trỏ rác.
|
||||
|
||||
### F16. Header khai `extern "C"` nhưng dùng tham chiếu C++
|
||||
|
||||
`size_t &out_count`, `PoseStamped &out_pose`, `OccupancyGrid &out_map`… Trình biên dịch C thuần không
|
||||
dịch được file này. ABI thì vẫn là con trỏ nên P/Invoke không bị ảnh hưởng. Không sửa được mà giữ chữ
|
||||
ký — chỉ ghi nhận.
|
||||
|
||||
### F17. Ghi chú giải phóng bộ nhớ không đầy đủ
|
||||
|
||||
`nav_c_api.h:265` có nhắc `out_twist->header.frame_id` phải free; `:274` nhắc `feed_back_str`. Nhưng
|
||||
`navigation_get_robot_pose_stamped` (`:250`) cũng `strdup` `frame_id` (`convertor.cpp:134`) mà doc
|
||||
không nhắc gì. Bốn getter sensor và hai getter planner data cũng cấp phát mà doc không nói (nay đã có
|
||||
`navigation_free_*` bên `nav_c_api_2`, nhưng doc của header cũ chưa trỏ sang).
|
||||
|
||||
---
|
||||
|
||||
## P4 — nhỏ, nhất quán, hạ tầng
|
||||
|
||||
### F18. `resize()` trước khi kiểm con trỏ NULL
|
||||
|
||||
`convertor.cpp:384` (`convert2CppPointCloud`) và `:423` (`convert2CppPointCloud2`):
|
||||
|
||||
```cpp
|
||||
cpp.points.resize(c.points_count); // resize trước
|
||||
for (size_t i = 0; i < c.points_count && c.points; ++i) // kiểm NULL sau
|
||||
```
|
||||
|
||||
Nếu host truyền `points = NULL` nhưng `points_count` lớn thì `resize` vẫn cấp phát đủ chỗ rồi vòng
|
||||
lặp không chạy. Không crash, nhưng cấp phát vô ích có thể rất lớn. `convert2CppLaserScan:21-22` làm
|
||||
đúng: tính size đã guard trước rồi mới resize.
|
||||
|
||||
### F19. `get_all_static_maps` lệch với ba hàm cùng nhóm
|
||||
|
||||
`nav_c_api.cpp:954` không có nhánh `if (empty()) { out_count = 0; return true; }` mà `:1000`, `:1036`,
|
||||
`:1072` đều có. Kết quả cuối giống nhau (vòng lặp không chạy, `out_count = 0`), chỉ là lệch hình thức.
|
||||
|
||||
### F20. `header_create` đọc đồng hồ hai lần
|
||||
|
||||
`std_msgs/Header.cpp:9-10`:
|
||||
|
||||
```cpp
|
||||
header.sec = robot::Time::now().sec;
|
||||
header.nsec = robot::Time::now().nsec;
|
||||
```
|
||||
|
||||
Hai lời gọi riêng biệt. Nếu rơi đúng lúc `nsec` vòng qua giây thì `sec` lấy từ lần đọc trước còn
|
||||
`nsec` từ lần sau — timestamp lệch tới một giây. Xác suất thấp nhưng hậu quả nằm ở TF lookup.
|
||||
|
||||
### F21. `catch (...)` nuốt lỗi không log
|
||||
|
||||
Phần lớn hàm kết thúc bằng `catch (...) { return false; }` trần. Host chỉ nhận `false`, không có cách
|
||||
nào biết vì sao. `navigation_create` (`:100-107`) còn nuốt cả `std::exception &e` mà không in `e.what()`
|
||||
— trong khi đây đúng là chỗ hay hỏng nhất (không tìm thấy `.so`, sai `library_path`).
|
||||
|
||||
### F22. CMake guard không bao giờ khớp
|
||||
|
||||
`pnkx_nav_core/CMakeLists.txt:237`: `if (NOT TARGET navigation_c_api)` — nhưng target thật tên
|
||||
`nav_c_api` (`src/APIs/c_api/CMakeLists.txt:61`). Guard vô tác dụng; `.so` sinh ra là
|
||||
`libnav_c_api.so`, không phải `libnavigation_c_api.so` như tài liệu ở nơi khác ghi.
|
||||
|
||||
### F23. Không có test nào
|
||||
|
||||
`src/APIs/c_api/` không có thư mục `test/`. Không có test đơn vị cho lớp converter — nơi tập trung
|
||||
gần hết các lỗi P0 ở trên và là nơi test rẻ nhất (không cần dựng navigation thật).
|
||||
|
||||
### F24. Năng lực contract chưa phơi ra ở bề mặt cũ
|
||||
|
||||
`BaseNavigation` có `addDepthCameraData()` (thuần ảo) và `shutdown()` mà `nav_c_api.h` không có hàm
|
||||
tương ứng. Đã bù bằng `navigation_add_depth_camera_data()` và `navigation_shutdown()` trong
|
||||
`nav_c_api_2`; ghi lại ở đây để bảng rà soát đầy đủ.
|
||||
|
||||
---
|
||||
|
||||
## Sửa được gì trong ràng buộc "không đổi chữ ký, không đổi chức năng chính"
|
||||
|
||||
**Sửa được ngay — 20 điểm:** F1, F2, F3, F7, F8, F9, F10, F11, F12, F13, F14, F15, F17, F18, F19,
|
||||
F20, F21, F22, F23, và phần tài liệu của F5.
|
||||
|
||||
- F1 là làm cho hàm **thực hiện đúng chức năng nó đã khai** — dùng tham số thay vì hằng số. Chữ ký
|
||||
không đổi, mục đích không đổi.
|
||||
- F2, F3, F18, F20, F21 là bổ sung guard và sửa lỗi nhỏ, không chạm hợp đồng.
|
||||
- F7–F12 là dọn log.
|
||||
- F13–F15, F17 là sửa khai báo và doc cho khớp hiện thực — F15 quan trọng vì nó đang dẫn người viết
|
||||
binding đi sai.
|
||||
|
||||
**Không sửa được mà giữ nguyên chữ ký — 3 điểm:**
|
||||
|
||||
| # | Vì sao | Lối ra |
|
||||
|---|---|---|
|
||||
| **F4** | Cần một đường báo "không tìm thấy" mà chữ ký hiện tại không có | Tài liệu hoá ngay; thêm `navigation_has_*` bên `nav_c_api_2` khi có dịp |
|
||||
| **F5** | Cần tham số `capacity` | Tài liệu hoá ngay; thêm biến thể có `capacity` bên `nav_c_api_2` |
|
||||
| **F16** | Bỏ tham chiếu C++ khỏi header là đổi chữ ký toàn bộ | Ghi nhận; chỉ đổi nếu có đợt phá vỡ ABI |
|
||||
|
||||
Riêng **F6** đã có lối ra không phá vỡ gì: `navigation_initialize_checked()` đã tồn tại.
|
||||
|
||||
---
|
||||
|
||||
## Thứ tự đề nghị
|
||||
|
||||
1. **F1** — một mình nó đủ khiến trần vận tốc không hoạt động. Cần chốt ý định trước (xem dưới).
|
||||
2. **F2, F3** — ba dòng guard, chặn ba đường segfault.
|
||||
3. **F15, F14, F13** — sửa doc và khai báo, vì chúng đang tạo ra bug ở phía binding.
|
||||
4. **F7–F12** — dọn log, gộp một lần.
|
||||
5. **F23** — một binary GTest cho riêng lớp converter: `frame_id` NULL, mảng NULL với count > 0,
|
||||
`Order` với mọi trường NULL, round-trip C++ → C → C++. Không cần dựng navigation thật.
|
||||
6. **F4, F5** — chốt hướng rồi mới làm.
|
||||
|
||||
---
|
||||
|
||||
## Câu hỏi mở — cần xác nhận trước khi sửa
|
||||
|
||||
1. ~~**F1 — ý định của `navigation_set_twist_linear` là gì?**~~ **Đã chốt:** truyền nguyên dạng, dấu
|
||||
chọn chiều, một lời gọi đặt một chiều. Xem F1.
|
||||
2. **Giá trị `0.1` cũ có phải trần an toàn cố ý của một lần thử nghiệm không?** Nếu đúng là có chủ ý
|
||||
thì nó phải nằm trong YAML chứ không phải hard-code trong lớp binding — và sau bản sửa này robot
|
||||
sẽ chạy đúng tốc độ host yêu cầu, không còn bị kẹp ở 0.1 m/s. **Cần biết trước khi chạy thật.**
|
||||
3. **F4 — có host nào đang dựa vào việc getter luôn trả `true` không?** Nếu không, đổi sang trả
|
||||
`false` khi rỗng là hợp lý hơn nhiều — nhưng đó là đổi hành vi.
|
||||
4. **Phía C# hiện có đang gọi `header_create` với `frame_id` NULL không** (F3), và có gọi
|
||||
`navigation_get_all_*` với mảng cấp sẵn bao nhiêu phần tử (F5)?
|
||||
|
||||
---
|
||||
|
||||
## F25 — hàm được khai báo và được gọi nhưng chưa bao giờ hiện thực
|
||||
|
||||
**Vị trí:** `include/convertor.h:137` khai báo, `src/nav_c_api.cpp:61` gọi, **không có định nghĩa ở
|
||||
đâu cả**.
|
||||
|
||||
```cpp
|
||||
robot_geometry_msgs::Pose2D convert2CppPose2D(const Pose2D& pose_2d); // chỉ có khai báo
|
||||
```
|
||||
|
||||
**Vì sao không ai phát hiện.** Thư viện chia sẻ được phép link với symbol chưa phân giải: `.so` build
|
||||
sạch, không một cảnh báo nào. Symbol nằm im trong bảng undefined:
|
||||
|
||||
```
|
||||
$ nm -D --undefined-only libnav_c_api.so | grep convert2CppPose2D
|
||||
U _Z17convert2CppPose2DRK6Pose2D
|
||||
```
|
||||
|
||||
**Ảnh hưởng.** `navigation_offset_goal_2d()` — hàm duy nhất gọi nó — chết ngay ở lời gọi đầu tiên với
|
||||
`symbol lookup error`, hoặc làm `dlopen` thất bại tuỳ cách nạp. Hàm này chưa bao giờ chạy được.
|
||||
|
||||
**Cách nó lộ ra.** Không phải do đọc mã. Bộ test mới (F23) link một **executable** vào thư viện, và
|
||||
executable thì không được phép có symbol chưa phân giải — trình liên kết báo ngay. Đây đúng là lý do
|
||||
bộ test tồn tại.
|
||||
|
||||
**Trạng thái: đã sửa** — hiện thực trong `convertor.cpp` ngay cạnh `convert2CPose2D`.
|
||||
|
||||
---
|
||||
|
||||
## Đã làm gì
|
||||
|
||||
Sửa **21/25 điểm**, giữ nguyên chữ ký và chức năng chính của mọi hàm.
|
||||
|
||||
| Nhóm | Điểm | Trạng thái |
|
||||
|---|---|---|
|
||||
| P0 | F1, F2, F3 | Đã sửa |
|
||||
| P1 | F6 | Đã có `navigation_initialize_checked` từ trước; header nay trỏ sang nó |
|
||||
| P1 | F4, F5 | Không sửa được mà giữ chữ ký — **đã ghi cảnh báo rõ trong header** |
|
||||
| P2 | F7–F12 | Đã sửa |
|
||||
| P3 | F13, F14, F15, F17 | Đã sửa |
|
||||
| P3 | F16 | Không sửa — cần phá vỡ ABI |
|
||||
| P4 | F18, F19, F20, F21, F22, F23 | Đã sửa |
|
||||
| P4 | F24 | Đã bù từ trước bằng `nav_c_api_2` |
|
||||
| — | **F25** | Đã sửa |
|
||||
|
||||
### File đã chạm
|
||||
|
||||
| File | Thay đổi |
|
||||
|---|---|
|
||||
| `src/nav_c_api.cpp` | F1 (dùng `linear_x` thật, bỏ short-circuit), F8–F12 (bỏ 9 `printf`, chuyển sang `robot::log_*`, hạ cấp log debug), F19, F21 (log lý do trong `catch`) |
|
||||
| `src/convertor.cpp` | F2 (`safe_cstr` cho 3 chỗ), F7 (bỏ log ABI), F18 (lấy kích thước từ con trỏ), **F25** |
|
||||
| `src/std_msgs/Header.cpp` | F3 (`strdup` chấp nhận NULL), F20 (đọc đồng hồ một lần) |
|
||||
| `include/nav_c_api.h` | F13 (3 khai báo thiếu), F14, F15, F17, cảnh báo F4/F5/F6, đơn vị `[m/s]`/`[rad/s]` |
|
||||
| `CMakeLists.txt` (gói) | F22 sửa tên target trong guard; thêm nhánh build test |
|
||||
| `../../../CMakeLists.txt` | F22 |
|
||||
| `test/test_convertor.cpp` | **Mới** — F23 |
|
||||
|
||||
### Hai thay đổi cần chú ý khi đọc diff
|
||||
|
||||
**F1 — `navigation_set_twist_linear` giờ truyền `linear_x` nguyên dạng, giữ dấu.** Dấu chọn chiều:
|
||||
âm đặt trần lùi, dương đặt trần tiến; một lời gọi đặt một chiều. **Đây là thay đổi hành vi thật** —
|
||||
trước đó trần luôn là ±0.1 m/s bất kể host truyền gì. Host nào từng "quen" với việc robot chạy
|
||||
0.1 m/s sẽ thấy robot chạy đúng tốc độ nó yêu cầu kể từ bản này.
|
||||
|
||||
**F5 — vẫn còn ghi mù.** Cảnh báo đã vào header nhưng bản chất không đổi: `get_all_*` và
|
||||
`get_robot_footprint` vẫn ghi theo số phần tử lõi đang giữ. Nếu muốn chặn thật thì phải thêm biến thể
|
||||
có `capacity` bên `nav_c_api_2`.
|
||||
|
||||
---
|
||||
|
||||
## Đã kiểm chứng tới đâu
|
||||
|
||||
**Lệnh đã chạy và kết quả thật:**
|
||||
|
||||
```
|
||||
$ cmake -S . -B build -DBUILD_C_API_TESTS=ON
|
||||
-- nav_c_api: converter tests enabled
|
||||
|
||||
$ cmake --build build --target nav_c_api test_convertor -j4
|
||||
[100%] Built target nav_c_api
|
||||
[100%] Built target test_convertor
|
||||
|
||||
$ ./build/test_convertor
|
||||
[==========] 20 tests from 6 test cases ran. (0 ms total)
|
||||
[ PASSED ] 20 tests.
|
||||
|
||||
$ nm -D --undefined-only build/libnav_c_api.so | grep -E "convert2|isQuaternion|order_free|header_"
|
||||
(không còn)
|
||||
|
||||
$ g++ -std=c++17 -Wall -Wextra -fsyntax-only # cả 5 file nguồn
|
||||
nav_c_api OK (0 warning)
|
||||
convertor OK (0 warning)
|
||||
nav_c_api_2 OK (0 warning)
|
||||
convertor_2 OK (0 warning)
|
||||
Header.cpp OK
|
||||
```
|
||||
|
||||
20 test phủ: `frame_id` NULL trên 4 loại message, mảng NULL kèm bộ đếm khác 0 trên 3 loại, round-trip
|
||||
C++ → C → C++ cho OccupancyGrid và LaserScan, `Order` zero-init và `Order` có node/edge với chuỗi
|
||||
NULL, chuyển đổi depth camera (gồm kiểm tra copy chứ không alias), 5 hàm `navigation_free_*` (gọi với
|
||||
NULL, gọi hai lần, giải phóng buffer lồng nhau), và `isQuaternionValid`.
|
||||
|
||||
**Chưa kiểm chứng:**
|
||||
|
||||
- Chưa chạy trên robot hay Gazebo. Không có test tích hợp nào dựng navigation thật.
|
||||
- **F1 chưa được xác nhận trên phần cứng.** Trần vận tốc giờ đi đúng giá trị host truyền — cần một
|
||||
lần chạy thật để xác nhận robot không vọt quá tốc độ mong đợi, vì trước đây nó luôn bị kẹp ở
|
||||
0.1 m/s. Đây là thay đổi cần chú ý nhất khi triển khai.
|
||||
- `valgrind` chưa cài trên máy này, nên phần rò bộ nhớ của các hàm `free` mới chỉ được kiểm bằng
|
||||
kiểm tra con trỏ sau khi giải phóng, không bằng công cụ.
|
||||
- Bốn câu hỏi mở ở mục trên vẫn còn nguyên; F1 đã tự trả lời được bằng cách đọc host ROS, ba câu còn
|
||||
lại vẫn cần phía host xác nhận.
|
||||
1887
src/APIs/c_api/NAV_C_API_2_GUIDE.md
Normal file
1887
src/APIs/c_api/NAV_C_API_2_GUIDE.md
Normal file
File diff suppressed because it is too large
Load Diff
217
src/APIs/c_api/include/convertor.h
Normal file
217
src/APIs/c_api/include/convertor.h
Normal file
@@ -0,0 +1,217 @@
|
||||
#ifndef C_API_CONVERTOR_H
|
||||
#define C_API_CONVERTOR_H
|
||||
|
||||
// C
|
||||
#include "sensor_msgs/LaserScan.h"
|
||||
#include "sensor_msgs/PointCloud.h"
|
||||
#include "sensor_msgs/PointCloud2.h"
|
||||
#include "nav_msgs/Odometry.h"
|
||||
#include "std_msgs/Header.h"
|
||||
#include "nav_msgs/OccupancyGrid.h"
|
||||
#include "geometry_msgs/Point.h"
|
||||
#include "geometry_msgs/PoseStamped.h"
|
||||
#include "geometry_msgs/Pose2D.h"
|
||||
#include "nav_2d_msgs/Twist2D.h"
|
||||
#include "nav_2d_msgs/Twist2DStamped.h"
|
||||
#include "nav_2d_msgs/Path2D.h"
|
||||
#include "map_msgs/OccupancyGridUpdate.h"
|
||||
#include "geometry_msgs/PolygonStamped.h"
|
||||
#include "protocol_msgs/Order.h"
|
||||
|
||||
// C++
|
||||
#include <robot_sensor_msgs/LaserScan.h>
|
||||
#include <robot_sensor_msgs/PointCloud.h>
|
||||
#include <robot_sensor_msgs/PointCloud2.h>
|
||||
#include <robot_nav_msgs/Odometry.h>
|
||||
#include <robot_nav_msgs/OccupancyGrid.h>
|
||||
#include <robot_geometry_msgs/PoseStamped.h>
|
||||
#include <robot_geometry_msgs/Pose2D.h>
|
||||
#include <robot_nav_2d_msgs/Twist2D.h>
|
||||
#include <robot_nav_2d_msgs/Twist2DStamped.h>
|
||||
#include <robot_nav_2d_msgs/Path2D.h>
|
||||
#include <robot_map_msgs/OccupancyGridUpdate.h>
|
||||
#include <robot_geometry_msgs/PolygonStamped.h>
|
||||
#include <robot_protocol_msgs/Order.h>
|
||||
|
||||
#include <move_base_core/navigation.h>
|
||||
#include <move_base_core/common.h>
|
||||
|
||||
/**
|
||||
* @brief Convert C LaserScan to C++ LaserScan
|
||||
* @param laser_scan C LaserScan
|
||||
* @return C++ LaserScan
|
||||
*/
|
||||
robot_sensor_msgs::LaserScan convert2CppLaserScan(const LaserScan& laser_scan);
|
||||
|
||||
/**
|
||||
* @brief Convert C OccupancyGrid to C++ OccupancyGrid
|
||||
* @param occupancy_grid C OccupancyGrid
|
||||
* @return C++ OccupancyGrid
|
||||
*/
|
||||
robot_nav_msgs::OccupancyGrid convert2CppOccupancyGrid(const OccupancyGrid& occupancy_grid);
|
||||
|
||||
/**
|
||||
* @brief Convert C++ OccupancyGrid to C OccupancyGrid
|
||||
* @param cpp C++ OccupancyGrid
|
||||
* @param out C OccupancyGrid
|
||||
*/
|
||||
void convert2COccupancyGrid(const robot_nav_msgs::OccupancyGrid& cpp, OccupancyGrid& out);
|
||||
|
||||
/**
|
||||
* @brief Convert C++ Path2D to C Path2D
|
||||
*/
|
||||
void convert2CPath2D(const robot_nav_2d_msgs::Path2D& cpp, Path2D& out);
|
||||
|
||||
/**
|
||||
* @brief Convert C++ OccupancyGridUpdate to C OccupancyGridUpdate
|
||||
*/
|
||||
void convert2COccupancyGridUpdate(const robot_map_msgs::OccupancyGridUpdate& cpp, OccupancyGridUpdate& out);
|
||||
|
||||
/**
|
||||
* @brief Convert C++ PolygonStamped to C PolygonStamped
|
||||
*/
|
||||
void convert2CPolygonStamped(const robot_geometry_msgs::PolygonStamped& cpp, PolygonStamped& out);
|
||||
|
||||
/**
|
||||
* @brief Convert C++ LaserScan to C LaserScan
|
||||
* @param cpp C++ LaserScan
|
||||
* @param out C LaserScan
|
||||
*/
|
||||
void convert2CLaserScan(const robot_sensor_msgs::LaserScan& cpp, LaserScan& out);
|
||||
|
||||
/**
|
||||
* @brief Convert C++ PointCloud to C PointCloud
|
||||
* @param cpp C++ PointCloud
|
||||
* @param out C PointCloud
|
||||
*/
|
||||
void convert2CPointCloud(const robot_sensor_msgs::PointCloud& cpp, PointCloud& out);
|
||||
|
||||
/**
|
||||
* @brief Convert C++ PointCloud2 to C PointCloud2
|
||||
* @param cpp C++ PointCloud2
|
||||
* @param out C PointCloud2
|
||||
*/
|
||||
void convert2CPointCloud2(const robot_sensor_msgs::PointCloud2& cpp, PointCloud2& out);
|
||||
|
||||
/**
|
||||
* @brief Convert C PointCloud to C++ PointCloud
|
||||
* @param c C PointCloud
|
||||
* @return C++ PointCloud
|
||||
*/
|
||||
robot_sensor_msgs::PointCloud convert2CppPointCloud(const PointCloud& c);
|
||||
|
||||
/**
|
||||
* @brief Convert C PointCloud2 to C++ PointCloud2
|
||||
* @param c C PointCloud2
|
||||
* @return C++ PointCloud2
|
||||
*/
|
||||
robot_sensor_msgs::PointCloud2 convert2CppPointCloud2(const PointCloud2& c);
|
||||
|
||||
/**
|
||||
* @brief Convert C Odometry to C++ Odometry
|
||||
* @param odometry C Odometry
|
||||
* @return C++ Odometry
|
||||
*/
|
||||
robot_nav_msgs::Odometry convert2CppOdometry(const Odometry& odometry);
|
||||
|
||||
/**
|
||||
* @brief Convert C PoseStamped to C++ PoseStamped
|
||||
* @param pose_stamped C PoseStamped
|
||||
* @return C++ PoseStamped
|
||||
*/
|
||||
robot_geometry_msgs::PoseStamped convert2CppPoseStamped(const PoseStamped& pose_stamped);
|
||||
|
||||
/**
|
||||
* @brief Convert C++ PoseStamped to C PoseStamped
|
||||
* @param cpp_pose_stamped C++ PoseStamped
|
||||
* @return C PoseStamped
|
||||
*/
|
||||
PoseStamped convert2CPoseStamped(const robot_geometry_msgs::PoseStamped& cpp_pose_stamped);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Convert C Pose2D to C++ Pose2D
|
||||
* @param pose_2d C Pose2D
|
||||
* @return C++ Pose2D
|
||||
*/
|
||||
robot_geometry_msgs::Pose2D convert2CppPose2D(const Pose2D& pose_2d);
|
||||
|
||||
/**
|
||||
* @brief Convert C++ Pose2D to C Pose2D
|
||||
* @param cpp_pose_2d C++ Pose2D
|
||||
* @return C Pose2D
|
||||
*/
|
||||
Pose2D convert2CPose2D(const robot_geometry_msgs::Pose2D& cpp_pose_2d);
|
||||
|
||||
/**
|
||||
* @brief Convert C Twist2D to C++ Twist2D
|
||||
* @param twist_2d C Twist2D
|
||||
* @return C++ Twist2D
|
||||
*/
|
||||
robot_nav_2d_msgs::Twist2D convert2CppTwist2D(const Twist2D& twist_2d);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Convert C++ Twist2D to C Twist2D
|
||||
* @param cpp_twist_2d C++ Twist2D
|
||||
* @return C Twist2D
|
||||
*/
|
||||
Twist2D convert2CTwist2D(const robot_nav_2d_msgs::Twist2D& cpp_twist_2d);
|
||||
|
||||
/**
|
||||
* @brief Convert C Twist2DStamped to C++ Twist2DStamped
|
||||
* @param twist_2d_stamped C Twist2DStamped
|
||||
* @return C++ Twist2DStamped
|
||||
*/
|
||||
robot_nav_2d_msgs::Twist2DStamped convert2CppTwist2DStamped(const Twist2DStamped& twist_2d_stamped);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Convert C++ Twist2DStamped to C Twist2DStamped
|
||||
* @param cpp_twist_2d_stamped C++ Twist2DStamped
|
||||
* @return C Twist2DStamped
|
||||
*/
|
||||
Twist2DStamped convert2CTwist2DStamped(const robot_nav_2d_msgs::Twist2DStamped& cpp_twist_2d_stamped);
|
||||
|
||||
/**
|
||||
* @brief Convert C Order to C++ Order
|
||||
* @param order C Order
|
||||
* @return C++ Order
|
||||
*/
|
||||
robot_protocol_msgs::Order convert2CppOrder(const Order& order);
|
||||
|
||||
/**
|
||||
* @brief Convert a C Action to a C++ Action.
|
||||
*
|
||||
* Null char* fields become empty strings, so a partially filled struct converts without crashing —
|
||||
* the callee validates content, this only crosses the language boundary.
|
||||
*
|
||||
* @param action C Action
|
||||
* @return C++ Action
|
||||
*/
|
||||
robot_protocol_msgs::Action convert2CppAction(const Action& action);
|
||||
|
||||
/**
|
||||
* @brief Convert C++ Order to C Order
|
||||
* @param cpp_order C++ Order
|
||||
* @return C Order (caller must call order_free when done to release memory)
|
||||
*/
|
||||
Order convert2COrder(const robot_protocol_msgs::Order& cpp_order);
|
||||
|
||||
/**
|
||||
* @brief Check if a quaternion is valid
|
||||
* @param q Quaternion
|
||||
* @return True if valid, false otherwise
|
||||
*/
|
||||
bool isQuaternionValid(const Quaternion& q);
|
||||
|
||||
/**
|
||||
* @brief Free dynamic memory held by an Order returned from convert2COrder
|
||||
* @param order Order to free (pointers and counts are zeroed)
|
||||
*/
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
#endif
|
||||
void order_free(Order* order);
|
||||
|
||||
#endif // C_API_CONVERTOR_H
|
||||
51
src/APIs/c_api/include/convertor_2.h
Normal file
51
src/APIs/c_api/include/convertor_2.h
Normal file
@@ -0,0 +1,51 @@
|
||||
#ifndef C_API_CONVERTOR_2_H
|
||||
#define C_API_CONVERTOR_2_H
|
||||
|
||||
/**
|
||||
* @file convertor_2.h
|
||||
* @brief Converters that only the move_base2 entry points need.
|
||||
*
|
||||
* Kept apart from convertor.h so the move_base2 surface can be added, reviewed and reverted without
|
||||
* touching the converters the existing binding already depends on.
|
||||
*/
|
||||
|
||||
// C
|
||||
#include "std_msgs/Header.h"
|
||||
#include "sensor_msgs/Image.h"
|
||||
#include "sensor_msgs/CameraInfo.h"
|
||||
#include "sensor_msgs/DepthCameraData.h"
|
||||
|
||||
// C++
|
||||
#include <robot_std_msgs/Header.h>
|
||||
#include <robot_sensor_msgs/Image.h>
|
||||
#include <robot_sensor_msgs/CameraInfo.h>
|
||||
#include <robot_sensor_msgs/DepthCameraData.h>
|
||||
|
||||
/**
|
||||
* @brief Convert C Header to C++ Header.
|
||||
* @param header C header; `frame_id` may be NULL (becomes an empty string).
|
||||
*/
|
||||
robot_std_msgs::Header convert2CppHeader(const Header& header);
|
||||
|
||||
/**
|
||||
* @brief Convert C Image to C++ Image.
|
||||
*
|
||||
* The pixel buffer is copied, so the caller keeps ownership of `image.data` and may free it as
|
||||
* soon as this call returns.
|
||||
*
|
||||
* @param image C image; `data` and `encoding` may be NULL.
|
||||
*/
|
||||
robot_sensor_msgs::Image convert2CppImage(const Image& image);
|
||||
|
||||
/**
|
||||
* @brief Convert C CameraInfo to C++ CameraInfo.
|
||||
* @param info C camera info; `D` and `distortion_model` may be NULL. K/R/P are fixed size (9/9/12).
|
||||
*/
|
||||
robot_sensor_msgs::CameraInfo convert2CppCameraInfo(const CameraInfo& info);
|
||||
|
||||
/**
|
||||
* @brief Convert C DepthCameraData to C++ DepthCameraData. Everything is deep-copied.
|
||||
*/
|
||||
robot_sensor_msgs::DepthCameraData convert2CppDepthCameraData(const DepthCameraData& data);
|
||||
|
||||
#endif // C_API_CONVERTOR_2_H
|
||||
22
src/APIs/c_api/include/geometry_msgs/Accel.h
Normal file
22
src/APIs/c_api/include/geometry_msgs/Accel.h
Normal file
@@ -0,0 +1,22 @@
|
||||
#ifndef C_API_GEOMETRY_MSGS_ACCEL_H
|
||||
#define C_API_GEOMETRY_MSGS_ACCEL_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include "geometry_msgs/Vector3.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
Vector3 linear;
|
||||
Vector3 angular;
|
||||
} Accel;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // C_API_GEOMETRY_MSGS_ACCEL_H
|
||||
23
src/APIs/c_api/include/geometry_msgs/AccelStamped.h
Normal file
23
src/APIs/c_api/include/geometry_msgs/AccelStamped.h
Normal file
@@ -0,0 +1,23 @@
|
||||
#ifndef C_API_GEOMETRY_MSGS_ACCELSTAMPED_H
|
||||
#define C_API_GEOMETRY_MSGS_ACCELSTAMPED_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include "std_msgs/Header.h"
|
||||
#include "geometry_msgs/Accel.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
Header header;
|
||||
Accel accel;
|
||||
} AccelStamped;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // C_API_GEOMETRY_MSGS_ACCELSTAMPED_H
|
||||
22
src/APIs/c_api/include/geometry_msgs/AccelWithCovariance.h
Normal file
22
src/APIs/c_api/include/geometry_msgs/AccelWithCovariance.h
Normal file
@@ -0,0 +1,22 @@
|
||||
#ifndef C_API_GEOMETRY_MSGS_ACCELWITHCOVARIANCE_H
|
||||
#define C_API_GEOMETRY_MSGS_ACCELWITHCOVARIANCE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include "geometry_msgs/Accel.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
Accel accel;
|
||||
double covariance[36];
|
||||
} AccelWithCovariance;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // C_API_GEOMETRY_MSGS_ACCELWITHCOVARIANCE_H
|
||||
@@ -0,0 +1,23 @@
|
||||
#ifndef C_API_GEOMETRY_MSGS_ACCELWITHCOVARIANCESTAMPED_H
|
||||
#define C_API_GEOMETRY_MSGS_ACCELWITHCOVARIANCESTAMPED_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include "std_msgs/Header.h"
|
||||
#include "geometry_msgs/AccelWithCovariance.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
Header header;
|
||||
AccelWithCovariance accel;
|
||||
} AccelWithCovarianceStamped;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // C_API_GEOMETRY_MSGS_ACCELWITHCOVARIANCESTAMPED_H
|
||||
28
src/APIs/c_api/include/geometry_msgs/Inertia.h
Normal file
28
src/APIs/c_api/include/geometry_msgs/Inertia.h
Normal file
@@ -0,0 +1,28 @@
|
||||
#ifndef C_API_GEOMETRY_MSGS_INERTIA_H
|
||||
#define C_API_GEOMETRY_MSGS_INERTIA_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include "geometry_msgs/Vector3.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
double m;
|
||||
Vector3 com;
|
||||
double ixx;
|
||||
double ixy;
|
||||
double ixz;
|
||||
double iyy;
|
||||
double iyz;
|
||||
double izz;
|
||||
} Inertia;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // C_API_GEOMETRY_MSGS_INERTIA_H
|
||||
23
src/APIs/c_api/include/geometry_msgs/InertiaStamped.h
Normal file
23
src/APIs/c_api/include/geometry_msgs/InertiaStamped.h
Normal file
@@ -0,0 +1,23 @@
|
||||
#ifndef C_API_GEOMETRY_MSGS_INERTIASTAMPED_H
|
||||
#define C_API_GEOMETRY_MSGS_INERTIASTAMPED_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include "std_msgs/Header.h"
|
||||
#include "geometry_msgs/Inertia.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
Header header;
|
||||
Inertia inertia;
|
||||
} InertiaStamped;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // C_API_GEOMETRY_MSGS_INERTIASTAMPED_H
|
||||
21
src/APIs/c_api/include/geometry_msgs/Point.h
Normal file
21
src/APIs/c_api/include/geometry_msgs/Point.h
Normal file
@@ -0,0 +1,21 @@
|
||||
#ifndef C_API_GEOMETRY_MSGS_POINT_H
|
||||
#define C_API_GEOMETRY_MSGS_POINT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
typedef struct
|
||||
{
|
||||
double x;
|
||||
double y;
|
||||
double z;
|
||||
} Point;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // C_API_GEOMETRY_MSGS_POINT_H
|
||||
22
src/APIs/c_api/include/geometry_msgs/Point32.h
Normal file
22
src/APIs/c_api/include/geometry_msgs/Point32.h
Normal file
@@ -0,0 +1,22 @@
|
||||
#ifndef C_API_GEOMETRY_MSGS_POINT32_H
|
||||
#define C_API_GEOMETRY_MSGS_POINT32_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float x;
|
||||
float y;
|
||||
float z;
|
||||
} Point32;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // C_API_GEOMETRY_MSGS_POINT32_H
|
||||
23
src/APIs/c_api/include/geometry_msgs/PointStamped.h
Normal file
23
src/APIs/c_api/include/geometry_msgs/PointStamped.h
Normal file
@@ -0,0 +1,23 @@
|
||||
#ifndef C_API_GEOMETRY_MSGS_POINTSTAMPED_H
|
||||
#define C_API_GEOMETRY_MSGS_POINTSTAMPED_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include "std_msgs/Header.h"
|
||||
#include "geometry_msgs/Point.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
Header header;
|
||||
Point point;
|
||||
} PointStamped;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // C_API_GEOMETRY_MSGS_POINTSTAMPED_H
|
||||
22
src/APIs/c_api/include/geometry_msgs/Polygon.h
Normal file
22
src/APIs/c_api/include/geometry_msgs/Polygon.h
Normal file
@@ -0,0 +1,22 @@
|
||||
#ifndef C_API_GEOMETRY_MSGS_POLYGON_H
|
||||
#define C_API_GEOMETRY_MSGS_POLYGON_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include "geometry_msgs/Point32.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
Point32 *points;
|
||||
size_t points_count;
|
||||
} Polygon;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // C_API_GEOMETRY_MSGS_POLYGON_H
|
||||
23
src/APIs/c_api/include/geometry_msgs/PolygonStamped.h
Normal file
23
src/APIs/c_api/include/geometry_msgs/PolygonStamped.h
Normal file
@@ -0,0 +1,23 @@
|
||||
#ifndef C_API_GEOMETRY_MSGS_POLYGONSTAMPED_H
|
||||
#define C_API_GEOMETRY_MSGS_POLYGONSTAMPED_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include "std_msgs/Header.h"
|
||||
#include "geometry_msgs/Polygon.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
Header header;
|
||||
Polygon polygon;
|
||||
} PolygonStamped;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // C_API_GEOMETRY_MSGS_POLYGONSTAMPED_H
|
||||
23
src/APIs/c_api/include/geometry_msgs/Pose.h
Normal file
23
src/APIs/c_api/include/geometry_msgs/Pose.h
Normal file
@@ -0,0 +1,23 @@
|
||||
#ifndef C_API_GEOMETRY_MSGS_POSE_H
|
||||
#define C_API_GEOMETRY_MSGS_POSE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include "geometry_msgs/Point.h"
|
||||
#include "geometry_msgs/Quaternion.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
Point position;
|
||||
Quaternion orientation;
|
||||
} Pose;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // C_API_GEOMETRY_MSGS_POSE_H
|
||||
22
src/APIs/c_api/include/geometry_msgs/Pose2D.h
Normal file
22
src/APIs/c_api/include/geometry_msgs/Pose2D.h
Normal file
@@ -0,0 +1,22 @@
|
||||
#ifndef C_API_GEOMETRY_MSGS_POSE2D_H
|
||||
#define C_API_GEOMETRY_MSGS_POSE2D_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
typedef struct
|
||||
{
|
||||
double x;
|
||||
double y;
|
||||
double theta;
|
||||
} Pose2D;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // C_API_GEOMETRY_MSGS_POSE2D_H
|
||||
24
src/APIs/c_api/include/geometry_msgs/PoseArray.h
Normal file
24
src/APIs/c_api/include/geometry_msgs/PoseArray.h
Normal file
@@ -0,0 +1,24 @@
|
||||
#ifndef C_API_GEOMETRY_MSGS_POSEARRAY_H
|
||||
#define C_API_GEOMETRY_MSGS_POSEARRAY_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include "std_msgs/Header.h"
|
||||
#include "geometry_msgs/Pose.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
Header header;
|
||||
Pose *poses;
|
||||
size_t poses_count;
|
||||
} PoseArray;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // C_API_GEOMETRY_MSGS_POSEARRAY_H
|
||||
23
src/APIs/c_api/include/geometry_msgs/PoseStamped.h
Normal file
23
src/APIs/c_api/include/geometry_msgs/PoseStamped.h
Normal file
@@ -0,0 +1,23 @@
|
||||
#ifndef C_API_GEOMETRY_MSGS_POSESTAMPED_H
|
||||
#define C_API_GEOMETRY_MSGS_POSESTAMPED_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include "std_msgs/Header.h"
|
||||
#include "geometry_msgs/Pose.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
Header header;
|
||||
Pose pose;
|
||||
} PoseStamped;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // C_API_GEOMETRY_MSGS_POSESTAMPED_H
|
||||
23
src/APIs/c_api/include/geometry_msgs/PoseWithCovariance.h
Normal file
23
src/APIs/c_api/include/geometry_msgs/PoseWithCovariance.h
Normal file
@@ -0,0 +1,23 @@
|
||||
#ifndef C_API_GEOMETRY_MSGS_POSEWITHCOVARIANCE_H
|
||||
#define C_API_GEOMETRY_MSGS_POSEWITHCOVARIANCE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include "geometry_msgs/Pose.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
Pose pose;
|
||||
double *covariance;
|
||||
size_t covariance_count;
|
||||
} PoseWithCovariance;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // C_API_GEOMETRY_MSGS_POSEWITHCOVARIANCE_H
|
||||
@@ -0,0 +1,23 @@
|
||||
#ifndef C_API_GEOMETRY_MSGS_POSEWITHCOVARIANCESTAMPED_H
|
||||
#define C_API_GEOMETRY_MSGS_POSEWITHCOVARIANCESTAMPED_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include "std_msgs/Header.h"
|
||||
#include "geometry_msgs/PoseWithCovariance.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
Header header;
|
||||
PoseWithCovariance pose;
|
||||
} PoseWithCovarianceStamped;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // C_API_GEOMETRY_MSGS_POSEWITHCOVARIANCESTAMPED_H
|
||||
23
src/APIs/c_api/include/geometry_msgs/Quaternion.h
Normal file
23
src/APIs/c_api/include/geometry_msgs/Quaternion.h
Normal file
@@ -0,0 +1,23 @@
|
||||
#ifndef C_API_GEOMETRY_MSGS_QUATERNION_H
|
||||
#define C_API_GEOMETRY_MSGS_QUATERNION_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
typedef struct
|
||||
{
|
||||
double x;
|
||||
double y;
|
||||
double z;
|
||||
double w;
|
||||
} Quaternion;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // C_API_GEOMETRY_MSGS_QUATERNION_H
|
||||
23
src/APIs/c_api/include/geometry_msgs/QuaternionStamped.h
Normal file
23
src/APIs/c_api/include/geometry_msgs/QuaternionStamped.h
Normal file
@@ -0,0 +1,23 @@
|
||||
#ifndef C_API_GEOMETRY_MSGS_QUATERNIONSTAMPED_H
|
||||
#define C_API_GEOMETRY_MSGS_QUATERNIONSTAMPED_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include "std_msgs/Header.h"
|
||||
#include "geometry_msgs/Quaternion.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
Header header;
|
||||
Quaternion quaternion;
|
||||
} QuaternionStamped;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // C_API_GEOMETRY_MSGS_QUATERNIONSTAMPED_H
|
||||
23
src/APIs/c_api/include/geometry_msgs/Transform.h
Normal file
23
src/APIs/c_api/include/geometry_msgs/Transform.h
Normal file
@@ -0,0 +1,23 @@
|
||||
#ifndef C_API_GEOMETRY_MSGS_TRANSFORM_H
|
||||
#define C_API_GEOMETRY_MSGS_TRANSFORM_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include "geometry_msgs/Vector3.h"
|
||||
#include "geometry_msgs/Quaternion.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
Vector3 translation;
|
||||
Quaternion rotation;
|
||||
} Transform;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // C_API_GEOMETRY_MSGS_TRANSFORM_H
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user