BehaviorTree.CPP icon indicating copy to clipboard operation
BehaviorTree.CPP copied to clipboard

Problem with node cli arguments

Open panwauu opened this issue 3 years ago • 3 comments

I am trying to pass the tree path as a command line argument as described here. But whenever I add the ~(tilde) to the NodeHandle the tree execution fails on an instant. Sadly I have no clue why this could happen. Thanks for any input.

How to reproduce: In test_bt.cpp:

// Change line 184:
ros::NodeHandle nh;
// to 
ros::NodeHandle nh("~");

panwauu avatar May 15 '22 19:05 panwauu

In the implementation of BT::RosServiceNode, which is given the nh instance created on line 184 of test_bt.cpp, the node handle is used to create a ROS service client

https://github.com/BehaviorTree/BehaviorTree.ROS/blob/81f49f09179b6b93969dfb5a937a146a2325ed4f/include/behaviortree_ros/bt_service_node.h#L90

I don't think the ros::NodeHandle::serviceClient function is valid for private node handles (created with ros::NodeHandle nh("~"))

asasine avatar May 18 '22 14:05 asasine

Thanks, I will check this out

facontidavide avatar May 18 '22 14:05 facontidavide

I think that a better design of my template might use dependency injection: instead of cresting a new service client, an existing one should probably be passed as a reference/pointer. The same is true for a potential template of ROS subscriber

facontidavide avatar May 18 '22 17:05 facontidavide