Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix status from Lotek #87

Open
JessKLockhart opened this issue Jun 21, 2024 · 5 comments · May be fixed by #88
Open

Fix status from Lotek #87

JessKLockhart opened this issue Jun 21, 2024 · 5 comments · May be fixed by #88

Comments

@JessKLockhart
Copy link

I'm wondering if it's possible to obtain the fix status (i.e. 2D, 3D, etc) from lotek's collar download metadata with this package? I've been using the fetch_lotek_positions function and noticed that the fix status is missing, but I think this is an important field to include.

Thanks!

@ericnewkirk
Copy link
Collaborator

Thanks @JessKLockhart for the suggestion, but I'm not sure that's possible. fetch_lotek_positions returns all the columns provided by Lotek's API, so if fix type is missing there it means Lotek didn't provide it in the response to the API call. Unfortunately that API isn't well documented, and we don't have any clear explanation of what the columns and values within them mean. I looked into whether RxStatus or FixType in the output correspond to 2D/3D briefly this morning, but I didn't get all that far. I'm a little concerned the values in those columns may depend on the model of collar and settings, too.

If you can figure out how to translate the integer values in either of those fields to their text equivalents I'd be happy to update the code. It looks like there's a bug in that function that needs to be fixed anyway.

@JessKLockhart
Copy link
Author

Thanks @ericnewkirk. I'll see what I can find in terms of figuring out what the integer values for those fields actually mean. Will keep you posted.

@JessKLockhart
Copy link
Author

Hi again,

I connected with Lotek and they informed me that the Fix status is actually encoded into the 'RxStatus' field using binary to decimal. They sent me the manual, attached, which explains the conversion. They also sent a function that does the conversion (see below). Are you able to include this in the collar package? Thanks!

parse_RxStatus <- Vectorize(
function(x){
binary <- decimal2binary(x, length = 7)
# Binary is read right to left. The fix strategy is stored in the last two digits.
fix_strategy <- binary2decimal(binary[5:7])

# satellites
satellites <- binary2decimal(binary[1:4])

fix_type <- case_when(
  fix_strategy == 0 ~ "No Fix", # 1 = no fix
  fix_strategy == 1 ~ "1 SV KF",
  fix_strategy == 2 ~ "2 SV KF",
  fix_strategy == 3 ~ "3 SV KF",
  fix_strategy == 4 ~ "4 or more SV KF",
  fix_strategy == 5 ~ "2-D least squares",
  fix_strategy == 6 ~ "3-D least squares",
  fix_strategy == 7 ~ "Dead Reckoning")

return(paste0(fix_type, ", ", satellites, "SVs"))}

)

Web-Service-API-User-Manual.pdf

@ericnewkirk
Copy link
Collaborator

Thanks @JessKLockhart! The manual is super helpful, and a lot better than what we had available when the Lotek functions were originally written. I will probably rewrite the conversion code to streamline it a bit and make sure it works for all Lotek devices, but that should be quick.

@JessKLockhart
Copy link
Author

Great! Thanks @ericnewkirk!

@ericnewkirk ericnewkirk linked a pull request Jul 26, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants