diff --git a/c/include/libsbp/tracking.h b/c/include/libsbp/tracking.h index c7f14d804..df2c5c67a 100644 --- a/c/include/libsbp/tracking.h +++ b/c/include/libsbp/tracking.h @@ -50,6 +50,41 @@ typedef struct __attribute__((packed)) { } msg_tracking_state_t; +/** Deprecated, use MSG_EPHEMERIS (0x0046) + * + * Deprecated, use MSG_EPHEMERIS (0x0046). + */ +#define SBP_MSG_EPHEMERIS_OLD 0x001A +typedef struct __attribute__((packed)) { + double tgd; /**< Group delay differential between L1 and L2 [s] */ + double crs; /**< Amplitude of the sine harmonic correction term to the orbit radius [m] */ + double crc; /**< Amplitude of the cosine harmonic correction term to the orbit radius [m] */ + double cuc; /**< Amplitude of the cosine harmonic correction term to the argument of latitude [rad] */ + double cus; /**< Amplitude of the sine harmonic correction term to the argument of latitude [rad] */ + double cic; /**< Amplitude of the cosine harmonic correction term to the angle of inclination [rad] */ + double cis; /**< Amplitude of the sine harmonic correction term to the angle of inclination [rad] */ + double dn; /**< Mean motion difference [rad/s] */ + double m0; /**< Mean anomaly at reference time [radians] */ + double ecc; /**< Eccentricity of satellite orbit */ + double sqrta; /**< Square root of the semi-major axis of orbit [m^(1/2)] */ + double omega0; /**< Longitude of ascending node of orbit plane at weekly epoch [rad] */ + double omegadot; /**< Rate of right ascension [rad/s] */ + double w; /**< Argument of perigee [rad] */ + double inc; /**< Inclination [rad] */ + double inc_dot; /**< Inclination first derivative [rad/s] */ + double af0; /**< Polynomial clock correction coefficient (clock bias) [s] */ + double af1; /**< Polynomial clock correction coefficient (clock drift) [s/s] */ + double af2; /**< Polynomial clock correction coefficient (rate of clock drift) [s/s^2] */ + double toe_tow; /**< Time of week [s] */ + u16 toe_wn; /**< Week number [week] */ + double toc_tow; /**< Clock reference time of week [s] */ + u16 toc_wn; /**< Clock reference week number [week] */ + u8 valid; /**< Is valid? */ + u8 healthy; /**< Satellite is healthy? */ + u8 prn; /**< PRN being tracked */ +} msg_ephemeris_old_t; + + /** \} */ #endif /* LIBSBP_TRACKING_MESSAGES_H */ \ No newline at end of file diff --git a/docs/sbp.pdf b/docs/sbp.pdf index a6e5ff569..e36c35c58 100644 Binary files a/docs/sbp.pdf and b/docs/sbp.pdf differ diff --git a/python/sbp/__init__.py b/python/sbp/__init__.py index 5493d36f9..c2ee80fe7 100755 --- a/python/sbp/__init__.py +++ b/python/sbp/__init__.py @@ -108,7 +108,7 @@ def unpack(d): def __repr__(self): p = (self.preamble, self.msg_type, self.sender, self.length, - self.payload, self.crc) + repr(self.payload), self.crc) fmt = "" return fmt % p diff --git a/python/sbp/tracking.py b/python/sbp/tracking.py index f7477f637..4cabb5393 100644 --- a/python/sbp/tracking.py +++ b/python/sbp/tracking.py @@ -126,7 +126,172 @@ def to_json_dict(self): d.update(j) return d +SBP_MSG_EPHEMERIS_OLD = 0x001A +class MsgEphemerisOld(SBP): + """SBP class for message MSG_EPHEMERIS_OLD (0x001A). + + You can have MSG_EPHEMERIS_OLD inherent its fields directly + from an inherited SBP object, or construct it inline using a dict + of its fields. + + + Deprecated, use MSG_EPHEMERIS (0x0046). + + + Parameters + ---------- + sbp : SBP + SBP parent object to inherit from. + tgd : double + Group delay differential between L1 and L2 + crs : double + Amplitude of the sine harmonic correction term to the orbit radius + crc : double + Amplitude of the cosine harmonic correction term to the orbit radius + cuc : double + Amplitude of the cosine harmonic correction term to the argument of latitude + cus : double + Amplitude of the sine harmonic correction term to the argument of latitude + cic : double + Amplitude of the cosine harmonic correction term to the angle of inclination + cis : double + Amplitude of the sine harmonic correction term to the angle of inclination + dn : double + Mean motion difference + m0 : double + Mean anomaly at reference time + ecc : double + Eccentricity of satellite orbit + sqrta : double + Square root of the semi-major axis of orbit + omega0 : double + Longitude of ascending node of orbit plane at weekly epoch + omegadot : double + Rate of right ascension + w : double + Argument of perigee + inc : double + Inclination + inc_dot : double + Inclination first derivative + af0 : double + Polynomial clock correction coefficient (clock bias) + af1 : double + Polynomial clock correction coefficient (clock drift) + af2 : double + Polynomial clock correction coefficient (rate of clock drift) + toe_tow : double + Time of week + toe_wn : int + Week number + toc_tow : double + Clock reference time of week + toc_wn : int + Clock reference week number + valid : int + Is valid? + healthy : int + Satellite is healthy? + prn : int + PRN being tracked + + """ + _parser = Struct("MsgEphemerisOld", + LFloat64('tgd'), + LFloat64('crs'), + LFloat64('crc'), + LFloat64('cuc'), + LFloat64('cus'), + LFloat64('cic'), + LFloat64('cis'), + LFloat64('dn'), + LFloat64('m0'), + LFloat64('ecc'), + LFloat64('sqrta'), + LFloat64('omega0'), + LFloat64('omegadot'), + LFloat64('w'), + LFloat64('inc'), + LFloat64('inc_dot'), + LFloat64('af0'), + LFloat64('af1'), + LFloat64('af2'), + LFloat64('toe_tow'), + ULInt16('toe_wn'), + LFloat64('toc_tow'), + ULInt16('toc_wn'), + ULInt8('valid'), + ULInt8('healthy'), + ULInt8('prn'),) + + def __init__(self, sbp=None, **kwargs): + if sbp: + self.__dict__.update(sbp.__dict__) + self.from_binary(sbp.payload) + else: + self.tgd = kwargs.pop('tgd') + self.crs = kwargs.pop('crs') + self.crc = kwargs.pop('crc') + self.cuc = kwargs.pop('cuc') + self.cus = kwargs.pop('cus') + self.cic = kwargs.pop('cic') + self.cis = kwargs.pop('cis') + self.dn = kwargs.pop('dn') + self.m0 = kwargs.pop('m0') + self.ecc = kwargs.pop('ecc') + self.sqrta = kwargs.pop('sqrta') + self.omega0 = kwargs.pop('omega0') + self.omegadot = kwargs.pop('omegadot') + self.w = kwargs.pop('w') + self.inc = kwargs.pop('inc') + self.inc_dot = kwargs.pop('inc_dot') + self.af0 = kwargs.pop('af0') + self.af1 = kwargs.pop('af1') + self.af2 = kwargs.pop('af2') + self.toe_tow = kwargs.pop('toe_tow') + self.toe_wn = kwargs.pop('toe_wn') + self.toc_tow = kwargs.pop('toc_tow') + self.toc_wn = kwargs.pop('toc_wn') + self.valid = kwargs.pop('valid') + self.healthy = kwargs.pop('healthy') + self.prn = kwargs.pop('prn') + + def __repr__(self): + return fmt_repr(self) + + def from_binary(self, d): + """Given a binary payload d, update the appropriate payload fields of + the message. + + """ + p = MsgEphemerisOld._parser.parse(d) + self.__dict__.update(dict(p.viewitems())) + + def to_binary(self): + """Produce a framed/packed SBP message. + + """ + c = Container(**exclude_fields(self)) + self.payload = MsgEphemerisOld._parser.build(c) + return self.pack() + + @staticmethod + def from_json(s): + """Given a JSON-encoded string s, build a message object. + + """ + d = json.loads(s) + sbp = SBP.from_json_dict(d) + return MsgEphemerisOld(sbp) + + def to_json_dict(self): + d = super( MsgEphemerisOld, self).to_json_dict() + j = walk_json_dict(exclude_fields(self)) + d.update(j) + return d + msg_classes = { 0x0016: MsgTrackingState, + 0x001A: MsgEphemerisOld, } \ No newline at end of file diff --git a/python/tests/sbp/test_table.py b/python/tests/sbp/test_table.py index 3a6505e3b..8c2c5200b 100644 --- a/python/tests/sbp/test_table.py +++ b/python/tests/sbp/test_table.py @@ -21,7 +21,7 @@ def test_table_count(): Test number of available messages to deserialize. """ - number_of_messages = 45 + number_of_messages = 46 assert len(_SBP_TABLE) == number_of_messages def test_available_messages(): diff --git a/spec/yaml/swiftnav/sbp/tracking.yaml b/spec/yaml/swiftnav/sbp/tracking.yaml index a2da3ae64..5a1d0a479 100644 --- a/spec/yaml/swiftnav/sbp/tracking.yaml +++ b/spec/yaml/swiftnav/sbp/tracking.yaml @@ -57,3 +57,111 @@ definitions: fill: TrackingChannelState desc: Satellite tracking channel state + - MSG_EPHEMERIS_OLD: + id: 0x001A + public: False + short_desc: Deprecated, use MSG_EPHEMERIS (0x0046) + desc: | + Deprecated, use MSG_EPHEMERIS (0x0046). + fields: + - tgd: + type: double + units: s + desc: Group delay differential between L1 and L2 + - crs: + type: double + units: m + desc: Amplitude of the sine harmonic correction term to the orbit radius + - crc: + type: double + units: m + desc: Amplitude of the cosine harmonic correction term to the orbit radius + - cuc: + type: double + units: rad + desc: Amplitude of the cosine harmonic correction term to the argument of latitude + - cus: + type: double + units: rad + desc: Amplitude of the sine harmonic correction term to the argument of latitude + - cic: + type: double + units: rad + desc: Amplitude of the cosine harmonic correction term to the angle of inclination + - cis: + type: double + units: rad + desc: Amplitude of the sine harmonic correction term to the angle of inclination + - dn: + type: double + units: rad/s + desc: Mean motion difference + - m0: + type: double + units: radians + desc: Mean anomaly at reference time + - ecc: + type: double + desc: Eccentricity of satellite orbit + - sqrta: + type: double + units: m^(1/2) + desc: Square root of the semi-major axis of orbit + - omega0: + type: double + units: rad + desc: Longitude of ascending node of orbit plane at weekly epoch + - omegadot: + type: double + units: rad/s + desc: Rate of right ascension + - w: + type: double + units: rad + desc: Argument of perigee + - inc: + type: double + units: rad + desc: Inclination + - inc_dot: + type: double + units: rad/s + desc: Inclination first derivative + - af0: + type: double + units: s + desc: Polynomial clock correction coefficient (clock bias) + - af1: + type: double + units: s/s + desc: Polynomial clock correction coefficient (clock drift) + - af2: + type: double + units: s/s^2 + desc: Polynomial clock correction coefficient (rate of clock drift) + - toe_tow: + type: double + units: s + desc: Time of week + - toe_wn: + type: u16 + units: week + desc: Week number + - toc_tow: + type: double + units: s + desc: Clock reference time of week + - toc_wn: + type: u16 + units: week + desc: Clock reference week number + - valid: + type: u8 + desc: Is valid? + - healthy: + type: u8 + desc: Satellite is healthy? + - prn: + type: u8 + desc: PRN being tracked +