A method for controlling a modular robot, wherein the method comprises the following steps: T1: providing a plurality of module units; T2: assembling the plurality of module units into an initial entity structure, which is a specific structure of the modular robot; T3: acquiring initial virtual configuration information of the initial entity structure; T4: generating an initial virtual configuration based on the initial virtual configuration information; T5: setting an action frame to generate preset action control information; and T6: transmitting the preset action control information to the modular robot which executes a motion according to the preset action control information; wherein each of the module units comprises two sub-modules that are rotatable relative to each other; wherein the plurality of module units comprises a plurality of identical or different module units, each of the sub-modules comprises at least one docking part and each of the docking parts has unique interface identification information; wherein the plurality of module units comprises a cell body and at least one single cell body; the cell body is one of the plurality of module units capable of communicating with a remote terminal, and the single cell body directly connected to the cell body is defined as a first-level single cell body; wherein acquiring the initial virtual configuration information of the initial entity structure comprises the following steps: T31: transmitting a signal by the cell body to the first-level single cell body connected thereto via the docking part; and T32: receiving the signal and then performing face recognition by the first-level single cell body to obtain the interface identification information of the docking part where the cell body transmits the signal, and transmitting the interface identification information of the docking part where the cell body transmits the signal together with the interface identification information of the docking part where the first-level single cell body per se receives the signal to the cell body by the first-level single cell body, so as to obtain the location information of the first-level single cell body. T1: providing a plurality of module units; T2: assembling the plurality of module units into an initial entity structure, which is a specific structure of the modular robot; T3: acquiring initial virtual configuration information of the initial entity structure; T4: generating an initial virtual configuration based on the initial virtual configuration information; T5: setting an action frame to generate preset action control information; and T6: transmitting the preset action control information to the modular robot which executes a motion according to the preset action control information; wherein each of the module units comprises two sub-modules that are rotatable relative to each other; wherein the plurality of module units comprises a plurality of identical or different module units, each of the sub-modules comprises at least one docking part and each of the docking parts has unique interface identification information; wherein the plurality of module units comprises a cell body and at least one single cell body; the cell body is one of the plurality of module units capable of communicating with a remote terminal, and the single cell body directly connected to the cell body is defined as a first-level single cell body; wherein acquiring the initial virtual configuration information of the initial entity structure comprises the following steps: T31: transmitting a signal by the cell body to the first-level single cell body connected thereto via the docking part; and T32: receiving the signal and then performing face recognition by the first-level single cell body to obtain the interface identification information of the docking part where the cell body transmits the signal, and transmitting the interface identification information of the docking part where the cell body transmits the signal together with the interface identification information of the docking part where the first-level single cell body per se receives the signal to the cell body by the first-level single cell body, so as to obtain the location information of the first-level single cell body. T31: transmitting a signal by the cell body to the first-level single cell body connected thereto via the docking part; and T32: receiving the signal and then performing face recognition by the first-level single cell body to obtain the interface identification information of the docking part where the cell body transmits the signal, and transmitting the interface identification information of the docking part where the cell body transmits the signal together with the interface identification information of the docking part where the first-level single cell body per se receives the signal to the cell body by the first-level single cell body, so as to obtain the location information of the first-level single cell body.