drone-vrp 1.0.0

Drone Vehicle Routing Problem solver with physics-based energy models for UAV delivery — supports DJI FlyCart 30, Ukrainian drones (R18, Vampire, PD-2, HeavyShot, Kazhan, Nemesis), and DJI Matrice 350 RTK
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
pub mod solver;
use serde::{Deserialize, Serialize};

/// Drone model identifier.
///
/// Includes original DJI delivery drones and popular Ukrainian drones
/// used for logistics, supply delivery, and reconnaissance in Ukraine.
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub enum DroneModel {
    // ── Original models ──
    FlyCart30,
    Wing,

    // ── Ukrainian drones ──
    /// Aerorozvidka R18 octocopter — Ukrainian strike/delivery drone
    R18,
    /// UkrSpecSystems PD-2 — Ukrainian VTOL fixed-wing (gasoline/hybrid)
    PD2,
    /// SkyFall Vampire — Ukrainian "Baba Yaga" hexacopter bomber/delivery
    Vampire,
    /// Gurzuf Defence Heavy Shot — Ukrainian heavy quadcopter
    HeavyShot,
    /// Reactive Drone Kazhan-630 — Ukrainian hexacopter bomber/delivery
    Kazhan,
    /// UFORCE Nemesis — Ukrainian heavy quadcopter bomber/delivery
    Nemesis,
    /// DJI Matrice 350 RTK — industrial multi-rotor, widely used in Ukraine
    Matrice350RTK,
}

/// Propulsion type for the energy model.
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub enum Propulsion {
    /// Pure battery-electric
    Electric,
    /// Gasoline internal combustion engine (effective energy converted from fuel)
    Gasoline,
    /// VTOL electric lift + gasoline cruise
    Hybrid,
}

/// Drone specification with physics-based energy model.
///
/// The energy model follows Dorling et al. (2017):
///   Power = P_p + (P_l − P_p) × (payload / max_payload)
///   Energy (Wh) = Power × (Distance / GroundSpeed) / 3600
///
/// GroundSpeed is adjusted for headwind:  ground_speed = max(cruise_speed − wind, 1.0)
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DroneSpec {
    pub model: DroneModel,
    /// Propulsion type — affects how battery_capacity_wh is interpreted
    pub propulsion: Propulsion,
    /// Manufacturer or developer
    pub manufacturer: String,
    /// Short description of the drone
    pub description: String,
    /// Country of origin
    pub country: String,
    /// Airframe mass without payload (kg)
    pub mass_kg: f64,
    /// Maximum payload capacity (kg)
    pub max_payload_kg: f64,
    /// Energy store capacity (Wh). For gasoline/hybrid, this is the
    /// effective usable energy converted at ~30 % thermal efficiency.
    pub battery_capacity_wh: f64,
    /// Cruise speed in still air (m/s)
    pub cruise_speed_ms: f64,
    /// Hover / cruise power with no payload (W) — P_p in Dorling et al.
    pub power_no_load_w: f64,
    /// Hover / cruise power at maximum payload (W) — P_l in Dorling et al.
    pub power_max_load_w: f64,
}

impl DroneSpec {
    // ─── Original models ────────────────────────────────────────────

    /// DJI FlyCart 30 — heavy-lift delivery drone
    pub fn flycart30() -> Self {
        Self {
            model: DroneModel::FlyCart30,
            propulsion: Propulsion::Electric,
            manufacturer: "DJI".into(),
            description: "Heavy-lift delivery drone, dual-battery system".into(),
            country: "CN".into(),
            mass_kg: 29.9,
            max_payload_kg: 30.0,
            battery_capacity_wh: 2000.0,
            cruise_speed_ms: 15.0,
            power_no_load_w: 500.0,
            power_max_load_w: 1200.0,
        }
    }

