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.
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.
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.
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);
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…
@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.