A comprehensive, production-ready Python package for generating and visualizing bio-inspired navigation research data. This project provides sophisticated data simulation, high-quality visualization, and robust analysis tools for bio-inspired navigation research.
- π Sophisticated Data Simulation: Advanced trajectory generation with periodic error correction
- β‘ Energy Consumption Analysis: Realistic energy consumption modeling with statistical validation
- π High-Quality Visualizations: Publication-ready plots with customizable styling
- π§ Modular Architecture: Clean, maintainable code structure with proper separation of concerns
- π Comprehensive Logging: Detailed logging and error tracking throughout the pipeline
- βοΈ Configuration Management: Centralized configuration with validation
- π§ͺ Data Validation: Built-in data quality checks and statistical analysis
- π¦ Production Ready: Proper packaging, error handling, and documentation
- π€ ROS2 Integration: Optional ROS2 node for real-time data streaming and research prototyping
- π³ Containerized Deployment: Ready-to-use Docker and Compose setup for reproducible runs
- Installation
- Quick Start
- Usage
- Project Structure
- Configuration
- API Documentation
- Examples
- Contributing
- License
- Python 3.8 or higher
- pip (Python package installer)
# Clone the repository
git clone https://github.com/yourusername/bio-nav-data.git
cd bio-nav-data
# Install required packages
pip install -r requirements.txt# Run the application to verify everything works
python main.py --config-only# Generate all data and plots
python main.py
# Show configuration
python main.py --config-only
# Validate setup
python main.py --validatefrom bio_nav_data import BioNavDataGenerator, Config
# Initialize with custom configuration
config = Config()
generator = BioNavDataGenerator(config)
# Run complete pipeline
generator.run_complete_pipeline()The application provides a comprehensive command-line interface:
# Basic usage - generate all data and plots
python main.py
# Show configuration details
python main.py --config-only
# Validate configuration
python main.py --validate
# Set custom output directory
python main.py --output-dir /path/to/output
# Set logging level
python main.py --log-level DEBUG
# Get help
python main.py --helpThe application uses a centralized configuration system:
from bio_nav_data.utils.config import Config
# Create custom configuration
config = Config(base_path="/custom/path")
# Update parameters
config.update_trajectory_params(n_points=200, distance_m=150)
config.update_energy_params(n_trials=150)
config.update_plot_params(dpi=600)
# Validate configuration
validation = config.validate_config()Generate different types of research data:
from bio_nav_data.data_generators import (
TrajectoryDataGenerator,
EnergyDataGenerator,
create_performance_summary
)
# Generate trajectory data
traj_gen = TrajectoryDataGenerator(n_points=101, distance_m=100)
trajectory_df = traj_gen.generate()
# Generate energy consumption data
energy_gen = EnergyDataGenerator(n_trials=100)
energy_df = energy_gen.generate()
# Generate performance summary
performance_df = create_performance_summary()Create publication-ready plots:
from bio_nav_data.visualizers.plots import (
plot_trajectory,
plot_energy_consumption,
plot_performance_comparison
)
# Create trajectory plot
plot_trajectory(trajectory_df, save_path="trajectory.png")
# Create energy consumption plot
plot_energy_consumption(energy_df, save_path="energy.png")
# Create performance comparison
plot_performance_comparison(performance_df, save_path="performance.png")bio_nav_data/
βββ bio_nav_data/ # Main package
β βββ __init__.py # Package initialization
β βββ data_generators/ # Data generation modules
β β βββ __init__.py
β β βββ trajectory.py # Trajectory data generator
β β βββ energy.py # Energy consumption generator
β β βββ performance.py # Performance metrics generator
β βββ visualizers/ # Visualization modules
β β βββ __init__.py
β β βββ plots.py # Plotting functions
β βββ utils/ # Utility modules
β βββ __init__.py
β βββ config.py # Configuration management
β βββ logger.py # Logging utilities
βββ main.py # Main application script
βββ requirements.txt # Python dependencies
βββ README.md # This file
βββ .gitignore # Git ignore rules
βββ output/ # Generated data files
βββ plots/ # Generated plots
βββ logs/ # Application logs
The application comes with sensible defaults:
# Trajectory parameters
trajectory_params = {
'n_points': 101, # Number of trajectory points
'distance_m': 100.0, # Total distance in meters
'correction_interval': 20, # Error correction interval
'random_seed': 42 # Random seed for reproducibility
}
# Energy parameters
energy_params = {
'n_trials': 100, # Number of trials per method
'random_seed': 42 # Random seed for reproducibility
}
# Plot parameters
plot_params = {
'dpi': 300, # Plot resolution
'figsize': (10, 8), # Figure size
'save_format': 'png', # Output format
'style': 'seaborn-v0_8-whitegrid' # Plot style
}You can customize any aspect of the configuration:
from bio_nav_data.utils.config import Config
config = Config()
# Update trajectory parameters
config.update_trajectory_params(
n_points=200,
distance_m=150,
correction_interval=30
)
# Update energy parameters
config.update_energy_params(n_trials=200)
# Update plot parameters
config.update_plot_params(dpi=600, figsize=(12, 10))Main application class for orchestrating data generation and visualization.
class BioNavDataGenerator:
def __init__(self, config: Optional[Config] = None)
def generate_all_data(self) -> Dict[str, Any]
def save_all_data(self, data: Dict[str, Any]) -> None
def generate_all_plots(self, data: Dict[str, Any]) -> None
def run_complete_pipeline(self) -> NoneGenerates sophisticated trajectory data with drift simulation and error correction.
class TrajectoryDataGenerator:
def __init__(self, n_points: int = 101, distance_m: float = 100.0,
correction_interval: int = 20, random_seed: int = 42)
def generate(self) -> pd.DataFrame
def get_statistics(self, df: pd.DataFrame) -> dictGenerates realistic energy consumption data with statistical validation.
class EnergyDataGenerator:
def __init__(self, n_trials: int = 100, random_seed: int = 42)
def generate(self) -> pd.DataFrame
def get_statistics(self, df: pd.DataFrame) -> Dict[str, Dict[str, float]]
def calculate_improvements(self, df: pd.DataFrame) -> Dict[str, float]
def validate_data_quality(self, df: pd.DataFrame) -> Dict[str, bool]Creates high-quality trajectory plots.
def plot_trajectory(df: pd.DataFrame,
save_path: Optional[str] = None,
figsize: Tuple[int, int] = (10, 8),
dpi: int = 300,
show_grid: bool = True,
show_legend: bool = True) -> plt.FigureCreates energy consumption box plots with statistical annotations.
def plot_energy_consumption(df: pd.DataFrame,
save_path: Optional[str] = None,
figsize: Tuple[int, int] = (10, 8),
dpi: int = 300,
show_outliers: bool = True,
show_statistics: bool = True) -> plt.Figurefrom bio_nav_data import BioNavDataGenerator
# Create generator
generator = BioNavDataGenerator()
# Generate all data
data = generator.generate_all_data()
# Access individual datasets
trajectory_df = data['trajectory']
energy_df = data['energy']
performance_df = data['performance']
print(f"Generated {len(trajectory_df)} trajectory points")
print(f"Generated {len(energy_df)} energy measurements")
print(f"Generated {len(performance_df)} performance metrics")from bio_nav_data import BioNavDataGenerator
from bio_nav_data.utils.config import Config
# Create custom configuration
config = Config()
config.update_trajectory_params(n_points=200, distance_m=150)
config.update_energy_params(n_trials=150)
config.update_plot_params(dpi=600)
# Use custom configuration
generator = BioNavDataGenerator(config)
generator.run_complete_pipeline()from bio_nav_data.data_generators import TrajectoryDataGenerator
from bio_nav_data.visualizers.plots import plot_trajectory
# Generate trajectory data
traj_gen = TrajectoryDataGenerator(n_points=101, distance_m=100)
trajectory_df = traj_gen.generate()
# Get statistics
stats = traj_gen.get_statistics(trajectory_df)
print(f"Traditional SLAM drift: {stats['traditional_slam_avg_drift']:.3f}m")
print(f"Our framework error: {stats['our_framework_avg_error']:.3f}m")
print(f"Improvement ratio: {stats['improvement_ratio']:.2f}x")
# Create plot
plot_trajectory(trajectory_df, save_path="custom_trajectory.png")from bio_nav_data.data_generators import EnergyDataGenerator
# Generate energy data
energy_gen = EnergyDataGenerator(n_trials=100)
energy_df = energy_gen.generate()
# Get comprehensive statistics
stats = energy_gen.get_statistics(energy_df)
improvements = energy_gen.calculate_improvements(energy_df)
validation = energy_gen.validate_data_quality(energy_df)
# Print results
for method, method_stats in stats.items():
print(f"{method}:")
print(f" Mean: {method_stats['mean']:.2f}W")
print(f" Std: {method_stats['std']:.2f}W")
print(f" Median: {method_stats['median']:.2f}W")
print(f"\nImprovements:")
for baseline, improvement in improvements.items():
print(f" {baseline}: {improvement:.1f}% reduction")
print(f"\nData Quality: {all(validation.values())}")Run the complete pipeline without installing local dependencies by using the provided container assets.
docker build -t bio-nav-data:latest .docker run --rm -v "$(pwd)/output:/app/output" -v "$(pwd)/plots:/app/plots" -v "$(pwd)/logs:/app/logs" bio-nav-data:latest --log-level INFOLOG_LEVEL=DEBUG docker compose up --buildThe Compose stack mounts the local output, plots, and logs folders so generated artifacts persist on the host. Override CLI arguments by editing docker-compose.yml or passing a different LOG_LEVEL environment variable at runtime.
An optional ROS2 package is included under ros2/src/bio_nav_data_ros. It wraps the
Python pipeline in a ROS2 node for real-time experimentation and visualization.
- Install ROS2 (Humble or newer) and ensure
colconis available.- macOS/Linux: install ROS2 from the official instructions, then
pip install colcon-common-extensionsif needed. - Source the ROS2 environment before building:
source /opt/ros/humble/setup.bash(path may vary).
- macOS/Linux: install ROS2 from the official instructions, then
- Install the core Python package so the node can import the pipeline:
pip install -e . - Build the ROS2 workspace and source the overlay:
cd ros2 colcon build --packages-select bio_nav_data_ros source install/setup.bash
- Launch the node:
ros2 launch bio_nav_data_ros bio_nav_data.launch.py
- Trajectory paths:
bio_nav_data/trajectory/path/{ground_truth, our_framework, traditional_slam}(nav_msgs/Path) - Data snapshots:
bio_nav_data/trajectory/json,bio_nav_data/energy/json,bio_nav_data/performance/json(std_msgs/String, JSON payloads) - Analytics summary:
bio_nav_data/analytics/json(std_msgs/String, statistics & validation results) - Trigger new run:
bio_nav_data/generate(std_srvs/Trigger)
| Parameter | Type | Default | Description |
|---|---|---|---|
publish_frequency_hz |
double | 1.0 |
Rate for republishing cached messages |
frame_id |
string | map |
Coordinate frame stamped on nav_msgs/Path messages |
auto_generate_on_startup |
bool | true |
Run the pipeline automatically when the node starts |
output_directory |
string | `` | Optional override for generated file locations |
save_results_to_disk |
bool | false |
Persist CSV outputs on each run |
generate_plots |
bool | false |
Produce plots alongside CSV outputs |
trajectory.* |
mixed | defaults from Config |
Fine-tune trajectory generator settings |
energy.* |
mixed | defaults from Config |
Fine-tune energy generator settings |
We welcome contributions! Please follow these steps:
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Make your changes: Follow the coding standards
- Add tests: Ensure your code is well-tested
- Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request: Describe your changes clearly
# Clone the repository
git clone https://github.com/yourusername/bio-nav-data.git
cd bio-nav-data
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install development dependencies
pip install -r requirements.txt
pip install pytest black flake8
# Run tests
pytest
# Format code
black .
# Check code quality
flake8- Follow PEP 8 style guidelines
- Use type hints for all function parameters and return values
- Write comprehensive docstrings
- Add logging for important operations
- Include error handling for robust operation
- Write unit tests for new functionality
This project is licensed under the MIT License - see the LICENSE file for details.
- Research team for the original bio-inspired navigation concepts
- Open source community for the excellent Python libraries used
- Contributors and reviewers for their valuable feedback
If you encounter any issues or have questions:
- Check the documentation
- Search existing issues
- Create a new issue with detailed information
- Contact the development team
Made with β€οΈ for the research community