    /// Wing (Alphabet) — light delivery drone
    pub fn wing() -> Self {
        Self {
            model: DroneModel::Wing,
            propulsion: Propulsion::Electric,
            manufacturer: "Wing (Alphabet)".into(),
            description: "Light autonomous delivery drone".into(),
            country: "US".into(),
            mass_kg: 4.8,
            max_payload_kg: 1.2,
            battery_capacity_wh: 150.0,
            cruise_speed_ms: 30.0,
            power_no_load_w: 80.0,
            power_max_load_w: 150.0,
        }
    }

    // ─── Ukrainian drones ─────────────────────────────────────────────

    /// Aerorozvidka R18 — Ukrainian octocopter strike / delivery drone
    ///
    /// Specs from Aerorozvidka official data and Wikipedia:
    ///   Total weight 17 kg, payload up to 5 kg, 45 min flight time,
    ///   12 m/s cruise, 2× Li-ion 6S 24V 32.5Ah battery packs,
    ///   wind resistance up to 10 m/s.
    pub fn r18() -> Self {
        Self {
            model: DroneModel::R18,
            propulsion: Propulsion::Electric,
            manufacturer: "Aerorozvidka".into(),
            description: "Ukrainian octocopter — strike, cargo delivery, recon".into(),
            country: "UA".into(),
            mass_kg: 17.0,
            max_payload_kg: 5.0,
            // 2 × 6S 22.2V × 32.5Ah ≈ 1443 Wh
            battery_capacity_wh: 1440.0,
            cruise_speed_ms: 12.0,
            power_no_load_w: 1400.0,
            power_max_load_w: 2200.0,
        }
    }

    /// UkrSpecSystems PD-2 — Ukrainian VTOL fixed-wing UAV
    ///
    /// Gasoline-powered (100 cc 4-stroke engine + 300W generator + electric
    /// VTOL lift motors).  MTOW 55 kg, payload 11 kg, cruise 100 km/h,
    /// endurance 8+ hours.
    ///
    /// `battery_capacity_wh` represents effective energy from 11L A-95
    /// gasoline converted at ~30 % thermal efficiency:
    ///   11 L × 8.8 kWh/L × 0.30 ≈ 29 000 Wh effective.
    pub fn pd2() -> Self {
        Self {
            model: DroneModel::PD2,
            propulsion: Propulsion::Hybrid,
            manufacturer: "UkrSpecSystems".into(),
            description: "Ukrainian VTOL fixed-wing — ISR, cargo drop, 8h+ endurance".into(),
            country: "UA".into(),
            mass_kg: 55.0,
            max_payload_kg: 11.0,
            battery_capacity_wh: 29_000.0,
            cruise_speed_ms: 27.8, // 100 km/h
            power_no_load_w: 2500.0,
            power_max_load_w: 3600.0,
        }
    }

    /// SkyFall Vampire — Ukrainian "Baba Yaga" hexacopter
    ///
    /// Heavy bomber / cargo delivery drone widely used by Ukrainian forces.
    /// Payload up to 15 kg, combat radius up to 20 km, 6-rotor hexacopter.
    /// Used for night strikes, mine-laying, and humanitarian supply delivery.
    pub fn vampire() -> Self {
        Self {
            model: DroneModel::Vampire,
            propulsion: Propulsion::Electric,
            manufacturer: "SkyFall".into(),
            description: "Ukrainian hexacopter — night strike, cargo, mine-laying, humanitarian".into(),
            country: "UA".into(),
            mass_kg: 25.0,
            max_payload_kg: 15.0,
            battery_capacity_wh: 3200.0,
            cruise_speed_ms: 16.7, // ~60 km/h
            power_no_load_w: 2800.0,
            power_max_load_w: 4200.0,
        }
    }

