# AprilTag Localization and landing

Source: https://forum.modalai.com/topic/4770/apriltag-localization-and-landing
Category: General Questions (https://forum.modalai.com/category/2/general-questions)
Posted: 2025-09-24 23:57:47 UTC by Rupesh
Replies: 5 · Views: 1741

## Rupesh · 2025-09-24 23:57:47 UTC

Hi,
I'm using Starling 2 Max drone. I'm trying to localize the drone with AprilTag. I followed all the instructions from the ModalAI documentation, but cannot get it to work. I feel like the instructions for Relocalization are incomplete. The voxl-inspect-tags is working perfectly, and voxl-inspect-services also shows everything working. I also changed the offboard mode to "follow_tag" as shown in the figure below. Can anyone help me with how to proceed? Or i must use docker and run the script file? If so, is offboard_follow_tag.c safe to use? Because the documentation says "offboard_follow_tag.c: (may be outdated and no longer functional)".
 ![64bf53f2-71eb-4573-9bba-b45c5c6ce387-Screenshot 2025-09-24 184013.jpg](https://forum.modalai.com/assets/uploads/files/1758758024587-64bf53f2-71eb-4573-9bba-b45c5c6ce387-screenshot-2025-09-24-184013.jpg) 
![bccd8a7f-cbb8-4df7-8214-be69c78b5b0e-Screenshot 2025-09-24 185439.png](https://forum.modalai.com/assets/uploads/files/1758758107860-bccd8a7f-cbb8-4df7-8214-be69c78b5b0e-screenshot-2025-09-24-185439.png)

## Reply by ApoorvThapliyal · 2025-09-29 21:04:38 UTC

@Rupesh Thanks for your question. Our subject matter expert is currently unavailable, but we will review this and get back to you within a few days.

## Reply by ApoorvThapliyal · 2025-10-03 20:53:06 UTC

@Rupesh What rotation matrix are you currently using in your `tag_locations.conf`?
 You can try setting it to:

[[0,  1, 0],
 [0,  0, 1],
 [1,  0, 0]]
Keep in mind that relocalization will only work reliably at certain viewing angles relative to the AprilTag. A good way to test is to rotate the tag and observe at which orientations `voxl-vision-hub --debug_fixed_frame` gives a value and not `WARNING, apriltag roll/pitch out of bounds`. Improvements are in progress to make this more robust across a wider range of angles.

## Reply by Rupesh · 2025-10-03 23:38:25 UTC (in reply to ApoorvThapliyal)

@ApoorvThapliyal Thank you for your reply.
I tried voxl-vision-hub --debug_fixed_frame while showing AprilTag to the tracking camera with different orientations, but got some warnings about qvio.
![682929b8-d9dd-49a6-b36a-b873d1f365d2-Screenshot 2025-10-03 182038.png](https://forum.modalai.com/assets/uploads/files/1759533823988-682929b8-d9dd-49a6-b36a-b873d1f365d2-screenshot-2025-10-03-182038.png) 
Since this was a warning about qvio, I checked voxl-inspect-qvio, and it was working okay.

Additionally, I wanted to integrate AprilTag Localization with voxl2_takeoff_land.py. Is it possible to make it work if I add the following code between the 'takeoff' and 'landing' commands?
try:
        await drone.offboard.set_position_ned(PositionNedYaw(0, 0, -1.0, 0))
        await drone.offboard.start()
    except OffboardError as e:
        print(f"Offboard start failed: {e._result.result}")

    await asyncio.sleep(20)

    print("-- Stopping Offboard mode")
    try:
        await drone.offboard.stop()
    except OffboardError as e:
        print(f"Offboard stop failed: {e._result.result}")

I tried to operate it without propellers and got the following logs in PX4. 
![fecd98f3-682b-44e9-9c24-3cf7e95a5a9f-Screenshot 2025-10-03 183324.png](https://forum.modalai.com/assets/uploads/files/1759534428979-fecd98f3-682b-44e9-9c24-3cf7e95a5a9f-screenshot-2025-10-03-183324.png) 
The set points appear to be at the origin instead of those defined by AprilTag. Can you please help me with this?

## Reply by Rupesh · 2025-10-08 21:13:09 UTC (in reply to ApoorvThapliyal)

@ApoorvThapliyal, with the setting you provided, I tried flying with propellers on in offboard mode. Once I armed and switched to offboard mode, the drone took off and stayed at around 10 cm height for 10 seconds. During that time, it didn't detect AprilTag and failed to align, as the height was too low for detection. However, after 10 seconds, it suddenly began to gain height, and as it approached the ceiling, I took control and landed. From the log file, we can see that the drone was attempting to align its X and Y positions with AprilTag; however, the issue was that the Z setpoints continually decreased. Can you please help me solve this? 

Additionally, it would be more beneficial if we could run it using MAVSDK and customize it for our specific code.

![0a5ae7d1-78ab-459d-aca4-123cdf9555c7-bokeh_plot (3).png](https://forum.modalai.com/assets/uploads/files/1759957847094-0a5ae7d1-78ab-459d-aca4-123cdf9555c7-bokeh_plot-3.png) ![74c3a513-d3fc-457c-a255-5661358c913f-bokeh_plot.png](https://forum.modalai.com/assets/uploads/files/1759957847116-74c3a513-d3fc-457c-a255-5661358c913f-bokeh_plot.png) ![81823e36-b956-4946-9e43-738052a44012-bokeh_plot (1).png](https://forum.modalai.com/assets/uploads/files/1759957847166-81823e36-b956-4946-9e43-738052a44012-bokeh_plot-1.png) ![5a5753ea-ac3e-427c-b9ff-d2f8903adf88-bokeh_plot (2).png](https://forum.modalai.com/assets/uploads/files/1759957847188-5a5753ea-ac3e-427c-b9ff-d2f8903adf88-bokeh_plot-2.png)

## Reply by ApoorvThapliyal · 2025-10-13 21:16:46 UTC (in reply to Rupesh)

@Rupesh Apologies for the late reply
It looks like there’s an issue with how the AprilTag system is relocalizing the drone. In my tests, the **z-value** appears to be misinterpreted, which could explain why your drone was climbing in altitude to correct its height estimate. We’re actively working on a fix.
