Changeset 83 in flair-src for branches/mavlink/tools/Controller/Mavlink
- Timestamp:
- Sep 21, 2016, 5:49:17 PM (8 years ago)
- Location:
- branches/mavlink/tools/Controller/Mavlink/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/mavlink/tools/Controller/Mavlink/src/GuiGcs.cpp
r82 r83 27 27 #include <ListWidget.h> 28 28 29 //todo remove for tests30 29 #include <iostream> 30 #include <array> 31 31 32 32 using namespace std; 33 33 using namespace flair::core; 34 34 using namespace flair::gui; 35 36 const std::string delimiter = "|"; 35 37 36 38 GuiGcs::GuiGcs(const FrameworkManager *parent, string name, … … 74 76 void GuiGcs::MissionStop() { 75 77 cout << "MavPlanner GuiGcs MissionStop" << endl; 76 outputSocket->SendMessage("MavPlanner GuiGcs MissionStop");77 78 } 78 79 79 80 void GuiGcs::MissionResume() { 80 81 cout << "MavPlanner GuiGcs MissionResume" << endl; 81 outputSocket->SendMessage("MavPlanner GuiGcs MissionResume");82 82 } 83 83 … … 103 103 // sending mission items 104 104 cout << "[INFO] Mission items.\n"; 105 std::string delimiter = "|";106 105 for (auto &missionCommand : missionCommandList) { 107 106 cout << "[INFO] Mission item : " << missionCommand << "\n"; … … 109 108 std::string command = missionCommand.substr(0, missionCommand.find(delimiter)); 110 109 missionCommand.erase(0, missionCommand.find(delimiter) + delimiter.length()); 111 // Parse param1 112 float param1 = std::stof(missionCommand.substr(0, missionCommand.find(delimiter))); 113 missionCommand.erase(0, missionCommand.find(delimiter) + delimiter.length()); 114 // Parse param2 115 float param2 = std::stof(missionCommand.substr(0, missionCommand.find(delimiter))); 116 missionCommand.erase(0, missionCommand.find(delimiter) + delimiter.length()); 117 // Parse param3 118 float param3 = std::stof(missionCommand.substr(0, missionCommand.find(delimiter))); 119 missionCommand.erase(0, missionCommand.find(delimiter) + delimiter.length()); 120 // Parse latitude 121 float latitude = std::stof(missionCommand.substr(0, missionCommand.find(delimiter))); 122 missionCommand.erase(0, missionCommand.find(delimiter) + delimiter.length()); 123 // Parse longitude 124 float longitude = std::stof(missionCommand.substr(0, missionCommand.find(delimiter))); 125 missionCommand.erase(0, missionCommand.find(delimiter) + delimiter.length()); 126 // Parse altitude 127 float altitude = std::stof(missionCommand.substr(0, missionCommand.find(delimiter))); 128 missionCommand.erase(0, missionCommand.find(delimiter) + delimiter.length()); 129 // cout << "[INFO] Mission item commands : " << command << ", " << param1 << ", " << param2 << ", " << param3 << std::endl; 130 mavCom->sendMissionItem(mavCom->target.getSysID(), mavCom->target.getCompID(), 0, MAV_FRAME_GLOBAL_RELATIVE_ALT, MavCommandGet(command), 0, 1, param1, param2, param3, 0, latitude, longitude, altitude); 110 std::array<float, 6> missionParameters; 111 ParametersParse(missionCommand, missionParameters); 112 113 mavCom->sendMissionItem(mavCom->target.getSysID(), mavCom->target.getCompID(), 0, MAV_FRAME_GLOBAL_RELATIVE_ALT, MavCommandGet(command), 0, 1, 114 missionParameters[0], missionParameters[1], missionParameters[2], 0, missionParameters[3], missionParameters[4], missionParameters[5]); 131 115 mavCom->waitMissionAck(ACK_TIMEOUT); 132 116 } … … 142 126 } 143 127 128 void GuiGcs::ParametersParse(const std::string& parametersString, std::array<float, 6>& parametersFloat) { 129 std::string parametersBuffer = parametersString; 130 for (int count = 0; count < parametersFloat.size(); count++) { 131 parametersFloat[count] = std::stof(parametersBuffer.substr(0, parametersBuffer.find(delimiter))); 132 parametersBuffer.erase(0, parametersBuffer.find(delimiter) + delimiter.length()); 133 } 134 } 135 144 136 uint16_t GuiGcs::MavCommandGet(const std::string& command) const { 145 137 uint16_t returnValue = -1; -
branches/mavlink/tools/Controller/Mavlink/src/GuiGcs.h
r82 r83 21 21 22 22 #include <string> 23 #include <array> 23 24 24 25 #include "GuiInterface.h" … … 53 54 54 55 private: 55 flair::core::Socket *outputSocket;56 56 std::string outputAddress; 57 57 int outputPort; … … 60 60 61 61 void Initialize(); 62 void ParametersParse(const std::string& parametersString, std::array<float, 6>& parametersFloat); 62 63 }; 63 64
Note:
See TracChangeset
for help on using the changeset viewer.