duongtd b102391fb8 Keep raw sensor readings so plugins can reach what the costmap threw away
Sensor data entered this runtime and disappeared into the costmap. At 0.05 m
with inflation the costmap has destroyed ray order and object shape, so a dock
detector fitting lines to find a V plate cannot reconstruct what the laser
saw - two 0.2 m wings on that grid are one blob. A reinforcement-learning
local planner wants the raw scan for the same reason. Neither had a route:
ActionContext held only TF, and LocalPlanner::initialize takes only a costmap.

NavigationServer now owns a SensorStore and feeds it from all five doors,
handing a read-only port to the action registry and to the controller runner.

The store gets the reading BEFORE the filter. Anything that wants filtering
filters upstream; the store does not know a filter exists. With laser SOR on,
the store and the costmap deliberately see different data - one wants outliers
gone, the other wants the true shape - and the comment at addLaserScan now
says so, because the one it replaces claimed the opposite.

remove* mirrors into the store, dropping readings while keeping the topic
declared. A host that has disowned data while the store still serves it means
the two disagree about what the robot can currently see, and max_age only
covers the tail of that.

Reaching a local planner without breaking every other one: widening
LocalPlanner::initialize would break hybrid, mppi, priest, stanley and
deep_mpc at once for the sake of one planner. A planner that wants sensor data
inherits SensorConsumer instead, and ControllerRunner finds out with a
dynamic_cast after loading it, at all three sites that build an instance and
always before initialize(). Planners that do not inherit it cast to null and
nothing happens, so nothing needs rebuilding. That cast crosses a .so boundary
and depends on matching RTTI, which a green build does not prove - hence the
log line, and hence TestControllerSensorProbe, dlopen'd like a real plugin, to
check it actually matches.

sensor_store/report_period prints what the store holds every N seconds, off by
default. Until a consumer exists it is the only way to see whether data
arrives at all, and it is what separates a mistyped topic from a dead sensor -
without it the two look identical. It reads age from the control loop's clock,
not robot::Time::now(), which is the wall clock while a simulated scan is not.

Config is refused at boot, not at first use: an unknown data_type, a short name
two packages share, a duplicate topic, a capacity below 1, a max_age that is
not positive. Declaring no sensor at all is valid and leaves the store empty
and silent - a runtime with no consumer of raw data holds nothing, which is an
answer rather than a reason to refuse to start.

robot_nav_msgs/OccupancyGrid is registered here rather than in
robot_sensor_ports, which ships only its own package's types; pulling
robot_nav_msgs into every translation unit that touches the store would be the
cost of doing otherwise.
2026-08-26 11:35:17 +07:00
2026-08-10 21:50:42 +07:00
2026-08-10 21:50:42 +07:00

move_base2

Navigation runtime thế hệ 2: nhận yêu cầu di chuyển, điều phối global planner, local planner và recovery behavior qua một state machine tường minh, và phát lệnh vận tốc từ đúng một nguồn tại mỗi thời điểm.

Gói hiện thực contract host robot::move_base_core::BaseNavigation và được nạp bằng Boost.DLL (alias MoveBase2) như mọi plugin khác của workspace.

Điểm khác biệt

Phần lõi quyết định — state machine và bộ trọng tài vận tốc — là logic thuần, không I/O. Nó không đụng costmap, không đụng TF, không log, không cấp phát trong vòng lặp. Vì vậy hành vi của nó kiểm được bằng bảng chuyển trạng thái thay vì phải chạy robot, và mọi thay đổi hành vi đều để lại dấu vết trong test.

Mọi phụ thuộc ra ngoài đi qua port: thời gian, pose, global planner, local planner, recovery, mission. Lõi không biết mission framework hay recovery framework nào đang chạy phía sau.

Cấu trúc

include/move_base2/
├── ports/            # sáu cổng ra: clock, pose, planner, controller, recovery, mission
├── core/             # navigation_request, navigation_state, state_machine, velocity_arbiter
├── control_loop.h    # một control cycle
└── navigation_server.h   # facade hiện thực BaseNavigation
src/
test/                 # fake_ports.h + ba bộ test
docs/                 # ARCHITECTURE.md, STATE_MACHINE.md, THREADING.md

docs/STATE_MACHINE.md là nguồn chuẩn cho hành vi chuyển state. Đổi hành vi thì sửa tài liệu đó trước, sửa test, rồi mới sửa code.

Luồng runtime

