Large Scale Aerial Multi-Robot Coverage Path Planning 閲讀筆記(二)

Large Scale Aerial Multi-Robot Coverage Path Planning 閲讀筆記(二)

6. 實際操作記錄

6.1 安裝Gurobi

首先,我們需要前往Gurobi官網並註冊賬戶。登錄後,找到適合我們操作系統的Gurobi安裝包並下載。接下來,運行剛剛下載的安裝包,根據提示完成安裝過程,包括接受許可協議、選擇安裝路徑等。安裝完成後,系統會自動激活我們的Gurobi許可證。

接著,我們需要設置環境變量。找到剛剛安裝Gurobi的路徑,一般在C:\Program Files\Gurobi或/opt/gurobi,將此路徑添加到系統的PATH環境變量中,以便在命令行中直接調用Gurobi。對於Windows,可以右擊"我的電腦" -> “屬性” -> “高級系統設置” -> “環境變量"進行設置;對於Linux/macOS,可以在shell配置文件(如.bashrc)中添加export PATH=”/opt/gurobi/bin:$PATH"。為了驗證安裝是否成功,我們可以打開命令提示符/終端,輸入gurobi_cl,如果出現Gurobi的歡迎信息,說明安裝成功。我們也可以嘗試在Python/MATLAB/R等環境中導入Gurobi庫並運行一些示例代碼,確認安裝正確。

最後,如果是在商業環境中使用Gurobi,請確保擁有有效的商業許可證;如果是在學術環境中使用,請申請免費的學術許可證。

要注意的一點是需要先安裝Gurobi再安裝wadl-planner,不然在跑程序的時候會出現以下報錯信息:

1
the solver GUROBI is not installed

6.2 安裝wadl-planner

pip

1
pip install wadl-planner

source

1
2
git clone https://github.com/k2shah/wadl.git
pip install -r requirements.txt

快速開始

1
2
3
4
from wadl.survey import Survey
survey = Survey()
survey.addTask(<path_to_geofence.csv>, step=100)
survey.plan()

step是指定的格子大小。

如果需要更多信息,可以查看tutorial中的内容。

6.3 運行範例程序

引入相關Python包

1
2
3
4
5
from wadl.survey import Survey
from wadl.mission import Mission
from wadl.solver.solver import SolverParameters
from wadl.lib.route import RouteParameters
from wadl.mission import MissionParameters

寫入csv文件

1
file = "wadl-master/example/data/stanford.csv"

進行勘探

1
2
name = 'stanford'
survey = Survey(name)

添加關鍵點

1
2
3
4
keyPoints = {"oval": (37.4298541, -122.1694745),
"MSL": (37.4266113, -122.173492)
}
survey.setKeyPoints(keyPoints)

飛行參數設置

1
2
3
4
routeParams = RouteParameters()
routeParams["limit"] = 30*60
routeParams["speed"] = 5
routeParams["altitude"] = 50.0

添加任務

1
2
3
4
5
survey.addTask(file,
step=100
home=["MSL""oval"],
routeParameters=routeParams,
)

求解器參數設置

1
2
3
4
5
6
7
solverParams = SolverParameters()
solverParams["subGraph_size"] = 20
solverParams["SATBound_offset"] = 2
solverParams["timeout"] = 10
solverParams["stitch"] = "milp"

survey.setSolverParamters(solverParams)

求解

1
2
3
4
5
6
7
8
9
# plan the survey
view = 0
# view current plan
if view == 1:
survey.view()
else:
# run path solver to plan paths and write output
survey.plan(write=False, showPlot=True)
#survey.plot()

路綫求解結果

Survey Region with Grid and Home Sites

執行任務

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# make mission
# mission parameters
missionParams = MissionParameters()
missionParams["N_bands"] = 3
missionParams["autoland"] = False

missionParams["assign"] = "sequence"

missionParams["offset_takeoff_dist"] = 10
missionParams["offset_land_dist"] = 10


mission = Mission(missionParams)
mission.fromSurvey(survey, showPlot=True)
mission.setVersion(40187)
mission.write()

執行任務結果

Survey Region with Grid and Home Sites

完整代碼

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!bin/bash/python3
# wadl
from wadl.survey import Survey
from wadl.mission import Mission
# paramters
from wadl.solver.solver import SolverParameters
from wadl.lib.route import RouteParameters
from wadl.mission import MissionParameters

# survey design script
# get file name
# files are assumed geofences (ID, lat, long)
file = "wadl-master/example/data/stanford.csv"

# make survey
name = 'stanford'
survey = Survey(name)

# add the keypoints
keyPoints = {"oval": (37.4298541, -122.1694745),
"MSL": (37.4266113, -122.173492)
}
survey.setKeyPoints(keyPoints)

# route parameters
routeParams = RouteParameters()
routeParams["limit"] = 30*60 # s
routeParams["speed"] = 5 # m/s
routeParams["altitude"] = 50.0 # m
# add the tasks

survey.addTask(file,
step=100
home=["MSL""oval"],
routeParameters=routeParams,
)

# solver parameters
solverParams = SolverParameters()
solverParams["subGraph_size"] = 20
solverParams["SATBound_offset"] = 2
solverParams["timeout"] = 10
solverParams["stitch"] = "milp"

# set the solver parameters
survey.setSolverParamters(solverParams)

# plan the survey
view = 0
# view current plan
if view == 1:
survey.view()
else:
# run path solver to plan paths and write output
survey.plan(write=False, showPlot=True)
#survey.plot()

# make mission
# mission parameters
missionParams = MissionParameters()
missionParams["N_bands"] = 3
missionParams["autoland"] = False

missionParams["assign"] = "sequence"

missionParams["offset_takeoff_dist"] = 10
missionParams["offset_land_dist"] = 10


mission = Mission(missionParams)
mission.fromSurvey(survey, showPlot=True)
mission.setVersion(40187)
mission.write()