Implementation of a Camera Sensor Pixy 2 CMUcam5 to A Two Wheeled Robot to Follow Colored Object

— This article discusses the design of a colored object follower robot. The colored object used has a simple shape. For the detection process, a wheeled robot that uses sensors based on digital images of Pixy 2. Pixy2 can learn to detect objects that you teach it, just by pressing a button. Additionally, Pixy2 has new algorithms that detect and track lines for use with line-following robots. Pixy2 camera is able to recognize and track all objects whose color has been memorized. In maneuvering, this robot has 2 wheels on the right and left. Movement control is carried out by the Arduino Uno microcontroller board. This robot moves according to the direction of movement of the object. The conclusion obtained in this research is that this wheeled robot can be examined from the left, front and right side objects properly, then it follows the direction of the detected object.


I. INTRODUCTION
An automatic robot technology is common to help human work in this 4.0 industrial revolution. A wheeled robot is a type of robot that is relatively easy to implement. This type of robot only needs wheels and a motor to maneuver its movements.
The use of robots is also very widespread in industrial machinery and can provide human needs on a large scale. It depends on the function of a robot. Scientists, academics, and industry players have spent a lot of money on the development of this robotic technology. The use of robot technology in various fields has been used by humanity [1] - [3]. With more advanced technology, it will be more affordable and robust [4] - [6].
Several studies have been carried out in the design of this wheeled robot, such as the line follower wheeled robot by Latif et al [7]. A research robot used for irrigation has also been carried out by Hassan et al [8]. Research on the implementation of an ultrasonic sensor implanted in a fire suppression robot has been carried out by Ipin et al [9]. Several researches on wheeled robots used to help agriculture have also been conducted [10] - [12]. The following robots are used for disinfectant spraying purposes in the hospital by Kendrick et al [13].
In this research, the robot is controlled by an Arduino Uno microcontroller board [14], [15]. The use of this controller component is considered from the simplicity of the system functions. As we know that this Arduino board has a core Atmega8 microcontroller IC which is very relevant for use in simple and real-time automation systems [16] - [25].
The Pixy Cmucam5 sensor as an object detector has image processing capabilities. Pixy CMUcam5 sensor is used as the vision-based sensor to detect a specific pattern on the target object [28], [29]. This sensor is placed in front of the robot with a wide viewing range. This sensor generates object size data and 2-dimensional object position to be forwarded to the Arduino board via serial communication [30] and [31]. Arduino's robot movement setup takes into account the actual data from this Pixy sensor.

A. System block diagram
Pixy sensor is used to detect the size and coordinates of objects in a 2-dimensional view. The results of the detection are sent to the Arduino Uno microcontroller board for processing. The process of reading the position of the object is used to determine the position of the object against the robot's body. The position of the object in this 2-dimensional view will determine the direction of movement of the robot which is carried out by 2 both right and left motors. Speed control and activation of the two motors are carried out by an LM298 motor driver which is governed by a microcontroller. This movement of forward, backward, right, left, and stationary adjusts the position of the object, so that the robot can follow the position of objects in space.

B. Object detection
The mechanism of object detection is using camera and need for some configurations and settings. The camera needs some image environments to be captured by focusing and registering methods that the capturing image needs brightness and then the image of an object turns it into a video signal [32]. The video signal is then digitized and stored in the microcontroller's memory. The data of the captured image Sigit Dani Perkasa, Implementation of a Camera Sensor Pixy 2 CMUcam5 to A Two Wheeled Robot to Follow Colored Object must be computed every time and every frame to be manipulated.
The Pixy CMUCAM5 test method is using color filtering here it is known that this method will separate the colors that have been selected into the colors to be followed and the coordinates of the object will be detected based on their edges. Testing is done by introducing the object's color first to Pixy CMUCAM5 then seeing where the coordinates of the object are. After knowing the coordinates of the object, the angle of degree will be looked for in order to know the range of vision of the camera, for that, use the trigonometric formula to find out the degree of vision from the camera.

