ardupilot icon indicating copy to clipboard operation
ardupilot copied to clipboard

Copter: "Pause Mission" with CH7

Open robustini opened this issue 13 years ago • 21 comments

I think this is very usefull, pause a mission with CH7 and able to being again without start from the beginning. I had to take pictures along a path between some waypoints and would be very useful activating the CH7 that the quad to stop in Loiter and then leave always to the next waypoint at my command.

Marco

robustini avatar Jun 10 '13 06:06 robustini

I'm thinking about implementing this for AC3.1 but I'm unsure how it should work.

So Marco you think we should have a ch7/ch8 switch that basically switches you to auto and resumes the previous mission if it was there? Yes, maybe this is the most straight forward way to do it.

I was thinking of trying to intelligently decide when the user switches back into AUTO mode whether to resume the mission or restart. In this way I was hoping to make it more intuitive and save a switch.

Sometimes it's very easy to decide whether to restart or resume: 1. if the mission has never been started we should start from the beginning 2. if the previous time the mission was run it completed, we should start from the beginning 3. if the copter was armed/disarmed since the last time we ran the mission then we should start from the beginning.

But if we are 1/2 way through the previous mission and the user switches to AUTO we could check if we are closer to home or closer to the previous waypoint ... if we're closer to the previous waypoint we resume.

..or we could add a new parameter and if you set it to 1 and it will always resume a mission if it was running. In this case if you wanted to restart the mission you would need to return home, disarm and rearm and then switch to AUTO.

What do you think?

rmackay9 avatar Jul 28 '13 03:07 rmackay9

Thanks Randy for taking into account this thing, I'm looking for new useful features, not found in other flight board. All the things you suggest are great! My need, partly because I was asked, would be to stop the quad in Loiter (or in another flight mode) from Auto, do inspections for video/photo in "Loiter" and then continue the mission to the next waypoint. My need, partly because I was asked, would be to stop the quad in Loiter, do inspections video / photo and then continue the mission. But in flight may need to repeat the mission from the start, if there is a parameter to 0/1 must land and change it, or land/disarm/rearm/take off to make it again, I find it rather uncomfortable but not bad. You could do that the mission is repeated from the start only if the quad is located within a radius "x" (in meters) from the point where we have reinforced what we do as Auto and if the flag "arm motors" is engaged, i think is a better idea, but there should still be a parameter 0/1 to disable this feature, but if I have the quad far away are forced to return to the home to start again. What do you think? This way I can also move the quad in Stabilize elsewhere or in any other flight mode, and when engage again Auto the quad moves to the next waypoint. If you want to save ch function i think this is the right way, anyway it would be nice if you choose in-flight start from scratch or continue.

Bests, Marco

robustini avatar Jul 28 '13 06:07 robustini

Or, perhaps even better, the mission can be restarted from scratch only if the quad is located beyond a radius "x" (in meters) from where we disengage Auto the last time, what do you think? :-) In this way to restart the mission I just get away for a bit from where I came out from Auto, and it's better not to rely on the distance from one of the waypoints, it might be more confusing. But in this way you must record the latest gps position where disengage Auto. Great this one! :P

robustini avatar Jul 28 '13 06:07 robustini

Consider, however, also have the option ch7/8, when activated the quad stops in Loiter though have the throttle stick to zero, and when deactivated the the quad continues the mission from that point, easier... :+1:

robustini avatar Jul 28 '13 07:07 robustini

Another solution would be to use a 3 positions switch for Auto mode :

  • low position : auto mode disabled
  • mid position : take off or pause
  • high position : auto

When in auto (high position), switching to mid position pause the mission. Switching back to high position resume the mission. Switching to low position reset the mission without possibility to resume.

Using that solution save a mode slot on CH5.

I did implement 3 positions switches detection for CH7 and CH8 (primarily for Simple / SuperSimple control), i did implement it so that it will be easy to use that for other functions. Functions 101 - 254 are free for this use.

I will test it today and will send the pull request as soon as it is ok.

Olivier.

Olivier-ADLER avatar Jul 28 '13 08:07 Olivier-ADLER

Really nice Olivier, i like the "3 position switch on CH7/8", all the tx have a 3 position switch, dunno why CH7/8 are limited to two position only. In think your is the better solution!

robustini avatar Jul 28 '13 09:07 robustini

It is not limited anymore. I did send a pull request #463 a few minutes ago with CH7 - CH8 3 positions switches support and a new Simple - SuperSimple 3 pos mode.

It is tested in flight.

It is on my GITHub repository : Olivier-ADLER:CH7-CH8_Simple-SuperSimple_3pos

Olivier

Olivier-ADLER avatar Jul 28 '13 10:07 Olivier-ADLER

The ability to pause and resume a mission will be added to master as part of the upcoming AP_mission library integration. I haven't yet wired up ch7/ch8 so that it works as described above but I'll try and get that in for AC3.2.

rmackay9 avatar Mar 04 '14 07:03 rmackay9

I have this working in a branch here: https://github.com/chapman/ardupilot/compare/pause_continue_ch7-ch8

You can use CH7/CH8 as a 2-position switch (HIGH will pause, LOW will resume), or a 3-position switch (HIGH will pause, LOW will resume, MID will reset).

I was about to do a pull request, however it occurred to me that rather than being locked into AUTO mode and be able to pause/continue/reset with that switch, you really want to be able to pause, switch flight mode, take manual control for a bit, then continue the mission (e.g. in a search and rescue operation: spot something in a grid sweep, check it out, false alarm, continue).

So it might be better to change the default behaviour of copter to match plane in that AUTO missions are always continued from where they were last up to, and you need to explicitly reset if you want it to start from WP1 again.

There is already a 'Restart Mission' button in Mission Planner for this, and I would suggest we make this new CH7/CH8 option to restart mission from the tx.

That way you can not only pause/continue/reset within an AUTO mission, but also switch out of AUTO into another flight mode, then back into AUTO to have it continue where it left off, which is much more useful.

Thoughts?

Also, Randy, I noticed that AP_Mission.stop() currently doesn't stop until it reaches the next waypoint. I think it should stop where it is and loiter when you pause, no? AP_Mission.start() does have immediate effect if you trigger it between waypoints in AUTO.

chapman avatar Apr 15 '14 07:04 chapman

AC, yes, that sounds great. Let's make it the same as plane. I definitely like the idea of being able to switch out of auto to another flight mode and then back again to resume the mission, that makes perfect sense.

rmackay9 avatar Apr 15 '14 08:04 rmackay9

Cool - we'll just need to be sure everyone know's that change is happening. I know it was a surprise to not restart automatically when I first flew APM:Plane. Maybe we should add a parameter to control that? MIS_AUTORESET=1 being copter's current behaviour, MIS_AUTORESET=0 being equivalent to plane's current default?

And do you agree that AP_Mission::stop() for copter should stop where it is? I'll look into what's causing it to continue to the next waypoint before stopping.

chapman avatar Apr 15 '14 08:04 chapman

AC, yes a parameter to control whether it resumes or not might be a good idea. I guess it makes sense to put it into the AP_Mission library although my guess is that it may not actually be used directly by the library but instead by the main code... I guess it depends upon how you implement it.

I think it will be difficult to make it stop when ap-mission::stop() is called. All that logic is up in the main code while the library mostly just handles the queue and saving/restoring commands from the eeprom. I think if someone wants to stop the vehicle, they should switch to loiter mode.

rmackay9 avatar Apr 15 '14 08:04 rmackay9

Ok, working well in SITL now, two pull requests coming through soon:

  1. for AP_Mission to add the MIS_AUTORESET parameter (defaults to 0, i.e. continue), and a couple of extra functions to make use of it
  2. for copter to enable the 3-pos switch and use that lib change

The behaviour: LOW: start or resume AUTO mission (can be used to initiate AUTO mode) MID: pause AUTO mission, switches to LOITER HIGH: reset AUTO mission, if in AUTO mode immediately heads for WP1, otherwise it will do next time AUTO is initiated

chapman avatar Apr 15 '14 18:04 chapman

We are hoping to pause missions on Droid Planner, but we were planning on doing it by entering Loiter, then asking Nav to start with a saved WP index. But, I'm afraid the state of the AP would be lost - for example how would we handle Do now commands such as set_speed and set_yaw behavior.

Do you save the state of the Mission in an instance? Before we let the mission edit globals and AP_Param items which was very sketchy. Jason

On Apr 15, 2014, at 1:36 AM, Randy Mackay [email protected] wrote:

AC, yes a parameter to control whether it resumes or not might be a good idea. I guess it makes sense to put it into the AP_Mission library although my guess is that it may not actually be used directly by the library but instead by the main code... I guess it depends upon how you implement it.

I think it will be difficult to make it stop when ap-mission::stop() is called. All that logic is up in the main code while the library mostly just handles the queue and saving/restoring commands from the eeprom. I think if someone wants to stop the vehicle, they should switch to loiter mode.

— Reply to this email directly or view it on GitHub.

jason4short avatar Apr 15 '14 19:04 jason4short

The new AP_Mission library should handle the persistence of mission state through run/pause/resume. I'll do a lot more thorough testing, but it seemed to be doing everything right last night, including maintaining the DO_JUMP count. I'll test the more esoteric cases like yaw, roi, etc soon

So in terms of GCS integration, we just need MAVLink commands for pause/resume, if they don't exist already (the reset command must exist already, plane uses it).

chapman avatar Apr 15 '14 21:04 chapman

Ok, I did some testing this morning which showed up some general issues in AP_Mission (logged), and some things which don't quite behave properly in the case of pausing and continuing a mission:

Things that work well: LOITER_TIME (remaining time correct after pause+continue) LOITER_UNLIMITED (remains in loiter after pause+continue, even if there's a subsequent command) RTL (can pause+continue during RTL) LAND (can pause+continue during LAND) DO_JUMP (correctly keeps track of jump count before+after pause) DO_SET_HOME (checked pause+continue after setting new home, it goes there on later RTL)

Things I couldn't test properly because they don't seem to work at the moment in general: CONDITION_DISTANCE: seems broken in AP_Mission? #994 CONDITION_YAW: seems broken in AP_Mission? #991 DO_CHANGE_SPEED: seems broken in AP_Mission? #995

And some mission commands that have quirks particular to pause+continue: LOITER_TURNS: resets the turn count and initial direction on pause+continue, should be persistent ROI: if ROI is 1st command, pause+continue RESETS YAW to point to next waypoint, then after crossing that WP ROI resumes. If ROI is not 1st command, it is lost after pause+continue CONDITION_DELAY: seems to reset the delay timer when you pause+continue, should be persistent

I think we should close this issue when pull #997 happens, in that pause+continue in general works well with the tx switch now, and I can make a separate issue for these little quirks in pausing AP_Mission

chapman avatar Apr 16 '14 20:04 chapman

Correction: LOITER_TIME is resetting the timer upon pause+continue

So it seems like in general only stateless commands are behaving correctly with a mission pause, other than DO_JUMP which has specific handling to keep that persistent (init_jump_tracking())

chapman avatar Apr 16 '14 20:04 chapman

Thanks Andrew!

robustini avatar Apr 24 '14 22:04 robustini

AC's changes are in in master now so there is a MIS_RESTART parameter. If you exit AUTO and then enter again it will begin at the last command that it was running. In this way we don't have a "Pause switch" exactly but basically the default is to always resume the mission where it left off. The mission is reset back to the first command if the mission completes or if the vehicle is disarmed.

When a command is interrupted and then resumed we begin the command again from it's beginning. So for example if you had a LOITER_TURNS command which requested 3 revolutions around a point, if that command was paused after 1 revolution and then resumed, it would do another 3 revolutions. I think this behaviour is fine though.

rmackay9 avatar May 16 '14 06:05 rmackay9

Ok Randy, but if i want to restart the mission from the begin during flight? Sorry but i don't understand this step.

robustini avatar May 16 '14 06:05 robustini