Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 98 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions avionics-mock/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ edition = "2024"

[dependencies]
protocols = { version = "0.1.0", path = "../protocols" }
rand = "0.9.2"
tokio = { version = "1.48.0", features = ["macros", "rt-multi-thread", "time"] }

[lints]
Expand Down
10 changes: 9 additions & 1 deletion avionics-mock/src/sim.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! Simulates the rockets ascent and decent.
use protocols::api::{Location, Velocity};
use rand::Rng;

use crate::WICHLEN;

Expand Down Expand Up @@ -98,7 +99,14 @@
/// Causes the simulation to simulate opening the drogue parachute.
pub fn deploy_drogue(&mut self) {
if self.deployment_status == DeploymentStatus::None {
self.deployment_status = DeploymentStatus::Drogue;
let mut rng = rand::thread_rng();

Check failure on line 102 in avionics-mock/src/sim.rs

View workflow job for this annotation

GitHub Actions / clippy results

[clippy results] avionics-mock/src/sim.rs#L102

error: use of deprecated function `rand::thread_rng`: Renamed to `rng` --> avionics-mock/src/sim.rs:102:33 | 102 | let mut rng = rand::thread_rng(); | ^^^^^^^^^^ | = note: `-D deprecated` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(deprecated)]`
Raw output
avionics-mock/src/sim.rs:102:33:e:error: use of deprecated function `rand::thread_rng`: Renamed to `rng`
   --> avionics-mock/src/sim.rs:102:33
    |
102 |             let mut rng = rand::thread_rng();
    |                                 ^^^^^^^^^^
    |
    = note: `-D deprecated` implied by `-D warnings`
    = help: to override `-D warnings` add `#[allow(deprecated)]`


__END__

Check failure on line 102 in avionics-mock/src/sim.rs

View workflow job for this annotation

GitHub Actions / clippy results

[clippy results] avionics-mock/src/sim.rs#L102

error: use of deprecated function `rand::thread_rng`: Renamed to `rng` --> avionics-mock/src/sim.rs:102:33 | 102 | let mut rng = rand::thread_rng(); | ^^^^^^^^^^ | = note: `-D deprecated` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(deprecated)]`
Raw output
avionics-mock/src/sim.rs:102:33:e:error: use of deprecated function `rand::thread_rng`: Renamed to `rng`
   --> avionics-mock/src/sim.rs:102:33
    |
102 |             let mut rng = rand::thread_rng();
    |                                 ^^^^^^^^^^
    |
    = note: `-D deprecated` implied by `-D warnings`
    = help: to override `-D warnings` add `#[allow(deprecated)]`


__END__
let randomstuff: u32 = rng.random();
if randomstuff % 2 == 0 {

Check failure on line 104 in avionics-mock/src/sim.rs

View workflow job for this annotation

GitHub Actions / clippy results

[clippy results] avionics-mock/src/sim.rs#L104

error: manual implementation of `.is_multiple_of()` --> avionics-mock/src/sim.rs:104:16 | 104 | if randomstuff % 2 == 0 { | ^^^^^^^^^^^^^^^^^^^^ help: replace with: `randomstuff.is_multiple_of(2)` | = help: for further information visit https://rust-lang.github.io/rust-clippy/beta/index.html#manual_is_multiple_of = note: `-D clippy::manual-is-multiple-of` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::manual_is_multiple_of)]`
Raw output
avionics-mock/src/sim.rs:104:16:e:error: manual implementation of `.is_multiple_of()`
   --> avionics-mock/src/sim.rs:104:16
    |
104 |             if randomstuff % 2 == 0 {
    |                ^^^^^^^^^^^^^^^^^^^^ help: replace with: `randomstuff.is_multiple_of(2)`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/beta/index.html#manual_is_multiple_of
    = note: `-D clippy::manual-is-multiple-of` implied by `-D warnings`
    = help: to override `-D warnings` add `#[allow(clippy::manual_is_multiple_of)]`


__END__

Check failure on line 104 in avionics-mock/src/sim.rs

View workflow job for this annotation

GitHub Actions / clippy results

[clippy results] avionics-mock/src/sim.rs#L104

error: manual implementation of `.is_multiple_of()` --> avionics-mock/src/sim.rs:104:16 | 104 | if randomstuff % 2 == 0 { | ^^^^^^^^^^^^^^^^^^^^ help: replace with: `randomstuff.is_multiple_of(2)` | = help: for further information visit https://rust-lang.github.io/rust-clippy/beta/index.html#manual_is_multiple_of = note: `-D clippy::manual-is-multiple-of` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::manual_is_multiple_of)]`
Raw output
avionics-mock/src/sim.rs:104:16:e:error: manual implementation of `.is_multiple_of()`
   --> avionics-mock/src/sim.rs:104:16
    |
104 |             if randomstuff % 2 == 0 {
    |                ^^^^^^^^^^^^^^^^^^^^ help: replace with: `randomstuff.is_multiple_of(2)`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/beta/index.html#manual_is_multiple_of
    = note: `-D clippy::manual-is-multiple-of` implied by `-D warnings`
    = help: to override `-D warnings` add `#[allow(clippy::manual_is_multiple_of)]`


__END__
Comment on lines +103 to +104
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This gives some clippy errors, and personally I prefer making a f32 and checking < p for arbitrary probability.

eprintln!("Drogue parachute deployment failed!");
self.deployment_status = DeploymentStatus::BrokenChutes;
} else {
self.deployment_status = DeploymentStatus::Drogue;
}
} else {
eprintln!("Drogue parachute already deployed");
}
Expand Down
Loading