C. Sensor Pixy CmuCam 5
Pixy (CMUcam5) is a partnership between the Carnegie Mellon Robotics Institute and Charmed Labs. Pixy addresses these problems by pairing a powerful dedicated processor with the image sensor. Pixy processes images from the image sensor and only sends the useful information to microcontroller. And it does this at frame rate of 60 Hz.
The dual core NXP LPC4330 processor embedded in the Pixy CMUCam5 camera is the place for image processing, so that when put together in one system, the microcontroller will not be burdened with the data reading process. The Pixy CMUCam5 camera is capable of integrated image processing and can track certain colors at the same time. The object used is colored paper with a round shape [33]. PixyMon application can be used to recognize objects that have been tagged through this application. This camera has a horizontal viewing angle of 750. By determining the object's coordinates to the camera's viewing distance, it will be the basis for programming the Arduino microcontroller to adjust the motion of 4 motors. Arduino will receive image processing results from the CMUCam5 pixy camera.
Pixy can easily connect to lots of different controllers because it supports several interface options (UART serial, SPI, I2C, USB, or digital/analog output), but Pixy began its life talking to Arduino.
The working of this sensor is when object detection done in each frame are sorted by object size. The first data which sent to serial communication is the largest size of detected object. The maximum number of object sent per image frame can be set manually. The method of its new frame data image communication protocol is signed by two words which synchronized to 0xaa55 that the first byte send is 0x55 then second byte is 0xaa. Data communication which will be sent is the serial stream of waiting for two synchronous words and then parsing next object block [34].

D. Arduino Uno
Arduino Uno is a microcontroller development kit based on the ATmega28. This board is one of the boards of the Arduino family. There are several kinds of Arduino bard such as Arduino Nano, Arduino Pro Mini, Arduino Mega, Arduino Yun, and others. But the most popular is the Arduino Uno. Arduino Uno R3 is the last and latest in the Arduino USB series.
This module is equipped with various things needed to support the microcontroller to work, just plug it into the power supply or connect it via a USB cable to a PC, Arduino Uno is ready to work.
The Arduino Uno board has 14 digital input / output pins, 6 analog inputs, a 16MHz ceramic resonator, a USB connection, a power input plug, an ICSP header, and a reset button.

E. Motor driver LM298
L298 is a type of motor driver IC that can control the direction of rotation and speed of a DC motor or stepper motor. Able to output voltage for DC motors and stepper motors of 50 volts. IC L298 consists of logical transistors (TTL) with a NAND gate which makes it easy to determine the direction of rotation of a dc motor and a stepper motor. Can control 2 DC motors but can only control 1 stepper motor. Its use is most often for line follower robots. Its small shape allows it to minimize the manufacture of any wheeled robot.

III. IMPLEMENTATION
The implementation of this colored object follower wheeled robot consists of mechanical, electrical and firmware design. This stage is done by measuring the real parameters of the wheeled robot used. In this study, the value for each wheel on the robot is fixed, because it is a robot which is used does not have a steering wheel.

A. Mechanical body and drives
The body of this robot uses lightweight 5 mm acrylic. The robot's body is circular with 2 acrylic layers on the top and bottom to support the electrical components. Figure 2 shows the visualization of the robot body consisting of 2 layers of acrylic. Lower layer to support the battery and 2 DC motors for the right and left. Sigit Dani Perkasa, Implementation of a Camera Sensor Pixy 2 CMUcam5 to A Two Wheeled Robot to Follow Colored Object

B. Electrical design
The main circuit of the robotic system is the same as the block diagram in Figure 1. All these components are supplied by a 3 cell LiPo 800Ah battery. The DC electrical load is separated into 2, namely for the motor driver and for the microcontroller board along with the Pixy sensor. With this battery capacity, the robot can operate for approximately 20 minutes.

C. Differential Drive Kinematics
In wheeled robots, kinematics equations (forward kinematics) define several parts of the robot's movement, including ẋ, ẏ, and θ. The resultant between ẋ, ẏ is v (t). Vector. The variable v represents linear velocity, and represents the angular velocity of the robot. The equation for the robot posture is expressed in the form shown in equation (1).
The position of (robot center) at global coordinates (G) is expressed in coordinates (x, y) and the difference in angle between global coordinates and robot coordinates (R) is denoted as θ. Meanwhile, the speed of the wheeled robot at global coordinates can be expressed in terms of as in equation (2).
The variables ẋ and ẏ which are the speed of the robot on the global x-axis (XG) and global y (YG), and ̇ which is the angular velocity of the robot. To describe the movement of the robot in terms of the movement of the components along the movement global coordinate reference frame ( , ) to move along the reference frame the robot's local coordinates ( , ) need to be mapped. This mapping is done using a matrix orthogonal rotation (R(θ) as in equation (3).
To get the speed of the robot at the local coordinates of the robot (ξR) of the robot's speed on global coordinates ( "), equation (4) is used.
Siegwart and Nourbakhsh define two assumptions on a robot wheel used to derive kinematics equations and inverse kinematics. For kind of fixed standard wheel, these two assumptions are stated in equation (5) and equation (6). The variable is the position (angle) of the wheel axis to the axis of the robot, is the position (angle) of the steering wheel to the wheel axis, is the distance between the center (origin) of the robot and the center (origin) of the wheel, is the radius of the wheel, and ̇ is the angular velocity of the wheel.
Where ( ) −1 is the inverse of the rotation matrix, ̇ $ is the translation speed of the right wheel, and ̇1is the translation speed of the left wheel. Equation 7 is used to get the robot speed at global coordinates by knowing the wheel speed. Conversely, the speed of each wheel from robot speed at global coordinates can be obtained using inverse equations kinematics. Therefore, this study contributes to deriving the inverse equation kinematics for wheeled differential drive robots that play an important role in control the wheeled robot.

