generated from wessel/boilerplate
feat(doc): Add node & test documentation
This commit is contained in:
67
doc/tests/IMUDataSimulator.md
Normal file
67
doc/tests/IMUDataSimulator.md
Normal file
@@ -0,0 +1,67 @@
|
||||
# IMU Data Simulator Unit Tests
|
||||
|
||||
Unit tests for the `DataSimulator` (IMU) node are implemented in `src/g2_2025_odometry_pkg/test/test_imu_simulator.cpp` using Google Test and ROS2 test utilities. The tests validate node initialization, message publishing, and data correctness.
|
||||
|
||||
## Test Cases
|
||||
|
||||
### 1. NodeInitialization
|
||||
|
||||
**Description:** Verifies that the DataSimulator node can be created without errors.
|
||||
|
||||
- **Test Action:** Create DataSimulator instance
|
||||
- **Expected Result:** No exceptions thrown during construction
|
||||
|
||||
### 2. MessagePublishing
|
||||
|
||||
**Description:** Tests that IMU messages are published on the correct topic.
|
||||
|
||||
- **Test Action:**
|
||||
- Create subscription to `simulated_imu_data` topic
|
||||
- Create DataSimulator node
|
||||
- Spin both nodes for a short period
|
||||
- **Expected Result:** At least one `sensor_msgs/msg/Imu` message is received
|
||||
|
||||
### 3. MessageFrameId
|
||||
|
||||
**Description:** Verifies that published IMU messages have the correct frame_id.
|
||||
|
||||
- **Test Action:**
|
||||
- Subscribe to `simulated_imu_data`
|
||||
- Receive a message
|
||||
- **Expected Result:** `header.frame_id` equals `"imu_link"`
|
||||
|
||||
### 4. LinearAccelerationValues
|
||||
|
||||
**Description:** Tests that linear acceleration values are valid (finite numbers).
|
||||
|
||||
- **Test Action:**
|
||||
- Subscribe and receive IMU message
|
||||
- Check linear_acceleration fields
|
||||
- **Expected Result:**
|
||||
- `linear_acceleration.x` is finite
|
||||
- `linear_acceleration.y` is finite
|
||||
- `linear_acceleration.z` is finite
|
||||
|
||||
### 5. AngularVelocityValues
|
||||
|
||||
**Description:** Tests that angular velocity values are valid (finite numbers).
|
||||
|
||||
- **Test Action:**
|
||||
- Subscribe and receive IMU message
|
||||
- Check angular_velocity fields
|
||||
- **Expected Result:**
|
||||
- `angular_velocity.x` is finite
|
||||
- `angular_velocity.y` is finite
|
||||
- `angular_velocity.z` is finite
|
||||
|
||||
## Test Infrastructure
|
||||
|
||||
The test class `IMUSimulatorTest` provides:
|
||||
- Static `SetUpTestSuite()` and `TearDownTestSuite()` for ROS2 init/shutdown
|
||||
- Helper method `setupBasicIMUParams()` for setting up default test parameters
|
||||
|
||||
## ROS2 Topics Used
|
||||
|
||||
| Topic | Message Type | Direction |
|
||||
|-------|--------------|-----------|
|
||||
| `simulated_imu_data` | sensor_msgs/msg/Imu | Published by node under test |
|
||||
98
doc/tests/Simulator.md
Normal file
98
doc/tests/Simulator.md
Normal file
@@ -0,0 +1,98 @@
|
||||
# Simulator Unit Tests
|
||||
|
||||
Unit tests for `Simulator` are implemented in `src/g2_2025_odometry_pkg/test/test_simulator.cpp` using Google Test and ROS2 test utilities. The tests validate interval-based value generation with different interpolation types.
|
||||
|
||||
## Test Cases
|
||||
|
||||
### 1. ConstantInterval
|
||||
|
||||
**Description:** Verifies constant interpolation returns the same value throughout the interval.
|
||||
|
||||
- **Test Configuration:**
|
||||
- Single interval: t=[0, 10], y_start=5.0
|
||||
- Type: constant
|
||||
- **Expected Result:**
|
||||
- Value is 5.0 at t=0, t=5, t=10
|
||||
- Value holds at 5.0 after interval (t=15)
|
||||
|
||||
### 2. LinearInterval
|
||||
|
||||
**Description:** Tests linear interpolation between start and end values.
|
||||
|
||||
- **Test Configuration:**
|
||||
- Single interval: t=[0, 10], y_start=0.0, y_end=10.0
|
||||
- Type: linear
|
||||
- **Expected Result:**
|
||||
- Value is 0.0 at t=0
|
||||
- Value is 5.0 at t=5
|
||||
- Value is 10.0 at t=10
|
||||
- Value holds at 10.0 after interval (t=15)
|
||||
|
||||
### 3. QuadraticInterval
|
||||
|
||||
**Description:** Tests quadratic (Lagrange) interpolation through 3 points.
|
||||
|
||||
- **Test Configuration:**
|
||||
- Single interval: t=[0, 10], y_start=0.0, y_end=0.0, t_mid=5.0, y_mid=10.0
|
||||
- Type: quadratic
|
||||
- **Expected Result:**
|
||||
- Value is 0.0 at t=0
|
||||
- Value is 10.0 at t=5 (peak)
|
||||
- Value is 0.0 at t=10
|
||||
- Value holds at 0.0 after interval (t=15)
|
||||
|
||||
### 4. MultipleIntervals
|
||||
|
||||
**Description:** Tests behavior with multiple non-overlapping intervals and gaps.
|
||||
|
||||
- **Test Configuration:**
|
||||
- Interval 0: t=[0, 5], constant 5.0
|
||||
- Interval 1: t=[10, 15], constant 10.0
|
||||
- Gap between t=5 and t=10
|
||||
- **Expected Result:**
|
||||
- Value is 5.0 at t=2.5 (first interval)
|
||||
- Value holds at 5.0 in gap (t=7.5)
|
||||
- Value is 10.0 at t=12.5 (second interval)
|
||||
- Value holds at 10.0 after all intervals (t=20)
|
||||
|
||||
### 5. ValueBeforeIntervals
|
||||
|
||||
**Description:** Tests behavior when querying time before any interval starts.
|
||||
|
||||
- **Test Configuration:**
|
||||
- Single interval: t=[10, 20]
|
||||
- **Expected Result:**
|
||||
- Value is 0.0 at t=5 (before interval starts)
|
||||
|
||||
### 6. NonExistentChannel
|
||||
|
||||
**Description:** Tests graceful handling of queries for unconfigured channels.
|
||||
|
||||
- **Test Action:** Query `get_object_value("nonexistent_channel", 5.0)`
|
||||
- **Expected Result:** Returns 0.0
|
||||
|
||||
### 7. OverlappingIntervalsThrowsException
|
||||
|
||||
**Description:** Verifies that overlapping intervals are detected and rejected.
|
||||
|
||||
- **Test Configuration:**
|
||||
- Interval 0: t=[0, 10]
|
||||
- Interval 1: t=[5, 15] (overlaps)
|
||||
- **Expected Result:** Constructor throws `std::runtime_error`
|
||||
|
||||
### 8. MaxIntervalsLimit
|
||||
|
||||
**Description:** Tests that `max_intervals` parameter limits loaded intervals.
|
||||
|
||||
- **Test Configuration:**
|
||||
- max_intervals=2
|
||||
- num_intervals=3 (defines 3 intervals)
|
||||
- **Expected Result:**
|
||||
- Only first 2 intervals are loaded
|
||||
- Third interval values default to holding second interval's end value
|
||||
|
||||
## Test Infrastructure
|
||||
|
||||
The test class `SimulatorTest` provides:
|
||||
- Static `SetUpTestSuite()` and `TearDownTestSuite()` for ROS2 init/shutdown
|
||||
- Helper method `createNodeWithParams()` for creating nodes with parameter overrides
|
||||
73
doc/tests/WheelDataSimulator.md
Normal file
73
doc/tests/WheelDataSimulator.md
Normal file
@@ -0,0 +1,73 @@
|
||||
# Wheel Data Simulator Unit Tests
|
||||
|
||||
Unit tests for the `DataSimulator` (Wheel) node are implemented in `src/g2_2025_odometry_pkg/test/test_wheel_simulator.cpp` using Google Test and ROS2 test utilities. The tests validate node initialization, message publishing, array structure, and data correctness.
|
||||
|
||||
## Test Cases
|
||||
|
||||
### 1. NodeInitialization
|
||||
|
||||
**Description:** Verifies that the Wheel DataSimulator node can be created without errors.
|
||||
|
||||
- **Test Action:** Create DataSimulator instance
|
||||
- **Expected Result:** No exceptions thrown during construction
|
||||
|
||||
### 2. WheelDataPublishing
|
||||
|
||||
**Description:** Tests that wheel data messages are published on the correct topic.
|
||||
|
||||
- **Test Action:**
|
||||
- Create subscription to `simulated_wheel_data` topic
|
||||
- Create DataSimulator node
|
||||
- Spin both nodes for a short period
|
||||
- **Expected Result:** At least one `std_msgs/msg/Float64MultiArray` message is received
|
||||
|
||||
### 3. WheelDataArraySize
|
||||
|
||||
**Description:** Verifies that the published array contains the correct number of wheel values.
|
||||
|
||||
- **Test Action:**
|
||||
- Subscribe to `simulated_wheel_data`
|
||||
- Receive a message
|
||||
- Check array size
|
||||
- **Expected Result:** `data.size()` equals 4 (FL, FR, RL, RR)
|
||||
|
||||
### 4. ValidVelocityValues
|
||||
|
||||
**Description:** Tests that all wheel velocity values are valid (finite numbers).
|
||||
|
||||
- **Test Action:**
|
||||
- Subscribe and receive wheel data message
|
||||
- Check each value in the array
|
||||
- **Expected Result:** All 4 values are finite numbers
|
||||
|
||||
### 5. MultipleMessagesReceived
|
||||
|
||||
**Description:** Tests that multiple messages are published over time.
|
||||
|
||||
- **Test Action:**
|
||||
- Subscribe and count received messages
|
||||
- Spin for a short duration
|
||||
- **Expected Result:** Message count is greater than 0
|
||||
|
||||
## Test Infrastructure
|
||||
|
||||
The test class `WheelSimulatorTest` provides:
|
||||
- Static `SetUpTestSuite()` and `TearDownTestSuite()` for ROS2 init/shutdown
|
||||
- Helper method `setupBasicWheelParams()` for setting up default test parameters
|
||||
|
||||
## ROS2 Topics Used
|
||||
|
||||
| Topic | Message Type | Direction |
|
||||
|-------|--------------|-----------|
|
||||
| `simulated_wheel_data` | std_msgs/msg/Float64MultiArray | Published by node under test |
|
||||
|
||||
## Data Array Format
|
||||
|
||||
The published Float64MultiArray contains wheel values in the following order:
|
||||
|
||||
| Index | Wheel |
|
||||
|-------|-------|
|
||||
| 0 | Front Left (FL) |
|
||||
| 1 | Front Right (FR) |
|
||||
| 2 | Rear Left (RL) |
|
||||
| 3 | Rear Right (RR) |
|
||||
Reference in New Issue
Block a user