Return-to-Launch (RTL) on High Wind Indication

We are attempting to integrate the FT743-SM wind sensor to detect wind speed for our quadcopter. The sensor communicates via serial interface or CAN. Our application involves setting the Return-to-Launch (RTL) function to activate during high wind conditions. Currently, we are using the Pixhawk Cube Orange+ for our project. Could someone please assist us with this integration.

Thank you.

I assume you are using this while flying autonomous.
I certainly think it’s not a good practice to fly autonomous without any pilot monitoring and in control. Or take control in events of emergency.
If you like to proceed with it.

Few ways I think can be done.
With microcomputer and a simple python script. Reading for signs of high wind. Could be potential thrust loss or direction of drone kept differing from intended orientation. Or even way too high vibration. Or airspeed vs throttle ratio. Then trigger the RTL.

I don’t think there are onboard sensor that could detect high wind. Except of course if it’s on the ground.

1 Like

Arducopter is already capable of doing wind speed calculations without any additional hardware.

https://ardupilot.org/copter/docs/airspeed-estimation.html

You could probably set up a lua script that would trigger RTL once with the wind value became too high.

2 Likes

That sensor isn’t going to do you much good without using some inertial/positional reference to compare against, and it seems a very strange use case for a what is intended to be a stationary surface wind sensor. Highly recommend using the firmware’s own wind sensing as @Allister says.

It might be possible to integrate support for that sensor, but it would take careful installation and a lot of testing and validation at various attitudes and altitudes to fully support it as a very strange airspeed source. Probably not the right hardware for an air vehicle.

3 Likes

We are relatively new to Lua scripting, and we currently lack extensive knowledge in this area. Specifically, we are interested in understanding how to trigger Return to Launch (RTL) behaviour using Lua scripts. Would you be able to provide any documentation or resources related to RTL triggering through Lua? We greatly appreciate any assistance you can offer.
Thank you in advance for your support.

The best part is no part. And it saves weight! :slight_smile:

Learn Lua

Configure wind estimation

2 Likes

We are beginners with Lua scripting and are attempting to trigger RTL when the wind speed exceeds 15 m/s. We have tried using the following code, but it did not work. Could someone please assist us with this issue?

– High Wind Alert and RTL Script for Pixhawk (Copter firmware)

– Set the wind speed threshold (in meters per second)
local windSpeedThreshold = 15

– Function to check wind speed and trigger actions
function checkWindSpeed()
local windSpeed = copter.wind_speed() – Get wind speed from Pixhawk

if windSpeed > windSpeedThreshold then
    -- Display alert in GCS
    gcs.send_text(3, "High wind alert! Wind speed: " .. windSpeed .. " m/s")

    -- Trigger RTL mode
    copter.mode_rtl()
end

end

– Main loop
function update()
checkWindSpeed()
end

– Call the update function periodically (adjust the interval as needed)
– For example, every 1 second:
– timer.periodic(1000, update)

Have you got the wind speed estimations working? Did you do the calibrations already?

Can you attach the full LUA script for troubleshooting?

Almost zero of that syntax is correct. Please look at the examples and documentation.

Here is a snippet for wind magnitude:

local wind3f = ahrs:wind_estimate()
local wind_magnitude = wind3f:length()

yes i attach the full lua script

Thank you for your response. I’ve implemented a sample code that triggers Return-to-Launch (RTL) when the drone crosses a distance range of 1000 meters, and it works as expected. However, I’ve noticed that after rebooting the Pixhawk in simulation, the script only functions properly if I manually restart it. How can I ensure that the script runs in the background consistently, even after the drone restarts?

local distance_threshold = 1000  
local rtl_triggered = false      

function update()
   
    local current_pos = ahrs:get_position()
    local home = ahrs:get_home()

    if current_pos and home then
        
        local distance_from_home = current_pos:get_distance(home)

        
        if distance_from_home > distance_threshold and not rtl_triggered then
            
            vehicle:set_mode(6)  
            gcs:send_text(6, "Distance from home exceeds 1000 meters. Triggering RTL.")
            rtl_triggered = true
        end
    else
        
        gcs:send_text(6, "Error: Unable to retrieve position or home data.")
    end

    return update, 1000  
end

return update()