opened
rikba
username_0
Thank you for providing this state machine @username_1 . 

I am wondering if I could somehow tell my task to do a certain operation only if the parameters have changed.

I.e.
```
task_manager_lib::TaskIndicator TrajectoryGeneration::iterate() {
  if (cfg.magic_changed_flag) {
     updateTrajectory();
  }

  return tmm::TaskStatus::TASK_RUNNING;
}
```
where I am looking for such `magic_changed_flag`.

Cheers.
Change task behaviour when dynamic parameter changes.
issue
created
cedricpradalier
username_1
Hello,

You could do it this way and in this case, you could define your magic flag in the .cfg file corresponding to your task. You would then need dynamic_reconfigure GUI to update the flag.

However, I don't think this is the correct approach. It would make more sense for your task to create a service or a subscriber for this magic_flag event (maybe a std_msgs/Bool), and trigger the replanning using the appropriate ROS mechanisms. You could also put the subscriber/service in the environment is several tasks will need the same variables. 

Update of the task parameters with dynamic reconfigure was designed initially for control gains, to make it easier to fine tune a task control law. I don't think they are the right mechanism for system-level interaction with the task.
comment
created
rikba
username_0
I agree that it would be wrong to send a command to my node via rqt_reconfigure.

We currently use rqt_reconfigure to change the trajectory parameters, e.g., maximum velocity. And we were wondering if our task could only recalculate the trajectory if we change these parameters instead of constantly replan even if the parameters did not change. Kind of like a callback to the rqt_reconfigure server.

Maybe that's both the same and we should reconsider our design and replan on a specific event, e.g., service request.

If you have another idea of monitoring changing rqt_reconfigure parameters I'd appreciate. Otherwise you can consider the issue closed and I rework our design :)
comment
created
cedricpradalier
username_1
The only alternative so far would be for you to store the value of the parameter (or the whole cfg structure) as a class member and check if it has been changed when entering iterate, this is typically how the  callbacks for dynamic reconfigure are implemented. 

It would also be possible to add a ros::Time to the callback to record when the dynamic reconfigure callback was called but I am not sure this is the right design. Feel free to give it a go. The class that register the dynamic reconfigure server is TaskDefinition in task_manager_lib.
comment
created
rikba
username_0
Thanks! These are plausible ideas. We will consider implementing one of both when the trajectory generation becomes a bottleneck! I'd maybe go for the second version as this does not require manually copying all parameters.
comment
closed
rikba
username_0
issue
created
cedricpradalier
username_1
Hi,

I just found out that all task instance can overload the reconfigure function. This would be an easy way for you to handle your replanning only when a configure event has been triggered.

From TaskDefinition.h:
                // Setup a dynamic reconfigure server that just update all the
                // config. To be updated 
                virtual void reconfigure(CFG &config, uint32_t level) {
                    cfg = config;
                }
comment
created
rikba
username_0
Awesome!
comment