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

GpsModel(struct SCType *S) always says Valid #144

Open
sdunlap-afit opened this issue Sep 30, 2024 · 4 comments
Open

GpsModel(struct SCType *S) always says Valid #144

sdunlap-afit opened this issue Sep 30, 2024 · 4 comments

Comments

@sdunlap-afit
Copy link

In 42sensors.c GpsModel(struct SCType *S), GPS->Valid is set true inside the SampleCounter if-statement but is only set to false if the RefOrb is not Earth. Is this the intended functionality (always valid after the first update) or a bug? Thanks.

for(Ig=0;Ig<S->Ngps;Ig++) {
            GPS = &S->GPS[Ig];
            
            GPS->SampleCounter++;
            if (GPS->SampleCounter >= GPS->MaxCounter) {
               GPS->SampleCounter = 0;
               
               GPS->Valid = TRUE;
               ....
@ericstoneking
Copy link
Owner

I wouldn't call it a bug, just a limitation of the model. All models are abstractions, and for various reasons some models in 42 are more fleshed out than others. The GPS model is pretty unsophisticated. If you need more fidelity, you may need to add it in yourself. I can't respond to all feature requests, but if you describe what you'd like to see, I'll at least consider it.

Regards,
-Eric

@sdunlap-afit
Copy link
Author

Thanks for getting back to me. I was going to use the Valid flag to determine if a new measurement was taken (due to slower sample times), but looking at the other sensor types (e.g., AcGyroType), I realize I'll need a different approach. I could use SampleCounter == 0 in the higher level types (e.g., GyroType) since that seems pretty consistent. How do you normally handle sample rates? I have a private fork of 42 that I can modify (I wanted to call my C++ code directly from 42fsw.c to keep sim times down).

Thanks,
Steve

@ericstoneking
Copy link
Owner

Hi Steve,

Sounds like you want a flag or a time tag in the sensor model, that you can check and clear in your sensor processing. For example,

In GpsModel, when the measurement is taken, set GPS->NewMeas = TRUE. Then, in your sensor processing...

if (GPS->NewMeas) { GPS->NewMeas = FALSE; [...process measurement...] }

There are variations on the theme, depending on needs and taste.

Regards,
-Eric (he/him)

@sdunlap-afit
Copy link
Author

Thanks Eric. That's effectively what I'm doing. I'm implementing some custom error models, so I think I'll handle the flag at the same time. That solves my problem. Thank you for your time!
Steve

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

No branches or pull requests

2 participants