# Design of Smart Home Service Robot Based on ROS

Authors: Jiansheng Peng; Hemin Ye; Qiwen He; Yong Qin; Zhenwu Wan; Junxu Lu
Journal: Mobile Information Systems
 (2021)

---

## Abstract

At present, the functions of home service robots are not perfect, and home service robot systems that can independently complete autonomous inspections and home services are still lacking. In response to this problem, this paper designs a smart home service robot system based on ROS. The system uses Raspberry Pi 3B as the main control to manage the nodes of each sensor. CC2530 sets up a ZigBee network to collect home environmental information and control home electrical appliances. The image information of the home is collected by the USB camera. The human speech is recognized by Baidu Speech Recognition API. When encountering a dangerous situation, the GSM module is used to give users SMS and phone alarms. Arduino mega2560 is used as the bottom controller to control the movement of the service robot. The indoor environment map of the home is constructed by the lidar and the attitude sensor. The service robot finally designed and developed realizes the functions of wireless control of home appliances, voice remote control, autonomous positioning and navigation, liquefied gas leakage alarm, and human infrared detection alarm. Compared with the household service robots in the related literature, the household service robots developed by us have more complete functions. And the robot system has completed the task of combining independent patrol and home service well.


---

## Body

## 1. Introduction

In recent years, with the development of science and technology, various robots have appeared in people’s lives, for example, handling robots in factories [1], medical robots in hospitals [2], service robots in hotels [3], food delivery robots in restaurants [4], and smart home service robots that reduce the burden on family members [5]. Among them, the smart home service robot is the closest to people’s lives and the most used.According to a recent survey by the World Health Organization, in 2015, the number of people over 60 years old in the world reached 900 million people, and by 2050, the number of people over 60 years old will reach 2 billion [6]. More and more elderly people are unable to complete some tasks smoothly due to their age. At this time, they need the assistance of smart home robots. And smart home service robots can be used as companion objects for the elderly so that they will not feel lonely at home. And with the aging of the population becoming more and more serious, the demand for smart home service robots is also increasing.Most young workers nowadays basically go out to work during the day and only spend a short time at home. If there is any dangerous situation at home, it is difficult to find out and take relevant measures at the first time. In recent years, home burglaries and gas leaks have occurred frequently. In order to ensure that the home is safe enough, there needs to be a “people” in the home at this time and can send alarm messages to the owner at any time when encountering danger so as to reduce the owner’s economic loss. The “people” mentioned here are smart home service robots. In addition, this type of robot can help the owner do housework (such as sweeping the floor) to reduce the burden on the owner. In addition, when the owner who works outside wants to have hot water to drink as soon as he returns home, he can send corresponding instructions to the smart home service robot in advance to turn on the electric tea kettle heating function, and the owner can drink hot water when he returns home.In summary, smart home robots can share housework for people and reduce the burden on the owner and can bring a lot of convenience to people’s lives. Especially for the elderly, smart home service robots bring convenience to their lives and add a lot of fun to their lives. In addition, the danger alarm function of the smart home service robot can make people’s home life safer. Therefore, smart home service robots are becoming more and more important to people’s daily lives. However, the functions of some smart home service robots are not yet perfect, so it is necessary to research and develop smart home service robots with more comprehensive functions.The organizational structure of the rest of this article is as follows. Related work will be discussed in the second part. The third part introduces the overall design of the system in detail. In the fourth part, the hardware design of the motion system, power supply system, wireless communication system, alarm system, and autonomous navigation system is introduced. In the fifth part, the software design of the system is introduced, including motion system software design, wireless communication system software design, and autonomous navigation software design. The sixth part gives an introduction to system debugging. The seventh part compares the functions and experience of the smart home service robot. The eighth part is the summary of this article.


## 2. Related Work

