ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

Create subscription from NodeTopicsInterface?

asked 2021-07-19 12:23:13 -0600

tylerjw gravatar image

How do I go about creating a subscription from the NodeTopicsInterface? The create_subscriptionmethod does not have the same interface. I found this:

Is there an example of how one should use NodeTopicsInterface to create a subscription, including documentation on what the factory is and how it should be configured?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2021-07-19 12:41:16 -0600

tylerjw gravatar image

After being shown an example of how to use rclcpp::create_subscription (the header I linked to) I realized it has nearly the same interface as rclcpp::Node::create_subscription.

In my case I was trying to replace this line:

joint_state_subscriber_ = node_->create_subscription<sensor_msgs::msg::JointState>( joint_states_topic, 25, std::bind(&CurrentStateMonitor::jointStateCallback, this, std::placeholders::_1));

Using the example here ( and the convenience constructor for rclcpp::QoS( I converted the line to work like this:

joint_state_subscriber_ = rclcpp::create_subscription<sensor_msgs::msg::JointState>( node_topics_interface_, joint_states_topic, rclcpp::QoS(25), std::bind(&CurrentStateMonitor::jointStateCallback, this, std::placeholders::_1));

Is there a place where these functions that are not part of rclcpp::Node are documented?

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2021-07-19 12:23:13 -0600

Seen: 118 times

Last updated: Jul 19 '21