{"action":"opened","issue":{"url":"https://api.github.com/repos/mitre/FMACM/issues/6","labels_url":"https://api.github.com/repos/mitre/FMACM/issues/6/labels{/name}","comments_url":"https://api.github.com/repos/mitre/FMACM/issues/6/comments","events_url":"https://api.github.com/repos/mitre/FMACM/issues/6/events","html_url":"https://github.com/mitre/FMACM/issues/6","id":93815282,"number":6,"title":"FlightManagementSystem if-loop necessary?","user":{"login":"sbowman-mitre","id":12277219,"avatar_url":"https://avatars.githubusercontent.com/u/12277219?v=3","gravatar_id":"","url":"https://api.github.com/users/sbowman-mitre","html_url":"https://github.com/sbowman-mitre","followers_url":"https://api.github.com/users/sbowman-mitre/followers","following_url":"https://api.github.com/users/sbowman-mitre/following{/other_user}","gists_url":"https://api.github.com/users/sbowman-mitre/gists{/gist_id}","starred_url":"https://api.github.com/users/sbowman-mitre/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sbowman-mitre/subscriptions","organizations_url":"https://api.github.com/users/sbowman-mitre/orgs","repos_url":"https://api.github.com/users/sbowman-mitre/repos","events_url":"https://api.github.com/users/sbowman-mitre/events{/privacy}","received_events_url":"https://api.github.com/users/sbowman-mitre/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-07-08T15:13:31Z","updated_at":"2015-07-08T15:13:31Z","closed_at":null,"body":"In #5, @HonJinghua identified some code in FlightManagmentSystem{} that looks odd. I'm reposting here as a separate issue.\r\n\r\nThe vector preCal_Wpt in FlightManagementSystem::update() in FlightManagementSystem.cpp are pushed from HPT_1 to HPT_8. So the constraint_dist are vectored starting from the endpoint in function TrajectoryFromFile::calculateWaypoints() . So precalcWaypoints[ix].constraints.constraint_dist is greater than precalcWaypoints[ix-1].constraints.constraint_dist, the condition below will always be failed.\r\n\r\n```c++\r\n    for (int ix = 1;(ix if ((currDist < precalcWaypoints[ix-1].constraints.constraint_dist) &&\r\n       (currDist >= precalcWaypoints[ix].constraints.constraint_dist)) \r\n    {\r\n           this->NextWp = ix;\r\n           break;\r\n    }\r\n```\r\n\r\nCurrent our solution is \r\n\r\n```c++\r\nfor (int ix = 1;(ix if ((currDist >= precalcWaypoints[ix-1].constraints.constraint_dist) &&\r\n    (currDist < precalcWaypoints[ix].constraints.constraint_dist)) \r\n    {\r\n        this->NextWp = 8-ix;\r\n        break;\r\n    }\r\n```\r\n\r\n"}}