@@ -73,12 +73,13 @@ def download_script(script_url):
73
73
except Exception as e :
74
74
logger .error (f"Error during download or extraction: { e } " )
75
75
76
- def compile_mission (dsl_file , kml_file , drone_list ):
76
+ def compile_mission (dsl_file , kml_file , drone_list , alt ):
77
77
# Construct the full paths for the DSL and KML files
78
78
dsl_file_path = os .path .join (compiler_path , dsl_file )
79
79
kml_file_path = os .path .join (compiler_path , kml_file )
80
80
jar_path = os .path .join (compiler_path , compiler_file )
81
-
81
+ altitude = str (alt )
82
+
82
83
# Define the command and arguments
83
84
command = [
84
85
"java" ,
@@ -87,10 +88,12 @@ def compile_mission(dsl_file, kml_file, drone_list):
87
88
"-s" , dsl_file_path ,
88
89
"-k" , kml_file_path ,
89
90
"-o" , output_path ,
90
- "-p" , platform_path
91
+ "-p" , platform_path ,
92
+ "-a" , altitude
91
93
]
92
94
93
95
# Run the command
96
+ logger .info (f"Running command: { ' ' .join (command )} " )
94
97
result = subprocess .run (command , check = True , capture_output = True , text = True )
95
98
96
99
# Log the output
@@ -120,7 +123,7 @@ def listen_drones(args, drones):
120
123
sock .send (b'Error decoding protobuf. Did you send a cnc_pb2?' )
121
124
sock .close ()
122
125
123
- def listen_cmdrs (args , drones , redis ):
126
+ def listen_cmdrs (args , drones , redis , alt ):
124
127
ctx = zmq .Context ()
125
128
sock = ctx .socket (zmq .REP )
126
129
sock .bind (f'tcp://*:{ args .cmdrport } ' )
@@ -157,7 +160,7 @@ def listen_cmdrs(args, drones, redis):
157
160
# compile the mission
158
161
drone_list_revised = "&" .join (drone_list )
159
162
logger .info (f"drone list revised: { drone_list_revised } " )
160
- compile_mission (dsl , kml , drone_list_revised )
163
+ compile_mission (dsl , kml , drone_list_revised , alt )
161
164
162
165
# get the base url
163
166
parsed_url = urlparse (script_url )
@@ -198,8 +201,11 @@ def main():
198
201
parser .add_argument (
199
202
"-a" , "--auth" , default = "" , help = "Share key for redis user."
200
203
)
204
+ parser .add_argument (
205
+ "--altitude" , type = int , default = 15 , help = "base altitude for the drones mission"
206
+ )
201
207
args = parser .parse_args ()
202
-
208
+ alt = args . altitude
203
209
r = redis .Redis (host = 'redis' , port = args .redis , username = 'steeleagle' , password = f'{ args .auth } ' ,decode_responses = True )
204
210
logger .info (f"Connected to redis on port { args .redis } ..." )
205
211
drones = {}
@@ -208,7 +214,7 @@ def main():
208
214
logger .info (f'Listening on tcp://*:{ args .cmdrport } for commander requests...' )
209
215
210
216
d = threading .Thread (target = listen_drones , args = [args , drones ])
211
- c = threading .Thread (target = listen_cmdrs , args = [args , drones , r ])
217
+ c = threading .Thread (target = listen_cmdrs , args = [args , drones , r , alt ])
212
218
d .start ()
213
219
c .start ()
214
220
0 commit comments