Skip to content

Commit

Permalink
created individual robot based task option
Browse files Browse the repository at this point in the history
  • Loading branch information
Marius-Juston committed Jan 25, 2024
1 parent 60da0c9 commit 4f4e924
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/motion_creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ def set(self, x=0, y=0, z=0, ax=0, ay=0, az=0):
for drone in self.drones:
drone.set(x, y, z, ax, ay, az)

def __getitem__(self, item):
return self.drones[item]


class TaskTimer(threading.Thread):
"""
Expand Down Expand Up @@ -113,9 +116,15 @@ def __init__(self, robot_groups):
for key in robot_groups.keys():
self.tasks[key] = []

def add_task(self, seconds, robot_group, **vel_command):
self.tasks[robot_group].append(
TaskTimer(seconds, lambda: self.robot_groups[robot_group].set(**vel_command)))
def add_task(self, seconds, robot_group, robot_id=None, **vel_command):
if robot_id is None:
command = lambda: self.robot_groups[robot_group].set(**vel_command)


else:
command = lambda: self.robot_groups[robot_group].set(**vel_command)

self.tasks[robot_group].append(TaskTimer(seconds, command))

def run(self):
rate = Rate(1)
Expand Down Expand Up @@ -147,6 +156,11 @@ def run(self):
})

system_tasks.add_task(1, Drone, z=1)

system_tasks.add_task(1, Drone, robot_id=0, z=1)
system_tasks.add_task(2, Drone, robot_id=0, z=1)
system_tasks.add_task(3, Drone, robot_id=0, z=1)

system_tasks.add_task(0, Drone, z=0)
system_tasks.add_task(5, Jackal, x=2)

Expand Down

0 comments on commit 4f4e924

Please sign in to comment.