display.hpp
Go to the documentation of this file.
1 
9 #ifndef QTCTRL_DISPLAY
10 #define QTCTRL_DISPLAY
11 
12 #include <QWidget>
13 #include <QLabel>
14 #include <QCloseEvent>
15 #include <model/ROS_node.hpp>
16 #include <gui/overview.hpp>
17 
18 
25 class DataWidget : public QWidget {
26  Q_OBJECT // This macro is needed to handle graphical events
27 
28  QPointF last_vel;
29  std::ofstream *output;
30 
33  enum Labels {
40  vCmd,
45  };
46 
49  static const char *names[];
50 
53  QLabel labels[nbLabels];
54 
58 
69  void setLabels(const Labels& offset, const Labels& nbData,
70  const double *data);
71 
74  bool outputOK() const
75  { return (output != NULL) && ( output->is_open() ); }
76 
78  void outputEnd()
79  { if ( outputOK() ) { output->close(); delete output; } }
80 
81 public:
87  DataWidget(QWidget& parent);
88 
92 
95  void setOutput(const char* output_file_name) {
96  outputEnd(); // if the stream was open, close it...
97  output = new std::ofstream(output_file_name);
98  if ( outputOK() ) // Write header line in the ouput stream
99  for(int idx = 0; idx < nbLabels; idx++)
100  *output << names[idx] << (idx < nbLabels - 1 ? '\t' : '\n');
101  }
102 
105  void updateState(const State& state);
106 
111  void updateCommands(const double& trans_vel, const double& rot_vel);
112 
116  void addTrajectory(const std::list<State*>& trajectory)
117  { motion_GUI.addTrajectory(trajectory); }
118 
121  void newTrajectory() { motion_GUI.clear(); }
122 
123 }; // end of class DataWidget
124 
125 #endif // QTCTRL_DISPLAY
Index of the odometry&#39;s translation velocity.
Definition: display.hpp:38
ROS communication node.
void updateState(const State &state)
Update the display of the state.
Definition: display.cpp:85
Number of commands indexes.
Definition: display.hpp:44
void setOutput(const char *output_file_name)
Change the output stream to a new file.
Definition: display.hpp:95
Index of the odometry&#39;s time.
Definition: display.hpp:34
QPointF last_vel
The last command published.
Definition: display.hpp:28
std::ofstream * output
The output stream, if any.
Definition: display.hpp:29
Index of the odometry&#39;s position abscissa.
Definition: display.hpp:35
This class shows the motion of the robot.
Definition: overview.hpp:24
DataWidget(QWidget &parent)
The constructor needs the ROS node whose data will be displayed.
Definition: display.cpp:25
Index of the commands&#39; rotation velocity.
Definition: display.hpp:41
void newTrajectory()
Clears the motion display.
Definition: display.hpp:121
void addTrajectory(const std::list< State * > &trajectory)
Definition: overview.cpp:29
Number of labels in the array.
Definition: display.hpp:42
bool outputOK() const
Is the output stream OK for writting?
Definition: display.hpp:74
Labels
These are the indexes of the array of labels.
Definition: display.hpp:33
Index of the odometry&#39;s orientation.
Definition: display.hpp:37
This class defines a state, i.e. a configuration and its (translation and rotation) velocities...
Definition: state.hpp:22
QLabel labels[nbLabels]
Array of labels displaying controller&#39;s data.
Definition: display.hpp:53
void setLabels(const Labels &offset, const Labels &nbData, const double *data)
Transfer data into the labels.
Definition: display.cpp:69
static const char * names[]
Labels shown before the values, and headers in the ouput file.
Definition: display.hpp:49
Index of the odometry&#39;s position ordinate.
Definition: display.hpp:36
QtMotionGUI motion_GUI
Window showing the motion&#39;s path and velocities.
Definition: display.hpp:57
This class is a Qt widget which displays the data (odometry and commands) of the controller.
Definition: display.hpp:25
void clear()
Definition: overview.cpp:80
Index of the commands&#39; translation velocity.
Definition: display.hpp:40
void updateCommands(const double &trans_vel, const double &rot_vel)
Update the display of the controller&#39;s commands.
Definition: display.cpp:105
~DataWidget()
The destructor closes the output stream, if any.
Definition: display.hpp:91
void outputEnd()
Close and terminate the output stream.
Definition: display.hpp:78
Index of the odometry&#39;s rotation velocity.
Definition: display.hpp:39
Number of odometry indexes.
Definition: display.hpp:43
void addTrajectory(const std::list< State * > &trajectory)
Adds a trajectory to the motion display.
Definition: display.hpp:116
Qt based overview of the robot&#39;s motion.


qt_ctrl
Author(s): Alexis Scheuer
autogenerated on Wed Dec 16 2020 15:51:32