    /// Gurzuf Defence Heavy Shot — Ukrainian heavy quadcopter
    ///
    /// Combat payload up to 30 kg, combat radius up to 25 km,
    /// Starlink-capable. One of the heaviest Ukrainian bomber drones.
    pub fn heavy_shot() -> Self {
        Self {
            model: DroneModel::HeavyShot,
            propulsion: Propulsion::Electric,
            manufacturer: "Gurzuf Defence".into(),
            description: "Ukrainian heavy quadcopter — 30 kg payload, Starlink-capable".into(),
            country: "UA".into(),
            mass_kg: 30.0,
            max_payload_kg: 30.0,
            battery_capacity_wh: 5000.0,
            cruise_speed_ms: 14.0,
            power_no_load_w: 3000.0,
            power_max_load_w: 5500.0,
        }
    }

    /// Reactive Drone Kazhan-630 — Ukrainian hexacopter bomber
    ///
    /// Payload up to 20 kg, combat radius up to 25 km, AI-assisted
    /// targeting, triple-communication (encrypted radio + Starlink + LTE).
    /// Self-heating Li-Po solid-state batteries for winter operations.
    pub fn kazhan() -> Self {
        Self {
            model: DroneModel::Kazhan,
            propulsion: Propulsion::Electric,
            manufacturer: "Reactive Drone".into(),
            description: "Ukrainian hexacopter — 20 kg payload, AI targeting, winter-rated".into(),
            country: "UA".into(),
            mass_kg: 28.0,
            max_payload_kg: 20.0,
            battery_capacity_wh: 4000.0,
            cruise_speed_ms: 15.0,
            power_no_load_w: 2600.0,
            power_max_load_w: 4500.0,
        }
    }

    /// UFORCE Nemesis — Ukrainian heavy quadcopter
    ///
    /// Payload up to 20 kg, combat radius up to 25 km (Starlink),
    /// initially developed for the 412th separate SBS brigade.
    /// Uses Starlink satellite control for beyond-line-of-sight operations.
    pub fn nemesis() -> Self {
        Self {
            model: DroneModel::Nemesis,
            propulsion: Propulsion::Electric,
            manufacturer: "UFORCE".into(),
            description: "Ukrainian heavy quadcopter — Starlink-controlled, 20 kg payload".into(),
            country: "UA".into(),
            mass_kg: 22.0,
            max_payload_kg: 20.0,
            battery_capacity_wh: 3800.0,
            cruise_speed_ms: 18.0,
            power_no_load_w: 2400.0,
            power_max_load_w: 4200.0,
        }
    }

    /// DJI Matrice 350 RTK — industrial multi-rotor, widely deployed in Ukraine
    ///
    /// Used extensively by Ukrainian forces for ISR and light delivery.
    /// 2× TB65 batteries (~798 Wh total), max payload 2.7 kg,
    /// ~55 min flight time (no payload), IP54 rating.
    pub fn matrice350rtk() -> Self {
        Self {
            model: DroneModel::Matrice350RTK,
            propulsion: Propulsion::Electric,
            manufacturer: "DJI".into(),
            description: "Industrial multi-rotor — ISR & light delivery, widely used in Ukraine".into(),
            country: "CN".into(),
            mass_kg: 6.3,
            max_payload_kg: 2.7,
            battery_capacity_wh: 798.0,
            cruise_speed_ms: 15.0,
            power_no_load_w: 800.0,
            power_max_load_w: 1300.0,
        }
    }

    /// Return all available drone specs as a Vec.
    pub fn all() -> Vec<DroneSpec> {
        vec![
            Self::flycart30(),
            Self::wing(),
            Self::r18(),
            Self::pd2(),
            Self::vampire(),
            Self::heavy_shot(),
            Self::kazhan(),
            Self::nemesis(),
            Self::matrice350rtk(),
        ]
    }

