Changeset 124 in flair-src for trunk/demos/OpticalFlow/uav/src
- Timestamp:
- Jan 12, 2017, 10:39:23 AM (8 years ago)
- Location:
- trunk/demos/OpticalFlow/uav/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/demos/OpticalFlow/uav/src/DemoOpticalFlow.cpp
r122 r124 26 26 #include <GroupBox.h> 27 27 #include <DoubleSpinBox.h> 28 #include <PushButton.h> 28 29 #include <FrameworkManager.h> 29 30 #include <MetaDualShock3.h> … … 49 50 uav->GetVerticalCamera()->SetLogFormat(Camera::LogFormat::JPG); 50 51 getFrameworkManager()->AddDeviceToLog(uav->GetVerticalCamera()); 51 greyCameraImage=new CvtColor(uav->GetVerticalCamera(),"gray",CvtColor::Conversion_t::GRAY); 52 53 startOpticalflow=new PushButton(GetButtonsLayout()->NewRow(),"start optical flow"); 52 54 53 uav->GetVerticalCamera()->UseDefaultPlot(greyCameraImage->Output()); // Le defaultPlot de la caméra peut afficher n'importe quoi? 55 greyCameraImage=new CvtColor(uav->GetVerticalCamera(),"gray",CvtColor::Conversion_t::ToGray); 54 56 55 //optical flow stack 56 opticalFlow=new OpticalFlow(greyCameraImage,uav->GetVerticalCamera()->GetLayout()->NewRow(),"flux optique"); 57 opticalFlowSpeed=new OpticalFlowSpeed(opticalFlow,"vitesse du flux optique"); 57 uav->GetVerticalCamera()->UseDefaultPlot(greyCameraImage->Output()); // Le defaultPlot de la caméra peut afficher n'importe quoi? 58 58 59 cvmatrix_descriptor* desc=new cvmatrix_descriptor(2,1); 60 for(int i=0;i<2;i++) { 61 desc->SetElementName(i,0,opticalFlowSpeed->Output()->Name(i,0)); 62 } 63 cvmatrix* prev_value=new cvmatrix((const Thread*)this,desc,floatType,uav->ObjectName()); // diamond inheritance 64 for(int i=0;i<2;i++) { 65 prev_value->SetValue(i,0,0); 66 } 59 //optical flow stack 60 opticalFlow=new OpticalFlow(greyCameraImage,uav->GetVerticalCamera()->GetLayout()->NewRow(),"flux optique"); 61 opticalFlowSpeed=new OpticalFlowSpeed(opticalFlow,"vitesse du flux optique"); 67 62 68 opticalFlowSpeedFiltered=new LowPassFilter(opticalFlowSpeed,uav->GetVerticalCamera()->GetLayout()->NewRow(),"passe bas",prev_value); 63 cvmatrix_descriptor* desc=new cvmatrix_descriptor(2,1); 64 for(int i=0;i<2;i++) { 65 desc->SetElementName(i,0,opticalFlowSpeed->Output()->Name(i,0)); 66 } 67 cvmatrix* prev_value=new cvmatrix((const Thread*)this,desc,floatType,uav->ObjectName()); // diamond inheritance 68 for(int i=0;i<2;i++) { 69 prev_value->SetValue(i,0,0); 70 } 71 72 opticalFlowSpeedFiltered=new LowPassFilter(opticalFlowSpeed,uav->GetVerticalCamera()->GetLayout()->NewRow(),"passe bas",prev_value); 69 73 // delete prev_value? 70 74 71 75 getFrameworkManager()->AddDeviceToLog(opticalFlowSpeed); 72 76 73 74 75 77 Tab* opticalFlowTab=new Tab(getFrameworkManager()->GetTabWidget(),"flux optique"); 78 DataPlot1D* xVelocityPlot=new DataPlot1D(opticalFlowTab->NewRow(),"x_velocity",-5,5); 79 DataPlot1D* yVelocityPlot=new DataPlot1D(opticalFlowTab->LastRowLastCol(),"y_velocity",-5,5); 76 80 77 78 79 80 81 xVelocityPlot->AddCurve(opticalFlowSpeed->Output()->Element(0,0)); 82 xVelocityPlot->AddCurve(opticalFlowSpeedFiltered->Matrix()->Element(0,0),DataPlot::Blue); 83 yVelocityPlot->AddCurve(opticalFlowSpeed->Output()->Element(1,0)); 84 yVelocityPlot->AddCurve(opticalFlowSpeedFiltered->Matrix()->Element(1,0),DataPlot::Blue); 81 85 82 83 84 85 86 u_x=new Pid(setupLawTab->At(1,0),"u_x"); 87 u_x->UseDefaultPlot(graphLawTab->NewRow()); 88 u_y=new Pid(setupLawTab->At(1,1),"u_y"); 89 u_y->UseDefaultPlot(graphLawTab->LastRowLastCol()); 86 90 87 88 89 91 opticalFlowGroupBox=new GroupBox(GetJoystick()->GetTab()->NewRow(),"consignes fo"); 92 maxXSpeed=new DoubleSpinBox(opticalFlowGroupBox->NewRow(),"debattement x"," m/s",-5,5,0.1,1); 93 maxYSpeed=new DoubleSpinBox(opticalFlowGroupBox->LastRowLastCol(),"debattement y"," m/s",-5,5,0.1,1); 90 94 91 92 93 95 opticalFlowReference=new cvmatrix((const Thread*)this,2,1,floatType); 96 xVelocityPlot->AddCurve(opticalFlowReference->Element(0,0),DataPlot::Green,"consigne"); 97 yVelocityPlot->AddCurve(opticalFlowReference->Element(1,0),DataPlot::Green,"consigne"); 94 98 95 96 97 99 customReferenceOrientation= new AhrsData(this,"reference"); 100 uav->GetAhrs()->AddPlot(customReferenceOrientation,DataPlot::Yellow); 101 AddDataToControlLawLog(customReferenceOrientation); 98 102 } 99 103 … … 107 111 } 108 112 113 void DemoOpticalFlow::StartOpticalFlow(void) { 114 if (SetOrientationMode(OrientationMode_t::Custom)) { 115 Thread::Info("(Re)entering optical flow mode\n"); 116 u_x->Reset(); 117 u_y->Reset(); 118 } else { 119 Thread::Warn("Could not enter optical flow mode\n"); 120 } 121 } 122 123 void DemoOpticalFlow::ExtraCheckPushButton(void) { 124 if(startOpticalflow->Clicked()) { 125 //StartOpticalFlow(); 126 GetUav()->GetVerticalCamera()->SavePictureToFile("./toto.jpg"); 127 128 } 129 } 130 109 131 void DemoOpticalFlow::ExtraCheckJoystick(void) { 110 132 static bool wasOpticalFlowModeButtonPressed=false; … … 113 135 if (!wasOpticalFlowModeButtonPressed) { 114 136 wasOpticalFlowModeButtonPressed=true; 115 if (SetOrientationMode(OrientationMode_t::Custom)) { 116 Thread::Info("(Re)entering optical flow mode\n"); 117 u_x->Reset(); 118 u_y->Reset(); 119 } else { 120 Thread::Warn("Could not enter optical flow mode\n"); 121 } 137 StartOpticalFlow(); 122 138 } 123 139 } else { -
trunk/demos/OpticalFlow/uav/src/DemoOpticalFlow.h
r122 r124 25 25 class GroupBox; 26 26 class DoubleSpinBox; 27 class PushButton; 27 28 } 28 29 namespace filter { … … 46 47 void SignalEvent(Event_t event); 47 48 void ExtraCheckJoystick(void); 49 void ExtraCheckPushButton(void); 48 50 const flair::core::AhrsData *GetReferenceOrientation(void); 49 51 … … 59 61 flair::filter::OpticalFlow *opticalFlow; 60 62 flair::filter::OpticalFlowSpeed *opticalFlowSpeed; 63 flair::gui::PushButton *startOpticalflow,*stopOpticalflow; 64 void StartOpticalFlow(void); 61 65 }; 62 66
Note:
See TracChangeset
for help on using the changeset viewer.