Rrn-Time Models

Purpose

Allows a FLIGHTLAB model to be used in end-user applications without requiring the Scope development system.

Procedure

  1. Requirements analysis
  2. Specify FLIGHTLAB model data to be accessed by defining Scope variable lists
  3. Define corresponding C data structures
  4. Integrate application with FCM library
  5. Dump the model from FLIGHTLAB with FCMDUMP command
  6. Load model into C application at runtime

Improvements over CTRAN

Scope API -- Dumping a model

  1. Load model
  2. Set initial conditions, trim, etc.
  3. Set up and declare variable lists
  4. Run FCMDUMP("filename.fcm")

Scope API -- Example

// Load model:
exec("$FL_DIR/flme/models/articulated/arti-rgd-3iv-qs.def",1);

// Set initial conditions:
world_model_airframe_cpg_testcond_veq = 20;
exec("xatestcond.exc",1);
exec("xamodeltrim.exc",1);

// Set up and declare variable lists:
pushg(world_model_airframe_cpg_xaout)
    varlist @STATES "Position, orientation, and velocity" =  ..
       posxi,posyi,poszi, vxb,vyb,vzb, phi,theta,psi ;
popg;
fcmdump(@states);

// Dump model:
fcmdump("articulated.fcm");

C API -- Overview

C API -- Data Types

C API -- Initialization

C API -- Operations

C API -- Variable lists

C API -- Checkpoint and Restore

C API -- Example

#include "fcm.h"
... /* Initialization: */
FCM_FILE       fcm        = fcm_open("articulated.fcm");
FCM_OPERATION  op_step    = fcm_lookup_operation(fcm,"STEP");
FCM_VARLIST    vl_states  = fcm_lookup_varlist(fcm,"@STATES");
FCM_MODEL      model      = fcm_create(fcm);
double         state_buf[N_STATES];
... /* Run-time, once per frame: */
fcm_invoke(model, op_step);
fcm_fetch(model, vl_states, state_buf, N_STATES);
... /* Cleanup: */
fcm_close(fcm);

Error reporting

Locating the components library

  1. Explicitly specified with fcm_load_components()
  2. $FL_FCM_COMPONENTS environment variable
  3. flcomp.so in current working directory

Note: fcm_load_components(NULL); called automatically by libflcomms when needed

Thread-safety issues

Thread-safety -- suggested policy

Conclusion