09 Embedded System
09 Embedded System
Textbook
P. 232~277
1
Contents
I. OpenCR
II. rosserial
Textbook
P. 232~277
2
What is the Best
Computing Resource I’m a
Robot!
CPU? MCU?
3
The proportion of embedded systems in robots
4
The proportion of embedded systems in robots
Intel NUC
for Sensor and Communication
5
The proportion of embedded systems in robots
Intel NUC
for Sensor and Communication
ARM Cortex-M
for Motor control and Analog Sensors
6
Types of computer resources and ROS support
32-bit MCU
8/16-bit MCU ARM A-class x86
"small" 32-bit MCU "big" 32-bit MCU
Example Chip Atmel AVR ARM Cortex-M0 ARM Cortex-M7 Samsung Exynos Intel Core i5
Example System Arduino Leonardo Arduino M0 Pro SAM V71 ODROID Intel NUC
MIPS 10's 100's 100's 1000's 10000's
a few GB 2-16 GB
RAM 1-32 KB 32 KB 384 KB
(off-chip) (SODIMM)
Max power 10's of mW 100's of mW 100's of mW 1000's of mW 10000's of mW
Peripherals UART, USB FS, ... USB FS Ethernet, USB HS Gigabit Ethernet USB SS, PCIe
Sensor
TTL/RS485
http://wiki.ros.org/rosserial
‘rosserial’ server & client
message message
rosserial rosserial
topic topic
server client
rosserial
protocol
service service
10
‘rosserial’ server & client
$ sudo apt-get install ros-kinetic-rosserial ros-kinetic-rosserial-server ros-kinetic-rosserial-arduino
• rosserial server
• rosserial_python: Python language based rosserial server, very popular
• rosserial_server: C++ language based rosserial server, Some functions are limited
• rosserial_java: Java language based rosserial server, Used with android SDK
• rosserial client
• rosserial_arduino: Support Arduino & Leonardo, OpenCR uses it with few
modification
• rosserial_embeddedlinux: Linux Library for Embedded System
• rosserial_windows: Support Windows operating system,
Windows application and communication support
• rosserial_mbed: Support ARM’s mbed
• rosserial_tivac: Support TI’s Launchpad
11
‘rosserial’ Protocol (http://wiki.ros.org/rosserial/Overview/Protocol)
1st Byte 2nd Byte 3rd Byte 4th Byte 5th Byte 6th Byte 7th Byte N Bytes Byte N+8
Checksum Checksum
Sync Flag Serialized
Message Message over over
Sync Flag / Protocol Topic ID Topic ID Message Topic ID and
Length (N) Length (N) message
version Data Message Data
length
(Value: 0xFF) (Value: 0xFE) (Low Byte) (High Byte) (Low Byte) (High Byte)
Sync Flag Header to know the start position of the packet. It is always ‘0xFF’
Sync Flag / Protocol version A protocol version, ROS Groovy is ‘0xFF’, & ‘ROS Hydro’, ‘Indigo’, ‘Jade’ and ‘Kinetic’ are ‘0xFE’
Message Length (N) Data length of message, 2 Byte = Low Byte + High Byte, Low Byte are transmitted first, followed by ‘High Byte’
It is an ID for identifying the type of message. 2 Byte = Low Byte + High Byte
Topic ID ID_PUBLISHER=0, ID_SUBSCRIBER=1, ID_SERVICE_SERVER=2, ID_SERVICE_CLIENT=4,
ID_PARAMETER_REQUEST=6, ID_LOG=7, ID_TIME=10, ID_TX_STOP=11
Serialized Message Data It is the data to transmit the ROS message in serial form EX) IMU, TF, GPIO
13
OpenCR; Open-source
Control module for
ROS
14
OpenCR (Open-source Control Module for ROS)
• It is an embedded board that supports ROS and is used as the main controller in TurtleBot3
• Open source H/W, S/W : H/W information such as circuit, BOM, Gerber data, and all S/W of OpenCR as open source
• Configuration to overcome the limitations of rosserial
• 32-bit ARM Cortex-M7 with FPU (216MHz, 462DMIPS)
CAN LED Dip Switch GPIO JTAG OLLO Arduino
+X
+Z
• Communication Support
• USB, SPI, I2C +Y
+Z
• TTL, RS485, CAN
Magnetometer 16
Block Diagram & Flash Memory Map
SMPS Battery
12V 11.1V
0x08100000
0x08000000
Extension
Debugger Arduino Shield
Connector
17
Establish Development Environment
• OpenCR supports Arduino IDE
• How to build OpenCR development environment
• http://emanual.robotis.com/docs/en/platform/turtlebot3/appendix_opencr1_0/
• http://emanual.robotis.com/docs/en/parts/controller/opencr10/
18
‘rosserial’ Example (LED Control)
$ arduino
• After running Arduino, Load basic example [File] > [Examples] > [ROS] > [01.
Basics] > [a_LED], build and upload
• This example defines the ‘led_out’ subscriber with 4 LEDs using ‘std_msg/Byte’
which is a ROS standard data type
• When the subscriber callback function is called, if the bit is 1, the LED is
turned on; if it is 0, the LED is turned off
USER1
USER2
USER3
USER4
19
‘rosserial’ Example (LED Control)
#include <ros.h>
#include <std_msgs/String.h>
#include <std_msgs/Byte.h>
int led_pin_user[4] = { BDPIN_LED_USER_1, BDPIN_LED_USER_2,
BDPIN_LED_USER_3, BDPIN_LED_USER_4 };
ros::NodeHandle nh;
void messageCb( const std_msgs::Byte& led_msg) {
int i;
for (i=0; i<4; i++)
{
if (led_msg.data & (1<<i))
{
digitalWrite(led_pin_user[i], LOW);
}
else
{
digitalWrite(led_pin_user[i], HIGH);
}
}
}
ros::Subscriber<std_msgs::Byte> sub("led_out", messageCb );
void setup() {
pinMode(led_pin_user[0], OUTPUT);
pinMode(led_pin_user[1], OUTPUT);
pinMode(led_pin_user[2], OUTPUT);
pinMode(led_pin_user[3], OUTPUT);
nh.initNode();
nh.subscribe(sub);
}
void loop() {
nh.spinOnce();
}
20
Running ‘rosserial server’ and Publishing Topics for LED Control
• After running ‘roscore’, run ‘rosserial sever’
$ roscore
• Let’s use ‘rostopic pub’ to control the LED by entering a value in ‘led_out’
$ rostopic pub -1 led_out std_msgs/Byte 1 USER1 LED On
$ rostopic pub -1 led_out std_msgs/Byte 2 USER2 LED On
$ rostopic pub -1 led_out std_msgs/Byte 4 USER3 LED On
$ rostopic pub -1 led_out std_msgs/Byte 8 USER4 LED On
$ rostopic pub -1 led_out std_msgs/Byte 0 LED Off
21
Publisher Node & Subscriber Node for LED Control
• Let’s run rqt_graph
• It shows that rostopic command acts as a publisher node and
opencr(rosserial server) is acting as a subscriber
• It is possible to confirm that information is being transmitted and
received between the two nodes with the topic name ‘/led_out’
22
‘rosserial’ Example (IMU Control)
23
‘rosserial’ Example (TurtleBot3 Burger)
24
Question Time!
Advertisement #1
Download link
Language:
English, Chinese, Japanese, Korean
Direct Link
Advertisement #3
www.robotsource.org
The ‘RobotSource’ community is the space for people making robots.