Servers by jDrones

How to use Precision Landing feature with companion computer?

Hi everyone.

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.

MAVLINK message:

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()

4 Likes

Good to see you’re giving this a try. I’m hoping that I’ll be able to give this a try within the next month.

It should be enabled and obey the commands. It requires having a GPS lock by the way.

Can you post a dataflash log?

1 Like

@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 :slight_smile:)

Also I can’t seem to find any source code references for landing_target_encode(). A pointer would be helpful.

I’m pretty sure that quad plane doesn’t have the precision landing code included so it should just ignore that message.

As a follow up, I did try precision landing with a companion computer and it worked as it should which was a happy surprise.

1 Like

Nice video. How does it perform with moderate winds?

How much work is there to port this code into Plane?

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.

4 Likes

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.

By this you mean sending which data/messages exactly? Link to code would make it clear thanks.

Okay, if you’re using the same code above:

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.

https://github.com/squilter/target-land/blob/master/target_land.py

1 Like

Hello,
Here is my ‘‘instruction picture’’ showing how to make
squilter’s target_land.py works on SITL with an ODROID


So basically, if its working in SITL, it should work in the FIELD… Real test are comming :slight_smile:

1 Like

Great work, I did this in school as a project. This is a demo video.

1 Like

PERRRRRRRRRRRFECT !!!
Great Job , keep on !

I have the ZED and TX1 as well but the Zed is on a gimbal. Are you using a different carrier board?

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.

Good question, this would be great for quadplane!
You might want to take a look at vision_landing, it’s another method for precision landing:
http://discuss.ardupilot.org/t/maverick-vision-landing/18168

1 Like

@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 ?

Hi! Im trying to visualize the m255 landing target but there is no such parameter in qgroundcontrol.

Do you know if this changed?

Servers by jDrones