Mock-Batteriespannung an Zellenzahl des aktiven Drohnenprofils koppeln
Die simulierte Telemetrie war fest auf 6S verdrahtet (18.0-24.0V), obwohl das Drohnenprofil laengst eine konfigurierbare Zellenzahl hat - beim T1-Ranger-Standardprofil (4S) zeigte die Statusanzeige dadurch bis zu 18V, obwohl 16.8V (4 * 4.2V Ladeschluss) der realistische Maximalwert ist. MockFlightControllerLink nimmt jetzt batteryCellCount entgegen und skaliert den simulierten Spannungsverlauf (4.2V/Zelle voll bis 3.0V/Zelle nahezu leer) damit. telemetry_provider.dart uebergibt dafuer die Zellenzahl des aktuell aktiven Drohnenprofils (ref.read, analog zu den initialWaypoints - einmalig bei der Verbindungserzeugung, kein Reset des laufenden Akkustands bei spaeteren Profilwechseln). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
e902197462
commit
8d5b06d0b4
@@ -17,13 +17,23 @@ import '../flight_controller_link.dart';
|
|||||||
/// bleibt der alte Berlin-Fallback bestehen, damit die Klasse auch ganz
|
/// bleibt der alte Berlin-Fallback bestehen, damit die Klasse auch ganz
|
||||||
/// ohne Mission nutzbar ist.
|
/// ohne Mission nutzbar ist.
|
||||||
class MockFlightControllerLink implements FlightControllerLink {
|
class MockFlightControllerLink implements FlightControllerLink {
|
||||||
MockFlightControllerLink({List<Waypoint> initialWaypoints = const []})
|
MockFlightControllerLink({
|
||||||
: _anchorLat = initialWaypoints.isEmpty ? 52.5 : initialWaypoints.first.lat,
|
List<Waypoint> initialWaypoints = const [],
|
||||||
|
int batteryCellCount = 4,
|
||||||
|
}) : _anchorLat = initialWaypoints.isEmpty ? 52.5 : initialWaypoints.first.lat,
|
||||||
_anchorLon = initialWaypoints.isEmpty ? 13.4 : initialWaypoints.first.lon,
|
_anchorLon = initialWaypoints.isEmpty ? 13.4 : initialWaypoints.first.lon,
|
||||||
_activeWaypointIndex = initialWaypoints.isEmpty ? null : 0;
|
_activeWaypointIndex = initialWaypoints.isEmpty ? null : 0,
|
||||||
|
_batteryCellCount = batteryCellCount;
|
||||||
|
|
||||||
double _anchorLat;
|
double _anchorLat;
|
||||||
double _anchorLon;
|
double _anchorLon;
|
||||||
|
|
||||||
|
/// Zellenzahl des simulierten Akkus (Doku DroneProfile.batteryCellCount) -
|
||||||
|
/// bestimmt den Spannungsbereich der Mock-Telemetrie (siehe
|
||||||
|
/// batteryVoltage unten), damit die Statusanzeige mit den Ampel-
|
||||||
|
/// Schwellwerten des aktiven Profils zusammenpasst statt fest auf 6S
|
||||||
|
/// verdrahtet zu sein.
|
||||||
|
final int _batteryCellCount;
|
||||||
final _random = math.Random();
|
final _random = math.Random();
|
||||||
|
|
||||||
bool _armed = false;
|
bool _armed = false;
|
||||||
@@ -95,10 +105,15 @@ class MockFlightControllerLink implements FlightControllerLink {
|
|||||||
headingDeg: _heading,
|
headingDeg: _heading,
|
||||||
armed: _armed,
|
armed: _armed,
|
||||||
batteryPercent: _batteryPercent.round(),
|
batteryPercent: _batteryPercent.round(),
|
||||||
// 6S-Akku (22.2V nominal), Spannung sinkt mit dem Mock-Ladestand
|
// Spannung sinkt mit dem Mock-Ladestand von voll (4.2 V/Zelle,
|
||||||
// mit, damit auch die neue Statusanzeige (Doku: "Drone battery
|
// LiPo-Ladeschluss) auf nahezu leer (3.0 V/Zelle) mit, skaliert mit
|
||||||
// Voltage") auf Werteaenderungen reagiert.
|
// der Zellenzahl des aktiven Drohnenprofils statt fest auf 6S
|
||||||
batteryVoltage: 18.0 + (_batteryPercent / 100) * 6.0,
|
// verdrahtet zu sein (Doku: "bei 4s ist 16.8 Volt aber der max
|
||||||
|
// Wert") - damit reagiert auch die neue Statusanzeige (Doku: "Drone
|
||||||
|
// battery Voltage") auf Werteaenderungen und durchlaeuft dabei
|
||||||
|
// realistisch die Ampel-Schwellwerte des Profils.
|
||||||
|
batteryVoltage:
|
||||||
|
_batteryCellCount * (3.0 + (_batteryPercent / 100) * 1.2),
|
||||||
currentA: 12.5,
|
currentA: 12.5,
|
||||||
linkQuality: 95,
|
linkQuality: 95,
|
||||||
snrDb: 9,
|
snrDb: 9,
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import '../../transport/flight_controller_link.dart';
|
|||||||
import '../../transport/link_transport.dart';
|
import '../../transport/link_transport.dart';
|
||||||
import '../../transport/mock/mock_flight_controller_link.dart';
|
import '../../transport/mock/mock_flight_controller_link.dart';
|
||||||
import '../../transport/msp/msp_flight_controller_link.dart';
|
import '../../transport/msp/msp_flight_controller_link.dart';
|
||||||
|
import 'active_drone_profile_provider.dart';
|
||||||
import 'connection_settings_provider.dart';
|
import 'connection_settings_provider.dart';
|
||||||
import 'current_mission_provider.dart';
|
import 'current_mission_provider.dart';
|
||||||
import 'wifi_connection_provider.dart';
|
import 'wifi_connection_provider.dart';
|
||||||
@@ -44,7 +45,14 @@ final flightControllerLinkProvider = Provider<FlightControllerLink>((ref) {
|
|||||||
// verankert werden (Doku: "Mock-Daten fuer die Live-Details-Ansicht
|
// verankert werden (Doku: "Mock-Daten fuer die Live-Details-Ansicht
|
||||||
// nutzbar machen"), nicht bei jeder spaeteren Missionsaenderung
|
// nutzbar machen"), nicht bei jeder spaeteren Missionsaenderung
|
||||||
// neu erzeugt werden (das wuerde Timer/Drift/Akkustand zuruecksetzen).
|
// neu erzeugt werden (das wuerde Timer/Drift/Akkustand zuruecksetzen).
|
||||||
: MockFlightControllerLink(initialWaypoints: ref.read(currentMissionProvider));
|
// Gleiches gilt fuer die Zellenzahl: sie bestimmt nur den simulierten
|
||||||
|
// Spannungsbereich bei der Erzeugung, ein spaeterer Profilwechsel
|
||||||
|
// waehrend einer laufenden Mock-Verbindung setzt den Akkustand nicht
|
||||||
|
// zurueck.
|
||||||
|
: MockFlightControllerLink(
|
||||||
|
initialWaypoints: ref.read(currentMissionProvider),
|
||||||
|
batteryCellCount: ref.read(activeDroneProfileProvider).batteryCellCount,
|
||||||
|
);
|
||||||
ref.onDispose(link.disconnect);
|
ref.onDispose(link.disconnect);
|
||||||
return link;
|
return link;
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user