Skip to content
Browse files

Tracking loop stuff now uses floats.

  • Loading branch information...
1 parent a5a9a5a commit f4cccb05321c8a1745181436ca26d266bbc19dd8 @fnoble committed Mar 28, 2013
Showing with 45 additions and 41 deletions.
  1. +17 −13 swiftnav/track.pyx
  2. +28 −28 swiftnav/track_c.pxd
View
30 swiftnav/track.pyx
@@ -82,7 +82,7 @@ def calc_navigation_measurement(double t, chan_meas, es):
return nav_meas
-def calc_loop_gains(double bw, double zeta, double k, double loop_freq):
+def calc_loop_gains(float bw, float zeta, float k, float loop_freq):
"""
Wraps function :libswiftnav:`calc_loop_gains`.
@@ -103,8 +103,8 @@ def calc_loop_gains(double bw, double zeta, double k, double loop_freq):
The tuple `(pgain, igain)`.
"""
- cdef double pgain
- cdef double igain
+ cdef float pgain
+ cdef float igain
track_c.calc_loop_gains(bw, zeta, k, loop_freq, &pgain, &igain)
return (pgain, igain)
@@ -226,9 +226,9 @@ cdef class SimpleTrackingLoop:
"""
cdef track_c.simple_tl_state_t s
- cdef double loop_freq
- cdef double code_bw, code_zeta, code_k
- cdef double carr_bw, carr_zeta, carr_k
+ cdef float loop_freq
+ cdef float code_bw, code_zeta, code_k
+ cdef float carr_bw, carr_zeta, carr_k
def __cinit__(self, code_params, carr_params, loop_freq):
self.loop_freq = loop_freq
@@ -316,20 +316,24 @@ cdef class CompTrackingLoop:
The frequency with which loop updates are performed.
tau : float
The complimentary filter cross-over frequency.
+ cpc : float
+ The number of carrier cycles per complete code, or equivalently the ratio
+ of the carrier frequency to the nominal code frequency.
sched : int, optional
The gain scheduling count.
"""
cdef track_c.comp_tl_state_t s
- cdef double loop_freq, tau
- cdef double code_bw, code_zeta, code_k
- cdef double carr_bw, carr_zeta, carr_k
+ cdef float loop_freq, cpc, tau
+ cdef float code_bw, code_zeta, code_k
+ cdef float carr_bw, carr_zeta, carr_k
cdef u32 sched
- def __cinit__(self, code_params, carr_params, loop_freq, tau, sched=0):
+ def __cinit__(self, code_params, carr_params, loop_freq, tau, cpc, sched=0):
self.loop_freq = loop_freq
self.tau = tau
+ self.cpc = cpc
self.sched = sched
self.code_bw, self.code_zeta, self.code_k = code_params
self.carr_bw, self.carr_zeta, self.carr_k = carr_params
@@ -341,17 +345,17 @@ cdef class CompTrackingLoop:
Parameters
----------
code_freq : float
- The code phase rate (i.e. frequency).
+ The code phase rate (i.e. frequency) difference from nominal.
carr_freq : float
- The carrier frequency.
+ The carrier frequency difference from nominal, i.e. Doppler shift.
"""
track_c.comp_tl_init(&self.s, self.loop_freq,
code_freq, self.code_bw,
self.code_zeta, self.code_k,
carr_freq, self.carr_bw,
self.carr_zeta, self.carr_k,
- self.tau, self.sched)
+ self.tau, self.cpc, self.sched)
def update(self, complex e, complex p, complex l):
"""
View
56 swiftnav/track_c.pxd
@@ -29,52 +29,52 @@ cdef extern from "libswiftnav/track.h":
double sat_vel[3]
ctypedef struct simple_lf_state_t:
- double y
+ float y
ctypedef struct simple_tl_state_t:
- double code_freq
- double carr_freq
+ float code_freq
+ float carr_freq
ctypedef struct comp_tl_state_t:
- double code_freq
- double carr_freq
+ float code_freq
+ float carr_freq
ctypedef struct cn0_est_state_t:
pass
ctypedef struct correlation_t:
- double I
- double Q
+ float I
+ float Q
void calc_navigation_measurement_(u8 n_channels, channel_measurement_t* meas[], navigation_measurement_t* nav_meas[], double nav_time, ephemeris_t* ephemerides[])
- void calc_loop_gains(double bw, double zeta, double k, double loop_freq,
- double *pgain, double *igain)
- double costas_discriminator(double I, double Q)
- double dll_discriminator(correlation_t cs[3])
+ void calc_loop_gains(float bw, float zeta, float k, float loop_freq,
+ float *pgain, float *igain)
+ float costas_discriminator(float I, float Q)
+ float dll_discriminator(correlation_t cs[3])
- void simple_lf_init(simple_lf_state_t *s, double y0,
- double pgain, double igain)
- double simple_lf_update(simple_lf_state_t *s, double error)
+ void simple_lf_init(simple_lf_state_t *s, float y0,
+ float pgain, float igain)
+ float simple_lf_update(simple_lf_state_t *s, float error)
- void simple_tl_init(simple_tl_state_t *s, double loop_freq,
- double code_freq, double code_bw,
- double code_zeta, double code_k,
- double carr_freq, double carr_bw,
- double carr_zeta, double carr_k)
+ void simple_tl_init(simple_tl_state_t *s, float loop_freq,
+ float code_freq, float code_bw,
+ float code_zeta, float code_k,
+ float carr_freq, float carr_bw,
+ float carr_zeta, float carr_k)
void simple_tl_update(simple_tl_state_t *s, correlation_t cs[3])
- void comp_tl_init(comp_tl_state_t *s, double loop_freq,
- double code_freq, double code_bw,
- double code_zeta, double code_k,
- double carr_freq, double carr_bw,
- double carr_zeta, double carr_k,
- double tau, u32 sched)
+ void comp_tl_init(comp_tl_state_t *s, float loop_freq,
+ float code_freq, float code_bw,
+ float code_zeta, float code_k,
+ float carr_freq, float carr_bw,
+ float carr_zeta, float carr_k,
+ float tau, float cpc, u32 sched)
void comp_tl_update(comp_tl_state_t *s, correlation_t cs[3])
- void cn0_est_init(cn0_est_state_t* s, double bw, double cn0_0,
- double cutoff_freq, double loop_freq)
- double cn0_est(cn0_est_state_t* s, double I)
+ void cn0_est_init(cn0_est_state_t* s, float bw, float cn0_0,
+ float cutoff_freq, float loop_freq)
+ float cn0_est(cn0_est_state_t* s, float I)

0 comments on commit f4cccb0

Please sign in to comment.
Something went wrong with that request. Please try again.