{"action":"created","issue":{"url":"https://api.github.com/repos/PX4/Firmware/issues/2315","labels_url":"https://api.github.com/repos/PX4/Firmware/issues/2315/labels{/name}","comments_url":"https://api.github.com/repos/PX4/Firmware/issues/2315/comments","events_url":"https://api.github.com/repos/PX4/Firmware/issues/2315/events","html_url":"https://github.com/PX4/Firmware/issues/2315","id":86913750,"number":2315,"title":"set_nav_state() implementation looks fishy","user":{"login":"devbharat","id":3105122,"avatar_url":"https://avatars.githubusercontent.com/u/3105122?v=3","gravatar_id":"","url":"https://api.github.com/users/devbharat","html_url":"https://github.com/devbharat","followers_url":"https://api.github.com/users/devbharat/followers","following_url":"https://api.github.com/users/devbharat/following{/other_user}","gists_url":"https://api.github.com/users/devbharat/gists{/gist_id}","starred_url":"https://api.github.com/users/devbharat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/devbharat/subscriptions","organizations_url":"https://api.github.com/users/devbharat/orgs","repos_url":"https://api.github.com/users/devbharat/repos","events_url":"https://api.github.com/users/devbharat/events{/privacy}","received_events_url":"https://api.github.com/users/devbharat/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-06-10T10:10:49Z","updated_at":"2015-06-12T07:51:59Z","closed_at":"2015-06-12T07:51:59Z","body":"In the file \r\n\r\nhttps://github.com/PX4/Firmware/blob/master/src/modules/commander/state_machine_helper.cpp \r\n\r\nin the implementation of bool set_nav_state(), there is a cascaded switch-case statement with the same expression (status->main_state) as the expression of the outer switch-case statement. Line 538 and 558. \r\n\r\n    switch (status->main_state) {\r\n        case vehicle_status_s::MAIN_STATE_ACRO:\r\n        case vehicle_status_s::MAIN_STATE_MANUAL:\r\n        case vehicle_status_s::MAIN_STATE_ALTCTL:\r\n        case vehicle_status_s::MAIN_STATE_POSCTL:\r\n            if ((status->rc_signal_lost || status->rc_signal_lost_cmd) && armed) {\r\n\t\t\tstatus->failsafe = true;\r\n\r\n\t\t\tif (status->condition_global_position_valid && status->condition_home_position_valid) {\r\n\t\t\t\tstatus->nav_state = vehicle_status_s::NAVIGATION_STATE_AUTO_RCRECOVER;\r\n\t\t\t} else if (status->condition_local_position_valid) {\r\n\t\t\t\tstatus->nav_state = vehicle_status_s::NAVIGATION_STATE_LAND;\r\n\t\t\t} else if (status->condition_local_altitude_valid) {\r\n\t\t\t\tstatus->nav_state = vehicle_status_s::NAVIGATION_STATE_DESCEND;\r\n\t\t\t} else {\r\n\t\t\t\tstatus->nav_state = vehicle_status_s::NAVIGATION_STATE_TERMINATION;\r\n\t\t\t}\r\n\r\n            } else {\r\n\t\t\tswitch (status->main_state) {\r\n\t\t\tcase vehicle_status_s::MAIN_STATE_ACRO:\r\n\t\t\t\tstatus->nav_state = vehicle_status_s::NAVIGATION_STATE_ACRO;\r\n\t\t\t\tbreak;\r\n\r\n\t\t\tcase vehicle_status_s::MAIN_STATE_MANUAL:\r\n\t\t\t\tstatus->nav_state = vehicle_status_s::NAVIGATION_STATE_MANUAL;\r\n\t\t\t\tbreak;"},"comment":{"url":"https://api.github.com/repos/PX4/Firmware/issues/comments/111397652","html_url":"https://github.com/PX4/Firmware/issues/2315#issuecomment-111397652","issue_url":"https://api.github.com/repos/PX4/Firmware/issues/2315","id":111397652,"user":{"login":"devbharat","id":3105122,"avatar_url":"https://avatars.githubusercontent.com/u/3105122?v=3","gravatar_id":"","url":"https://api.github.com/users/devbharat","html_url":"https://github.com/devbharat","followers_url":"https://api.github.com/users/devbharat/followers","following_url":"https://api.github.com/users/devbharat/following{/other_user}","gists_url":"https://api.github.com/users/devbharat/gists{/gist_id}","starred_url":"https://api.github.com/users/devbharat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/devbharat/subscriptions","organizations_url":"https://api.github.com/users/devbharat/orgs","repos_url":"https://api.github.com/users/devbharat/repos","events_url":"https://api.github.com/users/devbharat/events{/privacy}","received_events_url":"https://api.github.com/users/devbharat/received_events","type":"User","site_admin":false},"created_at":"2015-06-12T07:51:59Z","updated_at":"2015-06-12T07:51:59Z","body":"I agree."}}