generated from wessel/boilerplate
65 lines
2.2 KiB
Markdown
65 lines
2.2 KiB
Markdown
# WheelDataSimulator (`assignments::three::wheel_data_simulator_node`)
|
|
|
|
The `WheelDataSimulator` node generates simulated wheel encoder/velocity data (`std_msgs/msg/Float64MultiArray`) based on configurable time-varying intervals. It publishes wheel values for a 4-wheel robot configuration 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 wheel |
|
|
| `<wheel>.num_intervals` | int | 0 | Number of intervals for each wheel |
|
|
| `<wheel>.interval_<n>.*` | various | - | Interval configuration (see Simulator) |
|
|
|
|
**Wheels Configured:**
|
|
- `wheel_fl` - Front Left wheel
|
|
- `wheel_fr` - Front Right wheel
|
|
- `wheel_rl` - Rear Left wheel
|
|
- `wheel_rr` - Rear Right wheel
|
|
|
|
**Constructor**
|
|
```cpp
|
|
DataSimulator()
|
|
```
|
|
- Initializes ROS2 node with name `wheel_data_simulator`
|
|
- Creates `Simulator` instance for value generation
|
|
- Creates publisher for `simulated_wheel_data` topic
|
|
- Sets up timer for periodic publishing
|
|
|
|
## Core Functionality
|
|
|
|
**`void publish_wheel_data()`**
|
|
- Timer callback invoked at the configured publish rate
|
|
- Calculates elapsed time since node start
|
|
- Queries `Simulator` for current values of all 4 wheels
|
|
- Populates Float64MultiArray message with wheel values in order: [FL, FR, RL, RR]
|
|
- Publishes message to topic
|
|
|
|
## ROS2 Interface
|
|
|
|
**Publications**
|
|
- `simulated_wheel_data` (std_msgs/msg/Float64MultiArray)
|
|
- Publishes simulated wheel data at configured rate
|
|
- Array contains 4 values: [front_left, front_right, rear_left, rear_right]
|
|
|
|
## Usage Example
|
|
|
|
```bash
|
|
ros2 run g2_2025_odometry_pkg wheel_data_simulator_node --ros-args \
|
|
-p publish_rate:=50.0 \
|
|
-p wheel_fl.num_intervals:=1 \
|
|
-p wheel_fl.interval_0.type:=linear \
|
|
-p wheel_fl.interval_0.t_start:=0.0 \
|
|
-p wheel_fl.interval_0.t_end:=10.0 \
|
|
-p wheel_fl.interval_0.y_start:=0.0 \
|
|
-p wheel_fl.interval_0.y_end:=5.0
|
|
```
|
|
|
|
## Dependencies
|
|
|
|
- `rclcpp` - ROS2 C++ client library
|
|
- `std_msgs` - Standard message types
|
|
- `Simulator` - Internal simulation engine
|