Bad Instruction on SITL on macOS OSX M4

I am trying to following this simple intro guide so that make my zephyr run.

I am on MacOS M4.

In my terminals, I run:

  1. sim_vehicle.py -v ArduPlane -f gazebo-zephyr --map --console --model JSON --debug --lldb --speedup 1
  2. gz sim -g
  3. gz sim -s -r -v4 zephyr_runway.sdf

But I am getting this result on one of the windows

Here’s the lldb window:

as you can see it gives me this response:

(lldb) target create "/Users/ibrahimsefer/Documents/GitHub/ardupilot/build/sitl/bin/arduplane"
Current executable set to '/Users/ibrahimsefer/Documents/GitHub/ardupilot/build/sitl/bin/arduplane' (arm64).
(lldb) settings set -- target.run-args  "--model" "JSON" "--speedup" "1" "--slave" "0" "--defaults" "Documents/GitHub/ardupilot/Tools/autotest/default_params/gazebo-zephyr.parm" "--sim-address=127.0.0.1" "-I0"
(lldb) command source -s 0 '/var/folders/_c/dylw2htx35b_nsyqp43w3nl00000gn/T/tmp30o4w__s'
Executing commands in '/var/folders/_c/dylw2htx35b_nsyqp43w3nl00000gn/T/tmp30o4w__s'.
(lldb) process launch
Setting SIM_SPEEDUP=1.000000
Starting SITL: JSON
JSON control interface set to 127.0.0.1:9002
Starting sketch 'ArduPlane'
Starting SITL input
Using Irlock at port : 9005
bind port 5760 for SERIAL0
SERIAL0 on TCP port 5760
Waiting for connection ....
Connection on serial port 5760
Loaded defaults from Documents/GitHub/ardupilot/Tools/autotest/default_params/gazebo-zephyr.parm
bind port 5762 for SERIAL1
SERIAL1 on TCP port 5762
bind port 5763 for SERIAL2
SERIAL2 on TCP port 5763
Home: -35.363262 149.165237 alt=584.000000m hdg=353.000000

JSON received:
	timestamp
	imu: gyro
	imu: accel_body
	position
	quaternion
	velocity

validate_structures:526: Validating structures
Loaded defaults from Documents/GitHub/ardupilot/Tools/autotest/default_params/gazebo-zephyr.parm
warning: arduplane was compiled with optimization - stepping may behave oddly; variables may not be available.
Process 11439 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_INSTRUCTION (code=1, subcode=0x1e201863)
    frame #0: 0x0000000100003f84 arduplane`Plane::calc_speed_scaler(this=0x00000001002eecb8) at Attitude.cpp:19:13 [opt]
   16  	        const float airspeed_min = MAX(aparm.airspeed_min, MIN_AIRSPEED_MIN);
   17  	        const float scale_min = MIN(0.5, g.scaling_speed / (2.0 * aparm.airspeed_max));
   18  	        const float scale_max = MAX(2.0, g.scaling_speed / (0.7 * airspeed_min));
-> 19  	        if (aspeed > 0.0001f) {
   20  	            speed_scaler = g.scaling_speed / aspeed;
   21  	        } else {
   22  	            speed_scaler = scale_max;
Target 0: (arduplane) stopped.
Process 11439 launched: '/Users/ibrahimsefer/Documents/GitHub/ardupilot/build/sitl/bin/arduplane' (arm64)
(lldb) 

As soon as this error is displayed, the no link gets displayed… It just disconnects…

Hopefully, someone is able to help me!

Here’s the full window display if it’s helpful:

P.S. I will tag you @timtuxworth because you had a very similar issue, so maybe you are encountering this issue right now, or maybe you have even solved it?

If I run it without --lldb I get this:

[1]    16656 illegal hardware instruction  /Users/ibrahimsefer/Documents/GitHub/ardupilot/build/sitl/bin/arduplane  JSON

And in the sim_vehicle.py ... terminal window, I get this:

Hopefully this added some more context…

what’s the value of aspeed when it breaks?

I have no idea… I don’t even know how to log that… Right now, I am trying to reinstall everything from scratch just in case, ChatGPT suggested that it’s something related to my compiler not being able to work it out, and my environment setup was a bit messy, because I accidentally was relying on both mamba and conda, so maybe that’s what was causing the issues.

@Sefibrah can you replicate the illegal instruction error on a standard SITL session? i.e. no Gazebo, just a copter or plane.

sim_vehicle.py --debug -v ArduPlane -f plane --console --map

with and without the debugger.

Also, which version of macOS and Xcode is installed (and any other system info that might be relevant).

I’ll try that as well, as soon as I reinstall everything from scratch :sweat_smile: