Newer
Older
Lionel Heng
committed
///*=====================================================================
//
//QGroundControl Open Source Ground Control Station
//
//(c) 2009, 2010 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
//
//This file is part of the QGROUNDCONTROL project
//
// QGROUNDCONTROL is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// QGROUNDCONTROL is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
//
//======================================================================*/
/**
* @file
* @brief Definition of the class Pixhawk3DWidget.
*
* @author Lionel Heng <hengli@student.ethz.ch>
*
*/
#include "Pixhawk3DWidget.h"
#include <sstream>
#include <osg/Geode>
#include <osg/Image>
Lionel Heng
committed
#include <osg/LineWidth>
#include <osg/ShapeDrawable>
#include "PixhawkCheetahGeode.h"
#include "UASManager.h"
Lionel Heng
committed
Lionel Heng
committed
#include "QGC.h"
Lionel Heng
committed
#ifdef QGC_PROTOBUF_ENABLED
#include <tr1/memory>
#include <pixhawk.pb.h>
#endif
Lionel Heng
committed
Pixhawk3DWidget::Pixhawk3DWidget(QWidget* parent)
: Q3DWidget(parent)
, uas(NULL)
, mode(DEFAULT_MODE)
, selectedWpIndex(-1)
, displayGrid(true)
, displayTrail(false)
, displayImagery(true)
, displayWaypoints(true)
, displayRGBD2D(false)
, displayRGBD3D(true)
, enableRGBDColor(false)
, enableTarget(false)
, followCamera(true)
, lastRobotX(0.0f)
, lastRobotY(0.0f)
, lastRobotZ(0.0f)
Lionel Heng
committed
{
setCameraParams(2.0f, 30.0f, 0.01f, 10000.0f);
Lionel Heng
committed
init(15.0f);
// generate Pixhawk Cheetah model
vehicleModel = PixhawkCheetahGeode::instance();
egocentricMap->addChild(vehicleModel);
Lionel Heng
committed
// generate grid model
gridNode = createGrid();
rollingMap->addChild(gridNode);
// generate empty trail model
trailNode = createTrail();
rollingMap->addChild(trailNode);
// generate map model
mapNode = createMap();
rollingMap->addChild(mapNode);
Lionel Heng
committed
// generate waypoint model
Lionel Heng
committed
waypointGroupNode = new WaypointGroupNode;
waypointGroupNode->init();
rollingMap->addChild(waypointGroupNode);
Lionel Heng
committed
// generate target model
targetNode = createTarget();
rollingMap->addChild(targetNode);
Lionel Heng
committed
rgbd3DNode = createRGBD3D();
egocentricMap->addChild(rgbd3DNode);
Lionel Heng
committed
setupHUD();
// find available vehicle models in models folder
vehicleModels = findVehicleModels();
Lionel Heng
committed
buildLayout();
connect(UASManager::instance(), SIGNAL(activeUASSet(UASInterface*)),
this, SLOT(setActiveUAS(UASInterface*)));
}
Pixhawk3DWidget::~Pixhawk3DWidget()
{
}
/**
*
* @param uas the UAS/MAV to monitor/display with the HUD
*/
Lionel Heng
committed
void
Pixhawk3DWidget::setActiveUAS(UASInterface* uas)
Lionel Heng
committed
{
if (this->uas != NULL && this->uas != uas) {
Lionel Heng
committed
// Disconnect any previously connected active MAV
//disconnect(uas, SIGNAL(valueChanged(UASInterface*,QString,double,quint64)), this, SLOT(updateValue(UASInterface*,QString,double,quint64)));
}
this->uas = uas;
}
Lionel Heng
committed
void
Pixhawk3DWidget::selectFrame(QString text)
{
if (text.compare("Global") == 0) {
Lionel Heng
committed
frame = MAV_FRAME_GLOBAL;
} else if (text.compare("Local") == 0) {
Lionel Heng
committed
}
getPosition(lastRobotX, lastRobotY, lastRobotZ);
recenter();
}
Lionel Heng
committed
void
Pixhawk3DWidget::showGrid(int32_t state)
{
Lionel Heng
committed
displayGrid = true;
Lionel Heng
committed
displayGrid = false;
}
}
void
Pixhawk3DWidget::showTrail(int32_t state)
{
if (state == Qt::Checked) {
if (!displayTrail) {
Lionel Heng
committed
}
displayTrail = true;
Lionel Heng
committed
displayTrail = false;
}
}
void
Pixhawk3DWidget::showWaypoints(int state)
{
displayWaypoints = true;
displayWaypoints = false;
}
}
Lionel Heng
committed
void
Pixhawk3DWidget::selectMapSource(int index)
{
mapNode->setImageryType(static_cast<Imagery::ImageryType>(index));
hengli
committed
if (mapNode->getImageryType() == Imagery::BLANK_MAP) {
hengli
committed
displayImagery = false;
hengli
committed
displayImagery = true;
}
Lionel Heng
committed
}
void
Pixhawk3DWidget::selectVehicleModel(int index)
{
vehicleModel = vehicleModels.at(index);
Loading
Loading full blame...