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

Flight task auto params #9287

Merged
merged 6 commits into from
Apr 16, 2018
Merged

Flight task auto params #9287

merged 6 commits into from
Apr 16, 2018

Conversation

Stifael
Copy link
Contributor

@Stifael Stifael commented Apr 11, 2018

@bkueng can you have a look?

@Stifael Stifael requested a review from bkueng April 11, 2018 09:23
param_t MPC_TILTMAX_AIR_h { PARAM_INVALID };
param_t MPC_MAN_TILT_MAX_h { PARAM_INVALID };
DEFINE_PARAMETERS(
(ParamFloat<px4::params::MPC_THR_MAX>) MPC_THR_MAX,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I strongly suggest you stick to the usual naming pattern for members: something like _maximum_thrust. Otherwise we have another inconsistency in the code-base.
However it's not part of this PR.

Copy link
Contributor Author

@Stifael Stifael Apr 11, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I discussed that with @MaEtUgR, and we came to the conclusion that it is more confusing to redefine the parameter names. For instance, the parameter in one module can have a complete different name in another module. In addition, from the name it is also not clear who is the owner of that parameter.

Reusing the name of the metadata removes the consistent redefinition of parameter names...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That needs a bigger upstream discussion then, you cannot simply make that decision in an unrelated PR. And if decided someone needs to go through the codebase and update all other places.
In addition, there are also reasons against this, for example:

  • allows to use more descriptive variable names, since params are restricted to 16 chars.
  • naming consistency with other other class members: after all, a parameter is just a class member like any other
  • naming conflicts/inconsistencies with macros/globals: typically macros or globals use all uppercase. This is also confusing for newcomers

Copy link
Contributor Author

@Stifael Stifael Apr 11, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That needs a bigger upstream discussion then, you cannot simply make that decision in an unrelated PR

I don't expect that this PR (= base of this PR) gets merged soon, but you are right, probably these param name changes should not be added to this PR. In the meantime I will initiate a discussion about parameter naming.

after all, a parameter is just a class member like any other

Not really. There should be a distinction between class members that change regularly (like setpoints) and class members that are parameters which do not change frequently.

naming conflicts/inconsistencies with macros/globals: typically macros or globals use all uppercase. This is also confusing for newcomers

I am sure that can be easily solved by adding a px4 convention page in the px4 devguide. I think the fact that there is no formal px4 convention page is the root cause of the confusion because a beginner has no chance to know what is legacy code vs expected px4 implementation.

Copy link
Contributor

@hamishwillee hamishwillee Apr 11, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am sure that can be easily solved by adding a px4 convention page in the px4 devguide. I think the fact that there is no formal px4 convention page is the root cause of the confusion because a beginner has no chance to know what is legacy code vs expected px4 implementation.

That sounds like a good idea. Probably as a sub-page of Contribution. All we have at the moment is that you should use astyle for formatting.

Can you (or @bkueng ) create an issue outlining the main conventions you are interested in - in bullet point form and ideally with examples. We can then drag in others and iterate.

* This method should only be called if parameters
* have been updated.
*/
void overwriteParams();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you make ModuleParams::updateParams virtual, and override it here instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, that could work as well

MPC_MAN_TILT_MAX = math::radians(MPC_MAN_TILT_MAX);

// Tilt needs to be in radians
MPC_TILTMAX_AIR.set(math::radians(MPC_TILTMAX_AIR.get()));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is prone to errors: if for some reason overwriteParams is not called, or several times, or you use MPC_TILTMAX_AIR.commit(), you will have completely wrong values. I suggest using a separate class member instead (I used the _deg suffix to make clear which one is in degrees). Not super nice, but much less error prone.

@Stifael Stifael merged commit a5a506c into FlightTask-Auto Apr 16, 2018
@Stifael Stifael deleted the FlightTask-Auto-params branch April 16, 2018 09:05
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 this pull request may close these issues.

3 participants