-
Notifications
You must be signed in to change notification settings - Fork 0
fix(ci): pin submodule to SDK v0.6.0, enable submodule checkout, format #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -76,13 +76,13 @@ public sealed class SimulationService : BackgroundService | |
| /// <param name="logger">Logger instance.</param> | ||
| public SimulationService(IHubContext<VizHub> hubContext, VizFrameBuilder frameBuilder, ILogger<SimulationService> logger) | ||
| { | ||
| _hubContext = hubContext; | ||
| _hubContext = hubContext; | ||
| _frameBuilder = frameBuilder; | ||
| _logger = logger; | ||
| _terrain = new TerrainNoiseService(); | ||
| _weather = new UpdatableWeatherSystem(new WeatherConfig()); | ||
| _world = new SimulationWorld(new SimulationConfig(), _terrain, _weather); | ||
| _swarm = new SwarmController(_terrain); | ||
| _logger = logger; | ||
| _terrain = new TerrainNoiseService(); | ||
| _weather = new UpdatableWeatherSystem(new WeatherConfig()); | ||
| _world = new SimulationWorld(new SimulationConfig(), _terrain, _weather); | ||
| _swarm = new SwarmController(_terrain); | ||
| _logger.LogInformation("SimulationService initialised."); | ||
| } | ||
|
|
||
|
|
@@ -124,9 +124,9 @@ public void SetWeather(string mode, double windSpeed, double direction) | |
| { | ||
| var weatherMode = mode.ToLowerInvariant() switch | ||
| { | ||
| "steady" => WeatherMode.Steady, | ||
| "steady" => WeatherMode.Steady, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| "turbulent" => WeatherMode.Turbulent, | ||
| _ => WeatherMode.Calm, | ||
| _ => WeatherMode.Calm, | ||
| }; | ||
| _weather.Update(new WeatherConfig(weatherMode, direction, windSpeed)); | ||
| _logger.LogInformation("Weather updated: mode={Mode}, speed={Speed} m/s, direction={Dir}°.", weatherMode, windSpeed, direction); | ||
|
|
@@ -161,10 +161,10 @@ public void Reset() | |
| { | ||
| lock (_lock) | ||
| { | ||
| _world = new SimulationWorld(new SimulationConfig(), _terrain, _weather); | ||
| _simTime = 0; | ||
| _tickCount = 0; | ||
| _swarmTick = 0; | ||
| _world = new SimulationWorld(new SimulationConfig(), _terrain, _weather); | ||
| _simTime = 0; | ||
| _tickCount = 0; | ||
| _swarmTick = 0; | ||
| _logger.LogInformation("Simulation reset."); | ||
| } | ||
| } | ||
|
|
@@ -181,13 +181,13 @@ public IReadOnlyList<DroneSnapshot> GetSnapshot() | |
| var q = state.Orientation; | ||
|
|
||
| return new DroneSnapshot( | ||
| Id: d.Id, | ||
| Id: d.Id, | ||
| Position: [state.Position.X, state.Position.Y, state.Position.Z], | ||
| Rotation: [q.X, q.Y, q.Z, q.W], | ||
| Velocity: [state.Velocity.X, state.Velocity.Y, state.Velocity.Z], | ||
| Battery: state.BatteryPercent, | ||
| Status: d.FlightModel.HasLanded ? "landed" : "flying", | ||
| Armed: !d.FlightModel.HasLanded); | ||
| Battery: state.BatteryPercent, | ||
| Status: d.FlightModel.HasLanded ? "landed" : "flying", | ||
| Armed: !d.FlightModel.HasLanded); | ||
| }).ToList(); | ||
| } | ||
| } | ||
|
|
@@ -224,7 +224,7 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken) | |
|
|
||
| // Build and broadcast frame outside the lock to avoid holding it during async I/O. | ||
| var snapshot = GetSnapshot(); | ||
| var frame = _frameBuilder.Build(snapshot, _simTime); | ||
| var frame = _frameBuilder.Build(snapshot, _simTime); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The variable |
||
| try | ||
| { | ||
| await _hubContext.Clients.All.SendAsync("ReceiveFrame", frame, stoppingToken); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,16 +27,16 @@ public sealed class VizFrameBuilder | |
|
|
||
| private sealed record SurvivorTargetConfig | ||
| { | ||
| public string Id { get; init; } = ""; | ||
| public string Id { get; init; } = ""; | ||
| public float[] Pos { get; init; } = []; | ||
| } | ||
|
|
||
| private sealed record HazardZoneConfig | ||
| { | ||
| public string Id { get; init; } = ""; | ||
| public string Type { get; init; } = ""; | ||
| public string Id { get; init; } = ""; | ||
| public string Type { get; init; } = ""; | ||
| public float[] Center { get; init; } = []; | ||
| public float Radius { get; init; } | ||
| public float Radius { get; init; } | ||
| } | ||
|
|
||
| private sealed record SurvivorTarget(string Id, Vector3 Position); | ||
|
|
@@ -76,8 +76,8 @@ public VizFrameBuilder(IConfiguration configuration) | |
| /// </summary> | ||
| public VizFrameBuilder() | ||
| { | ||
| _survivors = []; | ||
| _hazards = []; | ||
| _survivors = []; | ||
| _hazards = []; | ||
| _detectionRange = 35f; | ||
| } | ||
|
|
||
|
|
@@ -94,11 +94,11 @@ public VizFrame Build(IReadOnlyList<DroneSnapshot> drones, double simTime) | |
| .ToList(); | ||
|
|
||
| return new VizFrame( | ||
| Time: simTime, | ||
| Drones: droneStates, | ||
| Time: simTime, | ||
| Drones: droneStates, | ||
| Detections: BuildDetections(drones), | ||
| Hazards: BuildHazards(), | ||
| Mesh: null); | ||
| Hazards: BuildHazards(), | ||
| Mesh: null); | ||
| } | ||
|
|
||
| // ── Private helpers ──────────────────────────────────────────────────────── | ||
|
|
@@ -116,10 +116,10 @@ private IReadOnlyList<DetectionVizState> BuildDetections(IReadOnlyList<DroneSnap | |
| if (dist <= _detectionRange) | ||
| { | ||
| detections.Add(new DetectionVizState( | ||
| Id: target.Id, | ||
| Type: "survivor", | ||
| Pos: [target.Position.X, target.Position.Y, target.Position.Z], | ||
| DroneId: drone.Id, | ||
| Id: target.Id, | ||
| Type: "survivor", | ||
| Pos: [target.Position.X, target.Position.Y, target.Position.Z], | ||
| DroneId: drone.Id, | ||
| Confidence: 1f - dist / _detectionRange)); | ||
| } | ||
| } | ||
|
|
@@ -129,9 +129,9 @@ private IReadOnlyList<DetectionVizState> BuildDetections(IReadOnlyList<DroneSnap | |
|
|
||
| private IReadOnlyList<HazardVizState> BuildHazards() => | ||
| _hazards.Select(h => new HazardVizState( | ||
| Id: h.Id, | ||
| Type: h.Type, | ||
| Center: h.Center.Length == 3 ? [h.Center[0], h.Center[1], h.Center[2]] : [0f, 0f, 0f], | ||
| Radius: h.Radius, | ||
| Id: h.Id, | ||
| Type: h.Type, | ||
| Center: h.Center.Length == 3 ? [h.Center[0], h.Center[1], h.Center[2]] : [0f, 0f, 0f], | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If Center: h.Center is { Length: 3 } ? [h.Center[0], h.Center[1], h.Center[2]] : [0f, 0f, 0f], |
||
| Radius: h.Radius, | ||
| Severity: "medium")).ToList(); | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The constructor directly instantiates several complex dependencies (
TerrainNoiseService,UpdatableWeatherSystem,SimulationWorld, andSwarmController). This violates the Dependency Inversion Principle and makes the service difficult to unit test in isolation. Consider registering these as services in the dependency injection container and injecting them through the constructor.