Commit 50a69310 authored by CANNERE Xavier's avatar CANNERE Xavier
Browse files


parent 54d6eaa1
......@@ -58,7 +58,7 @@ Now we'll create a class ``visual``, we'll declare inside this class the main al
You can add the following line in the ``main`` before the ``spin``, it will define which node will be launched::
You can add the following line in the ``main`` before the ``spin``, it will declare which node will be launched by the spin::
auto node = std::make_shared<Visual>();
......@@ -100,10 +100,31 @@ Make sure your code looks like this::
return 0;
Step 3 : The constructor
Step 3 : Add the input and output topics
We'll declare the subscription of camera to take its information. First declare as global variable between the class and the include::
rclcpp::Subscription<sensor_msgs::msg::Image>::SharedPtr img_;
*img* is a subscriber of a *sensor_msgs* as an *image*
Now declare that in the constructor::
auto sensor_qos = rclcpp::QoS(rclcpp::SensorDataQoS());
img_ = this->create_subscription<sensor_msgs::msg::Image>(
"/camera/rgb/image_raw", sensor_qos,
std::bind(&Visu::getImage, this, std::placeholders::_1));
The first line declare the configuration of the execution for a sensor (QoS, for more information visit : The second line declare the variable *_img* into the constructor (the method getImage doesn't yet exist.
Same for the publisher, declare the global variable::
rclcpp::Publisher<geometry_msgs::msg::Twist>::SharedPtr pub_;
And in the constructor::
pub_ = this->create_publisher<geometry_msgs::msg::Twist>("/cmd_vel", 1);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment