Autonomous Mobile Robot Implemented in LEGO EV3 Integrated with Raspberry Pi to Use Android-Based Vision Control Algorithms for Human-Machine Interaction †

.


Introduction
Robots are one of the most promising devices to be potentially used in industry, agriculture [1,2], medicine [3], education [4,5] and some other fields.These can be programmed, configured, and optimized to perform tasks with high accuracy and great flexibility due to their kinematical degrees of freedom and versatility of adapting tools such as sensors, cameras, and other periphery devices.For instance, robots reach up to places inaccessible to humans, perceiving their surroundings, and collecting information to make decisions by themselves through decision support systems based on artificial intelligence techniques to adapt their movements depending on the requirements.Robots can perceive their surroundings by using several types of sensors, such as cameras, which allows the robot to have human-like perception.
Machines 2022, 10, 193 2 of 20 Different configurations of integrated robots applying mobile or fixed cameras or sensors are reported in literature [3,6,7].These are well-known as visual servoing, which is used to obtain the necessary data of the surroundings from a camera through images locally or remotely collected, by using various kinds of controllers such as task function [8][9][10], predictive control [11,12], rational systems and LMIs (Linear Matrix Inequalities) [13], applying Kalman filters [6], etc.The main goal of visual servo control is to allow the robotic system operation under surrounding changes, detected through the images recorded by a camera to perform tasks according to the decision of a controller.Usually, controllers can be carried out in two ways: the first uses a central station to process images and compute and transmit the controller's decision to the robot; and the second, the robot performs all tasks.For the last one, the robot's devices should have an adequate processing capability to process the image and run up as quickly as possible the control algorithms.
Applications use image processing, robotics, and control theory jointly to command the motion of a robot depending on the visual information extracted from the images captured by one or several cameras.Currently, there are many problems of great interest to the scientific community such as different image features extraction of more complex geometries, enhancement of velocity of algorithms, convergence problem in control, and others [14].
Regarding the state of the art, robotic and visual control converges in recent reported topics are related to omnidirectional platforms designed to cooperative robotic systems [15] to make a task.As an example, elements like Raspberry Pi with an integrated camera for image processing and future extraction [16], both operating in the same programing environment were used as mechanism of a manipulative robot.Moreover, an eye-in-hand manipulative robot using optimal controller allows to minimize the force and torque in the joint engines of the robotic systems to assess the performance of the controller [17].
Following the state of the art in robotic systems and its relationship with controllers, in this research work a novel robotic system integrated with technologies with different operating systems is presented, such as the LEGO Educational Kit and the Raspberry Pi to assess visual control algorithms.In addition, an Android application is added for human-machine interaction that allows to visualize the robot's perspective, thus allowing manual or automatic control of the robot for safe operation in case of being executed in a hostile environment.
This work shows the design of robotic systems either using IBVSs (Image-Based Visual Servo) (see a previous work reported by some authors in [18], PBVSs (Position-Based Visual Servo), or hybrid HBVS (Hybrid-Based Visual Servo) scheme (image and position-based).A camera mounted on the robot can roll over its axis minimizing the non-holonomy of the robotic system [19].Algorithms are implemented by running up embedded servoalgorithms in open-source platforms.In this case, a Single Board Computer (SBC) known as Raspberry Pi is used.This paper shows a robot assembled as a three degree of freedom (3 DOF) structure using LEGO™ Mindstorms robotic kit, adding a platform to hold a camera.Two of the 3 DOF were used for the platform movement in the XY plane, and the third-degree to enable the platform's rotation.This proposed robot was implemented as an IBVS and assisted with an Android smartphone for remote operation.One of the main challenges reported in the literature consists of using Mindstorms in other applications beyond educative programs since there are no limitations and impediments [4,20].These can be jointly configured with other operative systems like Raspbian, Linux, and mobile Android to support open-source codes and other sensors [21,22].This work is a proposal to explore this challenge focused on algorithms for feature extraction using IBVS, PBVS, and hybrid schemes implemented with an open-source operative system, as the first step of prototypes design to be used in broader applications in real environments.
This paper is organized into five sections.In the second section, a kinematic model of the 3 DOF's robot, and the image representation using matrix formulation, followed by the equations to design controllers based on the IBVS, PBVS algorithms, and hybrid approach are presented.The third section is related to the experimental setup of assembling the robot, the communication system between the Raspberry Pi, the Mindstorms control and power station Lego EV3 brick, and the mobile interface designed in an Android smartphone.In the fourth section, the simulation results of the IBVS and PBVS algorithms and a hybrid scheme are presented, applied to the proposed 3 DOF robotic system in terms of the image and position error evolution and the robot's expected poses.Finally, the article shows the results of the implementation using the servo control algorithm IBVS embedded on the Raspberry Pi to recognize a target image remotely monitored by a video streaming application running up in the interface of the Android smartphone.

Kinematical Degrees of Freedom Model, and Controller's Design
In this section, the robotic system is kinematically modeled using position and rotation equations, relating them to the images by using a matrix formulation.These equations are used to design controllers based on application of IBSV, PBVS algorithms, and a hybrid (HBVS) scheme.

Kinematic Model
This robot can be modeled using a Hilare-type approach implemented with one motor that controls each robot side as shown in Figure 1.This robot kind has reliable performance, low rotation radius, and is easily controllable and simple to assemble [20].Furthermore, it has three degrees of freedom (3 DOF), two of them make up the XY plane (two degrees of freedom), where the pair (x,y) is the robot's position in global coordinates used as a reference for the linear displacement assuming linear speed.The other coordinate is related with the z-axis, assigned to any rotation θ around itself.
the equations to design controllers based on the IBVS, PBVS algorithms, and hybrid approach are presented.The third section is related to the experimental setup of assembling the robot, the communication system between the Raspberry Pi, the Mindstorms control and power station Lego EV3 brick, and the mobile interface designed in an Android smartphone.In the fourth section, the simulation results of the IBVS and PBVS algorithms and a hybrid scheme are presented, applied to the proposed 3 DOF robotic system in terms of the image and position error evolution and the robot's expected poses.Finally, the article shows the results of the implementation using the servo control algorithm IBVS embedded on the Raspberry Pi to recognize a target image remotely monitored by a video streaming application running up in the interface of the Android smartphone.

Kinematical Degrees of Freedom Model, and Controller's Design
In this section, the robotic system is kinematically modeled using position and rotation equations, relating them to the images by using a matrix formulation.These equations are used to design controllers based on application of IBSV, PBVS algorithms, and a hybrid (HBVS) scheme.

Kinematic Model
This robot can be modeled using a Hilare-type approach implemented with one motor that controls each robot side as shown in Figure 1.This robot kind has reliable performance, low rotation radius, and is easily controllable and simple to assemble [20].Furthermore, it has three degrees of freedom (3 DOF), two of them make up the XY plane (two degrees of freedom), where the pair (x,y) is the robot's position in global coordinates used as a reference for the linear displacement assuming linear speed.The other coordinate is related with the z-axis, assigned to any rotation θ around itself.Using these coordinates, the robot kinematic can be depicted by Equations ( 1) and (2): Using these coordinates, the robot kinematic can be depicted by Equations ( 1) and (2): Equation ( 1) is a rotation matrix that models linear speed, and robot rotation concerning coordinates axes, and Equation (2) models the angular speed of the robot's wheels, so both equations can configure a real application.In Equation (1), .
x and .y are the linear speeds of the robot related to x and y coordinates, and .θ is the angular speed related to the rotation movement around z.The term .θ pl is the orientation related to the camera movements mounted on top of a rotary platform, so this is the third degree of freedom.The relationship between outputs and angular speeds (ω right , ω le f t , and ω pl ) of the robot's wheels are given by Equation ( 2) [10,20,21].These are the real inputs of the robotic system modeled for the application implemented here where r is the wheels' radius, L, distance between wheels, ω right , right wheel angular speed, and ω le f t , left wheel angular speed.
On the other hand, a mobile robot model can be described in different reference frames.These frames can be the world frame reference or the actuator frame reference.In this proposed robot, the actuator or element that gives a surrounding perception is a camera.Then, to pass from the world's frame to the image's frame, it is necessary to transform all frames that pass through the world's frame, mobile's frame, and then to the platform's frame, until the camera's frame that uses coordinates transformations.This kind of transformation is obtained through the following expressions shown in Equations ( 3) and ( 4) [10,15]: where x c is the x component of the translational vector to pass from platform frame reference to camera frame reference; x p , the x component of the translational vector to pass from robot frame reference to platform frame reference; y c , the y component of the translational vector to pass from platform frame reference to camera frame reference; and y p , is the y component of the translational vector to pass from robot frame reference to platform frame reference.V x c , V y c , and V z c are the linear speeds expressed in the camera's frame, and Ω x c , Ω y c , and Ω z are the angular speeds expressed in the camera's frame.
In this case, a control signal should be applied to change the angular speed of the wheels, then it is necessary to use Equation (2) instead of (1) for the coordinate's transformation, to obtain an expression for the angular speed of the robot in the camera frame reference [10,22]: To model the image in the camera, the next subsection will show the equations for the image representation in this frame of reference.

IBVS Interaction Matrix
Until now, an expression has been obtained that represents a change in the world's frame into the camera's frame as shown in Equation ( 4), nonetheless, it is necessary to find an expression that represents the changes in the camera's frame into the image (object) frame.
The object image representations are often modeled by the pinhole lens approach as shown in Figure 2.With this approach, the lens is considered an ideal pinhole.The pinhole is located at the lens focal center, and placed behind the image plane to simplify the model.Light passes through this pinhole intersecting the image plane.Thus, P is a point in the world with coordinates x,y,z; and p denotes the projection of P onto the image plane with coordinates (u,v,λ).
Machines 2022, 9, x FOR PEER REVIEW 5 of 21 To model the image in the camera, the next subsection will show the equations for the image representation in this frame of reference.

IBVS Interaction Matrix
Until now, an expression has been obtained that represents a change in the world's frame into the camera's frame as shown in Equation ( 4), nonetheless, it is necessary to find an expression that represents the changes in the camera's frame into the image (object) frame.
The object image representations are often modeled by the pinhole lens approach as shown in Figure 2.With this approach, the lens is considered an ideal pinhole.The pinhole is located at the lens focal center, and placed behind the image plane to simplify the model.Light passes through this pinhole intersecting the image plane.Thus, P is a point in the world with coordinates x,y,z; and p denotes the projection of P onto the image plane with coordinates (u,v,λ).Here, the Jacobian Image Li(s), also called interaction matrix, is used to represent the relative changes in the image into the camera reference frame.Assuming that the image geometry can be modeled using perspective projection and the camera lens is a pinhole type, the following expression can be used [10,20,21]: where  is the focal lens distance, and the pair (u,v) are the pixel location.s is a set of visual features extracted from the object.Here, the Jacobian Image L i (s), also called interaction matrix, is used to represent the relative changes in the image into the camera reference frame.Assuming that the image geometry can be modeled using perspective projection and the camera lens is a pinhole type, the following expression can be used [10,20,21]: where λ is the focal lens distance, and the pair (u,v) are the pixel location.s is a set of visual features extracted from the object.

PBVS Interaction Matrix
PBVS is aimed to regulate the error between current camera pose and goal pose with respect to the objective.Pose is defined as X(t) T Uθ T , where X(t) R 3x1 is the translational distance expressed in world frame reference and Uθ R 3x1 is the rotation angle around the axis defined by the unitary vector U, where U represents the orientation vector where the robot is rotating.The interaction matrix is given by [23][24][25]: where [X(t)] x is the skew matrix of X(t) and L θu is given by: The kinematic screw describes the changes of the kinematic chain concerning time, also known as Jacobian robot.At this point, it is possible to represent how the image changes depending on the robot movements in the world frame.The following subsection uses the kinematic screw and the interaction matrix to impose an error performance.

IBVS Servocontrollers
The Image-Based Visual Servo Control (IBVS) scheme uses a set of points that represent visual features of the objective obtained by the camera (real image).The image features (m) are often measured in pixel units and represent a set of image points in image coordinates.The objective image (s * ) can be static or dynamic.In this research work, it is assumed to be fixed to the world's frame.
The control scheme is obtained from an error function, and it is computed from the real image and the objective.Thus, the basic equation for an IBVS control scheme is: where C is the combination matrix, s(t), a set of visual points in the image plane, and s * (t), the visual goal feature points.To ensure the convergence of e(t) to zero, a decreasing behavior on the error is imposed: .
where, β is a positive gain scalar (β > 0) representing the time constant of the error convergence.Then, by deriving Equation ( 8) and equalizing with (9) the relationship between β and the error e i (t) is obtained: .
As s(t) represents the visual features, we have an expression to represent changes in the image frame into other frameworks, thus, the chain rule over ( 10) is allowed to apply as [21]: .
where r is the robot frame and .
p : v ω ω pl T is the control signal.

∂s(t)
∂r represents the image changes into the first robot frame, or the interaction matrix L(s) described in the last subsection; and ∂r(t) ∂p represents the robot changes regarding a known input variable or the Jacobian robot J r (p).
Finally, Equation ( 11) can be rewritten in terms of interaction matrix, well-known as L(s) or Jacobian, and Jacobian robot J r (p) as shown: .
Machines 2022, 10, 193 7 of 20 Based on the equality from ( 10) and ( 8) the control law is obtained as: .
where (L(s)J r (p)) + is the pseudo-inverse of L(s)J r (p).
To ensure stability in the sense of Lyapunov, it is proposed as a candidate, the Lyapunov function or quadratic function of the error: Since the proposed Lyapunov function depends on the quadratic norm of the error, then it can be demonstrated that ∀e(t), V(e i ) ≥ 0 so, the function is positively defined.Now, it is necessary that .
V(e i ) ≤ 0, then by deriving Equation ( 15) and replacing on (12) the following expression can be obtained: .
to ensure that .
V(e) ≤ 0, the following expression must be positive, semi-defined as This condition is rarely achieved when dim(s) > 6.The Jacobian image is overdetermined.It will have a nonempty null space, and local minima will exist.However, when L(s) is full rank at the goal s * , there is a neighborhood of s * in which (L(s)J r (p))(L(s)J r (p)) + is positive semi-defined, and thus IBVS is globally stable in the sense of Lyapunov [9,26].

PBVS Servocontroller
The PBVS control scheme (Position-Based Visual Servo Control) uses the robot relative pose.For this controller, an estimated pose is computed by the camera and feature extractor.Thus, s p (t) represents the actual orientation of the robot and s * p (t) represents the desired orientation of the robot with respect to the objective; the error equation is: In this case s * p (t) is fixed but can be a variable function.To ensure the convergence of e p (t) to zero ( e p (t) → 0 ) a behavior is imposed as follows: . e p (t) = −λ p e p (t) (19) where λ p is a positive gain scalar λ p > 0 and represents the error time constant.Then, Equation ( 18) is derived: . e p (t) = .
s p (t) can be calculated using the chain rule on the Equation ( 21), as follows: .
where r is the robot,  Finally, Equation ( 22) can be rewritten as shown: .
Equaling the Equations ( 21) and ( 23), the following expression is obtained: . p = −λ p L p (s)J r (p) + e p (t) (24) where L p (s)J r (p) + is the pseudo-inverse of L p (s)J r (p).
To ensure stability in the sense of Lyapunov, it is proposed as a candidate, the Lyapunov function or quadratic function of the error [27]: where D is 6 × 6 a weight matrix that ensures that the proposed Lyapunov function is positive V e p ≥ 0 .The following necessary condition .
V e p ≤ 0 must be fulfilled.This was developed in detail in [11,12,27], with the conclusion that the derivative of candidate Lyapunov function is negatively defined .
V e p ≤ 0 .By analyzing Equation ( 7), it is nonsingular when θ = 2kπ.In other cases, the system is asymptotically stable in the sense of Lyapunov.

HBVS Servocontroller
In this section, a control strategy is proposed that switches between controllers IBVS and PBVS to obtain better control and performance on the system.The switching rules between these controllers and their stability as a system are shown.It is important to highlight that those two stable systems in an inappropriate switching mode could generate an unstable system.The block diagram of Figure 3 Equaling the Equations ( 21) and ( 23), the following expression is obtained: where  () () is the pseudo-inverse of  () ().
To ensure stability in the sense of Lyapunov, it is proposed as a candidate, the Lyapunov function or quadratic function of the error [27]: where D is 6 × 6 a weight matrix that ensures that the proposed Lyapunov function is positive   ≥ 0 .The following necessary condition   ≤ 0 must be fulfilled.This was developed in detail in [11,12,27], with the conclusion that the derivative of candidate Lyapunov function is negatively defined   ≤ 0 .By analyzing Equation ( 7), it is nonsingular when  ≠ 2.In other cases, the system is asymptotically stable in the sense of Lyapunov.

HBVS Servocontroller
In this section, a control strategy is proposed that switches between controllers IBVS and PBVS to obtain better control and performance on the system.The switching rules between these controllers and their stability as a system are shown.It is important to highlight that those two stable systems in an inappropriate switching mode could generate an unstable system.The block diagram of Figure 3 shows a diagram representing the control strategy proposed, based on a structure of the Hybrid Control System between the IBVS and PBVS.The switching between the two types of controllers could be under arbitrary switching or based on commutation rules.In this research study, the stability under switching based on the state of the error is proposed.A switching strategy to simultaneously achieve stability in the pose space and image space as a set of simple switching rules is presented as follows: • PBVS to IBVS The switching between the two types of controllers could be under arbitrary switching or based on commutation rules.In this research study, the stability under switching based on the state of the error is proposed.A switching strategy to simultaneously achieve stability in the pose space and image space as a set of simple switching rules is presented as follows: Machines 2022, 10, 193 9 of 20 where β p : is the maximum acceptable pose error; β i : is the maximum acceptable feature point error.
Based on [25,28], it is possible to establish the stability of a hybrid switched control system.In this, two different Lyapunov functions will be used, V i (e i ) and V p e p as it was defined in ( 15) and ( 25) respectively.Let us consider a set of switching times by t = t 0 , t 1 , . . ., t n .Since we have two different controllers, it is possible to separate these set of times as follows: t i = t 0 , t 2 , t 4 , . . ., t n is the set of times at which the system changes from IBVS to PBVS and t p = t 1 , t 3 , t 5 , . . ., t n−1 is the set of times at which the system changes from PBVS to IBVS.
For our system, the conditions to ensure stability from [28] are: The conditions detailed above were tested in [22,25].In this paper, the aim of switching between these two systems is to ensure that the systems avoid the local minimum presented when IBVS is uniquely performing.It is important to highlight that in this scheme discontinuities may occur due to the switching between both controls with different types of references (image features and pose).

Experimental Setup
A communication system between a Raspberry Pi and a mobile interface of a smartphone was integrated on the assembled robot to perform an experimental setup to implement the IBVS control.This proposed 3 DOF robot is operated with an IBVS control scheme based on image detection installed on the operative system of the Raspberry Pi into an SD card, selecting Raspbian mode to support a balanced system.After that, it just remains plugged together with the peripherals: mouse and keyboard, HDMI output for video, and cable.Some software were installed such as OpenCV, SimpleCV libraries, and other libraries required for image processing and control implementation (NumPy, SciPy, and Setuptools), and SSH library for communication with Lego EV3 system [29,30].

Design of the Communication System between Raspberry Pi and Smartphone
The communication system structure is sketched in Figure 4. First, the configuration to make possible the communication between SSH and LEGO EV3 (Computer Kit LEGO robotics) was defined in order to configure the set of Raspberry Pi to operate as an access point, and in this way, not depend on an external Wi-Fi network.Second, the network Raspberry was created to maintain a fixed IP, assigning this to the smartphone with the Android operating system via the DHCP service.

Design of Mobile Interface Using a Smartphone
To design and implement the mobile interface (henceforth, mobile app), two sockets to communicate the phone with the Raspberry Pi were used.One of them, to receive data from the phone to the Raspberry Pi, and the other, to send control data.This application was configured in two control modes.First, the automatic mode, where the entire control process is performed by the Raspberry Pi, and second, the manual mode, in which a user operates the robot.Both modes are interchangeable using an eye-shaped button located at the top of the application.

Design of Mobile Interface Using a Smartphone
To design and implement the mobile interface (henceforth, mobile app), two sockets to communicate the phone with the Raspberry Pi were used.One of them, to receive data from the phone to the Raspberry Pi, and the other, to send control data.This application was configured in two control modes.First, the automatic mode, where the entire control process is performed by the Raspberry Pi, and second, the manual mode, in which a user operates the robot.Both modes are interchangeable using an eye-shaped button located at the top of the application.
The automatic mode will operate only to monitor the robot, so it was decided to activate a streaming video interface running up as an Android app that communicates to the robot's camera visualizing and monitoring the surroundings.The app also allows to visualize variables such as the angular speed of each motor of the right engine ( ), the left engine ( ), and the engine that moves the camera's platform ( ) (See Figure 5a).In contrast, the manual mode (see Figure 5b), allows access to up to six buttons to manually control the robot.Four of those buttons are used to control stock movements of the robot: forward, backward, right, and left, and the other two buttons are used to control the movement (right and left) of the camera platform.Both modes allow streaming video from the camera.The Mobile app code is found in the Supplementary Materials section.The automatic mode will operate only to monitor the robot, so it was decided to activate a streaming video interface running up as an Android app that communicates to the robot's camera visualizing and monitoring the surroundings.The app also allows to visualize variables such as the angular speed of each motor of the right engine (ω right ), the left engine (ω le f t ), and the engine that moves the camera's platform (ω pl ) (See Figure 5a).In contrast, the manual mode (see Figure 5b), allows access to up to six buttons to manually control the robot.Four of those buttons are used to control stock movements of the robot: forward, backward, right, and left, and the other two buttons are used to control the movement (right and left) of the camera platform.Both modes allow streaming video from the camera.The Mobile app code is found in the Supplementary Materials section.

Assembling the Robot
The robot was assembled using: • A Kit ™ LEGO Mindstorms robotics for the entire platform, including engines and

Assembling the Robot
The robot was assembled using: • A Kit ™ LEGO Mindstorms robotics for the entire platform, including engines and LEGO EV3 ™ CPU.

•
A Single Board Computer Raspberry Pi Model B, with a Pi Camera connected to it via ribbon cable.

•
An external battery of 5600 mAh.
The final design of the robotic system with the adaptation of the Raspberry Pi and the camera can be seen in Figure 6.

Assembling the Robot
The robot was assembled using: • A Kit ™ LEGO Mindstorms robotics for the entire platform, including engines and LEGO EV3 ™ CPU.

•
A Single Board Computer Raspberry Pi Model B, with a Pi Camera connected to it via ribbon cable.

•
An external battery of 5600 mAh.
The final design of the robotic system with the adaptation of the Raspberry Pi and the camera can be seen in Figure 6.Some simulations were running up to operate this robot using the controllers as shown in the next section.Some simulations were running up to operate this robot using the controllers as shown in the next section.

Simulation Results
The concept of Epipolar Geometry is a key topic for simulating visual servo-control systems.This geometry is related to stereoscopic vision.Thus, if one or two cameras are in a 3D scene, there are several geometric relationships between 3D points and their projections on 2D images.These relationships are obtained based on the assumption that the cameras can be approximated by the pinhole model.The Epipolar Geometry Toolbox developed in [31] at the University of Siena was used for the simulation.
Simulations for IBVS, PBVS, and Hybrid controllers are run up using these parameters and the codes reported in [32]: where Xc is the distance from the X-axis from the camera to the platform; Yc, the distance from the camera to the platform; Xp, from the X-axis of the platform to the center of the robot; and Yp, from the Y-axis of the platform to the center of the robot.
Figures 7 and 8 show the simulation results of the error of a visual servo control over a robotics system of 3 DOF.Once the previous results were obtained, the next steps were to compute the Jacobian robot, i.e., the 6 × 3 matrix in Equations ( 3) and (7), and the control law given by ( 12), (23) considering the real measurements of surrounding by using the parameters mentioned above.Furthermore, the switching rules are followed for the hybrid controller (see Section 2.5).The main difference between IBVS and PBVS controls consists of the reference to estimate the error norm.For instance, in IBVS control sensed images, features are extracted and compared using the image plane.In PBVS control image features are also extracted, and this information is used to compute relative position from the object to be compared with the goal relative position.PBVS error is greater than IBVS because they have different units: PBVS error is computed in length units of centimeters, but IBVS error is computed in pixels.The main difference between IBVS and PBVS controls consists of the reference to estimate the error norm.For instance, in IBVS control sensed images, features are extracted and compared using the image plane.In PBVS control image features are also extracted, and this information is used to compute relative position from the object to be compared with the goal relative position.PBVS error is greater than IBVS because they have different units: PBVS error is computed in length units of centimeters, but IBVS error is computed in pixels.

Evolution of Image Frame
Figure 9 shows the image evolution of the robot camera (in pixels) in the three cases IBVS, PBVS, and HBVS.For this, a square will be shaped by using the four red points shown in this figure.This will be shown for the IBVS in the next section of the experimental results.

Image Error Evolution
Figure 7 shows the simulation of the image error evolution as a time function applying the IBVS (Image Based Visual Servo), PBVS (Position Based Visual Servo)" and the hybrid scheme controllers.For the IBVS control, it can be observed that a minimum error is reached after 1.3 s (see the local minimun), and after there is a negligible increase, similarly, a minimum error is reached after 5 s for PBVS control.Regarding hybrid controller (HBVS), the simulation of image error evolution depends on the time when HBVS is applied.It can be observed that a minimum error is reached after 2.1 s.
The main difference between IBVS and PBVS controls consists of the reference to estimate the error norm.For instance, in IBVS control sensed images, features are extracted and compared using the image plane.In PBVS control image features are also extracted, and this information is used to compute relative position from the object to be compared with the goal relative position.PBVS error is greater than IBVS because they have different units: PBVS error is computed in length units of centimeters, but IBVS error is computed in pixels.

Control Signal Response
Figure 8 shows the control signals in terms of linear and angular speeds (see Equations ( 3) and ( 4)) once one of the IBVS, PBVS, or HBVS algorithms was run up.
The main idea is to use Equation ( 4) parameters which are the real kinematic of the robot.It can be observed that the control signals respond quickly (see inset Figures) in less than 0.05 s for IBVS, and 0.1 s for PBVS and HBVS.

Evolution of Image Frame
Figure 9 shows the image evolution of the robot camera (in pixels) in the three cases IBVS, PBVS, and HBVS.For this, a square will be shaped by using the four red points shown in this figure.This will be shown for the IBVS in the next section of the experimental results.

Initial and Final Pose in 3D
Figure 10 shows the simulation results after applying the IBVS, PBVS, and HBVS controllers, and inverse kinematic (see Equation ( 4)) to obtain the robot poses.than 0.05 s for IBVS, and 0.1 s for PBVS and HBVS.

Evolution of Image Frame
Figure 9 shows the image evolution of the robot camera (in pixels) in the three cases IBVS, PBVS, and HBVS.For this, a square will be shaped by using the four red points shown in this figure.This will be shown for the IBVS in the next section of the experimental results.

Initial and Final Pose in 3D
Figure 10 shows the simulation results after applying the IBVS, PBVS, and HBVS controllers, and inverse kinematic (see Equation ( 4)) to obtain the robot poses.

Color Image Processing
The fact of how the camera would recognize a square object filled with a specific color was researched in order to characterize the image processed.Several tests were performed with a red square over a black background as shown in Figure 11.

Color Image Processing
The fact of how the camera would recognize a square object filled with a specific color was researched in order to characterize the image processed.Several tests were performed with a red square over a black background as shown in Figure 11.This was the first image successfully processed and recognized.Following this process, red characteristics from the image sensed by the camera were searched.The next step was to invert the image and divide by 16, to get a better contrast for the image by making the algorithm run-up at low resolution.Later, it was necessary to filter to search only those who had a square shape using Algorithm 1 implemented on Python for the Raspberry Pi [33].As a result of this processing, four points related to the four corners of the square were obtained (See the Supplementary Materials section to obtain the codes for image processing and control algorithm):

Implementation of the Designed Controller
The control algorithm aims to calculate the control signals for engines, accomplishing the method of the kinematic chain (Jacobian of the robot) and imposing a decreasing behavior to image error.For these calculations, robot Jacobian images as can be seen in Equation (5) represent the optical flow equations that relate to the changes occurring in the image concerning the reference frame of the camera.The Jacobian of the robot, also known as the kinematic chain, is used to apply inverse kinematics to compute the angular speed values that will be applied to the robot engines.
The servo control algorithm (Algorithm 2) running up in Python for Raspberry Pi starts by calculating the Jacobian images (objective and sensed) using Equation (5).It is important to note that this equation describes the behavior of only one point in the image, and then this computing must be realized for all the image features extracted from the camera sensed image, similar to the four points extracted in Section 5.1.Implemented algorithms can be found in the Supplementary Materials section for image processing and control: This was the first image successfully processed and recognized.Following this process, red characteristics from the image sensed by the camera were searched.The next step was to invert the image and divide by 16, to get a better contrast for the image by making the algorithm run-up at low resolution.Later, it was necessary to filter to search only those who had a square shape using Algorithm 1 implemented on Python for the Raspberry Pi [33].As a result of this processing, four points related to the four corners of the square were obtained (See the Supplementary Materials section to obtain the codes for image processing and control algorithm):

Figure 1 .
Figure 1.Hilare-type robot of three degrees of freedom (3 DOF), using the kinematic model.

Figure 1 .
Figure 1.Hilare-type robot of three degrees of freedom (3 DOF), using the kinematic model.

.p
= v ω ω pl T the control signal, ∂s p (t) ∂r = L p (s) the interaction matrix, and ∂r(t) ∂p = J r (p), the Jacobian robot.
shows a diagram representing the control strategy proposed, based on a structure of the Hybrid Control System between the IBVS and PBVS.Machines 2022, 9, x FOR PEER REVIEW 8 of 21  () =  () ()

Figure 3 .
Figure 3. Proposal for a Hybrid Control System structure.

Figure 3 .
Figure 3. Proposal for a Hybrid Control System structure.

Figure 4 .
Figure 4. Communication system implemented in the experiment with specifications of interfaces, access points, connections, and communication protocols.

Figure 4 .
Figure 4. Communication system implemented in the experiment with specifications of interfaces, access points, connections, and communication protocols.

Figure 5 .
Figure 5. Smartphone app in (a) the automatic mode, and (b) manual mode.

Figure 5 .
Figure 5. Smartphone app in (a) the automatic mode, and (b) manual mode.

Figure 5 .
Figure 5. Smartphone app in (a) the automatic mode, and (b) manual mode.

Figure 6 .
Figure 6.Implemented Robotic system using the Raspberry Pi and Kit™ LEGO Mindstorms robotic.

Figure 6 .
Figure 6.Implemented Robotic system using the Raspberry Pi and Kit™ LEGO Mindstorms robotic.

Figure 7 .
Figure 7. (a) Simulation of the image error evolution applied to IBVS Control (minimum error at 1.3 s) (b) Simulation of the position error evolution applied to PBVS Control (minimum error at 5 s).(c) Simulation of the error evolution applied to HBVS Control (minimum error at 2.1 s).(d) Results of the superposition of IBVS and PBVS image errors resulting in HBVS Control.

Figure 8 Figure 7 .
Figure 8 shows the control signals in terms of linear and angular speeds (see Equations (3) and (4)) once one of the IBVS, PBVS, or HBVS algorithms was run up.

Figure 8 Figure 8 .
Figure 8 shows the control signals in terms of linear and angular speeds (see Equations (3) and (4)) once one of the IBVS, PBVS, or HBVS algorithms was run up.

Figure 8 .
Figure 8. Simulation of the control signals: linear and angular speeds applying the (a) IBVS, (b) PBVS, and (c) HBVS control algorithms.The main idea is to use Equation (4) parameters which are the real kinematic of the robot.It can be observed that the control signals respond quickly (see inset Figures) in less than 0.05 s for IBVS, and 0.1 s for PBVS and HBVS.

Figure 8 .
Figure 8. Simulation of the control signals: linear and angular speeds applying the (a) IBVS, (b) PBVS, and (c) HBVS control algorithms.

Figure 9 .
Figure 9. (a) Simulation of the extracted features evolution based on image frame based on IBVS, (b) PBVS, (c) HBVS.

Figure 9 .
Figure 9. (a) Simulation of the extracted features evolution based on image frame based on IBVS, (b) PBVS, (c) HBVS.

Figure 11 .
Figure 11.The robot's objective is implemented as a red square.

Algorithm 1 :
Feature extractionInput: Image collected by the camera.Output: set of 4 points coordinates in the image frame, s_i(t). 1 Get the image collected by the camera.2 Segment the red color.3 Compare shape (Must be square-like shape).4 Identify corners.5 Set coordinates of the points as s_i(t).

Figure 11 .
Figure 11.The robot's objective is implemented as a red square.
and V p e p > 0 f or e p = 0. ≤ 0 f or t 2k < t < t 2k+1 , f or k = 0, 1, ...•Condition 4. Vi(e i (t k )) ≤ V i (e i (t m )) f or all t k , t m t i s.t.t m < t k .≤0 f or t 2k−1 < t < t 2k , f or k = 1,2, . . .• Condition 6. V p e p (t k ) ≤ V p e p (t m ) f or all t k , t m t p s.t.t m < t k .
.V i (e i (t)).V p e p (t)