-
Notifications
You must be signed in to change notification settings - Fork 13.7k
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
Conversation
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) |
There was a problem hiding this 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); } |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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();
There was a problem hiding this comment.
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())); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
93d3f2b
to
ee7d9d6
Compare
ee7d9d6
to
939984a
Compare
…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.
…ontrol due to param dependencies
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
Circleci failure unrelated ( |
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)? |
Until now there was no need for that, but we can easily extend for that by making |
Same as #9159, but rebased & against master now
@Stifael I suggest we merge this before #9253