Changeset 55 in flair-src
- Timestamp:
- Jul 28, 2016, 5:55:31 PM (8 years ago)
- Location:
- trunk/lib
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/FlairCore/src/FrameworkManager.cpp
r45 r55 133 133 } 134 134 135 void FrameworkManager::SetupConnection(string address, uint16_t port, 135 void FrameworkManager::SetupConnection(string address, uint16_t port,Time watchdogTimeout, 136 136 size_t rcv_buf_size) { 137 137 pimpl_->SetupConnection(address, port, rcv_buf_size); … … 143 143 144 144 gui::TabWidget *FrameworkManager::GetTabWidget(void) const { 145 if(pimpl_->tabwidget==NULL) Err("SetupUserInterface must be called before\n"); 145 146 return pimpl_->tabwidget; 146 147 } -
trunk/lib/FlairCore/src/FrameworkManager.h
r15 r55 19 19 20 20 namespace flair { 21 namespace gui {22 class TabWidget;23 class SendData;24 }21 namespace gui { 22 class TabWidget; 23 class SendData; 24 } 25 25 } 26 26 namespace flair { … … 69 69 * 70 70 * Call this method just after the constructor of this class. If this method is 71 *not called, the program will run headless. 71 * not called, the program will run headless. 72 * If this method is called, SetupUserInterface must also be called after this. 72 73 * 73 74 * \param address address of ground station 74 75 * \param port port of ground station 76 * \param watchdogTimeout watchdog timeout for the connection, passing TIME_INFINITE will disable the watchdog 75 77 * \param rcv_buf_size receive buffer size 76 78 */ 77 void SetupConnection(std::string address, uint16_t port, 79 void SetupConnection(std::string address, uint16_t port,Time watchdogTimeout=(Time)1000000000, 78 80 size_t rcv_buf_size = 10000); 79 81 … … 82 84 * 83 85 * If this method is called after SetupConnection, Widgets will be displayed in 84 *the ground station. 85 * Otherwise, it will run headless, but default values of Widgets will be taken 86 *from the xml file. 86 * the ground station. 87 * If this method is called and SetupConnection was not called, it will run headless but default values of Widgets will be taken 88 * from the xml file. 89 * If this method is not called, Widgets will not be available. Constructing an object based on Widget class will fail. 87 90 * 88 91 * \param xml_file xml file for default values of Widgets -
trunk/lib/FlairCore/src/FrameworkManager_impl.cpp
r51 r55 103 103 gcs_watchdog = NULL; 104 104 _this = this; 105 tabwidget=NULL; 105 106 106 107 // Avoids memory swapping for this program … … 193 194 } 194 195 195 void FrameworkManager_impl::SetupConnection(string address, uint16_t port, 196 void FrameworkManager_impl::SetupConnection(string address, uint16_t port,Time watchdogTimeout, 196 197 size_t rcv_buf_size) { 197 198 UDT::startup(); … … 804 805 if (tmp.running == true) // start logging 805 806 { 806 filename = 807 caller->log_path + "/" + caller->FileName(tmp.device) + ".dbt"; 808 printf("Creating log file %s (log size %i)\n", filename.c_str(), 809 (int)tmp.size); 807 filename = caller->log_path + "/" + caller->FileName(tmp.device) + ".dbt"; 808 printf("Creating log file %s (log size %i)\n", filename.c_str(), (int)tmp.size); 810 809 tmp.dbtFile = inithdFile((char *)filename.c_str(), UAV, tmp.size); 811 810 logs.push_back(tmp); -
trunk/lib/FlairCore/src/unexported/FrameworkManager_impl.h
r15 r55 43 43 FrameworkManager_impl(flair::core::FrameworkManager *self, std::string name); 44 44 ~FrameworkManager_impl(); 45 void SetupConnection(std::string address, uint16_t port, 45 void SetupConnection(std::string address, uint16_t port,flair::core::Time watchdogTimeout, 46 46 size_t rcv_buf_size = 10000); 47 47 void SetupUserInterface(std::string xml_file); -
trunk/lib/FlairSensorActuator/src/Imu.cpp
r15 r55 59 59 60 60 void Imu::GetDatas(ImuData **outImuData) const { *outImuData = imuData; } 61 61 62 void Imu::UpdateImu() { 62 63 if (rotation == NULL) { -
trunk/lib/FlairSensorActuator/src/NmeaGps.cpp
r51 r55 47 47 nmea_zero_INFO(&info); 48 48 nmea_parser_init(&parser); 49 alt _ref = 0;49 altRef = 0; 50 50 51 51 if ((NMEAFlags & GGA) == 0) { … … 63 63 64 64 // station sol 65 main _tab = new Tab(parent->GetTabWidget(), name);66 tab = new TabWidget(main _tab->NewRow(), name);67 sensor _tab = new Tab(tab, "Reglages");68 GroupBox *reglages_groupbox = new GroupBox(sensor_tab->NewRow(), name);69 button _ref = new PushButton(reglages_groupbox->NewRow(), "set ref");70 nb _sat_label = new Label(reglages_groupbox->NewRow(), "nb_sat");71 fix _label = new Label(reglages_groupbox->LastRowLastCol(), "fix");65 mainTab = new Tab(parent->GetTabWidget(), name); 66 tab = new TabWidget(mainTab->NewRow(), name); 67 sensorTab = new Tab(tab, "Setup"); 68 setupGroupbox = new GroupBox(sensorTab->NewRow(), name); 69 buttonRef = new PushButton(setupGroupbox->NewRow(), "set ref"); 70 nbSatLabel = new Label(setupGroupbox->NewRow(), "nb_sat"); 71 fixLabel = new Label(setupGroupbox->LastRowLastCol(), "fix"); 72 72 73 73 position = new GeoCoordinate((IODevice *)this, "position", 0, 0, 0); 74 74 75 take _ref = false;75 takeRef = false; 76 76 77 77 gpsData = new GpsData(this); 78 78 AddDataToLog(gpsData); 79 79 80 nb_sat_label->SetText("nb_sat: %i", gpsData->GetNumberOfSatellites()); 81 fix_label->SetText("fix: %i", gpsData->GetFixQuality()); 80 nbSatLabel->SetText("number of satellies: %i", gpsData->GetNumberOfSatellites()); 81 fixLabel->SetText("fix quality: %i", gpsData->GetFixQuality()); 82 } 83 84 NmeaGps::NmeaGps(const IODevice *parent, std::string name) : IODevice(parent, name) { 85 gpsData = new GpsData(this); 86 mainTab = NULL; 87 tab = NULL; 88 sensorTab = NULL; 82 89 } 83 90 84 91 NmeaGps::~NmeaGps() { 85 nmea_parser_destroy(&parser); 86 delete main_tab; 87 } 92 if (mainTab != NULL) { 93 nmea_parser_destroy(&parser); 94 delete mainTab; 95 } 96 } 97 98 GroupBox *NmeaGps::GetGroupBox(void) const { return setupGroupbox; } 88 99 89 100 const GpsData *NmeaGps::GetDatas(void) const { … … 96 107 97 108 void NmeaGps::UseDefaultPlot(void) { 98 plot _tab = new Tab(tab, "Mesures");99 100 if ((NMEAFlags & GGA) != 0) { 101 e _plot = new DataPlot1D(plot_tab->NewRow(), "e", -10, 10);102 e _plot->AddCurve(gpsData->Element(GpsData::East));103 n _plot = new DataPlot1D(plot_tab->LastRowLastCol(), "n", -10, 10);104 n _plot->AddCurve(gpsData->Element(GpsData::North));105 u _plot = new DataPlot1D(plot_tab->LastRowLastCol(), "u", -10, 10);106 u _plot->AddCurve(gpsData->Element(GpsData::Up));109 plotTab = new Tab(tab, "Mesures"); 110 111 if ((NMEAFlags & GGA) != 0) { 112 ePlot = new DataPlot1D(plotTab->NewRow(), "e", -10, 10); 113 ePlot->AddCurve(gpsData->Element(GpsData::East)); 114 nPlot = new DataPlot1D(plotTab->LastRowLastCol(), "n", -10, 10); 115 nPlot->AddCurve(gpsData->Element(GpsData::North)); 116 uPlot = new DataPlot1D(plotTab->LastRowLastCol(), "u", -10, 10); 117 uPlot->AddCurve(gpsData->Element(GpsData::Up)); 107 118 } 108 119 if ((NMEAFlags & VTG) != 0) { 109 ve _plot = new DataPlot1D(plot_tab->NewRow(), "ve", -10, 10);110 ve _plot->AddCurve(gpsData->Element(GpsData::EastVelocity));111 vn _plot = new DataPlot1D(plot_tab->LastRowLastCol(), "vn", -10, 10);112 vn _plot->AddCurve(gpsData->Element(GpsData::NorthVelocity));120 vePlot = new DataPlot1D(plotTab->NewRow(), "ve", -10, 10); 121 vePlot->AddCurve(gpsData->Element(GpsData::EastVelocity)); 122 vnPlot = new DataPlot1D(plotTab->LastRowLastCol(), "vn", -10, 10); 123 vnPlot->AddCurve(gpsData->Element(GpsData::NorthVelocity)); 113 124 } 114 125 … … 120 131 DataPlot1D *NmeaGps::EPlot(void) const { 121 132 if ((NMEAFlags & GGA) != 0) { 122 return e _plot;133 return ePlot; 123 134 } else { 124 135 Err("GGA sentence not requested\n"); … … 129 140 DataPlot1D *NmeaGps::NPlot(void) const { 130 141 if ((NMEAFlags & GGA) != 0) { 131 return n _plot;142 return nPlot; 132 143 } else { 133 144 Err("GGA sentence not requested\n"); … … 138 149 DataPlot1D *NmeaGps::UPlot(void) const { 139 150 if ((NMEAFlags & GGA) != 0) { 140 return u _plot;151 return uPlot; 141 152 } else { 142 153 Err("GGA sentence not requested\n"); … … 147 158 DataPlot1D *NmeaGps::VEPlot(void) const { 148 159 if ((NMEAFlags & VTG) != 0) { 149 return ve _plot;160 return vePlot; 150 161 } else { 151 162 Err("GGA sentence not requested\n"); … … 156 167 DataPlot1D *NmeaGps::VNPlot(void) const { 157 168 if ((NMEAFlags & VTG) != 0) { 158 return vn _plot;159 } else { 160 Err("GGA sentence not requested\n"); 161 return NULL; 162 } 163 } 164 165 Layout *NmeaGps::GetLayout(void) const { return sensor _tab; }166 167 Tab *NmeaGps::GetPlotTab(void) const { return plot _tab; }169 return vnPlot; 170 } else { 171 Err("GGA sentence not requested\n"); 172 return NULL; 173 } 174 } 175 176 Layout *NmeaGps::GetLayout(void) const { return sensorTab; } 177 178 Tab *NmeaGps::GetPlotTab(void) const { return plotTab; } 168 179 169 180 TabWidget *NmeaGps::GetTab(void) const { return tab; } 170 181 171 void NmeaGps::SetRef(void) { take _ref = true; }182 void NmeaGps::SetRef(void) { takeRef = true; } 172 183 173 184 void NmeaGps::GetEnu(Vector3D *point) { … … 197 208 if (gpsData->GetFixQuality() != (GpsData::FixQuality_t)pack.sig) { 198 209 gpsData->SetFixQuality((GpsData::FixQuality_t)pack.sig); 199 fix _label->SetText("fix: %i", pack.sig);210 fixLabel->SetText("fix: %i", pack.sig); 200 211 } 201 212 if (gpsData->GetNumberOfSatellites() != pack.satinuse) { 202 213 gpsData->SetNumberOfSatellites(pack.satinuse) ; 203 nb _sat_label->SetText("nb_sat: %i", pack.satinuse);214 nbSatLabel->SetText("nb_sat: %i", pack.satinuse); 204 215 } 205 216 gpsData->ReleaseMutex(); … … 209 220 info.elv); 210 221 211 if ((info.sig == 2 && alt _ref == 0) || button_ref->Clicked() == true ||212 take _ref == true) {222 if ((info.sig == 2 && altRef == 0) || buttonRef->Clicked() == true || 223 takeRef == true) { 213 224 Printf("prise pos ref\n"); 214 lat _ref = pos.lat;215 long _ref = pos.lon;216 alt _ref = info.elv;217 take _ref = false;225 latRef = pos.lat; 226 longRef = pos.lon; 227 altRef = info.elv; 228 takeRef = false; 218 229 } 219 230 // if(alt_ref!=0) … … 222 233 double e, n, u; 223 234 Geographique_2_ECEF(pos.lon, pos.lat, info.elv, x, y, z); 224 ECEF_2_ENU(x, y, z, e, n, u, long _ref, lat_ref, alt_ref);235 ECEF_2_ENU(x, y, z, e, n, u, longRef, latRef, altRef); 225 236 // Printf("lon:%f lat:%f elv:%f\n",pos.lon,pos.lat,info.elv); 226 237 -
trunk/lib/FlairSensorActuator/src/NmeaGps.h
r51 r55 32 32 class Map; 33 33 class Label; 34 class GroupBox; 34 35 } 35 36 } … … 67 68 68 69 /*! 70 * \brief Constructor 71 * 72 * Construct a NmeaGps. \n 73 * This contructor must only be called for a simulated device. 74 * 75 * \param parent parent 76 * \param name name 77 */ 78 NmeaGps(const core::IODevice *parent, std::string name); 79 80 /*! 69 81 * \brief Destructor 70 82 * … … 173 185 NMEAFlags_t NMEAFlags; 174 186 175 protected: 187 /*! 188 * \brief Get GPS datas 189 * 190 * \param gpsData GPS datas 191 */ 192 void GetDatas(core::GpsData **gpsData) const; 193 194 /*! 195 * \brief Setup GroupBox 196 * 197 * \return setup GroupBox 198 */ 199 gui::GroupBox *GetGroupBox(void) const; 200 201 private: 202 gui::Tab *mainTab, *sensorTab; 203 gui::TabWidget *tab; 204 gui::GroupBox *setupGroupbox; 205 gui::PushButton *buttonRef; 206 gui::DataPlot1D *ePlot; 207 gui::DataPlot1D *nPlot; 208 gui::DataPlot1D *uPlot; 209 gui::DataPlot1D *vePlot; 210 gui::DataPlot1D *vnPlot; 211 gui::Tab *plotTab; 212 gui::Map *map; 213 gui::Label *nbSatLabel, *fixLabel; 176 214 core::GeoCoordinate *position; 177 178 /*! 179 * \brief Get GPS datas 180 * 181 * \param gpsData GPS datas 182 */ 183 void GetDatas(core::GpsData **gpsData) const; 184 185 private: 186 /*! 187 * \brief Update using provided datas 188 * 189 * Reimplemented from IODevice. 190 * 191 * \param data data from the parent to process 192 */ 193 void UpdateFrom(const core::io_data *data){}; 194 195 gui::Tab *main_tab, *sensor_tab; 196 gui::TabWidget *tab; 197 gui::PushButton *button_ref; 198 gui::DataPlot1D *e_plot; 199 gui::DataPlot1D *n_plot; 200 gui::DataPlot1D *u_plot; 201 gui::DataPlot1D *ve_plot; 202 gui::DataPlot1D *vn_plot; 203 gui::Tab *plot_tab; 204 gui::Map *map; 205 gui::Label *nb_sat_label, *fix_label; 206 bool take_ref; 215 bool takeRef; 207 216 nmeaINFO info; 208 217 nmeaPARSER parser; 209 218 nmeaGPGGA pack; 210 219 nmeaPOS pos; 211 double lat _ref, long_ref, alt_ref;220 double latRef, longRef, altRef; 212 221 core::GpsData* gpsData; 213 222 }; -
trunk/lib/FlairSensorActuator/src/SimuGps.cpp
r51 r55 18 18 #include "SimuGps.h" 19 19 #include <FrameworkManager.h> 20 #include <string.h>21 20 #include <GeoCoordinate.h> 22 21 #include <GpsData.h> 22 #include <SharedMem.h> 23 #include <SpinBox.h> 24 #include <DoubleSpinBox.h> 25 #include <GroupBox.h> 26 #include <Euler.h> 27 #include <cvmatrix.h> 28 #include <sstream> 29 #include "geodesie.h" 23 30 24 31 using std::string; 32 using std::ostringstream; 25 33 using namespace flair::core; 34 using namespace flair::gui; 35 using namespace Geodesie; 26 36 27 37 namespace flair { … … 29 39 30 40 SimuGps::SimuGps(const FrameworkManager *parent, string name, 31 NmeaGps::NMEAFlags_t NMEAFlags, uint8_t priority) 32 : Thread(parent, name, priority), NmeaGps(parent, name, NMEAFlags) {} 41 NmeaGps::NMEAFlags_t NMEAFlags, uint32_t deviceId,uint8_t priority) 42 : NmeaGps(parent, name, NMEAFlags),Thread(parent, name, priority) { 43 44 dataRate = new SpinBox(GetGroupBox()->NewRow(), "data rate", " Hz", 1, 500, 1, 200); 45 latitudeRef = new DoubleSpinBox(GetGroupBox()->NewRow(), "latitude ref", " deg", -90, 90, 1, 6,49.402313); 46 longitudeRef = new DoubleSpinBox(GetGroupBox()->LastRowLastCol(), "longitude ref", " deg", -180, 180, 1, 6,2.795463); 47 altitudeRef= new DoubleSpinBox(GetGroupBox()->LastRowLastCol(), "altitude ref", " m", 0, 6000, 100, 1,0); 48 fixQuality = new SpinBox(GetGroupBox()->NewRow(), "fix quality", 1, 8, 1, 1); 49 numberOfSatellites = new SpinBox(GetGroupBox()->NewRow(), "number of satellites", 1, 15, 1, 5); 50 51 ostringstream dev_name; 52 dev_name << "simu_gps_" << deviceId; 53 shmem = new SharedMem((Thread *)this, dev_name.str().c_str(), 54 sizeof(gps_states_t)); 55 } 56 57 58 SimuGps::SimuGps(const IODevice *parent, string name, uint32_t deviceId) 59 : NmeaGps(parent, name), Thread(parent, name, 0) { 60 dataRate = NULL; 61 62 ostringstream dev_name; 63 dev_name << "simu_gps_" << deviceId; 64 shmem = new SharedMem((Thread *)this, dev_name.str().c_str(), 65 sizeof(gps_states_t)); 66 } 33 67 34 68 SimuGps::~SimuGps() { … … 37 71 } 38 72 73 void SimuGps::UpdateFrom(const io_data *data) { 74 if (data != NULL) { 75 cvmatrix *input = (cvmatrix *)data; 76 gps_states_t state; 77 78 input->GetMutex(); 79 //simulator is ned, convert it to enu 80 //TODO: put simulator in enu? 81 state.x = input->ValueNoMutex(5, 0); 82 state.y = input->ValueNoMutex(4, 0); 83 state.z = -input->ValueNoMutex(6, 0); 84 input->ReleaseMutex(); 85 86 shmem->Write((char *)&state, sizeof(gps_states_t)); 87 } 88 } 89 39 90 void SimuGps::Run(void) { 40 // double lat=0;91 gps_states_t state; 41 92 char buf[500]; 42 93 nmeaGPGGA gga; 43 94 nmeaGPVTG vtg; 44 SetPeriodMS(500); 95 nmeaPOS pos; 96 nmeaINFO info; 97 98 if (dataRate == NULL) { 99 Thread::Err("not applicable for simulation part.\n"); 100 return; 101 } 102 103 SetPeriodUS((uint32_t)(1000000. / dataRate->Value())); 104 45 105 WarnUponSwitches(true); 46 47 gga.sig=1;48 gga.satinuse=2;49 gga.lat=49.402313;50 gga.lon=2.795463;51 106 52 107 vtg.spn=1; … … 56 111 WaitPeriod(); 57 112 113 if (dataRate->ValueChanged() == true) { 114 SetPeriodUS((uint32_t)(1000000. / dataRate->Value())); 115 } 116 117 shmem->Read((char *)&state, sizeof(gps_states_t)); 118 119 double x, y, z; 120 ENU_2_ECEF(state.x, state.y, state.z, x,y,z, Euler::ToRadian(longitudeRef->Value()), Euler::ToRadian(latitudeRef->Value()), altitudeRef->Value()); 121 ECEF_2_Geographique( x, y, z,pos.lon, pos.lat, gga.elv); 122 nmea_pos2info(&pos,&info); 123 124 if(pos.lat>0) { 125 gga.ns='N'; 126 gga.lat=info.lat; 127 } else { 128 gga.ns='S'; 129 gga.lat=-info.lat; 130 } 131 if(pos.lon>0) { 132 gga.ew='E'; 133 gga.lon=info.lon; 134 } else { 135 gga.ew='W'; 136 gga.lon=-info.lon; 137 } 138 139 gga.sig=fixQuality->Value(); 140 gga.satinuse=numberOfSatellites->Value(); 141 58 142 nmea_gen_GPGGA(buf,sizeof(buf),&gga); 59 143 parseFrame(buf,sizeof(buf)); 60 position->SetCoordinates(49.402313, 2.795463, 0);61 // lat+=.5;62 144 } 63 145 -
trunk/lib/FlairSensorActuator/src/SimuGps.h
r51 r55 18 18 19 19 namespace flair { 20 namespace core { 21 class FrameworkManager; 22 } 20 namespace core { 21 class FrameworkManager; 22 class SharedMem; 23 } 24 namespace gui { 25 class SpinBox; 26 class DoubleSpinBox; 27 } 23 28 } 24 29 … … 34 39 * \brief Constructor 35 40 * 36 * Construct a Novatel.41 * Construct a simulation GPS. Control part. 37 42 * 38 43 * \param parent parent 39 44 * \param name name 40 45 * \param NMEAFlags NMEA sentances to enable 46 * \param deviceId device id 41 47 * \param priority priority of the Thread 42 48 */ 43 49 SimuGps(const core::FrameworkManager *parent, std::string name, 44 NmeaGps::NMEAFlags_t NMEAFlags, uint8_t priority); 50 NmeaGps::NMEAFlags_t NMEAFlags, uint32_t deviceId,uint8_t priority); 51 52 /*! 53 * \brief Constructor 54 * 55 * Construct a simulation GPS. Simulation part.\n 56 * The Thread of this class should not be run. 57 * 58 * \param parent parent 59 * \param name name 60 * \param deviceId device id 61 */ 62 SimuGps(const core::IODevice *parent, std::string name, uint32_t deviceId); 45 63 46 64 /*! … … 58 76 * \param data data from the parent to process 59 77 */ 60 void UpdateFrom(const core::io_data *data) {};78 void UpdateFrom(const core::io_data *data); 61 79 62 80 /*! … … 67 85 */ 68 86 void Run(void); 87 88 typedef struct { 89 float x; 90 float y; 91 float z; 92 } gps_states_t; 93 94 core::SharedMem *shmem; 95 gui::SpinBox *dataRate,*fixQuality,*numberOfSatellites; 96 gui::DoubleSpinBox *latitudeRef,*longitudeRef,*altitudeRef; 69 97 }; 70 98 } // end namespace sensor -
trunk/lib/FlairSensorActuator/src/SimuImu.cpp
r15 r55 37 37 uint8_t priority) 38 38 : Imu(parent, name), Thread(parent, name, priority) { 39 data _rate =39 dataRate = 40 40 new SpinBox(GetGroupBox()->NewRow(), "data rate", " Hz", 1, 500, 1, 200); 41 41 ahrsData = new AhrsData((Imu *)this); … … 49 49 SimuImu::SimuImu(const IODevice *parent, string name, uint32_t dev_id) 50 50 : Imu(parent, name), Thread(parent, name, 0) { 51 data _rate = NULL;51 dataRate = NULL; 52 52 53 53 ostringstream dev_name; … … 86 86 GetDatas(&imuData); 87 87 88 if (data _rate == NULL) {88 if (dataRate == NULL) { 89 89 Thread::Err("not applicable for simulation part.\n"); 90 90 return; 91 91 } 92 92 93 SetPeriodUS((uint32_t)(1000000. / data _rate->Value()));93 SetPeriodUS((uint32_t)(1000000. / dataRate->Value())); 94 94 95 95 while (!ToBeStopped()) { 96 96 WaitPeriod(); 97 97 98 if (data _rate->ValueChanged() == true) {99 SetPeriodUS((uint32_t)(1000000. / data _rate->Value()));98 if (dataRate->ValueChanged() == true) { 99 SetPeriodUS((uint32_t)(1000000. / dataRate->Value())); 100 100 } 101 101 -
trunk/lib/FlairSensorActuator/src/SimuImu.h
r15 r55 18 18 19 19 namespace flair { 20 namespace core {21 class SharedMem;22 class AhrsData;23 }24 namespace gui {25 class SpinBox;26 }20 namespace core { 21 class SharedMem; 22 class AhrsData; 23 } 24 namespace gui { 25 class SpinBox; 26 } 27 27 } 28 28 … … 93 93 float wz; 94 94 } imu_states_t; 95 gui::SpinBox *data_rate; 95 96 gui::SpinBox *dataRate; 96 97 core::SharedMem *shmem; 97 98 core::AhrsData *ahrsData; -
trunk/lib/FlairSensorActuator/src/geodesie.cpp
r15 r55 322 322 } 323 323 324 //from https://gist.github.com/klucar/1536194 325 void Geodesie::ECEF_2_Geographique(double x, double y, double z, 326 double &longitude, double &latitude, double &he) { 327 328 double asq=pow(GRS_a, 2); 329 double esq=pow(GRS_e, 2); 330 double b = sqrt( asq * (1-esq) ); 331 double bsq = pow(b,2); 332 double ep = sqrt( (asq - bsq)/bsq); 333 double p = sqrt( pow(x,2) + pow(y,2) ); 334 double th = atan2(GRS_a*z, b*p); 335 336 longitude = atan2(y,x); 337 latitude = atan2( (z + pow(ep,2)*b*pow(sin(th),3) ), (p - esq*GRS_a*pow(cos(th),3)) ); 338 double N = GRS_a/( sqrt(1-esq*pow(sin(latitude),2)) ); 339 double alt = p / cos(latitude) - N; 340 341 // mod longitude to 0-2pi 342 if(longitude<0) longitude +=2*M_PI; 343 344 // correction for altitude near poles left out. 345 } 346 324 347 //////////////////////////////////////////////////////////////////////// 325 348 void Geodesie::ECEF_2_ENU(double x, double y, double z, double &e, double &n, … … 351 374 C.Apply(x, y, z, e, n, u); 352 375 } 376 377 void Geodesie::ENU_2_ECEF(double e, double n,double u, 378 double &x, double &y, double &z, 379 double lon0, double lat0, double he0) { 380 double slat = std::sin(lat0);//phi 381 double clat = std::cos(lat0); 382 double slon = std::sin(lon0);//lambda 383 double clon = std::cos(lon0); 384 385 Geodesie::Matrice C; 386 C.c0_l0 = -slon; 387 C.c1_l0 = -clon*slat; 388 C.c2_l0 = clon*clat; 389 390 C.c0_l1 = clon; 391 C.c1_l1 = -slon * slat; 392 C.c2_l1 = slon*clat; 393 394 C.c0_l2 = 0; 395 C.c1_l2 = clat; 396 C.c2_l2 = slat; 397 398 C.Apply(e, n, u,x,y,z); 399 400 double x0, y0, z0; 401 Geographique_2_ECEF(lon0, lat0, he0, x0, y0, z0); 402 403 x += x0; 404 y += y0; 405 z += z0; 406 } -
trunk/lib/FlairSensorActuator/src/unexported/geodesie.h
r16 r55 101 101 void Geographique_2_ECEF(double longitude, double latitude, double he, 102 102 double &x, double &y, double &z); 103 /** Convert from ECEF two ENU. 103 104 /** Convert from ECEF to geographique. 105 */ 106 void ECEF_2_Geographique(double x, double y, double z, 107 double &longitude, double &latitude, double &he); 108 109 /** Convert from ECEF to ENU. 104 110 * @param[in] lon0 Longitude of the origin in radian. 105 111 * @param[in] lat0 Latitude of the origin in radian. … … 108 114 void ECEF_2_ENU(double x, double y, double z, double &e, double &n, double &u, 109 115 double lon0, double lat0, double he0); 116 117 /** Convert from ECEF to ENU. 118 * @param[in] lon0 Longitude of the origin in radian. 119 * @param[in] lat0 Latitude of the origin in radian. 120 * @param[in] he0 Height of the origin in radian. 121 */ 122 void ENU_2_ECEF(double e, double n, double u,double &x, double &y, double &z, 123 double lon0, double lat0, double he0); 124 110 125 //////////////////////////////////////////////////////////////////////// 111 126
Note:
See TracChangeset
for help on using the changeset viewer.