    /// Parse a drone model name string (case-insensitive) into a DroneSpec.
    /// Supports aliases like "fc30", "m350", etc.
    pub fn from_name(name: &str) -> Result<Self, String> {
        match name.to_lowercase().as_str() {
            "flycart30" | "fc30" | "dji_fc30" => Ok(Self::flycart30()),
            "wing" => Ok(Self::wing()),
            "r18" | "aerorozvidka" => Ok(Self::r18()),
            "pd2" | "pd-2" | "ukrspecsystems" => Ok(Self::pd2()),
            "vampire" | "skyfall" | "baba_yaga" => Ok(Self::vampire()),
            "heavyshot" | "heavy_shot" | "gurzuf" => Ok(Self::heavy_shot()),
            "kazhan" | "kazhan630" | "reactive_drone" => Ok(Self::kazhan()),
            "nemesis" | "uforce" => Ok(Self::nemesis()),
            "matrice350rtk" | "m350" | "m350rtk" | "matrice" | "dji_m350" => Ok(Self::matrice350rtk()),
            _ => Err(format!(
                "Unknown drone model '{}'. Available: flycart30, wing, r18, pd2, vampire, heavy_shot, kazhan, nemesis, matrice350rtk",
                name
            )),
        }
    }

    /// Physics-based energy model (Dorling et al. 2017)
    ///
    /// Power = P_p + (P_l − P_p) × (payload / max_payload)
    /// Energy (Wh) = (Power × Distance / Speed) / 3600
    ///
    /// Wind is modelled as a reduction in ground speed:
    ///   ground_speed = max(cruise_speed − wind, 1.0)
    pub fn calculate_energy_wh(&self, distance_m: f64, payload_kg: f64, wind_ms: f64) -> f64 {
        let payload_ratio = (payload_kg / self.max_payload_kg).clamp(0.0, 1.0);
        let base_power =
            self.power_no_load_w + (self.power_max_load_w - self.power_no_load_w) * payload_ratio;

        // Simplified wind impact: adjust effective ground speed
        let ground_speed = (self.cruise_speed_ms - wind_ms).max(1.0);
        let time_h = (distance_m / ground_speed) / 3600.0;

        base_power * time_h
    }

    /// Estimate maximum one-way range (m) at a given payload and wind.
    /// Returns the distance where cumulative energy equals battery capacity.
    pub fn estimate_max_range_m(&self, payload_kg: f64, wind_ms: f64) -> f64 {
        let energy_per_m = self.calculate_energy_wh(1.0, payload_kg, wind_ms);
        if energy_per_m <= 0.0 {
            return f64::INFINITY;
        }
        // Reserve 20% battery for safety margin
        let usable_wh = self.battery_capacity_wh * 0.8;
        usable_wh / energy_per_m
    }
}

/// A circular no-fly zone.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct NoFlyZone {
    pub id: String,
    pub center_lat: f64,
    pub center_lon: f64,
    pub radius_m: f64,
}

/// Input instance for the Drone VRP solver.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DroneVrpInstance {
    pub drone_model: DroneModel,
    pub depot: [f64; 2],
    pub customers: Vec<[f64; 2]>,
    pub demands_kg: Vec<f64>,
    pub wind_speed_ms: f64,
    pub no_fly_zones: Vec<NoFlyZone>,
}

/// Result of a Drone VRP solve.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DroneVrpResult {
    pub routes: Vec<Vec<usize>>,
    pub energy_used_wh: f64,
    pub violations: Vec<String>,
}

#[cfg(test)]
mod tests {
    use super::*;

    // ── Original model tests ──

    #[test]
    fn test_drone_specs() {
        let fc = DroneSpec::flycart30();
        let wing = DroneSpec::wing();
        assert_eq!(fc.model, DroneModel::FlyCart30);
        assert_eq!(wing.model, DroneModel::Wing);
    }

    #[test]
    fn test_energy_model_empty() {
        let fc = DroneSpec::flycart30();
        let energy = fc.calculate_energy_wh(15000.0, 0.0, 0.0);
        // 500W × (15000/15)/3600 = 500 × 0.278 = 138.9 Wh
        assert!(energy > 130.0 && energy < 145.0);
    }

