You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
241 lines
7.6 KiB
241 lines
7.6 KiB
#include "objectSystemAnchor.h"
|
|
|
|
position3D::position3D(){
|
|
x = y = z = lat = lon = rot_z = rot_y = rot_z = speed = 0.f;
|
|
utmZone = 0;
|
|
};
|
|
|
|
position3D::~position3D(){
|
|
};
|
|
|
|
void position3D::setPositionWGS84( C3D_FLOAT Lat, C3D_FLOAT Lon, C3D_FLOAT Alt ){
|
|
coordConverter CC;
|
|
lat = Lat;
|
|
lon = Lon;
|
|
z = Alt;
|
|
#ifdef FLOAT_64
|
|
double A, B;
|
|
CC.LatLonToUTMXY( lat, lon, utmZone, A, B );
|
|
x = A;
|
|
y = B;
|
|
#else
|
|
CC.LatLonToUTMXY( lat, lon, utmZone, x, y );
|
|
#endif
|
|
|
|
};
|
|
|
|
void position3D::setPositionXYZ( C3D_FLOAT X, C3D_FLOAT Y, C3D_FLOAT Z, int zone ){
|
|
coordConverter CC;
|
|
if( zone != 0 ) utmZone = zone;
|
|
x = X;
|
|
y = Y;
|
|
z = Z;
|
|
#ifdef FLOAT_64
|
|
double A, B;
|
|
CC.UTMXYToLatLon(x, y, utmZone, false, A, B);
|
|
lat = A;
|
|
lon = B;
|
|
#else
|
|
CC.UTMXYToLatLon(x, y, utmZone, false, lat, lon);
|
|
#endif
|
|
};
|
|
|
|
void position3D::setOrientationRad( C3D_FLOAT RotX, C3D_FLOAT RotY, C3D_FLOAT RotZ ){
|
|
rot_x = RotX;
|
|
rot_y = RotY;
|
|
rot_z = RotZ;
|
|
};
|
|
|
|
void position3D::setOrientationDeg(C3D_FLOAT RotX, C3D_FLOAT RotY, C3D_FLOAT RotZ){
|
|
rot_x = deg2rad(RotX);
|
|
rot_y = deg2rad(RotY);
|
|
rot_z = deg2rad(RotZ);
|
|
};
|
|
|
|
void position3D::setSpeed( C3D_FLOAT Speed ){
|
|
speed = Speed;
|
|
};
|
|
|
|
|
|
systemAnchor* systemAnchor::_instance = 0;
|
|
|
|
/**
|
|
* Returns the single instance of the object.
|
|
*/
|
|
systemAnchor* systemAnchor::getInstance() {
|
|
// check if the instance has been created yet
|
|
if (0 == _instance) {
|
|
// if not, then create it
|
|
_instance = new systemAnchor;
|
|
}
|
|
// return the single instance
|
|
return _instance;
|
|
};
|
|
|
|
systemAnchor::systemAnchor(){
|
|
config_setting_t *pSetting;
|
|
m_pSettings = NULL;
|
|
pSetting = basicSettingsProvider::getInstance()->getSubNode( NULL, "APPLICATION_GUI" );
|
|
if( pSetting != NULL ){
|
|
m_pSettings = basicSettingsProvider::getInstance()->getSubNode( pSetting, "SYSTEM_ANCHOR" );
|
|
};
|
|
// Read Config
|
|
if( m_pSettings != NULL ){
|
|
pSetting = config_setting_get_member(m_pSettings, TAG_POSITION_LAT );
|
|
if (pSetting == NULL){
|
|
lat = 0.f;
|
|
pSetting = config_setting_add(m_pSettings, TAG_POSITION_LAT, CONFIG_TYPE_FLOAT );
|
|
config_setting_set_float( pSetting, lat );
|
|
basicSettingsProvider::getInstance()->compromise();
|
|
} else {
|
|
lat = config_setting_get_float(pSetting);
|
|
};
|
|
pSetting = config_setting_get_member(m_pSettings, TAG_POSITION_LON );
|
|
if (pSetting == NULL){
|
|
lon = 0.f;
|
|
pSetting = config_setting_add(m_pSettings, TAG_POSITION_LON, CONFIG_TYPE_FLOAT );
|
|
config_setting_set_float( pSetting, lon );
|
|
basicSettingsProvider::getInstance()->compromise();
|
|
} else {
|
|
lon = config_setting_get_float(pSetting);
|
|
};
|
|
pSetting = config_setting_get_member(m_pSettings, TAG_POSITION_ALT );
|
|
if (pSetting == NULL){
|
|
z = 0.f;
|
|
pSetting = config_setting_add(m_pSettings, TAG_POSITION_ALT, CONFIG_TYPE_FLOAT );
|
|
config_setting_set_float( pSetting, z );
|
|
basicSettingsProvider::getInstance()->compromise();
|
|
} else {
|
|
z = config_setting_get_float(pSetting);
|
|
};
|
|
/* No need to set Anchore Orientation
|
|
pSetting = config_setting_get_member(m_pSettings, TAG_POSITION_ROLL );
|
|
if (pSetting == NULL){
|
|
rot_y = 0.f;
|
|
pSetting = config_setting_add(m_pSettings, TAG_POSITION_ROLL, CONFIG_TYPE_FLOAT );
|
|
config_setting_set_float(pSetting, rot_y);
|
|
basicSettingsProvider::getInstance()->compromise();
|
|
} else {
|
|
rot_y = config_setting_get_float(pSetting);
|
|
};
|
|
pSetting = config_setting_get_member(m_pSettings, TAG_POSITION_PITCH );
|
|
if (pSetting == NULL){
|
|
rot_x = 0.f;
|
|
pSetting = config_setting_add(m_pSettings, TAG_POSITION_PITCH, CONFIG_TYPE_FLOAT );
|
|
config_setting_set_float(pSetting, rot_x);
|
|
basicSettingsProvider::getInstance()->compromise();
|
|
} else {
|
|
rot_x = config_setting_get_float(pSetting);
|
|
};
|
|
pSetting = config_setting_get_member(m_pSettings, TAG_POSITION_YAW );
|
|
if (pSetting == NULL){
|
|
rot_z = 0.f;
|
|
pSetting = config_setting_add(m_pSettings, TAG_POSITION_YAW, CONFIG_TYPE_FLOAT );
|
|
config_setting_set_float(pSetting, rot_z);
|
|
basicSettingsProvider::getInstance()->compromise();
|
|
} else {
|
|
rot_z = config_setting_get_float(pSetting);
|
|
};
|
|
*/
|
|
coordConverter CC;
|
|
#ifdef FLOAT_64
|
|
double A, B;
|
|
utmZone = CC.LatLonToUTMXY( lat, lon, 0 , A, B );
|
|
x = A;
|
|
y = B;
|
|
#else
|
|
utmZone = CC.LatLonToUTMXY(lat, lon, 0, x, y);
|
|
#endif
|
|
basicSettingsProvider::getInstance()->validate();
|
|
};
|
|
};
|
|
|
|
systemAnchor::~systemAnchor(){
|
|
config_setting_t *pSetting;
|
|
C3D_FLOAT tVal;
|
|
|
|
m_pSettings = NULL;
|
|
pSetting = basicSettingsProvider::getInstance()->getSubNode( NULL, "APPLICATION_GUI" );
|
|
if( pSetting != NULL ){
|
|
m_pSettings = basicSettingsProvider::getInstance()->getSubNode( pSetting, "SYSTEM_ANCHOR" );
|
|
};
|
|
// Read Config
|
|
if( m_pSettings != NULL ){
|
|
pSetting = config_setting_get_member(m_pSettings, TAG_POSITION_LAT);
|
|
if (pSetting == NULL){
|
|
pSetting = config_setting_add(m_pSettings, TAG_POSITION_LAT, CONFIG_TYPE_FLOAT );
|
|
config_setting_set_float(pSetting, lat );
|
|
basicSettingsProvider::getInstance()->compromise();
|
|
} else {
|
|
tVal = config_setting_get_float(pSetting);
|
|
if( lat != tVal ){
|
|
config_setting_set_float(pSetting, lat );
|
|
basicSettingsProvider::getInstance()->compromise();
|
|
};
|
|
};
|
|
pSetting = config_setting_get_member(m_pSettings, TAG_POSITION_LON);
|
|
if (pSetting == NULL){
|
|
pSetting = config_setting_add(m_pSettings, TAG_POSITION_LON, CONFIG_TYPE_FLOAT );
|
|
config_setting_set_float(pSetting, lon );
|
|
basicSettingsProvider::getInstance()->compromise();
|
|
} else {
|
|
tVal = config_setting_get_float(pSetting);
|
|
if( lon != tVal ){
|
|
config_setting_set_float(pSetting, lon );
|
|
basicSettingsProvider::getInstance()->compromise();
|
|
};
|
|
};
|
|
pSetting = config_setting_get_member(m_pSettings, TAG_POSITION_ALT);
|
|
if (pSetting == NULL){
|
|
pSetting = config_setting_add(m_pSettings, TAG_POSITION_ALT, CONFIG_TYPE_FLOAT );
|
|
config_setting_set_float(pSetting, z );
|
|
basicSettingsProvider::getInstance()->compromise();
|
|
} else {
|
|
tVal = config_setting_get_float(pSetting);
|
|
if( z != tVal ){
|
|
config_setting_set_float(pSetting, z );
|
|
basicSettingsProvider::getInstance()->compromise();
|
|
};
|
|
};
|
|
/*
|
|
pSetting = config_setting_get_member(m_pSettings, TAG_POSITION_ROLL);
|
|
if (pSetting == NULL){
|
|
pSetting = config_setting_add(m_pSettings, TAG_POSITION_ROLL, CONFIG_TYPE_FLOAT );
|
|
config_setting_set_float(pSetting, rot_y );
|
|
basicSettingsProvider::getInstance()->compromise();
|
|
} else {
|
|
tVal = config_setting_get_float(pSetting);
|
|
if (rot_y != tVal){
|
|
config_setting_set_float(pSetting, rot_y);
|
|
basicSettingsProvider::getInstance()->compromise();
|
|
};
|
|
};
|
|
pSetting = config_setting_get_member(m_pSettings, TAG_POSITION_PITCH);
|
|
if (pSetting == NULL){
|
|
pSetting = config_setting_add(m_pSettings, TAG_POSITION_PITCH, CONFIG_TYPE_FLOAT );
|
|
config_setting_set_float(pSetting, rot_x);
|
|
basicSettingsProvider::getInstance()->compromise();
|
|
} else {
|
|
tVal = config_setting_get_float(pSetting);
|
|
if (rot_x != tVal){
|
|
config_setting_set_float(pSetting, rot_x);
|
|
basicSettingsProvider::getInstance()->compromise();
|
|
};
|
|
};
|
|
pSetting = config_setting_get_member(m_pSettings, TAG_POSITION_YAW);
|
|
if (pSetting == NULL){
|
|
pSetting = config_setting_add(m_pSettings, TAG_POSITION_YAW, CONFIG_TYPE_FLOAT );
|
|
config_setting_set_float(pSetting, rot_z);
|
|
basicSettingsProvider::getInstance()->compromise();
|
|
} else {
|
|
tVal = config_setting_get_float(pSetting);
|
|
if (rot_z != tVal){
|
|
config_setting_set_float(pSetting, rot_z);
|
|
basicSettingsProvider::getInstance()->compromise();
|
|
};
|
|
};
|
|
*/
|
|
basicSettingsProvider::getInstance()->validate();
|
|
};
|
|
|
|
};
|