generated from wessel/boilerplate
68 lines
2.1 KiB
Markdown
68 lines
2.1 KiB
Markdown
# 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 |
|