0
$\begingroup$

I am trying to write a behaviour plugin which using Timed Behaviour. The behaviour does some calculations and the return a result, which has to be written to the blackboard of the bt_navigator. Is there any way to achieve this using the provided behaviour plugin architecture? Or should I implement this using some other method?

Thanks in advance!

$\endgroup$

1 Answer 1

1
$\begingroup$

Yes:

  • Create your plugin's action interface, which should have whatever values you want to have returned and on the blackboard (among others)
  • Implement the behavior plugin using that action interface, populating its contents and 'doing the thing'
  • Implement a BT.CPP Node plugin which takes in that data and in the on_* callbacks puts the values you want on the blackboard

QED!

This same pipeline is used by all Nav2 Action Servers and you can see examples of this if you track the ComputePathToPose or FollowPath actions. The BT.CPP node we have action base classes that make this very trivial in < 50 lines of code or so.

$\endgroup$
4
  • $\begingroup$ Thanks for the reply! The result in the Timed Behaviour class is initialised in the execute function making it inaccessible to the derived class. Is there a reason for this? For now I will try implementing using nav2_core::Behvaior as the base class. $\endgroup$
    – Sriram
    Commented Jul 2 at 5:00
  • $\begingroup$ You have access to the result to modify in the on action completion method: github.com/ros-navigation/navigation2/blob/jazzy/nav2_behaviors/… $\endgroup$ Commented Jul 2 at 19:48
  • $\begingroup$ Thanks for your reply, since we are using ros2 humble this is not available, is there a backport available? If not it seems to be a simple fix. Thanks a lot! $\endgroup$
    – Sriram
    Commented Jul 3 at 6:33
  • $\begingroup$ Unfortunately not, that is an API breaking change. You'll need to upgrade to get it. $\endgroup$ Commented Jul 3 at 22:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.