Post on 24-Mar-2020
3 Hidden PX4 SITL tricks for everyday development
Julian Oes - 2019-06-20
3 Hidden PX4 SITL tricks for everyday development
What is Software In The Loop (SITL) simulation?
Simulator PX4
Sensor values
Actuator outputs
Local computer
3 Hidden PX4 SITL tricks for everyday development 4
3 Hidden PX4 SITL tricks for everyday development
1 Lockstep2 Shell scripting3 Debugging with GDB, valgrind, callgrind
https://makeameme.org/meme/the-simulation-environment
3 Hidden PX4 SITL tricks for everyday development
1 Lockstep
3 Hidden PX4 SITL tricks for everyday development
Common problems with SITL● CPU load too high
● Interruptions can cause crashes
3 Hidden PX4 SITL tricks for everyday development
How does lockstep work?Sensor valuesand timestamp
Actuator outputs
Simulator PX4
https://dev.px4.io/v1.9.0/en/simulation/#lockstep-simulation
3 Hidden PX4 SITL tricks for everyday development
Why should I use lockstep?
● Bonus: Run simulations faster or slower than realtime 💡
https://beorganizing.com/2017/12/22/dear-old-computer-ive-moved/
● Pause to inspect or debug ✅● Runs better on slower computers ✅
https://giphy.com/explore/hamster-wheel
3 Hidden PX4 SITL tricks for everyday development
How to pause?
Press P
3 Hidden PX4 SITL tricks for everyday development
How to speed up or slow down?
https://dev.px4.io/v1.9.0/en/simulation/#simulation_speed
3 Hidden PX4 SITL tricks for everyday development
Demo
3 Hidden PX4 SITL tricks for everyday development
2 Shell scripting
3 Hidden PX4 SITL tricks for everyday development
NuttShell on NuttX
nsh>
https://docs.px4.io/en/flight_controller/pixhawk.html
3 Hidden PX4 SITL tricks for everyday development
NuttShell
3 Hidden PX4 SITL tricks for everyday development
Use your system shell with SITL
https://dev.px4.io/v1.9.0/en/concept/system_startup.html#posix-linuxmacos

...
3 Hidden PX4 SITL tricks for everyday development
Demo
3 Hidden PX4 SITL tricks for everyday development
3 Hidden PX4 SITL tricks for everyday development
3 Hidden PX4 SITL tricks for everyday development
3 Debugging with GDB, valgrind, callgrind
3 Hidden PX4 SITL tricks for everyday development
Debugging using GDB (or LLDB) in console
3 Hidden PX4 SITL tricks for everyday development
Debugging using GDB (or LLDB) in VSCode
https://dev.px4.io/master/en/setup/vscode.html (work in progress)
3 Hidden PX4 SITL tricks for everyday development
Demo
3 Hidden PX4 SITL tricks for everyday development
3 Hidden PX4 SITL tricks for everyday development
Memory error detection using valgrind● Find reads from uninitialized memory● Find memory leaks● Etc.
https://dev.px4.io/v1.9.0/en/setup/building_px4.html#make_targetshttp://www.valgrind.org/
3 Hidden PX4 SITL tricks for everyday development
Memory error detection using valgrind
3 Hidden PX4 SITL tricks for everyday development
Profiling using callgrind● Function call graph● Function call counts● Time spent in functions● And much more
https://dev.px4.io/v1.9.0/en/setup/building_px4.html#make_targetshttp://valgrind.org/docs/manual/cl-manual.html
3 Hidden PX4 SITL tricks for everyday development
Profiling using callgrind
3 Hidden PX4 SITL tricks for everyday development
KCacheGrind visualization of callgrind data
https://kcachegrind.github.io/html/Home.html
3 Hidden PX4 SITL tricks for everyday development
EKF2
3 Hidden PX4 SITL tricks for everyday development
http://www.quickmeme.com/meme/3qjtpp
Thank you!