Add a new mode for autotakeoff

Hi all,

Basically my goal is to add a new mode which allow the pilot to perform an autotakeoff just by switching a button on the radiocontroller.
e.g. the radio controller is on off then the pilot switches to autotakeoff mode, then the drone arms the motors and take off to a default altitude and then when it reaches this altitude, the drone goes back to POSHOLD and wait for the next command.

But i am lost on the step i should do to success this.
i read the page “how to add a new flight mode” but i am still not sure what the init() method should do and what the run() should do.
I guess i also have to override the allows_arming() method to let me arm the motors in the new mode.

Does someone have already do something similar?

thank you in advance,

There’s a similar feature which uses the PILOT_TKOFF_ALT parameter. If non-zero then once the pilot raises the throttle over 50% in AltHold, Loiter, PosHold, etc, the vehicle will climb to the specified height (in cm).

The only issue I see with the goal you’re aiming for is how the user interface will work. In particular, once the vehicle reaches the specified altitude the vehicle will switch into PosHold which means the pilot’s throttle stick will control the climb rate. If it’s a sprung throttle then that’s OK but if it’s not and the pilot hasn’t moved the stick to mid then the vehicle will begin descending very rapidly.

I guess my point is that it might be easier to extend the existing feature but allow the takeoff to be triggered by the switch instead of by the pilolt raising the throttle above 50%… but even if the switch is used the throttle still needs to be at mid. I guess I also question whether it’s really easier for the pilot to use the switch instead of just pushing the throttle up a tiny bit.

Dear @rmackay9

Thank you for your answer.
Indeed i understand the problem.
and if in the run() method, we trigger the change from newMode to POSHOLD (or any other mode) only if the throttle stick is higher than 50% and the position is reached, will it work better ?
because basically, we ( my team and me) want a switch to control the auto takeoff.

Secondly, where can i find this feature you mentioned, and how can we change the value of PILOT_TKOFF_ALT? in MP ?

Thank you

Jimmy,

Yes, PILOT_TKOFF_ALT is a parameter so it can be modified through the MP.

I think it is best to not create a new flight mode. Instead it would be simpler to add a check into mode_poshold.cpp to check an auxiliary switch position. I would change the check right here in mode_poshold.cpp.

@rmackay9,

Thank you for your answer.
I am using copter 3.4.6 and i dont have this mode_poshold.cpp in my repo, was it added in the higher releases?

Jimmy,

Ah, right. The same feature is in Copter-3.4.6 but I’m less sure how exactly it should be done. Sorry, it’s tough for me to support older releases…

Yes i understand. i really appreciate the time u use trying to help me.
At least you gave me a good start so i will look into it deeply and test different idea.

no problem. I had a quick look at Copter-3.4.6 and it hasn’t changed too much actually. the equivalent line that should probably be changed is here in control_poshold.cpp.

https://drive.google.com/folderview?id=1JohP8-NF3bPsMvKZgxdkHWb2jTnUSXNd

These are the log files plz help as soon as possible. The issue is that when I fly my drone near to me means about 100cm from me it flies fine . But when I fly it far away about 50m it wobbles and sometimes flips 180 degree and is out of control and to control it I increase the throttle to 100 percents to have some control on it. Plz help I am in a urgent need.

I have attached two log files plz analyse both of them.

I am using APM 2.8 with 3.2.1 firmware. And using flysky fs-i6 transmitter and iA6b reciever.

I am giving the parts links that I used to make my Quadcopter. I would be very thankful for the help. Thanks in advance.

Parts are
MOTOR- https://www.amazon.in/REES52-1000KV-Brushless-Dc-Motor/dp/B018IX1JR8/ref=mp_s_a_1_1?ie=UTF8&qid=1548677985&sr=8-1&pi=AC_SX118_SY170_FMwebp_QL65&keywords=motor+brushless+1000kv

ESC- https://www.amazon.in/REES52-REESESC30A-Brushless-Motor-Controller/dp/B0153E00WU/ref=mp_s_a_1_1?ie=UTF8&qid=1548678038&sr=8-1&pi=AC_SX118_SY170_FMwebp_QL65&keywords=esc

PROPELLER- https://www.amazon.in/REES52-Propeller-Multi-Copter-Clockwise-Rotating/dp/B014RTXJR0/ref=mp_s_a_1_2?ie=UTF8&qid=1548678106&sr=8-2&pi=AC_SX118_SY170_FMwebp_QL65&keywords=propeller+1045&dpPl=1&dpID=310N6CpENgL&ref=plSrch

FRAME- https://www.amazon.in/99035841-Neewer-4-Axis-Airframe/dp/B00ATLP6WM/ref=mp_s_a_1_1?ie=UTF8&qid=1548678176&sr=8-1&pi=AC_SX118_SY170_FMwebp_QL65&keywords=f450+quadcopter+frame

I am also posting a video link here for your better understanding. This is not my Quadcopter that I have built but I am facing the same issue and only in windy weather. Thanks again

@Rudransh_Singh_Mahra,

It’s likely a tuning issue but I’m sorry to say we stopped supporting the old APM2.x boards about 3 years ago. I highly recommend upgrading to one of the much more powerful boards that can run the latest AP software. Some of these boards are just as inexpensive as the older APM2.x boards.

To all: The video linked to above is mine. I just want to point out that the controller on the quad wasn’t APM wirh ArduPilot FW, but one of the first “Paris” boards with early “MultiWee” firmware. I have since moved to ArduPilot :grinning:

To: Rudransh Singh Mahra. Please take the developers advise regarding newer flight controller and latest FW.
Tuning may help, but also vibration may be an issue - try balancing the propellers and install the controller on flexible mounts.
Good luck!

-Jan

Ok thanks but I got a solution. He told me that it is a problem of weak battery or power supply issue. Because the voltage is dropping very much