Compass going crazy when sim_vehicle.py is run

Due to not knowing better, I bought the Pixhawk 2.4.8, which I come to realise now is a chinese copied version of PixHawk 2.4.6. But anyway, I am trying to setup the PixHawk with ChibiOS ArduCopter 3.6. Whenever I run sim_vehiclel.py, the compass starts going crazy and just switches directions randomly. If I try to reboot the vehicle or refresh the parameters, the compas then stops working.
The ground control station software I am using is QGC(latest). The OS is Ubuntu 18.04. If I try to calibrate the compass(while the sim_vehicle.py is running) error is: MAV_CMD (42424) command could not be sent.

Hello,

I don’t understand everything. So let’s try to clarify some points.
sim_vehicle.py is a convenient helper to bring ArduPilot simulation up. The default simulator is SITL and it is launched with an instance of mavproxy. On default parameter, if you connect on udp, you are generally using the mavproxy instance as relay.

About your case, what are you trying to do ?
If you want to load ArduCopter 3.6 on a pixhawk : use the documentation : http://ardupilot.org/copter/docs/common-loading-firmware-onto-pixhawk.html, if you want to use QGC, the process should be the close.
If you have build your own firmware with waf, connect your pixhawk on USB. Now you have 2 options :

  • don’t connect QGC, then use ./waf build --upload
  • launch QGC, chose to upload custom firmware, the built firmware should be in the build/Pixhawk1/bin

Wait the end of the boot sequence (see wiki) and you should be able to connect to QGC ! sim_vehicle.py isn’t used for real board !