Skip to content

Communications Simulation

Tiana Ton Nu edited this page Mar 1, 2019 · 5 revisions

Radio communication can be simulated without the use of XBee radios.

Under "comm_simulation" in the configs file, when "toggled_on" is set to true, a comm_simulation thread is started. Either file_simulated or http_simulated may then be set to true, toggling the type of simulation. file_simulation will read commands from the specified text file(under "comm_sim_file") and send them to xbee_callback. http_sim will read messages from HTTP POST requests sent to localhost:8080 (recommend using postman for intended use). Both methods will invoke xbee_callback and should be formatted as if they were sent by radio from GCS, as JSON bodies.

comm_sim.txt formatting:

Commands from the text file are read line by line. Each line should include the time to execute the instruction and the message formatted as a JSON string. "~" is used as a delimiter.

Example (file sim):

0.0~{"type":"start", "searchArea":{"center":[1, 1], "rad1":0, "rad2":100}}
1.0~{"type":"pause"}
2.0~{"type":"resume"}
3.0~{"type":"stop"}

Example (HTTP sim):

GET localhost:8080
body: {"type":"continue"}

More info about proper message formatting can be found on the JSON Message Formatting wiki page.