/// Single particle in a particle filter cloud snapshot. class Particle { const Particle({required this.x, required this.y, required this.weight}); /// Normalised 0..1 coordinates (same space as [Position]). final double x; final double y; /// Unnormalised likelihood weight. final double weight; factory Particle.fromJson(Map json) => Particle( x: (json['x'] as num).toDouble(), y: (json['y'] as num).toDouble(), weight: (json['w'] as num).toDouble(), ); } /// Position estimate from the particle filter (weighted mean). class Estimate { const Estimate({required this.x, required this.y}); final double x; final double y; factory Estimate.fromJson(Map json) => Estimate( x: (json['x'] as num).toDouble(), y: (json['y'] as num).toDouble(), ); } /// A single `particles_updated` push from the server: estimate + raw cloud. class ParticleSnapshot { const ParticleSnapshot({ required this.tagId, required this.estimate, required this.particles, }); final String tagId; final Estimate estimate; final List particles; }