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

reduce the use of param_find("XXX") #13089

Closed

Conversation

BazookaJoe1900
Copy link
Member

@BazookaJoe1900 BazookaJoe1900 commented Oct 3, 2019

reduce the use of param_find("XXX") in favor to param_handle(px4::params::XXX)

The pr is replacement to #13076

In case parameter is not in a version, there will be build time error.

My method was to set all parameters to use param_handle(px4::params::XXX) and then find what is not being built.
that mean that every place that there you can still find a param_find("XXX") some build/s been broken.
That mean that those places basically need to be fixed.
on some places the error seems as more critical then others, for example building px4_fmu-v2_test need the parameter FW_PSP_OFF but it doesn't exists. and later there is no check if it exists or not. that mean that in _params_handles_standard.pitch_setpoint_offset there is PARAM_INVALID and later there is garbage when trying to fetch the parameter

…ams::XXX)

that allows build time error if parameter is no in a version
@dagar
Copy link
Member

dagar commented Oct 3, 2019

We actually need to be more careful here than it first appeared. One difference is the param_find() also marks the parameter active (which then syncs to QGC).

#13081 (comment)

@BazookaJoe1900
Copy link
Member Author

BazookaJoe1900 commented Oct 4, 2019

I must say that in general I don't like the idea of "active" parameter. I think that either there is a parameter on a system or not.
In my custom firmware I added a do_touch_all() in order to set all the parameters as active.
the most problematic issue of having 'active' parameters is that copying a parameter file from drone to drone sometimes misses some parameters, as described on #12432.

the advantage of keep using 'active' is that downloading parameters might take a bit faster.
Or I missing another advantage?

@dagar
Copy link
Member

dagar commented Oct 6, 2019

I must say that in general I don't like the idea of "active" parameter. I think that either there is a parameter on a system or not.
In my custom firmware I added a do_touch_all() in order to set all the parameters as active.
the most problematic issue of having 'active' parameters is that copying a parameter file from drone to drone sometimes misses some parameters, as described on #12432.

the advantage of keep using 'active' is that downloading parameters might take a bit faster.
Or I missing another advantage?

Yes it makes downloading faster, but it's more fundamental in that it's really what makes the system scalable from a user perspective. We can have release binaries with all kinds of controllers and drivers, but the user is only going to see a relevant subset for configuration.

The pattern that should be enforced is that a module should be marking all of its parameters active when it starts. Virtually all the problems have come from doing this lazily or incorrectly.

@LorenzMeier
Copy link
Member

Seconding here - all what Daniel says its correct. The system is only tractable with this enabled. The same way that C++ requires correct initialization of pointers we require correct initialization of parameters. You can argue that the programming environment should address both, but then really the right starting point is to replace C++ with something a lot more defined, and that is what most people are not debating.

If you go down that path you ought to use purely compile-time configurations and binaries for every single airframe type - and yet PX4 has won against these legacy architectures because it creates an ecosystem that is able to generalize more and move faster.

@BazookaJoe1900
Copy link
Member Author

@dagar @LorenzMeier thanks for the replay, I appreciate how you look of things, and agree. My case study is after I removed most of the modules that are not relevant to me...
setting all parameters by do_touch_all() function that I added is optional, and that why I didn't even added it to the PX4/Firmware, I can if you want.

still, about this pr. there is still need to minimize the use of param_find("XXX"), and use hardcoded parameter name. so how about using param_set_used() in param_handle()?

@dagar
Copy link
Member

dagar commented Oct 6, 2019

still, about this pr. there is still need to minimize the use of param_find("XXX"), and use hardcoded parameter name. so how about using param_set_used() in param_handle()?

How about adding a param_find that only takes enum and marks it active? It would have to be c++ only similar to this.

https://github.com/PX4/Firmware/blob/941a3258b6e87640a52365fe003db1ec6bb898cd/src/lib/parameters/param.h#L491-L500

Then the replacement would be even cleaner.

param_find("BAT_SOURCE") -> param_find(px4::params::BAT_SOURCE)

@BazookaJoe1900
Copy link
Member Author

I am not sure that 'param_find()' will be the right term, you don't really search for it, you know it exist.
from what I see param_handle() isn't used almost, any just add param_set_used_internal() won't break anything.

@BazookaJoe1900
Copy link
Member Author

@dagar, should I close this issue, and #12992?

@BazookaJoe1900
Copy link
Member Author

seems to be irrelevant, closing

@BazookaJoe1900 BazookaJoe1900 deleted the pr-reduce_use_param_find branch January 24, 2020 07:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants