This repository was archived by the owner on Apr 13, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 86
Peregrine l2c update #315
Closed
adel-mamin
wants to merge
20
commits into
swift-nav:more_peregrine_updates
from
adel-mamin:peregrine-l2c-update
Closed
Peregrine l2c update #315
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
5f94af5
Add L2C correlator for Peregrine
f1321b0
Enable debug output in correlator unit test
14997a1
Disable SSSE3 for testing
fc126df
Fix bug in correlator Check unit test code generator
f0cb62d
Disable debug output
8ff2a93
Add L2C track support
13bed1f
Fix track.pyx for lock detectors
c5b438b
l2c: added cython bindings for CNAV message decoding
valeri-atamaniouk e89094d
iqgen: updated cython bindings for l1ca
valeri-atamaniouk eaefe03
Add alias lock detectors reinit()
8a10026
tracking: fixed python bindings for aided tracking
valeri-atamaniouk 204ced2
Add counter checkers for counters in RF4&RF1 and RF3&RF2
bb45031
Fix printf for size_t vars
ed093de
Fix travis build
383972d
Fix travis build
19a3718
Fix travis build
d96b4e5
Fix doxygen comments
8d3e9e2
Add C objects pickling for Peregrine track parallelization
ab7845c
swiftnav: updated python bindings for swiftnav component
valeri-atamaniouk a4c993f
Merge pull request #4 from valeri-atamaniouk/i95-peregine-nav
adel-mamin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
/* | ||
* Copyright (C) 2016 Swift Navigation Inc. | ||
* Contact: Adel Mamin <adelm@exafore.com> | ||
* | ||
* This source is subject to the license found in the file 'LICENSE' which must | ||
* be be distributed together with this source. All other rights reserved. | ||
* | ||
* THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, | ||
* EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED | ||
* WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. | ||
*/ | ||
|
||
/** | ||
@file | ||
|
||
This utility helps to verify the integrity of samples data from Piksi v3 HW. | ||
The regular Piksi v3 samples data format in one byte is: | ||
RF4 RF3 RF2 RF1 | ||
00 00 00 00 | ||
|
||
RF1 - GPS L1 | ||
RF2 - GLONASS L1 | ||
RF3 - GLONASS L2 | ||
RF4 - GPS L2 | ||
|
||
This utility is expecting RF3 and RF2 to have 4 bits counter, | ||
which is continuosly incremented with modulo SAMPLE_COUNTER_MODULO. | ||
RF2 is expected to have two least significant bits | ||
and RF3 - two most significant bits. | ||
Therefore, the bit indexes are: | ||
RF3 RF2 | ||
5&4 3&2 | ||
*/ | ||
|
||
#ifndef LIBSWIFTNAV_COUNTER_CHECKER_H | ||
#define LIBSWIFTNAV_COUNTER_CHECKER_H | ||
|
||
#include <stdint.h> | ||
#include <stddef.h> | ||
#include <libswiftnav/common.h> | ||
|
||
/** How many bytes we read from samples stream at a time. */ | ||
#define SAMPLE_CHUNK_SIZE (1024 * 1024) /* [bytes] */ | ||
|
||
/** The counter embedded into the sample data stream is expected | ||
to have this modulo. */ | ||
#define SAMPLE_COUNTER_MODULO 13 | ||
|
||
/** The counter bit size. */ | ||
#define SAMPLE_COUNTER_BITS 4 /* [bits] */ | ||
|
||
/** Teh counter bit offset within a byte. */ | ||
#define SAMPLE_COUNTER_OFFSET 2 /* [bits] */ | ||
|
||
/** How many bytes we read from samples file at a time. */ | ||
#define COUNTER_CHECKER_CHUNK_SIZE (1024 * 1024) /* [bytes] */ | ||
|
||
/** Get \e num of bits at \e offset in \e data */ | ||
#define GET_BITS(data, offset, num) \ | ||
( ((data) >> (offset)) & ((1 << (num)) - 1) ) | ||
|
||
/** Get \e num of bits at \e offset in \e data */ | ||
#define SET_BITS(data, offset, num, bits) \ | ||
( ( ~( ((1 << (num)) - 1) << (offset) ) & (data) ) | \ | ||
( ( (bits) & ((1 << (num)) - 1) ) << (offset) ) ) | ||
|
||
/** Get GPS counter | ||
* \param data Data byte | ||
* \return The counter value | ||
*/ | ||
uint8_t get_gps_counter(uint8_t data); | ||
|
||
/** Get Glonass counter | ||
* \param data Data byte | ||
* \return The counter value | ||
*/ | ||
uint8_t get_glo_counter(uint8_t data); | ||
|
||
uint8_t set_gps_counter(uint8_t data, uint8_t counter); | ||
uint8_t set_glo_counter(uint8_t data, uint8_t counter); | ||
|
||
/** A data mismatch descriptor. */ | ||
struct mismatch { | ||
size_t offset; /**! Data offset [bytes]. */ | ||
uint8_t data; /**! Data. */ | ||
uint8_t expected_counter; /**! The expected counter value. */ | ||
uint8_t actual_counter; /**! The actual counter value. */ | ||
}; | ||
|
||
/** Mismatch array data */ | ||
struct mismatch_data { | ||
/** The sample data counter mismatch incidents are stored here. */ | ||
struct mismatch data[COUNTER_CHECKER_CHUNK_SIZE]; | ||
/** How many valid entries there are in \e mismatch array. */ | ||
size_t counter; | ||
}; | ||
|
||
struct callbacks { | ||
size_t (*read)(void *ptr, size_t size, void *f); | ||
void (*rewind)(void *f); | ||
uint8_t (*get_counter)(uint8_t data); | ||
uint8_t (*set_counter)(uint8_t data, uint8_t counter); | ||
}; | ||
|
||
typedef size_t (*stream_read_t)(void *ptr, size_t size, void *stream); | ||
typedef void (*stream_rewind_t)(void *stream); | ||
|
||
uint8_t get_rf32_counter(uint8_t data); | ||
uint8_t set_rf32_counter(uint8_t data, uint8_t counter); | ||
uint8_t get_rf41_counter(uint8_t data); | ||
uint8_t set_rf41_counter(uint8_t data, uint8_t counter); | ||
|
||
void report_mismatch(const struct mismatch_data *mismatch); | ||
|
||
void counter_checker_init(void); | ||
|
||
const struct mismatch_data *counter_checker_run(struct callbacks *cbs, | ||
void *stream, | ||
size_t data_size); | ||
|
||
#endif /* LIBSWIFTNAV_COUNTER_CHECKER_H */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Copyright (C) 2016 Swift Navigation Inc. | ||
# | ||
# This source is subject to the license found in the file 'LICENSE' which must | ||
# be be distributed together with this source. All other rights reserved. | ||
# | ||
# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, | ||
# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED | ||
# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. | ||
|
||
from common cimport * | ||
from libcpp cimport bool | ||
|
||
cdef extern from "libswiftnav/cnav_msg.h": | ||
|
||
ctypedef struct cnav_msg_decoder_t: | ||
pass | ||
|
||
ctypedef struct cnav_msg_t: | ||
u8 prn # SV PRN. 0..31 | ||
u8 msg_id # Message id. 0..31 | ||
u32 tow # GPS ToW in 6-second units. Multiply to 6 to get seconds. | ||
bool alert # CNAV message alert flag | ||
|
||
void cnav_msg_decoder_init(cnav_msg_decoder_t *dec) | ||
bool cnav_msg_decoder_add_symbol(cnav_msg_decoder_t *dec, | ||
u8 symbol, | ||
cnav_msg_t *msg, | ||
u32 *delay) | ||
|
||
cdef extern from "libl2cbitstream/l2cbitstream.h": | ||
bool get_l2c_message(u8 *au_message, u8 prn, u8 msg_id, u32 tow) | ||
|
||
cdef class CNavMsgDecoder: | ||
cdef cnav_msg_decoder_t _thisptr | ||
cdef class CNavMsg: | ||
cdef cnav_msg_t _thisptr |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
# Copyright (C) 2016 Swift Navigation Inc. | ||
# | ||
# This source is subject to the license found in the file 'LICENSE' which must | ||
# be be distributed together with this source. All other rights reserved. | ||
# | ||
# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, | ||
# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED | ||
# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. | ||
|
||
from fmt_utils import fmt_repr | ||
from libc.string cimport memcpy, memset | ||
cimport numpy as np | ||
import numpy as np | ||
|
||
cdef class CNavMsgDecoder: | ||
|
||
def __init__(self, **kwargs): | ||
memset(&self._thisptr, 0, sizeof(cnav_msg_decoder_t)) | ||
cnav_msg_decoder_init(&self._thisptr) | ||
|
||
def __repr__(self): | ||
return fmt_repr(self) | ||
|
||
def decode(self, u8 symbol, CNavMsg msg): | ||
cdef u32 delay = 0 | ||
res = cnav_msg_decoder_add_symbol(&self._thisptr, | ||
symbol, | ||
&msg._thisptr, | ||
&delay) | ||
return res, delay | ||
|
||
cdef class CNavMsg: | ||
def __init__(self, **kwargs): | ||
memset(&self._thisptr, 0, sizeof(cnav_msg_t)) | ||
if 'prn' in kwargs: | ||
self._thisptr.prn = kwargs.pop('prn') | ||
if 'msg_id' in kwargs: | ||
self._thisptr.msg_id = kwargs.pop('msg_id') | ||
if 'tow' in kwargs: | ||
self._thisptr.tow = kwargs.pop('tow') | ||
if 'alert' in kwargs: | ||
self._thisptr.alert = kwargs.pop('alert') | ||
|
||
def __getattr__(self, k): | ||
return self._thisptr.get(k) | ||
|
||
def __repr__(self): | ||
return fmt_repr(self) | ||
|
||
def to_dict(self): | ||
return self._thisptr | ||
|
||
def from_dict(self, d): | ||
self._thisptr = d | ||
|
||
def __reduce__(self): | ||
return (rebuild_CNavMsg, tuple([tuple(self.to_dict().items())])) | ||
|
||
def getPrn(self): | ||
return self._thisptr.prn | ||
|
||
def getTow(self): | ||
return self._thisptr.tow | ||
|
||
def getMsgId(self): | ||
return self._thisptr.msg_id | ||
|
||
def getAlert(self): | ||
return self._thisptr.alert | ||
|
||
def rebuild_CNavMsg(reduced): | ||
""" | ||
Rebuild CNavMsg for unpickling. | ||
|
||
Parameters | ||
---------- | ||
reduced: tuple | ||
Tuple of dict of NavMsg cnav_msg_t struct fields | ||
|
||
Returns | ||
------- | ||
out: :class:`CNavMsg` instance | ||
Rebuilt :class:`CNavMsg` instance | ||
""" | ||
nm = CNavMsg() | ||
nm.from_dict(dict(reduced)) | ||
return nm | ||
|
||
|
||
cdef class CNavRawMsg: | ||
@staticmethod | ||
def generate(prn, msg_id, tow): | ||
cdef np.ndarray[np.uint8_t, ndim=1, mode="c"] tmp_ = np.ndarray(38, dtype=np.uint8) | ||
res = get_l2c_message(&tmp_[0], prn, msg_id, tow) | ||
return np.unpackbits(tmp_)[4:] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having removed
../include/
from here causes the python build to fail on Travis where the libraries are installed to an non-standard location. Maybe just have Travis install to~/.local/
?