With the development of electronic information technology and the improvement of people’s living standards, people are increasingly yearning for the life of smart home [7]. The concept of smart home is to integrate different services in one home by using a common communication system [8]. Smart homes ensure economical, safe, and comfortable home operations, including highly intelligent functions and flexibility. In recent years, with the development of robotics technology, more and more robots are used in smart homes and become smart home service robots. These robots bring people an economic, safe, comfortable, and happy family life.With the gradual aging of society, the number of elderly people has gradually increased. When there is only one elderly person at home, the mood and safety of the elderly are worthy of consideration. Wada K et al. invented a companion robot for the elderly named “Paro” [9]. “Paro” is a robot that can imitate animals. While bringing joy to the owner, there is no need to worry that it will bite you like a real animal. “Schpuffy” is also a companion robot [10]. It checks the owner’s schedule every morning. If it finds that the owner has an appointment at 8 : 30, it will wake up the owner in advance at 8 o’clock. If the weather is very cold, it will remind the owner to wear more clothes to keep warm. It will say goodbye to the owner when the owner leaves, and it will lock the door when the owner leaves. Literature [11] is dedicated to the development of social robotic systems to provide companionship, care, and services to the elderly through information and communication technology (ICT), thereby motivating them to stay active and independent and improve their well-being. The goal of this work is to enable these elderly people to live independently for as long as possible in their preferred environment by providing information and communication technology nursing services. As a service robot, the platform provides assistance to users and aims to solve the early preventive and health care problems of the aging process. The three robots mentioned above are mainly human-computer interaction functions, which are designed to bring convenience and joy to the owner, especially for the elderly, but they are not involved in other functions.Saunders et al. deployed a commercial autonomous robot in an ordinary suburban house. This robot describes teaching, learning, and robot and smart home system design methods as an integral unit. Experimental results show that participants think this method of robot personalization is easy to use and can be used in real life [5]. Abdallah and others used open source solutions to build a completely independent intelligent assistant robot, specifically for the elderly to manage smart homes. The system is built around a voice communication module based on Mycroft AI for communicating with sensors and smart devices. It includes many software applications for recognizing faces, setting tasks, and answering specific questions and requests. The embedded system is used as the local server to manage the smart home and its applications. The results show that the robot can perform various forms of actions to answer user queries [12]. Berrezueta-Guzman et al. [13] introduced the design of smart home environment. In this project, the Internet of Things (IoT) paradigm is combined with the development of robotic aids to realize a smart home environment. In this environment, the included smart things can determine the behavior of the child in the process of doing homework in real time. There is also a robotic assistant in the project that interacts with the child and provides necessary companionship (supervision and guidance), just like the therapist would do. The purpose of this project is to create a smart place for treatment purposes in the family to help children who suffer from ADHD and find it difficult to complete their homework. The above three kinds of robots can all perform voice interaction, but they all lack the functions of hazard alarm and home appliance control.Literature [14] explored the possibility of integrating wireless sensor networks and service robots into smart home applications. Service robots can be regarded as mobile nodes, providing additional sensor information, improving/fixing connectivity, and collecting information from wireless sensor nodes. The wireless sensor network can be regarded as an extension of the robot’s perception ability, providing an intelligent environment for the service robot. The robot mainly realizes that the robot obtains effective information from the sensor network so as to control the related equipment. In 2018, Taiwanese researchers proposed a smart home control system. The system integrates the Internet of Things, wireless sensor networks, smart robots, and single board computers to realize smart home applications. They use wireless technology and automation equipment to avoid adding too many communication cables, making the house more intelligent, keeping indoor activities smooth and tidy. This system brings intelligence and convenience to the family and makes the living environment more comfortable [15]. However, the above two types of robots do not have functions such as human-computer interaction and voice recognition.The functions of the robots researched and developed in the above literature are not very comprehensive, and it is difficult to meet people’s needs for a comfortable, convenient, safe, and fun home life. And they generally lack a home robot system that can independently complete the combination of autonomous inspections and home services. If the smart home service robot has incomplete functions and cannot complete the task of combining autonomous patrols and home services, this will bring a bad experience to users. In order to meet people’s needs for a comfortable, convenient, safe, and fun home life, this paper has researched and developed a home robot system that has more complete functions and can independently complete independent inspections and home services. This system is a smart home service robot system based on ROS, which can help people manage and control household appliances, which brings convenience to people. Its voice recognition function makes the communication between the owner, and it simple and convenient. For the elderly, this function can make them no longer feel lonely when they are at home alone and at the same time increase the joy of life for the elderly. It can also detect the situation at home. When there is a dangerous situation, it will send out an alarm to the owner, thereby reducing the owner’s economic loss and playing the effect of protecting the safety of the home.


## 3. Overall System Design

ROS (robot operating system) [16] is a metalevel operating system suitable for robot open source. Compared with other robot operating systems, ROS mainly has the following characteristics. (1) ROS provides a publish-subscribe communication framework for building distributed computing systems simply and quickly. (2) It provides a large number of simulation and data visualization tool combinations to configure, start, self-check, debug, visualize, login, test, and terminate system. (3) It also provides a large number of library files and realizes functions such as autonomous movement, operating objects, and perception of the environment. (4) The support and development of ROS constitute a powerful ecosystem.ZigBee technology [17] is a low-rate and short-distance wireless transmission technology based on IEEE802.15.4. It is characterized by self-organizing network, supporting a large number of network nodes, low power consumption, low speed, low cost, safe, and reliable. ZigBee technology is widely used in the fields of home network, medical sensors, and servo execution.Arduino is an open source electronic platform [18]. It has rich library resources and simple code structure, suitable for completing the driving of the robot and connecting with various electronic components to realize data collection and processing.The system framework is shown in Figure1. The ROS-based smart home service robot system uses Raspberry Pi 3 as the main control core board. It consists of lidar, attitude sensor, USB camera, CC2530 coordinator, CC2530 terminal node, relay module, MQ-5 module, SHT temperature and humidity module, Arduino mega2560, motor, motor drive module, human body infrared module, and GSM module. The ROS system is installed on the main control core board to exchange information with each module to control and run the entire system. The CC2530 coordinator and CC2530 terminal nodes construct a ZigBee network. The serial communication between the CC2530 coordinator and the main control core board realizes information exchange. The CC2530 terminal node drives the relay module, MQ-5 module, and SHT temperature and humidity module, respectively. These are used to collect environmental information at home and control household electrical appliances. Users can control the entire system by connecting the robot through the mobile phone.Figure 1
System framework diagram.


## 4. System Hardware Design

### 4.1. Motion System Hardware Design

#### 4.1.1. Mobile Chassis Structure Design

The movement method of robot movement adopts wheeled transmission method. The structure of the mobile chassis is shown in Figure2. The a and the b are DC geared motors. A wheel and B wheel are used as driving wheels. The C wheel is a universal wheel as an auxiliary wheel. This constitutes a self-balancing robot mobile chassis.Figure 2
Structure diagram of mobile chassis.


#### 4.1.2. Movement System Hardware Composition

The hardware of the robot motion system is composed of the L298P Moto Shield DC motor drive expansion board, the Arduino mega2560 development board, and the DC gear motor. The DC geared motor has a 13-wire AB two-phase Hall encoder. The phase A and phase B outputs of the encoder differ by 90°. The value read by the combination of two-phase is 4 times the term. The motor generates 780 pulses per revolution. Then, the speedn is as follows:(1)n=N4×780×t,where N is the number of pulses in time t.The system uses the external interrupt of the I/O port of the Arduino mega2560 development board to read the encoder pulse number. The speed of the geared motor is calculated by Equation (1). The controller outputs PWM through the driver to drive the reduction motor to rotate.


### 4.2. Power System Hardware Design

The power system structure is shown in Figure3. The main power supply uses 11 V lithium battery. The secondary power supply uses 5V batteries. The main power supply supplies power to the gear motor through the L298P Moto Shield DC motor drive expansion board. Raspberry Pi power supply needs 5 V/2A to work properly. Therefore, the CKCY buck module (which can output 5 V/3A) is used to get 5 V power supply. The lidar, USB camera, Arduino mega2560, and attitude sensor are powered by the USB serial port of the Raspberry Pi. The main power supply is reduced to 5 V through the LM2596S buck module and supplies power to the motor encoder, GSM module, CC2530 coordinator, and human body infrared module. The CC2530 terminal node is directly powered by a 5 V secondary battery.Figure 3
Ower system structure diagram.


