Hardware-in-the-loop simulation approach for the Robot at Factory Lite competition proposal

Mobile robotic applications are increasing in several areas not only in industries but also service robots. The Industry 4.0 promoted even more the digitalization of factories that opened space for smart-factories implementation. Robotic competitions are a key to improve research and to motivate learning. This paper addresses a new competition proposal, the Robot@Factory Lite, in the scope of the Portuguese Robotics Open. Beyond the competition, a reference robot with all its components is proposed and a simulation environment is also provided. To minimize the gap between the simulation and the real implementation, an Hardware-in-the-loop technique is proposed that allows to control the simulation with a real Arduino board. Results show the same code, and hardware, can control both simulation model and real robot.


I. INTRODUCTION
Over the years with technological development, robotics competitions attracted more and more the attention of students and researchers from the areas of technology knowledge [1].The robotics competitions present problems that can be used as benchmark, in order to evaluate and to compare the performances of different approaches [2].These competitions have the capacity to produce in their teamwork, development in programming and logic as well as application of tools for the design, construction and operation of the robot.
Based on this theme, the Robot@Factory Lite competition (RaF Lite) aims to motivate students to develop methods to solve problems similar to those found on the shop floor of the industries.As for example the problem of logistics in the transport of raw materials and their processes.With the need for more efficient plants, the industry can find a solution to the logistical problems in Automated Guided Vehicles (AGVs).These transporters can work dynamically, where unforeseen events can arise along the way: unexpected obstacles, people crossing the path, material left behind or even other AGV.To this end, some important topics of robotics are explored, such as: control, location and navigation [3]- [8].
The RaF Lite competition emulates the small-scale shop floor of an industry where it is possible for autonomous robots to transport materials from the supply warehouse to the machines, waiting for the material to be processed, and then transported back to the final product warehouse.Because of this, robots must be able to collect, transport, position the materials in the right position, locate and navigate within the given environment without collisions.
Another incentive of the competition is to point out to competitors the importance of using simulations for robotic applications with software SimTwo.This provides a realistic simulation that can be employed in preliminary testing of team control software.Thus, a simulation model was developed as a reference for the teams to test their prototypes.Furthermore, an Hardware in-the-loop concept is addressed to allow a real hardware control the simulation environment.
The paper is structured in presenting first the state of the art, indicating other competitions and their contributions.Next, the RaF lite competition is described in detail, presenting the maze and the parts.Afterwards, the available tools for the execution of the challenge are indicated, the model robot parts, the SimTwo (official competition simulator) and the method of integrating the sensors in hardware-in-the-loop format are presented.Finally, results and conclusions with future work are presented.

II. STATE OF ART
Robot competitions bring together researchers, students and enthusiasts in the search for different solutions to a proposed technological challenge [9].Such competitions are an excellent way to foment research and to attract students to technological areas introducing new technologies, teamwork [10] and even developing solutions to real challenges in industry.
In this scenario, there are a huge number of robotic competitions that receive prominence due to their difficulty and proposed challenges besides the technological innovations that are developed for the battles among the participating teams.In this context highlights the RoboCupSoccer competition, founded in 1997 in Nogaya, Japan.It consists of a competition 978-1-7281-3558-8/19/$31.00 ©2019 IEEE where teams of robots compete for a soccer match proposed by [11].The RoboCupSoccer are held in five leagues being them Middle Size League (MSL), Small Size League (SML), humanoid, four-legged, and simulation.Further information about MSL ans SSL can be analyzed respectively in [12], [13].Over the years these competitions have been contributing to the scientific advance in areas such as: robust design of mechatronic systems, localization, sensor-fusion, tracking, world modelling and distributed multi-agent coordination [12].Another well-known competition is the DARPA Robotics Challenge.It is a competition funded by the US Defense Advanced Research Projects Agency where semi-autonomous ground robots should do complex tasks in dangerous, degraded and human-engineered environments.
Another important competition in autonomous robots is the Swarmathon, the challenge is to program robots swarms to search for, pick up and drop off resources in a collection areas [14].Swarmathon tries to simulate the terrestrial environment of Mars, so that participants can contribute to collecting resources on the surface of the red planet.The focus of the event is to encourage participants to develop systems that operate autonomously, without a global map, and yet are flexible to meet the variety of unknown distributions.Beyond physical challenges, competitors can also participate in virtual disputes where the challenge is performed in a manner similar to the physical environment.As a result, the competition has already encouraged dozens of students to venture into the robotics field [15].
A competition that describes the essential components for the Factories of Future (FoF) is RoboCup@Work, which was established in 2012 [16].This competition uses mobile robots equipped with manipulators in scenarios that represent complex and challenging industrial environments to detect, manipulate and transport objects, evaluating the autonomous and adaptive capacity of the mobile [17].Some of the challenges to be faced by the teams to get good results in this competition are related to perception, path planning and motion planning, mobile manipulation, planning and scheduling, learning and adaptability, and probabilistic modeling [16].Information about rules of this competition can be checked at [18].
The Robot@Factory is one of the competitions in the main Portuguese Robotics Competition.It was designed to provide participating teams the challenges encountered in actual plants of flexible factories by using AGV's to transport objects or materials from one place to another.These mobile robots carry out a circuit that transports the material from supply warehouse to the machines and then to the final product warehouse.For this the robot should be able to collect, transport and position the materials in the correct positions, besides being able to locate, navigate and avoid the collision with obstacles, robots and walls existing in the scenario of the competition [19].The RaF@Lite was inspired by Robot@Factory, in order to improve the competition by adding new tools and technological components that will be described throughout this work.

III. COMPETITION DESCRIPTION
This competition aims to present a problem inspired on the deployment of autonomous mobile robots on a factory shop floor.One or more robots should be able to transport materials between warehouses or machines that process those materials.The robots must collect, transport and position the materials, self-localize and navigate while avoiding collisions with walls and other robots (if any).It was based on the original Robot@Factory with some mechanical and hardware simplifications.While in the original challenge the robot had to pick up the box with a forklift, in this version the robot can drag the box using an electromagnet.The dimensions will also be adjusted so that this competition can attract smaller robots whose control can be done with an embedded system or with a simple microcontroller.The floor will be replaced by a twosheet A0 print, where black lines on white background can be used for robot localization.The layout will be simplified to facilitate the maneuvers related to the transport and collection.The incoming and outgoing warehouses location remains the same.The challenge is composed by three rounds (as further presented in detail): In the first round, like the original challenge, it is necessary to move the parts between the incoming and outgoing warehouses.In the second round some parts must be processed by machines and in the third round some parts will have to go through two processing machines.The goal will be to transport as many parts as possible in the shortest time.The different parts can be recognized by the robot through an RFID reader.Important files and the complete description of rules can be found at [20].

A. Maze
The competition area simulates a small-scale factory floor where there are warehouses and machinery that are far apart.The maximum dimensions of this area are 1.7 x 1.2 m.There are eight available machines and two warehouses, one of which is used as the source of parts to be produced (the incoming warehouse) and the other is their final destination (the outgoing warehouse).Warehouses and machines are connected through tracks, forming a sort of maze, shown in Figure 1.The dimensions and distances of the field are illustrated in Figure 2. The robot has to load and unload the parts on the machines, so that this process resembles the manufacture of an industry.That is, in each machine there is an area where the parts must be placed to be processed (Input) and another area where the processed parts must be removed (Output), as illustrated in Figure 3. Therefore, after the part is placed on the left side of the machine (Input), it will be processed and must be collected on the right side (Output) and taken to the outgoing warehouse.

B. Floor markers
On the shop floor there are black lines that can be used by the robots to find the way between warehouses and machinery.All the black lines have a width of 30 mm.Teams are authorized to use other guidance and localization schemes, if desired.Four areas are set aside, near the corners of the "factory", where the teams can place their own markers to assist the robots in their localization or navigation.These areas are squares with 10 cm sides and the maximum height is 50 cm.

C. Parts
The parts to be transported by the robots have standard dimensions, the width and length of 90 x 60 mm, its height is not less than 65 mm.There is a metal plate with 23 x 80 mm placed on the front face of the part (shown in Figure 4).Each part has an RFID tag (placed inside the box and above the metal plate) that identifies the part type.When a part is placed on one machine, the part is transformed into another type of part.The delay (or its statistical distribution) for each part/machine will be available to the teams before the start of the competition.Altogether there are four pieces to be processed, they can be of three different types each (transported directly to the outgoing warehouse, perform a processing in the machine type A or perform two processing in machine type a followed by the processing in machine type B) -see Figure 3.

