f110_scripts.datagen package¶
Submodules¶
f110_scripts.datagen.combine_datasets module¶
Utility to combine multiple F1TENTH .npz datasets into a single file with deduplication based on an epsilon threshold.
- f110_scripts.datagen.combine_datasets.combine_datasets(input_files: List[str], output_file: str, epsilon: float = 0.01, deduplicate: bool = False) None¶
Combines multiple .npz datasets and optionally removes redundant rows.
This function loads multiple NPZ files, checks for key consistency across them, concatenates the data, and then optionally performs a deduplication step based on an epsilon threshold for all features in a row.
- Parameters:
input_files – List of paths to the input .npz files.
output_file – Path where the combined .npz file will be saved.
epsilon – Maximum absolute difference for two rows to be considered duplicates.
deduplicate – Whether to perform deduplication (default: False).
f110_scripts.datagen.waypoint_add_error module¶
Add stochastic errors to waypoint CSV files. Supports normal, uniform, and Laplace distributions for noise.
- class f110_scripts.datagen.waypoint_add_error.NoiseConfig(mean: float = 0.0, std: float = 0.05, distribution: str = 'normal', columns: str = 'x_m,y_m', seed: int | None = 42)¶
Bases:
objectConfiguration for stochastic noise injection.
- columns: str = 'x_m,y_m'¶
- distribution: str = 'normal'¶
- mean: float = 0.0¶
- seed: int | None = 42¶
- std: float = 0.05¶
- f110_scripts.datagen.waypoint_add_error.add_noise_to_waypoints(input_csv: str, output_csv: str, config: NoiseConfig) None¶
Reads a waypoint CSV and adds stochastic noise to specified columns.
- Parameters:
input_csv – Path to the input CSV file.
output_csv – Path to save the noisy CSV file.
config – Configuration parameters for noise generation.
- f110_scripts.datagen.waypoint_add_error.main() None¶
Main entry point for the waypoint error injection script.
f110_scripts.datagen.waypoint_datagen module¶
Data generation script for F1TENTH simulation.
Collects lidar scans, wall distance data, and heading errors while following waypoints. Outputs data in NPZ format for efficient storage and loading. Supports stochastic noise and drift injection to increase data variety for robust training.
- f110_scripts.datagen.waypoint_datagen.collect_data(env: Any, planner: PurePursuitPlanner, waypoints: ndarray, args: Namespace) tuple[dict[str, ndarray], int]¶
Executes simulation steps to gather LiDAR and telemetry data.
- Parameters:
env – Gymnasium environment.
planner – The autonomous controller following the path.
waypoints – The reference path array.
args – Simulation configuration arguments.
- Returns:
Dictionary of collected data channels (scans, distances, errors).
Total number of successful steps recorded.
- Return type:
A tuple containing
- f110_scripts.datagen.waypoint_datagen.create_planner(planner_type: str, waypoints: ndarray) PurePursuitPlanner¶
Creates a planner instance based on the specified type.
- Parameters:
planner_type – Type of planner to create (“pure_pursuit”).
waypoints – Reference path for the planner to follow.
- Returns:
An initialized planner instance.
- f110_scripts.datagen.waypoint_datagen.generate_output_filename(args: Namespace, num_samples: int) str¶
Constructs a descriptive filename based on simulation parameters.
- Parameters:
args – Command-line arguments containing map and planner info.
num_samples – Total count of data points collected.
- Returns:
A structured string for the output path.
- f110_scripts.datagen.waypoint_datagen.main() None¶
Main execution function.
- f110_scripts.datagen.waypoint_datagen.parse_args() Namespace¶
Parse command line arguments.
- f110_scripts.datagen.waypoint_datagen.save_data(data: dict[str, ndarray], output_path: str) None¶
Serializes the collected simulation data to a compressed NPZ file.
- Parameters:
data – Dictionary of data channels.
output_path – Destination file path.
- f110_scripts.datagen.waypoint_datagen.setup_environment(args: Namespace) tuple[Any, PurePursuitPlanner, ndarray]¶
Configures the simulation environment for data collection.
- Parameters:
args – Parsed command-line arguments.
- Returns:
A tuple containing (environment, planner, waypoints).