Changeset 79 in flair-src for branches/mavlink/tools/Controller
- Timestamp:
- Sep 21, 2016, 2:51:44 PM (8 years ago)
- Location:
- branches/mavlink/tools/Controller/Mavlink/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/mavlink/tools/Controller/Mavlink/src/GuiGcs.cpp
r77 r79 22 22 #include <FrameworkManager.h> 23 23 24 #include "MavlinkUDP.h" 25 26 #include <ListWidget.h> 27 24 28 //todo remove for tests 25 29 #include <iostream> … … 33 37 GuiInterface(parent, name) { 34 38 cout << "MavPlanner GuiGcs constructor" << endl; 35 outputSocket = new Socket((Thread *)this, "output socket", outputAddress + ":" + to_string(outputPort)); 39 //outputSocket = new Socket((Thread *)this, "output socket", outputAddress + ":" + to_string(outputPort)); 40 41 mavCom = new MavlinkUDP(outputAddress, outputPort); 42 if (mavCom) { 43 // mavCom->startThreads(); 44 } else { 45 //TODO handle the error 46 } 47 36 48 } 37 49 38 50 GuiGcs::~GuiGcs() { 39 51 if (mavCom) { 52 mavCom->stopThreads(); 53 delete mavCom; 54 } 40 55 } 41 56 … … 57 72 void GuiGcs::MissionSend() { 58 73 cout << "MavPlanner GuiGcs MissionSend" << endl; 74 75 76 // upload a flight plan 77 cout << "---------------\n"; 78 cout << "Flight planning \n"; 79 cout << "---------------\n"; 80 81 // get the list of commands to send 82 std::vector<std::string> missionCommandList = listMissionItems->GetItemList(); 83 84 // reset all the previous waypoints 85 mavCom->sendMissionClearAll(mavCom->target.getSysID(), mavCom->target.getCompID()); 86 87 cout << "[INFO] Mission write partial list.\n"; 88 // write partial list, takeoff + 4 waypoints + land 89 mavCom->sendMissionWritePartialList(mavCom->target.getSysID(),mavCom->target.getCompID(), 0, missionCommandList.size()); 90 mavCom->waitMissionAck(ACK_TIMEOUT); 91 92 // sending mission items 93 cout << "[INFO] Mission items.\n"; 94 std::string delimiter = "|"; 95 for (auto &missionCommand : missionCommandList) { 96 cout << "[INFO] Mission item : " << missionCommand << "\n"; 97 // Parse command 98 std::string command = missionCommand.substr(0, missionCommand.find(delimiter)); 99 missionCommand.erase(0, missionCommand.find(delimiter) + delimiter.length()); 100 // Parse param1 101 float param1 = std::stof(missionCommand.substr(0, missionCommand.find(delimiter))); 102 missionCommand.erase(0, missionCommand.find(delimiter) + delimiter.length()); 103 // Parse param2 104 float param2 = std::stof(missionCommand.substr(0, missionCommand.find(delimiter))); 105 missionCommand.erase(0, missionCommand.find(delimiter) + delimiter.length()); 106 // Parse param3 107 float param3 = std::stof(missionCommand.substr(0, missionCommand.find(delimiter))); 108 // cout << "[INFO] Mission item commands : " << command << ", " << param1 << ", " << param2 << ", " << param3 << std::endl; 109 mavCom->sendMissionItem(mavCom->target.getSysID(), mavCom->target.getCompID(), 0, MAV_FRAME_GLOBAL_RELATIVE_ALT, MavCommandGet(command), 0, 1, 0, 0, 0, 0, param1, param2, param3); 110 mavCom->waitMissionAck(ACK_TIMEOUT); 111 } 112 113 cout << "[INFO] Check mission item list.\n"; 114 // mission request list (to check) 115 mavCom->sendMissionRequestList(mavCom->target.getSysID(), mavCom->target.getCompID()); 116 //mavCom.waitMissionCount(ACK_TIMEOUT); 117 118 cout << "----------------\n"; 119 cout << "Flight plan sent \n"; 120 cout << "----------------\n"; 59 121 } 122 123 uint16_t GuiGcs::MavCommandGet(const std::string& command) const { 124 uint16_t returnValue = -1; 125 if (command == "WAYPOINT") { 126 returnValue = MAV_CMD_NAV_WAYPOINT; 127 } 128 if (command == "TAKEOFF") { 129 returnValue = MAV_CMD_NAV_TAKEOFF; 130 } 131 if (command == "LAND") { 132 returnValue = MAV_CMD_NAV_LAND; 133 } 134 if (command == "RETURN") { 135 returnValue = MAV_CMD_NAV_RETURN_TO_LAUNCH; 136 } 137 if (command == "JUMP") { 138 returnValue = MAV_CMD_DO_JUMP; 139 } 140 return returnValue; 141 } -
branches/mavlink/tools/Controller/Mavlink/src/GuiGcs.h
r77 r79 23 23 #include "GuiInterface.h" 24 24 25 #include "MavlinkUDP.h" 26 25 27 namespace flair { 26 28 namespace core { … … 44 46 virtual void MissionSend(); 45 47 48 uint16_t MavCommandGet(const std::string& command) const; 49 46 50 private: 47 51 flair::core::Socket *outputSocket; 48 52 std::string outputAddress; 49 53 int outputPort; 54 55 MavlinkUDP* mavCom; 50 56 }; 51 57 -
branches/mavlink/tools/Controller/Mavlink/src/GuiInterface.cpp
r77 r79 120 120 // Buttons to control GUI 121 121 if (btnAddMissionCmd->Clicked()) { 122 //TODO123 122 listMissionItems->AddItem(MissionCmdGet()); 124 123 }
Note:
See TracChangeset
for help on using the changeset viewer.