Disclosure of Invention
In view of the above, the present invention provides a multi-robot serial port to WIFI communication and cooperative motion control method, including:
Step 1: adding a virtual serial port in an upper computer, and determining a master robot and a slave robot in a plurality of robots, wherein the robots are provided with OpenCR controllers; two serial port-to-WIFI chips are installed and configured for a OpenCR controller of the master robot, and one serial port-to-WIFI chip is installed and configured for a OpenCR controller of the slave robot;
Step 2: connecting the upper computer and the host robot to the same wireless network, establishing TCP connection between the upper computer and the host robot as a server, and sending a control instruction to the host robot;
step 3: the slave robots move cooperatively with the master robots.
In step 1, a TCP server is established in the upper computer, IP and port are set, and connection is established with a virtual serial port through software; and setting the baud rate and the data bit of the virtual serial port, and sending the monitored virtual serial port data in the form of a TCP client.
Particularly, in the step 2, the upper computer sends a control command to the upper computer, wherein the control command can be output by adopting keyboard control, and the angle rotation of each steering engine is directly controlled.
In particular, step 2 further includes that the upper computer can control task coordinates of the robot through keys, and the rotation angles of the steering engines are obtained through inverse kinematics calculation to control.
In particular, step 2 also includes setting special gestures, rotation tracks or rotation speeds of some fixed points through keys; wherein the speed of the robot can be controlled by controlling the moving time between target points, and the actuating mechanism of the robot is formed by a plurality of PID links to form position feedback control.
Specifically, the host robot also sends the data of each steering engine sensor to the upper computer through the TCP client.
Specifically, in the step 3, the master robot establishes a TCP server, the slave robots each establish a TCP client to respectively establish a connection with the master robot, and the transmitted data is converted by OpenCR driving program, WIFI transmission and serial-to-WIFI chip conversion and finally transmitted to OpenCR controllers of the slave robots; and the slave robot sends a control instruction to each joint steering engine by a OpenCR controller according to the obtained data.
The beneficial effects are that:
1) According to the invention, communication from serial port to WIFI is directly realized on the OpenCR controller, the inconvenience that a plurality of serial ports are required to be connected with a plurality of upper computers in a plurality of robot scenes can be solved through the WIFI protocol, and the resource consumption and the space occupation are saved;
2) According to the invention, the host robot and the slave robot are connected by adopting the TCP protocol between the host computer and the host robot, so that the stability of connection and the accuracy of data transmission are ensured;
3) The upper computer can directly control the state of the host robot in various modes such as steering engine angles, task coordinates, special postures, rotation tracks or rotation speeds of the host robot, and the like, so that the high-speed robot has higher flexibility;
4) The host robot also transmits the data of each steering engine sensor to the upper computer through the TCP client, so that a closed loop of the control system is formed, and the control system can be used for verifying whether a control command is effective.
Detailed Description
The invention will now be described in detail by way of example with reference to the accompanying drawings.
The invention provides a method for converting serial ports of multiple robots into WIFI communication and cooperative motion control, wherein the process is shown in fig. 1, the actual scene is shown in fig. 2, and the method specifically comprises the following steps:
Step 1: adding a virtual serial port in an upper computer, and determining a master robot and a slave robot in a plurality of robots, wherein the robots are provided with OpenCR controllers; two serial-to-WIFI chips are installed and configured for a OpenCR controller of the master robot, and one serial-to-WIFI chip is installed and configured for a OpenCR controller of the slave robot.
The invention takes the Ubuntu system as an upper computer and installs the Ubuntu system on Vmware Workstation virtual machines. And installing virtual serial port application software on the Windows system, adding a virtual serial port for the system, adding and using the virtual serial port on the host system on the virtual machine, setting a network as a bridging network, and monitoring the data of the virtual serial port.
Each robot comprises five steering engines, steering engine wires are connected to steering engine interfaces of OpenCR controllers, two serial port-to-WIFI chips are installed on a UART/USART port of a OpenCR controller of a host robot, one of the chips is connected with an upper computer as a TCP client, the other chip is connected with a slave computer as a TCP server, a OpenCR controller of the slave robot is provided with a serial port-to-WIFI chip on the UART/USART port of the slave robot, the chip is connected with the host robot as a TCP client, and bidirectional transparent transmission of serial port data and WIFI data is automatically achieved.
Step 2: and connecting the upper computer and the host robot to the same wireless network, establishing TCP connection between the upper computer serving as a server and the host robot, and sending a control instruction to the host robot.
And establishing a TCP server for the host computer system of the upper computer, setting IP, ports and the like, and establishing connection with the virtual serial port through software. Setting parameters such as the baud rate of the virtual serial port, data bits and the like, and sending the monitored virtual serial port data in the form of a TCP client, wherein the sending mode is a transparent transmission mode, namely, the serial port data is not processed. Meanwhile, the return information received by the client is also sent to the virtual serial port, so that bidirectional data conversion and transmission of the virtual serial port and the WIFI are realized.
The upper computer and the chip of the host robot are connected to the same WIFI network, and the host robot chip is used as a TCP client to be connected with a TCP server of the upper computer.
The upper computer outputs control commands by adopting keyboard control, wherein a part of keys directly control the angle rotation of each steering engine to comprise opening and closing of a robot gripper, a part of keys control xyz task coordinates of the robot, the rotation angles of the steering engines are obtained by inverse kinematics calculation to control, special gestures of certain fixed points can be set by one key, the rotation track is used as a solution when the maximum value of the rotation angles in all joints is minimum, and the rotation speed can be set before the steering engines rotate. The steering engine is controlled by position control, and the steering engine is internally composed of a plurality of PID links.
Opening a virtual serial port, outputting a control instruction to the virtual serial port in a serial port data form, after the virtual serial port data is monitored, transmitting the data by the virtual serial port application software through the TCP connection between an upper computer and a host robot chip, converting the data after being transmitted to the chip and outputting the data to a UART/USART serial port, burning a conversion program from the serial port to a steering engine interface in advance in a OpenCR controller, and finally transmitting the data to a steering engine for control.
Meanwhile, the angle position and rotation speed information acquired by the steering engine sensor are transmitted in an inverted sequence, namely, the information is firstly subjected to OpenCR controller conversion program and then is transmitted to the serial port to WIFI chip, and finally, the information is fed back to the upper computer through TCP connection and monitoring of the virtual serial port, so that closed-loop control is realized.
Step 3: the slave robots move cooperatively with the master robots.
All robots are connected under the same WIFI, the host robot establishes a TCP server, and the slave robots respectively establish TCP clients and respectively establish connection with the host.
The host robot sends the data of each steering engine sensor to the upper computer through the TCP client, and also sends the data to all the slave robots through the TCP server, and the data is finally transmitted to OpenCR controllers of all the slave robots through OpenCR program conversion, WIFI transmission and chip conversion.
The control program is burnt in advance by the OpenCR controller of the slave machine, specifically, the same steering engine position control instruction is directly sent to the steering engine of the slave machine robot according to the obtained information of the master machine robot, so that the steering engine angle is the same as that of the master machine robot, and meanwhile, the steering engine angle is directly fed back to the OpenCR controller by the sensor of the slave machine robot, so that closed-loop control is realized.
In summary, the above embodiments are only preferred embodiments of the present invention, and are not intended to limit the scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
It will be evident to those skilled in the art that the embodiments of the invention are not limited to the details of the foregoing illustrative embodiments, and that the embodiments of the present invention may be embodied in other specific forms without departing from the spirit or essential characteristics thereof. The present embodiments are, therefore, to be considered in all respects as illustrative and not restrictive, the scope of embodiments being indicated by the appended claims rather than by the foregoing description, and all changes which come within the meaning and range of equivalency of the claims are therefore intended to be embraced therein. Any reference sign in a claim should not be construed as limiting the claim concerned. Furthermore, it is evident that the word "comprising" does not exclude other elements or steps, and that the singular does not exclude a plurality. A plurality of units, modules or means recited in a system, means or terminal claim may also be implemented by means of software or hardware by means of one and the same unit, module or means. The terms first, second, etc. are used to denote a name, but not any particular order.
Finally, it should be noted that the above-mentioned embodiments are merely for illustrating the technical solution of the embodiment of the present invention, and not for limiting, and although the embodiment of the present invention has been described in detail with reference to the above-mentioned preferred embodiments, it should be understood by those skilled in the art that modifications and equivalent substitutions can be made to the technical solution of the embodiment of the present invention without departing from the spirit and scope of the technical solution of the embodiment of the present invention.