    #[test]
    fn test_energy_model_full_load() {
        let fc = DroneSpec::flycart30();
        let energy = fc.calculate_energy_wh(15000.0, 30.0, 0.0);
        // 1200W × (15000/15)/3600 = 1200 × 0.278 = 333.3 Wh
        assert!(energy > 330.0 && energy < 340.0);
    }

    #[test]
    fn test_wind_impact() {
        let fc = DroneSpec::flycart30();
        let energy_no_wind = fc.calculate_energy_wh(10000.0, 0.0, 0.0);
        let energy_headwind = fc.calculate_energy_wh(10000.0, 0.0, 5.0);
        assert!(energy_headwind > energy_no_wind);
    }

    #[test]
    fn test_wing_energy() {
        let wing = DroneSpec::wing();
        let energy = wing.calculate_energy_wh(30000.0, 0.0, 0.0);
        // 80W × (30000/30)/3600 = 80 × 0.278 = 22.2 Wh
        assert!(energy > 20.0 && energy < 25.0);
    }

    #[test]
    fn test_payload_limit() {
        let fc = DroneSpec::flycart30();
        let energy_full = fc.calculate_energy_wh(1000.0, 30.0, 0.0);
        let energy_over = fc.calculate_energy_wh(1000.0, 100.0, 0.0);
        // Should cap at max_payload
        assert_eq!(energy_full, energy_over);
    }

    // ── Ukrainian drone tests ──

    #[test]
    fn test_r18_specs() {
        let r18 = DroneSpec::r18();
        assert_eq!(r18.model, DroneModel::R18);
        assert_eq!(r18.manufacturer, "Aerorozvidka");
        assert_eq!(r18.country, "UA");
        assert!(r18.battery_capacity_wh > 1000.0);
    }

    #[test]
    fn test_r18_energy() {
        let r18 = DroneSpec::r18();
        // 5 km flight at full payload (5 kg), no wind
        let energy = r18.calculate_energy_wh(5000.0, 5.0, 0.0);
        // Power at full load = 2200W, speed = 12 m/s
        // 2200 × (5000/12)/3600 = 2200 × 0.116 = 254.6 Wh
        assert!(energy > 240.0 && energy < 270.0, "R18 5km full load: got {energy}");
    }

    #[test]
    fn test_r18_range() {
        let r18 = DroneSpec::r18();
        // R18 should have ~5 km radius at full load (official spec)
        let range = r18.estimate_max_range_m(5.0, 0.0);
        // Battery 1440 Wh × 0.8 = 1152 Wh usable
        // Energy per meter at full load: 2200/(12*3600) = 0.051 Wh/m
        // Range ≈ 1152 / 0.051 ≈ 22 588 m ≈ 22.6 km one-way
        // (operational radius is about half = 11.3 km, close to official 5-12 km)
        assert!(range > 15000.0, "R18 range at full load: got {range}m");
    }

    #[test]
    fn test_pd2_range() {
        let pd2 = DroneSpec::pd2();
        // PD-2 should have enormous range due to gasoline engine
        let range = pd2.estimate_max_range_m(11.0, 0.0);
        // With 29000 Wh effective, should be well over 100 km
        assert!(range > 100_000.0, "PD2 range at full load: got {range}m");
    }

    #[test]
    fn test_vampire_energy() {
        let vampire = DroneSpec::vampire();
        // 10 km at full load (15 kg), no wind
        let energy = vampire.calculate_energy_wh(10000.0, 15.0, 0.0);
        // Power at full load = 4200W, speed = 16.7 m/s
        // 4200 × (10000/16.7)/3600 = 4200 × 0.166 = 698 Wh
        assert!(energy > 680.0 && energy < 720.0, "Vampire 10km full load: got {energy}");
    }

    #[test]
    fn test_vampire_range() {
        let vampire = DroneSpec::vampire();
        let range = vampire.estimate_max_range_m(15.0, 0.0);
        // Battery 3200 × 0.8 = 2560 Wh usable
        // Energy per meter at full load: 4200/(16.7*3600) = 0.070 Wh/m
        // Range ≈ 2560/0.070 ≈ 36 700 m ≈ 36.7 km one-way
        assert!(range > 25000.0, "Vampire range at full load: got {range}m");
    }

