AttitudeJson.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. using System.Collections.Generic;
  2. using Newtonsoft.Json.Linq;
  3. using o0.IMU;
  4. using o0.Geometry;
  5. using o0;
  6. public class AttitudeJson : JCUnityLib.CustomJson
  7. {
  8. public AttitudeJson() : base()
  9. {
  10. InitJsonClass<_9AxisPreProcessor>(() => new _9AxisPreProcessor(),
  11. "AccByteIndex",
  12. "GyrByteIndex",
  13. "MagByteIndex",
  14. "ByteToAcc",
  15. "ByteToGyr",
  16. "ByteToMag",
  17. "GyrCalibrater",
  18. "MagCalibrater",
  19. "ByteReverseMS"
  20. );
  21. InitJsonClass<MagnetometerAutoCalibrater>(() => new MagnetometerAutoCalibrater(),
  22. "CountPerLength",
  23. "EllipsoidFitting",
  24. "FitCountLeft",
  25. "FitThreshold",
  26. "LastTimestamp",
  27. "Lock",
  28. "MaxCount",
  29. "NewBlock",
  30. "NewBlockAccumulation",
  31. "Variance",
  32. "VectorByBlock"
  33. );
  34. InitJsonClass<ByteToShorts>(() => new ByteToShorts(3),
  35. "ByteToShort"
  36. );
  37. InitJsonClass<MeanMaintainer<Vector<double>>>(() => new MeanMaintainer<Vector<double>>(),
  38. "Count",
  39. "Mean"
  40. );
  41. InitJsonClass<ByteToShortByVariance>(() => new ByteToShortByVariance(),
  42. "Count",
  43. "Reverse",
  44. "Short",
  45. "ThresholdRate"
  46. );
  47. InitJsonClass<EllipsoidFitting>(() => new EllipsoidFitting(default, null, default),
  48. "Center",
  49. "CorrectMatrixArray",
  50. "Radius"
  51. );
  52. InitJsonClass<Dictionary<Vector<int>, Vector<double>>>(
  53. o => JToken.FromObject(o),
  54. jt => {
  55. var o = new Dictionary<Vector<int>, Vector<double>>();
  56. foreach (JProperty item in jt)
  57. o[ParseByExporter<Vector<int>>(JArray.Parse(item.Name))]
  58. = ParseByExporter<Vector<double>>(item.Value);
  59. return o;
  60. }
  61. );
  62. InitJsonClass<Vector<int>>(
  63. o => JToken.FromObject(o),
  64. jt => new Vector<int>(jt.ToObject<int[]>())
  65. );
  66. InitJsonClass<Vector<double>>(
  67. o => JToken.FromObject(o),
  68. jt => new Vector<double>(jt.ToObject<double[]>())
  69. );
  70. }
  71. }