mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-05-18 10:07:34 +08:00
b0e1cc72f7
Fixes a regression from 8bae4e5c0e, where
the orbit flight task wasn't an extra task (flight_tasks_to_add) anymore
and therefore the command handling wasn't generated.
There was a race condition that could cause several outcomes. The most severe
was that flight_mode_manager gets the command, switches to orbit and then
in the next iteration switches back because commander did not change
nav_state yet. When commander then switches, flight_mode_manager would still
be in the old mode.
This is prevented by storing the command (allowing it to arrive before or
after mode switch), and then apply it after the switch happens.
26 lines
1021 B
Python
26 lines
1021 B
Python
#!/usr/bin/env python
|
|
|
|
import em
|
|
import os
|
|
import argparse
|
|
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument("-t", "--tasks", dest='tasks_all', nargs='+', required=True, help="All tasks to be generated")
|
|
parser.add_argument("-i", "--input_directory", dest='directory_in', required=True, help="Output directory")
|
|
parser.add_argument("-o", "--output_directory", dest='directory_out', required=True, help="Input directory")
|
|
parser.add_argument("-f", "--files", dest='gen_files', nargs='+', required=True, help="Files to generate")
|
|
|
|
# Parse arguments
|
|
args = parser.parse_args()
|
|
|
|
for gen_file in args.gen_files:
|
|
ofile = args.directory_out + "/" + gen_file
|
|
output_file = open(ofile, 'w')
|
|
# need to specify the em_globals inside the loop -> em.Error: interpreter globals collision
|
|
em_globals = {
|
|
"tasks": args.tasks_all,
|
|
}
|
|
interpreter = em.Interpreter(output=output_file, globals=em_globals)
|
|
interpreter.file(open(args.directory_in + "/" + gen_file + ".em"))
|
|
interpreter.shutdown()
|