Disclosure of Invention
The invention aims to provide a mechanical arm control method, a robot and a computer readable storage medium, which can effectively improve the grabbing precision of the robot.
In order to solve the above technical problem, an embodiment of the present invention provides a method for controlling a robot arm, including: setting grabbing parameters according to the target position, controlling a mechanical arm to grab the target position according to the grabbing parameters, and acquiring the actual position actually grabbed by the mechanical arm; acquiring a difference value between the target position and the actual position, and acquiring a sum of the target position and the difference value as a grabbing position; establishing a corresponding relation between the grabbing position and the target position; taking the position of the object to be grabbed as the target position, and acquiring a grabbing position corresponding to the position of the object to be grabbed from the corresponding relation as the position to be grabbed; and setting grabbing parameters as parameters to be grabbed according to the positions to be grabbed, and controlling the mechanical arm to grab the object to be grabbed according to the parameters to be grabbed.
An embodiment of the present invention also provides an intelligent robot, including: the robot comprises a controller and a mechanical arm connected with the controller; the controller includes: at least one processor; and a memory communicatively coupled to the at least one processor; wherein the memory stores instructions executable by the at least one processor to enable the at least one robot to perform a robot control method as described above.
Embodiments of the present invention also provide a computer-readable storage medium storing a computer program which, when executed by a processor, implements the robot arm control method described above.
Compared with the prior art, the robot grabbing method and device based on the multi-point robot control have the advantages that the mechanical arm of the robot is controlled in advance to grab the target position, the actual grabbing position of the mechanical arm is obtained, the difference value between the actual position and the target position is obtained through calculation and is the grabbing deviation value of the robot, and the sum value of the target position and the difference value is the grabbing position actually corresponding to the target position. The method comprises the steps of establishing a corresponding relation between a target position and a grabbing position, when an object to be grabbed needs to be grabbed, using the position of the object to be grabbed as the target position, acquiring the grabbing position corresponding to the position of the object to be grabbed as the position to be grabbed through the corresponding relation, controlling the mechanical arm to grab the object to be grabbed according to the position to be grabbed, and reducing the situation that the mechanical arm caused by grabbing deviation grabs inaccurately, thereby effectively reducing the influence of the grabbing deviation value on the grabbing precision and improving the grabbing precision of the mechanical arm.
In addition, before setting the grabbing parameters according to the target position, the method further comprises the following steps: acquiring a graspable area of the mechanical arm; and sampling in the grippable region to obtain the target position.
In addition, the target position is the position of the central point of a preset image displayed on the touch screen; the acquiring of the actual position actually grabbed by the mechanical arm specifically includes: acquiring a touch position of the mechanical arm touching the touch screen, and determining the actual position according to the touch position.
In addition, the determining the actual position according to the touch position specifically includes: controlling the mechanical arm to grab the central point for multiple times to obtain multiple touch positions; and determining the actual position according to a plurality of touch positions. According to the actual position of a plurality of touching positions, the influence of test error on the precision of the actual position can be effectively reduced, and the grabbing precision of the mechanical arm is further improved.
In addition, before obtaining a plurality of touch positions, the method further includes: acquiring a preset area in the touch screen; before determining the actual position according to the plurality of touch positions, the method further includes: judging whether the touch positions are all located in the preset area; the determining the grasping position according to the plurality of touch positions specifically includes: and when the touch positions are all located in the preset area, taking the position of the central point of the preset area as the actual position. When a plurality of touch positions are located in the preset area, the position of the central point of the preset area is used as the actual position, so that the influence of the touch position with a large error on the accuracy of the actual position can be effectively reduced, and the grabbing accuracy of the mechanical arm is further improved.
In addition, before obtaining a plurality of touch positions, the method further includes: acquiring N preset areas in the touch screen, wherein N is a positive integer; before determining the grabbing position according to the plurality of touch positions, the method further includes: acquiring M preset regions with the largest number of touch positions in the regions as target preset regions, wherein M is smaller than or equal to N and is a positive integer; the determining the actual position according to the plurality of touch positions specifically includes: and determining the actual position according to the central point position of each target preset area.
In addition, the determining the actual position according to the center point position of each target preset region specifically includes: determining the weight of each target preset area according to the number of touch positions in each target preset area; and performing weighted calculation on the central point positions of the M target preset areas according to the weight values, and taking the result of the weighted calculation as the actual position. And performing weighted calculation according to the central point positions of the M target preset areas, so that the occupation ratio of the target preset areas with more touch positions in the actual position is more, and the accuracy of the actual position is further improved, thereby further improving the grabbing accuracy of the mechanical arm.
In addition, the controlling the mechanical arm to grab the target position according to the grabbing parameters specifically comprises: planning a grabbing path of the mechanical arm; and controlling the mechanical arm to grab the target position along the grabbing path.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, embodiments of the present invention will be described in detail below with reference to the accompanying drawings. However, it will be appreciated by those of ordinary skill in the art that numerous technical details are set forth in order to provide a better understanding of the present application in various embodiments of the present invention. However, the technical solution claimed in the present application can be implemented without these technical details and various changes and modifications based on the following embodiments.
The target embodiment of the invention relates to a mechanical arm control method, which comprises the following specific steps as shown in fig. 1:
step S101: and presetting a target position, controlling the mechanical arm to grab the target position, and acquiring the actual position actually grabbed by the mechanical arm.
Specifically, in this embodiment, a spatial coordinate system is first established, the robot arm is placed in a spatial rectangular coordinate system, a target position is selected from the spatial rectangular coordinate system, a grabbing parameter is set according to the target position, the robot arm is controlled to grab the target position according to the grabbing parameter, and a position actually grabbed by the robot arm is obtained as an actual position. For example, a three-dimensional rectangular coordinate system is established with the position of the robot arm as an origin, and the (X, Y, Z) position is taken as a target position.
Preferably, in this step, before the preset target position is obtained, a graspable region of the mechanical arm is also obtained, and the target position is obtained by sampling in the graspable region of the mechanical arm. The target position is obtained by sampling in the graspable area of the mechanical arm, so that the effectiveness of the target position can be effectively ensured.
Hereinafter, a specific application example of the method for acquiring an actual position in the present application will be described, and it should be understood that the following is only one specific application example in the present embodiment, and is not limited thereto.
A touch screen is arranged in a grabbing area of the mechanical arm, and a preset image is displayed in the touch screen. The mechanical arm carries out image recognition on the preset image and determines the preset image. And taking the position of the central point of the preset image as a target position, and acquiring the coordinate of the target position in the robot coordinate system through the transformation matrix. The grabbing parameters are set according to the target position, the mechanical arm is controlled to grab the target position according to the grabbing parameters, the touch screen is touched by the mechanical arm in the process of grabbing the preset image at each time, and the touch screen records and feeds back the touched position. After receiving the touch position sent by the touch screen, the robot determines the actual position actually grabbed by the mechanical arm according to the touch position. For example, the actual position is directly the touched position. It should be understood that the actual position of the touched position is only a specific implementation example in the present embodiment, and is not limited thereto.
Further, in this embodiment, the mechanical arm is controlled to capture the preset image for multiple times, multiple touch positions are obtained, and the actual position is determined according to the multiple touch positions. For example, the average value of the coordinates of a plurality of touch positions is defined as the actual position.
Furthermore, in this embodiment, a preset area in the touch screen is further obtained, after the plurality of touch positions are determined, whether the plurality of touch positions are all located in the preset area is determined, and if there is a touch position that is not located in the preset area, the plurality of touch positions are obtained again. And if the plurality of touch positions are all located in the preset area, taking the position of the central point of the preset area as the actual position.
Preferably, in this embodiment, N preset regions in the touch screen may also be obtained, where N is a positive integer; determining the number of touch positions in each preset area, and acquiring M preset areas with the largest number of touch positions in the areas as target preset areas, wherein M is smaller than or equal to N and is a positive integer. And taking the average value of the central point positions of the M target preset areas as an actual position. It can be understood that, besides taking the average of the central point positions of the M target preset regions as the actual position, the weight of each target preset region may also be determined according to the number of touch positions in each target preset region; and performing weighted calculation on the central point positions of the M target preset areas according to the weight values, and taking the result of the weighted calculation as the actual position. For example, the M value is 2, 41 touch positions and 7 touch positions are respectively located in 2 target preset regions, and the central point positions of the 2 target preset regions are (x, y, z) and (x) respectively1,y1,z1) Then the actual position is ((41x +7 x)1)/(41+7),(41y+7y1)/(41+7),(41z+7z1)/(41+7))。
Step S102: and acquiring a difference value between the target position and the actual position.
Specifically, in the present step, the absolute value of the difference between the coordinates of the actual position and the coordinates of the target position is calculated as the difference value of the actual position and the target position. For example, in the coordinate system, the coordinates of the target position are (X, Y, Z), and the coordinates of the actual position are (X)1,Y1,Z1) The difference is (X-X)1,Y-Y1,Z-Z1)。
Step S103: and taking the sum of the target position and the difference as the grabbing position.
Specifically, in this step, the sum of the coordinates and the difference of the target position is calculated as the grasping position. I.e. the grabbing position is (X + X-X)1,Y+Y-Y1,Z+Z-Z1)。
Step S104: and establishing a corresponding relation between the grabbing position and the target position.
Specifically, in this step, after the grasping position is obtained, a one-to-one correspondence relationship between the grasping position and the target position is established. For example, the target position (X, Y, Z) corresponds to a grasping position of (X + X-X)1,Y+Y-Y1,Z+Z-Z1)。
Step S105: and acquiring a grabbing position corresponding to the position of the object to be grabbed from the corresponding relation as the position to be grabbed.
Specifically, when an object to be grabbed is grabbed, after the position of the object to be grabbed is obtained, the position of the object to be grabbed is taken as a target position, and grabbing positions corresponding to the positions of the object to be grabbed in a one-to-one manner are obtained from the corresponding relation and taken as the positions to be grabbed. For example, when the position of the object to be grasped is (X, Y, Z), the grasping position obtained from the correspondence relationship is (X + X-X)1,Y+Y-Y1,Z+Z-Z1)。
Step S106: and controlling the mechanical arm to grab the object to be grabbed according to the position to be grabbed.
Specifically, in this step, after the position to be grasped is obtained, the grasping parameters are set as the parameters to be grasped according to the position to be grasped, and the mechanical arm is controlled to grasp the object to be grasped according to the parameters to be grasped.
Further, in this embodiment, after the position to be grasped is obtained, a grasping path of the mechanical arm is planned according to the position to be grasped, and the mechanical arm is controlled to grasp the target position along the grasping path.
Compared with the prior art, in the robot arm control method provided by the first embodiment of the present invention, the robot arm of the robot is controlled in advance to capture the target position, the actual captured position of the robot arm is obtained, the difference between the actual position and the target position is obtained through calculation, that is, the capture deviation value of the robot, and the sum of the target position and the difference is the capture position actually corresponding to the target position. The method comprises the steps of establishing a corresponding relation between a target position and a grabbing position, when an object to be grabbed needs to be grabbed, using the position of the object to be grabbed as the target position, acquiring the grabbing position corresponding to the position of the object to be grabbed as the position to be grabbed through the corresponding relation, controlling the mechanical arm to grab the object to be grabbed according to the position to be grabbed, and reducing the situation that the mechanical arm caused by grabbing deviation grabs inaccurately, thereby effectively reducing the influence of the grabbing deviation value on the grabbing precision and improving the grabbing precision of the mechanical arm.
A second embodiment of the present invention relates to a robot arm control method. The second embodiment is substantially the same as the first embodiment, and mainly differs therefrom in that: in the second embodiment, before the corresponding relationship between the grasping position and the target position is established, a step of verifying the grasping position is further included. The specific steps are shown in fig. 2, and include:
step S201: and presetting a target position, controlling the mechanical arm to grab the target position, and acquiring the actual position actually grabbed by the mechanical arm.
Step S202: and acquiring a difference value between the target position and the actual position.
Step S203: and taking the sum of the target position and the difference as the grabbing position.
Step S204: and verifying the grabbing position, and judging whether the grabbing position passes the verification, if so, executing the step S205, and if not, executing the step S201.
Specifically, in this step, a grabbing parameter is set according to a grabbing position to grab the target position for multiple times, a grabbing success rate of the multiple grabbing is obtained, if the success rate is higher than a preset success rate threshold, the grabbing position verification is passed, and if not, the grabbing position verification is not passed.
Step S205: and establishing a corresponding relation between the grabbing position and the target position.
Step S206: and acquiring a grabbing position corresponding to the position of the object to be grabbed from the corresponding relation as the position to be grabbed.
Step S207: and controlling the mechanical arm to grab the object to be grabbed according to the position to be grabbed.
Compared with the prior art, the mechanical arm control method provided by the second embodiment of the invention maintains all technical effects of the first embodiment, verifies the grabbing position, and establishes the corresponding relation between the grabbing position passing the verification and the target position, so that the effectiveness of the grabbing position can be ensured, and the grabbing precision of the mechanical arm is further improved.
The steps of the above methods are divided for clarity, and the implementation may be combined into one step or split some steps, and the steps are divided into multiple steps, so long as the steps contain the same logical relationship, which is within the protection scope of the present patent; it is within the scope of the patent to add insignificant modifications to the algorithms or processes or to introduce insignificant design changes to the core design without changing the algorithms or processes.
A third embodiment of the present invention relates to a robot, as shown in fig. 3, including: a controller 301 and a robot arm 302 connected to the controller 301, wherein the controller 301 comprises: at least one processor 3011; and a memory 3012 in communicative connection with the at least one processor 3011; the memory 3012 stores instructions executable by the at least one processor 3011, and the instructions are executed by the at least one processor 3011 to enable the at least one processor 3011 to execute the path planning method described above.
The memory 3012 and the processor 3011 are connected by a bus, which may include any number of interconnected buses and bridges that connect one or more of the various circuits of the processor 3011 and the memory 3012. The bus may also connect various other circuits such as peripherals, voltage regulators, power management circuits, and the like, which are well known in the art, and therefore, will not be described any further herein. A bus interface provides an interface between the bus and the transceiver. The transceiver may be one element or a plurality of elements, such as a plurality of receivers and transmitters, providing a means for communicating with various other apparatus over a transmission medium. The data processed by the processor 3011 is transmitted over a wireless medium through an antenna, which receives the data and forwards the data to the processor 3011.
The processor 3011 is responsible for managing the bus and general processing, and may also provide various functions including timing, peripheral interfaces, voltage regulation, power management, and other control functions. And the memory 3012 may be used to store data used by the processor 3011 in performing operations.
A fifth embodiment of the present invention relates to a computer-readable storage medium storing a computer program. The computer program realizes the above-described method embodiments when executed by a processor.
That is, as can be understood by those skilled in the art, all or part of the steps in the method according to the above embodiments may be implemented by a program instructing related hardware, where the program is stored in a storage medium and includes several instructions to enable a device (which may be a single chip, a chip, or the like) or a processor (processor) to execute all or part of the steps in the method according to the embodiments of the present application. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
It will be understood by those of ordinary skill in the art that the foregoing embodiments are specific examples for carrying out the invention, and that various changes in form and details may be made therein without departing from the spirit and scope of the invention in practice.