Method and apparatus for controlling an electronic device, device and readable storage medium
The present disclosure discloses a method and apparatus for controlling an electronic device, a device and a readable storage medium, and relates to the field of control technology. The electronic device comprises: a base, a rotating body, a first sensor, and a second sensor, wherein the rotating body is rotatably connected to the base, and a physical zero-initialization point is provided on the rotating body or the base; the first sensor is used to detect a rotation angle of the rotating body on a rotation plane; the second sensor is used to detect the physical zero-initialization point, and the physical zero-initialization point is such a position that after the rotation angle of the rotating body detected by the first sensor is zeroed on the rotation plane, the rotation angle of the rotating body on the rotation plane is re-detected by the first sensor.
1 . A method for controlling an electronic device, the electronic device comprising: a base, a rotation body, a first sensor, and a second sensor, wherein
the rotation body is rotatably connected to the base, and a physical zero-initialization point is provided on the rotation body or the base;
the first sensor is used to detect a rotation angle of the rotation body on a rotation plane; and
the second sensor is used to detect the physical zero-initialization point, and when the physical zero-initialization point is detected by the second sensor, after the rotation angle of the rotation body on the rotation plane detected by the first sensor is set to zero, the rotation angle of the rotation body on the rotation plane is re-detected by the first sensor, wherein
a first surface of the rotation body includes at least two first regions connected end to end, and the two first regions are arranged along a rotating direction of the rotation body, and the physical zero-initialization point is located on a boundary line between two adjacent first regions;
the second sensor is provided on the base and used to emit wave signals toward the first surface of the rotation body;
wherein the wave signals emitted by the second sensor are irradiated on different first regions of the first surface of the rotation body, and reflected wave signals received by the second sensor are different, or
a first surface of the base includes at least two second regions connected end to end, and the two second regions are arranged along a rotation direction of the rotation body, and the physical zero-initialization point is located on a boundary line between two adjacent second regions is;
the second sensor is provided on the rotation body and used to emit wave signals toward the first surface of the base;
wherein the wave signals emitted by the second sensor are irradiated on different second regions of the first surface of the base, and reflected wave signals received by the second sensor are different,
the first sensor is a rotation angle detection sensor, and the second sensor is a wave sensor,
the method for controlling an electronic device comprising the steps of:
acquiring a target rotation direction and a first target rotation angle;
acquiring a third target rotation angle, wherein the third target rotation angle is a rotation angle needed for rotating, for the first time, to a boundary of a prohibited rotation angle range along the target rotation direction;
judging whether the first target rotation angle is greater than the third target rotation angle;
when the first target rotation angle is less than or equal to the third target rotation angle, controlling the rotation body to rotate by the first target rotation angle along the target rotation direction;
when the first target rotation angle is greater than the third target rotation angle, updating the target rotation direction to a rotation direction opposite to the target rotation direction, and updating the first target rotation angle to a difference value between 360° and the first target rotation angle, and performing the step of controlling the rotation body to rotate by the first target rotation angle along the target rotation direction,
when the rotation body rotates by the first target rotation angle along the target rotation direction, when the physical zero-initialization point was detected by the second sensor, determining a second target rotation angle according to a current rotation angle detected by the first sensor and the first target rotation angle;
setting the current rotation angle detected by the first sensor to zero, and controlling the first sensor to re-detect the rotation angle of the rotation body on the rotation plane; and
updating the second target rotation angle to the first target rotation angle, and repeating the step of controlling the rotation body to rotate by the first target rotation angle along the target rotation direction.