stdr_robot_visualization.cpp
Go to the documentation of this file.
00001 /******************************************************************************
00002    STDR Simulator - Simple Two DImensional Robot Simulator
00003    Copyright (C) 2013 STDR Simulator
00004    This program is free software; you can redistribute it and/or modify
00005    it under the terms of the GNU General Public License as published by
00006    the Free Software Foundation; either version 3 of the License, or
00007    (at your option) any later version.
00008    This program is distributed in the hope that it will be useful,
00009    but WITHOUT ANY WARRANTY; without even the implied warranty of
00010    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011    GNU General Public License for more details.
00012    You should have received a copy of the GNU General Public License
00013    along with this program; if not, write to the Free Software Foundation,
00014    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
00015    
00016    Authors : 
00017    * Manos Tsardoulias, etsardou@gmail.com
00018    * Aris Thallas, aris.thallas@gmail.com
00019    * Chris Zalidis, zalidis@gmail.com 
00020 ******************************************************************************/
00021 
00022 #include "stdr_gui/stdr_visualization/stdr_robot_visualization.h"
00023 
00024 namespace stdr_gui
00025 {
00032   CRobotVisualisation::CRobotVisualisation(QString name,float resolution):
00033     name_(name),
00034     resolution_(resolution)
00035   {
00036     setupUi(this);
00037     setWindowTitle(name_);
00038     active_ = true;
00039     
00040     void_image_ = QImage(
00041       robotImage->width(),
00042       robotImage->height(),
00043       QImage::Format_RGB32);
00044       
00045     void_image_.fill(QColor(255,255,255,255));
00046   }
00047   
00052   CRobotVisualisation::~CRobotVisualisation(void)
00053   {
00054     
00055   }
00056   
00061   void CRobotVisualisation::destruct(void)
00062   {
00063     active_ = false;
00064     hide();
00065     delete robotImage;
00066     delete robotPose;
00067     delete robotSpeeds;
00068   }
00069   
00075   void CRobotVisualisation::closeEvent(QCloseEvent *event)
00076   {
00077     destruct();
00078     active_ = false;
00079   }
00080   
00085   bool CRobotVisualisation::getActive(void)
00086   {
00087     return active_;
00088   }
00089 
00095   void CRobotVisualisation::setImage(QImage img)
00096   {
00097     internal_image_ = img;
00098     robotImage->setPixmap(
00099       QPixmap().fromImage(internal_image_.mirrored(false,true)));
00100   }
00101   
00107   void CRobotVisualisation::setCurrentPose(geometry_msgs::Pose2D pose)
00108   {
00109     robotPoseX->setText(
00110       QString("\tx = ") + QString().setNum(pose.x) + QString(" m"));
00111     robotPoseY->setText(
00112       QString("\ty = ") + QString().setNum(pose.y) + QString(" m"));
00113     robotPoseTheta->setText(
00114       QString("\ttheta = ") + QString().setNum(pose.theta) + QString(" rad"));
00115   }
00116   
00122   void CRobotVisualisation::setCurrentSpeed(std::pair<float,float> msg)
00123   {
00124     robotSpeedLinear->setText(
00125       QString("\tu = ") + QString().setNum(msg.first) + QString(" m/s"));
00126     robotSpeedAngular->setText(
00127       QString("\tw = ") + QString().setNum(msg.second) + QString(" rad/s"));
00128   }
00129 }


stdr_gui
Author(s): Manos Tsardoulias
autogenerated on Wed Sep 2 2015 03:36:45