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 tasks: param refactoring #2 #9255

Merged
merged 8 commits into from
Apr 11, 2018
Merged

Conversation

bkueng
Copy link
Member

@bkueng bkueng commented Apr 6, 2018

Same as #9159, but rebased & against master now

@Stifael I suggest we merge this before #9253

@Stifael Stifael mentioned this pull request Apr 6, 2018
1 task
@Stifael
Copy link
Contributor

Stifael commented Apr 6, 2018

looks again good, but I have not paid attention to the mc_pos_control changes yet.

Need to free some flash again though.

FYI #9257 (comment)

Copy link
Member

@MaEtUgR MaEtUgR left a comment

Choose a reason for hiding this comment

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

If the parameter library now works with that client code it's simply genius!!

I looked through pretty much indetail and hopefully didn't miss anything. It looks good except for the _z_vel_i copy pasta error.

void overwriteAccelerationUp(float acc_max_up) {_acc_max_up = acc_max_up;};
void overwriteAccelerationDown(float acc_max_down) {_acc_max_down = acc_max_down;};
void overwriteJerkMax(float jerk_max) {_jerk_max = jerk_max;};
void overwriteAccelerationUp(float acc_max_up) { _acc_max_up.set(acc_max_up); }
Copy link
Member

Choose a reason for hiding this comment

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

I think these overwritten values are temporary and should not be saved to the parameters in the flash memory right?Is that still the case?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, it does not write back to the param store

/**
* Call this whenever a parameter update notification is received (parameter_update uORB message)
*/
void handleParameterUpdate()
Copy link
Member

Choose a reason for hiding this comment

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

I'm assuming this method is added such that a task can customize its checks/reactions to parameter changes right?

Copy link
Member Author

Choose a reason for hiding this comment

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

The primary purpose to call the protected updateParams method. If needed, it can be used for additional checks as well, but it will need to be made virtual.

/* since we use filter to detect manual direction change, take half the cutoff of the stick filtering */
param_get(_params_handles.rc_flt_cutoff, &(_params.rc_flt_cutoff));
ModuleParams::updateParams();
SuperBlock::updateParams();
Copy link
Member

Choose a reason for hiding this comment

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

That seems strange to have both... is that temporary because something is still legacy?

Copy link
Contributor

Choose a reason for hiding this comment

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

_vel_p(1) = _xy_vel_p.get();
_vel_p(2) = _z_vel_p.get();

_vel_i(0) = _z_vel_i.get();
Copy link
Member

Choose a reason for hiding this comment

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

xy velocity should have a different integral gain than z.

_vel_i(0) = _xy_vel_i.get();
_vel_i(1) = _xy_vel_i.get();

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks, fixed

_vel_d(1) = _xy_vel_d.get();
_vel_d(2) = _z_vel_d.get();

_thr_hover.set(math::constrain(_thr_hover.get(), _thr_min.get(), _thr_max.get()));
Copy link
Member

Choose a reason for hiding this comment

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

.set() only sets the parameter locally temporarily right? Altought if it's out of bounds it could be saved back as feedback for the user that the velue he changed actually doesn't apply.

Copy link
Member Author

Choose a reason for hiding this comment

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

Correct. I thought about it, and we could write it back, but I did not want to change the behavior in this PR.

Copy link
Contributor

@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.

What does that mean locally? If I there are two modules that both consume the same parameter, and in one of the modules I use the setter method for that parameter, does the other module then have the new value or the default?
Or another scenario: If there is a class member that also uses the same parameter as the base class and the base class overwrites one parameter with the setter method, what is the value of the parameter that the member class will consume?

Copy link
Member Author

Choose a reason for hiding this comment

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

If I there are two modules that both consume the same parameter, and in one of the modules I use the setter method for that parameter, does the other module then have the new value or the default?

It keeps the previous value. You can use the commit() method to store it persistently and notify all modules about the param change.

If there is a class member that also uses the same parameter as the base class and the base class overwrites one parameter with the setter method, what is the value of the parameter that the member class will consume?

If it accesses the same class member, it will have the updated value. If you define the same param in the subclass as a different class member, it's separate with the same behavior as in the separate modules case.

Copy link
Contributor

Choose a reason for hiding this comment

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

If you define the same param in the subclass as a different class member, it's separate with the same behavior as in the separate modules case.

good to know. thanks

@bkueng bkueng force-pushed the flight-task-param-refactoring branch from 93d3f2b to ee7d9d6 Compare April 10, 2018 07:42
@bkueng bkueng force-pushed the flight-task-param-refactoring branch from ee7d9d6 to 939984a Compare April 10, 2018 07:49
…p equal strings

reduces roughly 130 bytes. Almost enough to pass CI.
Since assertions lead to crashes, we need better failure handling. In all
the cases in this patch, the assert is not required.

All the ones with the task id should be replaced with the module base
class.

Ah yes, and this reduces flash space, since the ASSERT macro will expand to
a printf that contains the source file name.
Copy link
Member

@MaEtUgR MaEtUgR left a comment

Choose a reason for hiding this comment

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

Fixed

@bkueng
Copy link
Member Author

bkueng commented Apr 11, 2018

Circleci failure unrelated (Action failed: brew install px4-dev)

@bkueng bkueng merged commit b52a8de into master Apr 11, 2018
@bkueng bkueng deleted the flight-task-param-refactoring branch April 11, 2018 05:47
@Stifael
Copy link
Contributor

Stifael commented Apr 11, 2018

In general, how does a class member, that consumes parameters, knows when a new update of the parameter occurred (for instance the member class SmoothingZ.cpp)?

@bkueng
Copy link
Member Author

bkueng commented Apr 11, 2018

Until now there was no need for that, but we can easily extend for that by making ModuleParams::updateParams() virtual, and override it in the smoothingZ class for instance.

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