I’m trying to use an on board Raspberry Pi with dronekit python API and camera to land on a target. I am using a Pixhawk with Copter 3.4 with precision landing enabled and set to Companion Computer. I found this example (https://github.com/squilter/target-land) and based my code on that.
I took off manually in stabilized mode, hovered over the target, saw that the raspberry code found the target and started sending the MAVLINK messages to the Pixhawk with the landing target position but when I flipped to LAND mode the drone just landed like normal without adjusting it’s position over the target. I know the raspberry/pixhawk connection works since I can do autonomous take offs and stuff using dronekit with the drone in GUIDED mode, it’s just not listening to the landing_target message while in LAND mode and I don’t know why it’s not working like in the example I linked. Am I doing something wrong or is the MAVLINK message structured incorrecty?
Is the precision landing maybe still disabled in the 3.4-rc1 Quad but the variables still show up in the parameters in Mission Planner?
The log seems to show the precision landing variables but the drone was not doing anything? The Heal variable was 1 the whole flight.
@rmackay9 - Any idea if using vehicle.message_factory.landing_target_encode() against an APM:Plane will do anything? (This is a QuadPlane, before you ask )
Also I can’t seem to find any source code references for landing_target_encode(). A pointer would be helpful.
Hi there, the precision landing feature has been automatically enabled in the new firmware, I just finished using this feature yesterday and it worked, I’m using a Quad-copter DJI F450 body frame and PixHawk as the flight controller. The code you’re using for autonomous precision landing is correct, I’m using the Raspberry Pi 3 to run the Drone-Kit-Python code and it also does the image processing and everything is on-board.
Nice to hear. I’m going to use the feature with DFRobot IR positioning camera and IR source on the landing site. But cannot make to work the precision landing in sitl. Is it possible to check the precision landing in ArduCopter 3.4-dev in simulator?
In what mode should be the copter for the precision landing to work with companion computer? guided or land?
Thanx
@dollop Hi there, for SITL, I tried running it on my Raspberry Pi 3 but it didn’t work so I tried everything directly in real time operation, I’m sorry I can’t provide further information on simulation however the precision landing mode only works in LAND MODE when working with a companion computer.
Going through http://ardupilot.org/copter/docs/precision-landing-with-irlock.html, there isn’t much on how to make this feature work with a companion computer. Is the only requirement that the companion computer keep sending landing_target_encode()'ed messages and the flight controller with automatically pick up these messages when in LAND mode?
@Anthony well, if it helps the precision landing feature has to first enabled in the parameters accessible through Mission Planner parameter list if you’re using Mission Planner on your ground control station, select which feature you’re gonna use, either a companion computer or the precision ir lock feature. In my case I activate the companion computer feature in the parameters list, then I keep sending the visual data the precision landing function needs. I also keep looping the code so that the data is sent continuously. Hope this helps.
def send_land_message(x, y):
msg = vehicle.message_factory.landing_target_encode(
0, # time_boot_ms (not used)
0, # target num
0, # frame
(x-horizontal_resolution/2)*horizontal_fov/horizontal_resolution,
(y-vertical_resolution/2)*vertical_fov/vertical_resolution,
0, # altitude. Not supported.
0,0) # size of target in radians
vehicle.send_mavlink(msg)
vehicle.flush()
The variable which you should keep updating is ‘x’ and ‘y’ which are the co-ordinate information of your landing target in the image or video your python code is processing, in rcmackay9’s video, I’m guessing he is detecting circles, so he identifies the circle and he finds the center co-ordinate of the circle within the image and this is the ‘x’ and ‘y’ co-ordinate, so in the code the ‘x’ and ‘y’ variables keep updating so you have to run the above function again in a continuous loop so the copter knows where it has to go, horizontal_resolution and vertical_resolution are the resolution of your image, horizontal_fov and vertical_fov is how much your camera can see in terms of degrees, for a Pi camera v1.3 its 54 by 41 degrees. The rest of the parameters in the function I have yet to look into it. Try looking in this, you’ll get the idea of how the code should work. Hope this helps.
Such cool work! It’s exactly what I wanted. Can it be ported to quadplane? I’m just about to finish a Skywalker quadplane and I’d love to have precision landing capability.
@HjorturG
i need to know something from you because the docs is very confusing.
In the structure of your MavLink message, why the sixth value is put to zero with a hashtag for the altitude … shouldn’t this be the distance between the center of the camera and the center of the detected landing target ?