UAV Simulator
Loading...
Searching...
No Matches
simviewer.h
Go to the documentation of this file.
1/********************************************************************
2 * @file simviewer.h
3 * @brief Header for SimViewer, an extended Easy3D viewer with ImGui and aircraft rendering support.
4 *
5 * This class provides an interface for integrating an Aircraft object
6 * and rendering it with GUI controls using ImGui.
7 ********************************************************************/
8#ifndef SIMVIEWER_H
9#define SIMVIEWER_H
10
11#include <easy3d/viewer/viewer.h>
12#include "viewer_imgui.h"
13#include <implot.h>
14#include <easy3d/renderer/text_renderer.h>
15#include <easy3d/renderer/shadow.h>
16#include <aircraft/aircraft.h>
17#include <gnc/gnc.h>
26{
27public:
32 SimViewer(const std::string& title);
36 ~SimViewer() override;
41 void setAircraft(Aircraft* aircraft);
46 void setGNC(GNC* gnc);
47
48protected:
53 void draw() const override;
60 bool key_press_event(int key, int modifiers) override;
61
62 //From ImGui
66 void pre_draw() override;
70 void post_draw() override;
71
72private:
73 easy3d::TextRenderer* text_renderer_;
74 Aircraft* aircraft_ = nullptr;
75 GNC* gnc_ = nullptr;
76
77 // === GUI state flags ===
78 bool show_controls_ = true;
79
80 // For real-time plotting
81 std::vector<float> time_data_;
82 std::vector<std::vector<float>> state_data_ = std::vector<std::vector<float>>(18);
83 float plot_time_ = 0.0f;
84
85 // === NEW: Analysis Tab ===
89 void drawAnalysisTabs() const;
90
96 void DisplayMatrix(const std::string& name, const Eigen::MatrixXd& M) const;
97
98};
99
100
101
102
103
104#endif
Declaration of the Aircraft class for the UAV Simulator.
Represents a fixed‑wing UAV including its dynamics and 3D rendering.
Definition aircraft.h:41
Guidance, Navigation, and Control system for the aircraft.
Definition gnc.h:21
Specialized Easy3D viewer class for UAV simulation with GUI integration.
Definition simviewer.h:26
bool key_press_event(int key, int modifiers) override
Key press event handler.
Definition simviewer.cpp:62
void setGNC(GNC *gnc)
Sets the GNC object for displaying trim and linearisation results.
Definition simviewer.cpp:436
void post_draw() override
Called after rendering each frame (for ImGui overlays).
Definition simviewer.cpp:114
std::vector< std::vector< float > > state_data_
Definition simviewer.h:82
~SimViewer() override
Destructor.
Definition simviewer.cpp:28
Aircraft * aircraft_
Pointer to the Aircraft object for simulation.
Definition simviewer.h:74
easy3d::TextRenderer * text_renderer_
Renders on-screen text such as FPS or labels.
Definition simviewer.h:73
bool show_controls_
If true, display control panel in ImGui.
Definition simviewer.h:78
float plot_time_
Definition simviewer.h:83
GNC * gnc_
Pointer to the GNC object for analysis data (NEW)
Definition simviewer.h:75
void pre_draw() override
Called before rendering each frame (for ImGui setup).
Definition simviewer.cpp:276
void setAircraft(Aircraft *aircraft)
Sets the aircraft to be displayed in the viewer.
Definition simviewer.cpp:37
void DisplayMatrix(const std::string &name, const Eigen::MatrixXd &M) const
Utility function to display Eigen matrices in ImGui.
Definition simviewer.cpp:417
std::vector< float > time_data_
Definition simviewer.h:81
void draw() const override
Custom draw function called every frame. Handles rendering of the aircraft and any overlays.
Definition simviewer.cpp:42
void drawAnalysisTabs() const
Draws the Analysis tab with trim and linearisation results.
Definition simviewer.cpp:292
An Easy3D viewer with ImGui GUI support for custom rendering and input.
Definition viewer_imgui.h:33
Header file for the Guidance, Navigation, and Control (GNC) system.