# Stochastic Models and Control of Anchoring Mechanisms for Grasping in Microgravity
## 5 Generalized Control Algorithm  
The walking of the asteroid robot can be regarded as a cyclic process. The general closed-loop control system is used to control the attitude adjustment of the fuselage and the swing phase of the legs of the asteroid robot. The closed-loop control system includes an event trigger, which is used to identify whether the anchoring mechanism collides with the asteroid surface. The event trigger sends the trigger signal to the path adjustment controller, which is a sub controller of the closed-loop controller. After receiving the trigger signal, the path adjustment controller will optimize the path of the foot end and send it to the path-planning module. The control algorithm of asteroid exploration robot is shown in Figure 11.  
Considering the speed and attitude requirements of the asteroid robot, the motion planning and control algorithm includes the following modules:  
1. Closed-loop control The expected position of the asteroid and the attitude of the fuselage are sent to the closed-loop control system as the inputs of the closed-loop control system. The posture adjustment controller calculates the desired angular velocities of the fuselage, and they are sent to the path-planning module together with the desired velocity of the legs. The path-planning module sends the discrete foot end position to the inverse solution module, and then joints receive joint angles calculated by the inverse solution module. After the joints of the asteroid robot are driven, the joint angles are sent to the forward kinematics model. The position of the end of the leg is obtained through forward kinematics, and it is sent to the control target. 2. Path-planning module The function of the path-planning module is to plan the position of the spherical joint installed at the end of the leg, and send three-dimensional coordinates to the controller for the inverse kinematics solution. This module has three inputs: the target position of the spherical joint, the attitude of the fuselage and the compensation amount of the spherical joint path. Before the anchoring mechanism contacts the asteroid surface, only the target position of the spherical joint and the fuselage attitude are used as inputs. 3. Contact-judgment module There are two methods to determine the contact point between the anchoring mechanism and the asteroid surface. First, the terrain of asteroids can be obtained by depth camera. According to the forward kinematics model of the asteroid robot, the position of the anchoring mechanism in the control cycle can be obtained. Then the compensation is designed in the path planning to optimally guide the motion of the asteroid robot. In the second method, the contact force is detected by the force sensor installed on the anchoring mechanism and sent to the controller, and the position of the contact point is calculated according to the angle of the leg joint and the positive solution model. The force signal is used to judge whether the anchoring mechanism is in contact with the asteroid surface. However, too many microspines make it difficult to detect the collision force between the anchoring mechanism and the asteroid surface. In this paper, the distance sensor signal was used to judge whether there was a collision. The distance sensor was installed in the center of the drive disc. Through the angle information of the anchoring mechanism and the distance information between the anchoring mechanism and the asteroid surface, we could judge whether the anchoring mechanism collided with the asteroid surface. (4) Path-compensation module  
The path-compensation module calculates the compensation amount of the end of the leg according to the contact position and the angle of the anchoring mechanism, and sends it to the path-planning module. The path-planning module adds the compensation and the initial path together, and sends it to the inverse-kinematics module as a new path.