Precision Landing Not Working (using MAVLINK_MSG_ID_LANDING_TARGET)

I want to control the landing of my quadcopter using Mavlink messages and a telemetry dongle. i.e. my laptop has a dongle to send Mavlink messages to my quadcopter to actively update its landing position.

  • I have params PLND_ENABLE set to Enabled and PLND_TYPE set to CompanionComputer.
  • I ensure the quadcopter is hovering in Guided mode then send MAV_CMD_NAV_LAND and the quad descends as expected.
  • I then use mavlink_msg_landing_target_encode to send 20 messages separated by 300ms to set the landing target.
  • I have mavlink_landing_target_t members set as follows:
    ** size_x = 0.1
    ** size_y = 0.1
    ** angle_x = tan-1(-0.5) = -0.46 radians
    ** All other fields are zero.

The quadcopter descends in a vertical line, never deviating off that path. What am I doing wrong? I was expecting it to descend at the angle of 0.46*(180/pi) = 26 degrees off vertical.

Hello,
Do you have a downward-facing rangefinder enabled? If not, then you probably also need to specify the “distance” (i.e Distance to the target from the vehicle) field. Also, I am not sure, but why aren’t you setting the angle_y field?
Also, AFAIK at ardupilot backend, we ignore the size_x/y field.

Logs would be helpful for future

1 Like

I do not have a rangefinder or sensors of any type. That is why I am using PLND_TYPE set to CompanionComputer.

I don’t set angle_y as I just want to test landing in a westerly direction.

Yes you’re right, size_x and size_y are not used in libraries/AC_PrecLand/AC_PrecLand_Companion.cpp.

I will now say, I did try to set the distance field in previous tests but it did not make things work.

My function is like this:

set_landing_target(float east, float north, float height)
{
	// Set a landing target. All other values will land in the current position.
	mavlink_landing_target_t t;
	
	t.angle_x = atan(east/height);
	t.angle_y = atan(north/height);
	t.distance = sqrtf(east*east + north*north + height*height);
mavlink_msg_landing_target_encode(system_id, companion_id, &message, &t);
}

Basically. I have all units set to metres.

You need to configure a Mavlink based distance sensor. And send DISTANCE_SENSOR Mavlink messsages.

1 Like

I just tested this on a simulator. As long as you have distance and the angle fields mentioned (without rangefinder or DISTANCE_SENSOR mavlink message), and update rate is greater than 0.5 hz, everything should work…

You tested this on master right?

Yes, tested on Master. But we haven’t had any substantial change in prec land for a long time so I guess Copter 4.0.x should be the same… I might be wrong though

1 Like

Thanks, this explains why I could not use the precision landing feature. I will test this next week when I am able to fly my drone again.

Do you know if the distance sensor input to Arducopter takes into account the drone attitude? i.e. should I provide shortest vertical distance as the distance sensor reading?

If it is windy when landing, the drone will be tilted, thus giving a larger distance sensor reading than the shortest vertical distance to the ground.

Unfortunately I was unable to make this work so my next test will be with DISTANCE_SENSOR Mavlink messages.

It will take the attitude in account and correct the distance sensor readings accordingly

1 Like

@arduouspilot do you have a log for that flight where you tested this?

I had a 50MB log which failed to download.

I will make sure I get a short log just for the flight next week. I’ll do the flight with and without the DISTANCE_SENSOR messages.

I decided not to go down this route as it feels far too hacky. Instead I will manually set position targets until low enough to call land.

I’ll still test my previous method of setting landing targets so that I can post a log here.

Cheers.

@arduouspilot if you can send me the exact mavlink script you are using, I think we can figure out what the problem is.

1 Like

Okay, I now have this working.

I have no idea what I did as what I am sending in terms of Mavlink is the same as before:

  • MAV_CMD_NAV_LAND
  • mavlink_msg_landing_target_encode (sent once - enough to change the landing location)

My landing params are here - maybe one of those fixed things:

params

I did not send any DISTANCE_SENSOR messages. Hope this helps someone.

1 Like

@arduouspilot, its worth noting that if you have a downward facing rangefinder installed, the vehicle will slow down its vertical descend speed just before landing… the same is not true for without the rangefinder. So it’ll just land at a constant speed.

1 Like

Thanks, that’s good to know though also slightly concerning. I do like the standard landing velocity behaviour.

Hi,

I have been trying to precision land using mavlink based script from Tony’s (not my code) for initial testing phase. Camera is facing down, RPi is talking to FC (pixhawk4)

The aruco marker is detected but no action happens from the drones end. The Z (distance) is also working without the use of any rangefinder.

Question:

When the marker is detected by camera, what flight mode should be selected for mavlink based precision landing?

Thanks for help.

Activate precision loiter
And select land flight mode.

@amilcarlucas
Thanks, I will try it today and post the result