{"action":"created","comment":{"url":"https://api.github.com/repos/betaflight/betaflight/pulls/comments/188748606","pull_request_review_id":120790250,"id":188748606,"diff_hunk":"@@ -0,0 +1,373 @@\n+/*\n+ * This file is part of Betaflight.\n+ *\n+ * Betaflight is free software: you can redistribute it and/or modify\n+ * it under the terms of the GNU General Public License as published by\n+ * the Free Software Foundation, either version 3 of the License, or\n+ * (at your option) any later version.\n+ *\n+ * Betaflight is distributed in the hope that it will be useful,\n+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\n+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n+ * GNU General Public License for more details.\n+ *\n+ * You should have received a copy of the GNU General Public License\n+ * along with Betaflight. If not, see <http://www.gnu.org/licenses/>.\n+ */\n+\n+#include <stdint.h>\n+#include <math.h>\n+\n+#include \"common/axis.h\"\n+#include \"common/maths.h\"\n+\n+#include \"build/debug.h\"\n+\n+#include \"drivers/time.h\"\n+\n+#ifdef USE_GPS_RESCUE\n+\n+#include \"io/gps.h\"\n+\n+#include \"fc/fc_core.h\"\n+#include \"fc/runtime_config.h\"\n+#include \"fc/config.h\"\n+#include \"fc/rc_controls.h\"\n+\n+#include \"flight/position.h\"\n+#include \"flight/failsafe.h\"\n+#include \"flight/gps_rescue.h\"\n+#include \"flight/imu.h\"\n+#include \"flight/pid.h\"\n+\n+#include \"rx/rx.h\"\n+\n+#include \"sensors/acceleration.h\"\n+\n+int32_t       gpsRescueAngle[ANGLE_INDEX_COUNT] = { 0, 0 };\n+uint16_t      hoverThrottle = 0;\n+float         averageThrottle = 0.0;\n+float         altitudeError = 0.0;\n+uint32_t      throttleSamples = 0;\n+\n+static bool newGPSData = false;\n+\n+rescueState_s rescueState;\n+\n+/*\n+ If we have new GPS data, update home heading\n+ if possible and applicable.\n+*/\n+void rescueNewGpsData(void)\n+{\n+\n+   if (!ARMING_FLAG(ARMED))\n+    GPS_reset_home_position();","path":"src/main/flight/gps_rescue.c","position":65,"original_position":65,"commit_id":"58a93e8df65b38828132bc31f2bd22e8733fceea","original_commit_id":"58a93e8df65b38828132bc31f2bd22e8733fceea","user":{"login":"dbasch","id":383700,"avatar_url":"https://avatars1.githubusercontent.com/u/383700?v=4","gravatar_id":"","url":"https://api.github.com/users/dbasch","html_url":"https://github.com/dbasch","followers_url":"https://api.github.com/users/dbasch/followers","following_url":"https://api.github.com/users/dbasch/following{/other_user}","gists_url":"https://api.github.com/users/dbasch/gists{/gist_id}","starred_url":"https://api.github.com/users/dbasch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dbasch/subscriptions","organizations_url":"https://api.github.com/users/dbasch/orgs","repos_url":"https://api.github.com/users/dbasch/repos","events_url":"https://api.github.com/users/dbasch/events{/privacy}","received_events_url":"https://api.github.com/users/dbasch/received_events","type":"User","site_admin":false},"body":"Fixed.","created_at":"2018-05-16T19:41:14Z","updated_at":"2018-05-16T19:41:14Z","html_url":"https://github.com/betaflight/betaflight/pull/5899#discussion_r188748606","pull_request_url":"https://api.github.com/repos/betaflight/betaflight/pulls/5899","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/betaflight/betaflight/pulls/comments/188748606"},"html":{"href":"https://github.com/betaflight/betaflight/pull/5899#discussion_r188748606"},"pull_request":{"href":"https://api.github.com/repos/betaflight/betaflight/pulls/5899"}},"in_reply_to_id":188596957},"pull_request":{"url":"https://api.github.com/repos/betaflight/betaflight/pulls/5899","id":188263531,"html_url":"https://github.com/betaflight/betaflight/pull/5899","diff_url":"https://github.com/betaflight/betaflight/pull/5899.diff","patch_url":"https://github.com/betaflight/betaflight/pull/5899.patch","issue_url":"https://api.github.com/repos/betaflight/betaflight/issues/5899","number":5899,"state":"open","locked":false,"title":"[GPS RESCUE] - Add GPS rescue as a flight mode and failsafe mode","user":{"login":"s0up","id":863391,"avatar_url":"https://avatars3.githubusercontent.com/u/863391?v=4","gravatar_id":"","url":"https://api.github.com/users/s0up","html_url":"https://github.com/s0up","followers_url":"https://api.github.com/users/s0up/followers","following_url":"https://api.github.com/users/s0up/following{/other_user}","gists_url":"https://api.github.com/users/s0up/gists{/gist_id}","starred_url":"https://api.github.com/users/s0up/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/s0up/subscriptions","organizations_url":"https://api.github.com/users/s0up/orgs","repos_url":"https://api.github.com/users/s0up/repos","events_url":"https://api.github.com/users/s0up/events{/privacy}","received_events_url":"https://api.github.com/users/s0up/received_events","type":"User","site_admin":false},"body":"This is the addition of GPS Rescue Mode.   There has been a lot of work (and ruined quads) put into this by @dbasch and @s0up (me), and it is by no means perfect, but we are replacing a fairly large chunk of broken code (Cleanflight navigation code) with something that does work when the circumstances are right.\r\n\r\nThe motivation for this feature is simply the belief that for almost anybody doing semi long-range freestyle, the ability to have your quad get back within radio/video line of sight upon a major failure is a huge bonus when flying over terrain that makes recovery dangerous or unlikely.\r\n\r\nThis is not meant to be some DJI phantom style RTH, but simply a better alternative in some situations to dropping out of the sky on failsafe.  If you have a good GPS lock, this mode has a very good chance of getting your multirotor back home. This is not meant to be activated from 50 meters away in a park full of people.\r\n\r\nThere is a lot of room for improvement (some of which is already in the works), and it will be exciting to see what the community does with this.  ","created_at":"2018-05-15T21:39:51Z","updated_at":"2018-05-16T19:41:14Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b9e15374da3b475892527d33c18be499c52f1784","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/betaflight/betaflight/pulls/5899/commits","review_comments_url":"https://api.github.com/repos/betaflight/betaflight/pulls/5899/comments","review_comment_url":"https://api.github.com/repos/betaflight/betaflight/pulls/comments{/number}","comments_url":"https://api.github.com/repos/betaflight/betaflight/issues/5899/comments","statuses_url":"https://api.github.com/repos/betaflight/betaflight/statuses/58a93e8df65b38828132bc31f2bd22e8733fceea","head":{"label":"dbasch:gps_rescue_beta","ref":"gps_rescue_beta","sha":"58a93e8df65b38828132bc31f2bd22e8733fceea","user":{"login":"dbasch","id":383700,"avatar_url":"https://avatars1.githubusercontent.com/u/383700?v=4","gravatar_id":"","url":"https://api.github.com/users/dbasch","html_url":"https://github.com/dbasch","followers_url":"https://api.github.com/users/dbasch/followers","following_url":"https://api.github.com/users/dbasch/following{/other_user}","gists_url":"https://api.github.com/users/dbasch/gists{/gist_id}","starred_url":"https://api.github.com/users/dbasch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dbasch/subscriptions","organizations_url":"https://api.github.com/users/dbasch/orgs","repos_url":"https://api.github.com/users/dbasch/repos","events_url":"https://api.github.com/users/dbasch/events{/privacy}","received_events_url":"https://api.github.com/users/dbasch/received_events","type":"User","site_admin":false},"repo":{"id":121027334,"name":"betaflight","full_name":"dbasch/betaflight","owner":{"login":"dbasch","id":383700,"avatar_url":"https://avatars1.githubusercontent.com/u/383700?v=4","gravatar_id":"","url":"https://api.github.com/users/dbasch","html_url":"https://github.com/dbasch","followers_url":"https://api.github.com/users/dbasch/followers","following_url":"https://api.github.com/users/dbasch/following{/other_user}","gists_url":"https://api.github.com/users/dbasch/gists{/gist_id}","starred_url":"https://api.github.com/users/dbasch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dbasch/subscriptions","organizations_url":"https://api.github.com/users/dbasch/orgs","repos_url":"https://api.github.com/users/dbasch/repos","events_url":"https://api.github.com/users/dbasch/events{/privacy}","received_events_url":"https://api.github.com/users/dbasch/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/dbasch/betaflight","description":null,"fork":true,"url":"https://api.github.com/repos/dbasch/betaflight","forks_url":"https://api.github.com/repos/dbasch/betaflight/forks","keys_url":"https://api.github.com/repos/dbasch/betaflight/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dbasch/betaflight/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dbasch/betaflight/teams","hooks_url":"https://api.github.com/repos/dbasch/betaflight/hooks","issue_events_url":"https://api.github.com/repos/dbasch/betaflight/issues/events{/number}","events_url":"https://api.github.com/repos/dbasch/betaflight/events","assignees_url":"https://api.github.com/repos/dbasch/betaflight/assignees{/user}","branches_url":"https://api.github.com/repos/dbasch/betaflight/branches{/branch}","tags_url":"https://api.github.com/repos/dbasch/betaflight/tags","blobs_url":"https://api.github.com/repos/dbasch/betaflight/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dbasch/betaflight/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dbasch/betaflight/git/refs{/sha}","trees_url":"https://api.github.com/repos/dbasch/betaflight/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dbasch/betaflight/statuses/{sha}","languages_url":"https://api.github.com/repos/dbasch/betaflight/languages","stargazers_url":"https://api.github.com/repos/dbasch/betaflight/stargazers","contributors_url":"https://api.github.com/repos/dbasch/betaflight/contributors","subscribers_url":"https://api.github.com/repos/dbasch/betaflight/subscribers","subscription_url":"https://api.github.com/repos/dbasch/betaflight/subscription","commits_url":"https://api.github.com/repos/dbasch/betaflight/commits{/sha}","git_commits_url":"https://api.github.com/repos/dbasch/betaflight/git/commits{/sha}","comments_url":"https://api.github.com/repos/dbasch/betaflight/comments{/number}","issue_comment_url":"https://api.github.com/repos/dbasch/betaflight/issues/comments{/number}","contents_url":"https://api.github.com/repos/dbasch/betaflight/contents/{+path}","compare_url":"https://api.github.com/repos/dbasch/betaflight/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dbasch/betaflight/merges","archive_url":"https://api.github.com/repos/dbasch/betaflight/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dbasch/betaflight/downloads","issues_url":"https://api.github.com/repos/dbasch/betaflight/issues{/number}","pulls_url":"https://api.github.com/repos/dbasch/betaflight/pulls{/number}","milestones_url":"https://api.github.com/repos/dbasch/betaflight/milestones{/number}","notifications_url":"https://api.github.com/repos/dbasch/betaflight/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dbasch/betaflight/labels{/name}","releases_url":"https://api.github.com/repos/dbasch/betaflight/releases{/id}","deployments_url":"https://api.github.com/repos/dbasch/betaflight/deployments","created_at":"2018-02-10T15:29:06Z","updated_at":"2018-05-15T19:58:52Z","pushed_at":"2018-05-16T19:40:38Z","git_url":"git://github.com/dbasch/betaflight.git","ssh_url":"git@github.com:dbasch/betaflight.git","clone_url":"https://github.com/dbasch/betaflight.git","svn_url":"https://github.com/dbasch/betaflight","homepage":"","size":225681,"stargazers_count":1,"watchers_count":1,"language":"C","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"archived":false,"open_issues_count":3,"license":{"key":"gpl-3.0","name":"GNU General Public License v3.0","spdx_id":"GPL-3.0","url":"https://api.github.com/licenses/gpl-3.0"},"forks":1,"open_issues":3,"watchers":1,"default_branch":"master"}},"base":{"label":"betaflight:master","ref":"master","sha":"e405e41d0ca18c434ee9a058232af520fb7b8f7e","user":{"login":"betaflight","id":19597933,"avatar_url":"https://avatars1.githubusercontent.com/u/19597933?v=4","gravatar_id":"","url":"https://api.github.com/users/betaflight","html_url":"https://github.com/betaflight","followers_url":"https://api.github.com/users/betaflight/followers","following_url":"https://api.github.com/users/betaflight/following{/other_user}","gists_url":"https://api.github.com/users/betaflight/gists{/gist_id}","starred_url":"https://api.github.com/users/betaflight/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/betaflight/subscriptions","organizations_url":"https://api.github.com/users/betaflight/orgs","repos_url":"https://api.github.com/users/betaflight/repos","events_url":"https://api.github.com/users/betaflight/events{/privacy}","received_events_url":"https://api.github.com/users/betaflight/received_events","type":"Organization","site_admin":false},"repo":{"id":37060852,"name":"betaflight","full_name":"betaflight/betaflight","owner":{"login":"betaflight","id":19597933,"avatar_url":"https://avatars1.githubusercontent.com/u/19597933?v=4","gravatar_id":"","url":"https://api.github.com/users/betaflight","html_url":"https://github.com/betaflight","followers_url":"https://api.github.com/users/betaflight/followers","following_url":"https://api.github.com/users/betaflight/following{/other_user}","gists_url":"https://api.github.com/users/betaflight/gists{/gist_id}","starred_url":"https://api.github.com/users/betaflight/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/betaflight/subscriptions","organizations_url":"https://api.github.com/users/betaflight/orgs","repos_url":"https://api.github.com/users/betaflight/repos","events_url":"https://api.github.com/users/betaflight/events{/privacy}","received_events_url":"https://api.github.com/users/betaflight/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/betaflight/betaflight","description":"Open Source Flight Controller Firmware","fork":false,"url":"https://api.github.com/repos/betaflight/betaflight","forks_url":"https://api.github.com/repos/betaflight/betaflight/forks","keys_url":"https://api.github.com/repos/betaflight/betaflight/keys{/key_id}","collaborators_url":"https://api.github.com/repos/betaflight/betaflight/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/betaflight/betaflight/teams","hooks_url":"https://api.github.com/repos/betaflight/betaflight/hooks","issue_events_url":"https://api.github.com/repos/betaflight/betaflight/issues/events{/number}","events_url":"https://api.github.com/repos/betaflight/betaflight/events","assignees_url":"https://api.github.com/repos/betaflight/betaflight/assignees{/user}","branches_url":"https://api.github.com/repos/betaflight/betaflight/branches{/branch}","tags_url":"https://api.github.com/repos/betaflight/betaflight/tags","blobs_url":"https://api.github.com/repos/betaflight/betaflight/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/betaflight/betaflight/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/betaflight/betaflight/git/refs{/sha}","trees_url":"https://api.github.com/repos/betaflight/betaflight/git/trees{/sha}","statuses_url":"https://api.github.com/repos/betaflight/betaflight/statuses/{sha}","languages_url":"https://api.github.com/repos/betaflight/betaflight/languages","stargazers_url":"https://api.github.com/repos/betaflight/betaflight/stargazers","contributors_url":"https://api.github.com/repos/betaflight/betaflight/contributors","subscribers_url":"https://api.github.com/repos/betaflight/betaflight/subscribers","subscription_url":"https://api.github.com/repos/betaflight/betaflight/subscription","commits_url":"https://api.github.com/repos/betaflight/betaflight/commits{/sha}","git_commits_url":"https://api.github.com/repos/betaflight/betaflight/git/commits{/sha}","comments_url":"https://api.github.com/repos/betaflight/betaflight/comments{/number}","issue_comment_url":"https://api.github.com/repos/betaflight/betaflight/issues/comments{/number}","contents_url":"https://api.github.com/repos/betaflight/betaflight/contents/{+path}","compare_url":"https://api.github.com/repos/betaflight/betaflight/compare/{base}...{head}","merges_url":"https://api.github.com/repos/betaflight/betaflight/merges","archive_url":"https://api.github.com/repos/betaflight/betaflight/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/betaflight/betaflight/downloads","issues_url":"https://api.github.com/repos/betaflight/betaflight/issues{/number}","pulls_url":"https://api.github.com/repos/betaflight/betaflight/pulls{/number}","milestones_url":"https://api.github.com/repos/betaflight/betaflight/milestones{/number}","notifications_url":"https://api.github.com/repos/betaflight/betaflight/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/betaflight/betaflight/labels{/name}","releases_url":"https://api.github.com/repos/betaflight/betaflight/releases{/id}","deployments_url":"https://api.github.com/repos/betaflight/betaflight/deployments","created_at":"2015-06-08T10:37:44Z","updated_at":"2018-05-16T19:11:25Z","pushed_at":"2018-05-16T19:11:15Z","git_url":"git://github.com/betaflight/betaflight.git","ssh_url":"git@github.com:betaflight/betaflight.git","clone_url":"https://github.com/betaflight/betaflight.git","svn_url":"https://github.com/betaflight/betaflight","homepage":"","size":225261,"stargazers_count":1678,"watchers_count":1678,"language":"C","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":829,"mirror_url":null,"archived":false,"open_issues_count":210,"license":{"key":"gpl-3.0","name":"GNU General Public License v3.0","spdx_id":"GPL-3.0","url":"https://api.github.com/licenses/gpl-3.0"},"forks":829,"open_issues":210,"watchers":1678,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/betaflight/betaflight/pulls/5899"},"html":{"href":"https://github.com/betaflight/betaflight/pull/5899"},"issue":{"href":"https://api.github.com/repos/betaflight/betaflight/issues/5899"},"comments":{"href":"https://api.github.com/repos/betaflight/betaflight/issues/5899/comments"},"review_comments":{"href":"https://api.github.com/repos/betaflight/betaflight/pulls/5899/comments"},"review_comment":{"href":"https://api.github.com/repos/betaflight/betaflight/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/betaflight/betaflight/pulls/5899/commits"},"statuses":{"href":"https://api.github.com/repos/betaflight/betaflight/statuses/58a93e8df65b38828132bc31f2bd22e8733fceea"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"dbasch"}}