コード例 #1
0
ファイル: airdata_mgr.cpp プロジェクト: metiscus/microgear
void AirData_close() {
    // traverse configured modules
    SGPropertyNode *toplevel = fgGetNode("/config/sensors/air-data-group", true);
    for ( int i = 0; i < toplevel->nChildren(); ++i ) {
	SGPropertyNode *section = toplevel->getChild(i);
	string name = section->getName();
	if ( name == "airdata" ) {
	    string source = section->getChild("source", 0, true)->getStringValue();
	    string basename = "/sensors/";
	    basename += section->getDisplayName();
	    // printf("i = %d  name = %s source = %s %s\n",
	    //	   i, name.c_str(), source.c_str(), basename.c_str());
	    if ( source == "null" ) {
		// do nothing
	    } else if ( source == "fgfs" ) {
		// nop
	    } else if ( source == "ardupilot" ) {
		// nop
#ifdef ENABLE_MNAV_SENSOR
	    } else if ( source == "mnav" ) {
		// nop
#endif
	    } else {
		printf("Unknown air data source = '%s' in config file\n",
		       source.c_str());
	    }
	}
    }
}
コード例 #2
0
ファイル: airdata_mgr.cpp プロジェクト: metiscus/microgear
void AirData_init() {
    debug2b1.set_name("debug2b1 airdata update");
    debug2b2.set_name("debug2b2 airdata console link");

    // initialize air data property nodes
    airdata_timestamp_node = fgGetNode("/sensors/air-data/time-stamp", true);
    airdata_altitude_node = fgGetNode("/sensors/air-data/altitude-m", true);
    airdata_airspeed_node = fgGetNode("/sensors/air-data/airspeed-kt", true);

    // input property nodes
    filter_timestamp_node = fgGetNode("/filters/filter/time-stamp", true);
    filter_alt_node = fgGetNode("/position/altitude-m", true);

    // filtered/computed output property nodes
    altitude_filt_node = fgGetNode("/position/altitude-pressure-m", true);
    airspeed_filt_node = fgGetNode("/velocity/airspeed-kt", true);

    true_alt_ft_node = fgGetNode("/position/altitude-true-combined-ft",true);
    agl_alt_ft_node = fgGetNode("/position/altitude-pressure-agl-ft", true);

    pressure_error_m_node
	= fgGetNode("/position/pressure-error-m", true);
    vert_fps_node
	= fgGetNode("/velocity/pressure-vertical-speed-fps",true);
    forward_accel_node = fgGetNode("/acceleration/airspeed-ktps",true);
    ground_alt_press_m_node
        = fgGetNode("/position/ground-altitude-pressure-m", true);

    // initialize comm nodes
    airdata_console_skip = fgGetNode("/config/remote-link/airdata-skip", true);
    airdata_logging_skip = fgGetNode("/config/logging/airdata-skip", true);

    // traverse configured modules
    SGPropertyNode *toplevel = fgGetNode("/config/sensors/air-data-group", true);
    for ( int i = 0; i < toplevel->nChildren(); ++i ) {
	SGPropertyNode *section = toplevel->getChild(i);
	string name = section->getName();
	if ( name == "air-data" ) {
	    string source = section->getChild("source", 0, true)->getStringValue();
	    bool enabled = section->getChild("enable", 0, true)->getBoolValue();
	    if ( !enabled ) {
		continue;
	    }
	    string basename = "/sensors/";
	    basename += section->getDisplayName();
	    printf("i = %d  name = %s source = %s %s\n",
		   i, name.c_str(), source.c_str(), basename.c_str());
	    if ( source == "null" ) {
		// do nothing
	    } else if ( source == "ardupilot" ) {
		ardupilot_airdata_init( basename );
	    } else if ( source == "fgfs" ) {
		fgfs_airdata_init( basename );
#ifdef ENABLE_MNAV_SENSOR
	    } else if ( source == "mnav" ) {
		mnav_airdata_init( basename );
#endif // ENABLE_MNAV_SENSOR
	    } else {
		printf("Unknown air data source = '%s' in config file\n",
		       source.c_str());
	    }
	}
    }
}
コード例 #3
0
ファイル: airdata_mgr.cpp プロジェクト: metiscus/microgear
bool AirData_update() {
    debug2b1.start();

    air_prof.start();

    bool fresh_data = false;

    // traverse configured modules
    SGPropertyNode *toplevel = fgGetNode("/config/sensors/air-data-group", true);
    for ( int i = 0; i < toplevel->nChildren(); ++i ) {
	SGPropertyNode *section = toplevel->getChild(i);
	string name = section->getName();
	if ( name == "air-data" ) {
	    string source = section->getChild("source", 0, true)->getStringValue();
	    bool enabled = section->getChild("enable", 0, true)->getBoolValue();
	    if ( !enabled ) {
		continue;
	    }
	    string basename = "/sensors/";
	    basename += section->getDisplayName();
	    // printf("i = %d  name = %s source = %s %s\n",
	    //	   i, name.c_str(), source.c_str(), basename.c_str());
	    if ( source == "null" ) {
		// do nothing
	    } else if ( source == "ardupilot" ) {
		fresh_data = ardupilot_airdata_update();
	    } else if ( source == "fgfs" ) {
		fresh_data = fgfs_airdata_update();
#ifdef ENABLE_MNAV_SENSOR
	    } else if ( source == "mnav" ) {
		fresh_data = mnav_get_airdata();
#endif // ENABLE_MNAV_SENSOR
	    } else {
		printf("Unknown air data source = '%s' in config file\n",
		       source.c_str());
	    }
	}
    }

    debug2b1.stop();
    debug2b2.start();

    if ( fresh_data ) {
	update_pressure_helpers();

	if ( remote_link_on || log_to_file ) {
	    uint8_t buf[256];
	    int size = packetizer->packetize_airdata( buf );

	    if ( remote_link_on ) {
		// printf("sending filter packet\n");
		remote_link_airdata( buf, size,
				      airdata_console_skip->getIntValue() );
	    }

	    if ( log_to_file ) {
		log_airdata( buf, size, airdata_logging_skip->getIntValue() );
	    }
	}
    }

    debug2b2.stop();

    air_prof.stop();

    return fresh_data;
}