### 4.3. Wireless Communication System Hardware Design

The coordinator and the terminal nodes constitute the hardware component of the wireless communication system. There can only be one coordinator in each network. The main functions of the coordinator are to establish a network, assign network addresses, and maintain a binding table. The terminal node is used for each device node of the network. The same network can have up to 256 end nodes. The MQ-5 module, SHT temperature and humidity module, and relay switch are connected to the terminal node for information collection and control of household electrical appliances.


### 4.4. Alarm System Hardware Design

The human body infrared module, MQ-5 liquefied gas module, and GSM module constitute the hardware component of the robot alarm system. The human body infrared module is used to detect whether there are someone breaks into the house when living outdoors. MQ-5 liquefied gas module is used to detect whether there is a liquefied gas leak in the home. The GSM module is used to send text messages and dial phone calls to the residents. The wiring of human body infrared module, GSM module, and Arduino mage2560 is shown in Figure4. The connection mode between the MQ-5 module and the CC2530 terminal node is shown in Figure 5.Figure 4
Human body module and GSM module wiring diagram.Figure 5
Wiring block diagram of MQ-5 module and CC2530 terminal node.


### 4.5. Autonomous Navigation System Hardware Design

The hardware components of the robot’s autonomous navigation system are composed of lidar and attitude sensors. The system uses lidar to detect the surrounding environment through 360° scanning and ranging and then collects and processes the data. Finally, the system builds a digital map of the surrounding environment. The attitude sensor is used to obtain the data of acceleration, angular velocity, and magnetometer. In this way, the current real-time motion state of the robot can be solved. The wiring of Lidar, attitude sensor, and Raspberry Pi 3B is shown in Figure6.Figure 6
Wiring diagram of lidar and attitude sensor.


## 4.1. Motion System Hardware Design

### 4.1.1. Mobile Chassis Structure Design

The movement method of robot movement adopts wheeled transmission method. The structure of the mobile chassis is shown in Figure2. The a and the b are DC geared motors. A wheel and B wheel are used as driving wheels. The C wheel is a universal wheel as an auxiliary wheel. This constitutes a self-balancing robot mobile chassis.Figure 2
Structure diagram of mobile chassis.


### 4.1.2. Movement System Hardware Composition

The hardware of the robot motion system is composed of the L298P Moto Shield DC motor drive expansion board, the Arduino mega2560 development board, and the DC gear motor. The DC geared motor has a 13-wire AB two-phase Hall encoder. The phase A and phase B outputs of the encoder differ by 90°. The value read by the combination of two-phase is 4 times the term. The motor generates 780 pulses per revolution. Then, the speedn is as follows:(1)n=N4×780×t,where N is the number of pulses in time t.The system uses the external interrupt of the I/O port of the Arduino mega2560 development board to read the encoder pulse number. The speed of the geared motor is calculated by Equation (1). The controller outputs PWM through the driver to drive the reduction motor to rotate.


## 4.1.1. Mobile Chassis Structure Design

The movement method of robot movement adopts wheeled transmission method. The structure of the mobile chassis is shown in Figure2. The a and the b are DC geared motors. A wheel and B wheel are used as driving wheels. The C wheel is a universal wheel as an auxiliary wheel. This constitutes a self-balancing robot mobile chassis.Figure 2
Structure diagram of mobile chassis.


## 4.1.2. Movement System Hardware Composition

The hardware of the robot motion system is composed of the L298P Moto Shield DC motor drive expansion board, the Arduino mega2560 development board, and the DC gear motor. The DC geared motor has a 13-wire AB two-phase Hall encoder. The phase A and phase B outputs of the encoder differ by 90°. The value read by the combination of two-phase is 4 times the term. The motor generates 780 pulses per revolution. Then, the speedn is as follows:(1)n=N4×780×t,where N is the number of pulses in time t.The system uses the external interrupt of the I/O port of the Arduino mega2560 development board to read the encoder pulse number. The speed of the geared motor is calculated by Equation (1). The controller outputs PWM through the driver to drive the reduction motor to rotate.


## 4.2. Power System Hardware Design

The power system structure is shown in Figure3. The main power supply uses 11 V lithium battery. The secondary power supply uses 5V batteries. The main power supply supplies power to the gear motor through the L298P Moto Shield DC motor drive expansion board. Raspberry Pi power supply needs 5 V/2A to work properly. Therefore, the CKCY buck module (which can output 5 V/3A) is used to get 5 V power supply. The lidar, USB camera, Arduino mega2560, and attitude sensor are powered by the USB serial port of the Raspberry Pi. The main power supply is reduced to 5 V through the LM2596S buck module and supplies power to the motor encoder, GSM module, CC2530 coordinator, and human body infrared module. The CC2530 terminal node is directly powered by a 5 V secondary battery.Figure 3
Ower system structure diagram.


## 4.3. Wireless Communication System Hardware Design

The coordinator and the terminal nodes constitute the hardware component of the wireless communication system. There can only be one coordinator in each network. The main functions of the coordinator are to establish a network, assign network addresses, and maintain a binding table. The terminal node is used for each device node of the network. The same network can have up to 256 end nodes. The MQ-5 module, SHT temperature and humidity module, and relay switch are connected to the terminal node for information collection and control of household electrical appliances.


## 4.4. Alarm System Hardware Design

The human body infrared module, MQ-5 liquefied gas module, and GSM module constitute the hardware component of the robot alarm system. The human body infrared module is used to detect whether there are someone breaks into the house when living outdoors. MQ-5 liquefied gas module is used to detect whether there is a liquefied gas leak in the home. The GSM module is used to send text messages and dial phone calls to the residents. The wiring of human body infrared module, GSM module, and Arduino mage2560 is shown in Figure4. The connection mode between the MQ-5 module and the CC2530 terminal node is shown in Figure 5.Figure 4
Human body module and GSM module wiring diagram.Figure 5
Wiring block diagram of MQ-5 module and CC2530 terminal node.


## 4.5. Autonomous Navigation System Hardware Design

The hardware components of the robot’s autonomous navigation system are composed of lidar and attitude sensors. The system uses lidar to detect the surrounding environment through 360° scanning and ranging and then collects and processes the data. Finally, the system builds a digital map of the surrounding environment. The attitude sensor is used to obtain the data of acceleration, angular velocity, and magnetometer. In this way, the current real-time motion state of the robot can be solved. The wiring of Lidar, attitude sensor, and Raspberry Pi 3B is shown in Figure6.Figure 6
Wiring diagram of lidar and attitude sensor.


## 5. System Software Design

### 5.1. Software Overall Design

The designed smart home service robot uses Raspberry Pi as the main control core. The system uses CC2530 coordinator to build the network and CC2530 terminal nodes to form a wireless control network. The system also uses Arduino mega2560 as the slave controller. The Raspberry Pi 3B mainly processes lidar data, attitude sensor data, USB camera data, voice recognition API, and CC2530 coordinator data and controls the operation of the Arduino mega2560. The CC2530 coordinator is mainly used to obtain data of CC2530 terminal nodes. Arduino mega2560 mainly obtains encoder data and human body infrared sensor data. Control motor drives and controls GSM module work. The service robot software framework is shown in Figure7.Figure 7
Software block diagram.


### 5.2. Motion System Software Design

The robot adopts the incremental PID method to adjust the movement speed. The specific steps for adjusting the movement speed are as follows:(1)
When the deviation value of the motor speed is obtained, the upper computer sets the moving speed of the service robot. The lower computer obtains the speed value sent by the upper computer. The encoder’s own encoder is used to calculate the encoder’s pulse to obtain the current actual speed of the service robot. Finally, the system subtracts the two to get the speed deviation value.(2)
This system calculates the duty cycle through the PID incremental algorithm. The system obtains the latest 3 speed deviation values and then obtains the duty cycle through the PID incremental algorithm. It should be noted here that the minimum and maximum duty cycle values need to be set to avoid the motor rotating speed being too small or too large.(3)
Let the drive motor rotate to achieve speed regulation. The obtained duty ratio is converted to the corresponding PWM output value. Let the output PWM drive the motor speed to achieve speed regulation. The change of the motor speed will in turn affect the speed deviation value. The duty cycle changes as the motor speed changes. The output PWM value also changes accordingly. This process is repeated, and the final motor speed tends to the set theoretical speed.


### 5.3. Software Design of Wireless Communication System

ZigBee technology is a low-rate and short-distance wireless transmission technology based on IEEE802.15.4. ZigBee technology has the characteristics of self-organizing network, supporting a large number of network nodes, low power consumption, low speed, low cost, safety, and reliability. ZigBee technology is widely used in the fields of home network, medical sensors, and servo execution. The robot wireless communication system uses ZigBee network for wireless communication. The ZigBee network is composed of a coordinator and terminal nodes and uses a star network topology as shown in Figure8.Figure 8
Star network topology.


#### 5.3.1. CC2530 Coordinator Builds ZigBee Network

In a wireless communication system, the coordinator is equivalent to the controller in the network. It dominates the entire network. From the establishment of the network to the processing and transmission of system data, including the realization of system functions, it is inseparable from the coordinator. The specific steps of the ZigBee network construction process are as follows. First, the system configures the type of coordinator and sets PAN_ID! = 0XFFFF coordinator. In this way, the coordinator will only generate one network. Then, the system configures the network channel and scan channel of the coordinator and configures the short address of the coordinator. Finally, the coordinator starts to wait for the terminal node to join. If the terminal node wants to join the network, it first needs to configure the PIN_ID and network channel consistent with the coordinator. After receiving the request sent by the coordinator, the terminal node recognizes it. After the recognition results completely match, the network is built. The process for the coordinator to build a ZigBee network is shown in Figure9.Figure 9
Coordinator network building flow chart.


#### 5.3.2. CC2530 Terminal Node Joins ZigBee Network

There is a ZigBee network within the scope of the CC2530 terminal node. The terminal node matches the coordinator by scanning the channel. After a successful match, the terminal node applies for joining the network. If the coordinator agrees to the terminal node to access the network, the terminal node will receive the short address assigned by the coordinator and successfully access the network. The process of the terminal node joining the ZigBee network is shown in Figure10.Figure 10
Flow chart of terminal node network connection.


#### 5.3.3. CC2530 Coordinator Workflow

The coordinator constructs the network and configures the network channel and initializes the address table. Then, the terminal node starts scanning. After the coordinator agrees, the terminal node joins the network to complete the ZigBee networking. After successful networking, the coordinator waits for the command sent by the host computer and executes the corresponding operation after parsing the command. For commands of the control-type terminal node, the coordinator sends commands to the terminal node. The terminal node performs the work, and there is no information feedback. For the instructions of the information collection terminal node, the coordinator sends a work command to the terminal node. The terminal node performs the work. The coordinator receives the information from the terminal node and sends it to the main control. The coordinator workflow is shown in Figure11.Figure 11
Coordinator work flow chart.


#### 5.3.4. Controlled Terminal Node Workflow

The control terminal node is responsible for controlling household electrical appliances on the node. The workflow is as follows. First, it is initialized. Then, it starts to scan the network built by the coordinator and applies to join the network. If joining the network is successful, the system setting indicator lights up. The control-type terminal node starts to obtain commands and analysis sent by the coordinator and judges whether to execute control. The control terminal node workflow is shown in Figure12.Figure 12
Controlled end node flow chart.


### 5.4. Autonomous Positioning and Navigation Design

