Hi I’m working on a script that is meant to set landing plan so if I enter rtl the drone lands with my waypoints. I’m having trouble with setting waypoints’ altitude because when the code sets them it’s always absolute altitude and when I set them they are relative. I have searched through documentation and I haven’t even once seen a place in mavlink_mission_item_int_t()
to distinguish between absolute and relative altitude.
any help would be welcome
Hi jaca,
here are some code-snippets from my last project that might help you:
if (item:seq() > 0) and (item:command() == 16) and (item:x() ~= 0) and (item:y() ~= 0) then -- look for first waypoint
first_wp:lat(item:x())
first_wp:lng(item:y())
first_wp:alt(item:z()*100)
if item:frame() == 3 then
first_wp:relative_alt(1)
elseif item:frame() == 10 then
first_wp:terrain_alt(1)
end
-- calculate altitude-translation
assert(basepoint:change_alt_frame(first_wp:get_alt_frame()), 'SCR:alt_frame not comparable')
altitude_translation = basepoint:alt() - first_wp:alt()
if altitude_translation < 0 then -- allow just positive offsets for altitude
altitude_translation = 0
end
gcs:send_text(6, string.format('SCR:altitude translation: %+.1f m', altitude_translation/100))
end
1 Like