140 likes | 263 Views
Using C-kernels to Capture Instrument Articulation. June 28, 2002 Scott Turner (sturner@spice.jpl.nasa.gov). Capturing Articulation. Instrument-kernel. ... INS-82762_FOV_FRAME = ‘ CASSINI_MIMI_LEMMS1 ’. Frame-kernel. ... FRAME_CASSINI_MIMI_LEMMS1 = -82762
E N D
Using C-kernels to CaptureInstrument Articulation June 28, 2002 Scott Turner (sturner@spice.jpl.nasa.gov)
Capturing Articulation Instrument-kernel ... INS-82762_FOV_FRAME = ‘CASSINI_MIMI_LEMMS1’ ... Frame-kernel ... FRAME_CASSINI_MIMI_LEMMS1 = -82762 FRAME_-82762_NAME = ‘CASSINI_MIMI_LEMMS1’ FRAME_-82762_CLASS = 3 FRAME_-82762_CLASS_ID = -82762 FRAME_082762_CENTER = -82 CK_-82762_SCLK = -82 ... SCLK-kernel ... SCLK_DATA_TYPE_82 = ( 1 ) ... SPK C-kernel ID = -82 ID = -82762
C-kernel Based Fixed Offset J2000 CASSINI_SC_COORD CASSINI_MIMI_LEMMS_BASE CASSINI_MIMI_LEMMS_ART CASSINI_MIMI_LEMMS1 CASSINI_MIMI_LEMMS2 The Cassini Frames Hierarchy • C-kernels communicate to the frame system what frame they are relative to, thus multiple paths through the frame tree can and do exist. • While multiple paths may exist, at any epoch, the C-kernel priority system preserves the tree structure.
Multiple Paths, Segment Priority and Kernel Loading • Use furnsh_c to load all SPICE kernels, including CK, SPK, IK, FK, and SCLK files. • The standard SPICE paradigm regarding precedence is: “The last segment of the last kernel loaded has the highest priority”. • Load nominal, background, or predict content first. • Background Orientation (Resting position of Articulating Instruments, etc.) • Any “fixed” offset C-kernels designed to support the articulation branch of the frame tree. • Loading kernels in the wrong order can, and often will, result in retrieval of incorrect pointing or SPICE errors due to missing data.
File #1 “Fixed Offset” INS to ART File #2 “Resting Position” ART to BASE SEG#1: ART to BASE File #3 SEG#2: ART to BASE SEG#1: INS to SC File #4 SEG#2: INS to SC Example: Properly Loaded CKs LOWEST HIGHEST A B time
File #1 “Fixed Offset” INS to ART File #2 “Resting Position” ART to BASE SEG#1: ART to BASE File #3 SEG#2: ART to BASE SEG#1: INS to SC File #4 SEG#2: INS to SC Example: Improperly Loaded CKs LOWEST HIGHEST A B time
Creating C-kernels (1) • The quaternions in a C-kernel encapsulate a C-matrix that rotates vectors from a base-reference frame to the “instrument” frame: Vinstrument = [C] Vreference • There are several types of C-kernel segments: • Type 1 - Discrete Pointing • Type 2 - Constant Angular Velocity • Type 3 - Linear Interpolation (*Commonly Used) • Type 4 - Chebyshev Polynomials • There are several “styles” of quaternions that are in use in the space science community. SPICE style quaternions are what must be placed in a C-kernel.
Creating C-kernels (2) • Including angular rates in C-kernel segments is usually better than omitting them. • spkezr_c ( “OBJECT”, et, “CASSINI_CDA”, “LT+S”, “CASSINI”, state, < ); • Any other computations involving state transformations require angular rates. • “Construction” of angular rates from quaternions or other rotational sources is not particularly difficult. • Lastly, consider including a properly subsetted version of the relevant “fixed offset” CK segments in your predict C-kernels.
Creating a Type 3 C-kernel • The following code fragment illustrates the creation of a type 3 C-kernel with a single segment. ckopn_c ( filename, “my-ckernel”, 0, &handle ); /* Insert code that properly constructs the sclkdp, quats, avvs, and starts arrays. */ ckw03_c ( handle, begtim, endtim, inst, “reference_frame”, avflag, “segment_id”, nrec, sclkdp, quats, avvs, nints, starts ); ckcls_c ( handle );
Anatomy of the ckw03_c Call (1) • handle - file handle for the newly created C-kernel. • begtim, endtim - start and stop time in SCLK ticks for the segment. • inst - instrument ID code for the C-kernel. This can be obtained using: • namfrm_c ( “CASSINI_CDA”, &inst ); • ref - name of the reference or base frame as known to SPICE. In the case of articulating instruments on Cassini: “CASSINI_<INS>_BASE”. • avflag - a SpiceBoolean indicating whether to include angular velocity in the segment. • segid - a string identifying the segment. It should be less than 40 characters in length.
Anatomy of the ckw03_c Call (2) • nrec - number of records in sclkdp, quats, and avvs • sclkdp - monotonically increasing list of times in SCLK ticks that identify when quats and avvs were sampled. • quats - a list of SPICE quaternions that rotate vectors from the ref to inst frames. • m2q_c ( C_matrix, quaterion ); • avvs - angular rate vectors expanded in the ref frame. • starts - a list of SCLK ticks indicating the start of interpolation intervals. They must correspond to entries in sclkdp. • nints - number of entries in starts.
Converting an Angle Time-Series • Suppose you have a time series of angles (angles) for a Cassini articulating instrument and with epochs (epochs)in ephemeris time. Converting them to quaternions and ticks is as easy as: for(k=0; k<nrec; k++) { sce2c_c( scid, epochs[k], &sclkdp[k]); axisar_c( zaxis, -rpd_c()*angles[k], rotmat ); m2q_c ( rotmat, &quats[k][0] ); } where zaxis is ( 0, 0, 1 ) and scid is -82 for Cassini.
Approximating Angular Rates • One of the easiest ways to accomplish this is to assume a constant rotation rate between subsequent quaternions: for(k=0; k<(nrec-1); k++ ) { q2m_c ( quats[k][0], init_rot ); q2m_c ( quats[k+1][0], final_rot ); mtxm_c ( final_rot, init_rot, rotmat ); raxisa_c ( rotmat, axis, &angle ); sct2e_c ( scid, sclkdp[k], &init_et ); sct2e_c ( scid, sclkdp[k+1], &final_et ); vscl_c ( angle/(final_et-init_et), axis, &avvs[k][0] ); } • Lastly, simply copy the (nrec-1) value of avvs into the last element of avvs.
A Few Words of Caution • Constructing angular rates in this fashion assumes that between subsequent quaternions no more than a 180-degree rotation has occurred. In short raxisa_c chooses the smallest angle that performs the rotation encapsulated in the input matrix. • Other techniques exist, including differentiating quaternions. Care must be exercised when taking that particular approach however. • NAIF has a tool, msopck, that creates C-kernels from text input files listing quaternions, Euler angles, or rotation matrices tagged by UTC or SCLK times. It can be useful for validating C-kernel production code.