I now built example code for navio2 board which I have and it all runs fine there. So the question is can I somehow run the code on SITL? That would make experimentation much faster.
The SITL environment provided by sim_vehicle.py is only designed to be used by a full ardupilot build. It doesn’t work with the examples.
The example sketches provided in Library Example Sketches — Dev documentationmight work with SITL, but you would need to write up the scripts yourself. Those scripts are designed to be run directly on the hardware (Pixhawk, Navio, etc).
Interestingly, there’s no segmentation fault if you run it with a plane model. If you are able to connect it to a simulation backend, you might be able to get it working.
I’m actually interested in this as well. When you say you need to write up the scripts you’re talking about correctly starting up the simulator and connecting the example sketch to the appropriate ports?
Yes. As Stephen said, sim_vehicle.py is designed to run the full simulation, not the examples - so you need to start them on your own.
Also, the examples are made to be run on real boards, but it is possible they’ll run with SITL too.