Changeset 15 in flair-src for trunk/lib/FlairMeta/src/Uav.cpp
- Timestamp:
- 04/08/16 15:40:57 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/FlairMeta/src/Uav.cpp
r10 r15 38 38 using namespace flair::actuator; 39 39 40 namespace flair { namespace meta { 40 namespace flair { 41 namespace meta { 41 42 42 Uav::Uav(FrameworkManager* parent,string name,UavMultiplex *multiplex): Object(parent,name) { 43 vrpnclient=NULL; 44 uav_vrpn=NULL; 45 verticalCamera=NULL; 46 this->multiplex=multiplex; 43 Uav::Uav(FrameworkManager *parent, string name, UavMultiplex *multiplex) 44 : Object(parent, name) { 45 vrpnclient = NULL; 46 uav_vrpn = NULL; 47 verticalCamera = NULL; 48 this->multiplex = multiplex; 47 49 } 48 50 49 Uav::~Uav() { 50 } 51 Uav::~Uav() {} 51 52 52 53 void Uav::SetUsRangeFinder(const UsRangeFinder *inUs) { 53 us=(UsRangeFinder*)inUs;54 meta_us=new MetaUsRangeFinder(us);55 54 us = (UsRangeFinder *)inUs; 55 meta_us = new MetaUsRangeFinder(us); 56 getFrameworkManager()->AddDeviceToLog(us); 56 57 } 57 58 58 59 void Uav::SetAhrs(const Ahrs *inAhrs) { 59 ahrs=(Ahrs*)inAhrs;60 imu=(Imu*)ahrs->GetImu();61 60 ahrs = (Ahrs *)inAhrs; 61 imu = (Imu *)ahrs->GetImu(); 62 getFrameworkManager()->AddDeviceToLog(imu); 62 63 } 63 64 64 void Uav::SetBldc(const Bldc* inBldc) { 65 bldc=(Bldc*)inBldc; 66 } 65 void Uav::SetBldc(const Bldc *inBldc) { bldc = (Bldc *)inBldc; } 67 66 68 void Uav::SetBatteryMonitor(const BatteryMonitor *inBattery) {69 battery=(BatteryMonitor*)inBattery;67 void Uav::SetBatteryMonitor(const BatteryMonitor *inBattery) { 68 battery = (BatteryMonitor *)inBattery; 70 69 } 71 70 72 71 void Uav::SetMultiplex(const UavMultiplex *inMultiplex) { 73 multiplex=(UavMultiplex*)inMultiplex;74 72 multiplex = (UavMultiplex *)inMultiplex; 73 getFrameworkManager()->AddDeviceToLog(multiplex); 75 74 } 76 75 77 void Uav::SetVerticalCamera(const Camera *inVerticalCamera) {78 verticalCamera=(Camera*)inVerticalCamera;76 void Uav::SetVerticalCamera(const Camera *inVerticalCamera) { 77 verticalCamera = (Camera *)inVerticalCamera; 79 78 } 80 79 /* 81 void Uav::SetupVRPNSerial(SerialPort *vrpn_port,string name,int VRPNSerialObjectId) { 80 void Uav::SetupVRPNSerial(SerialPort *vrpn_port,string name,int 81 VRPNSerialObjectId) { 82 82 vrpnclient=new VrpnClient(getFrameworkManager(),"vrpn",vrpn_port,10000,80); 83 83 uav_vrpn=new MetaVrpnObject(vrpnclient,name,VRPNSerialObjectId); … … 87 87 */ 88 88 void Uav::SetupVRPNAutoIP(string name) { 89 SetupVRPN("192.168.147.197:3883",name);89 SetupVRPN("192.168.147.197:3883", name); 90 90 } 91 91 92 void Uav::SetupVRPN(string optitrack_address,string name) { 93 vrpnclient=new VrpnClient(getFrameworkManager(),"vrpn",optitrack_address,10000,80); 94 uav_vrpn=new MetaVrpnObject(vrpnclient,name); 92 void Uav::SetupVRPN(string optitrack_address, string name) { 93 vrpnclient = new VrpnClient(getFrameworkManager(), "vrpn", optitrack_address, 94 10000, 80); 95 uav_vrpn = new MetaVrpnObject(vrpnclient, name); 95 96 96 97 getFrameworkManager()->AddDeviceToLog(uav_vrpn); 97 98 98 GetAhrs()->YawPlot()->AddCurve(uav_vrpn->State()->Element(2),DataPlot::Green); 99 //GetAhrs()->RollPlot()->AddCurve(uav_vrpn->State()->Element(0),DataPlot::Green); 100 //GetAhrs()->PitchPlot()->AddCurve(uav_vrpn->State()->Element(1),DataPlot::Green); 99 GetAhrs()->YawPlot()->AddCurve(uav_vrpn->State()->Element(2), 100 DataPlot::Green); 101 // GetAhrs()->RollPlot()->AddCurve(uav_vrpn->State()->Element(0),DataPlot::Green); 102 // GetAhrs()->PitchPlot()->AddCurve(uav_vrpn->State()->Element(1),DataPlot::Green); 101 103 } 102 104 103 void Uav::StartSensors(void) 104 if(vrpnclient!=NULL) {105 106 105 void Uav::StartSensors(void) { 106 if (vrpnclient != NULL) { 107 vrpnclient->Start(); 108 } 107 109 } 108 110 void Uav::UseDefaultPlot(void) { 109 111 multiplex->UseDefaultPlot(); 110 112 111 if(bldc->HasSpeedMeasurement()) { 112 Tab* plot_tab=new Tab(multiplex->GetTabWidget(),"Speeds"); 113 DataPlot1D* plots[4]; 114 plots[0]=new DataPlot1D(plot_tab->NewRow(),"front left",0,7000); 115 plots[1]=new DataPlot1D(plot_tab->LastRowLastCol(),"front right",0,7000); 116 plots[2]=new DataPlot1D(plot_tab->NewRow(),"rear left",0,7000); 117 plots[3]=new DataPlot1D(plot_tab->LastRowLastCol(),"rear right",0,7000); 113 if (bldc->HasSpeedMeasurement()) { 114 Tab *plot_tab = new Tab(multiplex->GetTabWidget(), "Speeds"); 115 DataPlot1D *plots[4]; 116 plots[0] = new DataPlot1D(plot_tab->NewRow(), "front left", 0, 7000); 117 plots[1] = 118 new DataPlot1D(plot_tab->LastRowLastCol(), "front right", 0, 7000); 119 plots[2] = new DataPlot1D(plot_tab->NewRow(), "rear left", 0, 7000); 120 plots[3] = 121 new DataPlot1D(plot_tab->LastRowLastCol(), "rear right", 0, 7000); 118 122 119 if(bldc->MotorsCount()==8) { 120 for(int i=0;i<4;i++) plots[i]->AddCurve(bldc->Output()->Element(multiplex->MultiplexValue(i),0),DataPlot::Red,"top"); 121 for(int i=0;i<4;i++) plots[i]->AddCurve(bldc->Output()->Element(multiplex->MultiplexValue(i+4),0),DataPlot::Blue,"bottom"); 122 } else { 123 for(int i=0;i<4;i++) plots[i]->AddCurve(bldc->Output()->Element(multiplex->MultiplexValue(i),0)); 124 } 123 if (bldc->MotorsCount() == 8) { 124 for (int i = 0; i < 4; i++) 125 plots[i]->AddCurve( 126 bldc->Output()->Element(multiplex->MultiplexValue(i), 0), 127 DataPlot::Red, "top"); 128 for (int i = 0; i < 4; i++) 129 plots[i]->AddCurve( 130 bldc->Output()->Element(multiplex->MultiplexValue(i + 4), 0), 131 DataPlot::Blue, "bottom"); 132 } else { 133 for (int i = 0; i < 4; i++) 134 plots[i]->AddCurve( 135 bldc->Output()->Element(multiplex->MultiplexValue(i), 0)); 125 136 } 137 } 126 138 127 if(bldc->HasCurrentMeasurement()) {128 Tab* plot_tab=new Tab(multiplex->GetTabWidget(),"Currents");129 DataPlot1D*plots[4];130 plots[0]=new DataPlot1D(plot_tab->NewRow(),"front left",0,10);131 plots[1]=new DataPlot1D(plot_tab->LastRowLastCol(),"front right",0,10);132 plots[2]=new DataPlot1D(plot_tab->NewRow(),"rear left",0,10);133 plots[3]=new DataPlot1D(plot_tab->LastRowLastCol(),"rear right",0,10);139 if (bldc->HasCurrentMeasurement()) { 140 Tab *plot_tab = new Tab(multiplex->GetTabWidget(), "Currents"); 141 DataPlot1D *plots[4]; 142 plots[0] = new DataPlot1D(plot_tab->NewRow(), "front left", 0, 10); 143 plots[1] = new DataPlot1D(plot_tab->LastRowLastCol(), "front right", 0, 10); 144 plots[2] = new DataPlot1D(plot_tab->NewRow(), "rear left", 0, 10); 145 plots[3] = new DataPlot1D(plot_tab->LastRowLastCol(), "rear right", 0, 10); 134 146 135 if(bldc->MotorsCount()==8) { 136 for(int i=0;i<4;i++) plots[i]->AddCurve(bldc->Output()->Element(multiplex->MultiplexValue(i),1),DataPlot::Red,"top"); 137 for(int i=0;i<4;i++) plots[i]->AddCurve(bldc->Output()->Element(multiplex->MultiplexValue(i+4),1),DataPlot::Blue,"bottom"); 138 } else { 139 for(int i=0;i<4;i++) plots[i]->AddCurve(bldc->Output()->Element(multiplex->MultiplexValue(i),1)); 140 } 147 if (bldc->MotorsCount() == 8) { 148 for (int i = 0; i < 4; i++) 149 plots[i]->AddCurve( 150 bldc->Output()->Element(multiplex->MultiplexValue(i), 1), 151 DataPlot::Red, "top"); 152 for (int i = 0; i < 4; i++) 153 plots[i]->AddCurve( 154 bldc->Output()->Element(multiplex->MultiplexValue(i + 4), 1), 155 DataPlot::Blue, "bottom"); 156 } else { 157 for (int i = 0; i < 4; i++) 158 plots[i]->AddCurve( 159 bldc->Output()->Element(multiplex->MultiplexValue(i), 1)); 141 160 } 161 } 142 162 143 144 163 meta_us->UseDefaultPlot(); 164 ahrs->UseDefaultPlot(); 145 165 } 146 166 147 UavMultiplex* Uav::GetUavMultiplex(void) const { 148 return multiplex; 167 UavMultiplex *Uav::GetUavMultiplex(void) const { return multiplex; } 168 169 Bldc *Uav::GetBldc(void) const { return bldc; } 170 171 Ahrs *Uav::GetAhrs(void) const { return ahrs; } 172 173 Imu *Uav::GetImu(void) const { return imu; } 174 175 MetaUsRangeFinder *Uav::GetMetaUsRangeFinder(void) const { return meta_us; } 176 177 UsRangeFinder *Uav::GetUsRangeFinder(void) const { return us; } 178 179 BatteryMonitor *Uav::GetBatteryMonitor(void) const { return battery; } 180 181 VrpnClient *Uav::GetVrpnClient(void) const { 182 if (vrpnclient == NULL) 183 Err("vrpn is not setup, call SetupVRPN before\n"); 184 return vrpnclient; 149 185 } 150 186 151 Bldc* Uav::GetBldc(void) const { 152 return bldc; 153 } 187 MetaVrpnObject *Uav::GetVrpnObject(void) const { return uav_vrpn; } 154 188 155 Ahrs* Uav::GetAhrs(void) const { 156 return ahrs; 157 } 158 159 Imu* Uav::GetImu(void) const { 160 return imu; 161 } 162 163 MetaUsRangeFinder* Uav::GetMetaUsRangeFinder(void) const { 164 return meta_us; 165 } 166 167 UsRangeFinder* Uav::GetUsRangeFinder(void) const { 168 return us; 169 } 170 171 BatteryMonitor* Uav::GetBatteryMonitor(void) const { 172 return battery; 173 } 174 175 VrpnClient* Uav::GetVrpnClient(void) const { 176 if(vrpnclient==NULL) Err("vrpn is not setup, call SetupVRPN before\n"); 177 return vrpnclient; 178 } 179 180 MetaVrpnObject* Uav::GetVrpnObject(void) const { 181 return uav_vrpn; 182 } 183 184 Camera* Uav::GetVerticalCamera(void) const { 185 return verticalCamera; 186 } 189 Camera *Uav::GetVerticalCamera(void) const { return verticalCamera; } 187 190 188 191 } // end namespace meta
Note:
See TracChangeset
for help on using the changeset viewer.