    #[test]
    fn test_heavy_shot_energy() {
        let hs = DroneSpec::heavy_shot();
        let energy = hs.calculate_energy_wh(10000.0, 30.0, 0.0);
        // Power at full load = 5500W, speed = 14 m/s
        // 5500 × (10000/14)/3600 = 5500 × 0.198 = 1091 Wh
        assert!(energy > 1050.0 && energy < 1150.0, "HeavyShot 10km full load: got {energy}");
    }

    #[test]
    fn test_kazhan_energy() {
        let kz = DroneSpec::kazhan();
        let energy = kz.calculate_energy_wh(10000.0, 20.0, 0.0);
        // 4500 × (10000/15)/3600 = 4500 × 0.185 = 833 Wh
        assert!(energy > 800.0 && energy < 870.0, "Kazhan 10km full load: got {energy}");
    }

    #[test]
    fn test_nemesis_energy() {
        let nm = DroneSpec::nemesis();
        let energy = nm.calculate_energy_wh(10000.0, 20.0, 0.0);
        // 4200 × (10000/18)/3600 = 4200 × 0.154 = 648 Wh
        assert!(energy > 620.0 && energy < 680.0, "Nemesis 10km full load: got {energy}");
    }

    #[test]
    fn test_matrice350rtk_energy() {
        let m350 = DroneSpec::matrice350rtk();
        // 10 km at full load (2.7 kg)
        let energy = m350.calculate_energy_wh(10000.0, 2.7, 0.0);
        // Power at full load = 1300W, speed = 15 m/s
        // 1300 × (10000/15)/3600 = 1300 × 0.185 = 241 Wh
        assert!(energy > 230.0 && energy < 250.0, "M350 10km full load: got {energy}");
    }

    #[test]
    fn test_matrice350rtk_range() {
        let m350 = DroneSpec::matrice350rtk();
        let range_empty = m350.estimate_max_range_m(0.0, 0.0);
        // DJI spec: ~55 min no payload at 15 m/s → ~49.5 km
        // Battery 798 × 0.8 = 638 Wh usable
        // Energy per meter empty: 800/(15*3600) = 0.0148 Wh/m
        // Range ≈ 638/0.0148 ≈ 43 108 m ≈ 43 km
        assert!(range_empty > 35000.0, "M350 range empty: got {range_empty}m");
    }

    #[test]
    fn test_from_name_aliases() {
        assert_eq!(DroneSpec::from_name("r18").unwrap().model, DroneModel::R18);
        assert_eq!(DroneSpec::from_name("R18").unwrap().model, DroneModel::R18);
        assert_eq!(DroneSpec::from_name("aerorozvidka").unwrap().model, DroneModel::R18);
        assert_eq!(DroneSpec::from_name("baba_yaga").unwrap().model, DroneModel::Vampire);
        assert_eq!(DroneSpec::from_name("vampire").unwrap().model, DroneModel::Vampire);
        assert_eq!(DroneSpec::from_name("pd-2").unwrap().model, DroneModel::PD2);
        assert_eq!(DroneSpec::from_name("m350").unwrap().model, DroneModel::Matrice350RTK);
        assert!(DroneSpec::from_name("unknown").is_err());
    }

    #[test]
    fn test_all_returns_nine_models() {
        assert_eq!(DroneSpec::all().len(), 9);
    }

    #[test]
    fn test_ukrainian_drones_have_ua_country() {
        for spec in DroneSpec::all() {
            if matches!(spec.model,
                DroneModel::R18 | DroneModel::PD2 | DroneModel::Vampire |
                DroneModel::HeavyShot | DroneModel::Kazhan | DroneModel::Nemesis
            ) {
                assert_eq!(spec.country, "UA", "{} should be UA", spec.manufacturer);
            }
        }
    }
}