BehaviorTree / BehaviorTree.ROS2

BehaviorTree.CPP utilities to work with ROS2
Apache License 2.0
144 stars 59 forks source link

Unable to use behaviortree_ros2 plugin #85

Closed KaiYuanBu closed 1 month ago

KaiYuanBu commented 2 months ago

Recently was exploring the use of plugin for behaviortree_ros2, after colcon build, I ran the command "ros2 run ros2 run btcpp_ros2_samples sleep_server" on one terminal and another command "ros2 run btcpp_ros2_samples sleep_client_dyn " in another terminal. But the client terminal was unable to run and return the following error:

`terminate called after throwing an instance of 'BT::RuntimeError' what(): Could not load library: ../lib/libsleep_action_plugin.so: cannot open shared object file: No such file or directory

`

So i tried to copy the relative path of the .so file in the install directory and paste it into line 80 of the code. Below is the before change and after change.

BEFORE:

ifdef USE_SLEEP_PLUGIN

RegisterRosNode(factory, "../lib/libsleep_action_plugin.so", params);

else

factory.registerNodeType("SleepAction", params);

endif

AFTER:

ifdef USE_SLEEP_PLUGIN

RegisterRosNode(factory, "install/btcpp_ros2_samples/lib/btcpp_ros2_samples/libsleep_plugin.so", params);

else

factory.registerNodeType("SleepAction", params);

endif

I then colcon build and tried to run the code again, but it said that the ID "Sleep" is already registered. `terminate called after throwing an instance of 'BT::BehaviorTreeException' what(): ID [Sleep] already registered

` Not sure if this is an issue or I am doing something wrong. Please do provide guidance. Thank you.

UPDATE: Was able to resolve the issue by redoing the git clone for this package and installing all the dependencies and changing the path of the .so file to the correct path.