stdr_robot_visualization.cpp
Go to the documentation of this file.
1 /******************************************************************************
2  STDR Simulator - Simple Two DImensional Robot Simulator
3  Copyright (C) 2013 STDR Simulator
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 3 of the License, or
7  (at your option) any later version.
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  GNU General Public License for more details.
12  You should have received a copy of the GNU General Public License
13  along with this program; if not, write to the Free Software Foundation,
14  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15 
16  Authors :
17  * Manos Tsardoulias, etsardou@gmail.com
18  * Aris Thallas, aris.thallas@gmail.com
19  * Chris Zalidis, zalidis@gmail.com
20 ******************************************************************************/
21 
23 
24 namespace stdr_gui
25 {
32  CRobotVisualisation::CRobotVisualisation(QString name,float resolution):
33  name_(name),
34  resolution_(resolution)
35  {
36  setupUi(this);
37  setWindowTitle(name_);
38  active_ = true;
39 
40  void_image_ = QImage(
41  robotImage->width(),
42  robotImage->height(),
43  QImage::Format_RGB32);
44 
45  void_image_.fill(QColor(255,255,255,255));
46  }
47 
53  {
54 
55  }
56 
62  {
63  active_ = false;
64  hide();
65  delete robotImage;
66  delete robotPose;
67  delete robotSpeeds;
68  }
69 
75  void CRobotVisualisation::closeEvent(QCloseEvent *event)
76  {
77  destruct();
78  active_ = false;
79  }
80 
86  {
87  return active_;
88  }
89 
96  {
97  internal_image_ = img;
98  robotImage->setPixmap(
99  QPixmap().fromImage(internal_image_.mirrored(false,true)));
100  }
101 
107  void CRobotVisualisation::setCurrentPose(geometry_msgs::Pose2D pose)
108  {
109  robotPoseX->setText(
110  QString("\tx = ") + QString().setNum(pose.x) + QString(" m"));
111  robotPoseY->setText(
112  QString("\ty = ") + QString().setNum(pose.y) + QString(" m"));
113  robotPoseTheta->setText(
114  QString("\ttheta = ") + QString().setNum(pose.theta) + QString(" rad"));
115  }
116 
122  void CRobotVisualisation::setCurrentSpeed(std::vector<float> msg)
123  {
124  robotSpeedLinear->setText(
125  QString("\tu_x = ") + QString().setNum(msg[0]) + QString(" m/s"));
126  robotSpeedLinearY->setText(
127  QString("\tu_y = ") + QString().setNum(msg[1]) + QString(" m/s"));
128  robotSpeedAngular->setText(
129  QString("\tw = ") + QString().setNum(msg[2]) + QString(" rad/s"));
130  }
131 }
bool getActive(void)
Returns true if the visualizer is active.
void setCurrentSpeed(std::vector< float > msg)
Sets the robot&#39;s current speed.
void setCurrentPose(geometry_msgs::Pose2D pose)
Sets the robot&#39;s current pose.
void closeEvent(QCloseEvent *event)
Called when the close event is triggered.
QImage void_image_
The robot frame id.
void setImage(QImage img)
Sets the image to be shown.
CRobotVisualisation(QString name, float resolution)
Default contructor.
bool active_
< True if the visualizer is active
The main namespace for STDR GUI.
void destruct(void)
Destroys the visualizer.
~CRobotVisualisation(void)
Default destructor.


stdr_gui
Author(s): Manos Tsardoulias
autogenerated on Mon Jun 10 2019 15:15:17