Update criterion to 0.8 and toml to 0.9
Upgrade benchmark dependencies to latest versions. Criterion 0.8 requires using std::hint::black_box instead of criterion::black_box. Also includes minor formatting improvements from rustfmt.
This commit is contained in:
@@ -14,7 +14,7 @@ scenario = ["serde_yaml"] # Enable YAML scenario parsing for tests
|
||||
[dependencies]
|
||||
log = "0.4" # Logging
|
||||
serde = { version = "1.0", features = ["derive"] } # Config serialization
|
||||
toml = { version = "0.8", default-features = false, features = ["parse"] } # TOML config files
|
||||
toml = { version = "0.9", default-features = false, features = ["parse", "serde"] } # TOML config files
|
||||
rayon = "1.11" # Data parallelism for scan matching
|
||||
serde_yaml = { version = "0.9", optional = true } # YAML scenario parsing (optional)
|
||||
|
||||
@@ -22,7 +22,7 @@ serde_yaml = { version = "0.9", optional = true } # YAML scenario parsing (opti
|
||||
env_logger = "0.11" # Test logging
|
||||
approx = "0.5" # Approximate comparisons (tests only)
|
||||
image = { version = "0.25", default-features = false, features = ["png", "pnm"] }
|
||||
criterion = "0.5" # Benchmarking
|
||||
criterion = "0.8" # Benchmarking
|
||||
serde_yaml = "0.9" # YAML for tests (always available in tests)
|
||||
sangam-io = { path = "../sangam-io", features = ["mock"] } # Mock device for examples
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
//! Benchmark evaluation metrics performance.
|
||||
|
||||
use criterion::{BenchmarkId, Criterion, black_box, criterion_group, criterion_main};
|
||||
use criterion::{BenchmarkId, Criterion, criterion_group, criterion_main};
|
||||
use std::hint::black_box;
|
||||
use vastu_slam::LidarScan;
|
||||
use vastu_slam::Pose2D;
|
||||
use vastu_slam::evaluation::{
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
//! Benchmark grid operations performance.
|
||||
|
||||
use criterion::{BenchmarkId, Criterion, black_box, criterion_group, criterion_main};
|
||||
use criterion::{BenchmarkId, Criterion, criterion_group, criterion_main};
|
||||
use std::f32::consts::PI;
|
||||
use std::hint::black_box;
|
||||
use vastu_slam::matching::PrecomputedGrids;
|
||||
use vastu_slam::{LidarScan, MapConfig, OccupancyGridMap, Pose2D};
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
//! Benchmark scan matching performance.
|
||||
|
||||
use criterion::{BenchmarkId, Criterion, black_box, criterion_group, criterion_main};
|
||||
use criterion::{BenchmarkId, Criterion, criterion_group, criterion_main};
|
||||
use std::f32::consts::PI;
|
||||
use std::hint::black_box;
|
||||
use vastu_slam::{
|
||||
CorrelativeMatcher, CorrelativeMatcherConfig, LidarScan, MapConfig, OccupancyGridMap, Pose2D,
|
||||
};
|
||||
|
||||
@@ -341,10 +341,8 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let (linear, angular) = cmd.velocities();
|
||||
|
||||
// Determine if this command uses encoder-based or time-based execution
|
||||
let use_encoder_verification = matches!(
|
||||
cmd,
|
||||
Command::MoveDistance { .. } | Command::Rotate { .. }
|
||||
);
|
||||
let use_encoder_verification =
|
||||
matches!(cmd, Command::MoveDistance { .. } | Command::Rotate { .. });
|
||||
|
||||
if use_encoder_verification {
|
||||
// Get target wheel distances for encoder verification
|
||||
@@ -407,8 +405,11 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
// Check if target achieved (directional - stops before crossing)
|
||||
let left_done =
|
||||
wheel_reached_target(delta_left, expected_left_ticks, ENCODER_TOLERANCE_TICKS);
|
||||
let right_done =
|
||||
wheel_reached_target(delta_right, expected_right_ticks, ENCODER_TOLERANCE_TICKS);
|
||||
let right_done = wheel_reached_target(
|
||||
delta_right,
|
||||
expected_right_ticks,
|
||||
ENCODER_TOLERANCE_TICKS,
|
||||
);
|
||||
|
||||
if left_done && right_done {
|
||||
log::debug!(
|
||||
|
||||
@@ -135,7 +135,10 @@ impl Command {
|
||||
(duration_secs * 1000.0) as u64
|
||||
})
|
||||
}
|
||||
Command::Rotate { degrees, duration_ms } => {
|
||||
Command::Rotate {
|
||||
degrees,
|
||||
duration_ms,
|
||||
} => {
|
||||
// Use provided duration or auto-calculate from angular velocity
|
||||
duration_ms.unwrap_or_else(|| {
|
||||
let radians = degrees.to_radians();
|
||||
@@ -446,7 +449,11 @@ commands:
|
||||
let cmd1 = &scenario.commands[0];
|
||||
assert_eq!(cmd1.wheel_distances(), Some((0.5, 0.5)));
|
||||
let duration_ms = cmd1.duration_ms();
|
||||
assert!(duration_ms > 1600 && duration_ms < 1700, "Expected ~1667ms, got {}", duration_ms);
|
||||
assert!(
|
||||
duration_ms > 1600 && duration_ms < 1700,
|
||||
"Expected ~1667ms, got {}",
|
||||
duration_ms
|
||||
);
|
||||
|
||||
// Second command: explicit duration
|
||||
let cmd2 = &scenario.commands[1];
|
||||
@@ -466,7 +473,11 @@ commands:
|
||||
// vel_left = vel_right = 0.6m / 2s = 0.3 m/s
|
||||
// linear = (0.3 + 0.3) / 2 = 0.3 m/s
|
||||
// angular = (0.3 - 0.3) / 0.233 = 0 rad/s
|
||||
assert!((linear - 0.3).abs() < 1e-6, "Expected linear=0.3, got {}", linear);
|
||||
assert!(
|
||||
(linear - 0.3).abs() < 1e-6,
|
||||
"Expected linear=0.3, got {}",
|
||||
linear
|
||||
);
|
||||
assert!(angular.abs() < 1e-6, "Expected angular=0, got {}", angular);
|
||||
}
|
||||
|
||||
@@ -484,7 +495,11 @@ commands:
|
||||
// linear = (-0.1165 + 0.1165) / 2 = 0 m/s
|
||||
// angular = (0.1165 - (-0.1165)) / 0.233 = 0.233 / 0.233 = 1 rad/s
|
||||
assert!(linear.abs() < 1e-6, "Expected linear=0, got {}", linear);
|
||||
assert!((angular - 1.0).abs() < 0.01, "Expected angular=1.0, got {}", angular);
|
||||
assert!(
|
||||
(angular - 1.0).abs() < 0.01,
|
||||
"Expected angular=1.0, got {}",
|
||||
angular
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user