Newer
Older
// pos.psi_the_phi[0] = -999;
// pos.psi_the_phi[1] = -999;
// pos.psi_the_phi[2] = -999;
// pos.gear_flap_vect[0] = -999;
// pos.gear_flap_vect[1] = -999;
// pos.gear_flap_vect[2] = -999;
// writeBytes((const char*)&pos, sizeof(pos));
Lorenz Meier
committed
}
/**
* Sets a random position with an offset of max 1/1000 degree
* and max 100 m altitude
*/
void QGCXPlaneLink::setRandomPosition()
{
// Initialize generator
srand(0);
double offLat = rand() / static_cast<double>(RAND_MAX) / 500.0 + 1.0/500.0;
double offLon = rand() / static_cast<double>(RAND_MAX) / 500.0 + 1.0/500.0;
double offAlt = rand() / static_cast<double>(RAND_MAX) * 200.0 + 100.0;
Anton Babushkin
committed
if (mav->getAltitudeAMSL() + offAlt < 0)
Lorenz Meier
committed
{
offAlt *= -1.0;
}
setPositionAttitude(mav->getLatitude() + offLat,
mav->getLongitude() + offLon,
Anton Babushkin
committed
mav->getAltitudeAMSL() + offAlt,
Lorenz Meier
committed
mav->getRoll(),
mav->getPitch(),
mav->getYaw());
}
void QGCXPlaneLink::setRandomAttitude()
{
// Initialize generator
srand(0);
double roll = rand() / static_cast<double>(RAND_MAX) * 2.0 - 1.0;
double pitch = rand() / static_cast<double>(RAND_MAX) * 2.0 - 1.0;
double yaw = rand() / static_cast<double>(RAND_MAX) * 2.0 - 1.0;
setPositionAttitude(mav->getLatitude(),
mav->getLongitude(),
Anton Babushkin
committed
mav->getAltitudeAMSL(),
Lorenz Meier
committed
roll,
pitch,
yaw);
}
Lorenz Meier
committed
/**
* @brief Connect the connection.
*
* @return True if connection has been established, false if connection couldn't be established.
**/
bool QGCXPlaneLink::connectSimulation()
{
Lorenz Meier
committed
if (connectState) {
qDebug() << "Simulation already active";
} else {
qDebug() << "STARTING X-PLANE LINK, CONNECTING TO" << remoteHost << ":" << remotePort;
// XXX Hack
storeSettings();
start(HighPriority);
}
Lorenz Meier
committed
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
}
/**
* @brief Check if connection is active.
*
* @return True if link is connected, false otherwise.
**/
bool QGCXPlaneLink::isConnected()
{
return connectState;
}
QString QGCXPlaneLink::getName()
{
return name;
}
void QGCXPlaneLink::setName(QString name)
{
this->name = name;
// emit nameChanged(this->name);
}