Changeset 186 in flair-src
- Timestamp:
- Jun 23, 2017, 5:33:03 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 23 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ReleaseNotes
r180 r186 15 15 - Uav class is now a singleton 16 16 - VrpnClient class is now a singleton 17 - VrpnObject no longer outputs Euler (on y Quaternion): warning, output matrix has changed!17 - VrpnObject no longer outputs Euler (only Quaternion): warning, output matrix has changed! 18 18 19 19 ----------------------------------------------------------- -
trunk/demos/Gps/uav/build_x86_64/bin/x8.sh
r89 r186 4 4 5 5 if [ -f /proc/xenomai/version ];then 6 EXEC=./ CircleFollower_rt6 EXEC=./DemoGps_rt 7 7 else 8 EXEC=./ CircleFollower_nrt8 EXEC=./DemoGps_nrt 9 9 fi 10 10 -
trunk/demos/Gps/uav/src/DemoGps.cpp
r185 r186 29 29 #include <AhrsData.h> 30 30 #include <RTDM_SerialPort.h> 31 #include < Mb800.h>32 #include < SimuGps.h>31 #include <Imu.h> 32 #include <NmeaGps.h> 33 33 34 34 using namespace std; -
trunk/lib/FlairCore/src/FrameworkManager.cpp
r123 r186 81 81 for (vector<const Object *>::iterator it = Childs()->begin(); 82 82 it < Childs()->end(); it++) { 83 // Printf("child %i %s 84 // %s\n",Childs()->size(),(*it)->ObjectName().c_str(),(*it)->ObjectType().c_str()); 83 //Printf("child %i %s %s\n",Childs()->size(),(*it)->ObjectName().c_str(),(*it)->ObjectType().c_str()); 85 84 if ((*it)->ObjectType() == "Thread") { 86 85 if (*it != pimpl_) { … … 102 101 for (vector<const Object *>::iterator it = Childs()->begin(); 103 102 it < Childs()->end(); it++) { 104 // Printf("child %i %s 105 // %s\n",Childs()->size(),(*it)->ObjectName().c_str(),(*it)->ObjectType().c_str()); 103 //Printf("child %i %s %s\n",Childs()->size(),(*it)->ObjectName().c_str(),(*it)->ObjectType().c_str()); 106 104 if ((*it)->ObjectType() == "IODevice") { 107 105 // Printf("del\n"); … … 122 120 // permet de garder l'uicom pour notifer des destructions 123 121 while (Childs()->size() != 0) { 124 // Printf("child %i %s 125 // %s\n",Childs()->size(),Childs()->back()->ObjectName().c_str(),Childs()->back()->ObjectType().c_str()); 122 //Printf("child %i %s %s\n",Childs()->size(),Childs()->back()->ObjectName().c_str(),Childs()->back()->ObjectType().c_str()); 126 123 if (Childs()->back() != NULL) 127 124 delete Childs()->back(); … … 135 132 void FrameworkManager::SetupConnection(string address, uint16_t port,Time watchdogTimeout, 136 133 size_t rcv_buf_size) { 137 pimpl_->SetupConnection(address, port, rcv_buf_size);134 pimpl_->SetupConnection(address, port, watchdogTimeout,rcv_buf_size); 138 135 } 139 136 -
trunk/lib/FlairCore/src/FrameworkManager_impl.cpp
r137 r186 239 239 gcs_watchdog = new Watchdog( 240 240 this, std::bind(&FrameworkManager_impl::ConnectionLost, this), 241 (Time)1000000000);241 watchdogTimeout); 242 242 gcs_watchdog->Start(); 243 243 } -
trunk/lib/FlairCore/src/OneAxisRotation_impl.cpp
r167 r186 22 22 #include <Euler.h> 23 23 #include <Quaternion.h> 24 #include <math.h> 24 25 25 26 using std::string; … … 41 42 OneAxisRotation_impl::~OneAxisRotation_impl() {} 42 43 43 // compute rotation of each axis through ComputeRotation(Vector3D& vector)44 44 void OneAxisRotation_impl::ComputeRotation(Quaternion &quat) const { 45 Vector3Df rot = Vector3Df(quat.q1, quat.q2, quat.q3); 46 ComputeRotation(rot); 47 quat.q1 = rot.x; 48 quat.q2 = rot.y; 49 quat.q3 = rot.z; 45 Quaternion rot; 46 switch (rot_axe->CurrentIndex()) { 47 case 0: 48 rot=Quaternion(cosf(Euler::ToRadian(rot_value->Value()/2)),sinf(Euler::ToRadian(rot_value->Value()/2)), 0,0); 49 break; 50 case 1: 51 rot=Quaternion(cosf(Euler::ToRadian(rot_value->Value()/2)),0,sinf(Euler::ToRadian(rot_value->Value()/2)),0); 52 break; 53 case 2: 54 rot=Quaternion(cosf(Euler::ToRadian(rot_value->Value()/2)),0,0,sinf(Euler::ToRadian(rot_value->Value()/2))); 55 break; 56 } 57 quat=quat*rot; 50 58 } 51 59 -
trunk/lib/FlairCore/src/Thread_impl.cpp
r133 r186 57 57 this->priority = priority; 58 58 period = 100 * 1000 * 1000; // 100ms par defaut 59 min_ jitter= 1000 * 1000 * 1000;60 max_ jitter= 0;61 mean_ jitter= 0;59 min_latency = 1000 * 1000 * 1000; 60 max_latency = 0; 61 mean_latency = 0; 62 62 last = 0; 63 63 cpt = 0; … … 234 234 next_time += period; 235 235 #endif 236 Compute Jitter(GetTime());236 ComputeLatency(GetTime()); 237 237 } 238 238 … … 324 324 { 325 325 #ifndef __XENO__ 326 //if(last!=0)326 if(last!=0) 327 327 #endif 328 328 { Printf("Thread::%s :\n", self->ObjectName().c_str()); } … … 346 346 #endif 347 347 if (last != 0) { 348 Printf(" min jitter (ns): %lld\n", min_jitter);349 Printf(" max jitter (ns): %lld\n", max_jitter);350 Printf(" jitter moy (ns): %lld\n", mean_jitter/ cpt);348 Printf(" min latency (ns): %lld\n", min_latency); 349 Printf(" max latency (ns): %lld\n", max_latency); 350 Printf(" latency moy (ns): %lld\n", mean_latency / cpt); 351 351 Printf(" itertions: %lld\n", cpt); 352 352 } … … 370 370 } 371 371 372 void Thread_impl::Compute Jitter(Time time) {372 void Thread_impl::ComputeLatency(Time time) { 373 373 Time diff, delta; 374 374 diff = time - last; … … 384 384 return; 385 385 386 if (delta > max_ jitter)387 max_ jitter= delta;388 if (delta < min_ jitter)389 min_ jitter= delta;390 mean_ jitter+= delta;386 if (delta > max_latency) 387 max_latency = delta; 388 if (delta < min_latency) 389 min_latency = delta; 390 mean_latency += delta; 391 391 cpt++; 392 392 393 // Printf("Thread::%s jittermoy (ns):394 // %lld\n",self->ObjectName().c_str(),mean_ jitter/cpt);393 // Printf("Thread::%s latency moy (ns): 394 // %lld\n",self->ObjectName().c_str(),mean_latency/cpt); 395 395 } 396 396 -
trunk/lib/FlairCore/src/unexported/FrameworkManager_impl.h
r122 r186 44 44 ~FrameworkManager_impl(); 45 45 void SetupConnection(std::string address, uint16_t port,flair::core::Time watchdogTimeout, 46 size_t rcv_buf_size = 10000);46 size_t rcv_buf_size); 47 47 void SetupUserInterface(std::string xml_file); 48 48 void SetupLogger(std::string log_path); -
trunk/lib/FlairCore/src/unexported/Thread_impl.h
r139 r186 55 55 flair::core::ConditionVariable *cond; 56 56 uint8_t priority; 57 flair::core::Time max_ jitter, min_jitter, mean_jitter;57 flair::core::Time max_latency, min_latency, mean_latency; 58 58 flair::core::Time last; 59 59 uint64_t cpt; … … 62 62 bool is_suspended; 63 63 void PrintStats(void); 64 void Compute Jitter(flair::core::Time time);64 void ComputeLatency(flair::core::Time time); 65 65 #ifdef __XENO__ 66 66 RT_TASK task_rt; -
trunk/lib/FlairFilter/src/Gx3_25_ahrs.cpp
r173 r186 30 30 SerialPort *serialport, Gx3_25_imu::Command_t command, 31 31 uint8_t priority) 32 : Ahrs(new Gx3_25_imu( name, serialport, command, priority), name) {32 : Ahrs(new Gx3_25_imu( "imu", serialport, command, priority), name) { 33 33 34 34 SetIsReady(true); -
trunk/lib/FlairFilter/src/SimuAhrs.cpp
r167 r186 29 29 SimuAhrs::SimuAhrs(string name, uint32_t modelId,uint32_t deviceId, 30 30 uint8_t priority) 31 : Ahrs(new SimuImu( name, modelId,deviceId, priority), name) {31 : Ahrs(new SimuImu("imu", modelId,deviceId, priority), name) { 32 32 SetIsReady(true); 33 33 } -
trunk/lib/FlairMeta/src/HdsX8.cpp
r185 r186 49 49 "motors", GetUavMultiplex()->MotorsCount(), i2cport)); 50 50 SetUsRangeFinder(new Srf08("SRF08", i2cport, 0x70, 60)); 51 SetAhrs(new Gx3_25_ahrs(" imu", imu_port,51 SetAhrs(new Gx3_25_ahrs("ahrs", imu_port, 52 52 Gx3_25_imu::AccelerationAngularRateAndOrientationMatrix, 70)); 53 53 SetBatteryMonitor(((BlCtrlV2 *)GetBldc())->GetBatteryMonitor()); … … 57 57 if(useGps=="true") { 58 58 RTDM_SerialPort *gps_port = new RTDM_SerialPort(getFrameworkManager(), "gps_port", "rtser2"); 59 SetGps(new Mb800("gps",gps_port,(NmeaGps::NMEAFlags_t)(NmeaGps::GGA|NmeaGps::VTG ),40));59 SetGps(new Mb800("gps",gps_port,(NmeaGps::NMEAFlags_t)(NmeaGps::GGA|NmeaGps::VTG|NmeaGps::GSA),40)); 60 60 } 61 61 } … … 67 67 ((Srf08 *)GetUsRangeFinder())->Start(); 68 68 ((Ps3Eye *)GetVerticalCamera())->Start(); 69 ((Mb800 *)GetGps())->Start();69 if(GetGps()) ((Mb800 *)GetGps())->Start(); 70 70 } 71 71 -
trunk/lib/FlairMeta/src/SimuX4.cpp
r185 r186 49 49 "motors", GetUavMultiplex()->MotorsCount(), simu_id,0)); 50 50 SetUsRangeFinder(new SimuUs("us", simu_id,0, 60)); 51 SetAhrs(new SimuAhrs(" imu", simu_id, 0,70));51 SetAhrs(new SimuAhrs("ahrs", simu_id, 0,70)); 52 52 Tab *bat_tab = new Tab(getFrameworkManager()->GetTabWidget(), "battery"); 53 53 SetBatteryMonitor(new BatteryMonitor(bat_tab->NewRow(), "battery")); … … 77 77 ((SimuCamera *)GetVerticalCamera())->Start(); 78 78 ((SimuCamera *)GetHorizontalCamera())->Start(); 79 ((SimuGps *)GetGps())->Start();79 if(GetGps()) ((SimuGps *)GetGps())->Start(); 80 80 } 81 81 -
trunk/lib/FlairMeta/src/SimuX8.cpp
r185 r186 49 49 "motors", GetUavMultiplex()->MotorsCount(), simu_id,0)); 50 50 SetUsRangeFinder(new SimuUs("us", simu_id,0, 60)); 51 SetAhrs(new SimuAhrs(" imu", simu_id, 0,70));51 SetAhrs(new SimuAhrs("ahrs", simu_id, 0,70)); 52 52 Tab *bat_tab = new Tab(getFrameworkManager()->GetTabWidget(), "battery"); 53 53 SetBatteryMonitor(new BatteryMonitor(bat_tab->NewRow(), "battery")); … … 77 77 ((SimuCamera *)GetVerticalCamera())->Start(); 78 78 ((SimuCamera *)GetHorizontalCamera())->Start(); 79 ((SimuGps *)GetGps())->Start();79 if(GetGps()) ((SimuGps *)GetGps())->Start(); 80 80 } 81 81 -
trunk/lib/FlairMeta/src/Uav.cpp
r185 r186 73 73 ahrs = (Ahrs *)inAhrs; 74 74 imu = (Imu *)ahrs->GetImu(); 75 //only add imu; as ahrs is son of imu, it will be logged together 75 76 getFrameworkManager()->AddDeviceToLog(imu); 76 77 } -
trunk/lib/FlairMeta/src/UavStateMachine.cpp
r177 r186 460 460 flagZTrajectoryFinished = false; 461 461 462 if((altitudeState==AltitudeState_t::Stopped) && safeToFly && uav->isReadyToFly() && uav->GetBatteryMonitor()->IsBatteryLow()==false ) {462 if((altitudeState==AltitudeState_t::Stopped) && safeToFly && uav->isReadyToFly() && uav->GetBatteryMonitor()->IsBatteryLow()==false && !flagConnectionLost) { 463 463 //The uav always takes off in fail safe mode 464 464 flagBatteryLow=false; … … 573 573 if (getFrameworkManager()->ConnectionLost() && !flagConnectionLost) { 574 574 flagConnectionLost = true; 575 Thread::Err("Connection lost\n");575 576 576 EnterFailSafeMode(); 577 577 if (altitudeState == AltitudeState_t::Stopped) { 578 SafeStop(); 578 Thread::Warn("Connection lost\n"); 579 Thread::Warn("UAV won't take off\n"); 579 580 } else { 581 Thread::Err("Connection lost\n"); 580 582 Land(); 581 583 } -
trunk/lib/FlairSensorActuator/src/Gx3_25_imu_impl.cpp
r173 r186 80 80 Time imuTime; 81 81 ImuData *imuData; 82 Quaternion prevQuat;prevQuat.q0=-2;//for init 82 83 self->GetDatas(&imuData); 83 84 … … 115 116 } 116 117 117 // periode a passer en argument (reglable)118 // ou plutot laisser la periode geree par le centrale (polling)119 // self->SetPeriodMS(2);120 118 SetContinuousMode(command); 121 119 … … 169 167 170 168 Quaternion quaternion=matrix.ToQuaternion(); 169 170 //try to keep quaternion continuous (select between quaternion or -quaternion) 171 if(prevQuat.q0!=-2) {//skip first iteration 172 //search the greatest absolute value to avoid problems near 0 (quaternion's norm=1) 173 if(fabs(prevQuat.q0)>=fabs(prevQuat.q1) && fabs(prevQuat.q0)>=fabs(prevQuat.q2) && fabs(prevQuat.q0)>=fabs(prevQuat.q3)) { 174 if(prevQuat.q0*quaternion.q0<0) {//if signs are different 175 quaternion=-quaternion; 176 } 177 } else if(fabs(prevQuat.q1)>=fabs(prevQuat.q0) && fabs(prevQuat.q1)>=fabs(prevQuat.q2) && fabs(prevQuat.q1)>=fabs(prevQuat.q3)) { 178 if(prevQuat.q1*quaternion.q1<0) {//if signs are different 179 quaternion=-quaternion; 180 } 181 } else if(fabs(prevQuat.q2)>=fabs(prevQuat.q0) && fabs(prevQuat.q2)>=fabs(prevQuat.q1) && fabs(prevQuat.q2)>=fabs(prevQuat.q3)) { 182 if(prevQuat.q2*quaternion.q2<0) {//if signs are different 183 quaternion=-quaternion; 184 } 185 } else if(fabs(prevQuat.q3)>=fabs(prevQuat.q0) && fabs(prevQuat.q3)>=fabs(prevQuat.q1) && fabs(prevQuat.q3)>=fabs(prevQuat.q2)) { 186 if(prevQuat.q3*quaternion.q3<0) {//if signs are different 187 quaternion=-quaternion; 188 } 189 } 190 } 191 prevQuat=quaternion; 192 171 193 self->ApplyRotation(filteredAngRates); 172 194 self->ApplyRotation(quaternion); -
trunk/lib/FlairSensorActuator/src/Imu.cpp
r179 r186 42 42 setupGroupbox = new GroupBox(sensorTab->NewRow(), name); 43 43 rotation = new OneAxisRotation(sensorTab->NewRow(), "post rotation"); 44 AddDataToLog(imuData); 44 45 } 45 46 -
trunk/lib/FlairSensorActuator/src/Mb800.cpp
r180 r186 108 108 109 109 while (!ToBeStopped()) { 110 SleepMS(10);110 //SleepMS(10);?? 111 111 size = 0; 112 112 while (!ToBeStopped()) { -
trunk/lib/FlairSensorActuator/src/SimuImu.cpp
r173 r186 79 79 state.wy = input->ValueNoMutex(8, 0); 80 80 state.wz = input->ValueNoMutex(9, 0); 81 state.ax = input->ValueNoMutex(13, 0); 82 state.ay = input->ValueNoMutex(14, 0); 83 state.az = input->ValueNoMutex(15, 0); 84 state.mx = input->ValueNoMutex(16, 0); 85 state.my = input->ValueNoMutex(17, 0); 86 state.mz = input->ValueNoMutex(18, 0); 81 87 input->ReleaseMutex(); 82 88 … … 108 114 Quaternion quaternion(state.q0, state.q1, state.q2, state.q3); 109 115 Vector3Df angRate(state.wx, state.wy, state.wz); 116 Vector3Df rawAcc(state.ax, state.ay, state.az); 117 Vector3Df rawMag(state.mx, state.my, state.mz); 118 Vector3Df rawGyr(state.wx, state.wy, state.wz); 110 119 ApplyRotation(angRate); 111 120 ApplyRotation(quaternion); 121 ApplyRotation(rawAcc); 122 ApplyRotation(rawMag); 123 ApplyRotation(rawGyr); 112 124 ahrsData->SetQuaternionAndAngularRates(quaternion,angRate); 113 125 imuData->SetRawAccMagAndGyr(rawAcc,rawMag,rawGyr); 114 126 imuData->SetDataTime(GetTime()); 115 127 ahrsData->SetDataTime(GetTime()); -
trunk/lib/FlairSensorActuator/src/SimuImu.h
r158 r186 94 94 float wy; 95 95 float wz; 96 float ax; 97 float ay; 98 float az; 99 float mx; 100 float my; 101 float mz; 96 102 } imu_states_t; 97 103 -
trunk/lib/FlairSensorActuator/src/TargetController.cpp
r137 r186 118 118 Message *message; 119 119 120 if (getFrameworkManager()->ErrorOccured() || !ControllerInitialization()) { 120 //if (getFrameworkManager()->ErrorOccured() || !ControllerInitialization()) { 121 if (!ControllerInitialization()) { 121 122 SafeStop(); 122 123 Thread::Err("An error occured, we don't proceed with the loop.\n"); -
trunk/lib/FlairSimulator/src/Model_impl.cpp
r167 r186 114 114 self->state[-2] = self->state[0]; 115 115 116 cvmatrix_descriptor *desc = new cvmatrix_descriptor(1 3, 1);116 cvmatrix_descriptor *desc = new cvmatrix_descriptor(19, 1); 117 117 desc->SetElementName(0, 0, "q0"); 118 118 desc->SetElementName(1, 0, "q1"); … … 128 128 desc->SetElementName(11, 0, "vy"); 129 129 desc->SetElementName(12, 0, "vz"); 130 desc->SetElementName(13, 0, "ax"); 131 desc->SetElementName(14, 0, "ay"); 132 desc->SetElementName(15, 0, "az"); 133 desc->SetElementName(16, 0, "mx"); 134 desc->SetElementName(17, 0, "my"); 135 desc->SetElementName(18, 0, "mz"); 130 136 output = new cvmatrix(this, desc, floatType, "state"); 131 137 delete desc; … … 318 324 output->SetValueNoMutex(11, 0, self->state[0].Vel.y); 319 325 output->SetValueNoMutex(12, 0, self->state[0].Vel.z); 326 //todo: put acc and mag 327 output->SetValueNoMutex(13, 0, 0); 328 output->SetValueNoMutex(14, 0, 0); 329 output->SetValueNoMutex(15, 0, 0); 330 output->SetValueNoMutex(16, 0, 0); 331 output->SetValueNoMutex(17, 0, 0); 332 output->SetValueNoMutex(18, 0, 0); 320 333 output->ReleaseMutex(); 321 334 output->SetDataTime(GetTime());
Note:
See TracChangeset
for help on using the changeset viewer.