At present, it is difficult to realize high-precision robot positioning and navigation with a single sensor. Therefore, multisensor fusion is carried out in the design of this paper, and the data collected by the attitude sensor and the lidar are fused to realize the high-precision pose estimation of the service robot in the environment map. SLAM (simultaneous localization and mapping) means simultaneous localization and map construction. It is a common method to solve robot localization and mapping, and it is a research hotspot in the field of robotics. The optimization of the SLAM process can be achieved through multisensor data fusion. Figure13 is a basic structure diagram of multisensor data fusion. Firstly, relevant data are collected from the attitude sensor and lidar, and then the data are calculated and processed by the fusion model, and finally the robot pose is output.Figure 13
Basic structure diagram of multisensor data fusion.In the fusion model, a data fusion method based on BP neural network [19] is used to fuse the attitude sensor and lidar data, and finally the high-precision pose is output. BP neural network is one of the most widely used neural networks at present; it is trained according to the error back propagation algorithm. BP neural network uses the errors in each layer of the network to correct the partial derivatives of node weights and the corresponding weights. In the process of network learning, the error is propagated from the last output node to the entire BP neural network in each layer of the network in order to achieve the gradual convergence of the final output error. Figure 14 is the basic structure model of the BP neural network. The model has an input layer, a hidden layer, and an output layer. In the figure, Ii is the input data, Wij is the connection weight between the nodes of each layer, and Oi is the output data. In order to make the target output closer to the true value, it is necessary to take the average of the three consecutive pose outputs to achieve data smoothing and denoising. The specific operations are as follows:(2)Pk=Pk−1+Pk+Pk+13.Figure 14
The basic structure model of BP neural network.The designed BP neural network model takes the data of lidar and attitude sensor as input. Among them, the lidar has 440 data and the attitude sensor has 6 data, a total of 446 input data. There are three output data, which arex-axis coordinates, y-axis coordinates, and robot rotation angle. In the neural network training process, according to the error change and the analytical effect of the training model on the test data set, while ensuring the higher accuracy of the two parts, the number of nodes in the hidden layer is sequentially reduced in order to as much as possible use a smaller-scale neural network model. Finally, an ideal training result is obtained, as shown in Figure 15. As shown in Figure 15, in BP neural network, the training function used is trainrp, logsig is used as the transfer function between the first three layers, and the purelin linear function is used to adjust the output in the fourth layer.Figure 15
The final designed BP neural network model.In order to verify the effectiveness of using the designed BP neural network for data fusion to estimate the relative displacement of the robot, the situation of sensor data fusion is compared with the situation of using a single sensor for relative displacement estimation. Table1 is the comparison of the relative displacement estimation error of the attitude sensor, the lidar, and the data fusion of the two sensors. Figure 16 is a comparison diagram of the relative displacement estimation error. It can be clearly seen from the figure that the accuracy of the relative displacement estimation of the two sensors using the BP neural network method designed in this paper is higher than that of using a single sensor.Table 1
Comparison of relative displacement estimation errors.
TimeAttitude sensorLidarAttitude sensor and lidar data fusion10.5360.4030.10020.4780.5120.05030.4940.5110.06040.5010.4960.03050.5640.5000.04160.4780.5330.091…………450.5800.4940.196460.7000.6010.136470.6740.6320.133480.6010.6780.145490.6540.6310.101500.6250.5890.091Figure 16
Comparison of relative displacement estimation errors.


### 5.5. Voice Control Software Design

This design uses the speech recognition API interface of Baidu AI platform for speech recognition. In addition, we use SnowBoy offline voice wake-up engine to achieve offline voice wake-up and voice interaction.


#### 5.5.1. Baidu Speech Recognition API

We register an account on Baidu AI official website. Then, we create a speech recognition application and get the ID number and key as follows:(i)
APP_ID = ‘16188196’(ii)
API_KEY = ‘c8i1D8ncIKuUK8HOPYeESojR’(iii)
SECRET_KEY = ‘dhmLkQBjztATaDXrygYetKGQ0k46EiPn’.We install the corresponding SDK on the Raspberry Pi 3B and build a speech recognition and speech synthesis platform. We write a node function in the SDK and let the function run as a node in the system.


#### 5.5.2. Voice Wake Engine SnowBoy

The voice wake-up engine SnowBoy is used to wake up the robot. We use SnowBoy to train a model as the wake word of the robot. When the service robot awakened, it enters the working state of voice recognition so as to perform voice control on the service robot.


## 5.1. Software Overall Design

The designed smart home service robot uses Raspberry Pi as the main control core. The system uses CC2530 coordinator to build the network and CC2530 terminal nodes to form a wireless control network. The system also uses Arduino mega2560 as the slave controller. The Raspberry Pi 3B mainly processes lidar data, attitude sensor data, USB camera data, voice recognition API, and CC2530 coordinator data and controls the operation of the Arduino mega2560. The CC2530 coordinator is mainly used to obtain data of CC2530 terminal nodes. Arduino mega2560 mainly obtains encoder data and human body infrared sensor data. Control motor drives and controls GSM module work. The service robot software framework is shown in Figure7.Figure 7
Software block diagram.


## 5.2. Motion System Software Design

The robot adopts the incremental PID method to adjust the movement speed. The specific steps for adjusting the movement speed are as follows:(1)
When the deviation value of the motor speed is obtained, the upper computer sets the moving speed of the service robot. The lower computer obtains the speed value sent by the upper computer. The encoder’s own encoder is used to calculate the encoder’s pulse to obtain the current actual speed of the service robot. Finally, the system subtracts the two to get the speed deviation value.(2)
This system calculates the duty cycle through the PID incremental algorithm. The system obtains the latest 3 speed deviation values and then obtains the duty cycle through the PID incremental algorithm. It should be noted here that the minimum and maximum duty cycle values need to be set to avoid the motor rotating speed being too small or too large.(3)
Let the drive motor rotate to achieve speed regulation. The obtained duty ratio is converted to the corresponding PWM output value. Let the output PWM drive the motor speed to achieve speed regulation. The change of the motor speed will in turn affect the speed deviation value. The duty cycle changes as the motor speed changes. The output PWM value also changes accordingly. This process is repeated, and the final motor speed tends to the set theoretical speed.