D. Rules summary and rounds
The competition is divided into three rounds.Each team will have 10 minutes to do the initial tests on the field before the trial starts.During the trial a team can attempt as much runs as it is possible in its 10 minutes slot.
For each trial, the final score is the total number of parts correctly placed in the outgoing warehouse.The best run is automatically considered.Figure 3 shows the starting area for the robot and the machines types with the input and output places.For each run the robot must start inside the green area.
In the first round the objective is just to collect the four parts from the incoming warehouse and transport them to the outgoing warehouse as fast as possible.The four parts will be already placed on the incoming warehouse, ready to be moved.
In the second round, some of the four parts present in the incoming warehouse must be placed in a machine for processing.After the completion of this operation they can be carried into the outgoing warehouse.
A table that maps the RFID codes that differentiates the parts from those that are already processed and can be taken directly to the outgoing warehouse will be published.For this round there is an additional rule that every attempt must be spaced by at least one minute.It is only possible to resume an attempt one minute after the moment when the previous attempt was initiated.This limits the maximum number of attempts to less than 10.
In the third round, some parts in the incoming warehouse should be placed sequentially in more than one machine to be completely processed.Because of this there will be three types of parts in play, listed in the Table I:

E. Automatic Referee
The automatic referee is being developed in order to validate the movement of parts and perform the measurement of time for each team.It is supposed to place a camera upside the field and to use an embedded system that processes the image and automatically provide information about the competition.A tracking system based on QR-codes placed on the top of the parts will allow the image system to classify the movements.The automatic referee is an independent system and will be further presented in another paper.

IV. AVAILABLE TOOLS
Once Robot@Factory Lite is a new competition proposal, several tools are proposed by the organization to attract new teams to this challenge and to help in the robot prototyping.Nevertheless, teams are free to develop their own robot since it respect the dimensions available on the rules.The 3D parts of the proposed robot can be printed and assembled as further presented in next subsections.A source code example, based on Arduino Nano platform, is provided that allows to show how to control the proposed robot, moving forward and backward, reading the RFID module, detect the part, control the magnet and follow the floor line.A simulation environment ( [21]), based on SimTwo [22], allows to simulate and develop the control application.To approach the simulation and the real robot, a hardware-in-the-loop communication is provided in order to use the Arduino as the main controller of the simulated robot (in SimTwo via USB).

A. Robot parts
The organization provide to the teams the 3D cad files (in stl format) of the parts and of the robot, so that is can be easily assembled.A list of components and materials needed to develop and assembly the hardware is also available.The proposed robot can be created in a 3D printer through several parts.The assembled robot is depicted in the top of Figure 5 which presents a CAD model whereas the bottom shows a real assembled robot.

B. Simulation environment model
Simulation is one of the most powerful tools to develop, test and validate hardware, software and mechanical approaches.In this proposal, SimTwo simulator is encouraged to be used.SimTwo is a realistic simulation system, based on ODE and GLScene, that can support several types of robots.The main purpose is the simulation of robots where the model of sensors and actuators are implemented bridging the gap between the simulation and the reality [22].A model of the Robot@Factory environment is available that allow users to test and validate algorithms.Figure 6 presents a screenshot of the 3D SimTwo environment at left and the Pascal script to implement the control at right side.This simulation tool was used in several other projects but for this competition, a GRV elec magnet model was developed and implemented in this simulation environment.The electromagnet can only generate attraction forces, as it is defined in Equation 1, where the Magnetic Force (F m ) depends on the products of the permeability coefficient (µ 0 ), cross area (A) and number of coils (N ) divided by 4. Considering the air-gap, this relation depends on the current of the solenoid (i) in the square divided by the distance of the airgap (g) squared [23].The force value is computed and applied to the metallic parts in the simulation.This type of parts are attracted to the solenoid when connected.
Besides, a more realistic approach is presented in next subsection that uses an Arduino to control the simulator.

