Skip to content

Commit 87a836c

Browse files
committed
Merge branch 'main' of github.com:cmusatyalab/steeleagle into main
2 parents d2de259 + fbdec81 commit 87a836c

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

cnc/server/control_plane.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,13 @@ def download_script(script_url):
7373
except Exception as e:
7474
logger.error(f"Error during download or extraction: {e}")
7575

76-
def compile_mission(dsl_file, kml_file, drone_list):
76+
def compile_mission(dsl_file, kml_file, drone_list, alt):
7777
# Construct the full paths for the DSL and KML files
7878
dsl_file_path = os.path.join(compiler_path, dsl_file)
7979
kml_file_path = os.path.join(compiler_path, kml_file)
8080
jar_path = os.path.join(compiler_path, compiler_file)
81-
81+
altitude = str(alt)
82+
8283
# Define the command and arguments
8384
command = [
8485
"java",
@@ -87,10 +88,12 @@ def compile_mission(dsl_file, kml_file, drone_list):
8788
"-s", dsl_file_path,
8889
"-k", kml_file_path,
8990
"-o", output_path,
90-
"-p", platform_path
91+
"-p", platform_path,
92+
"-a", altitude
9193
]
9294

9395
# Run the command
96+
logger.info(f"Running command: {' '.join(command)}")
9497
result = subprocess.run(command, check=True, capture_output=True, text=True)
9598

9699
# Log the output
@@ -120,7 +123,7 @@ def listen_drones(args, drones):
120123
sock.send(b'Error decoding protobuf. Did you send a cnc_pb2?')
121124
sock.close()
122125

123-
def listen_cmdrs(args, drones, redis):
126+
def listen_cmdrs(args, drones, redis, alt):
124127
ctx = zmq.Context()
125128
sock = ctx.socket(zmq.REP)
126129
sock.bind(f'tcp://*:{args.cmdrport}')
@@ -157,7 +160,7 @@ def listen_cmdrs(args, drones, redis):
157160
# compile the mission
158161
drone_list_revised = "&".join(drone_list)
159162
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)
161164

162165
# get the base url
163166
parsed_url = urlparse(script_url)
@@ -198,8 +201,11 @@ def main():
198201
parser.add_argument(
199202
"-a", "--auth", default="", help="Share key for redis user."
200203
)
204+
parser.add_argument(
205+
"--altitude", type=int, default=15, help="base altitude for the drones mission"
206+
)
201207
args = parser.parse_args()
202-
208+
alt = args.altitude
203209
r = redis.Redis(host='redis', port=args.redis, username='steeleagle', password=f'{args.auth}',decode_responses=True)
204210
logger.info(f"Connected to redis on port {args.redis}...")
205211
drones = {}
@@ -208,7 +214,7 @@ def main():
208214
logger.info(f'Listening on tcp://*:{args.cmdrport} for commander requests...')
209215

210216
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])
212218
d.start()
213219
c.start()
214220

0 commit comments

Comments
 (0)