diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..550c1fd --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,14 @@ +# These are supported funding model platforms + +# github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] +# patreon: # Replace with a single Patreon username +# open_collective: # Replace with a single Open Collective username +ko_fi: philiplinden +# tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel +# community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry +# liberapay: # Replace with a single Liberapay username +# issuehunt: # Replace with a single IssueHunt username +# lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry +# polar: # Replace with a single Polar username +# buy_me_a_coffee: # Replace with a single Buy Me a Coffee username +# custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml new file mode 100644 index 0000000..789db9e --- /dev/null +++ b/.github/workflows/docs.yml @@ -0,0 +1,34 @@ +name: Docs + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +env: + CARGO_TERM_COLOR: always + RUST_LOG: info + +jobs: + book: + runs-on: ubuntu-20.04 + concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + steps: + - uses: actions/checkout@v2 + + - name: Setup mdBook + uses: peaceiris/actions-mdbook@v2 + with: + mdbook-version: '0.4.10' + # mdbook-version: 'latest' + + - run: mdbook build + + - name: Deploy to GitHub Pages + uses: peaceiris/actions-gh-pages@v3 + if: ${{ github.ref == 'refs/heads/main' }} + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./docs/book diff --git a/.github/workflows/extras.yml b/.github/workflows/extras.yml deleted file mode 100644 index 1b415c5..0000000 --- a/.github/workflows/extras.yml +++ /dev/null @@ -1,66 +0,0 @@ -name: Extras - -on: - push: - branches: [ "main" ] - pull_request: - branches: [ "main" ] - -env: - CARGO_TERM_COLOR: always - RUST_LOG: info - -jobs: - - book: - runs-on: ubuntu-20.04 - concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - steps: - - uses: actions/checkout@v2 - - - name: Setup mdBook - uses: peaceiris/actions-mdbook@v2 - with: - mdbook-version: '0.4.10' - - - run: mdbook build - - - name: Deploy - uses: peaceiris/actions-gh-pages@v3 - if: ${{ github.ref == 'refs/heads/main' }} - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: ./book - -# deploy: -# if: github.ref == 'refs/heads/main' -# needs: doc -# # Grant GITHUB_TOKEN the permissions required to make a Pages deployment -# permissions: -# pages: write # to deploy to Pages -# id-token: write # to verify the deployment originates from an appropriate source -# # Deploy to the github-pages environment -# environment: -# name: github-pages -# url: ${{ steps.deployment.outputs.page_url }} -# runs-on: ubuntu-latest -# steps: -# - uses: actions/checkout@v3 -# with: -# fetch-depth: 0 - -# - uses: actions/download-artifact@v4 -# with: -# name: doc -# path: ${{ github.workspace }} - -# - name: Upload Pages artifact -# uses: actions/upload-pages-artifact@v3 -# with: -# path: target/doc - -# - name: Deploy to GitHub Pages -# id: deployment -# uses: actions/deploy-pages@v4 -# if: github.event_name != 'pull_request' diff --git a/Cargo.toml b/Cargo.toml index 952077a..bdf7399 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,55 +1,20 @@ -[package] +[workspace] +resolver = "2" # Important for Bevy +members = [ + "crates/yahs", + "crates/yahs-cli", + "crates/yahs-ui" +] + +[workspace.package] name = "yahs" description = "Yet Another HAB Simulator" version = "0.4.0" authors = ["Philip Linden "] readme = "README.md" -license = "MIT or Apache-2.0" -edition = "2021" - -default-run = "yahs" - -# When importing this crate as a dependency, use the simulator library as "yahs" -[lib] -name = "yahs" -path = "src/simulator/src/lib.rs" - -# When running this project as a CLI, use the CLI binary as "yahs" -[[bin]] -name = "yahs" -path = "src/cli/src/main.rs" - -# These are the dependencies when building the CLI from the project root -[dependencies] -# Simulator dependencies -yahs-simulator = { path = "src/simulator" } -bevy = { workspace = true } -avian3d = { workspace = true } -bevy-trait-query = { workspace = true } - -# CLI dependencies -yahs-cli = { path = "src/cli" } -bevy_ratatui = "0.7.0" -ratatui = "0.29" -color-eyre = "0.6.3" -crossterm = "0.28.1" - -[features] -default = ["dev"] -dev = ["yahs-cli/dev", "yahs-simulator/dev"] - -[workspace.package] -authors = ["Philip Linden "] edition = "2021" license = "MIT or Apache-2.0" - -[workspace] -resolver = "2" # Important for Bevy -members = [ - "src/simulator", - "src/cli", - "src/ui" -] +license-file = "LICENSE-APACHE" [workspace.dependencies] # Shared dependencies with fixed versions @@ -59,21 +24,6 @@ bevy = { version = "0.15.0", default-features = false, features = [ avian3d = { git = "https://github.com/Jondolf/avian.git", branch = "main" } bevy-trait-query = "0.7.0" -# ----------------------------------------------------------------------------- -# Some Bevy optimizations -# ----------------------------------------------------------------------------- - -# Idiomatic Bevy code often triggers these lints, and the CI workflow treats -# them as errors. In some cases they may still signal poor code quality however, -# so consider commenting out these lines. -[lints.clippy] -# Bevy supplies arguments to systems via dependency injection, so it's -# natural for systems to request more than 7 arguments -- which triggers -# this lint. -too_many_arguments = "allow" -# Queries that access many components may trigger this lint. -type_complexity = "allow" - # Compile with Performance Optimizations: # https://bevyengine.org/learn/quick-start/getting-started/setup/#compile-with-performance-optimizations @@ -92,7 +42,8 @@ debug = false [profile.release] # Compile the entire crate as one unit. Slows compile times, marginal # improvements. -codegen-units = 1 +# codegen-units = 1 + # Optimize with size in mind (also try "z", sometimes it is better). # Slightly slows compile times, great improvements to file size and runtime # performance. diff --git a/README.md b/README.md index 1854d29..95a20ce 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,8 @@ A high altitude balloon flight simulator built in [Bevy](https://bevyengine.org/) with Rust, inspired by -[tkschuler/EarthSHAB](https://github.com/tkschuler/EarthSHAB). +[tkschuler/EarthSHAB](https://github.com/tkschuler/EarthSHAB) and +[mfc-apps](https://github.com/Brickworks/mfc-apps). [devlog](docs/devlog.md) @@ -28,7 +29,7 @@ fn main() { ``` Then you can use all of the components and systems from the -[`yahs-simulator`](./src/simulator/README.md) crate. +[`yahs`](./crates/yahs/README.md) crate. ### As an application diff --git a/src/cli/Cargo.toml b/crates/yahs-cli/Cargo.toml similarity index 91% rename from src/cli/Cargo.toml rename to crates/yahs-cli/Cargo.toml index e1f8448..9ed0e11 100644 --- a/src/cli/Cargo.toml +++ b/crates/yahs-cli/Cargo.toml @@ -11,7 +11,7 @@ name = "yahs-cli" path = "src/main.rs" [dependencies] -yahs-simulator = { path = "../simulator" } +yahs = { path = "../yahs" } bevy = { workspace = true, features = [ "bevy_state", "multi_threaded", diff --git a/src/cli/README.md b/crates/yahs-cli/README.md similarity index 100% rename from src/cli/README.md rename to crates/yahs-cli/README.md diff --git a/src/cli/src/lib.rs b/crates/yahs-cli/src/lib.rs similarity index 100% rename from src/cli/src/lib.rs rename to crates/yahs-cli/src/lib.rs diff --git a/src/cli/src/main.rs b/crates/yahs-cli/src/main.rs similarity index 100% rename from src/cli/src/main.rs rename to crates/yahs-cli/src/main.rs diff --git a/src/ui/Cargo.toml b/crates/yahs-ui/Cargo.toml similarity index 92% rename from src/ui/Cargo.toml rename to crates/yahs-ui/Cargo.toml index 95a7e72..49f39ff 100644 --- a/src/ui/Cargo.toml +++ b/crates/yahs-ui/Cargo.toml @@ -11,7 +11,7 @@ name = "yahs-ui" path = "src/main.rs" [dependencies] -yahs-simulator = { path = "../simulator" } +yahs = { path = "../yahs" } bevy = { workspace = true, default-features = false, features = [ "bevy_asset", "bevy_core_pipeline", @@ -38,6 +38,6 @@ dev = [ "avian3d/debug-plugin", "bevy/bevy_dev_tools", "bevy/dynamic_linking", - "yahs-simulator/dev", + "yahs/dev", ] inspect = ["bevy-inspector-egui"] diff --git a/crates/yahs-ui/README.md b/crates/yahs-ui/README.md new file mode 100644 index 0000000..5820ca5 --- /dev/null +++ b/crates/yahs-ui/README.md @@ -0,0 +1 @@ +# yahs-ui diff --git a/src/ui/src/camera.rs b/crates/yahs-ui/src/camera.rs similarity index 99% rename from src/ui/src/camera.rs rename to crates/yahs-ui/src/camera.rs index 0f90a3c..6996393 100644 --- a/src/ui/src/camera.rs +++ b/crates/yahs-ui/src/camera.rs @@ -6,7 +6,7 @@ use bevy::{ use std::f32::consts::PI; use super::controls::{CameraControls, KeyBindingsConfig}; -use yahs_simulator::prelude::Balloon; +use yahs::prelude::Balloon; pub struct CameraPlugin; diff --git a/src/ui/src/controls.rs b/crates/yahs-ui/src/controls.rs similarity index 98% rename from src/ui/src/controls.rs rename to crates/yahs-ui/src/controls.rs index b261fd0..87eddd0 100644 --- a/src/ui/src/controls.rs +++ b/crates/yahs-ui/src/controls.rs @@ -1,6 +1,6 @@ use bevy::prelude::*; -use yahs_simulator::prelude::{SimState, TimeScaleOptions}; +use yahs::prelude::{SimState, TimeScaleOptions}; pub struct ControlsPlugin; diff --git a/src/ui/src/dev_tools.rs b/crates/yahs-ui/src/dev_tools.rs similarity index 100% rename from src/ui/src/dev_tools.rs rename to crates/yahs-ui/src/dev_tools.rs diff --git a/src/ui/src/gizmos.rs b/crates/yahs-ui/src/gizmos.rs similarity index 98% rename from src/ui/src/gizmos.rs rename to crates/yahs-ui/src/gizmos.rs index c30d914..04855de 100644 --- a/src/ui/src/gizmos.rs +++ b/crates/yahs-ui/src/gizmos.rs @@ -1,6 +1,6 @@ use bevy::{color::palettes::basic::*, prelude::*}; -use crate::simulator::forces::Force; +use yahs::forces::Force; const ARROW_SCALE: f32 = 0.1; diff --git a/src/ui/src/lib.rs b/crates/yahs-ui/src/lib.rs similarity index 100% rename from src/ui/src/lib.rs rename to crates/yahs-ui/src/lib.rs diff --git a/src/ui/src/main.rs b/crates/yahs-ui/src/main.rs similarity index 96% rename from src/ui/src/main.rs rename to crates/yahs-ui/src/main.rs index 4e08fcd..b0e5598 100644 --- a/src/ui/src/main.rs +++ b/crates/yahs-ui/src/main.rs @@ -19,7 +19,7 @@ use bevy::{ asset::AssetMetaCheck, }; -use yahs_simulator::prelude::SimulatorPlugins; +use yahs::prelude::SimulatorPlugins; fn main() { App::new() diff --git a/src/ui/src/scene.rs b/crates/yahs-ui/src/scene.rs similarity index 98% rename from src/ui/src/scene.rs rename to crates/yahs-ui/src/scene.rs index 853991c..46a854e 100644 --- a/src/ui/src/scene.rs +++ b/crates/yahs-ui/src/scene.rs @@ -2,7 +2,7 @@ use avian3d::prelude::*; use bevy::prelude::*; use std::f32::consts::PI; -use yahs_simulator::prelude::*; +use yahs::prelude::*; pub struct ScenePlugin; diff --git a/src/simulator/Cargo.toml b/crates/yahs/Cargo.toml similarity index 94% rename from src/simulator/Cargo.toml rename to crates/yahs/Cargo.toml index 261c979..b333bfe 100644 --- a/src/simulator/Cargo.toml +++ b/crates/yahs/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "yahs-simulator" +name = "yahs" version = "0.4.0" description = "High Altitude Balloon simulation plugin for Bevy" edition = "2021" diff --git a/crates/yahs/README.md b/crates/yahs/README.md new file mode 100644 index 0000000..f8feb65 --- /dev/null +++ b/crates/yahs/README.md @@ -0,0 +1 @@ +# yahs diff --git a/src/simulator/src/atmosphere.rs b/crates/yahs/src/atmosphere.rs similarity index 100% rename from src/simulator/src/atmosphere.rs rename to crates/yahs/src/atmosphere.rs diff --git a/src/simulator/src/balloon.rs b/crates/yahs/src/balloon.rs similarity index 100% rename from src/simulator/src/balloon.rs rename to crates/yahs/src/balloon.rs diff --git a/src/simulator/src/core.rs b/crates/yahs/src/core.rs similarity index 100% rename from src/simulator/src/core.rs rename to crates/yahs/src/core.rs diff --git a/src/simulator/src/forces/aero.rs b/crates/yahs/src/forces/aero.rs similarity index 100% rename from src/simulator/src/forces/aero.rs rename to crates/yahs/src/forces/aero.rs diff --git a/src/simulator/src/forces/body.rs b/crates/yahs/src/forces/body.rs similarity index 100% rename from src/simulator/src/forces/body.rs rename to crates/yahs/src/forces/body.rs diff --git a/src/simulator/src/forces/mod.rs b/crates/yahs/src/forces/mod.rs similarity index 100% rename from src/simulator/src/forces/mod.rs rename to crates/yahs/src/forces/mod.rs diff --git a/src/simulator/src/forces/scratch.rs b/crates/yahs/src/forces/scratch.rs similarity index 100% rename from src/simulator/src/forces/scratch.rs rename to crates/yahs/src/forces/scratch.rs diff --git a/src/simulator/src/heat.rs b/crates/yahs/src/heat.rs similarity index 100% rename from src/simulator/src/heat.rs rename to crates/yahs/src/heat.rs diff --git a/src/simulator/src/ideal_gas.rs b/crates/yahs/src/ideal_gas.rs similarity index 100% rename from src/simulator/src/ideal_gas.rs rename to crates/yahs/src/ideal_gas.rs diff --git a/src/simulator/src/lib.rs b/crates/yahs/src/lib.rs similarity index 100% rename from src/simulator/src/lib.rs rename to crates/yahs/src/lib.rs diff --git a/src/simulator/src/mod.rs b/crates/yahs/src/mod.rs similarity index 100% rename from src/simulator/src/mod.rs rename to crates/yahs/src/mod.rs diff --git a/src/simulator/src/payload.rs b/crates/yahs/src/payload.rs similarity index 100% rename from src/simulator/src/payload.rs rename to crates/yahs/src/payload.rs diff --git a/src/simulator/src/properties.rs b/crates/yahs/src/properties.rs similarity index 100% rename from src/simulator/src/properties.rs rename to crates/yahs/src/properties.rs diff --git a/src/simulator/src/time.rs b/crates/yahs/src/time.rs similarity index 100% rename from src/simulator/src/time.rs rename to crates/yahs/src/time.rs diff --git a/docs/SUMMARY.md b/docs/SUMMARY.md index 70b16c7..871d36f 100644 --- a/docs/SUMMARY.md +++ b/docs/SUMMARY.md @@ -1,11 +1,17 @@ +# Summary + [Introduction](index.md) --- -- [yahs-sim](crates/yahs-sim/README.md) -- [yahs-ui](crates/yahs-ui/README.md) -- [yahs-cli](crates/yahs-cli/README.md) +# Crates + +- [yahs](../crates/yahs/README.md) +- [yahs-ui](../crates/yahs-ui/README.md) +- [yahs-cli](../crates/yahs-cli/README.md) --- +# Development + [Devlog](devlog.md) diff --git a/docs/devlog.md b/docs/devlog.md index 4af3818..94703af 100644 --- a/docs/devlog.md +++ b/docs/devlog.md @@ -1,5 +1,24 @@ # development log +## 2024-12-16 + +I'm leaning into the use case of running this as the "outside world" interface +for a software-in-the-loop simulation. I think there are a few things I need to +figure out before that is possible: + +- Host the simulation as a server or otherwise "free running" environment. +- Connect a client application that can send commands and receive telemetry or + data from sensors, where the telemetry is created by the server and supplied + to the client over normal network protocols that it would expect from actual + hardware. +- The server and client applications should be able to run in a headless mode, + or otherwise without a UI. + +It would be ideal if this was not required---I'd like to be able to run a +completely virtual vehicle along with a software-in-the-loop simulation. In a +sense this is the same as running a completely passive vehicle in the sim while +also allowing for an active vehicle too. + ## 2024-12-15 - Added [mdbook](https://github.com/rust-lang/mdBook) to the project. diff --git a/docs/index.md b/docs/index.md index 3d07d7d..777dab0 100644 --- a/docs/index.md +++ b/docs/index.md @@ -8,11 +8,52 @@ simulation. This project is split into three parts: -- [yahs-sim](https://github.com/philiplinden/yahs-sim) is the main simulation - crate. It is a Bevy plugin that can be added to any Bevy project. -- [yahs-ui](https://github.com/philiplinden/yahs-ui) is a simple UI for the - simulation. It is not required but it is useful for visualizing the +- [yahs](crates/yahs/README.md) is the main simulation crate. It is a Bevy + plugin that can be added to any Bevy project. +- [yahs-ui](crates/yahs-ui/README.md) is a simple UI for the simulation. It is + not required but it is useful for visualizing the simulation and for simulation and for debugging. -- [yahs-cli](https://github.com/philiplinden/yahs-cli) is a command line tool - for running the simulation. It is useful for testing out the simulation - without having to deal with the UI. +- [yahs-cli](crates/yahs-cli/README.md) is a command line tool for running the + simulation. It is useful for testing out the simulation without having to deal + with the UI or for running the simulation in a headless mode. + + +## Usage + +### As a library + +Add `yahs` to your `Cargo.toml`: + +```toml +[dependencies] +yahs = "0.4.0" +``` + +Then, add the `SimulatorPlugins` to your Bevy app: + +```rust +use yahs::prelude::SimulatorPlugins; + +fn main() { + App::new().add_plugins(SimulatorPlugins); +} +``` + +Then you can use all of the components and systems from the +[`yahs`](./crates/yahs/README.md) crate. + + +### As an application + +Running this package as a standalone application compiles all of the crates +and runs the CLI by default: + +```bash +cargo run +``` + +Force the standalone application to run the GUI instead of the CLI: + +```bash +cargo run --bin yahs-ui +``` diff --git a/src/simulator/README.md b/src/simulator/README.md deleted file mode 100644 index e69de29..0000000 diff --git a/src/ui/README.md b/src/ui/README.md deleted file mode 100644 index e69de29..0000000