Skip to content
Snippets Groups Projects
Commit f6c0ce23 authored by Paul Beuchat's avatar Paul Beuchat
Browse files

Added first draft of simulation to CS1 GUI

parent 005c044c
No related branches found
No related tags found
No related merge requests found
......@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>2417</width>
<width>3197</width>
<height>1336</height>
</rect>
</property>
......@@ -421,6 +421,22 @@
<property name="rightMargin">
<number>0</number>
</property>
<item row="0" column="8">
<widget class="QLabel" name="label_simulation">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Simulation</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="label_time_delay">
<property name="font">
......@@ -437,7 +453,7 @@
</property>
</widget>
</item>
<item row="1" column="8">
<item row="1" column="10">
<layout class="QGridLayout" name="gridLayout_8">
<item row="2" column="0">
<widget class="QPushButton" name="reset_integrator_button">
......@@ -495,7 +511,7 @@
</item>
</layout>
</item>
<item row="0" column="7">
<item row="0" column="9">
<spacer name="horizontalSpacer_7">
<property name="orientation">
<enum>Qt::Horizontal</enum>
......@@ -543,7 +559,7 @@
</property>
</widget>
</item>
<item row="0" column="10">
<item row="0" column="12">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
......@@ -592,7 +608,7 @@
</font>
</property>
<property name="text">
<string>0.1</string>
<string>0.10</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
......@@ -641,7 +657,7 @@
</property>
<property name="maximumSize">
<size>
<width>180</width>
<width>240</width>
<height>60</height>
</size>
</property>
......@@ -651,7 +667,7 @@
</font>
</property>
<property name="text">
<string>0.016</string>
<string>0.0160</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
......@@ -922,7 +938,7 @@
</font>
</property>
<property name="text">
<string>0.2</string>
<string>0.5</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
......@@ -1028,7 +1044,7 @@
</property>
</widget>
</item>
<item row="0" column="8">
<item row="0" column="10">
<widget class="QLabel" name="label_integrator">
<property name="font">
<font>
......@@ -1044,7 +1060,7 @@
</property>
</widget>
</item>
<item row="0" column="9">
<item row="0" column="11">
<spacer name="horizontalSpacer_8">
<property name="orientation">
<enum>Qt::Horizontal</enum>
......@@ -1123,6 +1139,80 @@
</item>
</layout>
</item>
<item row="0" column="7">
<spacer name="horizontalSpacer_simulation">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>100</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="8">
<layout class="QGridLayout" name="gridLayout_10">
<item row="2" column="0">
<widget class="QPushButton" name="clear_simulation_button">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>1000</width>
<height>60</height>
</size>
</property>
<property name="text">
<string>Clear</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="simulate_step_response_button">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>1000</width>
<height>60</height>
</size>
</property>
<property name="text">
<string>Perform</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_simulation_blank">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item row="7" column="0">
......@@ -1167,15 +1257,28 @@
<tabstop>lineEdit_k</tabstop>
<tabstop>lineEdit_T</tabstop>
<tabstop>lineEdit_alpha</tabstop>
<tabstop>lineEdit_time_delay</tabstop>
<tabstop>lineEdit_kp</tabstop>
<tabstop>lineEdit_kd</tabstop>
<tabstop>lineEdit_step_size</tabstop>
<tabstop>lineEdit_step_duration</tabstop>
<tabstop>set_lead_compensator_parameters_button</tabstop>
<tabstop>set_time_delay_button</tabstop>
<tabstop>set_pd_controller_parameters_button</tabstop>
<tabstop>perform_step_button</tabstop>
<tabstop>log_data_button</tabstop>
<tabstop>simulate_step_response_button</tabstop>
<tabstop>clear_simulation_button</tabstop>
<tabstop>toggle_integrator_button</tabstop>
<tabstop>reset_integrator_button</tabstop>
<tabstop>lineEdit_rise_time</tabstop>
<tabstop>lineEdit_settling_time</tabstop>
<tabstop>lineEdit_step_end</tabstop>
<tabstop>lineEdit_step_start</tabstop>
<tabstop>chartView_for_x</tabstop>
<tabstop>chartView_for_pitch</tabstop>
<tabstop>lineEdit_overshoot_value</tabstop>
<tabstop>lineEdit_overshoot_percent</tabstop>
</tabstops>
<resources/>
<connections/>
......
......@@ -59,6 +59,8 @@
// For the chart:
#include <QChart>
#include <QLineSeries>
#include <QList>
#include <QPointF>
using namespace QtCharts;
#ifdef CATKIN_MAKE
......@@ -118,6 +120,9 @@ public slots:
private slots:
float validate_and_get_value_from_lineEdit(QLineEdit * lineEdit, float min, float max, int decimals, float default_value);
void newDataForPerformingStepAndPlotting(float x, float pitch);
void analyseStepResponse();
void updateStepAnalysisLineEdit(float value, QLineEdit * lineEdit, int num_dec_places);
......@@ -126,6 +131,9 @@ private slots:
void on_perform_step_button_clicked();
void on_log_data_button_clicked();
void on_simulate_step_response_button_clicked();
void on_clear_simulation_button_clicked();
void on_set_lead_compensator_parameters_button_clicked();
void on_set_time_delay_button_clicked();
......@@ -142,10 +150,17 @@ private slots:
void on_lineEdit_step_size_returnPressed();
void on_lineEdit_step_duration_returnPressed();
void on_lineEdit_k_editingFinished();
void on_lineEdit_T_editingFinished();
void on_lineEdit_alpha_editingFinished();
void on_lineEdit_step_size_editingFinished();
void on_lineEdit_step_duration_editingFinished();
void simulate_step_response();
private:
Ui::CsoneControllerTab *ui;
......@@ -171,6 +186,9 @@ private:
float m_current_setpoint_z = 0.4;
float m_current_setpoint_yaw = 0.0;
// > Mutex for serialising acess to the controller variables
QMutex m_controller_parameter_mutex;
// FOR PLOTTING DATA ON THE CHART
// > Mutex for serialising acess to any charting variable
QMutex m_chart_mutex;
......@@ -183,7 +201,7 @@ private:
// > Time (as a float) for the horizontal axis
float m_time_for_step = 0.0f;
// > The duration for which to record the step
float m_step_response_data_recording_duration = 20.0f;
float m_step_response_data_recording_duration = 10.0f;
// > Line Series for the x position data
QLineSeries *m_lineSeries_for_setpoint_x;
QLineSeries *m_lineSeries_for_measured_x;
......@@ -192,6 +210,28 @@ private:
QLineSeries *m_lineSeries_for_measured_pitch;
// FOR SIMULATING THE CONTROLLER
// > Mutex for serialising acess to any simulation variables
QMutex m_simulation_mutex;
// Flag for whether a simulation is under way
bool m_simulationIsInProgress = false;
// The state space matrices of lead compensator controller
float m_lead_compensator_A=0.987578;
float m_lead_compensator_B=0.00496888;
float m_lead_compensator_C=-0.36;
float m_lead_compensator_D=0.16;
// The state of lead compensator controller
float m_lead_compensator_state = 0.0;
// Line Series for plotting the simulation results
QLineSeries *m_lineSeries_for_sim_setpoint_x;
QLineSeries *m_lineSeries_for_sim_measured_x;
QLineSeries *m_lineSeries_for_sim_measured_pitch;
#ifdef CATKIN_MAKE
// PUBLISHER
......@@ -248,6 +288,8 @@ private:
void publishRequestForTimeDelayChange(int time_delay_to_publish);
void convertIntoDiscreteTimeParameters(float k, float T, float alpha);
};
#endif // CSONECONTROLLERTAB_H
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment