Robot arm color recognition | picked up a robot arm on the road, give it some color to see?

Time:2020-9-15

Robot arm color recognition | picked up a robot arm on the road, give it some color to see?

Hello everyone, I am the one who often finds treasure on the roadIron bearTeacher, what interesting things did you find today? A five degree of freedom manipulator, from the sky appeared in front of me!

I don’t believe it myself. I’m not so lucky! In fact, this is a friend sent me to play, do you also want this robot arm? what! You don’t want a mechanical arm. You want that friend? That’s impossible.

Robot arm color recognition | picked up a robot arm on the road, give it some color to see?

Since the white whore such a high-end robot arm, always want to play something to be worthy of it! Then give it some color to see see, let it in the future obediently listen to me. Let’s design one todayColor block sorting manipulatorCase bar: through the color sensor, add color recognition ability to the manipulator, so that it can recognize the colors of different color blocks, and then put the same color blocks together.

Robot arm color recognition | picked up a robot arm on the road, give it some color to see?

Before we start the full tutorial, let’s take a look at the demo video:

https://www.bilibili.com/vide…

Introduction to manipulator

First of all, let’s know about this manipulator: it is a five degree of freedom manipulator, using Arduino uno as the main control board, and all joints are controlled by serial bus steering gear. That is to say, as long as one signal line is used, five steering gears on the manipulator can be controlled at the same time. In addition, it can also use mixly graphical programming. Due to the adoption of Arduino master controller and DIY structure, it has strong openness and expansibility. It can not only seamlessly integrate various sensors commonly used in Arduino, but also modify the structure and apply it in various projects.

Robot arm color recognition | picked up a robot arm on the road, give it some color to see?

In order to match its unique serial bus steering gear control, it also has a special Arduino expansion boardArdurobo1

Robot arm color recognition | picked up a robot arm on the road, give it some color to see?

Ardurobo1 mainly has the following functional characteristics:

  • It is directly compatible with Arduino uno plug-in without other connections;
  • Integrated with 6-channel distributed serial bus channels, ch1-ch6, each channel can be connected with up to 6 servos in series, so it can control up to 36 rudders at the same time;
  • The pre edited action group can be called directly;
  • Integrated I2C interface, digital interface, analog interface, compatible with a variety of commonly used sensors;
  • Power management is optimized for Arduino to meet the power requirements of multiple steering gears working at the same time;
  • The reverse connection protection of power supply is provided to prevent wrong wiring of power supply.

The ardurobo1 expansion board can be directly inserted into Arduino uno according to the corresponding pin relationship, as shown in the following figure:

Robot arm color recognition | picked up a robot arm on the road, give it some color to see?

Introduction of color sensor

As this project involves the sorting of color blocks, that is, color recognition should be carried out first, so we use color sensors here. Of course, there is no problem with other sensors that can identify colors, such as image recognition sensors. Here we will first introduce the color sensor and its use.

There are many types of color sensors, such as TCS230, tcs34725 and so on. Their use methods are basically similar. The color sensor model used in this project is tcs34725.

Tcs34725 is a low-cost, cost-effective RGB full-color color sensor. The sensor can recognize the surface color of objects through optical induction. Support recognition of red, green, blue (R, G, b) three primary colors, can output the corresponding specific value, help you restore the color authenticity.

Robot arm color recognition | picked up a robot arm on the road, give it some color to see?

In order to improve the accuracy and prevent the interference from the surrounding environment, an infrared light shield is usually added at the bottom of the sensor to minimize the infrared spectrum component of the incident light and make the color management more accurate. On board with high brightness LED, so that the sensor in low ambient light can still work normally, to achieve the “fill light” function. The module adopts I2C communication, which can be easily connected to the main control board.

Robot arm color recognition | picked up a robot arm on the road, give it some color to see?

Next, let’s learn how to program a color sensor to recognize colors in mixly.

Color sensor circuit connection

We connect the color recognition sensor to the I2C pin of Arduino uno (or ardurobo1 expansion board), as shown in the following figure:

Robot arm color recognition | picked up a robot arm on the road, give it some color to see?

Read RGB color values

There’s a special one in mixlyTcs34725 color sensorProgramming module, which is located insensorIn classification, its function is to return the values of R (red), G (green) and B (blue) of the color to be identified, and then we can distinguish (classify) the color by R, G and b values.

Robot arm color recognition | picked up a robot arm on the road, give it some color to see?

Let’s write a program to obtain the RGB values of different color squares, and print the RGB values in the serial port. The program is as follows:

Robot arm color recognition | picked up a robot arm on the road, give it some color to see?

Upload the program, open the serial port monitor, observe the square with different colors, and return the results in the serial port monitor:

Robot arm color recognition | picked up a robot arm on the road, give it some color to see?

Note: ambient light, surface smoothness of object, sensor and object to be measured will affect the recognition result of color sensor. In actual use, if the environment to be measured changes, please re measure the value, and try to keep the same distance between the color recognition sensor and the surface to be measured.

Color block color resolution

From the above results, we can find that:

  • testinggulesIn square, R value is relatively large (r > 60), G, b value is relatively small (g < 10, B < 10);
  • testinggreenIn square, g value is relatively large (G > 30), R and b values are relatively small (r < 10, B < 10);
  • testingblueIn square, b value is relatively large (b > 40), R, g value is relatively small (r < 10, B < 20);
  • testingyellowIn square, R and g values are relatively large (r > 20, G > 20), and b values are relatively small (b < 10).

According to this result, we carry out the following reasoning and classification. In the scene of detecting 4-color squares, we can determine:

  • When r > 60, the detected square is red;
  • When G > 30, the detected square is green;
  • When b > 40, the detected square is blue;
  • When r > 20 and G > 20, the detected square is yellow.

Note: when setting the RGB color boundary range, we should carefully observe the numerical range of each color, so that the set RGB boundary value can maintain the uniqueness of each color block, which can greatly simplify the program. If it is close to the RGB value, it is necessary to compare the two color values. Therefore, in the experiment of color recognition, we should choose the color with obvious difference as far as possible.

According to the above reasoning, a program is written to determine the color of the block according to the detected RGB value

Robot arm color recognition | picked up a robot arm on the road, give it some color to see?

Upload the program, and then check each block separately, and check whether the returned result is consistent with the actual block color in the serial port monitor.

Robot arm color recognition | picked up a robot arm on the road, give it some color to see?

Color block sorting manipulator

With the use of color sensor basis, it is not difficult to design the color block sorting robot arm project.

Mechanical arm circuit connection

We use special anti reverse wiring, connect color sensor to I2C pin, dot matrix screen to I2C pin, and connect steering gear on manipulator to CH2 channel in series (or other 5 channels are OK), as shown in the figure below. The dot matrix screen module is added here to display the color name (abbreviation) recognized.

Robot arm color recognition | picked up a robot arm on the road, give it some color to see?

Scene Building

Then, according to the video demonstration effect, we will build a simple scene. First, find a white foam, open a hole in the middle of the front, dig a slot on the back, install the color into the card slot, and identify the chip of the color sensor and the LED light up, as shown in the following figure:

Robot arm color recognition | picked up a robot arm on the road, give it some color to see?

Then find 4 boxes and mark them with red, green, blue and yellow, representing the sorting boxes with different color blocks.

Robot arm color recognition | picked up a robot arm on the road, give it some color to see?

Then place the manipulator, color sensor and sorting box as shown in the figure below.

Robot arm color recognition | picked up a robot arm on the road, give it some color to see?

At this point, the simple scene of the color block sorting manipulator is completed, and the manipulator action design and programming are started.

Action design of manipulator

At the beginning, I thought that the design of the grab action of the manipulator was very troublesome. It would take a long time for one steering gear to adjust the angle. It must take a long time to complete so many grasping actions. And the path between different movements and motion planning, that is even more difficult! And my friend told me,It has a special motion editor software, as long as the hand to give it concave shape, break off the joint, and then use the software to record it。 There’s such a simple way, don’t try it!

Here, the use of the motion editor software will not be detailed. Anyway, it is very simple. If there are many teachers who use this manipulator, I would like to write an action editor tutorial.

Robot arm color recognition | picked up a robot arm on the road, give it some color to see?

Firstly, the manipulator is connected with special motion editor software through serial port connection, and then a series of actions of manipulator are designed by concave modeling. Note that each action here actually represents a shape of the manipulator, which allows the manipulator to move from any position to the specified shape position,The actions here are similar to the different statements executed during programming。 andWhen the position or action is switched between different shapes, the manipulator will automatically generate a smooth path planning, which does not need us to calculate the angle。 One word, simple! How delicious!

The different actions of color block sorting are designed as follows. Each action can make the manipulator reach a designated position and maintain the status. Because of the use of manual concave modeling for action design, so the action here is not unique, everyone can design different action positions according to their own needs. Of course, you can adjust the angle of each steering gear accurately after manual concave modeling to make the action more accurate.

Robot arm color recognition | picked up a robot arm on the road, give it some color to see?

Then, some tasks or actions can be combined to form an action group (called “macro” in the software). These combined actions can be used to complete some specific tasks and facilitate other actions or tasks to be called,The action group here is similar to the function in programming

The different action groups of color block sorting tasks are as follows:

Robot arm color recognition | picked up a robot arm on the road, give it some color to see?

After setting the action group, you need to generate the definition of the action groupGenerate macro definitionIn fact, it is to generate a number for each action group, which is convenient to call when programming in mixly or other ways

Robot arm color recognition | picked up a robot arm on the road, give it some color to see?

You can click Copy to temporarily copy these macro definitions to a text file

//Grab the box
#define MACRO01 1337761498
//Sorting red squares
#define MACRO02 1331656684
//Sorting green squares
#define MACRO03 420974790
//Sorting blue squares
#define MACRO04 390176801
//Sorting yellow squares
#define MACRO05 711367415

After designing the action of the manipulator, you can program in mixly.

Mixly programming

First, let’s take a look at the mixly graphics modules corresponding to this manipulator, as shown in the figure below. In fact, the function of these modules is to realize various control modes of the steering gear.

Robot arm color recognition | picked up a robot arm on the road, give it some color to see?

However, the mixly program of our color block sorting project is relatively simple, just need toColor block color resolutionThe program can be modified slightly

  • In the initialization module, dot matrix screen initialization and ardurobo1 control board (dbsp control board) initialization are added;
  • Dot matrix screen is used to display recognized color abbreviations, such as red display R (red), green G (green), etc;
  • The color printing function of serial port is changed to display and execute sorting action group (Executive macro) of corresponding color on dot matrix screen.

In particular, hereExecute macro numberModule, its function is to call different action groups of the manipulator, so that the manipulator can complete specific tasks. As like as two peas, we can compare the macro numbers used in the program with the macro number defined above. For example, the number of sorting red squares in the program (with notes in the program) is 1331656684; when designing actions, the macro definition number of sorting red squares generated is 1331656684, which is exactly the same!

YesExecute macro numberThis program module, in mixly programming, you just need to call the action or action group of the manipulator. It is as simple and convenient as calling functions.

Robot arm color recognition | picked up a robot arm on the road, give it some color to see?

After writing mixly program, upload to Arduino development board, you can see the effect in the video at the beginning of the article.

summary

That’s the end of today’s tutorial. In this article, we learned the principle of color recognition sensor, wiring method and programming method, and also learned how to use color sensor to distinguish different colors. Finally, combined with the dot matrix screen module, a color block sorting robot arm project is designed. Since this manipulator integrates motion editor software and mixly graphic programming, it is very simple to use. It is very suitable for teachers and students who are tired of playing with various smart cars to enter other robot projects. I will use this manipulator in more projects later. Let’s look forward to it~

Welcome to our attention

Finally, welcome to the code of public attention: the official account of the iron bear, and update the related contents of making customer production, technology course and creating customer education.

Robot arm color recognition | picked up a robot arm on the road, give it some color to see?