Skip to content

Add unit test suite for mission module BT nodes#172

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/add-test-mission-module
Draft

Add unit test suite for mission module BT nodes#172
Copilot wants to merge 2 commits intomainfrom
copilot/add-test-mission-module

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 23, 2026

The mission module had no test coverage despite supporting automatic task orchestration via behavior trees. This adds a closed-loop test suite that validates all BT node state transitions using a virtual blackboard and MissionContext mock injection — no CyberRT or hardware required.

New: modules/mission/mission_test.cc

  • BtTypeConvertersTestPointENU string conversion: "x,y", "x,y,z", and invalid input (throws)
  • CheckBatteryNodeTestFAILURE with null chassis, SUCCESS/FAILURE against threshold
  • StationWaitNodeTestRUNNING on first tick, SUCCESS after deadline passes
  • MoveToNodeTestRUNNING without localization, SUCCESS within 3 m, RUNNING when distant
  • ChargeNodeTestRUNNING without chassis, SUCCESS when SOC ≥ target
  • BtFactoryIntegrationTest — inline XML tree loading; patrol task stays RUNNING, shuttle bus short-circuits to FAILURE on low battery
// Virtual blackboard pre-populated with waypoints; MissionContext injected with mock data
auto chassis = std::make_shared<apollo::canbus::Chassis>();
chassis->set_battery_soc_percentage(5.0);
MissionContext::Instance()->UpdateChassis(chassis);

// CheckBattery(min=20) fails → whole Sequence fails immediately
BT::NodeStatus status = tree.tickOnce();
EXPECT_EQ(status, BT::NodeStatus::FAILURE);

Modified: modules/mission/BUILD

Added cc_test target mission_test with deps on node libraries, proto messages, behaviortree_cpp, and gtest_main.

Original prompt

This section details on the original issue you should resolve

<issue_title>[Feature]: Test mission module</issue_title>
<issue_description>### Use Case / Motivation

Currently, mission mode supports automatic task orchestration, but we haven't provided a minimum example.

https://github.com/wheelos/apollo-lite/tree/main/modules/mission/conf

Proposed Implementation

No response

Alternatives Considered

No response</issue_description>

<agent_instructions>## 1. System Design

Goal:
Build a “closed-loop” test environment that can simulate executor feedback and verify behavior status transitions.

Components:

  • Test Runner:
    Loads behavior tree definitions from XML/YAML under bt_trees.

  • Black-box Mock Layer:
    Simulates external inputs required by Action Nodes and Condition Nodes (e.g., sensor data, vehicle states).

  • State Monitor:
    Subscribes to BT status updates and records node return values (SUCCESS, FAILURE, RUNNING).

  • Assertion Engine:
    Checks whether the resulting behavior sequence matches expected outcomes.


2. Review of Existing Design

In the modules/mission architecture:

  • Supported: Yes — the existing framework typically includes a BT engine (e.g., Groot or BehaviorTree.CPP), and BT uses a Blackboard shared memory for key/value state communication. ([Cnblogs][1])

  • Bottleneck:
    Current implementation may be tightly coupled with CyberRT or real hardware interfaces, making it hard to run in a test environment without physical systems.

  • Improvements:
    Introduce a Virtual Blackboard that you can pre-populate with test data before execution, and use Mock Action nodes to replace real control commands.

</agent_instructions>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: daohu527 <10419854+daohu527@users.noreply.github.com>
Copilot AI changed the title [WIP] Add minimum example for test mission module Add unit test suite for mission module BT nodes Feb 23, 2026
Copilot AI requested a review from daohu527 February 23, 2026 10:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Test mission module

2 participants