generated from wessel/boilerplate
64 lines
2.1 KiB
Markdown
64 lines
2.1 KiB
Markdown
# IMUDataSimulator (`assignments::three::data_simulator_node`)
|
|
|
|
The `IMUDataSimulator` node generates simulated IMU sensor data (`sensor_msgs/msg/Imu`) based on configurable time-varying intervals. It publishes linear acceleration and angular velocity values that can follow constant, linear, or quadratic trajectories over time.
|
|
|
|
## Implementation Details
|
|
|
|
**Parameters**
|
|
|
|
| Parameter | Type | Default | Description |
|
|
|-----------|------|---------|-------------|
|
|
| `publish_rate` | double | 10.0 | Publishing frequency in Hz |
|
|
| `max_intervals` | int | 4 | Maximum number of intervals per axis |
|
|
| `<axis>.num_intervals` | int | 0 | Number of intervals for each axis |
|
|
| `<axis>.interval_<n>.*` | various | - | Interval configuration (see Simulator) |
|
|
|
|
**Axes Configured:**
|
|
- `linear_x`, `linear_y`, `linear_z` - Linear acceleration axes
|
|
- `angular_x`, `angular_y`, `angular_z` - Angular velocity axes
|
|
|
|
**Constructor**
|
|
```cpp
|
|
DataSimulator()
|
|
```
|
|
- Initializes ROS2 node with name `imu_data_simulator`
|
|
- Creates `Simulator` instance for value generation
|
|
- Creates publisher for `simulated_imu_data` topic
|
|
- Sets up timer for periodic publishing
|
|
|
|
## Core Functionality
|
|
|
|
**`void publish_imu_data()`**
|
|
- Timer callback invoked at the configured publish rate
|
|
- Calculates elapsed time since node start
|
|
- Queries `Simulator` for current values of all 6 axes
|
|
- Populates IMU message with:
|
|
- Header timestamp and frame_id (`imu_link`)
|
|
- Linear acceleration (x, y, z)
|
|
- Angular velocity (x, y, z)
|
|
- Publishes message to topic
|
|
|
|
## ROS2 Interface
|
|
|
|
**Publications**
|
|
- `simulated_imu_data` (sensor_msgs/msg/Imu)
|
|
- Publishes simulated IMU data at configured rate
|
|
- Frame ID: `imu_link`
|
|
|
|
## Usage Example
|
|
|
|
```bash
|
|
ros2 run g2_2025_odometry_pkg imu_data_simulator_node --ros-args \
|
|
-p publish_rate:=20.0 \
|
|
-p linear_x.num_intervals:=1 \
|
|
-p linear_x.interval_0.type:=constant \
|
|
-p linear_x.interval_0.t_start:=0.0 \
|
|
-p linear_x.interval_0.t_end:=10.0 \
|
|
-p linear_x.interval_0.y_start:=9.81
|
|
```
|
|
|
|
## Dependencies
|
|
|
|
- `rclcpp` - ROS2 C++ client library
|
|
- `sensor_msgs` - Standard sensor message types
|
|
- `Simulator` - Internal simulation engine |