C. Hardware in the Loop
Another useful and available tool for this competition is the Hardware-in-the-Loop (HIL).This tool provides a feature to test the hardware responsible for controlling all actions of the real robot, but controlling the virtual robot through Serial (USB) communication established with SimTwo in real time.In other words, the simulator will provide the sensor data (line sensor values, part detection and RFID tag) to the embedded controller in the hardware, which will process the data and control the actions of the virtual robot (motors and electromagnet) according to the architecture shown in Figure 7.The HIL tool provides the possibility for competitors to implement their scripts in the microcontroller that will control the real robot and perform tests on the simulated robot, reducing errors in design, algorithms, controls and logic [20].The HIL deals with the real limitations of the microcontroller used to control the robot.The memory requirements and the processing limitations of a microcontroller are stressed and return the real problems minimizing the gap between the simulation and the reality.Each 40ms, the control loop is updated by the microcontroller that receives the data, processes it and send the control data to the simulator.

V. RESULTS
Although the RaF Lite is based on another competition, some optimizations have emerged in the course of its development as detailed in next subsections.

A. Competition
Given the need of the industry, it was thought to create a small-scale environment such as found on the shop floor.Without any feature of the industrial plant being lost, so the arrangement of the components of this environment is in accordance with the same movements of a robot in the real workspace.
The choice of the size of the environment was due to the fact of facilitating the mobility of the arena, so the competitors can print on sheets A0 and carry out their tests in a low-cost way.With floor markers to form the path between points of interest, competitors can easily implement simple hardware and software solutions to control and locate their robots.Another factor of the marked floor is the application in real industries, since it is a commonly applied practice in demarcating the floor to indicate certain situations.As previously noticed, teams can use any other method to perform the localization.

B. Control robot
In order to encourage the teams to participate in the competition, a prototype robot controlled by the Arduino Uno microcontroller and an example of the implementation of HIL in conjunction with the SimTwo was created.Figure 8, shows at left the real robot picking up the part and at the right side the simulation.The two situations are occurring at the same time and in the same position of the arena, as shown in Figure 8.The validation test can be seen in two videos: The link https://www.youtube.com/watch?v=s0QYIX771MY shows the real robot picking the part moving 180 degrees and place it, whereas the video on the link https://www.youtube.com/watch?v=ljbvA9CRFfkshown the simulated robot that is controlled by the Arduino Nano performing the same movement.It is import to notice that the same code in the Arduino board allows to perform the same tasks: real and simulated environment.The only difference is that in the first case, the Arduino receives the information from the sensors and actuates the driver for the motors and in the second case the sensors data is provided by the SimTwo and the Arduino actuates the motors of the simulated robot through the serial port.All the competition can be tested in the environment scenario but controlled by the Arduino or another embedded system.
An important factor in the application of HIL is the use of different widows that provide information about the execution, such as the "Sheet" tool that present and control the state of the robot, the chart window that allow user to log and verify all the sensors information and position of the components.Figure 9 presents a graphic with the left and right motors speed.Figure 10 shows the data provided by the line sensors from the SimTwo.
In the provided demo, it is required to select the "Serial" option and use the "Set" value of 1 to start the movement.

VI. CONCLUSION AND FUTURE WORK
This paper described a new competition proposal to be included at the Portuguese Robotics Open that occurs annually and receives international teams.In order to captivate new participants, a mechanical setup of the robot is proposed as well as the basic controller algorithms that follow a line, magnetically grabs the parts to be moved and read sensors such as RFID.A simulation model is also provided to help participants in the algorithms development, testing and validation.Furthermore, this paper presents a hardware-in-the-loop methodology that allows an Arduino board to control the simulation robot.By this way, the real limitations (such as memory requirements and processing time) are stressed and the developed algorithms can be implemented and validated in the hardware without the real robot.As future work, it is proposed the development of an automatic referee based on image processing that classifies the teams in an automatic way.

Fig. 4 .
Fig. 4. Isometric view of the part with RFID tag.

Fig. 5 .
Fig. 5. Assembly of the robot in CAD model and prototype.

Fig. 8 .
Fig. 8. HIL test developed.At right the real robot and at left the simulation.