## 5.3. Software Design of Wireless Communication System

ZigBee technology is a low-rate and short-distance wireless transmission technology based on IEEE802.15.4. ZigBee technology has the characteristics of self-organizing network, supporting a large number of network nodes, low power consumption, low speed, low cost, safety, and reliability. ZigBee technology is widely used in the fields of home network, medical sensors, and servo execution. The robot wireless communication system uses ZigBee network for wireless communication. The ZigBee network is composed of a coordinator and terminal nodes and uses a star network topology as shown in Figure8.Figure 8
Star network topology.


### 5.3.1. CC2530 Coordinator Builds ZigBee Network

In a wireless communication system, the coordinator is equivalent to the controller in the network. It dominates the entire network. From the establishment of the network to the processing and transmission of system data, including the realization of system functions, it is inseparable from the coordinator. The specific steps of the ZigBee network construction process are as follows. First, the system configures the type of coordinator and sets PAN_ID! = 0XFFFF coordinator. In this way, the coordinator will only generate one network. Then, the system configures the network channel and scan channel of the coordinator and configures the short address of the coordinator. Finally, the coordinator starts to wait for the terminal node to join. If the terminal node wants to join the network, it first needs to configure the PIN_ID and network channel consistent with the coordinator. After receiving the request sent by the coordinator, the terminal node recognizes it. After the recognition results completely match, the network is built. The process for the coordinator to build a ZigBee network is shown in Figure9.Figure 9
Coordinator network building flow chart.


### 5.3.2. CC2530 Terminal Node Joins ZigBee Network

There is a ZigBee network within the scope of the CC2530 terminal node. The terminal node matches the coordinator by scanning the channel. After a successful match, the terminal node applies for joining the network. If the coordinator agrees to the terminal node to access the network, the terminal node will receive the short address assigned by the coordinator and successfully access the network. The process of the terminal node joining the ZigBee network is shown in Figure10.Figure 10
Flow chart of terminal node network connection.


### 5.3.3. CC2530 Coordinator Workflow

The coordinator constructs the network and configures the network channel and initializes the address table. Then, the terminal node starts scanning. After the coordinator agrees, the terminal node joins the network to complete the ZigBee networking. After successful networking, the coordinator waits for the command sent by the host computer and executes the corresponding operation after parsing the command. For commands of the control-type terminal node, the coordinator sends commands to the terminal node. The terminal node performs the work, and there is no information feedback. For the instructions of the information collection terminal node, the coordinator sends a work command to the terminal node. The terminal node performs the work. The coordinator receives the information from the terminal node and sends it to the main control. The coordinator workflow is shown in Figure11.Figure 11
Coordinator work flow chart.


### 5.3.4. Controlled Terminal Node Workflow

The control terminal node is responsible for controlling household electrical appliances on the node. The workflow is as follows. First, it is initialized. Then, it starts to scan the network built by the coordinator and applies to join the network. If joining the network is successful, the system setting indicator lights up. The control-type terminal node starts to obtain commands and analysis sent by the coordinator and judges whether to execute control. The control terminal node workflow is shown in Figure12.Figure 12
Controlled end node flow chart.


## 5.3.1. CC2530 Coordinator Builds ZigBee Network

In a wireless communication system, the coordinator is equivalent to the controller in the network. It dominates the entire network. From the establishment of the network to the processing and transmission of system data, including the realization of system functions, it is inseparable from the coordinator. The specific steps of the ZigBee network construction process are as follows. First, the system configures the type of coordinator and sets PAN_ID! = 0XFFFF coordinator. In this way, the coordinator will only generate one network. Then, the system configures the network channel and scan channel of the coordinator and configures the short address of the coordinator. Finally, the coordinator starts to wait for the terminal node to join. If the terminal node wants to join the network, it first needs to configure the PIN_ID and network channel consistent with the coordinator. After receiving the request sent by the coordinator, the terminal node recognizes it. After the recognition results completely match, the network is built. The process for the coordinator to build a ZigBee network is shown in Figure9.Figure 9
Coordinator network building flow chart.


## 5.3.2. CC2530 Terminal Node Joins ZigBee Network

There is a ZigBee network within the scope of the CC2530 terminal node. The terminal node matches the coordinator by scanning the channel. After a successful match, the terminal node applies for joining the network. If the coordinator agrees to the terminal node to access the network, the terminal node will receive the short address assigned by the coordinator and successfully access the network. The process of the terminal node joining the ZigBee network is shown in Figure10.Figure 10
Flow chart of terminal node network connection.


## 5.3.3. CC2530 Coordinator Workflow

The coordinator constructs the network and configures the network channel and initializes the address table. Then, the terminal node starts scanning. After the coordinator agrees, the terminal node joins the network to complete the ZigBee networking. After successful networking, the coordinator waits for the command sent by the host computer and executes the corresponding operation after parsing the command. For commands of the control-type terminal node, the coordinator sends commands to the terminal node. The terminal node performs the work, and there is no information feedback. For the instructions of the information collection terminal node, the coordinator sends a work command to the terminal node. The terminal node performs the work. The coordinator receives the information from the terminal node and sends it to the main control. The coordinator workflow is shown in Figure11.Figure 11
Coordinator work flow chart.


## 5.3.4. Controlled Terminal Node Workflow

The control terminal node is responsible for controlling household electrical appliances on the node. The workflow is as follows. First, it is initialized. Then, it starts to scan the network built by the coordinator and applies to join the network. If joining the network is successful, the system setting indicator lights up. The control-type terminal node starts to obtain commands and analysis sent by the coordinator and judges whether to execute control. The control terminal node workflow is shown in Figure12.Figure 12
Controlled end node flow chart.


