Guided mode with optical flow, without GPS, in simulation

Hi,

In preparation for making an autonomous drone for indoors flight, I have been trying to simulate a drone with optical flow, but I fail to take off.

I have set up the simulation as described in the toutorials. I have also set up the optical flow and range finder as described on the wiki. I configured it by editing the default parameters to this (2.4 KB) this (2.4 KB) .

To set the mode, arm it and attempt takeoff, I use the mavros utility commands like this:

mavsys mode -c 4
mavsafety arm
mavcmd takeoffcur 0 0 1

This results in the drone correctly arming in guided mode, but when I run the last command, it fails while giving this error message in the SITL console:

Got MAVLink msg: COMMAND_ACK {command : 410, result : 4}

Do you know what command 410 and result 4 mean?

I did not find it in the wiki, but another discuss post said to use EKF3 and these parameters:

AHRS_EKF_TYPE = 3
EK2_ENABLE = 0
EK3_ENABLE=1
GPS_TYPE = 0

I would guess my configuration parameters are wrong somehow. Could you please advice on correct parameters or guide to relevant documentation?

Any help would be appreciated. :slight_smile:

Edit: There was a error in the format of the file I initially uploaded, that the new one does not have.

1 Like

Take a look at the mavproxy documentation. The UAV refused that command problrably because you do not have gps lock

Thanks for the reply.

What exactly should I look for in the mavproxy documentation?

To take off without GPS lock is exactly the point, I am trying to use optical flow as an replacement for GPS to enable Guided mode.

I realize that my question is not really clear about not using GPS, so I will edit it.

The question is perhaps more like: How do i configure ardupilot so I can use Guided mode without GPS, but with optical flow?

see here: https://ardupilot.org/copter/docs/common-px4flow-overview.html

I would rather use EK2. You need to set EK2_GPS_TYPE to 3

Thank you for the link, I had not looked at the pages for the individual sensors.

I tried to use EKF3 based the discussion on the post linked in the initial message in this thread, but that did obviously not work the way I did it.

I tried to naively just switch from EKF3 to EKF2 by these lines in the parameter file

AHRS_EKF_TYPE 2
EK2_ENABLE 1
EK3_ENABLE 0
GPS_TYPE 0
EK2_GPS_TYPE 3

so that it now looks like this (2.4 KB) .

This did still now work, it seems to be the same problem. At least it gives the same lack of response.

Do I miss something? I.e. do I need to do more to make it use EKF2 correctly?

I got it working in the end. My problem was that the EKF needs a position, even if we are only using relative movement commands. This can be solved by manually setting the position using e.g.

  • the map in mavproxy.
  • something like this script
  • mavros and the topic /mavros/global_position/set_gp_origin

I used mavros, and have not tested the others.

In the end, I ended up using EKF2, and the parameters i had worked.

1 Like

Can you talk more about how to set gp origin by topic /mavros/global_position/set_gp_origin and confirm that ?
I can only see gp origin message on topic /mavros/global_position/gp_origin once when my copter was armed, and it wasn’t change after I sent set gp origin message on /mavros/global_position/set_gp_origin.
Thank you.

That is a good point. /mavros/global_position/set_gp_origin works well to set the origin, but it not obvious how to check if it is set and ready to arm. When I tried it just now I got a response on /mavros/global_position/gp_origin when trying to arm before it was ready., when it was ready to be armed and when I armed it after it was ready. I.e. 3 responses before first successful arm. I don’t know how /mavros/global_position/gp_origin is supposed to be used, but for me it publishes something when the origin is confirmed and the drone is ready to arm. Since it also publishes at other times, I am not sure how to use it.

I ended up just trying to arm it and see if it would arm to test whether it was ready to fly. This is however an abuse of the safety features and not a good solution.

Sorry for not being more helpful, but I don’t know the solution to this one.

1 Like