-
Notifications
You must be signed in to change notification settings - Fork 430
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
Exception when declaring parameters after callback is set #769
Comments
|
The callback is rather long to be copied, but you can check the code here: https://github.com/ros-drivers/urg_node/pull/50/files#diff-d6a6026f1c3c9643497413ff2fc498caR271 It is basically checking for the parameters set in the URG node and returns Why multiple callbacks are ideal? The diagnostic updater uses the node interfaces of the outer URG node. So it declares the diagnostics related parameters on the URG node parameter interface. If I could register multiple callbacks on the same parameter interface, then the URG node could use its callback to really only verify laser related parameters, whereas the diagnostic updater can use its own callback to only check for diagnostic related parameters and both don't interfere with each other. The alternative right now is that every node which is using diagnostics has to know the intrinsics of it and deal with parameters and their changes respectively. That means, every time a new diagnostics parameter was to be introduced, every package using diagnostics has to be updated as well. Does this make sense? |
The callback looks good. I will try to do a simpler repro, as it should be possible to register the callback before declaring the parameters.
Ok, now I understand better. I think that adding the ability of registering multiple callbacks would be good. Well, maybe it's better just to add multiple callbacks .... |
@Karsten1987 About the bug (calling Edit: |
@Karsten1987 #772 added support to multiple |
Great work @ivanpauno. I haven't gotten around to test it, but from what I've seen I think it's on the spot. I'll give it a shot ASAP. |
@ivanpauno I finally had some time to continue working on this. It looks to me as if I am still doing something wrong. I've uploaded a little dummy project here to illustrate what I am trying to do: To give a little bit context to that package: There are two sorts of node packages sketched.
Keep in mind that both classes in this case could be potentially be written by two individually packages (i.e. If you build and run this package, you'll get the following error:
Which indicates that in this case only the callback set in the outer node class is taken into consideration: When I then go ahead and change the order here, meaning adding the callback after declaring the inner node parameter, I get the following order:
Which means, it's taking the correct callback (it parses its parameter correctly), but fails after. I am a bit puzzled about it, but I feel that the call fails because the second callback of the outer node fails. That does mean the order of the callbacks matter? Could this assumption be correct or am I doing something wrong? I am a bit puzzled here. In general, two more questions came into my mind while testing: 1.) Given that the two nodes might be developed independently (as I motivated with the |
The problem is that your callbacks are by default rejecting a change, when they should be accepting it. Callback results are combined like an https://github.com/Karsten1987/parameter_test/blob/66b3fc9c15c0a457de6d63ccd9f3fd8a333c9ec0/include/parameter_test/outer_node.hpp#L38
I agree that 2.) Is it recommended to always set the callback functions before declaring the parameter? Yes, that will validate the default value of the parameter or the override provided by the user (override=value provided as command line argument). |
I somehow feel that defaulting to
It somehow does if the previously set callback doesn't default to true. |
The idea is to have both |
Can you give an example of how two callbacks attached to the same node are not checking a disjoint set of parameters? I am going to close this issue as I believe the actual topic of this issue - the exception - is being addressed. I am not convinced that the logical AND is the best solution here, but that's out of scope for this issue. |
It's not an usual case, but I prefer not limiting the implementation to it. I think that it's a good idea to bring up the discussion in a team meeting, and decide if we want to go with |
* Add coverage tests wait module * Add fault injection test * Add zero_init allocator test to init * Remove bomb allocator test * Add better handling fault injection * Add comment to fault injection tests * Move test to another section Signed-off-by: Jorge Perez <jjperez@ekumenlabs.com>
I am struggling with how to declare parameters for my
diagnostic_updater
. Specifically, I have the following setup: I am spawning theURG
laser driver, which is a node and has a diagnostics updater instance as a class member variable. That diagnostics updater takes a node (or better node interfaces) in its constructor. The diagnostics updater has a parameterperiod
which is meant to be updated dynamically. The URG node itself has multiple laser specific parameters declared as well.Within code, this kind of looks like this:
I am noticing two problems with this:
1.) When having
set_on_parameters_set_callback
called before initializing the diagnostics updater instance, I am unable to declare any parameter within the diagnostics instance as the assigned callback for the URG node is not aware of the diagnostics parameter and I get an exception:So I had to make sure that the parameter callback is set at last and no new parameters were declared after that.
2.) When modifying the
URG
callback in a way to catch a change of parameter for the diagnostics updater (i.e. the parameter "period"), I need public API on the diagnostics updater in order toset/get
the current period on it. Plus, every other node which uses diagnostics, e.g.cartographer
has to write the same logic in their code.After thinking about this for a while, I'd like to have the parameter
period
being solely declared within the diagnostics updater and ideally have a callback for that parameter which is handled within the diagnostics updater itself.I remember we talked about having multiple callbacks for parameters, especially with cases like
use_sim_time
. Is that possible with the current dashing API? If not, do you have any suggestions on how to handle that case?The text was updated successfully, but these errors were encountered: