# robot class for loop formation simulation12class LFRobot: # LF stands for loop formation3def __init__(self, pos, vel, ori):4# position, velocity, and orientation for the physics5self.pos = list(pos) # convert to list6self.vel = vel # unsigned scalar7self.ori = ori # moving direction8# variables for configuring individual robots's formation process9self.status = 0 # key status for the formation, start with '0'10# '0' for being single, moving around, available for grouping11# '1' for on the way to a formal group, temporary transition status12# '2' for being in a group, all members indexed, constantly adjusting position13# '-1' for being single, moving around, ignoring all connections14# see more details for substatuses in "loop_formation.py"15self.group_id = 0 # for status '1' and '2'16self.status_1_sub = 0 # substatus for status '1' robot17# '0' for forming the initial triangle18# '1' for merging into a loop19self.status_1_0_sub = 0 # substatus for status '1_0' robot20# '0' for forming the pair21# '1' for forming the triangle22self.status_1_0_1_des = [0,0] # destination for the triangle forming robots23self.status_1_1_des = [0,0] # destination for the merging robots24self.status_2_avail1 = True # first availability for this robot allowing merging25# indicating if the interior angle at this node is at good range26self.status_2_avail2 = [True,True] # second availability for two sides to be merged27# indicating if a robot is merging at one side, if yes, then availability is False28# first value for small index side, second for large side29self.key_neighbors = [-1,-1] # key neighbors to secure the group formation30# two members list for all '1' and '2' robots, except '1_0_0'31# first value is the robot on the small index side, second for large side32# if no neighbor at one side, value of '-1' will act as a flag33self.status_n1_life = 0 # life time of status '-1', randomly generated3435363738