nullptr when implement a ROS2 subscriber condition node #800
Unanswered
SFhmichael
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi all, I am implement a BT condition node as a ROS2 subscriber, so that I can get some states from the topic and decide the condition node to return SUCCESS or FAILURE.
In BehaviorTree.ROS2/behaviortree_ros2/include/behaviortree_ros2/bt_topic_sub_node.hpp
https://github.com/BehaviorTree/BehaviorTree.ROS2/blob/ce923e19c12d28f4734a41b1442c123f2d4a41d2/behaviortree_ros2/include/behaviortree_ros2/bt_topic_sub_node.hpp#L97
And the onTick function is implement in btcpp_ros2_samples/src/subscriber_test.cpp
https://github.com/BehaviorTree/BehaviorTree.ROS2/blob/ce923e19c12d28f4734a41b1442c123f2d4a41d2/btcpp_ros2_samples/src/subscriber_test.cpp#L20
What I can't understand is the reason that put last_msg_ = nullptr every tick, this means when the frequency of tick(ontick), is higher than the message published, and I want to use the content of topic to identify the condition to return SUCCESS or FAILURE. There will be a segmentation fault since the the next message doesn't come in and the content of pointer is null.
The following is my onTick function, and I will get segV because last_msg->data is empty.
Beta Was this translation helpful? Give feedback.
All reactions