WEBVTT

00:00.320 --> 00:06.230
Finally, we can try out our transmitter node and see how we can communicate with the Arduino board

00:06.260 --> 00:07.340
through the Ros.

00:07.340 --> 00:08.270
Two topics.

00:08.300 --> 00:11.660
In order to turn a Led on or off.

00:12.400 --> 00:13.360
To do this.

00:13.390 --> 00:18.400
First, let's connect the Arduino board to our PC using an USB cable.

00:22.620 --> 00:28.080
Then open the Arduino IDE to check which port the board is connected to.

00:28.170 --> 00:30.210
So in the tools.

00:31.140 --> 00:31.830
Port.

00:32.070 --> 00:36.060
In my case, this is the ACM zero port.

00:36.980 --> 00:42.170
And then since we have already uploaded the code to the Arduino board in the previous lesson, we no

00:42.170 --> 00:49.520
longer need the Arduino IDE so we can proceed to start our transmitter node, which reads the messages

00:49.520 --> 00:54.290
from our ros2 topic and sends them through the serial port to the Arduino.

00:54.740 --> 00:58.730
So let's open a new terminal and let's go to the workspace.

00:58.970 --> 01:03.680
And here let's source the file setup dot bash.

01:03.680 --> 01:12.200
So source the workspace and let's start our Ros two node with the command Ros two run and from the Arduino

01:12.200 --> 01:14.510
bot firmware package.

01:14.510 --> 01:18.380
Let's start the simple serial transmitter node.

01:18.470 --> 01:22.940
Now with this, I'm going to start the cplusplus implementation of this node.

01:22.970 --> 01:29.690
Otherwise, if you want to launch the Python implementation of this node, let's just type dot pi.

01:30.080 --> 01:33.650
And so this one will launch the Pi implementation of this node.

01:34.310 --> 01:40.410
Also before starting the node it needs to be configured, so we need to assign a value to the parameter

01:40.410 --> 01:41.100
port.

01:41.130 --> 01:48.720
So let's use the Ros args and then let's assign a parameter to the port.

01:49.170 --> 01:53.580
And this is the port of your PC to which the Arduino is connected.

01:53.580 --> 02:01.020
So in my case this is the M0 port, so let's press enter.

02:01.170 --> 02:07.470
And upon starting this node it does nothing but initialize the serial communication with the Arduino

02:07.470 --> 02:09.000
on the indicated port.

02:09.000 --> 02:11.430
So on the ACM zero port.

02:11.790 --> 02:16.950
Additionally, the node is also listening on a Ros two topic called Serial Transmitter.

02:17.070 --> 02:23.130
In fact, if we open a new terminal and we execute the command Ros two topic list.

02:23.980 --> 02:32.680
We can see that the serial transmitter topic exists and so we can use it to turn on or off the light

02:32.680 --> 02:34.450
that is embedded in the board.

02:34.780 --> 02:40.290
To do so, we can use the command Ros2 topic Poop.

02:41.120 --> 02:46.130
And so let's publish a message on the serial transmitter.

02:46.160 --> 02:48.200
Then let's press tab twice.

02:48.320 --> 02:51.530
And then let's type the type of the interface.

02:51.530 --> 02:57.130
So the standard message string that we are going to use in order to send messages within this topic,

02:57.140 --> 02:58.970
then use the double quotes.

02:59.000 --> 03:03.500
Then let's type the letter D and let's press tab again.

03:03.500 --> 03:09.080
And so this will insert an empty prototype of the string message which we can publish on the serial

03:09.080 --> 03:10.280
transmitter topic.

03:10.490 --> 03:16.310
For example, let's turn on the led by publishing the value one on this topic.

03:16.310 --> 03:18.170
So let's press enter.

03:18.170 --> 03:22.310
And as soon as we do so we can see, we can interrupt this one.

03:22.310 --> 03:27.620
We can see that the Led that is integrated into the board is on now is turned on.

03:28.230 --> 03:33.600
If we send another message, for example, now let's send the message zero.

03:33.960 --> 03:35.760
So let's send it.

03:35.760 --> 03:41.280
And now we can see that as soon as we send this message, the lead that is embedded in the board is

03:41.280 --> 03:42.240
turned off.
