Skip to content

Commit

Permalink
fixed routing bug
Browse files Browse the repository at this point in the history
  • Loading branch information
kasperg3 committed Aug 27, 2024
1 parent 82a1060 commit 76e9845
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
5 changes: 3 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ def run_experiment(experiment_title, n_agents, capacity, show_plots, debug, resu
]
exp = Experiment.Runner(coverage_problem=cp, enable_plotting=show_plots, agents=agent_list)

allocations = exp.solve(profiling_enabled=False, debug=debug)
exp.solve(profiling_enabled=False, debug=debug)

# TODO rewrite this as a function
# if export:
# temp = []
Expand Down Expand Up @@ -174,7 +175,7 @@ def run_experiment(experiment_title, n_agents, capacity, show_plots, debug, resu
else:
ds = "AC300"
n_agents = 3
capacity = 100000
capacity = 5000
main(
dataset_name=ds,
experiment_title=ds + "_" + str(n_agents) + "agents_" + str(capacity) + "capacity",
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name="trajallocpy",
version="0.0.3",
version="0.0.10",
description="TrajAllocPy is a Python library that provides functionality for trajectory task Allocation using Consensus based bundle algorithm",
long_description="",
long_description_content_type="text/markdown",
Expand Down
6 changes: 5 additions & 1 deletion trajallocpy/Agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,20 @@ def getDistance(start, end, environment=None):
def getTravelPath(position, assigned_tasks, environment):
full_path = []
travel_paths = []
task_paths = []
if len(assigned_tasks) > 0:
path, dist = environment.find_shortest_path(position, assigned_tasks[0].start, free_space_after=False, verify=False)
full_path.extend(path)
for i in range(len(assigned_tasks) - 1):
full_path.extend(assigned_tasks[i].trajectory.coords)
path, dist = environment.find_shortest_path(assigned_tasks[i].end, assigned_tasks[i + 1].start, free_space_after=False, verify=False)
full_path.extend(path)
task_paths.append(assigned_tasks[i].trajectory.coords)
travel_paths.append(path)
full_path.extend(assigned_tasks[-1].trajectory.coords)
return full_path, travel_paths
task_paths.append(assigned_tasks[-1].trajectory.coords)

return full_path, travel_paths, task_paths


@cache
Expand Down
5 changes: 3 additions & 2 deletions trajallocpy/Experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,9 @@ def solve(self, profiling_enabled=False, debug=False):

# Save the results in the object
for robot in self.robot_list.values():
self.routes[robot.id], self.transport[robot.id] = Agent.getTravelPath(robot.state, robot.getPathTasks(), robot.environment)
self.tasks[robot.id] = [[coord for coord in task.trajectory.coords] for task in robot.getPathTasks()]
self.routes[robot.id], self.transport[robot.id], self.tasks[robot.id] = Agent.getTravelPath(
robot.state, robot.getPathTasks(), robot.environment
)

if self.plot:
plotter.plotAgents(self.robot_list.values())
Expand Down

0 comments on commit 76e9845

Please # to comment.