## 5.4. Autonomous Positioning and Navigation Design

At present, it is difficult to realize high-precision robot positioning and navigation with a single sensor. Therefore, multisensor fusion is carried out in the design of this paper, and the data collected by the attitude sensor and the lidar are fused to realize the high-precision pose estimation of the service robot in the environment map. SLAM (simultaneous localization and mapping) means simultaneous localization and map construction. It is a common method to solve robot localization and mapping, and it is a research hotspot in the field of robotics. The optimization of the SLAM process can be achieved through multisensor data fusion. Figure13 is a basic structure diagram of multisensor data fusion. Firstly, relevant data are collected from the attitude sensor and lidar, and then the data are calculated and processed by the fusion model, and finally the robot pose is output.Figure 13
Basic structure diagram of multisensor data fusion.In the fusion model, a data fusion method based on BP neural network [19] is used to fuse the attitude sensor and lidar data, and finally the high-precision pose is output. BP neural network is one of the most widely used neural networks at present; it is trained according to the error back propagation algorithm. BP neural network uses the errors in each layer of the network to correct the partial derivatives of node weights and the corresponding weights. In the process of network learning, the error is propagated from the last output node to the entire BP neural network in each layer of the network in order to achieve the gradual convergence of the final output error. Figure 14 is the basic structure model of the BP neural network. The model has an input layer, a hidden layer, and an output layer. In the figure, Ii is the input data, Wij is the connection weight between the nodes of each layer, and Oi is the output data. In order to make the target output closer to the true value, it is necessary to take the average of the three consecutive pose outputs to achieve data smoothing and denoising. The specific operations are as follows:(2)Pk=Pk−1+Pk+Pk+13.Figure 14
The basic structure model of BP neural network.The designed BP neural network model takes the data of lidar and attitude sensor as input. Among them, the lidar has 440 data and the attitude sensor has 6 data, a total of 446 input data. There are three output data, which arex-axis coordinates, y-axis coordinates, and robot rotation angle. In the neural network training process, according to the error change and the analytical effect of the training model on the test data set, while ensuring the higher accuracy of the two parts, the number of nodes in the hidden layer is sequentially reduced in order to as much as possible use a smaller-scale neural network model. Finally, an ideal training result is obtained, as shown in Figure 15. As shown in Figure 15, in BP neural network, the training function used is trainrp, logsig is used as the transfer function between the first three layers, and the purelin linear function is used to adjust the output in the fourth layer.Figure 15
The final designed BP neural network model.In order to verify the effectiveness of using the designed BP neural network for data fusion to estimate the relative displacement of the robot, the situation of sensor data fusion is compared with the situation of using a single sensor for relative displacement estimation. Table1 is the comparison of the relative displacement estimation error of the attitude sensor, the lidar, and the data fusion of the two sensors. Figure 16 is a comparison diagram of the relative displacement estimation error. It can be clearly seen from the figure that the accuracy of the relative displacement estimation of the two sensors using the BP neural network method designed in this paper is higher than that of using a single sensor.Table 1
Comparison of relative displacement estimation errors.
TimeAttitude sensorLidarAttitude sensor and lidar data fusion10.5360.4030.10020.4780.5120.05030.4940.5110.06040.5010.4960.03050.5640.5000.04160.4780.5330.091…………450.5800.4940.196460.7000.6010.136470.6740.6320.133480.6010.6780.145490.6540.6310.101500.6250.5890.091Figure 16
Comparison of relative displacement estimation errors.


## 5.5. Voice Control Software Design

This design uses the speech recognition API interface of Baidu AI platform for speech recognition. In addition, we use SnowBoy offline voice wake-up engine to achieve offline voice wake-up and voice interaction.


### 5.5.1. Baidu Speech Recognition API

We register an account on Baidu AI official website. Then, we create a speech recognition application and get the ID number and key as follows:(i)
APP_ID = ‘16188196’(ii)
API_KEY = ‘c8i1D8ncIKuUK8HOPYeESojR’(iii)
SECRET_KEY = ‘dhmLkQBjztATaDXrygYetKGQ0k46EiPn’.We install the corresponding SDK on the Raspberry Pi 3B and build a speech recognition and speech synthesis platform. We write a node function in the SDK and let the function run as a node in the system.


### 5.5.2. Voice Wake Engine SnowBoy

The voice wake-up engine SnowBoy is used to wake up the robot. We use SnowBoy to train a model as the wake word of the robot. When the service robot awakened, it enters the working state of voice recognition so as to perform voice control on the service robot.


## 5.5.1. Baidu Speech Recognition API

We register an account on Baidu AI official website. Then, we create a speech recognition application and get the ID number and key as follows:(i)
APP_ID = ‘16188196’(ii)
API_KEY = ‘c8i1D8ncIKuUK8HOPYeESojR’(iii)
SECRET_KEY = ‘dhmLkQBjztATaDXrygYetKGQ0k46EiPn’.We install the corresponding SDK on the Raspberry Pi 3B and build a speech recognition and speech synthesis platform. We write a node function in the SDK and let the function run as a node in the system.


## 5.5.2. Voice Wake Engine SnowBoy

The voice wake-up engine SnowBoy is used to wake up the robot. We use SnowBoy to train a model as the wake word of the robot. When the service robot awakened, it enters the working state of voice recognition so as to perform voice control on the service robot.


## 6. System Debugging

### 6.1. Robot Control Household Electrical Debugging

On the system, we send a command to the service robot to turn on the light. The service robot sends instructions to the terminal node that controls the lights through the CC2530 coordinator. The terminal node controls the on and off of the relay switch to control the light on and off. The control effect is shown in Figures17 and 18. In the debugging process, we test the control distance of the service robot by continuously increasing the distance between the service robot and the terminal node. In the absence of walls or other obstacles, the control distance of the service robot is within 10 meters. If there are obstacles, the control effect will be greatly affected.Figure 17
Effect picture before robot control.Figure 18
Effect picture after robot control.


