FACT++  1.0
template<class T , class S >
int StateMachineDrive< T, S >::UpdateTrackingPosition ( )
inlineprivate

Definition at line 2340 of file drivectrl.cc.

References Local::az, data, RaDec::dec, dev, Time::GetAsStr(), Drive::State::kOnTrack, Drive::State::kTracking, PointingData::mount, Nova::ORM(), PointingData::pointing, RaDec::ra, PointingData::sky, PointingData::source, and Local::zd.

2341  {
2342  // First calculate deviation between
2343  // command position and nominal position
2344  //fPointing.mount = sepos; // [deg] ref pos for alignment
2345  const PointingData data = CalcPointingPos(fDrive.GetSeTime());
2346 
2347  // Get current position and calculate deviation
2348  const Encoder sepos = fDrive.GetSePos()*360; // [deg]
2349  const Encoder dev = sepos - data.mount;
2350 
2351  // Calculate absolut deviation on the sky
2352  const double absdev = GetDevAbs(data.mount.zd, sepos.zd, dev.az)*3600;
2353 
2354  // Smoothing
2355  fDevBuffer[fDevCount++%5] = absdev;
2356 
2357  // Calculate average
2358  const uint8_t cnt = fDevCount<5 ? fDevCount : 5;
2359  const double avgdev = accumulate(fDevBuffer.begin(), fDevBuffer.begin()+cnt, 0.)/cnt;
2360 
2361  // Count the consecutive number of avgdev below fDeviationLimit
2362  if (avgdev<fDeviationLimit)
2363  fTrackingCounter++;
2364  else
2365  fTrackingCounter = 0;
2366 
2367  const double ha = fmod(fDrive.GetSeTime(),1)*24 - Nova::ORM().lng/15;
2368 
2369  array<double, 12> dim;
2370  dim[0] = data.pointing.ra * 12/M_PI; // Ra [h] optical axis
2371  dim[1] = data.pointing.dec * 180/M_PI; // Dec [deg] optical axis
2372  dim[2] = ha - data.pointing.ra; // Ha [h] optical axis
2373  dim[3] = data.source.ra * 12/M_PI; // SrcRa [h] source position
2374  dim[4] = data.source.dec * 180/M_PI; // SrcDec [deg] source position
2375  dim[5] = ha - data.source.ra; // SrcHa [h] source position
2376  dim[6] = data.sky.zd * 180/M_PI; // Zd [deg] optical axis
2377  dim[7] = data.sky.az * 180/M_PI; // Az [deg] optical axis
2378  dim[8] = dev.zd; // dZd [deg] control deviation
2379  dim[9] = dev.az; // dAz [deg] control deviation
2380  dim[10] = absdev; // dev [arcsec] absolute control deviation
2381  dim[11] = avgdev; // dev [arcsec] average control deviation
2382 
2383  fDrive.UpdateTracking(fDrive.GetSeTime(), dim);
2384 
2385  if (fDrive.GetVerbosity())
2386  T::Out() << Time().GetAsStr(" %H:%M:%S.%f") << " - Deviation [deg] " << absdev << "\"|" << avgdev << "\"|" << fDevCount<< " dZd=" << dev.zd*3600 << "\" dAz=" << dev.az*3600 << "\"" << endl;
2387 
2388  // Maximum deviation execeeded -> fall back to Tracking state
2389  if (T::GetCurrentState()==State::kOnTrack && avgdev>fDeviationMax)
2390  return State::kTracking;
2391 
2392  // Condition for OnTrack state achieved -> enhance to OnTrack state
2393  if (T::GetCurrentState()==State::kTracking && fTrackingCounter>=fDeviationCounter)
2394  return State::kOnTrack;
2395 
2396  // No state change
2397  return T::GetCurrentState();
2398  }
vector< double > fDevBuffer
Definition: drivectrl.cc:1591
double GetDevAbs(double nomzd, double meszd, double devaz)
Definition: drivectrl.cc:1762
uint16_t fDeviationMax
Definition: drivectrl.cc:1589
uint64_t fTrackingCounter
Definition: drivectrl.cc:1594
const LnLatPosn & ORM()
Definition: nova.h:66
Adds some functionality to boost::posix_time::ptime for our needs.
Definition: Time.h:30
RaDec pointing
Definition: drivectrl.cc:165
uint64_t fDevCount
Definition: drivectrl.cc:1592
double zd
Definition: drivectrl.cc:51
RaDec source
Definition: drivectrl.cc:164
PointingData CalcPointingPos(double mjd)
Definition: drivectrl.cc:1815
double az
Definition: drivectrl.cc:52
uint16_t fDeviationLimit
Definition: drivectrl.cc:1587
double dec
Definition: drivectrl.cc:37
Encoder mount
Definition: drivectrl.cc:168
uint16_t fDeviationCounter
Definition: drivectrl.cc:1588
float data[4 *1440]
Return to feeserver c CVS log Up to[MAIN] dcscvs FeeServer feeserver src Wed FeeServer_v0 v0 dev
Definition: feeserver.c:5
std::string GetAsStr(const char *fmt="%Y-%m-%d %H:%M:%S") const
Definition: Time.cc:240
double ra
Definition: drivectrl.cc:36

+ Here is the call graph for this function: