Skip to content

parse_json() and configs.json

Andrewli128 edited this page Oct 27, 2018 · 6 revisions

configs.json serves as an input file for configurations for quick scan, such as what aspects of the program are simulated, the label of the vehicle, whether the program is being run on a quadcopter or VTOL, etc. If you are working with a parameter that should be an input to the entire quick scan program, add it to configs.json. At the beginning of quick scan, it will be parsed into a dictionary called configs. Then, access that dictionary in the area of code that you're working in to see the value of the parameter.

Details on how these work:

parse_json():

Searches the current directory for the .json file specified in the first command line argument; if the specified file is found, returns a dict of its contents. Otherwise, a FileNotFound exception is raised. If no command line arguments are given, the function defaults to searching for "configs.json".

configs.json:

Text file that contains a set of key-value pairs in the form

{ "keyA": valuea, "keyB": valueb, ... "keyX": valuex }

where keys are strings and values are numbers, strings, booleans, etc.

Note: Currently, "xbee_port_name" and "mission_control_MAC" are hard-coded in and are computer dependent.