### 6.2. PID Parameter Debugging

The stability of the service robot movement requires tuning of PID parameters. This design uses empirical trial and error method to determine PID parameters through experiments. The service robot conducts experiments under the condition of only its own weight and determines the PID parameters. Considering that the service robot is in the actual practical teaching application scenario, the load will not change much in a short time. Therefore, the parameters determined after experiments are applicable in general. The specific operation method of PID parameter tuning is as follows. First, we determine a set of parameter values ofkp, ki, and kd and put the system into operation. Then, we set the desired motor speed. Observe the step response curve of the motor speed output through the rqt_plot tool, and continuously change the parameter values of kp, ki, and kd to obtain a satisfactory step response curve.


### 6.3. Camera Information Collection and Debugging

The camera and the Raspberry Pi are directly connected through the USB serial port. Then, the PC is connected to the Raspberry Pi 3B remotely. The PC side runs the node (usb_cam) that starts the camera in the Raspberry Pi 3B, and then the PC side runs the rqt_imsge_view tool to obtain the image information of the camera as shown in Figure19. By adjusting the focus of the camera, clear image information is obtained.Figure 19
Information collected by the camera.


### 6.4. Human Infrared Detection Alarm Debugging

We issue commands to the service robot on the PC side. Let the infrared module of the human body start to detect if there is a human being. The system uses Arduino mage2560 to control the GSM module to call and send text messages to users. This system can remind users in time by dialing. The user can know the specific information of the alarm by checking the short message. The test is shown in Figures20 and 21.Figure 20
Human infrared sensor detects someone.Figure 21
View SMS messages.


## 6.1. Robot Control Household Electrical Debugging

On the system, we send a command to the service robot to turn on the light. The service robot sends instructions to the terminal node that controls the lights through the CC2530 coordinator. The terminal node controls the on and off of the relay switch to control the light on and off. The control effect is shown in Figures17 and 18. In the debugging process, we test the control distance of the service robot by continuously increasing the distance between the service robot and the terminal node. In the absence of walls or other obstacles, the control distance of the service robot is within 10 meters. If there are obstacles, the control effect will be greatly affected.Figure 17
Effect picture before robot control.Figure 18
Effect picture after robot control.


## 6.2. PID Parameter Debugging

The stability of the service robot movement requires tuning of PID parameters. This design uses empirical trial and error method to determine PID parameters through experiments. The service robot conducts experiments under the condition of only its own weight and determines the PID parameters. Considering that the service robot is in the actual practical teaching application scenario, the load will not change much in a short time. Therefore, the parameters determined after experiments are applicable in general. The specific operation method of PID parameter tuning is as follows. First, we determine a set of parameter values ofkp, ki, and kd and put the system into operation. Then, we set the desired motor speed. Observe the step response curve of the motor speed output through the rqt_plot tool, and continuously change the parameter values of kp, ki, and kd to obtain a satisfactory step response curve.


## 6.3. Camera Information Collection and Debugging

The camera and the Raspberry Pi are directly connected through the USB serial port. Then, the PC is connected to the Raspberry Pi 3B remotely. The PC side runs the node (usb_cam) that starts the camera in the Raspberry Pi 3B, and then the PC side runs the rqt_imsge_view tool to obtain the image information of the camera as shown in Figure19. By adjusting the focus of the camera, clear image information is obtained.Figure 19
Information collected by the camera.


## 6.4. Human Infrared Detection Alarm Debugging

We issue commands to the service robot on the PC side. Let the infrared module of the human body start to detect if there is a human being. The system uses Arduino mage2560 to control the GSM module to call and send text messages to users. This system can remind users in time by dialing. The user can know the specific information of the alarm by checking the short message. The test is shown in Figures20 and 21.Figure 20
Human infrared sensor detects someone.Figure 21
View SMS messages.


## 7. Function and User Experience Comparison

In order to reflect the advantages of the home service robot designed in this article, we compared the robot function developed in this article with the robot function in the reference. We randomly selected 15 people, and each person experienced the robots in the following table for two days and then scored the experience of each robot. The results of the survey are shown in Table2. It can be seen from the table that the home service robot designed in this article has more complete functions than other robots, and the user experience is the best.Table 2
Survey results.
LiteratureFeaturesUser experienceReference [7]Temperature and humidity measurement, camera, light control, flame/smoke alarm, human body infrared sensor∗∗∗Reference [5]Human-computer interaction∗∗Reference [12]Voice communication, face recognition, human-computer interaction∗∗∗∗Reference [14]Wireless sensor and robot communication∗Reference [13]Speech recognition, human-computer interaction∗∗Reference [15]Wireless control∗Reference [16]Robot walking (balanced walking motion)∗∗The robot designed in this articleRobot walking, wireless communication, hazard alarm, autonomous navigation, indoor positioning, voice control, control of home appliances, human infrared detection warning, camera information collection∗∗∗∗∗


## 8. Conclusion

Currently, smart home service robots have fewer functions, and it is difficult to meet people’s needs for a comfortable, convenient, safe, and fun home life. And they still generally lack the ability to independently complete the task of combining autonomous patrols and home services. In response to this problem, this article has researched and developed a home robot system that has complete functions and can independently complete the task of combining autonomous patrols and home services. The system is based on ROS to design a smart home service robot system. It uses the framework and principles of the ROS system to build a distributed computing system through message publish-subscribe. The ZigBee networking structure between the CC2530 chip, the coordinator, and the terminal nodes is used to realize the ZigBee wireless networking. The voice control service robot is realized by Baidu AI voice recognition API. Using the combination of lidar and attitude sensor, the service robot realizes the establishment of maps and autonomous navigation of the indoor environment. Compared with related home service robots, the home service robots researched and designed in this paper have relatively sound functions and at the same time complete the task of combining independent inspections with home service. Compared with other home service systems, the system designed in this paper has a better user experience, making the user’s life more comfortable, convenient, safe, and fun.



---

*Source: 5511546-2021-06-28.xml*