D. Inverse Kinematics Based Control Development
Based on equation (9) and the kinematics formula for a wheeled differential drive robot in equation (9), the inverse kinematics equation for a wheeled robot can be derived as in equation (10).
After that, the rotational speed is converted back into a PWM signal using the equation a straight line with respect to the motor speed used in Fig. 3. To obtain the pulse value at the appropriate speed, a line equation is used straight that is derived from two points ( 1 , 1 ) dan ( 2 , 2 ) in equation (12).
From Fig. 3, it can be obtained that ( 1 , 1 ) = (40, 21) and ( 2 , 2 ) = (190, 348). Then subtitute to equation (13 (13) where is the PWM pulse parameter in μs, and is the rotational speed of the inner motor RPM. Then from equation (13) we can derive equations (14) and (15) (15) where 1 is the control signal for the right wheel that rotate clockwise and 2 is the control signal of the left wheel rotating counter-clockwise.

E. Firmware design
The work flow system shown in Figure 3 illustrate that the system operation begins with system initialization in the form of variable declarations and Pixy operations. After that object detection is done by receiving parameter data of the object width and the x and y positions of the object. The width value represents the distance between the object and the robot. Meanwhile, the x value represents the object's position to the robot at the x coordinate. Fig. 4. Shows that if the distance is more than 90 and the x value is between 109 and 199, the robot will move forward. If any distance and the x value is less than 109, the robot will move to the left. If any distance and value of x is more than 199, then the robot will move to the right. If all the conditions above are not met, the robot will stop.
When robot turn left, means that the left wheel will stop and the right wheel will rotate, and vice versa. The rotation of the wheel depends on calculation between object's position and pulse width modulation (PWM) signal which send to the motor driver. Likewise, when the robot moves straight, the rpm of the two wheels also depends on the calculation results between the object width which represents the object's distance to the robot and the PWM signal.

A. Colored object detection
Color object detection test is carried out with the default software from the Pixy sensor, Pixymon, which is installed on Windows-based computers.
The test is carried out in the front, left, and right positions. Each position varies the distance between the object and the robot.   Figure 4 shows an object that is arranged in the middle position of the robot in various variations of the distance that cannot be detected properly. This was due to the unstable lighting at the test.  Figure 4 shows an object that is arranged in the right position of the robot in a variety of distances that can be detected properly.

B. Maneuver test
Robot maneuver testing is carried out to determine the robot's response to the position of the detected colored object. The test is carried out at the far front, near front, left, right position. Table 1 shows the i results of the maneuver test. at a distance of 5 cm in the position to the right and left of the robot to stop, it should rotate in the intended direction.

V. CONCLUSION
From this research it can be concluded that this robot is able to detect certain colored objects located in front of it. Object Follower Using Pixy CMUCAM5 Based on Arduino Uno 328P, the main processing function is on the Arduino Journal of Robotics and Control (JRC) ISSN: 2715-5072 500 Sigit Dani Perkasa, Implementation of a Camera Sensor Pixy 2 CMUcam5 to A Two Wheeled Robot to Follow Colored Object Uno 328P microcontroller while the Pixy CMUCAM5 is the slave processor and the L298 is the motor driver, due to limited resources on the camera module making reading affected by lighting and limitations in image quality affect camera reading greatly. Dependence on light and the reading distance is only 86 degrees. The robot's maneuvers are also in accordance with the target, which is to be able to follow colored objects well at a certain speed.