host / mission layer
        │  moveTo(goal) / moveTo(order) / executeInstantActions
        ▼
NavigationServer::submit()          quy về một NavigationRequest
        │                           từ chối ngay tại cửa nếu goal hỏng hoặc không nạp được planner
        ▼
ControlLoop::step()                 mỗi control cycle:
        │  1. đọc thời gian và pose, tính dt thật
        │  2. chạy state machine với phản hồi của cycle TRƯỚC
        │  3. thi hành output: nhận yêu cầu, đẩy plan, start/tick recovery, chạy controller
        │  4. đưa lệnh ứng viên qua bộ trọng tài
        │  5. báo kết quả cho mission layer nếu state machine yêu cầu
        ▼
    cmd_vel

Nguồn vận tốc chỉ có hai khả năng khác kNone: local planner khi đang ở CONTROLLING, recovery behavior khi đang ở RECOVERING. Đổi nguồn luôn chèn đúng một cycle vận tốc 0.

Build và test

cd /home/duongtd/T800_ws
catkin_make --pkg nav_test_harness
catkin_make --pkg move_base2

./devel/lib/move_base2/state_machine_test
./devel/lib/move_base2/velocity_arbiter_test
./devel/lib/move_base2/walking_skeleton_test

Gói build với -Wall -Wextra qua target_compile_options và không kế thừa cờ tắt warning của cây nav core.

Cấu hình

Ở trạng thái hiện tại, cấu hình được truyền vào bằng struct ControlLoopConfig (có validate() và describe()). Phần đọc từ YAML qua robot::NodeHandle thuộc bước nối dây runtime; khi thêm, file cấu hình đang có hiệu lực sẽ nằm trong cây config của nav core, không nằm trong gói này — bản trong test/ nếu có chỉ phục vụ test và phải chạy kèm biến môi trường trỏ vào đúng thư mục đó.

Trạng thái

Runtime thật đã chạy trọn trên sim: costmap, planner/controller/recovery/action nạp qua boost::dll, và mission layer (mission_adapters) được dựng trong NavigationRuntime nên order VDA5050 được cắt thành từng chặng thay vì dồn thành một goal. Phần còn thiếu được liệt kê ở cuối docs/ARCHITECTURE.md.

Ba đường vào, tất cả qua mission layer

Entry point Schema Layer từ chối thì
moveTo(goal, …) geometry.pose_stamped rơi xuống submit() trực tiếp — goal đơn vẫn còn nguyên nghĩa
moveTo(order, goal, …) vda5050.order rơi xuống đường trực tiếp: một NavigationRequest cho cả order, hành vi gen-1
executeInstantActions(actions) vda5050.instant_action trả false — không có fallback

Order đi qua mission_adapters: cắt chặng tại mỗi node có action, chỉ chạy phần released, orderUpdateId nối tiếp thay vì chạy lại, mission_timeout làm lưới cuối.

executeInstantActions không có fallback vì một instantAction chỉ có nghĩa sau khi được nở theo bảng compound_actions: đẩy thẳng xuống lõi sẽ biến PickUp thành một chặng chỉ-action không có bước dò và không có bước tiến vào — robot báo "đã nâng kệ" khi càng còn chưa tới gần kệ.

Bốn entry point đã bị gỡ

dockTo ×2, moveStraightTo, rotateTo không còn trong contract host. Chúng submit thẳng vào lõi, bỏ qua mission layer, nên một goal đến giữa chừng ghi đè chặng đang chạy mà hàng đợi không biết — MissionManager vẫn giao chặng kế của một tuyến robot đã rời khỏi.

Bốn MotionProfile giữ nguyên. Docking / go-straight / rotate giờ là thuộc tính của từng chặng trong order: khoá profile: (position | docking | go_straight | rotate) cộng marker: cho docking, khai trong config/runtime/compound_actions_params.yaml.

instantActions

Một message = một lô. Cả message xuống cùng lúc và luôn preempt những gì đang trong hàng đợi; blockingType không còn chọn cách vào hàng đợi. Chi tiết và lý do: docs/ARCHITECTURE.md, cùng doc của mission_plugins::InstantActionSourceAdapter.

Payload mẫu để thử tay: Controllers/Packages/amr_comunication/scripts/samples/.

Description
No description provided
Readme 4.9 MiB
Languages
C++ 96.4%
Python 1.5%
CMake 1.2%
MATLAB 0.9%