SatCat5
ptp_doppler.h
1 // Copyright 2024-2025 The Aerospace Corporation.
3 // This file is a part of SatCat5, licensed under CERN-OHL-W v2 or later.
5 // Doppler Precision Time Protocol (Doppler-PTP)
6 
7 #pragma once
8 
9 #include <satcat5/ptp_filters.h>
10 #include <satcat5/ptp_tlv.h>
11 #include <satcat5/timeref.h>
12 
13 namespace satcat5 {
14  namespace ptp {
29  public:
31  explicit DopplerTlv(satcat5::ptp::Client* client);
32 
35  inline void add_filter(satcat5::ptp::Filter* filter)
36  { m_predict.add_filter(filter); }
37 
39  inline bool get_tcomp_en() const
40  { return m_tcomp; }
41 
44  inline void set_tcomp_en(bool enable)
45  { m_tcomp = enable; }
46 
48  inline s64 get_velocity() const
49  { return m_predict.predict(0); }
50 
52  inline s64 get_acceleration() const
53  { return m_predict.predict(1000000) - m_predict.predict(0); }
54 
55  // Required TlvHandler API.
56  bool tlv_rcvd(
57  const satcat5::ptp::Header& hdr,
58  const satcat5::ptp::TlvHeader& tlv,
59  satcat5::io::LimitedRead& rd) override;
60  unsigned tlv_send(
61  const satcat5::ptp::Header& hdr,
62  satcat5::io::Writeable* wr) override;
63  void tlv_meas(satcat5::ptp::Measurement& meas) override;
64 
65  protected:
67  s64 m_dstamp;
69  bool m_tcomp;
70  };
71 
75  public:
76  explicit DopplerSimple(satcat5::ptp::Client* client);
77 
78  protected:
81  };
82  }
83 }
Limited read of next N bytes.
Definition: io_readable.h:255
Abstract API for writing byte-streams and packets.
Definition: io_writeable.h:24
Amplitude-based outlier rejection.
Definition: ptp_filters.h:135
Client for the IEEE 1588-2019 Precision Time Protocol (PTP)
Definition: ptp_client.h:67
Loop-filter for a proportional-integral (PI) controller.
Definition: ptp_filters.h:267
Streamlined variant of ptp::DopplerTlv, with a built-in filter chain that is adequate for most PTP ap...
Definition: ptp_doppler.h:74
TlvHandler for experimental Doppler-TLV tags.
Definition: ptp_doppler.h:28
void add_filter(satcat5::ptp::Filter *filter)
Add to the chain of processing filters.
Definition: ptp_doppler.h:35
s64 get_acceleration() const
Measured acceleration (subns/sec^2).
Definition: ptp_doppler.h:52
s64 get_velocity() const
Measured velocity (subns/sec).
Definition: ptp_doppler.h:48
bool get_tcomp_en() const
Is timestamp compensation currently enabled?
Definition: ptp_doppler.h:39
bool tlv_rcvd(const satcat5::ptp::Header &hdr, const satcat5::ptp::TlvHeader &tlv, satcat5::io::LimitedRead &rd) override
Child class SHOULD override this method to read incoming TLV(s).
Definition: ptp_doppler.cc:52
void set_tcomp_en(bool enable)
Enable or disable timestamp compensation.
Definition: ptp_doppler.h:44
DopplerTlv(satcat5::ptp::Client *client)
Link this instance to a specific PTP client.
Definition: ptp_doppler.cc:42
void tlv_meas(satcat5::ptp::Measurement &meas) override
Child class MAY override this method to read or modify each complete two-way handshake event.
Definition: ptp_doppler.cc:114
unsigned tlv_send(const satcat5::ptp::Header &hdr, satcat5::io::Writeable *wr) override
Child class SHOULD override this method to append outgoing TLV(s).
Definition: ptp_doppler.cc:87
Define the basic chain-of-filters API.
Definition: ptp_filters.h:38
An inline filter that iteratively estimates linear trends.
Definition: ptp_filters.h:505
s64 predict(u32 elapsed_usec) const
Extrapolate trendline relative to most recent update() event.
Definition: ptp_filters.cc:485
void add_filter(satcat5::ptp::Filter *filter)
Add to the chain of processing filters.
Definition: ptp_filters.h:516
Users should derive custom TLV objects from this base class.
Definition: ptp_tlv.h:111
Chainable filters for use with ptp::TrackingController.
TLV metadata for the IEEE 1588-2019 Precision Time Protocol (PTP).
Struct representing the PTP header used for all message types.
Definition: ptp_header.h:46
Timestamps and metadata for a two-way time-transfer handshake.
Data structure for identifying TLV headers.
Definition: ptp_tlv.h:70
Timestamp for measuring elapsed time.
Definition: timeref.h:48
TimeRef and TimeVal define the API for monotonic timers.