Hi, I am performing a SITL simulation for Arducopter in GPS denied environments. I have setup Gazebo with SITL.
I am using optical flow sensor along with rangefinder in substitue of GPS. I have disabled GPS Pre-Arm checks and I am able to arm the throttle but the copter does not takeoff giving an error msg shown below.
Got COMMAND_ACK: NAV_TAKEOFF: FAILED
These are the parameters that I have set.
AHRS_EKF_TYPE = 3 (Enable EKF version 3, 2 is set by default)
EK2_ENABLE = 0 (Disable EKF2)
EK3_ENABLE=1 (Enable EKF3)
GPS_TYPE = 0 (Disable GPS)
EK3_GPS_TYPE=3
AHRS_GPS_USE=0
For adding a Rangefinder set the following parameters:
SIM_SONAR_SCALE 10
RNGFND1_TYPE=1
RNGFND1_SCALING=10
RNGFND1_PIN=0
RNGFND1_MAX_CM=5000
RNGFND1_MIN_CM=0
EK3_ALT_SOURCE=1 (Use Rangefinder as altitude source for EKF)
Adding Virtual Optical flow sensor:
SIM_FLOW_ENABLE=1
FLOW_TYPE=5
I want to know whether I have mis-configured something? It does not take off in Loiter or Stabilize mode.
Ref. this post Ardupilot needs a position reference, even if you will only use relative motion commands. You can test if that is the issue by right clicking in the mavproxy map and click set origin.
Edit: You should be able to take of in stabilized mode without this, so it might be a different issue.
I don’t know what the issue is. I have not seen the message APM: EKF3 refusing to set origin before.
Are you using your own optical flow implementation? I see you set FLOW_TYPE=5 while the docs set FLOW_TYPE=10. I don’t know if this is a problem or not, but it is a divergence from the setup I used.
I think the TAKEOFF command requires position(I.e. GUIDED mode). Does it work to take off in STABILIZED mode using the simulated rc controls? (Eg. rc 3 1800)
By “requires position” I mean that ardupilot needs a position estimate to fly this flight mode. Typically it gets the position estimate from GNSS, but it can also get it from an optical flow sensor and an initial origin.
Since you can fly in STABILIZED mode, I guess that your issue is with this position estimate.
Did you try to set FLOW_TYPE=10?
Perhaps worth to try to fly with the simulated GPS active. If that does work, we don’t know much more, but if it does not work we can further try to isolate the issue.