ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Create subscription from NodeTopicsInterface?

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

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: https://github.com/ros2/rclcpp/blob/2...

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
1

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

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 (https://github.com/ros-visualization/...) and the convenience constructor for rclcpp::QoS(https://docs.ros2.org/dashing/api/rcl...) 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

Question Tools

1 follower

Stats

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

Seen: 235 times

Last updated: Jul 19 '21