Example #1
0
void	Button::DrawContent(sf::RenderWindow &in) const
{
    sf::Text	txt;
    sf::Font	Acent;
    sf::Sprite	pic;
    int	x;
    int	y;
    int	x2;
    int	y2;

    getPosU(x, y);
    getPosD(x2, y2);
    x2 = in.getSize().x / 4;
    //x2 -= 100;
    Acent.loadFromFile("./Ressources/Acens.ttf");
    if (_isTarget == true)
        txt.setColor(sf::Color(205, 225, 0));
    txt.setFont(Acent);
    txt.setString(this->getContent());
    txt.setPosition(_initX, _initY);
    in.draw(txt);
    if (this->getWin() != NULL)
        if (this->getWin()->getType() == GAME)
        {
            if (this->getWin()->isGood() == true)
            {
                pic.setPosition(_initX, _initY + 50);
                pic.setTexture(this->getWin()->getPic());
                pic.setScale(0.10f, 0.15f);
                in.draw(pic);
            }
        }
}
// Return the last calculated latitude, longitude and height of the body frame origin in WGS-84
// If a calculated location isn't available, return a raw GPS measurement
// The status will return true if a calculation or raw measurement is available
// The getFilterStatus() function provides a more detailed description of data health and must be checked if data is to be used for flight control
bool NavEKF2_core::getLLH(struct Location &loc) const
{
    const AP_GPS &gps = AP::gps();
    Location origin;
    float posD;

    if(getPosD(posD) && getOriginLLH(origin)) {
        // Altitude returned is an absolute altitude relative to the WGS-84 spherioid
        loc.alt =  origin.alt - posD*100;
        loc.relative_alt = 0;
        loc.terrain_alt = 0;

        // there are three modes of operation, absolute position (GPS fusion), relative position (optical flow fusion) and constant position (no aiding)
        if (filterStatus.flags.horiz_pos_abs || filterStatus.flags.horiz_pos_rel) {
            loc.lat = EKF_origin.lat;
            loc.lng = EKF_origin.lng;
            // correct for IMU offset (EKF calculations are at the IMU position)
            loc.offset((outputDataNew.position.x + posOffsetNED.x), (outputDataNew.position.y + posOffsetNED.y));
            return true;
        } else {
            // we could be in constant position mode  because the vehicle has taken off without GPS, or has lost GPS
            // in this mode we cannot use the EKF states to estimate position so will return the best available data
            if ((gps.status() >= AP_GPS::GPS_OK_FIX_2D)) {
                // we have a GPS position fix to return
                const struct Location &gpsloc = gps.location();
                loc.lat = gpsloc.lat;
                loc.lng = gpsloc.lng;
                return true;
            } else {
                // if no GPS fix, provide last known position before entering the mode
                // correct for IMU offset (EKF calculations are at the IMU position)
                loc.offset((lastKnownPositionNE.x + posOffsetNED.x), (lastKnownPositionNE.y + posOffsetNED.y));
                return false;
            }
        }
    } else {
        // If no origin has been defined for the EKF, then we cannot use its position states so return a raw
        // GPS reading if available and return false
        if ((gps.status() >= AP_GPS::GPS_OK_FIX_3D)) {
            const struct Location &gpsloc = gps.location();
            loc = gpsloc;
            loc.relative_alt = 0;
            loc.terrain_alt = 0;
        }
        return false;
    }
}