Use a Linux terminal and
execute dmesg or dmesg | grep
tty. The dmesg will show the kernel
logs and we can find the serial
device corresponding to the
Arduino. The output of dmesg &
dmesg | grep tty is shown in
Figure 7 and Figure 8.
The device name for the Arduino is ttyACM0. It
may be different for each system.
ROS Running on VirtualBox
SERVO 11.2016 33
Figure 7. Linux kernel messages.
Figure 8. Dmesg and grep messages.
If you are working from Windows and VirtualBox,
you first need to install the proper driver of the Arduino for
Load the sketch,
compile it, and upload it to the board.
Note: If you are getting a permission denied error or
something similar, you can do the following fix to solve it.
These commands will allow us to add a current user
into a group called dialout. This group user can access a
serial device without permission:
Windows. The drivers are available in the Arduino
installation folder itself. You may need to download
“Arduino for Windows” to get this driver. After installing the
driver, use the Windows Device Manager to check the serial
port number of the Arduino. If everything is set, it should
look like Figure 9. You will only see this if the Arduino
drivers are properly installed. After setting the drivers, you
can share this serial device in VirtualBox.
sudo usermod -a -G dialout <username>
Launch VirtualBox and got to Settings -> Serial Port.
Share the real port in the guest OS as shown in Figure 10.
To set the read/write permission to the existing serial
device, use this:
Here, the actual device is COM5:. In the guest device, it
is going to be COM1 which corresponds to ttyS0 in Linux.
sudo chmod 666 /dev/ttyACM0 or ttyS0
Setting the Board Name and Port
in the Arduino IDE Running on
If everything is working great, upload an Arduino-ROS
client code for blinking an LED on the Arduino board. You
will get it from File -> Example -> ros_lib -> Blink.
After getting the serial port number of the Arduino, we
should set these parameters inside the Arduino IDE. Here is
how we do that.
First Project: Blink an LED
To set the board name, go to the IDE Menu Tools -
>Board ->Arduino Mega 2560. Also set the port name from
rosserial Subscriber Example
Blinks an LED on callback
Tools -> Port ->ttyS0.
// Arduino ––ROS headers
If you are working
from a PC, the port will
be ttyACMO. If you
VirtualBox, recall the
port that we assigned
was ttyS0. Test the
the Arduino and
VirtualBox by burning a
Figure 10. Sharing a
serial port in VirtualBox.
File -> Examples ->
Basics -> Blink
Figure 9. Windows Device