Download Development of a PC-Based Object-Oriented Real
Transcript
3.8.1.2.2 CubSplineTrajGen Class Description The cubic spline offline trajectory generation class CubSplineTrajGen is derived from the CTrajGenerator base class. CubSplineTrajGen has two private member functions: getAcceleration(), which calculates the acceleration of each knot so that the acceleration, velocity and position of the trajectory is continuous and interpPoint(), which interpolates the position for any point in time. InterpPoint() is declared as a virtual function in the base class CTrajGenerator, however, for offline trajectory generation overloads the operators to make the function suitable for offline computation. Both interpPoint and getAcceleration() are used by calcPath(), which is the only public member function of this class. CalcPath() calculates the cubic spline path for any set of non-uniformly spaced knots, and produces a full position queue ready for the control loop. The mathematics of this class are covered in Section 3.12.1. 3.8.1.2.3 PVTOnlineTrajGen Class Description The Position-Velocity-Time (PVT) trajectory generation class PVTOnlineTrajGen is derived from the CTrajGenerator base class. There are eight member variables in this class: iCurKnotPtr is the current position on the circular queue used by the trajectory generator, the coefficients fA, fB, fC and fD of the cubic spline polynomial equation, and arrays for two time instances of position, velocity and time in variables fP, fV, and fT. Public member functions include: a constructor used to initialize class variables, readData() used to read PVT values from circular queue, calcCoeff() uses the PVT knots to calculate the fA, fB, fC, and fD coefficients of the cubic polynomial for the current time segment, interpPoint() is used to interpolate the position within a spline segment, and saveDataInstance() used to move array values from the current time instance to previous time instance in fP, fV and fT. The mathematical details of this class are covered in Section 3.12.2. 3.8.1.2.4 PIDffCtrl Class Description The PID control with feed-forward acceleration and velocity algorithm with a notch filter is implemented in the PIDffCtrl class. This class is derived from the CServoCtrl base class and has five private member variables representing the gains of the controller, which can be set by calling the public setGain() member function. The gains are: portional gain (fPGain), integral gain (fIGain), derivative gain (fDGain), feed-forward velocity gain (fKvff), and acceleration gain (fKaff). Two private arrays are used to store the coefficients of the notch filter. Array fNcoeff stores the coefficients for the numerator and fDcoeff stores the coefficients of the denominator, covered in Section 3.11.1 of the notch filter. 43