Path: blob/master/line_formation_1_robot.py
104 views
# robot class for line formation 1 simulation12class LFRobot: # LF stands for line formation3def __init__(self, pos, vel, ori):4# variables for the physical movement5self.pos = list(pos) # pos[0] for x, pos[1] for y, convert to list6self.vel = vel # unsigned scalar7self.ori = ori # global orientation of moving direction8# variables for the line formation control9self.status = 0 # robot's status for the line formation process10# '0' for being single, and seeking connections11# '1' for in a group, but climbing the line, not on the line yet12# '2' for in a group, and in correct position for the line13# '-1' for being single, and ignoring all connections14self.group_id = -1 # random integer to uniquely identify the group15self.status_1_sub = -1 # sub state for state '1' robot16# '0' for initial forming17# '1' for climbing18self.status_1_1_dir = 0 # movind direction for the climbing robot19# '0' for climbing toward the small index end20# '1' for climbing toward the large index end21self.status_1_1_des = [0,0] # destination coordiantes for the climbign robots22# decided by the current grab-on robot23self.status_1_1_side = 0 # left or right side along the moving direction24# '0' for left, '1' for right25self.status_2_sequence = -1 # sequence along the line for state '2' robot26# index starts from '0'27self.status_2_end = False # sub state deciding if robot is at the end of line28# False: not at the end of line29# True: at the end of line30self.key_neighbors = [] # key neighbors to secure the group formation31# for '1_0' robot, neighbor is the other initial forming robot32# for '1_1' robot, neighbor is the line traveling robot33# for '2' robot, neighbors are two robots adjacent on the line34# one robot if the '2' is at the begining or end35self.status_n1_life = 0 # life time of status '-1', randomly generated3637383940