Make an option to have Home be 'Permanent' if within 200m of current location at boot.
I am creating a new request that was originally made by me in August 2010 in the original Ardupilot issues section here. http://code.google.com/p/ardupilot/issues/detail?id=12
Things have changed somewhat since I originally requested this feature back in 2010. It appears that the feature was added at some point, but no-one seems clear on its operation. This is what I suggest; we need something both convenient and safe. Since a large number of users tend to fly at the same field repeatedly, and their flying sites have rules not allowing flight behind the flight line, I would suggest the following:
-
The mission planner be used to set the desired home position along with a mission file, which can then be uploaded to the APM.
-
Upon boot and 3D lock the APM checks the stored home position and compares it's location to the current location. If the stored location is within 200m of the current location, wag the ailerons, then use the stored location. If the stored location is greater than 200m from the current location, wag the elevator, then overwrite the stored location with the current location and use it as home.
I think 200m is a safe distance, keeping the plane within sight at all times while not being overly close at the same time. The user might have a home location he defines in the MP where his loiter radius is 45m and he sets home at 80m (by mouse click). Or he might choose to place home further out, so long as he doesn't exceed 200m from the location where the APM boots up. Then on subsequent flights either on the same day or on other days he would retain the stored home location as long as the boot location was within 200m and the mission file hadn't changed. This would also require that the mission planner always uploads a home location.
NOTE: For those that don't use the Mission Planner or Telemetry, this feature should probably have a parameter allowing the user to either turn it on or off.
This feature has been discussed recently here http://diydrones.com/forum/topics/creating-a-switch-to-set-home?commentId=705844%3AComment%3A1314169&xg_source=msg_com_forum .
I also made this request in the forum linked above.
Its a nice idea but can we stop using the servos as indicators? There are LEDs for that - and some planes like one of mine actually bounce around on the table with the servo movements, risking to smash the gears and disrupt gyro calibration too. Elevon planes will be confused/ing too ;)
I also think that we need a feature of this sort to satisfy the club requirements of NOT flying behind the flight line. It is my opinion that this method would also stop potential mistakes when setting the home location in MP then having it "stick".
@dongfang It really doesn't matter to me how we communicate the state of the home position. However on most aircraft I've owned, it's hard to see the LED's because they are buried inside the aircraft. If we could put support for a remote LED panel that could be plugged into some of the IO pins I'd be happy with that. The nice thing about wagginf the control surfaces is it's universal (for a plane).
I flew last weekend on v2.73 and made several attempts to move the home location using the mission planner to no avail. I loaded a mission to the APM via the MP (1.2.60) with a home position that was about 100m in front of my current location. I then read back the WP file to the MP and was asked if I wanted to save the loaded home position, I said yes and the home position displayed was where I expected 100m in front of me. I then took off any flew my mission. At one point I decided to test RTL and discovered that despite the process shown above the home location was still where I had booted the APM and not where home was shown on the MP. After landing I left the plane on cleared the mission on the mission planner and then read the WP file on the APM; it shows the home position where I wanted it to be, but it still is flying RTL to where I booted up the plane. I'm either missing something, doing something wrong etc, or the change home function doesn't work. Either way I think adding the functionality to make the home position a 'Permanent' location as long as it remains within 200m of it's loaded location would be a good safety feature as well as a convenience.
:)
I experienced the same thing. I have been told that cycling the power on the APM reset the home, and I can't remember if I swapped batteries after setting home. I haven't had a chance to test. KD2, did you cycle the power on the APM after writing your desired home to the EPROM and flying? BTW, home is defined at GPS lock, not boot up.
Let me present a small analysis of the code. It will show that the MP set home position is not used for anything...
1: Where is Home? APM has two home positions, namely struct Location home (declared in ArduPlane.pde) and waypoint number zero.
2: Where did the info come from? There are three sources of home positions: GPS, mission waypoint number zero, and the MAV_CMD_DO_SET_HOME mission command.
2.1: Home initialization by GPS In update_GPS() in ArduPlane.pde there is some logic that calls init_home() at the 5th GPS position received (BTW my altitude is often 100 m off. Maybe the 50th would be better?). This sets both struct Location home and waypoint number zero.
2.2: Home initialization by upload of mission script This happens the same as for all other WPs. struct Location home is not affected from anywhere in MAVLINK_MSG_ID_MISSION_ITEM case in GCS_MAVLink::handleMessage() that I have found.
2.3: Home initialization by the MAV_CMD_DO_SET_HOME mission script command: Setting of home a by MAVLink command happens in do_set_home() in commands_logic.pde. Depending on the p1 parameter sent in the command, it does either:
- call init_home() which sets both struct Location home and waypoint number zero to the current GPS position or
- set struct Location home to the position in the command parameters. So it depends on the p1 parameter if waypoint number zero is written along or not. Bug?
3: How APM flies home: There are two ways for APM to fly home, namely a plain RTL but also handle_no_commands() in commands_logic.pde (they differ in the control mode used, and how the altitude regulation works). Both use struct Location home as home position.
4: How APM interprets missions in general: This is a difficult one. There are several variables sort of claiming to be the index of the current command: g.command_index (which is initialized to zero in init_commands()) nav_command_index (same initlialization) non_nav_command_index is not relevant. nav_command_ID is a sort of flag whether the current nav. command is active, or the next one should be sought. It it initialized to NO_COMMAND in init_commands() The current interpreter with all these variables will, if I understand it right, be replaced soon.
As I understand the script interpreter (commands, commands_logic and commands_process), waypoint number zero is sometimes referred to by indices but never actually used. In process_command(), there is a condition if nav_command_ID==NO_COMMAND then scan the mission for the next navigation command. It scans forward at least one. So cf. the initialization of nav_command_ID=NO_COMMAND, the first time an auto flight looks for where to fly to, it skips past waypoint number zero.
5: Comclusions of my code look through: a) Waypoint number zero is set from MP and written into EEPROM b) Waypoint number zero is overwritten once per APM startup after GPS had enough good fixes. It is also written to from executing the MAV_CMD_DO_SET_HOME mission command but only if some parameter in the command is something. c) Waypoint number zero is never used in flight d) Waypoint number zero is returned when requesting the mission from the UAV. It is whatever one has last written to it - except if one has reset the APM after last write, see b).
6: Conclusion overall: It's somewhat confusing as it is now (OK - it's not really bad). The home position set in and written from MP mission upload has no effect. Also, if one writes a mission and re-reads it, it will deceptively seem that one has set a home pos. that is actually used (MP even asks if you want to take it). Really, you will read the home position that you just wrote, and APM does not use it for anything, it rather uses its own struct Location home KD2DEY: If one writes a mission, then resets APM and gets (or already has) a GPS lock and then re-reads the mission and accepts the new home position in the MP dialog, then MP will reflect the position that APM actually uses. (BTW, pilots using absolute altitude (like me) should always do another reset because the APM accepts GPS fix too early - initial altitude is often way off. Doing a reset well after GPS fix and before takeoff helps.)
KD2DEY: What is a flight line? Anyway I see no trace of a feature that finds the distance between the 2 different home positions or anything at all that sets the actually used one (struct Location home) to the value of the uploaded one (waypoint number zero).
How about this, which should round up most issues mentioned: APM will use struct Location home for all navigation (as it does now). Reading the mission in MAVLink will return struct Location home as WP number zero (NOT the position in the currently EEPROM stored waypoint number zero). That's right, if you sit at your desk xxx km from your flying field and play with planning, reading and writing missions, the home position will be your desk and not your planned one. BUT this reflects what the APM would actually do and is therefore correct.
There is a new parameter HOMES_MAX_DIFFERENCE (or some better name). a) If HOMES_MAX_DIFFERENCE is zero, do like now: a1) At the time of the n'th good GPS fix, it will be written into struct Location home. a2) When a mission is written: Just store waypoint number zero without ever using it for anything. This is the current behavior.
b) else if HOMES_MAX_DIFFERENCE is positive b0) If HOMES_MAX_DIFFERENCE is very small, set it to some tolerance minimum like 50 meters. b1) At the time of n'th good GPS fix: If the distance between WP number zero and current GPS location is smaller than HOMES_MAX_DIFFERENCE , then write WP number zero into struct Location home. Else write current GPS pos. into struct Location home and flag the mission as suspicious. b2) When a mission is written: Same action as b1).
"Flagging a mission as suspicious" is for the case when a mission-planned home location is used, but the distance between that and the actual GPS startup home locations is large. It could consist of some sort of warning, or deleting or ignoring the mission.
One could also make a variation where the "HOMES_MAX_DIFFERENCE is positive" (b) behavior is always used but with a high default value of HOMES_MAX_DIFFERENCE. Does anybody ever need to be able to actually fly their missions very very far from the planned home position?
Soren Kuula
Soren, Thanks for the detailed analysis! To answer your question 'the flight line' is the location from which a pilot flies his plane when there is an organized flying site. This is usually at the near edge of the runway and all AMA sanctioned sites I have been at forbid flying behind the near edge (flight line) of the runway for safety reasons. If you lost control of your aircraft in this area it would be much more likely to cause injury of property damage. By allowing the home position to be set via the Mission Planner at set radial distance from the initial GPS lock location you could fulfill two requirements, first the home location could be moved in front of the pilots location instead of above satisfying the field rules that forbid flight behind the edge of the runway, and second if the location could be made semi-permanent as long as the stored location was within as you suggested HOMES_MAX_DISTANCE from the most recent GPS lock location then you wouldn't need to repeat the process of defining the home location when you are flying several times at the same site. I like the sound of your suggestions and hope we can see some form of this feature in a future release!
BTW Any idea why the MP has this feature to load the home position if it doesn't do anything?
Regards, Nathaniel ~KD2DEY
Iskess,
No I don't reset power after setting the home location with the MP. I wait for GPS lock then write the mission with the modified home location to the APM, I then clear the mission in the MP and read the way-points from the APM, when the MP asks if I want to save the home position with the loaded WP I say yes and voila the home position is where I want it to be. If I read it again it is once again where I want it to be, but it doesn't ask the question again. This had lead me to believe that I was doing it right. As dongfang (Soren) pointed out however this only sets the new 'home' location as WP0 in the mission script and is ignored in all flight modes......so it really doesn't appear to serve any purpose. Hopefully something will come of this in the next release. :)
Regards, Nathaniel ~KD2DEY
What I described about the MP was solely reading and writing missions. The set-home feature you mention, is that the "Home Location" clickable hypertext that is in the lower right corner of Flight Planner? It's probably just for loading the current pos. from APM to use in on-site mission planning. As described, this then becomes waypoint 0 and is not used for anything. We have an unorthodox and unsanctioned fliying site here and we love it :) I didn't know about the flight line. OK yes of course with such rules it would be nice to be able to tell APM where its de facto home should be. If somebody likes my idea of having a param that pulls the de facto home to where waypoint 0 is if they were not too far apart, I could make a prototype implementation. Just need to find out what to do if they are too far apart. Maybe simply doing like now (de facto home is the startup position) is OK. It is for the case where somebody takes off with mission for a different site loaded. Probably he will wonder where the h the plane is going. The plane should ignore the (wrong) mission and go to the startup position when he engages RTL. As it does now. Regards, Soren, OZ1ZOR & HB9FDK
That sounds perfect! Thank you for offering to write the code. I look forward to testing it.
Hmmmmm diydrones is down. I made a solution suggestion: https://github.com/dongfang/ardupilot/tree/StickyHome The fun is in init_home() in commands.pde and the 2 new parameters are STICKYHOME_RAD (stickyness radius in meters) and STICKYHOME_MAD (max altitude deviation in meters). Here is the blog post that I cannot send:
I wrote a feature for ArduPlane that allows the home position to be somewhere else than where the APM was started. This is useful for flight under "flight line" rules or if you want to ready your plane in one place and fly it from another.
The original APM behavior: Home position is set to one of the first positions the GPS reports after powerup. Even if you desired another position as home. The position is written into waypoint 0 too, so you will see the home position by (re)loading the mission into MP.
Modified behavior: There is a new parameter STICKYHOME_RAD, in meters. If the home position (as per the old way described above) is nearer than this from waypoint 0, it will be se to waypoint 0. Otherwise it will remain unchanged and the controls will wiggle 3 times. This allows one to set an alternative home position without risking a flyaway of more than STICKYHOME_RAD meters. In this version, I have removed the servo wiggling at normal startup because I find it unnecessary and it makes my planes rock'n'roll at gyro calibration. Wiggle = something is not as expected.
Waypoint 0 is only overwritten if it was previously undefined. Reading the mission, the waypoint 0 read is the one last written. Any reason to change that?
There are a few console messages too. It appears that not all get though because they come in a too rapid succession...
The home altitude may be quite inaccurate too, because GPS takes some time to get altitude right. If you fly with pure baro altimeter (ALT_MIX=1) and you use relative-altitude waypoints, you will not be affected. Funny enough, this is default. I fly in hilly terrain and need to check my missions carefully against Google Earth etc. and therefore need absolute altitude. I often get home altitudes that are 100s of feet off, potentially disastrous if not rejected.
To try solve that problem, the altitude of waypoint 0 is also used. If the horizontal distance to waypoint 0 was OK, the GPS altitude is compared to the waypoint 0 ditto. If off by less than STICKYHOME_MAD (Max Altitude Deviation), the altitude of waypoint 0 is used for home. Else, the controls will wiggle 5 times.
So all in all
*No wiggles: Waypoint 0 was undefined at startup, or both position and altitude were within bounds of waypoint 0 *3 wiggles: Position was not within bounds of waypoint 0. GPS position and altitude were used for home3 wiggles: *5 wiggles: Position was within bounds of waypoint 0 but not altitude. GPS altitude was used for home. Recommended action if using absolute altitude: Wait a few minutes, try reset APM.
For consideration: When reading the mission, should the EEPROM stored waypoint 0 be returned as waypoint 0, or should the actually used home position (which is the same if within bounds)?
Regards Soren Kuula
Thanks for your hard work Soren. This can really help Arduplane to be accepted at sanctioned fields where flight behind the near edge of the runway (aka over the pit areas filled with pilots and spectators) is strictly taboo. Most at my flying club are truly fascinated by this technology. Maybe this will make it into the next firmware release.
I would very much like to see the SET HOME feature in mission planner actually change the HOME POSITION in APM. I spent a bunch of time trying to figure out why APM wouldn't honour the new HOME position when I moved it using Mission Planner. I never did find out, until I came across this ' issues page' .
Perhaps a forth comming 'set Home' feature could also bet set manually by a switch on the TX and/or arming APM (like ACM) when it is in position for take off on the field.
This related issue: #1677 is in master now and will go out with AC3.3. It still relies on GCS changes to send the do-set-home message when we want to "lock" the home position. This isn't implemented for plane at the moment.
Support implemented on #1677