Home        Store        Docs        Blog

Editing and Identifying C++ Files for SITL

I have installed Cygwin, MavProxy, and ArduPilot on my Windows laptop. I followed instructions according to https://ardupilot.org/dev/docs/sitl-simulator-software-in-the-loop.html. In Cygwin, from folder “autotest”, I enter python sim_vehicle.py -v ArduSub -L RATBeach --map --console and it works fine. My objective is to edit ardupilot and test my edits in SITL before actually using them on the UAV. I have two questions:

  1. How do I tell the computer to recompile any or all C++ files so that my edits are actually implemented?
  2. How can I tell what C++ files, out of all of ardupilot, are used for ArduSub?

I have solid C++ experience but not really with command lines. Thank you!

Hello,

Sim_vehicle.py should take care of rebuilding all the modified files for the vehicle.

It is hard to tell out of all ArduPilot. You may need to work your way up from the ArduSub folder, which constains most of Sub’s relevant features.

This is done by waf, take a look in the wscripts files, but if you are not doing something really out of the standard you should not worry about it.

Thank you for responding so quickly!

To AC_PosControl.cpp I added #include <iostream> at the top (to handle the error it was throwing) and added two std::cout << ... statements to the functions init_ekf_z_reset and check_for_ekf_z_reset. I ran sub_mission.txt in SITL but neither of my messages were printed. Does this mean that std::cout does not work here or that those functions are simply not being called? Should I learn how to use gcs().send_text instead?

Update: I added gcs().send_text(MAV_SEVERITY_INFO, "init_ekf_z_reset: %f", (double)_ekf_z_reset_ms); to the function init_ekf_z_reset() and still I didn’t see my message. Am I doing something wrong or is the function not being called?

I typically use printf with no issues. Be aware that sim_vehicle launches another terminal instance and that these outputs are printed there, not in the terminal instance that launched sitl.

I run SITL by typing python sim_vehicle.py -v ArduSub -L RATBeach --map --console into the Cygwin command line. Then 3 new windows pop up: the MavProxy command line (C:\Users\yunyi\MAVProxy\mavproxy.exe), the console, and the map. I have std::cout, printf, and gcs().send_text commands all in a row but the only thing that I am seeing is the gcs output in the console. What terminal instance are you referring to where the printf outputs are printed?

This test worked fine here: