Path: blob/master/line_formation_2_robot.py
104 views
# robot class for line formation 2 simulation12class LFRobot: # LF for line formation3def __init__(self, pos, vel, ori):4# pos, velocity, orientation for recording the physics5self.pos = list(pos) # convert to list6self.vel = vel # unsigned scalar7self.ori = ori # moving direction in the physical coordinates8# variables for configuring indivudual robot's formation process9self.status = 0 # key status for the formation, start with '0'10# '0' for being single, moving around, available for joining a group11# '1' for in a group, but not an indexed member, still on the way to the line12# '2' for in a group, indexed member, position is good13# '-1' for being single, moving around, and ignoring all connections14self.group_id = 0 # for status '1' and '2'15self.status_1_sub = 0 # sub status for status '1' robot16# '0' for forming the initial line segment17# '1' for merging into the line18self.status_1_1_des = [0,0] # destination for the merging robot19self.status_2_sequence = 0 # sequence along the line for status '2' robot20# index ranges from 0 to N-121self.status_2_end = False # sub status deciding if robot is at larger index end22# False: not at the larger index end of the line23# True: at the larger index end, index should be N-124self.status_2_avail1 = [True,True] # first availability for two sides to be merged25# first availability indicates if the distance is large enough for merging26# first value for small index side, second for large side27self.status_2_avail2 = [True,True] # second availability for two sides to be merged28# second availability indicates if a robot '1' is allowed to merge29# first value for the small index side, second for large side30self.key_neighbors = [-1, -1] # key neighbors to secure the group formation31# one member list for '1_0' robot, the other initial forming neighbor32# two member list for '1_1' and '2' robots33# first member is the robot on the smaller index side of the line34# second member is the robot on the larger index side of the line35# if no neighbor at one side, use -1 as a flag36self.status_n1_life = 0 # life time of status '-1', randomly generated373839404142