Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
yangliu28
GitHub Repository: yangliu28/swarm_formation_sim
Path: blob/master/line_formation_1_robot.py
104 views
1
# robot class for line formation 1 simulation
2
3
class LFRobot: # LF stands for line formation
4
def __init__(self, pos, vel, ori):
5
# variables for the physical movement
6
self.pos = list(pos) # pos[0] for x, pos[1] for y, convert to list
7
self.vel = vel # unsigned scalar
8
self.ori = ori # global orientation of moving direction
9
# variables for the line formation control
10
self.status = 0 # robot's status for the line formation process
11
# '0' for being single, and seeking connections
12
# '1' for in a group, but climbing the line, not on the line yet
13
# '2' for in a group, and in correct position for the line
14
# '-1' for being single, and ignoring all connections
15
self.group_id = -1 # random integer to uniquely identify the group
16
self.status_1_sub = -1 # sub state for state '1' robot
17
# '0' for initial forming
18
# '1' for climbing
19
self.status_1_1_dir = 0 # movind direction for the climbing robot
20
# '0' for climbing toward the small index end
21
# '1' for climbing toward the large index end
22
self.status_1_1_des = [0,0] # destination coordiantes for the climbign robots
23
# decided by the current grab-on robot
24
self.status_1_1_side = 0 # left or right side along the moving direction
25
# '0' for left, '1' for right
26
self.status_2_sequence = -1 # sequence along the line for state '2' robot
27
# index starts from '0'
28
self.status_2_end = False # sub state deciding if robot is at the end of line
29
# False: not at the end of line
30
# True: at the end of line
31
self.key_neighbors = [] # key neighbors to secure the group formation
32
# for '1_0' robot, neighbor is the other initial forming robot
33
# for '1_1' robot, neighbor is the line traveling robot
34
# for '2' robot, neighbors are two robots adjacent on the line
35
# one robot if the '2' is at the begining or end
36
self.status_n1_life = 0 # life time of status '-1', randomly generated
37
38
39
40